X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=http.php;h=6c8f916412ef4127777fc836c1eb369b54ed5312;hp=b82e3d1dff7f44a705645552767510a3bef7198a;hb=9a3136a5bee66e1055ffb566373952b6054dd7bf;hpb=856f805c6cbb6e712c662214f3b5821442f808a0 diff --git a/http.php b/http.php index b82e3d1..6c8f916 100644 --- a/http.php +++ b/http.php @@ -78,11 +78,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(); } @@ -92,4 +95,11 @@ function redirect($url, $status = '302 Moved Temporarily', $message = '') { 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 +} + ?>