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/common.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index bf5987c28..0816d9fbb 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1266,6 +1266,21 @@ function dformat($dt=null,$format=''){ return strftime($format,$dt); } +/** + * Formats a timestamp as ISO 8601 date + * + * @author + * @link http://www.php.net/manual/en/function.date.php#54072 + */ +function date_iso8601($int_date) { + //$int_date: current date in UNIX timestamp + $date_mod = date('Y-m-d\TH:i:s', $int_date); + $pre_timezone = date('O', $int_date); + $time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2); + $date_mod .= $time_zone; + return $date_mod; +} + /** * return an obfuscated email address in line with $conf['mailguard'] setting * -- cgit v1.2.3 From 37c1acbdeda6af9ade16d4063188587ff924cd8d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Mon, 11 Oct 2010 11:24:26 +0200 Subject: Correctly handle non-default sepchars in page templates (FS#2057) --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 6af7f49de..3e760419f 100644 --- a/inc/common.php +++ b/inc/common.php @@ -843,7 +843,7 @@ function parsePageTemplate(&$data) { // replace placeholders $file = noNS($id); - $page = strtr($file,'_',' '); + $page = strtr($file, $conf['sepchar'], ' '); $tpl = str_replace(array( '@ID@', -- cgit v1.2.3 From 5ec3fefc5fc0983d6fdc0efdaed2e78e0d09a868 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 5 Nov 2010 11:18:31 +0100 Subject: handle mailfrom replacements in a central place FS#2091 --- inc/common.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 3e760419f..881179f4b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1134,12 +1134,7 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject; } - $from = $conf['mailfrom']; - $from = str_replace('@USER@',$_SERVER['REMOTE_USER'],$from); - $from = str_replace('@NAME@',$INFO['userinfo']['name'],$from); - $from = str_replace('@MAIL@',$INFO['userinfo']['mail'],$from); - - mail_send($to,$subject,$text,$from,'',$bcc); + mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc); } /** -- cgit v1.2.3 From 4871414204799044c31aa2764c4b4ca020e2331d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 26 Nov 2010 16:54:51 +0100 Subject: Fix for $conf['breadcrumbs'] < 0, FS#2107 This fixes an infinite loop in breadcrumbs() and makes the behaviors in all places where breadcrumbs are used consistent so that non-numeric values, values < 0 and 0 are treated the same way. --- inc/common.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 18f782788..667846804 100644 --- a/inc/common.php +++ b/inc/common.php @@ -268,6 +268,9 @@ function breadcrumbs(){ global $ACT; global $conf; + // Prevent infinite loop later in this function + if (!is_numeric($conf['breadcrumbs']) || $conf['breadcrumbs'] <= 0) return array(); + //first visit? $crumbs = isset($_SESSION[DOKU_COOKIE]['bc']) ? $_SESSION[DOKU_COOKIE]['bc'] : array(); //we only save on show and existing wiki documents -- 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/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 667846804..b6048825b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1541,4 +1541,4 @@ function valid_input_set($param, $valid_values, $array, $exc = '') { } } -//Setup VIM: ex: et ts=2 enc=utf-8 : +//Setup VIM: ex: et ts=2 : -- cgit v1.2.3 From 359fab8b2f7d0847ef0cf9b669e6c8ffb0687525 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 30 Nov 2010 18:34:10 +0100 Subject: Revert "Fix for $conf['breadcrumbs'] < 0, FS#2107", new fix This reverts commit 4871414204799044c31aa2764c4b4ca020e2331d. Additionally there is a new fix for FS#2107 that doesn't introduce a lot of checks but instead ensures that the configuration option can't be set to negative values when the configuration manager is used. --- inc/common.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index b6048825b..a1c4580a6 100644 --- a/inc/common.php +++ b/inc/common.php @@ -268,9 +268,6 @@ function breadcrumbs(){ global $ACT; global $conf; - // Prevent infinite loop later in this function - if (!is_numeric($conf['breadcrumbs']) || $conf['breadcrumbs'] <= 0) return array(); - //first visit? $crumbs = isset($_SESSION[DOKU_COOKIE]['bc']) ? $_SESSION[DOKU_COOKIE]['bc'] : array(); //we only save on show and existing wiki documents -- cgit v1.2.3 From 5526795c71a703486ddd19bf986e6a0cf7309945 Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Fri, 31 Dec 2010 15:46:43 +0100 Subject: Allow a prefix for subject of sent mails (Close FS#2021) --- inc/common.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index a1c4580a6..6ea6d56d8 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1128,12 +1128,15 @@ function notify($id,$who,$rev='',$summary='',$minor=false,$replace=array()){ $diff = rawWiki($id); } $text = str_replace('@DIFF@',$diff,$text); - if(utf8_strlen($conf['title']) < 20) { - $subject = '['.$conf['title'].'] '.$subject; + if(empty($conf['mailprefix'])) { + if(utf8_strlen($conf['title']) < 20) { + $subject = '['.$conf['title'].'] '.$subject; + }else{ + $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject; + } }else{ - $subject = '['.utf8_substr($conf['title'], 0, 20).'...] '.$subject; + $subject = '['.$conf['mailprefix'].'] '.$subject; } - mail_send($to,$subject,$text,$conf['mailfrom'],'',$bcc); } -- cgit v1.2.3 From 9063ec149f164f26e583c635f4fa29dcba23eb90 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 12 Jan 2011 13:09:23 +0100 Subject: Remove trailing whitespace in buildAttributes output --- inc/common.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 6ea6d56d8..b4866bccf 100644 --- a/inc/common.php +++ b/inc/common.php @@ -242,13 +242,16 @@ function buildURLparams($params, $sep='&'){ */ function buildAttributes($params,$skipempty=false){ $url = ''; + $white = false; foreach($params as $key => $val){ if($key{0} == '_') continue; if($val === '' && $skipempty) continue; + if($white) $url .= ' '; $url .= $key.'="'; $url .= htmlspecialchars ($val); - $url .= '" '; + $url .= '"'; + $white = true; } return $url; } -- cgit v1.2.3 From 7b84afa2e557a05fcd900a1cbf5715a6988828dc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 3 Feb 2011 16:12:32 +0100 Subject: Replace COMMON_PAGE_FROMTEMPLATE with COMMON_PAGETPL_LOAD event As discussed on the mailing list [1] this patch replaces the COMMON_PAGE_FROMTEMPLATE with a more flexible event to better intercept page template use. Plugin authors need to change their plugins. Details on the event are available at [2] [1] http://www.freelists.org/post/dokuwiki/COMMON-PAGE-FROMTEMPLATE-event [2] http://www.dokuwiki.org/devel:event:common_pagetpl_load --- inc/common.php | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index b4866bccf..eab5f1129 100644 --- a/inc/common.php +++ b/inc/common.php @@ -804,7 +804,7 @@ function rawWiki($id,$rev=''){ /** * Returns the pagetemplate contents for the ID's namespace * - * @triggers COMMON_PAGE_FROMTEMPLATE + * @triggers COMMON_PAGETPL_LOAD * @author Andreas Gohr */ function pageTemplate($id){ @@ -812,29 +812,50 @@ function pageTemplate($id){ if (is_array($id)) $id = $id[0]; - $path = dirname(wikiFN($id)); - $tpl = ''; - if(@file_exists($path.'/_template.txt')){ - $tpl = io_readFile($path.'/_template.txt'); - }else{ - // search upper namespaces for templates - $len = strlen(rtrim($conf['datadir'],'/')); - while (strlen($path) >= $len){ - if(@file_exists($path.'/__template.txt')){ - $tpl = io_readFile($path.'/__template.txt'); - break; + // prepare initial event data + $data = array( + 'id' => $id, // the id of the page to be created + 'tpl' => '', // the text used as template + 'tplfile' => '', // the file above text was/should be loaded from + 'doreplace' => true // should wildcard replacements be done on the text? + ); + + $evt = new Doku_Event('COMMON_PAGETPL_LOAD',$data); + if($evt->advise_before(true)){ + // the before event might have loaded the content already + if(empty($data['tpl'])){ + // if the before event did not set a template file, try to find one + if(empty($data['tplfile'])){ + $path = dirname(wikiFN($id)); + $tpl = ''; + if(@file_exists($path.'/_template.txt')){ + $data['tplfile'] = $path.'/_template.txt'; + }else{ + // search upper namespaces for templates + $len = strlen(rtrim($conf['datadir'],'/')); + while (strlen($path) >= $len){ + if(@file_exists($path.'/__template.txt')){ + $data['tplfile'] = $path.'/__template.txt'; + break; + } + $path = substr($path, 0, strrpos($path, '/')); + } + } } - $path = substr($path, 0, strrpos($path, '/')); + // load the content + $data['tpl'] = io_readFile($data['tpl']); } + if($data['doreplace']) parsePageTemplate(&$data); } - $data = compact('tpl', 'id'); - trigger_event('COMMON_PAGE_FROMTEMPLATE', $data, 'parsePageTemplate', true); + $evt->advise_after(); + unset($evt); + return $data['tpl']; } /** * Performs common page template replacements - * This is the default action for COMMON_PAGE_FROMTEMPLATE + * This works on data from COMMON_PAGETPL_LOAD * * @author Andreas Gohr */ -- cgit v1.2.3 From 2343a762fb62ebed6ef140bca2d8b5aa4fa2983d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 6 Feb 2011 12:44:16 +0100 Subject: handle link local and localhost IPv6 addresses in clientIP FS#2138 --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index eab5f1129..23d9c7155 100644 --- a/inc/common.php +++ b/inc/common.php @@ -639,7 +639,7 @@ function clientIP($single=false){ // decide which IP to use, trying to avoid local addresses $ip = array_reverse($ip); foreach($ip as $i){ - if(preg_match('/^(127\.|10\.|192\.168\.|172\.((1[6-9])|(2[0-9])|(3[0-1]))\.)/',$i)){ + if(preg_match('/^(::1|[fF][eE]80:|127\.|10\.|192\.168\.|172\.((1[6-9])|(2[0-9])|(3[0-1]))\.)/',$i)){ continue; }else{ return $i; -- cgit v1.2.3 From 3d7ac595bb629f3ee3bf26cefe9309e1d20d4470 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 7 Feb 2011 23:23:32 +0100 Subject: Fix namespace template loading (load $data['tplfile'] instead of $data['tpl']) --- inc/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 23d9c7155..ac7ddd653 100644 --- a/inc/common.php +++ b/inc/common.php @@ -843,7 +843,7 @@ function pageTemplate($id){ } } // load the content - $data['tpl'] = io_readFile($data['tpl']); + $data['tpl'] = io_readFile($data['tplfile']); } if($data['doreplace']) parsePageTemplate(&$data); } -- cgit v1.2.3