X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=functions%2Fglobal.php;h=be2e1a2eba9b3c17a6ee540b5bcf177c456edfca;hb=c53195bbbf00d53343b5b33c35f43f75bb2646a9;hp=1883494a0a04fafd97441ad1b40a378e9e997495;hpb=c3d4275eae0b920a3d25a2d3ec57117693c37fc5;p=squirrelmail.git diff --git a/functions/global.php b/functions/global.php index 1883494a..be2e1a2e 100644 --- a/functions/global.php +++ b/functions/global.php @@ -7,7 +7,7 @@ * It also has some session register functions that work across various * php versions. * - * @copyright 1999-2016 The SquirrelMail Project Team + * @copyright 1999-2021 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ * @package squirrelmail @@ -697,9 +697,11 @@ if (!function_exists('session_regenerate_id')) { * @return string The path, filename and any arguments for the * current script */ -function php_self() { +function php_self($with_query_string=TRUE) { - $request_uri = ''; + static $request_uri = ''; + if (!empty($request_uri)) + return ($with_query_string ? $request_uri : (strpos($request_uri, '?') !== FALSE ? substr($request_uri, 0, strpos($request_uri, '?')) : $request_uri)); // first try $_SERVER['PHP_SELF'], which seems most reliable // (albeit it usually won't include the query string) @@ -733,7 +735,10 @@ function php_self() { $request_uri .= '?' . $query_string; } - return $request_uri; + global $php_self_pattern, $php_self_replacement; + if (!empty($php_self_pattern)) + $request_uri = preg_replace($php_self_pattern, $php_self_replacement, $request_uri); + return ($with_query_string ? $request_uri : (strpos($request_uri, '?') !== FALSE ? substr($request_uri, 0, strpos($request_uri, '?')) : $request_uri)); }