|
@@ -1,20 +1,12 @@
|
|
|
<?php
|
|
|
function convert_link($link) {
|
|
|
- if (isset($_SERVER["REQUEST_SCHEME"]))
|
|
|
- $scheme = $_SERVER["REQUEST_SCHEME"];
|
|
|
- elseif (isset($_SERVER["HTTPS"]))
|
|
|
- $scheme = "https";
|
|
|
- else
|
|
|
- $scheme = "http";
|
|
|
-
|
|
|
- $host = $_SERVER["HTTP_HOST"];
|
|
|
- $uri = $_SERVER["REQUEST_URI"];
|
|
|
-
|
|
|
- $base = $scheme . "://" . $host . preg_replace("/\/.*.php/", "/", strtok($uri, "?"));
|
|
|
-
|
|
|
- unset($scheme);
|
|
|
- unset($host);
|
|
|
- unset($uri);
|
|
|
+ if (! function_exists('str_ends_with')) {
|
|
|
+ function str_ends_with(string $haystack, string $needle): bool
|
|
|
+ {
|
|
|
+ $needle_len = strlen($needle);
|
|
|
+ return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
$host = parse_url($link, PHP_URL_HOST);
|
|
|
$path = ltrim(parse_url($link, PHP_URL_PATH), "/");
|
|
@@ -53,7 +45,7 @@
|
|
|
} else
|
|
|
return $link;
|
|
|
|
|
|
- return $base . $file . ".php?" . http_build_query($data);
|
|
|
+ return $file . ".php?" . http_build_query($data);
|
|
|
};
|
|
|
|
|
|
function prefix_link($link, $parameter) {
|