summaryrefslogtreecommitdiff
path: root/inc/actions.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2010-04-07 11:31:50 +0200
committerMichael Hamann <michael@content-space.de>2010-09-22 17:55:07 +0200
commitc4f79b71351dd0d96f19f7c5629888d85a814c72 (patch)
tree404b45b1606d3b9153faa3a16c8c9e56712e91da /inc/actions.php
parent42de51b18d302d07e109c24dfb0ae237e6d38643 (diff)
downloadrpg-c4f79b71351dd0d96f19f7c5629888d85a814c72.tar.gz
rpg-c4f79b71351dd0d96f19f7c5629888d85a814c72.tar.bz2
Sitemap rewrite
Diffstat (limited to 'inc/actions.php')
-rw-r--r--inc/actions.php57
1 files changed, 55 insertions, 2 deletions
diff --git a/inc/actions.php b/inc/actions.php
index 3e0cb1207..2d70ac8ed 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -56,6 +56,10 @@ function act_dispatch(){
//check permissions
$ACT = act_permcheck($ACT);
+ //sitemap
+ if ($ACT == 'sitemap')
+ $ACT = act_sitemap($ACT);
+
//register
$nil = array();
if($ACT == 'register' && $_POST['save'] && register()){
@@ -205,7 +209,7 @@ function act_clean($act){
'preview','search','show','check','index','revisions',
'diff','recent','backlink','admin','subscribe','revert',
'unsubscribe','profile','resendpwd','recover',
- 'draftdel','subscribens','unsubscribens',)) && substr($act,0,7) != 'export_' ) {
+ 'draftdel','subscribens','unsubscribens','sitemap')) && substr($act,0,7) != 'export_' ) {
msg('Command unknown: '.htmlspecialchars($act),-1);
return 'show';
}
@@ -233,7 +237,8 @@ function act_permcheck($act){
}else{
$permneed = AUTH_CREATE;
}
- }elseif(in_array($act,array('login','search','recent','profile','index'))){
+ }elseif(in_array($act,array('login','search','recent','profile','index', 'sitemap'))){
+ }elseif(in_array($act,array('login','search','recent','profile','sitemap'))){
$permneed = AUTH_NONE;
}elseif($act == 'revert'){
$permneed = AUTH_ADMIN;
@@ -587,6 +592,54 @@ function act_export($act){
}
/**
+ * Handle sitemap delivery
+ *
+ * @author Michael Hamann <michael@content-space.de>
+ */
+function act_sitemap($act) {
+ global $conf;
+
+ if (!$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'){
+ $mime = 'application/x-gzip';
+ $sitemap .= '.gz';
+ } else {
+ $mime = 'application/xml; charset=utf-8';
+ }
+
+ // Check if sitemap file exists, otherwise create it
+ if (!is_readable($sitemap)) {
+ require_once DOKU_INC.'inc/sitemap.php';
+ sitemapGenerate();
+ }
+
+ if (is_readable($sitemap)) {
+ // Send headers
+ header('Content-Type: '.$mime);
+
+ // 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;
+ }
+ }
+
+ header("HTTP/1.0 500 Internal Server Error");
+ print "Could not read $sitemap - bad permissions?";
+ exit;
+}
+
+/**
* Handle page 'subscribe'
*
* Throws exception on error.