From c4f79b71351dd0d96f19f7c5629888d85a814c72 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 7 Apr 2010 11:31:50 +0200 Subject: Sitemap rewrite --- inc/actions.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'inc/actions.php') 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; @@ -586,6 +591,54 @@ function act_export($act){ return 'show'; } +/** + * Handle sitemap delivery + * + * @author Michael Hamann + */ +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' * -- cgit v1.2.3 From 2897eb23759202676f5447a72d7fe5eb68321ce3 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 26 Jun 2010 13:33:46 +0200 Subject: Transformed the sitemapper into a class This makes it possible to autoload the sitemapper when needed. --- inc/actions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 2d70ac8ed..12c4c595f 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -615,8 +615,7 @@ function act_sitemap($act) { // Check if sitemap file exists, otherwise create it if (!is_readable($sitemap)) { - require_once DOKU_INC.'inc/sitemap.php'; - sitemapGenerate(); + Sitemapper::generate(); } if (is_readable($sitemap)) { -- cgit v1.2.3 From eae17177de8f3f3580af5ea66d126aee0f23227f Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Wed, 22 Sep 2010 17:52:13 +0200 Subject: 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. --- inc/actions.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'inc/actions.php') 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; } -- cgit v1.2.3 From 4064e2d30906d01e696c5de106fd9ff356980a93 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:13:21 +0100 Subject: Handle do=check before ACL checking --- inc/actions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 9db7d5f24..7a6d2eb85 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -50,6 +50,12 @@ function act_dispatch(){ } } + //display some infos + if($ACT == 'check'){ + check(); + $ACT = 'show'; + } + //check permissions $ACT = act_permcheck($ACT); @@ -120,12 +126,6 @@ function act_dispatch(){ if(substr($ACT,0,7) == 'export_') $ACT = act_export($ACT); - //display some infos - if($ACT == 'check'){ - check(); - $ACT = 'show'; - } - //handle admin tasks if($ACT == 'admin'){ // retrieve admin plugin name from $_REQUEST['page'] -- cgit v1.2.3 From 85dcda20ffd82becbe69a7ca5d99e4b6fd99c9ea Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Sat, 20 Nov 2010 13:17:00 +0100 Subject: Send 403 header for permission denied screens when send404 is enabled --- inc/actions.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 7a6d2eb85..fb2ae452f 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -20,6 +20,7 @@ function act_dispatch(){ global $ID; global $QUERY; global $lang; + global $conf; $preact = $ACT; @@ -143,6 +144,10 @@ function act_dispatch(){ $ACT = act_permcheck($ACT); } // end event ACTION_ACT_PREPROCESS default action $evt->advise_after(); + // Make sure plugs can handle 'denied' + if($conf['send404'] && $ACT == 'denied') { + header('HTTP/1.0 403 Forbidden'); + } unset($evt); // when action 'show', the intial not 'show' and POST, do a redirect -- cgit v1.2.3 From e3776c06c37cc197709dac60892604dfea894ac2 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 29 Nov 2010 01:34:36 +0100 Subject: Remove enc=utf-8 in VIM modeline as it is not allowed in VIM 7.3 As of VIM 7.3 it is no longer possible to specify the encoding in the modeline. This gives an error message whenever such a file is opened, thus this commit removes the enc setting from the modeline. --- inc/actions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index fb2ae452f..d98382a3b 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -743,4 +743,4 @@ function subscription_handle_post(&$params) { $params = compact('target', 'style', 'data', 'action'); } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : -- cgit v1.2.3 From 03f008cd4edafbcb75d5f3b99bd3271caabed988 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 12 Dec 2010 19:48:29 +0100 Subject: Copy changes from ajax_lock to act_draftsave --- inc/actions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index d98382a3b..a4461d1ab 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -292,9 +292,10 @@ function act_draftsave($act){ global $conf; if($conf['usedraft'] && $_POST['wikitext']){ $draft = array('id' => $ID, - 'prefix' => $_POST['prefix'], + 'prefix' => substr($_POST['prefix'], 0, -1), 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], + 'date' => (int) $_POST['date'], 'date' => $_POST['date'], 'client' => $INFO['client'], ); -- cgit v1.2.3 From ec5906e60bfe61520ec062e6a89096988c218690 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 13 Dec 2010 15:52:57 +0100 Subject: Delete superfluous assignment created by the last commit --- inc/actions.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index a4461d1ab..0297f6e56 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -296,7 +296,6 @@ function act_draftsave($act){ 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], 'date' => (int) $_POST['date'], - 'date' => $_POST['date'], 'client' => $INFO['client'], ); $cname = getCacheName($draft['client'].$ID,'.draft'); -- cgit v1.2.3 From 4c36bf829933f31b2adfa813cd61b9b895e31469 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Mon, 3 Jan 2011 14:46:03 +0100 Subject: Change sitemap filename to sitemap.xml(.gz). Closes FS#2127 --- inc/actions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 0297f6e56..016af4aea 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -626,6 +626,7 @@ function act_sitemap($act) { if (is_readable($sitemap)) { // Send headers header('Content-Type: '.$mime); + header('Content-Disposition: attachment; filename='.basename($sitemap)); http_conditionalRequest(filemtime($sitemap)); -- cgit v1.2.3 From bd07158f0f2569ae470f980dd49d69b7f1fd2c49 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Tue, 22 Feb 2011 23:11:13 +0000 Subject: deleted redundant line --- inc/actions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 016af4aea..321d928b3 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -244,7 +244,6 @@ function act_permcheck($act){ $permneed = AUTH_CREATE; } }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; @@ -610,7 +609,7 @@ function act_sitemap($act) { print "Sitemap generation is disabled."; exit; } - + $sitemap = Sitemapper::getFilePath(); if(strrchr($sitemap, '.') === '.gz'){ $mime = 'application/x-gzip'; -- cgit v1.2.3 From 24ea6500cc5285aac7f02df7f535ea10f8f97729 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 4 Mar 2011 20:29:24 +0100 Subject: check manager/admin role earlier for admin plugins FS#2180 --- inc/actions.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'inc/actions.php') diff --git a/inc/actions.php b/inc/actions.php index 321d928b3..fa11bb7f1 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -18,6 +18,7 @@ if(!defined('DOKU_INC')) die('meh.'); function act_dispatch(){ global $ACT; global $ID; + global $INFO; global $QUERY; global $lang; global $conf; @@ -134,8 +135,15 @@ function act_dispatch(){ $pluginlist = plugin_list('admin'); if (in_array($_REQUEST['page'], $pluginlist)) { // attempt to load the plugin - if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== null) - $plugin->handle(); + if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== null){ + if($plugin->forAdminOnly() && !$INFO['isadmin']){ + // a manager tried to load a plugin that's for admins only + unset($_REQUEST['page']); + msg('For admins only',-1); + }else{ + $plugin->handle(); + } + } } } } -- cgit v1.2.3