summaryrefslogtreecommitdiff
path: root/inc/actions.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/actions.php')
-rw-r--r--inc/actions.php55
1 files changed, 53 insertions, 2 deletions
diff --git a/inc/actions.php b/inc/actions.php
index 0a6e6d8c7..9db7d5f24 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -53,6 +53,11 @@ function act_dispatch(){
//check permissions
$ACT = act_permcheck($ACT);
+ //sitemap
+ if ($ACT == 'sitemap'){
+ $ACT = act_sitemap($ACT);
+ }
+
//register
if($ACT == 'register' && $_POST['save'] && register()){
$ACT = 'login';
@@ -205,7 +210,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 +238,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 +593,51 @@ function act_export($act){
}
/**
+ * Handle sitemap delivery
+ *
+ * @author Michael Hamann <michael@content-space.de>
+ */
+function act_sitemap($act) {
+ global $conf;
+
+ if ($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) {
+ header("HTTP/1.0 404 Not Found");
+ print "Sitemap generation is disabled.";
+ exit;
+ }
+
+ $sitemap = Sitemapper::getFilePath();
+ if(strrchr($sitemap, '.') === '.gz'){
+ $mime = 'application/x-gzip';
+ }else{
+ $mime = 'application/xml; charset=utf-8';
+ }
+
+ // Check if sitemap file exists, otherwise create it
+ if (!is_readable($sitemap)) {
+ Sitemapper::generate();
+ }
+
+ if (is_readable($sitemap)) {
+ // 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;
+
+ readfile($sitemap);
+ exit;
+ }
+
+ header("HTTP/1.0 500 Internal Server Error");
+ print "Could not read the sitemap file - bad permissions?";
+ exit;
+}
+
+/**
* Handle page 'subscribe'
*
* Throws exception on error.