Rev 63 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 63 | Rev 85 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * PHP Utilities - Misc functions |
4 | * PHP Utilities - Misc functions |
5 | * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2023 Daniel Marschall, ViaThinkSoft |
6 | * Revision: 2023-02-27 |
6 | * Revision: 2023-08-01 |
7 | * |
7 | * |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | * you may not use this file except in compliance with the License. |
9 | * you may not use this file except in compliance with the License. |
10 | * You may obtain a copy of the License at |
10 | * You may obtain a copy of the License at |
11 | * |
11 | * |
Line 135... | Line 135... | ||
135 | } |
135 | } |
136 | return false; |
136 | return false; |
137 | } |
137 | } |
138 | 138 | ||
139 | function isInternetExplorer() { |
139 | function isInternetExplorer() { |
140 | // see also includes/oidplus_base.js |
- | |
141 | $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
140 | $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
142 | return ((strpos($ua,'MSIE ') !== false) || (strpos($ua,'Trident/') !== false)); |
141 | return ((strpos($ua,'MSIE ') !== false) || (strpos($ua,'Trident/') !== false)); |
143 | } |
142 | } |
144 | 143 | ||
- | 144 | if (!function_exists('str_starts_with')) { |
|
- | 145 | // PHP 7.x compatibility |
|
- | 146 | // source: Laravel Framework |
|
- | 147 | // https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Str.php |
|
- | 148 | function str_starts_with($haystack, $needle) { |
|
- | 149 | return (string)$needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0; |
|
- | 150 | } |
|
- | 151 | } |
|
- | 152 | ||
145 | if (!function_exists('str_ends_with')) { |
153 | if (!function_exists('str_ends_with')) { |
146 | // PHP 7.x compatibility |
154 | // PHP 7.x compatibility |
- | 155 | // source: Laravel Framework |
|
- | 156 | // https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Str.php |
|
147 | function str_ends_with($haystack, $needle) { |
157 | function str_ends_with($haystack, $needle) { |
148 | $length = strlen($needle); |
- | |
149 | return $length > 0 ? substr($haystack, -$length) === $needle : true; |
158 | return $needle !== '' && substr($haystack, -strlen($needle)) === (string)$needle; |
150 | } |
159 | } |
151 | } |
160 | } |
152 | 161 | ||
153 | if (!function_exists('str_starts_with')) { |
162 | if (!function_exists('str_contains')) { |
154 | // PHP 7.x compatibility |
163 | // PHP 7.x compatibility |
- | 164 | // source: Laravel Framework |
|
- | 165 | // https://github.com/laravel/framework/blob/8.x/src/Illuminate/Support/Str.php |
|
155 | function str_starts_with($haystack, $needle) { |
166 | function str_contains($haystack, $needle) { |
156 | return strpos($haystack, $needle) === 0; |
167 | return $needle !== '' && mb_strpos($haystack, $needle) !== false; |
157 | } |
168 | } |
158 | } |
169 | } |
159 | 170 | ||
160 | function random_bytes_ex($len, $raw=true, $force_cryptographically_secure=true) { |
171 | function random_bytes_ex($len, $raw=true, $force_cryptographically_secure=true) { |
161 | if ($len === 0) return ''; |
172 | if ($len === 0) return ''; |