diff options
author | Michael Hamann <michael@content-space.de> | 2010-09-22 17:52:13 +0200 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2010-09-22 17:55:07 +0200 |
commit | eae17177de8f3f3580af5ea66d126aee0f23227f (patch) | |
tree | 7dc2ce31cd343066f997cf433de898e4f3875e75 /inc/actions.php | |
parent | 6c062f5e5826443084fc996d18a7001b28624f78 (diff) | |
download | rpg-eae17177de8f3f3580af5ea66d126aee0f23227f.tar.gz rpg-eae17177de8f3f3580af5ea66d126aee0f23227f.tar.bz2 |
Action handler for sitemaps improved
The action handler for the sitemap now makes use of the sitemapper
methods for determining the filename and uses http conditional requests.
Diffstat (limited to 'inc/actions.php')
-rw-r--r-- | inc/actions.php | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/inc/actions.php b/inc/actions.php index 12c4c595f..78666ec98 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -57,8 +57,9 @@ function act_dispatch(){ $ACT = act_permcheck($ACT); //sitemap - if ($ACT == 'sitemap') + if ($ACT == 'sitemap'){ $ACT = act_sitemap($ACT); + } //register $nil = array(); @@ -599,17 +600,16 @@ function act_export($act){ function act_sitemap($act) { global $conf; - if (!$conf['sitemap']) { + if ($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) { header("HTTP/1.0 404 Not Found"); print "Sitemap generation is disabled."; exit; } - $sitemap = $conf['cachedir'].'/sitemap.xml'; - if($conf['compression'] == 'bz2' || $conf['compression'] == 'gz'){ + $sitemap = Sitemapper::getFilePath(); + if(strrchr($sitemap, '.') === '.gz'){ $mime = 'application/x-gzip'; - $sitemap .= '.gz'; - } else { + }else{ $mime = 'application/xml; charset=utf-8'; } @@ -622,19 +622,18 @@ function act_sitemap($act) { // Send headers header('Content-Type: '.$mime); + http_conditionalRequest(filemtime($sitemap)); + // Send file //use x-sendfile header to pass the delivery to compatible webservers if (http_sendfile($sitemap)) exit; - $fp = @fopen($sitemap,"rb"); - if($fp){ - http_rangeRequest($fp,filesize($sitemap),$mime); - exit; - } + readfile($sitemap); + exit; } header("HTTP/1.0 500 Internal Server Error"); - print "Could not read $sitemap - bad permissions?"; + print "Could not read the sitemap file - bad permissions?"; exit; } |