X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=http.php;h=b1f2aece64279389f230b001c66637a15d8e6244;hb=f58acc2fd5e5fbfb4a01d6b66711b2f62bf77c4a;hp=1abd50bc1757abe53f46ef77f95ba4734aa6770a;hpb=88edfcf26c7b4cdbd083dede0834de5cf6f16999;p=wfpl.git diff --git a/http.php b/http.php index 1abd50b..b1f2aec 100644 --- a/http.php +++ b/http.php @@ -1,24 +1,14 @@ . +# This program is in the public domain within the United States. Additionally, +# we waive copyright and related rights in the work worldwide through the CC0 +# 1.0 Universal public domain dedication, which can be found at +# http://creativecommons.org/publicdomain/zero/1.0/ # return our best guess at the url used to access this page, without the path or query string function this_url_sans_path() { - if(strtolower($_SERVER['HTTPS']) == 'on' || strtolower($_SERVER['HTTPS']) == 'yes') { + if (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) == 'on' || strtolower($_SERVER['HTTPS']) == 'yes')) { $url = 'https'; $expected_port = 443; } else { @@ -78,11 +68,14 @@ function redirect($url, $status = '302 Moved Temporarily', $message = '') { if(substr($url, 0, 1) == '/') { $url = this_url_sans_path() . $url; } else { - $url = ereg_replace('/[^/]*$', "/$url", this_url()); + $url = preg_replace('|/[^/]*$|', "/$url", this_url()); } } if(function_exists('session_save_messages')) { + if(function_exists('atexit_now')) { + atexit_now(); + } session_save_messages(); }