From f523c9718baf12a5bc99e2285bc0666796ab2a97 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 20 Nov 2013 13:36:22 +0100 Subject: update function calls to changelog functions --- inc/common.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 32771285b..dd30b53ab 100644 --- a/inc/common.php +++ b/inc/common.php @@ -187,13 +187,14 @@ function pageinfo() { $info['meta'] = p_get_metadata($ID); //who's the editor + $pagelog = new PageRevisionLog($ID, 1024); if($REV) { - $revinfo = getRevisionInfo($ID, $REV, 1024); + $revinfo = $pagelog->getRevisionInfo($REV); } else { if(is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { - $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); + $revinfo = $pagelog->getRevisionInfo($info['lastmod']); // cache most recent changelog line in metadata if missing and still valid if($revinfo !== false) { $info['meta']['last_change'] = $revinfo; @@ -1059,8 +1060,9 @@ function saveWikiText($id, $text, $summary, $minor = false) { $wasRemoved = (trim($text) == ''); // check for empty or whitespace only $wasCreated = !@file_exists($file); $wasReverted = ($REV == true); + $pagelog = new PageRevisionLog($id, 1024); $newRev = false; - $oldRev = getRevisions($id, -1, 1, 1024); // from changelog + $oldRev = $pagelog->getRevisions(-1, 1); // from changelog $oldRev = (int) (empty($oldRev) ? 0 : $oldRev[0]); if(!@file_exists(wikiFN($id, $old)) && @file_exists($file) && $old >= $oldRev) { // add old revision to the attic if missing -- cgit v1.2.3 From 5c2eed9a193e9341fbfee63d4a973898acdc5ee5 Mon Sep 17 00:00:00 2001 From: lisps Date: Thu, 21 Nov 2013 15:50:52 +0100 Subject: add parameter at($DATE_AT) and mind revisions --- 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 dd30b53ab..e5e4f78c8 100644 --- a/inc/common.php +++ b/inc/common.php @@ -161,7 +161,7 @@ function pageinfo() { if($REV) { //check if current revision was meant if($info['exists'] && (@filemtime($info['filepath']) == $REV)) { - $REV = ''; + //$REV = ''; //if we enter a rev we want to see that revision (inc media files) } elseif($RANGE) { //section editing does not work with old revisions! $REV = ''; -- cgit v1.2.3 From 047bad06fab8157452aa0dd04379a7c507b1f39f Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 21 Nov 2013 21:07:08 +0100 Subject: refactor PageRevisionLog into Media- and PageChangelog extending Changelog --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index dd30b53ab..7821cb3de 100644 --- a/inc/common.php +++ b/inc/common.php @@ -187,7 +187,7 @@ function pageinfo() { $info['meta'] = p_get_metadata($ID); //who's the editor - $pagelog = new PageRevisionLog($ID, 1024); + $pagelog = new PageChangeLog($ID, 1024); if($REV) { $revinfo = $pagelog->getRevisionInfo($REV); } else { @@ -1060,7 +1060,7 @@ function saveWikiText($id, $text, $summary, $minor = false) { $wasRemoved = (trim($text) == ''); // check for empty or whitespace only $wasCreated = !@file_exists($file); $wasReverted = ($REV == true); - $pagelog = new PageRevisionLog($id, 1024); + $pagelog = new PageChangeLog($id, 1024); $newRev = false; $oldRev = $pagelog->getRevisions(-1, 1); // from changelog $oldRev = (int) (empty($oldRev) ? 0 : $oldRev[0]); -- cgit v1.2.3 From 4bde2196a1e3572cead3f4d4e4b6a5a752bd62b3 Mon Sep 17 00:00:00 2001 From: lisps Date: Fri, 22 Nov 2013 09:04:44 +0100 Subject: remove property rev from xhtml.php changed variable name $create_time to $modified_time --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index e5e4f78c8..7f7095a12 100644 --- a/inc/common.php +++ b/inc/common.php @@ -383,6 +383,7 @@ function idfilter($id, $ue = true) { function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&') { global $conf; if(is_array($urlParameters)) { + if(isset($urlParameters['rev']) && !$urlParameters['rev']) unset($urlParameters['rev']); $urlParameters = buildURLparams($urlParameters, $separator); } else { $urlParameters = str_replace(',', $separator, $urlParameters); -- cgit v1.2.3 From 78b874e68a5f2a45f71a91efb168761c283e3a91 Mon Sep 17 00:00:00 2001 From: lisps Date: Fri, 22 Nov 2013 10:51:16 +0100 Subject: fix function name media_isexternal() remove empty rev from ml() rename getProperRevision() to getLastRevisionAt() make getLastRevisionAt() a method of ChangeLog --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 106bf7c15..5dcf58e39 100644 --- a/inc/common.php +++ b/inc/common.php @@ -484,6 +484,7 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) if(empty($more['w'])) unset($more['w']); if(empty($more['h'])) unset($more['h']); if(isset($more['id']) && $direct) unset($more['id']); + if(isset($more['rev']) && !$more['rev']) unset($more['rev']); $more = buildURLparams($more, $sep); } else { $matches = array(); -- cgit v1.2.3 From d81178045b12622c84f48c892ddda32c6aba5576 Mon Sep 17 00:00:00 2001 From: lisps Date: Fri, 22 Nov 2013 13:56:58 +0100 Subject: restore old version of pageinfo() --- 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 5dcf58e39..ce74717d0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -161,7 +161,7 @@ function pageinfo() { if($REV) { //check if current revision was meant if($info['exists'] && (@filemtime($info['filepath']) == $REV)) { - //$REV = ''; //if we enter a rev we want to see that revision (inc media files) + $REV = ''; } elseif($RANGE) { //section editing does not work with old revisions! $REV = ''; -- cgit v1.2.3 From 60a396c8ac50f17c2e3f43a9533af86cf6976976 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 4 Feb 2014 00:34:12 +0100 Subject: wrap userlink building with event. Implements an event which can modify the link below usernames, and the displayed user name. When no name supplied, the name of currently logged-in user is used. --- inc/common.php | 109 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 24 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 32771285b..053776a41 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1418,34 +1418,95 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { * @author Andy Webber */ function editorinfo($username) { - global $conf; + return userinfo($username); +} + +/** + * Returns users realname w/o link + * + * @param string|bool $username or false when currently logged-in user should be used + * @return string html of formatted user name + * + * @triggers COMMON_USER_LINK + */ +function userinfo($username = false) { + global $conf, $INFO; + /** @var DokuWiki_Auth_Plugin $auth */ global $auth; - switch($conf['showuseras']) { - case 'username': - case 'email': - case 'email_link': - if($auth) $info = $auth->getUserData($username); - break; - default: - return hsc($username); - } - - if(isset($info) && $info) { - switch($conf['showuseras']) { - case 'username': - return hsc($info['name']); - case 'email': - return obfuscate($info['mail']); - case 'email_link': - $mail = obfuscate($info['mail']); - return ''.$mail.''; - default: - return hsc($username); + // prepare initial event data + $data = array( + 'username' => $username, // the unique user name + 'name' => '', + 'link' => array( //setting 'link' to false disables linking + 'target' => '', + 'pre' => '', + 'suf' => '', + 'style' => '', + 'more' => '', + 'url' => '', + 'title' => '', + 'class' => '' + ), + 'userinfo' => '' + ); + if($username === false) { + $data['username'] = $_SERVER['REMOTE_USER']; + $data['name'] = ''.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; + } + + $evt = new Doku_Event('COMMON_USER_LINK', $data); + if($evt->advise_before(true)) { + if(empty($data['name'])) { + if($conf['showuseras'] == 'loginname') { + $data['name'] = hsc($data['username']); + } else { + if($auth) $info = $auth->getUserData($username); + if(isset($info) && $info) { + switch($conf['showuseras']) { + case 'username': + $data['name'] = hsc($info['name']); + break; + case 'email': + case 'email_link': + $data['name'] = obfuscate($info['mail']); + break; + } + } + } + } + if($data['link'] !== false && empty($data['link']['url'])){ + if($conf['showuseras'] == 'email_link') { + if(!isset($info)) { + if($auth) $info = $auth->getUserData($username); + } + if(isset($info) && $info) { + $data['link']['url'] = 'mailto:'.obfuscate($info['mail']); + } else { + $data['link'] = false; + } + + } else { + $data['link'] = false; + } + } + + if($data['link'] === false) { + $data['userinfo'] = $data['name']; + } else{ + $data['link']['name'] = $data['name']; + /** @var Doku_Renderer_xhtml $xhtml_renderer */ + static $xhtml_renderer = null; + if(is_null($xhtml_renderer)){ + $xhtml_renderer = p_get_renderer('xhtml'); + } + $data['userinfo'] = $xhtml_renderer->_formatLink($data['link']); } - } else { - return hsc($username); } + $evt->advise_after(); + unset($evt); + + return $data['userinfo']; } /** -- cgit v1.2.3 From 8a7e0ee6403bb358edf90c2419af066dd79cb2ce Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 4 Feb 2014 00:59:45 +0100 Subject: update $username as well, when read from _SERVER --- 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 053776a41..297c36355 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1451,7 +1451,7 @@ function userinfo($username = false) { 'userinfo' => '' ); if($username === false) { - $data['username'] = $_SERVER['REMOTE_USER']; + $data['username'] = $username = $_SERVER['REMOTE_USER']; $data['name'] = ''.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; } -- cgit v1.2.3 From 62c8004ec7c360471b96b4faa6128cd207f89bf2 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Fri, 14 Feb 2014 14:36:54 +0100 Subject: change default arg value of userinfo in null instead false --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 297c36355..c18f43668 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1429,7 +1429,7 @@ function editorinfo($username) { * * @triggers COMMON_USER_LINK */ -function userinfo($username = false) { +function userinfo($username = null) { global $conf, $INFO; /** @var DokuWiki_Auth_Plugin $auth */ global $auth; @@ -1450,7 +1450,7 @@ function userinfo($username = false) { ), 'userinfo' => '' ); - if($username === false) { + if($username === null) { $data['username'] = $username = $_SERVER['REMOTE_USER']; $data['name'] = ''.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; } -- cgit v1.2.3 From 7f081821c51e704c2720b993ca5364fa5e7e3663 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 00:42:05 +0100 Subject: Extend showuseras config with username_link uses the user interwiki link as profile link --- inc/common.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index c18f43668..22e57b2c5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1465,6 +1465,7 @@ function userinfo($username = null) { if(isset($info) && $info) { switch($conf['showuseras']) { case 'username': + case 'username_link': $data['name'] = hsc($info['name']); break; case 'email': @@ -1475,13 +1476,31 @@ function userinfo($username = null) { } } } + + /** @var Doku_Renderer_xhtml $xhtml_renderer */ + static $xhtml_renderer = null; + if($data['link'] !== false && empty($data['link']['url'])){ - if($conf['showuseras'] == 'email_link') { + + if(in_array($conf['showuseras'], array('email_link', 'username_link'))) { if(!isset($info)) { if($auth) $info = $auth->getUserData($username); } if(isset($info) && $info) { - $data['link']['url'] = 'mailto:'.obfuscate($info['mail']); + if($conf['showuseras'] == 'email_link') { + $data['link']['url'] = 'mailto:'.obfuscate($info['mail']); + } else { + if(is_null($xhtml_renderer)){ + $xhtml_renderer = p_get_renderer('xhtml'); + } + if(empty($xhtml_renderer->interwiki)) { + $xhtml_renderer->interwiki = getInterwiki(); + } + $shortcut = 'user'; + $url = $xhtml_renderer->_resolveInterWiki($shortcut, $username); + list($url, $urlparam) = explode('?', $url, 2); + $data['link']['url'] = wl($url, $urlparam); + } } else { $data['link'] = false; } @@ -1495,8 +1514,6 @@ function userinfo($username = null) { $data['userinfo'] = $data['name']; } else{ $data['link']['name'] = $data['name']; - /** @var Doku_Renderer_xhtml $xhtml_renderer */ - static $xhtml_renderer = null; if(is_null($xhtml_renderer)){ $xhtml_renderer = p_get_renderer('xhtml'); } -- cgit v1.2.3 From 2345e871e407dbece52f3181cd8b077f07cbb0c1 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:11:15 +0100 Subject: wikilink creating refactored to _resolveinterwiki(). Added DOKU_BASE for local target --- inc/common.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 22e57b2c5..e991375f5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1497,9 +1497,7 @@ function userinfo($username = null) { $xhtml_renderer->interwiki = getInterwiki(); } $shortcut = 'user'; - $url = $xhtml_renderer->_resolveInterWiki($shortcut, $username); - list($url, $urlparam) = explode('?', $url, 2); - $data['link']['url'] = wl($url, $urlparam); + $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username); } } else { $data['link'] = false; -- cgit v1.2.3 From 5a9ce44695f44ecc76f356c1fc26f0a1846231b7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:17:09 +0100 Subject: code reformatting --- inc/common.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index e991375f5..cd3c053a3 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1438,21 +1438,21 @@ function userinfo($username = null) { $data = array( 'username' => $username, // the unique user name 'name' => '', - 'link' => array( //setting 'link' to false disables linking - 'target' => '', - 'pre' => '', - 'suf' => '', - 'style' => '', - 'more' => '', - 'url' => '', - 'title' => '', - 'class' => '' + 'link' => array( //setting 'link' to false disables linking + 'target' => '', + 'pre' => '', + 'suf' => '', + 'style' => '', + 'more' => '', + 'url' => '', + 'title' => '', + 'class' => '' ), 'userinfo' => '' ); if($username === null) { $data['username'] = $username = $_SERVER['REMOTE_USER']; - $data['name'] = ''.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; + $data['name'] = '' . hsc($INFO['userinfo']['name']) . ' (' . hsc($_SERVER['REMOTE_USER']) . ')'; } $evt = new Doku_Event('COMMON_USER_LINK', $data); @@ -1480,7 +1480,7 @@ function userinfo($username = null) { /** @var Doku_Renderer_xhtml $xhtml_renderer */ static $xhtml_renderer = null; - if($data['link'] !== false && empty($data['link']['url'])){ + if($data['link'] !== false && empty($data['link']['url'])) { if(in_array($conf['showuseras'], array('email_link', 'username_link'))) { if(!isset($info)) { @@ -1488,9 +1488,9 @@ function userinfo($username = null) { } if(isset($info) && $info) { if($conf['showuseras'] == 'email_link') { - $data['link']['url'] = 'mailto:'.obfuscate($info['mail']); + $data['link']['url'] = 'mailto:' . obfuscate($info['mail']); } else { - if(is_null($xhtml_renderer)){ + if(is_null($xhtml_renderer)) { $xhtml_renderer = p_get_renderer('xhtml'); } if(empty($xhtml_renderer->interwiki)) { @@ -1510,9 +1510,9 @@ function userinfo($username = null) { if($data['link'] === false) { $data['userinfo'] = $data['name']; - } else{ + } else { $data['link']['name'] = $data['name']; - if(is_null($xhtml_renderer)){ + if(is_null($xhtml_renderer)) { $xhtml_renderer = p_get_renderer('xhtml'); } $data['userinfo'] = $xhtml_renderer->_formatLink($data['link']); -- cgit v1.2.3 From 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 14:34:26 +0100 Subject: interwiki : prefixed configurls handled as wikilinks --- inc/common.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index cd3c053a3..aa59a8c11 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1497,7 +1497,15 @@ function userinfo($username = null) { $xhtml_renderer->interwiki = getInterwiki(); } $shortcut = 'user'; - $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username); + $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists); + if($exists !== null) { + if($exists) { + $data['link']['class'] .= ' wikilink1'; + } else { + $data['link']['class'] .= ' wikilink2'; + $data['link']['rel'] = 'nofollow'; + } + } } } else { $data['link'] = false; -- cgit v1.2.3 From 2a2a43c4fa64079215d205d1faf50ab8a59caaab Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 17 Feb 2014 00:37:28 +0100 Subject: change default userspace to :user: and add interwiki class --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index aa59a8c11..4a5ead6b8 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1498,6 +1498,7 @@ function userinfo($username = null) { } $shortcut = 'user'; $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists); + $data['link']['class'] .= ' interwiki iw_user'; if($exists !== null) { if($exists) { $data['link']['class'] .= ' wikilink1'; -- cgit v1.2.3 From 74160ca1dea24b237ff3e956d19a420a1593b957 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 20 Feb 2014 14:10:24 +0100 Subject: PHPDocs missing breaks, removed unused var in common.php --- inc/common.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 32771285b..4682bedf9 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1140,7 +1140,6 @@ function saveWikiText($id, $text, $summary, $minor = false) { * @author Andreas Gohr */ function saveOldRevision($id) { - global $conf; $oldf = wikiFN($id); if(!@file_exists($oldf)) return ''; $date = filemtime($oldf); @@ -1230,8 +1229,9 @@ function getGoogleQuery() { /** * Return the human readable size of a file * - * @param int $size A file size - * @param int $dec A number of decimal places + * @param int $size A file size + * @param int $dec A number of decimal places + * @return string human readable size * @author Martin Benjamin * @author Aidan Lister * @version 1.0.0 @@ -1362,12 +1362,16 @@ function php_to_byte($v) { $l = substr($v, -1); $ret = substr($v, 0, -1); switch(strtoupper($l)) { + /** @noinspection PhpMissingBreakStatementInspection */ case 'P': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'T': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'G': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'M': $ret *= 1024; case 'K': -- cgit v1.2.3 From 01c9a118dacc1e2c07f2b0ddee84c514022e5927 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 23 Feb 2014 09:54:47 +0100 Subject: have most current revision always available in $INFO fixes fix for FS#2853 --- inc/common.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 32771285b..bbc0a6e68 100644 --- a/inc/common.php +++ b/inc/common.php @@ -155,12 +155,13 @@ function pageinfo() { $info['subscribed'] = false; } - $info['locked'] = checklock($ID); - $info['filepath'] = fullpath(wikiFN($ID)); - $info['exists'] = @file_exists($info['filepath']); + $info['locked'] = checklock($ID); + $info['filepath'] = fullpath(wikiFN($ID)); + $info['exists'] = @file_exists($info['filepath']); + $info['currentrev'] = @filemtime($info['filepath']); if($REV) { //check if current revision was meant - if($info['exists'] && (@filemtime($info['filepath']) == $REV)) { + if($info['exists'] && ($info['currentrev'] == $REV)) { $REV = ''; } elseif($RANGE) { //section editing does not work with old revisions! -- cgit v1.2.3 From 0e80bb5e347ff00c6f81627d8e39dafaaa923bc5 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 21:58:46 +0000 Subject: use empty() where array values might not be set --- 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 9a53ee526..36bd32c4f 100644 --- a/inc/common.php +++ b/inc/common.php @@ -191,7 +191,7 @@ function pageinfo() { if($REV) { $revinfo = getRevisionInfo($ID, $REV, 1024); } else { - if(is_array($info['meta']['last_change'])) { + if(!empty($info['meta']['last_change']) && is_array($info['meta']['last_change'])) { $revinfo = $info['meta']['last_change']; } else { $revinfo = getRevisionInfo($ID, $info['lastmod'], 1024); -- cgit v1.2.3 From 6d2af55dde922ac10a288b4195b1bf338e7bc5a9 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 5 Mar 2014 22:01:20 +0000 Subject: suppress errors where list() may not fill all vars --- inc/common.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 36bd32c4f..6aad42bd1 100644 --- a/inc/common.php +++ b/inc/common.php @@ -773,7 +773,7 @@ function checklock($id) { } //my own lock - list($ip, $session) = explode("\n", io_readFile($lock)); + @list($ip, $session) = explode("\n", io_readFile($lock)); if($ip == $_SERVER['REMOTE_USER'] || $ip == clientIP() || $session == session_id()) { return false; } @@ -811,7 +811,7 @@ function lock($id) { function unlock($id) { $lock = wikiLockFN($id); if(@file_exists($lock)) { - list($ip, $session) = explode("\n", io_readFile($lock)); + @list($ip, $session) = explode("\n", io_readFile($lock)); if($ip == $_SERVER['REMOTE_USER'] || $ip == clientIP() || $session == session_id()) { @unlink($lock); return true; @@ -1536,7 +1536,7 @@ function send_redirect($url) { // work around IE bug // http://www.ianhoar.com/2008/11/16/internet-explorer-6-and-redirected-anchor-links/ - list($url, $hash) = explode('#', $url); + @list($url, $hash) = explode('#', $url); if($hash) { if(strpos($url, '?')) { $url = $url.'&#'.$hash; -- cgit v1.2.3 From 585bf44e2b756eac2e1cfce7035ef237bc02a788 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 6 Mar 2014 19:55:56 +0000 Subject: amend $_SERVER to $INPUT->server --- inc/common.php | 102 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 31 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 6aad42bd1..9fbebde94 100644 --- a/inc/common.php +++ b/inc/common.php @@ -56,15 +56,18 @@ function stripctl($string) { * @return string */ function getSecurityToken() { - return PassHash::hmac('md5', session_id().$_SERVER['REMOTE_USER'], auth_cookiesalt()); + /** @var Input $INPUT */ + global $INPUT; + return PassHash::hmac('md5', session_id().$INPUT->server->str('REMOTE_USER'), auth_cookiesalt()); } /** * Check the secret CSRF token */ function checkSecurityToken($token = null) { + /** @var Input $INPUT */ global $INPUT; - if(empty($_SERVER['REMOTE_USER'])) return true; // no logged in user, no need for a check + if(!$INPUT->server->str('REMOTE_USER')) return true; // no logged in user, no need for a check if(is_null($token)) $token = $INPUT->str('sectok'); if(getSecurityToken() != $token) { @@ -93,14 +96,16 @@ function formSecurityToken($print = true) { */ function basicinfo($id, $htmlClient=true){ global $USERINFO; + /* @var Input $INPUT */ + global $INPUT; // set info about manager/admin status. $info['isadmin'] = false; $info['ismanager'] = false; - if(isset($_SERVER['REMOTE_USER'])) { + if($INPUT->server->has('REMOTE_USER')) { $info['userinfo'] = $USERINFO; $info['perm'] = auth_quickaclcheck($id); - $info['client'] = $_SERVER['REMOTE_USER']; + $info['client'] = $INPUT->server->str('REMOTE_USER'); if($info['perm'] == AUTH_ADMIN) { $info['isadmin'] = true; @@ -111,7 +116,7 @@ function basicinfo($id, $htmlClient=true){ // if some outside auth were used only REMOTE_USER is set if(!$info['userinfo']['name']) { - $info['userinfo']['name'] = $_SERVER['REMOTE_USER']; + $info['userinfo']['name'] = $INPUT->server->str('REMOTE_USER'); } } else { @@ -140,6 +145,8 @@ function pageinfo() { global $REV; global $RANGE; global $lang; + /* @var Input $INPUT */ + global $INPUT; $info = basicinfo($ID); @@ -148,7 +155,7 @@ function pageinfo() { $info['id'] = $ID; $info['rev'] = $REV; - if(isset($_SERVER['REMOTE_USER'])) { + if($INPUT->server->has('REMOTE_USER')) { $sub = new Subscription(); $info['subscribed'] = $sub->user_subscription(); } else { @@ -356,11 +363,14 @@ function breadcrumbs() { */ function idfilter($id, $ue = true) { global $conf; + /* @var Input $INPUT */ + global $INPUT; + if($conf['useslash'] && $conf['userewrite']) { $id = strtr($id, ':', '/'); } elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && $conf['userewrite'] && - strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') === false + strpos($INPUT->server->str('SERVER_SOFTWARE'), 'Microsoft-IIS') === false ) { $id = strtr($id, ':', ';'); } @@ -588,6 +598,8 @@ function checkwordblock($text = '') { global $SUM; global $conf; global $INFO; + /* @var Input $INPUT */ + global $INPUT; if(!$conf['usewordblock']) return false; @@ -620,9 +632,9 @@ function checkwordblock($text = '') { if(count($re) && preg_match('#('.join('|', $re).')#si', $text, $matches)) { // prepare event data $data['matches'] = $matches; - $data['userinfo']['ip'] = $_SERVER['REMOTE_ADDR']; - if($_SERVER['REMOTE_USER']) { - $data['userinfo']['user'] = $_SERVER['REMOTE_USER']; + $data['userinfo']['ip'] = $INPUT->server->str('REMOTE_ADDR'); + if($INPUT->server->str('REMOTE_USER')) { + $data['userinfo']['user'] = $INPUT->server->str('REMOTE_USER'); $data['userinfo']['name'] = $INFO['userinfo']['name']; $data['userinfo']['mail'] = $INFO['userinfo']['mail']; } @@ -648,12 +660,17 @@ function checkwordblock($text = '') { * @return string */ function clientIP($single = false) { + /* @var Input $INPUT */ + global $INPUT; + $ip = array(); - $ip[] = $_SERVER['REMOTE_ADDR']; - if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) - $ip = array_merge($ip, explode(',', str_replace(' ', '', $_SERVER['HTTP_X_FORWARDED_FOR']))); - if(!empty($_SERVER['HTTP_X_REAL_IP'])) - $ip = array_merge($ip, explode(',', str_replace(' ', '', $_SERVER['HTTP_X_REAL_IP']))); + $ip[] = $INPUT->server->str('REMOTE_ADDR'); + if($INPUT->server->str('HTTP_X_FORWARDED_FOR')) { + $ip = array_merge($ip, explode(',', str_replace(' ', '', $INPUT->server->str('HTTP_X_FORWARDED_FOR')))); + } + if($INPUT->server->str('HTTP_X_REAL_IP')) { + $ip = array_merge($ip, explode(',', str_replace(' ', '', $INPUT->server->str('HTTP_X_REAL_IP')))); + } // some IPv4/v6 regexps borrowed from Feyd // see: http://forums.devnetwork.net/viewtopic.php?f=38&t=53479 @@ -712,16 +729,18 @@ function clientIP($single = false) { * @link http://www.brainhandles.com/2007/10/15/detecting-mobile-browsers/#code */ function clientismobile() { + /* @var Input $INPUT */ + global $INPUT; - if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) return true; + if($INPUT->server->has('HTTP_X_WAP_PROFILE')) return true; - if(preg_match('/wap\.|\.wap/i', $_SERVER['HTTP_ACCEPT'])) return true; + if(preg_match('/wap\.|\.wap/i', $INPUT->server->str('HTTP_ACCEPT'))) return true; - if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; + if(!$INPUT->server->has('HTTP_USER_AGENT')) return false; $uamatches = 'midp|j2me|avantg|docomo|novarra|palmos|palmsource|240x320|opwv|chtml|pda|windows ce|mmp\/|blackberry|mib\/|symbian|wireless|nokia|hand|mobi|phone|cdm|up\.b|audio|SIE\-|SEC\-|samsung|HTC|mot\-|mitsu|sagem|sony|alcatel|lg|erics|vx|NEC|philips|mmm|xx|panasonic|sharp|wap|sch|rover|pocket|benq|java|pt|pg|vox|amoi|bird|compal|kg|voda|sany|kdd|dbt|sendo|sgh|gradi|jb|\d\d\di|moto'; - if(preg_match("/$uamatches/i", $_SERVER['HTTP_USER_AGENT'])) return true; + if(preg_match("/$uamatches/i", $INPUT->server->str('HTTP_USER_AGENT'))) return true; return false; } @@ -761,6 +780,9 @@ function gethostsbyaddrs($ips) { */ function checklock($id) { global $conf; + /* @var Input $INPUT */ + global $INPUT; + $lock = wikiLockFN($id); //no lockfile @@ -774,7 +796,7 @@ function checklock($id) { //my own lock @list($ip, $session) = explode("\n", io_readFile($lock)); - if($ip == $_SERVER['REMOTE_USER'] || $ip == clientIP() || $session == session_id()) { + if($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || $session == session_id()) { return false; } @@ -788,14 +810,16 @@ function checklock($id) { */ function lock($id) { global $conf; + /* @var Input $INPUT */ + global $INPUT; if($conf['locktime'] == 0) { return; } $lock = wikiLockFN($id); - if($_SERVER['REMOTE_USER']) { - io_saveFile($lock, $_SERVER['REMOTE_USER']); + if($INPUT->server->str('REMOTE_USER')) { + io_saveFile($lock, $INPUT->server->str('REMOTE_USER')); } else { io_saveFile($lock, clientIP()."\n".session_id()); } @@ -809,10 +833,13 @@ function lock($id) { * @return bool true if a lock was removed */ function unlock($id) { + /* @var Input $INPUT */ + global $INPUT; + $lock = wikiLockFN($id); if(@file_exists($lock)) { @list($ip, $session) = explode("\n", io_readFile($lock)); - if($ip == $_SERVER['REMOTE_USER'] || $ip == clientIP() || $session == session_id()) { + if($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || $session == session_id()) { @unlink($lock); return true; } @@ -938,6 +965,8 @@ function parsePageTemplate(&$data) { global $USERINFO; global $conf; + /* @var Input $INPUT */ + global $INPUT; // replace placeholders $file = noNS($id); @@ -969,7 +998,7 @@ function parsePageTemplate(&$data) { utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), - $_SERVER['REMOTE_USER'], + $INPUT->server->str('REMOTE_USER'), $USERINFO['name'], $USERINFO['mail'], $conf['dformat'], @@ -1050,6 +1079,9 @@ function saveWikiText($id, $text, $summary, $minor = false) { global $conf; global $lang; global $REV; + /* @var Input $INPUT */ + global $INPUT; + // ignore if no changes were made if($text == rawWiki($id, '')) { return; @@ -1112,7 +1144,7 @@ function saveWikiText($id, $text, $summary, $minor = false) { $type = DOKU_CHANGE_TYPE_CREATE; } else if($wasRemoved) { $type = DOKU_CHANGE_TYPE_DELETE; - } else if($minor && $conf['useacl'] && $_SERVER['REMOTE_USER']) { + } else if($minor && $conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { $type = DOKU_CHANGE_TYPE_MINOR_EDIT; } //minor edits only for logged in users @@ -1164,6 +1196,8 @@ function saveOldRevision($id) { */ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array()) { global $conf; + /* @var Input $INPUT */ + global $INPUT; // decide if there is something to do, eg. whom to mail if($who == 'admin') { @@ -1172,7 +1206,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = $to = $conf['notify']; } elseif($who == 'subscribers') { if(!actionOK('subscribe')) return false; //subscribers enabled? - if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors + if($conf['useacl'] && $INPUT->server->str('REMOTE_USER') && $minor) return false; //skip minors $data = array('id' => $id, 'addresslist' => '', 'self' => false); trigger_event( 'COMMON_NOTIFY_ADDRESSLIST', $data, @@ -1197,10 +1231,13 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = * @author Todd Augsburger */ function getGoogleQuery() { - if(!isset($_SERVER['HTTP_REFERER'])) { + /* @var Input $INPUT */ + global $INPUT; + + if(!$INPUT->server->has('HTTP_REFERER')) { return ''; } - $url = parse_url($_SERVER['HTTP_REFERER']); + $url = parse_url($INPUT->server->str('HTTP_REFERER')); // only handle common SEs if(!preg_match('/(google|bing|yahoo|ask|duckduckgo|babylon|aol|yandex)/',$url['host'])) return ''; @@ -1523,6 +1560,9 @@ function is_mem_available($mem, $bytes = 1048576) { * @author Andreas Gohr */ function send_redirect($url) { + /* @var Input $INPUT */ + global $INPUT; + //are there any undisplayed messages? keep them in session for display global $MSG; if(isset($MSG) && count($MSG) && !defined('NOSESSION')) { @@ -1546,9 +1586,9 @@ function send_redirect($url) { } // check if running on IIS < 6 with CGI-PHP - if(isset($_SERVER['SERVER_SOFTWARE']) && isset($_SERVER['GATEWAY_INTERFACE']) && - (strpos($_SERVER['GATEWAY_INTERFACE'], 'CGI') !== false) && - (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($_SERVER['SERVER_SOFTWARE']), $matches)) && + if($INPUT->server->has('SERVER_SOFTWARE') && $INPUT->server->has('GATEWAY_INTERFACE') && + (strpos($INPUT->server->str('GATEWAY_INTERFACE'), 'CGI') !== false) && + (preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($INPUT->server->str('SERVER_SOFTWARE')), $matches)) && $matches[1] < 6 ) { header('Refresh: 0;url='.$url); -- cgit v1.2.3 From 30f6ec4bf42de282d69f87494819f0599a1fae82 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 10 Mar 2014 23:58:18 +0100 Subject: update usage in userlink --- inc/common.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 143ad8923..d971986df 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1475,6 +1475,8 @@ function userinfo($username = null) { global $conf, $INFO; /** @var DokuWiki_Auth_Plugin $auth */ global $auth; + /** @var Input $INPUT */ + global $INPUT; // prepare initial event data $data = array( @@ -1493,8 +1495,8 @@ function userinfo($username = null) { 'userinfo' => '' ); if($username === null) { - $data['username'] = $username = $_SERVER['REMOTE_USER']; - $data['name'] = '' . hsc($INFO['userinfo']['name']) . ' (' . hsc($_SERVER['REMOTE_USER']) . ')'; + $data['username'] = $username = $INPUT->server->str('REMOTE_USER'); + $data['name'] = '' . hsc($INFO['userinfo']['name']) . ' (' . hsc($INPUT->server->str('REMOTE_USER')) . ')'; } $evt = new Doku_Event('COMMON_USER_LINK', $data); -- cgit v1.2.3 From 533772e1d092bc1b1326f7fe5a31091b58bf9030 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 11 Mar 2014 00:00:50 +0100 Subject: declare more clear, before used as ref --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index d971986df..6e7142f0e 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1541,6 +1541,7 @@ function userinfo($username = null) { $xhtml_renderer->interwiki = getInterwiki(); } $shortcut = 'user'; + $exists = null; $data['link']['url'] = $xhtml_renderer->_resolveInterWiki($shortcut, $username, $exists); $data['link']['class'] .= ' interwiki iw_user'; if($exists !== null) { -- cgit v1.2.3 From 2046a6546c8ed62b9a7b33305b6201458f2f8291 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 12 Mar 2014 15:38:28 +0000 Subject: Allow user info to be retrieved without groups Some parts of dokuwiki (e.g. recent changes, old revisions) can requests lots of user info (to provide editor names) without requiring any group information. This change also implements caching of user info by authmysql & authpgsql plugins to avoid repeated querying of the DB to retrieve the same user information. --- 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 9fbebde94..6851cdea3 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1467,7 +1467,7 @@ function editorinfo($username) { case 'username': case 'email': case 'email_link': - if($auth) $info = $auth->getUserData($username); + if($auth) $info = $auth->getUserData($username, DokuWiki_Auth_Plugin::IGNORE_GROUPS); break; default: return hsc($username); -- cgit v1.2.3 From 15f3bc49ed925ccb7c04299e9f614b0a1b739b13 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Fri, 14 Mar 2014 18:42:25 +0100 Subject: enable editorinfo and userinfo to return plain text names --- inc/common.php | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 6e7142f0e..f0c935c0c 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1457,21 +1457,26 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { * Return the users realname or e-mail address for use * in page footer and recent changes pages * + * @param string|bool $username or false when currently logged-in user should be used + * @param bool $textonly true returns only plain text, true allows returning html + * @return string html or text of formatted user name + * * @author Andy Webber */ -function editorinfo($username) { - return userinfo($username); +function editorinfo($username, $textonly = false) { + return userinfo($username, $textonly); } /** * Returns users realname w/o link * * @param string|bool $username or false when currently logged-in user should be used - * @return string html of formatted user name + * @param bool $textonly true returns only plain text, true allows returning html + * @return string html or text of formatted user name * * @triggers COMMON_USER_LINK */ -function userinfo($username = null) { +function userinfo($username = null, $textonly = false) { global $conf, $INFO; /** @var DokuWiki_Auth_Plugin $auth */ global $auth; @@ -1492,25 +1497,30 @@ function userinfo($username = null) { 'title' => '', 'class' => '' ), - 'userinfo' => '' + 'userinfo' => '', // formatted user name as will be returned + 'textonly' => $textonly ); if($username === null) { $data['username'] = $username = $INPUT->server->str('REMOTE_USER'); - $data['name'] = '' . hsc($INFO['userinfo']['name']) . ' (' . hsc($INPUT->server->str('REMOTE_USER')) . ')'; + if($textonly){ + $data['name'] = $INFO['userinfo']['name']. ' (' . $INPUT->server->str('REMOTE_USER') . ')'; + }else { + $data['name'] = '' . hsc($INFO['userinfo']['name']) . ' (' . hsc($INPUT->server->str('REMOTE_USER')) . ')'; + } } $evt = new Doku_Event('COMMON_USER_LINK', $data); if($evt->advise_before(true)) { if(empty($data['name'])) { if($conf['showuseras'] == 'loginname') { - $data['name'] = hsc($data['username']); + $data['name'] = $textonly ? $data['username'] : hsc($data['username']); } else { if($auth) $info = $auth->getUserData($username); if(isset($info) && $info) { switch($conf['showuseras']) { case 'username': case 'username_link': - $data['name'] = hsc($info['name']); + $data['name'] = $textonly ? $info['name'] : hsc($info['name']); break; case 'email': case 'email_link': @@ -1524,7 +1534,7 @@ function userinfo($username = null) { /** @var Doku_Renderer_xhtml $xhtml_renderer */ static $xhtml_renderer = null; - if($data['link'] !== false && empty($data['link']['url'])) { + if(!$data['textonly'] && empty($data['link']['url'])) { if(in_array($conf['showuseras'], array('email_link', 'username_link'))) { if(!isset($info)) { @@ -1554,15 +1564,15 @@ function userinfo($username = null) { } } } else { - $data['link'] = false; + $data['textonly'] = true; } } else { - $data['link'] = false; + $data['textonly'] = true; } } - if($data['link'] === false) { + if($data['textonly']) { $data['userinfo'] = $data['name']; } else { $data['link']['name'] = $data['name']; -- cgit v1.2.3 From 06e3e0c7b506a637df1ea27c6a8a439756e7139d Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 14 Mar 2014 17:58:53 +0000 Subject: use $requireGroups constants in auth classes; comments; code improvements --- inc/common.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 6851cdea3..9ed9e84d4 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1454,13 +1454,14 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { } /** - * Return the users realname or e-mail address for use + * Return the users real name or e-mail address for use * in page footer and recent changes pages * * @author Andy Webber */ function editorinfo($username) { global $conf; + /* @var DokuWiki_Auth_Plugin $auth */ global $auth; switch($conf['showuseras']) { @@ -1473,7 +1474,7 @@ function editorinfo($username) { return hsc($username); } - if(isset($info) && $info) { + if(!empty($info)) { switch($conf['showuseras']) { case 'username': return hsc($info['name']); @@ -1485,9 +1486,9 @@ function editorinfo($username) { default: return hsc($username); } - } else { - return hsc($username); } + + return hsc($username); } /** -- cgit v1.2.3 From f8fb2d1811251304687b805a60b489f63cb5c4fb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Mar 2014 21:29:33 +0100 Subject: strip sourcemaps in CSS and JS #601 source maps are invalid for our dispatched sources and may even cause problems. this makes sure any sourcemap declarations are stripped from the output --- inc/common.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 9fbebde94..5aacf6355 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1675,4 +1675,13 @@ function set_doku_pref($pref, $val) { } } +/** + * Strips source mapping declarations from given text #601 + * + * @param &string $text reference to the CSS or JavaScript code to clean + */ +function stripsourcemaps(&$text){ + $text = preg_replace('/^(\/\/|\/\*)[@#]\s+sourceMappingURL=.*?(\*\/)?$/im', '\\1\\2', $text); +} + //Setup VIM: ex: et ts=2 : -- cgit v1.2.3 From c0953023fdf442f13e6c27b7bd70dcde61243e88 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 16 Mar 2014 21:00:06 +0100 Subject: improve phpdocs editorinfo() --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index f0c935c0c..14d4a9d79 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1459,7 +1459,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { * * @param string|bool $username or false when currently logged-in user should be used * @param bool $textonly true returns only plain text, true allows returning html - * @return string html or text of formatted user name + * @return string html or plain text(not escaped) of formatted user name * * @author Andy Webber */ @@ -1472,7 +1472,7 @@ function editorinfo($username, $textonly = false) { * * @param string|bool $username or false when currently logged-in user should be used * @param bool $textonly true returns only plain text, true allows returning html - * @return string html or text of formatted user name + * @return string html or plain text(not escaped) of formatted user name * * @triggers COMMON_USER_LINK */ -- cgit v1.2.3 From cd4635ee7f07ae17e1b2a58d8d9e6620ddb077ef Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 16 Mar 2014 21:10:43 +0100 Subject: Rename userinfo() to userlink() --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 14d4a9d79..eef160122 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1464,7 +1464,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { * @author Andy Webber */ function editorinfo($username, $textonly = false) { - return userinfo($username, $textonly); + return userlink($username, $textonly); } /** @@ -1476,7 +1476,7 @@ function editorinfo($username, $textonly = false) { * * @triggers COMMON_USER_LINK */ -function userinfo($username = null, $textonly = false) { +function userlink($username = null, $textonly = false) { global $conf, $INFO; /** @var DokuWiki_Auth_Plugin $auth */ global $auth; -- cgit v1.2.3 From 4d5fc927eace8f4208895cd309d23fc9025dbb6b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 16 Mar 2014 21:13:27 +0100 Subject: use more consistent names --- inc/common.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index eef160122..5164d4ac0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1497,7 +1497,7 @@ function userlink($username = null, $textonly = false) { 'title' => '', 'class' => '' ), - 'userinfo' => '', // formatted user name as will be returned + 'userlink' => '', // formatted user name as will be returned 'textonly' => $textonly ); if($username === null) { @@ -1573,19 +1573,19 @@ function userlink($username = null, $textonly = false) { } if($data['textonly']) { - $data['userinfo'] = $data['name']; + $data['userlink'] = $data['name']; } else { $data['link']['name'] = $data['name']; if(is_null($xhtml_renderer)) { $xhtml_renderer = p_get_renderer('xhtml'); } - $data['userinfo'] = $xhtml_renderer->_formatLink($data['link']); + $data['userlink'] = $xhtml_renderer->_formatLink($data['link']); } } $evt->advise_after(); unset($evt); - return $data['userinfo']; + return $data['userlink']; } /** -- cgit v1.2.3 From 7b62b42de1887c3627c727f0483aea41556742d4 Mon Sep 17 00:00:00 2001 From: lisps Date: Wed, 19 Mar 2014 10:32:55 +0100 Subject: add config date_at_format change translation message --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 0b15c284d..44cfe91ba 100644 --- a/inc/common.php +++ b/inc/common.php @@ -395,6 +395,7 @@ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '& global $conf; if(is_array($urlParameters)) { if(isset($urlParameters['rev']) && !$urlParameters['rev']) unset($urlParameters['rev']); + if(isset($urlParameters['at']) && $conf['date_at_format']) $urlParameters['at'] = date($conf['date_at_format'],$urlParameters['at']); $urlParameters = buildURLparams($urlParameters, $separator); } else { $urlParameters = str_replace(',', $separator, $urlParameters); -- cgit v1.2.3 From 2dc9e90007f12ac996b0e74479137a9dc6243c3c Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sun, 4 May 2014 19:20:11 +0100 Subject: KISS - remove class constants for REQUIRE_GROUPS & IGNORE_GROUPS and replace with boolean values --- 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 9ed9e84d4..9b3c59e6e 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1468,7 +1468,7 @@ function editorinfo($username) { case 'username': case 'email': case 'email_link': - if($auth) $info = $auth->getUserData($username, DokuWiki_Auth_Plugin::IGNORE_GROUPS); + if($auth) $info = $auth->getUserData($username, $requireGroups = false); break; default: return hsc($username); -- cgit v1.2.3 From 0712fefaefb6c7857ccc3455db2d8d269fb3ed16 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 16 May 2014 08:35:38 +0200 Subject: don't unlock based on empty session --- 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 9fbebde94..c960c8739 100644 --- a/inc/common.php +++ b/inc/common.php @@ -796,7 +796,7 @@ function checklock($id) { //my own lock @list($ip, $session) = explode("\n", io_readFile($lock)); - if($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || $session == session_id()) { + if($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || (session_id() && $session == session_id())) { return false; } -- cgit v1.2.3 From 4bc480e54901356eb84ce27ab4a76c5f88875a60 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 19 May 2014 22:18:01 +0200 Subject: doc updates --- inc/common.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 84121fd43..ecd743a96 100644 --- a/inc/common.php +++ b/inc/common.php @@ -386,10 +386,15 @@ function idfilter($id, $ue = true) { /** * This builds a link to a wikipage * - * It handles URL rewriting and adds additional parameter if - * given in $more + * It handles URL rewriting and adds additional parameters * * @author Andreas Gohr + * + * @param string $id page id, defaults to start page + * @param string|array $urlParameters URL parameters, associative array recommended + * @param bool $absolute request an absolute URL instead of relative + * @param string $separator parameter separator + * @return string */ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&') { global $conf; @@ -431,13 +436,19 @@ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '& * Handles URL rewriting if enabled. Follows the style of wl(). * * @author Ben Coburn + * @param string $id page id, defaults to start page + * @param string $format the export renderer to use + * @param string|array $urlParameters URL parameters, associative array recommended + * @param bool $abs request an absolute URL instead of relative + * @param string $sep parameter separator + * @return string */ -function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep = '&') { +function exportlink($id = '', $format = 'raw', $urlParameters = '', $abs = false, $sep = '&') { global $conf; - if(is_array($more)) { - $more = buildURLparams($more, $sep); + if(is_array($urlParameters)) { + $urlParameters = buildURLparams($urlParameters, $sep); } else { - $more = str_replace(',', $sep, $more); + $urlParameters = str_replace(',', $sep, $urlParameters); } $format = rawurlencode($format); @@ -450,13 +461,13 @@ function exportlink($id = '', $format = 'raw', $more = '', $abs = false, $sep = if($conf['userewrite'] == 2) { $xlink .= DOKU_SCRIPT.'/'.$id.'?do=export_'.$format; - if($more) $xlink .= $sep.$more; + if($urlParameters) $xlink .= $sep.$urlParameters; } elseif($conf['userewrite'] == 1) { $xlink .= '_export/'.$format.'/'.$id; - if($more) $xlink .= '?'.$more; + if($urlParameters) $xlink .= '?'.$urlParameters; } else { $xlink .= DOKU_SCRIPT.'?do=export_'.$format.$sep.'id='.$id; - if($more) $xlink .= $sep.$more; + if($urlParameters) $xlink .= $sep.$urlParameters; } return $xlink; -- cgit v1.2.3 From 140cfbcdb4e284716917a759600e8b417668d1bd Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 20 May 2014 22:37:49 +0200 Subject: PHPDocs for common.php --- inc/common.php | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 127 insertions(+), 4 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index ecd743a96..f51053cc0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -22,6 +22,9 @@ define('RECENTS_MEDIA_PAGES_MIXED', 32); * * @author Andreas Gohr * @see htmlspecialchars() + * + * @param string $string the string being converted + * @return string converted string */ function hsc($string) { return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); @@ -33,6 +36,9 @@ function hsc($string) { * You can give an indention as optional parameter * * @author Andreas Gohr + * + * @param string $string line of text + * @param int $indent number of spaces indention */ function ptln($string, $indent = 0) { echo str_repeat(' ', $indent)."$string\n"; @@ -42,6 +48,9 @@ function ptln($string, $indent = 0) { * strips control characters (<32) from the given string * * @author Andreas Gohr + * + * @param $string string being stripped + * @return string */ function stripctl($string) { return preg_replace('/[\x00-\x1F]+/s', '', $string); @@ -63,6 +72,9 @@ function getSecurityToken() { /** * Check the secret CSRF token + * + * @param null|string $token security token or null to read it from request variable + * @return bool success if the token matched */ function checkSecurityToken($token = null) { /** @var Input $INPUT */ @@ -81,6 +93,9 @@ function checkSecurityToken($token = null) { * Print a hidden form field with a secret CSRF token * * @author Andreas Gohr + * + * @param bool $print if true print the field, otherwise html of the field is returned + * @return void|string html of hidden form field */ function formSecurityToken($print = true) { $ret = '
'."\n"; @@ -93,6 +108,11 @@ function formSecurityToken($print = true) { * * @author Andreas Gohr * @author Chris Smith + * + * @param string $id pageid + * @param bool $htmlClient add info about whether is mobile browser + * @return array with info for a request of $id + * */ function basicinfo($id, $htmlClient=true){ global $USERINFO; @@ -139,6 +159,8 @@ function basicinfo($id, $htmlClient=true){ * array. * * @author Andreas Gohr + * + * @return array with info about current document */ function pageinfo() { global $ID; @@ -246,6 +268,8 @@ function pageinfo() { /** * Return information about the current media item as an associative array. + * + * @return array with info about current media item */ function mediainfo(){ global $NS; @@ -261,6 +285,10 @@ function mediainfo(){ * Build an string of URL parameters * * @author Andreas Gohr + * + * @param array $params array with key-value pairs + * @param string $sep series of pairs are separated by this character + * @return string query string */ function buildURLparams($params, $sep = '&') { $url = ''; @@ -281,6 +309,10 @@ function buildURLparams($params, $sep = '&') { * Skips keys starting with '_', values get HTML encoded * * @author Andreas Gohr + * + * @param array $params array with (attribute name-attribute value) pairs + * @param bool $skipempty skip empty string values? + * @return string */ function buildAttributes($params, $skipempty = false) { $url = ''; @@ -302,6 +334,8 @@ function buildAttributes($params, $skipempty = false) { * This builds the breadcrumb trail and returns it as array * * @author Andreas Gohr + * + * @return array(pageid=>name, ... ) */ function breadcrumbs() { // we prepare the breadcrumbs early for quick session closing @@ -361,6 +395,10 @@ function breadcrumbs() { * Urlencoding is ommitted when the second parameter is false * * @author Andreas Gohr + * + * @param string $id pageid being filtered + * @param bool $ue apply urlencoding? + * @return string */ function idfilter($id, $ue = true) { global $conf; @@ -574,6 +612,8 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) * Consider using wl() instead, unless you absoutely need the doku.php endpoint * * @author Andreas Gohr + * + * @return string */ function script() { return DOKU_BASE.DOKU_SCRIPT; @@ -600,6 +640,7 @@ function script() { * * @author Andreas Gohr * @author Michael Klier + * * @param string $text - optional text to check, if not given the globals are used * @return bool - true if a spam word was found */ @@ -668,6 +709,7 @@ function checkwordblock($text = '') { * headers * * @author Andreas Gohr + * * @param boolean $single If set only a single IP is returned * @return string */ @@ -739,6 +781,8 @@ function clientIP($single = false) { * Adapted from the example code at url below * * @link http://www.brainhandles.com/2007/10/15/detecting-mobile-browsers/#code + * + * @return bool if true, client is mobile browser; otherwise false */ function clientismobile() { /* @var Input $INPUT */ @@ -763,6 +807,7 @@ function clientismobile() { * If $conf['dnslookups'] is disabled it simply returns the input string * * @author Glen Harris + * * @param string $ips comma separated list of IP addresses * @return string a comma separated list of hostnames */ @@ -789,6 +834,9 @@ function gethostsbyaddrs($ips) { * removes stale lockfiles * * @author Andreas Gohr + * + * @param string $id page id + * @return bool page is locked? */ function checklock($id) { global $conf; @@ -819,6 +867,8 @@ function checklock($id) { * Lock a page for editing * * @author Andreas Gohr + * + * @param string $id page id to lock */ function lock($id) { global $conf; @@ -841,6 +891,7 @@ function lock($id) { * Unlock a page if it was locked by the user * * @author Andreas Gohr + * * @param string $id page id to unlock * @return bool true if a lock was removed */ @@ -866,6 +917,9 @@ function unlock($id) { * * @see formText() for 2crlf conversion * @author Andreas Gohr + * + * @param string $text + * @return string */ function cleanText($text) { $text = preg_replace("/(\015\012)|(\015)/", "\012", $text); @@ -885,6 +939,9 @@ function cleanText($text) { * * @see cleanText() for 2unix conversion * @author Andreas Gohr + * + * @param string $text + * @return string */ function formText($text) { $text = str_replace("\012", "\015\012", $text); @@ -895,6 +952,10 @@ function formText($text) { * Returns the specified local text in raw format * * @author Andreas Gohr + * + * @param string $id page id + * @param string $ext extension of file being read, default 'txt' + * @return string */ function rawLocale($id, $ext = 'txt') { return io_readFile(localeFN($id, $ext)); @@ -904,6 +965,10 @@ function rawLocale($id, $ext = 'txt') { * Returns the raw WikiText * * @author Andreas Gohr + * + * @param string $id page id + * @param string $rev timestamp when a revision of wikitext is desired + * @return string */ function rawWiki($id, $rev = '') { return io_readWikiPage(wikiFN($id, $rev), $id, $rev); @@ -914,6 +979,9 @@ function rawWiki($id, $rev = '') { * * @triggers COMMON_PAGETPL_LOAD * @author Andreas Gohr + * + * @param string $id the id of the page to be created + * @return string parsed pagetemplate content */ function pageTemplate($id) { global $conf; @@ -965,6 +1033,9 @@ function pageTemplate($id) { * This works on data from COMMON_PAGETPL_LOAD * * @author Andreas Gohr + * + * @param array $data array with event data + * @return string */ function parsePageTemplate(&$data) { /** @@ -1032,6 +1103,11 @@ function parsePageTemplate(&$data) { * The returned order is prefix, section and suffix. * * @author Andreas Gohr + * + * @param string $range in form "from-to" + * @param string $id page id + * @param string $rev optional, the revision timestamp + * @return array with three slices */ function rawWikiSlices($range, $id, $rev = '') { $text = io_readWikiPage(wikiFN($id, $rev), $id, $rev); @@ -1056,6 +1132,12 @@ function rawWikiSlices($range, $id, $rev = '') { * lines between sections if needed (used on saving). * * @author Andreas Gohr + * + * @param string $pre prefix + * @param string $text text in the middle + * @param string $suf suffix + * @param bool $pretty add additional empty lines between sections + * @return string */ function con($pre, $text, $suf, $pretty = false) { if($pretty) { @@ -1080,6 +1162,11 @@ function con($pre, $text, $suf, $pretty = false) { * * @author Andreas Gohr * @author Ben Coburn + * + * @param string $id page id + * @param string $text wikitext being saved + * @param string $summary summary of text update + * @param bool $minor mark this saved version as minor update */ function saveWikiText($id, $text, $summary, $minor = false) { /* Note to developers: @@ -1184,6 +1271,9 @@ function saveWikiText($id, $text, $summary, $minor = false) { * revision date * * @author Andreas Gohr + * + * @param string $id page id + * @return int|string revision timestamp */ function saveOldRevision($id) { $oldf = wikiFN($id); @@ -1203,8 +1293,8 @@ function saveOldRevision($id) { * @param string $summary What changed * @param boolean $minor Is this a minor edit? * @param array $replace Additional string substitutions, @KEY@ to be replaced by value - * * @return bool + * * @author Andreas Gohr */ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array()) { @@ -1242,6 +1332,8 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = * * @author Andreas Gohr * @author Todd Augsburger + * + * @return array|string */ function getGoogleQuery() { /* @var Input $INPUT */ @@ -1283,6 +1375,7 @@ function getGoogleQuery() { * @param int $size A file size * @param int $dec A number of decimal places * @return string human readable size + * * @author Martin Benjamin * @author Aidan Lister * @version 1.0.0 @@ -1304,6 +1397,9 @@ function filesize_h($size, $dec = 1) { * Return the given timestamp as human readable, fuzzy age * * @author Andreas Gohr + * + * @param int $dt timestamp + * @return string */ function datetime_h($dt) { global $lang; @@ -1338,6 +1434,10 @@ function datetime_h($dt) { * * @see datetime_h * @author Andreas Gohr + * + * @param int|null $dt timestamp when given, null will take current timestamp + * @param string $format empty default to $conf['dformat'], or provide format as recognized by strftime() + * @return string */ function dformat($dt = null, $format = '') { global $conf; @@ -1355,6 +1455,7 @@ function dformat($dt = null, $format = '') { * * @author * @link http://www.php.net/manual/en/function.date.php#54072 + * * @param int $int_date: current date in UNIX timestamp * @return string */ @@ -1371,6 +1472,9 @@ function date_iso8601($int_date) { * * @author Harry Fuecks * @author Christopher Smith + * + * @param string $email email address + * @return string */ function obfuscate($email) { global $conf; @@ -1398,6 +1502,10 @@ function obfuscate($email) { * Removes quoting backslashes * * @author Andreas Gohr + * + * @param string $string + * @param string $char backslashed character + * @return string */ function unslash($string, $char = "'") { return str_replace('\\'.$char, $char, $string); @@ -1408,6 +1516,9 @@ function unslash($string, $char = "'") { * * @author * @link http://de3.php.net/manual/en/ini.core.php#79564 + * + * @param string $v shorthands + * @return int|string */ function php_to_byte($v) { $l = substr($v, -1); @@ -1437,6 +1548,9 @@ function php_to_byte($v) { /** * Wrapper around preg_quote adding the default delimiter + * + * @param string $string + * @return string */ function preg_quote_cb($string) { return preg_quote($string, '/'); @@ -1606,6 +1720,7 @@ function userlink($username = null, $textonly = false) { * When no image exists, returns an empty string * * @author Andreas Gohr + * * @param string $type - type of image 'badge' or 'button' * @return string */ @@ -1636,9 +1751,8 @@ function license_img($type) { * @author Filip Oscadal * @author Andreas Gohr * - * @param int $mem Size of memory you want to allocate in bytes - * @param int $bytes - * @internal param int $used already allocated memory (see above) + * @param int $mem Size of memory you want to allocate in bytes + * @param int $bytes already allocated memory (see above) * @return bool */ function is_mem_available($mem, $bytes = 1048576) { @@ -1669,6 +1783,8 @@ function is_mem_available($mem, $bytes = 1048576) { * * @link http://support.microsoft.com/kb/q176113/ * @author Andreas Gohr + * + * @param string $url url being directed to */ function send_redirect($url) { /* @var Input $INPUT */ @@ -1740,6 +1856,10 @@ function valid_input_set($param, $valid_values, $array, $exc = '') { /** * Read a preference from the DokuWiki cookie * (remembering both keys & values are urlencoded) + * + * @param string $pref preference key + * @param string $default value returned when preference not found + * @return string preference value */ function get_doku_pref($pref, $default) { $enc_pref = urlencode($pref); @@ -1758,6 +1878,9 @@ function get_doku_pref($pref, $default) { /** * Add a preference to the DokuWiki cookie * (remembering $_COOKIE['DOKU_PREFS'] is urlencoded) + * + * @param string $pref preference key + * @param string $val preference value */ function set_doku_pref($pref, $val) { global $conf; -- cgit v1.2.3 From 0bb378687e0397cf4268ea411c65d60e6a51ddc6 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 20 May 2014 23:00:48 +0200 Subject: add replacements to event data of COMMON_NOTIFY_ADDRESSLIST --- 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 f51053cc0..aea6065d0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1310,7 +1310,7 @@ function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = } elseif($who == 'subscribers') { if(!actionOK('subscribe')) return false; //subscribers enabled? if($conf['useacl'] && $INPUT->server->str('REMOTE_USER') && $minor) return false; //skip minors - $data = array('id' => $id, 'addresslist' => '', 'self' => false); + $data = array('id' => $id, 'addresslist' => '', 'self' => false, 'replacements' => $replace); trigger_event( 'COMMON_NOTIFY_ADDRESSLIST', $data, array(new Subscription(), 'notifyaddresses') -- cgit v1.2.3 From f168548c334622dbfa567a8f7bb998271195656e Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 20 May 2014 23:01:31 +0200 Subject: phpdocs, fallthrough, unused var in common.php --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index aea6065d0..cd180e29e 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1536,6 +1536,7 @@ function php_to_byte($v) { /** @noinspection PhpMissingBreakStatementInspection */ case 'M': $ret *= 1024; + /** @noinspection PhpMissingBreakStatementInspection */ case 'K': $ret *= 1024; break; @@ -1597,7 +1598,7 @@ function editorinfo($username, $textonly = false) { /** * Returns users realname w/o link * - * @param string|bool $username or false when currently logged-in user should be used + * @param string|null $username or null when currently logged-in user should be used * @param bool $textonly true returns only plain text, true allows returning html * @return string html or plain text(not escaped) of formatted user name * @@ -1729,7 +1730,6 @@ function license_img($type) { global $conf; if(!$conf['license']) return ''; if(!is_array($license[$conf['license']])) return ''; - $lic = $license[$conf['license']]; $try = array(); $try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.png'; $try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.gif'; -- cgit v1.2.3 From b4b6c9a156df8ab4655a518790afb625ea927adb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 20 May 2014 23:25:28 +0200 Subject: Phpdocs --- inc/common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index cd180e29e..0fe33c5b1 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1585,7 +1585,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…') { * Return the users realname or e-mail address for use * in page footer and recent changes pages * - * @param string|bool $username or false when currently logged-in user should be used + * @param string|null $username or null when currently logged-in user should be used * @param bool $textonly true returns only plain text, true allows returning html * @return string html or plain text(not escaped) of formatted user name * @@ -1858,7 +1858,7 @@ function valid_input_set($param, $valid_values, $array, $exc = '') { * (remembering both keys & values are urlencoded) * * @param string $pref preference key - * @param string $default value returned when preference not found + * @param mixed $default value returned when preference not found * @return string preference value */ function get_doku_pref($pref, $default) { -- cgit v1.2.3 From edd95259bb705c653f690b97064e0337a75aa2e4 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 15 Jul 2014 16:05:47 +0200 Subject: not encode semicolon in idfilter. Restores vanished changes of #84 --- inc/common.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 0fe33c5b1..8c9956018 100644 --- a/inc/common.php +++ b/inc/common.php @@ -416,6 +416,7 @@ function idfilter($id, $ue = true) { if($ue) { $id = rawurlencode($id); $id = str_replace('%3A', ':', $id); //keep as colon + $id = str_replace('%3B', ';', $id); //keep as semicolon $id = str_replace('%2F', '/', $id); //keep as slash } return $id; -- cgit v1.2.3 From 65833968962f86342542bf9d52f9cdcb7f595379 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 1 Sep 2014 17:50:24 +0200 Subject: fix userlink title when no authplugin is available or no user is found --- inc/common.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 8c9956018..503155c46 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1641,22 +1641,20 @@ function userlink($username = null, $textonly = false) { $evt = new Doku_Event('COMMON_USER_LINK', $data); if($evt->advise_before(true)) { if(empty($data['name'])) { - if($conf['showuseras'] == 'loginname') { - $data['name'] = $textonly ? $data['username'] : hsc($data['username']); - } else { - if($auth) $info = $auth->getUserData($username); - if(isset($info) && $info) { - switch($conf['showuseras']) { - case 'username': - case 'username_link': - $data['name'] = $textonly ? $info['name'] : hsc($info['name']); - break; - case 'email': - case 'email_link': - $data['name'] = obfuscate($info['mail']); - break; - } + if($auth) $info = $auth->getUserData($username); + if($conf['showuseras'] != 'loginname' && isset($info) && $info) { + switch($conf['showuseras']) { + case 'username': + case 'username_link': + $data['name'] = $textonly ? $info['name'] : hsc($info['name']); + break; + case 'email': + case 'email_link': + $data['name'] = obfuscate($info['mail']); + break; } + } else { + $data['name'] = $textonly ? $data['username'] : hsc($data['username']); } } -- cgit v1.2.3 From e0c26282a603881e8d2f839d94c28dbbfc57d71b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 03:34:17 +0200 Subject: scrutinizer documentations issues --- 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 e56285f62..95ea4e72d 100644 --- a/inc/common.php +++ b/inc/common.php @@ -968,7 +968,7 @@ function rawLocale($id, $ext = 'txt') { * @author Andreas Gohr * * @param string $id page id - * @param string $rev timestamp when a revision of wikitext is desired + * @param string|int $rev timestamp when a revision of wikitext is desired * @return string */ function rawWiki($id, $rev = '') { -- cgit v1.2.3 From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- 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 95ea4e72d..91a068bb0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -120,6 +120,7 @@ function basicinfo($id, $htmlClient=true){ global $INPUT; // set info about manager/admin status. + $info = array(); $info['isadmin'] = false; $info['ismanager'] = false; if($INPUT->server->has('REMOTE_USER')) { @@ -685,6 +686,7 @@ function checkwordblock($text = '') { } if(count($re) && preg_match('#('.join('|', $re).')#si', $text, $matches)) { // prepare event data + $data = array(); $data['matches'] = $matches; $data['userinfo']['ip'] = $INPUT->server->str('REMOTE_ADDR'); if($INPUT->server->str('REMOTE_USER')) { @@ -1119,6 +1121,7 @@ function rawWikiSlices($range, $id, $rev = '') { $from = !$from ? 0 : ($from - 1); $to = !$to ? strlen($text) : ($to - 1); + $slices = array(); $slices[0] = substr($text, 0, $from); $slices[1] = substr($text, $from, $to - $from); $slices[2] = substr($text, $to); -- cgit v1.2.3 From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/common.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 91a068bb0..444e90198 100644 --- a/inc/common.php +++ b/inc/common.php @@ -49,7 +49,7 @@ function ptln($string, $indent = 0) { * * @author Andreas Gohr * - * @param $string string being stripped + * @param string $string being stripped * @return string */ function stripctl($string) { @@ -62,6 +62,7 @@ function stripctl($string) { * @author Andreas Gohr * @link http://en.wikipedia.org/wiki/Cross-site_request_forgery * @link http://christ1an.blogspot.com/2007/04/preventing-csrf-efficiently.html + * * @return string */ function getSecurityToken() { @@ -95,7 +96,7 @@ function checkSecurityToken($token = null) { * @author Andreas Gohr * * @param bool $print if true print the field, otherwise html of the field is returned - * @return void|string html of hidden form field + * @return string html of hidden form field */ function formSecurityToken($print = true) { $ret = '
'."\n"; @@ -336,7 +337,7 @@ function buildAttributes($params, $skipempty = false) { * * @author Andreas Gohr * - * @return array(pageid=>name, ... ) + * @return string[string] with the data: array(pageid=>name, ... ) */ function breadcrumbs() { // we prepare the breadcrumbs early for quick session closing @@ -1110,7 +1111,7 @@ function parsePageTemplate(&$data) { * @param string $range in form "from-to" * @param string $id page id * @param string $rev optional, the revision timestamp - * @return array with three slices + * @return string[] with three slices */ function rawWikiSlices($range, $id, $rev = '') { $text = io_readWikiPage(wikiFN($id, $rev), $id, $rev); @@ -1296,7 +1297,7 @@ function saveOldRevision($id) { * @param int|string $rev Old page revision * @param string $summary What changed * @param boolean $minor Is this a minor edit? - * @param array $replace Additional string substitutions, @KEY@ to be replaced by value + * @param string[] $replace Additional string substitutions, @KEY@ to be replaced by value * @return bool * * @author Andreas Gohr @@ -1376,8 +1377,8 @@ function getGoogleQuery() { /** * Return the human readable size of a file * - * @param int $size A file size - * @param int $dec A number of decimal places + * @param int $size A file size + * @param int $dec A number of decimal places * @return string human readable size * * @author Martin Benjamin @@ -1914,7 +1915,7 @@ function set_doku_pref($pref, $val) { /** * Strips source mapping declarations from given text #601 * - * @param &string $text reference to the CSS or JavaScript code to clean + * @param string &$text reference to the CSS or JavaScript code to clean */ function stripsourcemaps(&$text){ $text = preg_replace('/^(\/\/|\/\*)[@#]\s+sourceMappingURL=.*?(\*\/)?$/im', '\\1\\2', $text); -- cgit v1.2.3 From e3710957c6b7e12293805a15d0624be7c7054092 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 17:05:40 +0200 Subject: more phpdocs and minor check --- 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 444e90198..7932fc9f0 100644 --- a/inc/common.php +++ b/inc/common.php @@ -337,7 +337,7 @@ function buildAttributes($params, $skipempty = false) { * * @author Andreas Gohr * - * @return string[string] with the data: array(pageid=>name, ... ) + * @return string[] with the data: array(pageid=>name, ... ) */ function breadcrumbs() { // we prepare the breadcrumbs early for quick session closing -- cgit v1.2.3 From 7e8500eea1e53b1de0e0f70400664afa442cd08d Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 2 Oct 2014 14:55:24 +0200 Subject: PHPDocs and some improvements --- 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 7932fc9f0..d628ab6b2 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1461,7 +1461,7 @@ function dformat($dt = null, $format = '') { * @author * @link http://www.php.net/manual/en/function.date.php#54072 * - * @param int $int_date: current date in UNIX timestamp + * @param int $int_date current date in UNIX timestamp * @return string */ function date_iso8601($int_date) { -- cgit v1.2.3 From 81781cb6b4211de42700790b0f4968f39feababd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 17 Dec 2014 13:14:29 +0100 Subject: never exit during test runs --- inc/common.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index b5fdd1ea5..2c9359a0c 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1828,6 +1828,8 @@ function send_redirect($url) { } else { header('Location: '.$url); } + + if(defined('DOKU_UNITTEST')) return; // no exits during unit tests exit; } -- cgit v1.2.3 From 79e79377626799a77c11aa7849cb9c64305590c8 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:47:45 +0100 Subject: Remove error supression for file_exists() In an older version of PHP a file_exists() call would issue a warning when the file did not exist. This was fixed in later PHP releases. Since we require PHP 5.3 now, there's no need to supress any error here anymore. This might even give a minor performance boost. --- inc/common.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 2c9359a0c..9b330000b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -188,7 +188,7 @@ function pageinfo() { $info['locked'] = checklock($ID); $info['filepath'] = fullpath(wikiFN($ID)); - $info['exists'] = @file_exists($info['filepath']); + $info['exists'] = file_exists($info['filepath']); $info['currentrev'] = @filemtime($info['filepath']); if($REV) { //check if current revision was meant @@ -202,7 +202,7 @@ function pageinfo() { } else { //really use old revision $info['filepath'] = fullpath(wikiFN($ID, $REV)); - $info['exists'] = @file_exists($info['filepath']); + $info['exists'] = file_exists($info['filepath']); } } $info['rev'] = $REV; @@ -256,7 +256,7 @@ function pageinfo() { // draft $draft = getCacheName($info['client'].$ID, '.draft'); - if(@file_exists($draft)) { + if(file_exists($draft)) { if(@filemtime($draft) < @filemtime(wikiFN($ID))) { // remove stale draft @unlink($draft); @@ -352,7 +352,7 @@ function breadcrumbs() { $crumbs = isset($_SESSION[DOKU_COOKIE]['bc']) ? $_SESSION[DOKU_COOKIE]['bc'] : array(); //we only save on show and existing wiki documents $file = wikiFN($ID); - if($ACT != 'show' || !@file_exists($file)) { + if($ACT != 'show' || !file_exists($file)) { $_SESSION[DOKU_COOKIE]['bc'] = $crumbs; return $crumbs; } @@ -853,7 +853,7 @@ function checklock($id) { $lock = wikiLockFN($id); //no lockfile - if(!@file_exists($lock)) return false; + if(!file_exists($lock)) return false; //lockfile expired if((time() - filemtime($lock)) > $conf['locktime']) { @@ -907,7 +907,7 @@ function unlock($id) { global $INPUT; $lock = wikiLockFN($id); - if(@file_exists($lock)) { + if(file_exists($lock)) { @list($ip, $session) = explode("\n", io_readFile($lock)); if($ip == $INPUT->server->str('REMOTE_USER') || $ip == clientIP() || $session == session_id()) { @unlink($lock); @@ -1010,13 +1010,13 @@ function pageTemplate($id) { // if the before event did not set a template file, try to find one if(empty($data['tplfile'])) { $path = dirname(wikiFN($id)); - if(@file_exists($path.'/_template.txt')) { + 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')) { + if(file_exists($path.'/__template.txt')) { $data['tplfile'] = $path.'/__template.txt'; break; } @@ -1197,13 +1197,13 @@ function saveWikiText($id, $text, $summary, $minor = false) { $file = wikiFN($id); $old = @filemtime($file); // from page $wasRemoved = (trim($text) == ''); // check for empty or whitespace only - $wasCreated = !@file_exists($file); + $wasCreated = !file_exists($file); $wasReverted = ($REV == true); $pagelog = new PageChangeLog($id, 1024); $newRev = false; $oldRev = $pagelog->getRevisions(-1, 1); // from changelog $oldRev = (int) (empty($oldRev) ? 0 : $oldRev[0]); - if(!@file_exists(wikiFN($id, $old)) && @file_exists($file) && $old >= $oldRev) { + if(!file_exists(wikiFN($id, $old)) && file_exists($file) && $old >= $oldRev) { // add old revision to the attic if missing saveOldRevision($id); // add a changelog entry if this edit came from outside dokuwiki @@ -1285,7 +1285,7 @@ function saveWikiText($id, $text, $summary, $minor = false) { */ function saveOldRevision($id) { $oldf = wikiFN($id); - if(!@file_exists($oldf)) return ''; + if(!file_exists($oldf)) return ''; $date = filemtime($oldf); $newf = wikiFN($id, $date); io_writeWikiPage($newf, rawWiki($id), $id, $date); @@ -1743,7 +1743,7 @@ function license_img($type) { $try[] = 'lib/images/license/'.$type.'/cc.png'; } foreach($try as $src) { - if(@file_exists(DOKU_INC.$src)) return $src; + if(file_exists(DOKU_INC.$src)) return $src; } return ''; } -- cgit v1.2.3 From 326dd43a06ec0806d8771d08a0733d63090e126f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 7 Jan 2015 10:56:28 +0100 Subject: Remove IE6 workaround for redirects with hashes We no longer support IE6, so hashes in URLs no longer need to be protected when redirecting. --- inc/common.php | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 9b330000b..5a8b5c900 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1807,17 +1807,6 @@ function send_redirect($url) { // always close the session session_write_close(); - // work around IE bug - // http://www.ianhoar.com/2008/11/16/internet-explorer-6-and-redirected-anchor-links/ - @list($url, $hash) = explode('#', $url); - if($hash) { - if(strpos($url, '?')) { - $url = $url.'&#'.$hash; - } else { - $url = $url.'?&#'.$hash; - } - } - // check if running on IIS < 6 with CGI-PHP if($INPUT->server->has('SERVER_SOFTWARE') && $INPUT->server->has('GATEWAY_INTERFACE') && (strpos($INPUT->server->str('GATEWAY_INTERFACE'), 'CGI') !== false) && -- cgit v1.2.3