<?php
-# Copyright (C) 2005 Jason Woofenden
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# 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 {
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();
}
exit();
}
-?>
+# output http headers to allow caching of this page forever
+function http_cache_forever($cache_control = 'public') {
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', 5025) . ' GMT'); # long time ago
+ header("Cache-Control: $cache_control");
+ header('Expires: ' . gmdate('D, d M Y H:i:s',time()+31536000) . ' GMT'); # rfc 2616 says not to go more than a year in the future
+}