From c1482d1c08360e6401534a1391da2b650c37d34d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 30 Aug 2023 17:03:06 +0200 Subject: [PATCH] codestyle adjustments: function argument spacing --- _test/phpcs_MigrationAdjustments.xml | 3 - doku.php | 4 +- inc/ChangeLog/MediaChangeLog.php | 2 +- inc/ChangeLog/PageChangeLog.php | 2 +- inc/ChangeLog/RevisionInfo.php | 4 +- inc/Draft.php | 4 +- inc/Mailer.class.php | 6 +- inc/PassHash.php | 6 +- inc/SafeFN.class.php | 12 ++-- inc/Search/Indexer.php | 12 ++-- inc/Sitemap/Mapper.php | 2 +- inc/actions.php | 4 +- inc/auth.php | 12 ++-- inc/common.php | 12 ++-- inc/confutils.php | 40 +++++------ inc/form.php | 32 ++++----- inc/fulltext.php | 64 +++++++++--------- inc/html.php | 12 ++-- inc/indexer.php | 8 +-- inc/infoutils.php | 66 +++++++++---------- inc/init.php | 50 +++++++------- inc/io.php | 60 ++++++++--------- inc/mail.php | 14 ++-- inc/media.php | 80 +++++++++++----------- inc/pluginutils.php | 8 +-- inc/search.php | 66 +++++++++---------- inc/template.php | 4 +- inc/toolbar.php | 8 +-- lib/exe/css.php | 34 +++++----- lib/exe/detail.php | 8 +-- lib/exe/js.php | 22 +++---- lib/exe/manifest.php | 2 +- lib/exe/mediamanager.php | 102 ++++++++++++++--------------- lib/exe/opensearch.php | 6 +- lib/exe/taskrunner.php | 2 +- lib/plugins/extension/helper/extension.php | 2 +- lib/plugins/testing/action.php | 2 +- lib/tpl/dokuwiki/detail.php | 8 +-- lib/tpl/index.php | 6 +- 39 files changed, 394 insertions(+), 397 deletions(-) diff --git a/_test/phpcs_MigrationAdjustments.xml b/_test/phpcs_MigrationAdjustments.xml index c0c3688cd..b1f226faf 100644 --- a/_test/phpcs_MigrationAdjustments.xml +++ b/_test/phpcs_MigrationAdjustments.xml @@ -6,9 +6,6 @@ - - - diff --git a/doku.php b/doku.php index 909a36e93..b5ed8e793 100644 --- a/doku.php +++ b/doku.php @@ -63,7 +63,7 @@ if($DATE_AT) { if($date_parse) { $DATE_AT = $date_parse; } else { // check for UNIX Timestamp - $date_parse = @date('Ymd',$DATE_AT); + $date_parse = @date('Ymd', $DATE_AT); if(!$date_parse || $date_parse === '19700101') { msg(sprintf($lang['unable_to_parse_date'], hsc($DATE_AT))); $DATE_AT = null; @@ -81,7 +81,7 @@ if($DATE_AT) { $DATE_AT = null; } elseif ($rev_t === false) { //page did not exist - $rev_n = $pagelog->getRelativeRevision($DATE_AT,+1); + $rev_n = $pagelog->getRelativeRevision($DATE_AT, +1); msg( sprintf( $lang['page_nonexist_rev'], diff --git a/inc/ChangeLog/MediaChangeLog.php b/inc/ChangeLog/MediaChangeLog.php index 54bdc14e0..4c4d420f8 100644 --- a/inc/ChangeLog/MediaChangeLog.php +++ b/inc/ChangeLog/MediaChangeLog.php @@ -48,7 +48,7 @@ class MediaChangeLog extends ChangeLog // add changelog lines $logline = static::buildLogLine($info, $timestamp); - io_saveFile(mediaMetaFN($this->id,'.changes'), $logline, $append = true); + io_saveFile(mediaMetaFN($this->id, '.changes'), $logline, $append = true); io_saveFile($conf['media_changelog'], $logline, $append = true); //global changelog cache // update cache diff --git a/inc/ChangeLog/PageChangeLog.php b/inc/ChangeLog/PageChangeLog.php index c546eba2a..2230dc172 100644 --- a/inc/ChangeLog/PageChangeLog.php +++ b/inc/ChangeLog/PageChangeLog.php @@ -48,7 +48,7 @@ class PageChangeLog extends ChangeLog // add changelog lines $logline = static::buildLogLine($info, $timestamp); - io_saveFile(metaFN($this->id,'.changes'), $logline, true); + io_saveFile(metaFN($this->id, '.changes'), $logline, true); io_saveFile($conf['changelog'], $logline, true); //global changelog cache // update cache diff --git a/inc/ChangeLog/RevisionInfo.php b/inc/ChangeLog/RevisionInfo.php index cfb486f42..edbc2d7ad 100644 --- a/inc/ChangeLog/RevisionInfo.php +++ b/inc/ChangeLog/RevisionInfo.php @@ -128,7 +128,7 @@ class RevisionInfo if ($checkTimestamp && $this->val('timestamp') === false) { // exact date is unknown for externally deleted file // when unknown, alter formatted string "YYYY-mm-DD HH:MM" to "____-__-__ __:__" - $formatted = preg_replace('/[0-9a-zA-Z]/','_', $formatted); + $formatted = preg_replace('/[0-9a-zA-Z]/', '_', $formatted); } return ''. $formatted .''; } @@ -266,7 +266,7 @@ class RevisionInfo // diff icon will not be shown when external edit occurred // because no attic file to be compared with current. $revs = (new MediaChangeLog($id))->getRevisions(0, 1); - $showLink = (count($revs) && file_exists(mediaFN($id,$revs[0])) && file_exists(mediaFN($id))); + $showLink = (count($revs) && file_exists(mediaFN($id, $revs[0])) && file_exists(mediaFN($id))); if ($showLink) { $param = ['tab_details'=>'history', 'mediado'=>'diff', 'ns'=> getNS($id), 'image'=> $id]; $href = media_managerURL($param, '&'); diff --git a/inc/Draft.php b/inc/Draft.php index 99e0d2c86..6ac089307 100644 --- a/inc/Draft.php +++ b/inc/Draft.php @@ -117,8 +117,8 @@ class Draft "Draft for page $this->id and user $this->client doesn't exist at $this->cname." ); } - $draft = unserialize(io_readFile($this->cname,false)); - return cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); + $draft = unserialize(io_readFile($this->cname, false)); + return cleanText(con($draft['prefix'], $draft['text'], $draft['suffix'], true)); } /** diff --git a/inc/Mailer.class.php b/inc/Mailer.class.php index d83c06911..49aa77d04 100644 --- a/inc/Mailer.class.php +++ b/inc/Mailer.class.php @@ -41,9 +41,9 @@ class Mailer { global $INPUT; $server = parse_url(DOKU_URL, PHP_URL_HOST); - if(strpos($server,'.') === false) $server .= '.localhost'; + if(strpos($server, '.') === false) $server .= '.localhost'; - $this->partid = substr(md5(uniqid(random_int(0, mt_getrandmax()), true)),0, 8).'@'.$server; + $this->partid = substr(md5(uniqid(random_int(0, mt_getrandmax()), true)), 0, 8).'@'.$server; $this->boundary = '__________'.md5(uniqid(random_int(0, mt_getrandmax()), true)); $listid = implode('.', array_reverse(explode('/', DOKU_BASE))).$server; @@ -453,7 +453,7 @@ class Mailer { $mime .= '--'.$this->boundary.MAILHEADER_EOL; $mime .= $this->wrappedHeaderLine('Content-Type', $media['mime'].'; id="'.$cid.'"'); $mime .= $this->wrappedHeaderLine('Content-Transfer-Encoding', 'base64'); - $mime .= $this->wrappedHeaderLine('Content-ID',"<$cid>"); + $mime .= $this->wrappedHeaderLine('Content-ID', "<$cid>"); if($media['embed']) { $mime .= $this->wrappedHeaderLine('Content-Disposition', 'inline; filename='.$media['name']); } else { diff --git a/inc/PassHash.php b/inc/PassHash.php index a0759800e..f8896f6ff 100644 --- a/inc/PassHash.php +++ b/inc/PassHash.php @@ -94,7 +94,7 @@ class PassHash { if(!defined('PASSWORD_'.strtoupper($m[1]))) { throw new \Exception('This PHP installation has no '.strtoupper($m[1]).' support'); } - return password_verify($clear,$hash); + return password_verify($clear, $hash); } elseif($len == 32) { $method = 'md5'; } elseif($len == 40) { @@ -745,7 +745,7 @@ class PassHash { if(!defined('PASSWORD_ARGON2I')) { throw new \Exception('This PHP installation has no ARGON2I support'); } - return password_hash($clear,PASSWORD_ARGON2I); + return password_hash($clear, PASSWORD_ARGON2I); } /** @@ -763,7 +763,7 @@ class PassHash { if(!defined('PASSWORD_ARGON2ID')) { throw new \Exception('This PHP installation has no ARGON2ID support'); } - return password_hash($clear,PASSWORD_ARGON2ID); + return password_hash($clear, PASSWORD_ARGON2ID); } /** diff --git a/inc/SafeFN.class.php b/inc/SafeFN.class.php index 4e050ef52..82e67874a 100644 --- a/inc/SafeFN.class.php +++ b/inc/SafeFN.class.php @@ -79,11 +79,11 @@ class SafeFN { } public static function validatePrintableUtf8($printable_utf8) { - return !preg_match('#[\x01-\x1f]#',$printable_utf8); + return !preg_match('#[\x01-\x1f]#', $printable_utf8); } public static function validateSafe($safe) { - return !preg_match('#[^'.self::$plain.self::$post_indicator.self::$pre_indicator.']#',$safe); + return !preg_match('#[^'.self::$plain.self::$post_indicator.self::$pre_indicator.']#', $safe); } /** @@ -100,7 +100,7 @@ class SafeFN { $converted = false; foreach ($unicode as $codepoint) { - if ($codepoint < 127 && (strpos(self::$plain.self::$post_indicator,chr($codepoint))!==false)) { + if ($codepoint < 127 && (strpos(self::$plain.self::$post_indicator, chr($codepoint))!==false)) { if ($converted) { $safe .= self::$post_indicator; $converted = false; @@ -110,7 +110,7 @@ class SafeFN { $safe .= self::$pre_indicator; $converted = true; } else { - $safe .= self::$pre_indicator.base_convert((string)($codepoint-32),10,36); + $safe .= self::$pre_indicator.base_convert((string)($codepoint-32), 10, 36); $converted = true; } } @@ -129,7 +129,7 @@ class SafeFN { private static function safeToUnicode($safe) { $unicode = []; - $split = preg_split('#(?=['.self::$post_indicator.self::$pre_indicator.'])#',$safe,-1,PREG_SPLIT_NO_EMPTY); + $split = preg_split('#(?=['.self::$post_indicator.self::$pre_indicator.'])#', $safe, -1, PREG_SPLIT_NO_EMPTY); $converted = false; foreach ($split as $sub) { @@ -147,7 +147,7 @@ class SafeFN { $converted = true; } else { // a single codepoint in base36, adjusted for initial 32 non-printable chars - $unicode[] = 32 + (int)base_convert(substr($sub,1),36,10); + $unicode[] = 32 + (int)base_convert(substr($sub, 1), 36, 10); $converted = true; } } diff --git a/inc/Search/Indexer.php b/inc/Search/Indexer.php index 3ec7c5529..87f4831ba 100644 --- a/inc/Search/Indexer.php +++ b/inc/Search/Indexer.php @@ -68,7 +68,7 @@ class Indexer { // Remove obsolete index entries $pageword_idx = $this->getIndexKey('pageword', '', $pid); if ($pageword_idx !== '') { - $oldwords = explode(':',$pageword_idx); + $oldwords = explode(':', $pageword_idx); $delwords = array_diff($oldwords, $pagewords); $upwords = []; foreach ($delwords as $word) { @@ -402,7 +402,7 @@ class Indexer { // Remove obsolete index entries $pageword_idx = $this->getIndexKey('pageword', '', $pid); if ($pageword_idx !== '') { - $delwords = explode(':',$pageword_idx); + $delwords = explode(':', $pageword_idx); $upwords = []; foreach ($delwords as $word) { if ($word != '') { @@ -457,9 +457,9 @@ class Indexer { $dir = @opendir($conf['indexdir']); if($dir!==false){ while(($f = readdir($dir)) !== false){ - if(substr($f,-4)=='.idx' && - (substr($f,0,1)=='i' || substr($f,0,1)=='w' - || substr($f,-6)=='_w.idx' || substr($f,-6)=='_i.idx' || substr($f,-6)=='_p.idx')) + if(substr($f, -4)=='.idx' && + (substr($f, 0, 1)=='i' || substr($f, 0, 1)=='w' + || substr($f, -6)=='_w.idx' || substr($f, -6)=='_i.idx' || substr($f, -6)=='_p.idx')) @unlink($conf['indexdir']."/$f"); } } @@ -1152,7 +1152,7 @@ class Indexer { */ protected function updateTuple($line, $id, $count) { if ($line != ''){ - $line = preg_replace('/(^|:)'.preg_quote($id,'/').'\*\d*/', '', $line); + $line = preg_replace('/(^|:)'.preg_quote($id, '/').'\*\d*/', '', $line); } $line = trim($line, ':'); if ($count) { diff --git a/inc/Sitemap/Mapper.php b/inc/Sitemap/Mapper.php index 2b5fcfcb0..9db028eee 100644 --- a/inc/Sitemap/Mapper.php +++ b/inc/Sitemap/Mapper.php @@ -59,7 +59,7 @@ class Mapper { foreach($pages as $id){ //skip hidden, non existing and restricted files if(isHiddenPage($id)) continue; - if(auth_aclcheck($id,'',[]) < AUTH_READ) continue; + if(auth_aclcheck($id, '', []) < AUTH_READ) continue; $item = Item::createFromID($id); if ($item instanceof Item) $items[] = $item; diff --git a/inc/actions.php b/inc/actions.php index 87017f8e0..d027b2f49 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -16,7 +16,7 @@ function act_dispatch(){ $router = ActionRouter::getInstance(true); $headers = ['Content-Type: text/html; charset=utf-8']; - Event::createAndTrigger('ACTION_HEADERS_SEND',$headers,'act_sendheaders'); + Event::createAndTrigger('ACTION_HEADERS_SEND', $headers, 'act_sendheaders'); // clear internal variables unset($router); @@ -57,7 +57,7 @@ function act_clean($act){ //remove all bad chars $act = strtolower($act); - $act = preg_replace('/[^1-9a-z_]+/','',$act); + $act = preg_replace('/[^1-9a-z_]+/', '', $act); if($act == 'export_html') $act = 'export_xhtml'; if($act == 'export_htmlbody') $act = 'export_xhtmlbody'; diff --git a/inc/auth.php b/inc/auth.php index 0fae22984..0e0f8a10f 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -132,15 +132,15 @@ function auth_loadACL() { foreach($acl as $line) { $line = trim($line); if(empty($line) || ($line[0] == '#')) continue; // skip blank lines & comments - [$id, $rest] = preg_split('/[ \t]+/',$line,2); + [$id, $rest] = preg_split('/[ \t]+/', $line, 2); // substitute user wildcard first (its 1:1) if(strstr($line, '%USER%')){ // if user is not logged in, this ACL line is meaningless - skip it if (!$INPUT->server->has('REMOTE_USER')) continue; - $id = str_replace('%USER%',cleanID($INPUT->server->str('REMOTE_USER')),$id); - $rest = str_replace('%USER%',auth_nameencode($INPUT->server->str('REMOTE_USER')),$rest); + $id = str_replace('%USER%', cleanID($INPUT->server->str('REMOTE_USER')), $id); + $rest = str_replace('%USER%', auth_nameencode($INPUT->server->str('REMOTE_USER')), $rest); } // substitute group wildcard (its 1:m) @@ -148,8 +148,8 @@ function auth_loadACL() { // if user is not logged in, grps is empty, no output will be added (i.e. skipped) if(isset($USERINFO['grps'])){ foreach((array) $USERINFO['grps'] as $grp){ - $nid = str_replace('%GROUP%',cleanID($grp),$id); - $nrest = str_replace('%GROUP%','@'.auth_nameencode($grp),$rest); + $nid = str_replace('%GROUP%', cleanID($grp), $id); + $nrest = str_replace('%GROUP%', '@'.auth_nameencode($grp), $rest); $out[] = "$nid\t$nrest"; } } @@ -781,7 +781,7 @@ function auth_nameencode($name, $skip_group = false) { * @return string */ function auth_nameencode_callback($matches) { - return '%'.dechex(ord(substr($matches[1],-1))); + return '%'.dechex(ord(substr($matches[1], -1))); } /** diff --git a/inc/common.php b/inc/common.php index c85bd1a6c..86404cf1a 100644 --- a/inc/common.php +++ b/inc/common.php @@ -623,13 +623,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&', $abs = false) $more = buildURLparams($more, $sep); } else { $matches = []; - if (preg_match_all('/\b(w|h)=(\d*)\b/',$more,$matches,PREG_SET_ORDER) || $isexternalimage){ + if (preg_match_all('/\b(w|h)=(\d*)\b/', $more, $matches, PREG_SET_ORDER) || $isexternalimage){ $resize = ['w'=>0, 'h'=>0]; foreach ($matches as $match){ $resize[$match[1]] = $match[2]; } $more .= $more === '' ? '' : $sep; - $more .= 'tok='.media_get_token($id,$resize['w'],$resize['h']); + $more .= 'tok='.media_get_token($id, $resize['w'], $resize['h']); } $more = str_replace('cache=cache', '', $more); //skip default $more = str_replace(',,', ',', $more); @@ -870,7 +870,7 @@ function clientismobile() { * @return bool */ function link_isinterwiki($link){ - if (preg_match('/^[a-zA-Z0-9\.]+>/u',$link)) return true; + if (preg_match('/^[a-zA-Z0-9\.]+>/u', $link)) return true; return false; } @@ -1369,7 +1369,7 @@ function getGoogleQuery() { // only handle common SEs if(!array_key_exists('host', $url)) return ''; - if(!preg_match('/(google|bing|yahoo|ask|duckduckgo|babylon|aol|yandex)/',$url['host'])) return ''; + if(!preg_match('/(google|bing|yahoo|ask|duckduckgo|babylon|aol|yandex)/', $url['host'])) return ''; $query = []; if(!array_key_exists('query', $url)) return ''; @@ -1541,7 +1541,7 @@ function unslash($string, $char = "'") { * @return int */ function php_to_byte($value) { - switch (strtoupper(substr($value,-1))) { + switch (strtoupper(substr($value, -1))) { case 'G': $ret = (int) substr($value, 0, -1) * 1024 * 1024 * 1024; break; @@ -1979,7 +1979,7 @@ function inlineSVG($file, $maxsize = 2048) { if(filesize($file) > $maxsize) return false; if(!is_readable($file)) return false; $content = file_get_contents($file); - $content = preg_replace('/)/s','', $content); // comments + $content = preg_replace('/)/s', '', $content); // comments $content = preg_replace('/<\?xml .*?\?>/i', '', $content); // xml header $content = preg_replace('//i', '', $content); // doc type $content = preg_replace('/>\s+<', $content); // newlines between tags diff --git a/inc/confutils.php b/inc/confutils.php index 1261d1fbc..127b07603 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -43,7 +43,7 @@ function mimetype($file, $knownonly=true){ } } if($mtypes[$ext][0] == '!'){ - return [$ext, substr($mtypes[$ext],1), true]; + return [$ext, substr($mtypes[$ext], 1), true]; }else{ return [$ext, $mtypes[$ext], false]; } @@ -57,7 +57,7 @@ function mimetype($file, $knownonly=true){ function getMimeTypes() { static $mime = null; if ( !$mime ) { - $mime = retrieveConfig('mime','confToHash'); + $mime = retrieveConfig('mime', 'confToHash'); $mime = array_filter($mime); } return $mime; @@ -71,7 +71,7 @@ function getMimeTypes() { function getAcronyms() { static $acronyms = null; if ( !$acronyms ) { - $acronyms = retrieveConfig('acronyms','confToHash'); + $acronyms = retrieveConfig('acronyms', 'confToHash'); $acronyms = array_filter($acronyms, 'strlen'); } return $acronyms; @@ -85,7 +85,7 @@ function getAcronyms() { function getSmileys() { static $smileys = null; if ( !$smileys ) { - $smileys = retrieveConfig('smileys','confToHash'); + $smileys = retrieveConfig('smileys', 'confToHash'); $smileys = array_filter($smileys, 'strlen'); } return $smileys; @@ -99,7 +99,7 @@ function getSmileys() { function getEntities() { static $entities = null; if ( !$entities ) { - $entities = retrieveConfig('entities','confToHash'); + $entities = retrieveConfig('entities', 'confToHash'); $entities = array_filter($entities, 'strlen'); } return $entities; @@ -113,7 +113,7 @@ function getEntities() { function getInterwiki() { static $wikis = null; if ( !$wikis ) { - $wikis = retrieveConfig('interwiki','confToHash',[true]); + $wikis = retrieveConfig('interwiki', 'confToHash', [true]); $wikis = array_filter($wikis, 'strlen'); //add sepecial case 'this' @@ -176,7 +176,7 @@ function getCdnUrls() { function getWordblocks() { static $wordblocks = null; if ( !$wordblocks ) { - $wordblocks = retrieveConfig('wordblock','file',null,'array_merge_with_removal'); + $wordblocks = retrieveConfig('wordblock', 'file', null, 'array_merge_with_removal'); } return $wordblocks; } @@ -189,7 +189,7 @@ function getWordblocks() { function getSchemes() { static $schemes = null; if ( !$schemes ) { - $schemes = retrieveConfig('scheme','file',null,'array_merge_with_removal'); + $schemes = retrieveConfig('scheme', 'file', null, 'array_merge_with_removal'); $schemes = array_map('trim', $schemes); $schemes = preg_replace('/^#.*/', '', $schemes); $schemes = array_filter($schemes); @@ -299,12 +299,12 @@ function retrieveConfig($type,$fn,$params=null,$combine='array_merge') { if(!is_array($params)) $params = []; $combined = []; - if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING); + if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"', E_USER_WARNING); foreach (['default', 'local', 'protected'] as $config_group) { if (empty($config_cascade[$type][$config_group])) continue; foreach ($config_cascade[$type][$config_group] as $file) { if (file_exists($file)) { - $config = call_user_func_array($fn,array_merge([$file],$params)); + $config = call_user_func_array($fn, array_merge([$file], $params)); $combined = $combine($combined, $config); } } @@ -325,7 +325,7 @@ function getConfigFiles($type) { global $config_cascade; $files = []; - if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING); + if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"', E_USER_WARNING); foreach (['default', 'local', 'protected'] as $config_group) { if (empty($config_cascade[$type][$config_group])) continue; $files = array_merge($files, $config_cascade[$type][$config_group]); @@ -349,8 +349,8 @@ function actionOK($action){ global $auth; // prepare disabled actions array and handle legacy options - $disabled = explode(',',$conf['disableactions']); - $disabled = array_map('trim',$disabled); + $disabled = explode(',', $conf['disableactions']); + $disabled = array_map('trim', $disabled); if((isset($conf['openregister']) && !$conf['openregister']) || is_null($auth) || !$auth->canDo('addUser')) { $disabled[] = 'register'; } @@ -375,7 +375,7 @@ function actionOK($action){ $disabled = array_unique($disabled); } - return !in_array($action,$disabled); + return !in_array($action, $disabled); } /** @@ -438,9 +438,9 @@ function conf_encodeString($str,$code) { * @return string plain text */ function conf_decodeString($str) { - switch (substr($str,0,3)) { - case '' : return base64_decode(substr($str,3)); - case '' : return convert_uudecode(substr($str,3)); + switch (substr($str, 0, 3)) { + case '' : return base64_decode(substr($str, 3)); + case '' : return convert_uudecode(substr($str, 3)); default: // not encoded (or unknown) return $str; } @@ -456,8 +456,8 @@ function conf_decodeString($str) { */ function array_merge_with_removal($current, $new) { foreach ($new as $val) { - if (substr($val,0,1) == DOKU_CONF_NEGATION) { - $idx = array_search(trim(substr($val,1)),$current); + if (substr($val, 0, 1) == DOKU_CONF_NEGATION) { + $idx = array_search(trim(substr($val, 1)), $current); if ($idx !== false) { unset($current[$idx]); } @@ -466,6 +466,6 @@ function array_merge_with_removal($current, $new) { } } - return array_slice($current,0); + return array_slice($current, 0); } //Setup VIM: ex: et ts=4 : diff --git a/inc/form.php b/inc/form.php index e93be0f27..9202bd230 100644 --- a/inc/form.php +++ b/inc/form.php @@ -279,7 +279,7 @@ class Doku_Form global $lang; $form = ''; $this->params['accept-charset'] = $lang['encoding']; - $form .= '
params,false) .'>
'. DOKU_LF; + $form .= 'params, false) .'>
'. DOKU_LF; if (!empty($this->_hidden)) { foreach ($this->_hidden as $name => $value) $form .= form_hidden(array('name'=>$name, 'value'=>$value)); @@ -685,7 +685,7 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' // FIXME: php doesn't know the difference between a string and an integer if (is_string(key($values))) { foreach ($values as $val => $text) { - $options[] = array($val, $text, in_array($val,$selected)); + $options[] = array($val, $text, in_array($val, $selected)); } } else { foreach ($values as $val) { @@ -716,7 +716,7 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' * @return string html of tag */ function form_tag($attrs) { - return '<'.$attrs['_tag'].' '. buildAttributes($attrs,true) .'/>'; + return '<'.$attrs['_tag'].' '. buildAttributes($attrs, true) .'/>'; } /** @@ -732,7 +732,7 @@ function form_tag($attrs) { * @return string html of tag */ function form_opentag($attrs) { - return '<'.$attrs['_tag'].' '. buildAttributes($attrs,true) .'>'; + return '<'.$attrs['_tag'].' '. buildAttributes($attrs, true) .'>'; } /** @@ -764,7 +764,7 @@ function form_closetag($attrs) { * @return string html */ function form_openfieldset($attrs) { - $s = '
'; + $s = '
'; if (!is_null($attrs['_legend'])) $s .= ''.$attrs['_legend'].''; return $s; } @@ -816,7 +816,7 @@ function form_wikitext($attrs) { unset($attrs['name']); unset($attrs['id']); return ''; } @@ -837,7 +837,7 @@ function form_button($attrs) { $p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : ''; $value = $attrs['value']; unset($attrs['value']); - return ''; + return ''; } /** @@ -858,7 +858,7 @@ function form_field($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].''; - $s .= ' '; + $s .= ' '; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -881,7 +881,7 @@ function form_fieldright($attrs) { $s = ''; + $s .= '>'; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; @@ -908,7 +908,7 @@ function form_textfield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -934,7 +934,7 @@ function form_passwordfield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''; + $s .= ''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; return $s; @@ -960,7 +960,7 @@ function form_filefield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''; $attrs['value'] = $attrs['value'][0]; } - $s .= ''; + $s .= ''; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; @@ -1022,7 +1022,7 @@ function form_radiofield($attrs) { $s = ''; + $s .= '>'; $s .= ' '.$attrs['_text'].''; if (preg_match('/(^| )block($| )/', $attrs['_class'])) $s .= '
'; @@ -1051,7 +1051,7 @@ function form_menufield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].''; - $s .= ' '.DOKU_LF; if (!empty($attrs['_options'])) { $selected = false; @@ -1098,7 +1098,7 @@ function form_listboxfield($attrs) { if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"'; if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"'; $s .= '>'.$attrs['_text'].' '; - $s .= ''.DOKU_LF; if (!empty($attrs['_options'])) { foreach ($attrs['_options'] as $opt) { @list($value, $text, $select, $disabled) = $opt; diff --git a/inc/fulltext.php b/inc/fulltext.php index 3c90d60c6..27da093dd 100644 --- a/inc/fulltext.php +++ b/inc/fulltext.php @@ -15,7 +15,7 @@ use dokuwiki\Utf8\Sort; /** * create snippets for the first few results only */ -if(!defined('FT_SNIPPET_NUMBER')) define('FT_SNIPPET_NUMBER',15); +if(!defined('FT_SNIPPET_NUMBER')) define('FT_SNIPPET_NUMBER', 15); /** * The fulltext search @@ -101,7 +101,7 @@ function _ft_pageSearch(&$data) { 'phrase' => $phrase, 'text' => rawWiki($id) ]; - $evt = new Event('FULLTEXT_PHRASE_MATCH',$evdata); + $evt = new Event('FULLTEXT_PHRASE_MATCH', $evdata); if ($evt->advise_before() && $evt->result !== true) { $text = PhpString::strtolower($evdata['text']); if (strpos($text, $phrase) !== false) { @@ -326,7 +326,7 @@ function _ft_pageLookup(&$data){ $pages = _ft_filterResultsByTime($pages, $data['after'], $data['before']); - uksort($pages,'ft_pagesorter'); + uksort($pages, 'ft_pagesorter'); return $pages; } @@ -390,14 +390,14 @@ function _ft_pageLookupTitleCompare($search, $title) { * @return int Returns < 0 if $a is less than $b; > 0 if $a is greater than $b, and 0 if they are equal. */ function ft_pagesorter($a, $b){ - $ac = count(explode(':',$a)); - $bc = count(explode(':',$b)); + $ac = count(explode(':', $a)); + $bc = count(explode(':', $b)); if($ac < $bc){ return -1; }elseif($ac > $bc){ return 1; } - return Sort::strcmp($a,$b); + return Sort::strcmp($a, $b); } /** @@ -426,7 +426,7 @@ function ft_pagemtimesorter($a, $b) { */ function ft_snippet($id,$highlight){ $text = rawWiki($id); - $text = str_replace("\xC2\xAD",'',$text); + $text = str_replace("\xC2\xAD", '', $text); // remove soft-hyphens $evdata = [ 'id' => $id, @@ -435,7 +435,7 @@ function ft_snippet($id,$highlight){ 'snippet' => '' ]; - $evt = new Event('FULLTEXT_SNIPPET_CREATE',$evdata); + $evt = new Event('FULLTEXT_SNIPPET_CREATE', $evdata); if ($evt->advise_before()) { $match = []; $snippets = []; @@ -462,11 +462,11 @@ function ft_snippet($id,$highlight){ for ($cnt=4; $cnt--;) { if (0) { - } elseif (preg_match('/'.$re3.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) { + } elseif (preg_match('/'.$re3.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) { - } elseif (preg_match('/'.$re2.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) { + } elseif (preg_match('/'.$re2.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) { - } elseif (preg_match('/'.$re1.'/iu',$text,$match,PREG_OFFSET_CAPTURE,$offset)) { + } elseif (preg_match('/'.$re1.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) { } else { break; @@ -475,20 +475,20 @@ function ft_snippet($id,$highlight){ [$str, $idx] = $match[0]; // convert $idx (a byte offset) into a utf8 character offset - $utf8_idx = PhpString::strlen(substr($text,0,$idx)); + $utf8_idx = PhpString::strlen(substr($text, 0, $idx)); $utf8_len = PhpString::strlen($str); // establish context, 100 bytes surrounding the match string // first look to see if we can go 100 either side, // then drop to 50 adding any excess if the other side can't go to 50, - $pre = min($utf8_idx-$utf8_offset,100); - $post = min($len-$utf8_idx-$utf8_len,100); + $pre = min($utf8_idx-$utf8_offset, 100); + $post = min($len-$utf8_idx-$utf8_len, 100); if ($pre>50 && $post>50) { $pre = 50; $post = 50; } elseif ($pre>50) { - $pre = min($pre,100-$post); + $pre = min($pre, 100-$post); } elseif ($post>50) { $post = min($post, 100-$pre); } elseif ($offset == 0) { @@ -506,9 +506,9 @@ function ft_snippet($id,$highlight){ $end = $utf8_idx + $utf8_len + $post; // now set it to the end of this context if ($append) { - $snippets[count($snippets)-1] .= PhpString::substr($text,$append,$end-$append); + $snippets[count($snippets)-1] .= PhpString::substr($text, $append, $end-$append); } else { - $snippets[] = PhpString::substr($text,$start,$end-$start); + $snippets[] = PhpString::substr($text, $start, $end-$start); } // set $offset for next match attempt @@ -517,12 +517,12 @@ function ft_snippet($id,$highlight){ // this prevents further matching of this snippet but for possible matches of length // smaller than match length + context (at least 50 characters) this match is part of the context $utf8_offset = $utf8_idx + $utf8_len; - $offset = $idx + strlen(PhpString::substr($text,$utf8_idx,$utf8_len)); - $offset = Clean::correctIdx($text,$offset); + $offset = $idx + strlen(PhpString::substr($text, $utf8_idx, $utf8_len)); + $offset = Clean::correctIdx($text, $offset); } $m = "\1"; - $snippets = preg_replace('/'.$re1.'/iu',$m.'$1'.$m,$snippets); + $snippets = preg_replace('/'.$re1.'/iu', $m.'$1'.$m, $snippets); $snippet = preg_replace( '/' . $m . '([^' . $m . ']*?)' . $m . '/iu', '$1', @@ -558,14 +558,14 @@ function ft_snippet_re_preprocess($term) { $BR = '\b'; } - if(substr($term,0,2) == '\\*'){ - $term = substr($term,2); + if(substr($term, 0, 2) == '\\*'){ + $term = substr($term, 2); }else{ $term = $BL.$term; } - if(substr($term,-2,2) == '\\*'){ - $term = substr($term,0,-2); + if(substr($term, -2, 2) == '\\*'){ + $term = substr($term, 0, -2); }else{ $term .= $BR; } @@ -720,8 +720,8 @@ function ft_queryParser($Indexer, $query){ $term = str_replace('"', ' ', $term); // fix parentheses - $term = str_replace(')' , ' ) ', $term); - $term = str_replace('(' , ' ( ', $term); + $term = str_replace(')', ' ) ', $term); + $term = str_replace('(', ' ( ', $term); $term = str_replace('- (', ' -(', $term); // treat pipe symbols as 'OR' operators @@ -729,7 +729,7 @@ function ft_queryParser($Indexer, $query){ // treat ideographic spaces (U+3000) as search term separators // FIXME: some more separators? - $term = preg_replace('/[ \x{3000}]+/u', ' ', $term); + $term = preg_replace('/[ \x{3000}]+/u', ' ', $term); $term = trim($term); if ($term === '') continue; @@ -777,11 +777,11 @@ function ft_queryParser($Indexer, $query){ $parsed_query_old = $parsed_query; $parsed_query = preg_replace('/(NOT)?\(\)/u', '', $parsed_query); } while ($parsed_query !== $parsed_query_old); - $parsed_query = preg_replace('/(NOT|OR)+\)/u', ')' , $parsed_query); - $parsed_query = preg_replace('/(OR)+/u' , 'OR' , $parsed_query); - $parsed_query = preg_replace('/\(OR/u' , '(' , $parsed_query); - $parsed_query = preg_replace('/^OR|OR$/u' , '' , $parsed_query); - $parsed_query = preg_replace('/\)(NOT)?\(/u' , ')AND$1(', $parsed_query); + $parsed_query = preg_replace('/(NOT|OR)+\)/u', ')', $parsed_query); + $parsed_query = preg_replace('/(OR)+/u', 'OR', $parsed_query); + $parsed_query = preg_replace('/\(OR/u', '(', $parsed_query); + $parsed_query = preg_replace('/^OR|OR$/u', '', $parsed_query); + $parsed_query = preg_replace('/\)(NOT)?\(/u', ')AND$1(', $parsed_query); // adjustment: make highlightings right $parens_level = 0; diff --git a/inc/html.php b/inc/html.php index c1260ce28..015a2e3dd 100644 --- a/inc/html.php +++ b/inc/html.php @@ -48,7 +48,7 @@ function html_wikilink($id, $name = null, $search = '') { $xhtml_renderer = p_get_renderer('xhtml'); } - return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); + return $xhtml_renderer->internallink($id, $name, $search, true, 'navigation'); } /** @@ -88,7 +88,7 @@ function html_secedit($text, $show = true) { global $INFO; if ((isset($INFO) && !$INFO['writable']) || !$show || (isset($INFO) && $INFO['rev'])) { - return preg_replace(SEC_EDIT_PATTERN,'',$text); + return preg_replace(SEC_EDIT_PATTERN, '', $text); } return preg_replace_callback(SEC_EDIT_PATTERN, @@ -193,7 +193,7 @@ function html_btn($name, $id, $akey, $params, $method = 'get', $tooltip = '', $l $label = $lang['btn_'.$name]; //filter id (without urlencoding) - $id = idfilter($id,false); + $id = idfilter($id, false); //make nice URLs even for buttons if ($conf['userewrite'] == 2) { @@ -281,7 +281,7 @@ function html_hilight($html, $phrases) { $phrases = array_map('ft_snippet_re_preprocess', $phrases); $phrases = array_filter($phrases); - $regex = implode('|',$phrases); + $regex = implode('|', $phrases); if ($regex === '') return $html; if (!Clean::isUtf8($regex)) return $html; @@ -725,7 +725,7 @@ function html_debug() { print ''; print 'locale:
';
-    print setlocale(LC_ALL,0);
+    print setlocale(LC_ALL, 0);
     print '
'; print 'encoding:
';
@@ -735,7 +735,7 @@ function html_debug() {
     if ($auth) {
         print 'Auth backend capabilities:
';
         foreach ($auth->getCapabilities() as $cando) {
-            print '   '.str_pad($cando,16) .' => '. (int)$auth->canDo($cando) . DOKU_LF;
+            print '   '.str_pad($cando, 16) .' => '. (int)$auth->canDo($cando) . DOKU_LF;
         }
         print '
'; } diff --git a/inc/indexer.php b/inc/indexer.php index 44745520f..d7a6625a3 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -14,7 +14,7 @@ use dokuwiki\Search\Indexer; define('INDEXER_VERSION', 8); // set the minimum token length to use in the index (note, this doesn't apply to numeric tokens) -if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH',2); +if (!defined('IDX_MINWORDLENGTH')) define('IDX_MINWORDLENGTH', 2); /** * Version of the indexer taking into consideration the external tokenizer. @@ -60,7 +60,7 @@ function wordlen($w){ $l = strlen($w); // If left alone, all chinese "words" will get put into w3.idx // So the "length" of a "word" is faked - if(preg_match_all('/[\xE2-\xEF]/',$w,$leadbytes)) { + if(preg_match_all('/[\xE2-\xEF]/', $w, $leadbytes)) { foreach($leadbytes[0] as $b) $l += ord($b) - 0xE1; } @@ -116,7 +116,7 @@ function & idx_get_stopwords() { * @author Tom N Harris */ function idx_addPage($page, $verbose=false, $force=false) { - $idxtag = metaFN($page,'.indexed'); + $idxtag = metaFN($page, '.indexed'); // check if page was deleted but is still in the index if (!page_exists($page)) { if (!file_exists($idxtag)) { @@ -201,7 +201,7 @@ function idx_addPage($page, $verbose=false, $force=false) { } if ($result) - io_saveFile(metaFN($page,'.indexed'), idx_get_version()); + io_saveFile(metaFN($page, '.indexed'), idx_get_version()); if ($verbose) { print("Indexer: finished".DOKU_LF); return true; diff --git a/inc/infoutils.php b/inc/infoutils.php index 4e5076f6c..4e3ef09ef 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -13,9 +13,9 @@ use dokuwiki\Logger; if(!defined('DOKU_MESSAGEURL')){ if(in_array('ssl', stream_get_transports())) { - define('DOKU_MESSAGEURL','https://update.dokuwiki.org/check/'); + define('DOKU_MESSAGEURL', 'https://update.dokuwiki.org/check/'); }else{ - define('DOKU_MESSAGEURL','http://update.dokuwiki.org/check/'); + define('DOKU_MESSAGEURL', 'http://update.dokuwiki.org/check/'); } } @@ -45,7 +45,7 @@ function checkUpdateMessages(){ if(is_string($resp) && ($resp == "" || substr(trim($resp), -1) == '%')) { // basic sanity check that this is either an empty string response (ie "no messages") // or it looks like one of our messages, not WiFi login or other interposed response - io_saveFile($cf,$resp); + io_saveFile($cf, $resp); } else { Logger::debug("checkUpdateMessages(): unexpected HTTP response received", $http->error); } @@ -55,9 +55,9 @@ function checkUpdateMessages(){ $data = io_readFile($cf); // show messages through the usual message mechanism - $msgs = explode("\n%\n",$data); + $msgs = explode("\n%\n", $data); foreach($msgs as $msg){ - if($msg) msg($msg,2); + if($msg) msg($msg, 2); } } @@ -155,14 +155,14 @@ function check(){ global $INPUT; if ($INFO['isadmin'] || $INFO['ismanager']) { - msg('DokuWiki version: '.getVersion(),1); - if(version_compare(phpversion(),'7.4.0','<')){ - msg('Your PHP version is too old ('.phpversion().' vs. 7.4+ needed)',-1); + msg('DokuWiki version: '.getVersion(), 1); + if(version_compare(phpversion(), '7.4.0', '<')){ + msg('Your PHP version is too old ('.phpversion().' vs. 7.4+ needed)', -1); }else{ - msg('PHP version '.phpversion(),1); + msg('PHP version '.phpversion(), 1); } - } elseif (version_compare(phpversion(),'7.4.0','<')) { - msg('Your PHP version is too old',-1); + } elseif (version_compare(phpversion(), '7.4.0', '<')) { + msg('Your PHP version is too old', -1); } $mem = php_to_byte(ini_get('memory_limit')); @@ -184,9 +184,9 @@ function check(){ } if (is_writable($conf['changelog'])) { - msg('Changelog is writable',1); + msg('Changelog is writable', 1); } elseif (file_exists($conf['changelog'])) { - msg('Changelog is not writable',-1); + msg('Changelog is not writable', -1); } if (isset($conf['changelog_old']) && file_exists($conf['changelog_old'])) { @@ -205,31 +205,31 @@ function check(){ } if(is_writable(DOKU_CONF)){ - msg('conf directory is writable',1); + msg('conf directory is writable', 1); }else{ - msg('conf directory is not writable',-1); + msg('conf directory is not writable', -1); } if($conf['authtype'] == 'plain'){ global $config_cascade; if(is_writable($config_cascade['plainauth.users']['default'])){ - msg('conf/users.auth.php is writable',1); + msg('conf/users.auth.php is writable', 1); }else{ - msg('conf/users.auth.php is not writable',0); + msg('conf/users.auth.php is not writable', 0); } } if(function_exists('mb_strpos')){ if(defined('UTF8_NOMBSTRING')){ - msg('mb_string extension is available but will not be used',0); + msg('mb_string extension is available but will not be used', 0); }else{ - msg('mb_string extension is available and will be used',1); + msg('mb_string extension is available and will be used', 1); if(ini_get('mbstring.func_overload') != 0){ - msg('mb_string function overloading is enabled, this will cause problems and should be disabled',-1); + msg('mb_string function overloading is enabled, this will cause problems and should be disabled', -1); } } }else{ - msg('mb_string extension not available - PHP only replacements will be used',0); + msg('mb_string extension not available - PHP only replacements will be used', 0); } if (!UTF8_PREGSUPPORT) { @@ -241,28 +241,28 @@ function check(){ $loc = setlocale(LC_ALL, 0); if(!$loc){ - msg('No valid locale is set for your PHP setup. You should fix this',-1); - }elseif(stripos($loc,'utf') === false){ + msg('No valid locale is set for your PHP setup. You should fix this', -1); + }elseif(stripos($loc, 'utf') === false){ msg('Your locale '.hsc($loc).' seems not to be a UTF-8 locale, - you should fix this if you encounter problems.',0); + you should fix this if you encounter problems.', 0); }else{ msg('Valid locale '.hsc($loc).' found.', 1); } if($conf['allowdebug']){ - msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0',-1); + msg('Debugging support is enabled. If you don\'t need it you should set $conf[\'allowdebug\'] = 0', -1); }else{ - msg('Debugging support is disabled',1); + msg('Debugging support is disabled', 1); } if(!empty($INFO['userinfo']['name'])){ - msg('You are currently logged in as '.$INPUT->server->str('REMOTE_USER').' ('.$INFO['userinfo']['name'].')',0); - msg('You are part of the groups '.implode(', ', $INFO['userinfo']['grps']),0); + msg('You are currently logged in as '.$INPUT->server->str('REMOTE_USER').' ('.$INFO['userinfo']['name'].')', 0); + msg('You are part of the groups '.implode(', ', $INFO['userinfo']['grps']), 0); }else{ - msg('You are currently not logged in',0); + msg('You are currently not logged in', 0); } - msg('Your current permission for this page is '.$INFO['perm'],0); + msg('Your current permission for this page is '.$INFO['perm'], 0); if (file_exists($INFO['filepath']) && is_writable($INFO['filepath'])) { msg('The current page is writable by the webserver', 1); @@ -442,7 +442,7 @@ function dbg($msg,$hidden=false){ echo "\n-->"; }else{ echo '
';
-        echo hsc(print_r($msg,true));
+        echo hsc(print_r($msg, true));
         echo '
'; } } @@ -513,7 +513,7 @@ function dbg_backtrace(){ } } } - $params = implode(', ',$params); + $params = implode(', ', $params); $calls[$depth - $i] = sprintf('%s(%s) called at %s', $function, @@ -537,7 +537,7 @@ function dbg_backtrace(){ */ function debug_guard(&$data){ foreach($data as $key => $value){ - if(preg_match('/(notify|pass|auth|secret|ftp|userinfo|token|buid|mail|proxy)/i',$key)){ + if(preg_match('/(notify|pass|auth|secret|ftp|userinfo|token|buid|mail|proxy)/i', $key)){ $data[$key] = '***'; continue; } diff --git a/inc/init.php b/inc/init.php index c21fc1753..398419e5a 100644 --- a/inc/init.php +++ b/inc/init.php @@ -28,13 +28,13 @@ $preload = fullpath(__DIR__).'/preload.php'; if (file_exists($preload)) include($preload); // define the include path -if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(__DIR__.'/../').'/'); +if(!defined('DOKU_INC')) define('DOKU_INC', fullpath(__DIR__.'/../').'/'); // define Plugin dir -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); // define config path (packagers may want to change this to /etc/dokuwiki/) -if(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); +if(!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC.'conf/'); // check for error reporting override or set error reporting to sane values if (!defined('DOKU_E_LEVEL') && file_exists(DOKU_CONF.'report_e_all')) { @@ -97,20 +97,20 @@ foreach (['default', 'local'] as $config_group) { date_default_timezone_set(@date_default_timezone_get()); // define baseURL -if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false)); -if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true)); +if(!defined('DOKU_REL')) define('DOKU_REL', getBaseURL(false)); +if(!defined('DOKU_URL')) define('DOKU_URL', getBaseURL(true)); if(!defined('DOKU_BASE')){ if($conf['canonical']){ - define('DOKU_BASE',DOKU_URL); + define('DOKU_BASE', DOKU_URL); }else{ - define('DOKU_BASE',DOKU_REL); + define('DOKU_BASE', DOKU_REL); } } // define whitespace -if(!defined('NL')) define ('NL',"\n"); -if(!defined('DOKU_LF')) define ('DOKU_LF',"\n"); -if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t"); +if(!defined('NL')) define ('NL', "\n"); +if(!defined('DOKU_LF')) define ('DOKU_LF', "\n"); +if(!defined('DOKU_TAB')) define ('DOKU_TAB', "\t"); // define cookie and session id, append server port when securecookie is configured FS#1664 if (!defined('DOKU_COOKIE')) { @@ -120,7 +120,7 @@ if (!defined('DOKU_COOKIE')) { } // define main script -if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php'); +if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT', 'doku.php'); if(!defined('DOKU_TPL')) { /** @@ -181,7 +181,7 @@ if(!headers_sent() && !defined('NOSESSION')) { } // don't let cookies ever interfere with request vars -$_REQUEST = array_merge($_GET,$_POST); +$_REQUEST = array_merge($_GET, $_POST); // we don't want a purge URL to be digged if(isset($_REQUEST['purge']) && !empty($_SERVER['HTTP_REFERER'])) unset($_REQUEST['purge']); @@ -351,7 +351,7 @@ function init_files(){ foreach($files as $file){ if(!file_exists($file)){ - $fh = @fopen($file,'a'); + $fh = @fopen($file, 'a'); if($fh){ fclose($fh); if($conf['fperm']) chmod($file, $conf['fperm']); @@ -450,32 +450,32 @@ function getBaseURL($abs=null){ if(!empty($conf['basedir'])){ $dir = $conf['basedir']; - }elseif(substr($_SERVER['SCRIPT_NAME'],-4) == '.php'){ + }elseif(substr($_SERVER['SCRIPT_NAME'], -4) == '.php'){ $dir = dirname($_SERVER['SCRIPT_NAME']); - }elseif(substr($_SERVER['PHP_SELF'],-4) == '.php'){ + }elseif(substr($_SERVER['PHP_SELF'], -4) == '.php'){ $dir = dirname($_SERVER['PHP_SELF']); }elseif($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']){ - $dir = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'],'/').'/','', + $dir = preg_replace ('/^'.preg_quote($_SERVER['DOCUMENT_ROOT'], '/').'/', '', $_SERVER['SCRIPT_FILENAME']); $dir = dirname('/'.$dir); }else{ $dir = '.'; //probably wrong } - $dir = str_replace('\\','/',$dir); // bugfix for weird WIN behaviour - $dir = preg_replace('#//+#','/',"/$dir/"); // ensure leading and trailing slashes + $dir = str_replace('\\', '/', $dir); // bugfix for weird WIN behaviour + $dir = preg_replace('#//+#', '/', "/$dir/"); // ensure leading and trailing slashes //handle script in lib/exe dir - $dir = preg_replace('!lib/exe/$!','',$dir); + $dir = preg_replace('!lib/exe/$!', '', $dir); //handle script in lib/plugins dir - $dir = preg_replace('!lib/plugins/.*$!','',$dir); + $dir = preg_replace('!lib/plugins/.*$!', '', $dir); //finish here for relative URLs if(!$abs) return $dir; //use config if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path - if(!empty($conf['baseurl'])) return rtrim($conf['baseurl'],'/').$dir; + if(!empty($conf['baseurl'])) return rtrim($conf['baseurl'], '/').$dir; //split hostheader into host and port if(isset($_SERVER['HTTP_HOST'])){ @@ -595,15 +595,15 @@ function fullpath($path,$exists=false){ $root = '/'; }elseif($iswin){ // match drive letter and UNC paths - if (preg_match('!^([a-zA-z]:)(.*)!',$path,$match)) { + if (preg_match('!^([a-zA-z]:)(.*)!', $path, $match)) { $root = $match[1].'/'; $path = $match[2]; - } elseif (preg_match('!^(\\\\\\\\[^\\\\/]+\\\\[^\\\\/]+[\\\\/])(.*)!',$path,$match)) { + } elseif (preg_match('!^(\\\\\\\\[^\\\\/]+\\\\[^\\\\/]+[\\\\/])(.*)!', $path, $match)) { $root = $match[1]; $path = $match[2]; } } - $path = str_replace('\\','/',$path); + $path = str_replace('\\', '/', $path); // if the given path wasn't absolute already, prepend the script path and retry if(!$root){ @@ -611,7 +611,7 @@ function fullpath($path,$exists=false){ $path = $base.'/'.$path; if($run == 0){ // avoid endless recursion when base isn't absolute for some reason $run++; - return fullpath($path,$exists); + return fullpath($path, $exists); } } $run = 0; diff --git a/inc/io.php b/inc/io.php index 3ac8cc87a..4196214aa 100644 --- a/inc/io.php +++ b/inc/io.php @@ -33,7 +33,7 @@ function io_sweepNS($id,$basedir='datadir'){ //scan all namespaces while(($id = getNS($id)) !== false){ - $dir = $conf[$basedir].'/'.utf8_encodeFN(str_replace(':','/',$id)); + $dir = $conf[$basedir].'/'.utf8_encodeFN(str_replace(':', '/', $id)); //try to delete dir else return if(@rmdir($dir)) { @@ -106,11 +106,11 @@ function _io_readWikiPage_action($data) { function io_readFile($file,$clean=true){ $ret = ''; if(file_exists($file)){ - if (substr($file,-3) == '.gz') { + if (substr($file, -3) == '.gz') { if(!DOKU_HAS_GZIP) return false; $ret = gzfile($file); if(is_array($ret)) $ret = implode('', $ret); - } elseif (substr($file,-4) == '.bz2') { + } elseif (substr($file, -4) == '.bz2') { if(!DOKU_HAS_BZIP) return false; $ret = bzfile($file); } else{ @@ -135,14 +135,14 @@ function io_readFile($file,$clean=true){ * @return string|array|bool content or false on error */ function bzfile($file, $array=false) { - $bz = bzopen($file,"r"); + $bz = bzopen($file, "r"); if($bz === false) return false; if($array) $lines = []; $str = ''; while (!feof($bz)) { //8192 seems to be the maximum buffersize? - $buffer = bzread($bz,8192); + $buffer = bzread($bz, 8192); if(($buffer === false) || (bzerrno($bz) !== 0)) { return false; } @@ -228,25 +228,25 @@ function _io_saveFile($file, $content, $append) { $mode = ($append) ? 'ab' : 'wb'; $fileexists = file_exists($file); - if (substr($file,-3) == '.gz') { + if (substr($file, -3) == '.gz') { if(!DOKU_HAS_GZIP) return false; - $fh = @gzopen($file,$mode.'9'); + $fh = @gzopen($file, $mode.'9'); if(!$fh) return false; gzwrite($fh, $content); gzclose($fh); - } elseif (substr($file,-4) == '.bz2') { + } elseif (substr($file, -4) == '.bz2') { if(!DOKU_HAS_BZIP) return false; if($append) { $bzcontent = bzfile($file); if($bzcontent === false) return false; $content = $bzcontent.$content; } - $fh = @bzopen($file,'w'); + $fh = @bzopen($file, 'w'); if(!$fh) return false; bzwrite($fh, $content); bzclose($fh); } else{ - $fh = @fopen($file,$mode); + $fh = @fopen($file, $mode); if(!$fh) return false; fwrite($fh, $content); fclose($fh); @@ -276,7 +276,7 @@ function io_saveFile($file, $content, $append=false) { io_makeFileDir($file); io_lock($file); if(!_io_saveFile($file, $content, $append)) { - msg("Writing $file failed",-1); + msg("Writing $file failed", -1); io_unlock($file); return false; } @@ -321,10 +321,10 @@ function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0) io_lock($file); // load into array - if (substr($file,-3) == '.gz') { + if (substr($file, -3) == '.gz') { if(!DOKU_HAS_GZIP) return false; $lines = gzfile($file); - } elseif (substr($file,-4) == '.bz2') { + } elseif (substr($file, -4) == '.bz2') { if(!DOKU_HAS_BZIP) return false; $lines = bzfile($file, true); } else{ @@ -332,7 +332,7 @@ function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0) } // make non-regexes into regexes - $pattern = $regex ? $oldline : '/^'.preg_quote($oldline,'/').'$/'; + $pattern = $regex ? $oldline : '/^'.preg_quote($oldline, '/').'$/'; $replace = $regex ? $newline : addcslashes($newline, '\$'); // remove matching lines @@ -355,8 +355,8 @@ function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0) } if(count($lines)){ - if(!_io_saveFile($file, implode('',$lines), false)) { - msg("Removing content from $file failed",-1); + if(!_io_saveFile($file, implode('', $lines), false)) { + msg("Removing content from $file failed", -1); io_unlock($file); return false; } @@ -381,7 +381,7 @@ function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0) * @return bool true on success */ function io_deleteFromFile($file,$badline,$regex=false){ - return io_replaceInFile($file,$badline,null,$regex,0); + return io_replaceInFile($file, $badline, null, $regex, 0); } /** @@ -483,7 +483,7 @@ function io_createNamespace($id, $ns_type='pages') { function io_makeFileDir($file){ $dir = dirname($file); if(!@is_dir($dir)){ - io_mkdir_p($dir) || msg("Creating directory $dir failed",-1); + io_mkdir_p($dir) || msg("Creating directory $dir failed", -1); } } @@ -502,7 +502,7 @@ function io_mkdir_p($target){ if (@is_dir($target)||empty($target)) return 1; // best case check first if (file_exists($target) && !is_dir($target)) return 0; //recursion - if (io_mkdir_p(substr($target,0,strrpos($target,'/')))){ + if (io_mkdir_p(substr($target, 0, strrpos($target, '/')))){ $ret = @mkdir($target); // crawl back up & create dir tree if($ret && !empty($conf['dperm'])) chmod($target, $conf['dperm']); return $ret; @@ -632,9 +632,9 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2_ } $fileexists = file_exists($file); - $fp = @fopen($file,"w"); + $fp = @fopen($file, "w"); if(!$fp) return false; - fwrite($fp,$data); + fwrite($fp, $data); fclose($fp); if(!$fileexists && $conf['fperm']) chmod($file, $conf['fperm']); if ($useAttachment) return $name; @@ -653,8 +653,8 @@ function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2_ */ function io_rename($from,$to){ global $conf; - if(!@rename($from,$to)){ - if(@copy($from,$to)){ + if(!@rename($from, $to)){ + if(@copy($from, $to)){ if($conf['fperm']) chmod($to, $conf['fperm']); @unlink($from); return true; @@ -706,7 +706,7 @@ function io_exec($cmd, $input, &$output){ * @return array matching lines or backref, false on error */ function io_grep($file,$pattern,$max=0,$backref=false){ - $fh = @fopen($file,'r'); + $fh = @fopen($file, 'r'); if(!$fh) return false; $matches = []; @@ -714,10 +714,10 @@ function io_grep($file,$pattern,$max=0,$backref=false){ $line = ''; while (!feof($fh)) { $line .= fgets($fh, 4096); // read full line - if(substr($line,-1) != "\n") continue; + if(substr($line, -1) != "\n") continue; // check if line matches - if(preg_match($pattern,$line,$match)){ + if(preg_match($pattern, $line, $match)){ if($backref){ $matches[] = $match; }else{ @@ -745,7 +745,7 @@ function io_grep($file,$pattern,$max=0,$backref=false){ function io_getSizeFile($file) { if (!file_exists($file)) return 0; - if (substr($file,-3) == '.gz') { + if (substr($file, -3) == '.gz') { $fp = @fopen($file, "rb"); if($fp === false) return 0; fseek($fp, -4, SEEK_END); @@ -753,14 +753,14 @@ function io_getSizeFile($file) { fclose($fp); $array = unpack("V", $buffer); $uncompressedsize = end($array); - } elseif (substr($file,-4) == '.bz2') { + } elseif (substr($file, -4) == '.bz2') { if(!DOKU_HAS_BZIP) return 0; - $bz = bzopen($file,"r"); + $bz = bzopen($file, "r"); if($bz === false) return 0; $uncompressedsize = 0; while (!feof($bz)) { //8192 seems to be the maximum buffersize? - $buffer = bzread($bz,8192); + $buffer = bzread($bz, 8192); if(($buffer === false) || (bzerrno($bz) !== 0)) { return 0; } diff --git a/inc/mail.php b/inc/mail.php index f95a17bd8..fd28c1553 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -20,7 +20,7 @@ * @author Chris Smith * Check if a given mail address is valid */ -if (!defined('RFC2822_ATEXT')) define('RFC2822_ATEXT',"0-9a-zA-Z!#$%&'*+/=?^_`{|}~-"); +if (!defined('RFC2822_ATEXT')) define('RFC2822_ATEXT', "0-9a-zA-Z!#$%&'*+/=?^_`{|}~-"); if (!defined('PREG_PATTERN_VALID_EMAIL')) define( 'PREG_PATTERN_VALID_EMAIL', '['.RFC2822_ATEXT.']+(?:\.['.RFC2822_ATEXT.']+)*@(?i:[0-9a-z][0-9a-z-]*\.)+(?i:[a-z]{2,63})' @@ -41,7 +41,7 @@ function mail_setup(){ global $INPUT; // auto constructed address - $host = @parse_url(DOKU_URL,PHP_URL_HOST); + $host = @parse_url(DOKU_URL, PHP_URL_HOST); if(!$host) $host = 'example.com'; $noreply = 'noreply@'.$host; @@ -127,16 +127,16 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) // please correct me, if I'm wrong, // or comment next line for RFC2045 conformance, if you like if (!($bEmulate_imap_8bit && ($i==count($aLines)-1))){ - if (($iLastChar==0x09)||($iLastChar==0x20)) { - $sLine[$iLength-1]='='; - $sLine .= ($iLastChar==0x09)?'09':'20'; + if (($iLastChar==0x09)||($iLastChar==0x20)) { + $sLine[$iLength-1]='='; + $sLine .= ($iLastChar==0x09)?'09':'20'; } } } // imap_8bit encodes x20 before chr(13), too // although IMHO not requested by RFC2045, why not do it safer :) // and why not encode any x20 around chr(10) or chr(13) if ($bEmulate_imap_8bit) { - $sLine=str_replace(' =0D','=20=0D',$sLine); + $sLine=str_replace(' =0D', '=20=0D', $sLine); //$sLine=str_replace(' =0A','=20=0A',$sLine); //$sLine=str_replace('=0D ','=0D=20',$sLine); //$sLine=str_replace('=0A ','=0A=20',$sLine); @@ -154,7 +154,7 @@ function mail_quotedprintable_encode($sText,$maxlen=74,$bEmulate_imap_8bit=true) } // join lines into text - return implode(MAILHEADER_EOL,$aLines); + return implode(MAILHEADER_EOL, $aLines); } function mail_quotedprintable_encode_callback($matches){ diff --git a/inc/media.php b/inc/media.php index 019d36614..095835da2 100644 --- a/inc/media.php +++ b/inc/media.php @@ -78,7 +78,7 @@ function media_metasave($id,$auth,$data){ if(empty($val)){ $meta->deleteField($key); }else{ - $meta->setField($key,$val); + $meta->setField($key, $val); } } @@ -98,10 +98,10 @@ function media_metasave($id,$auth,$data){ // add a log entry to the media changelog addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT, $lang['media_meta_edited'], '', null, $sizechange); - msg($lang['metasaveok'],1); + msg($lang['metasaveok'], 1); return $id; }else{ - msg($lang['metasaveerr'],-1); + msg($lang['metasaveerr'], -1); return false; } } @@ -222,7 +222,7 @@ function media_inuse($id) { global $conf; if($conf['refcheck']){ - $mediareferences = ft_mediause($id,true); + $mediareferences = ft_mediause($id, true); if($mediareferences === []) { return false; } else { @@ -265,7 +265,7 @@ function media_delete($id,$auth){ $data['unl'] = false; $data['del'] = false; - $evt = new Event('MEDIA_DELETE_FILE',$data); + $evt = new Event('MEDIA_DELETE_FILE', $data); if ($evt->advise_before()) { $old = @filemtime($file); if(!file_exists(mediaFN($id, $old)) && file_exists($file)) { @@ -365,7 +365,7 @@ function media_upload($ns,$auth,$file=false){ $imime = $fmime; }elseif($fext && $fext != $iext){ // extension was changed, print warning - msg(sprintf($lang['mediaextchange'],$fext,$iext)); + msg(sprintf($lang['mediaextchange'], $fext, $iext)); } $res = media_save( @@ -453,10 +453,10 @@ function media_save($file, $id, $ow, $auth, $move) { static fn($q) => preg_quote($q, "/"), $types ); - $regex = implode('|',$types); + $regex = implode('|', $types); // because a temp file was created already - if(!preg_match('/\.('.$regex.')$/i',$fn)) { + if(!preg_match('/\.('.$regex.')$/i', $fn)) { return [$lang['uploadwrong'], -1]; } @@ -469,7 +469,7 @@ function media_save($file, $id, $ow, $auth, $move) { // check for valid content $ok = media_contentcheck($file['name'], $file['mime']); if($ok == -1){ - return [sprintf($lang['uploadbadcontent'],'.' . $file['ext']), -1]; + return [sprintf($lang['uploadbadcontent'], '.' . $file['ext']), -1]; }elseif($ok == -2){ return [$lang['uploadspam'], -1]; }elseif($ok == -3){ @@ -538,14 +538,14 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov $filesize_old = file_exists($fn) ? filesize($fn) : 0; if($move($fn_tmp, $fn)) { - @clearstatcache(true,$fn); + @clearstatcache(true, $fn); $new = @filemtime($fn); // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) chmod($fn, $conf['fmode']); - msg($lang['uploadsucc'],1); - media_notify($id,$fn,$imime,$old,$new); + msg($lang['uploadsucc'], 1); + media_notify($id, $fn, $imime, $old, $new); // add a log entry to the media changelog $filesize_new = filesize($fn); $sizechange = $filesize_new - $filesize_old; @@ -637,12 +637,12 @@ function media_contentcheck($file,$mime){ if($fh){ $bytes = fread($fh, 256); fclose($fh); - if(preg_match('/<(script|a|img|html|body|iframe)[\s>]/i',$bytes)){ + if(preg_match('/<(script|a|img|html|body|iframe)[\s>]/i', $bytes)){ return -3; //XSS: possibly malicious content } } } - if(substr($mime,0,6) == 'image/'){ + if(substr($mime, 0, 6) == 'image/'){ $info = @getimagesize($file); if($mime == 'image/gif' && $info[2] != 1){ return -1; // uploaded content did not match the file extension @@ -652,7 +652,7 @@ function media_contentcheck($file,$mime){ return -1; } # fixme maybe check other images types as well - }elseif(substr($mime,0,5) == 'text/'){ + }elseif(substr($mime, 0, 5) == 'text/'){ global $TEXT; $TEXT = io_readFile($file); if(checkwordblock()){ @@ -708,10 +708,10 @@ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false,$sort=fals media_searchform($ns); } - $dir = utf8_encodeFN(str_replace(':','/',$ns)); + $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = []; - search($data,$conf['mediadir'],'search_mediafiles', - ['showmsg'=>true, 'depth'=>1],$dir,1,$sort); + search($data, $conf['mediadir'], 'search_mediafiles', + ['showmsg'=>true, 'depth'=>1], $dir, 1, $sort); if(!count($data)){ echo '
'.$lang['nothingfound'].'
'.NL; @@ -911,7 +911,7 @@ function media_tab_files($ns,$auth=null,$jump='') { if($auth < AUTH_READ){ echo '
'.$lang['media_perm_read'].'
'.NL; }else{ - media_filelist($ns,$auth,$jump,true,_media_get_sort_type()); + media_filelist($ns, $auth, $jump, true, _media_get_sort_type()); } } @@ -953,7 +953,7 @@ function media_tab_search($ns,$auth=null) { media_searchform($ns, $query, true); if ($do == 'searchlist' || $query) { - media_searchlist($query,$ns,$auth,true,_media_get_sort_type()); + media_searchlist($query, $ns, $auth, true, _media_get_sort_type()); } echo '
'.NL; } @@ -997,7 +997,7 @@ function media_tab_edit($image, $ns, $auth=null) { if ($image) { [, $mime] = mimetype($image); - if ($mime == 'image/jpeg') media_metaform($image,$auth); + if ($mime == 'image/jpeg') media_metaform($image, $auth); } } @@ -1021,7 +1021,7 @@ function media_tab_history($image, $ns, $auth=null) { if ($do == 'diff'){ (new MediaDiff($image))->show(); //media_diff($image, $ns, $auth); } else { - $first = $INPUT->int('first',-1); + $first = $INPUT->int('first', -1); (new MediaRevisions($image))->show($first); } } else { @@ -1199,7 +1199,7 @@ function media_file_tags($meta) { foreach ($fields as $tag) { $t = []; if (!empty($tag[0])) $t = [$tag[0]]; - if (isset($tag[3]) && is_array($tag[3])) $t = array_merge($t,$tag[3]); + if (isset($tag[3]) && is_array($tag[3])) $t = array_merge($t, $tag[3]); $value = media_getTag($t, $meta); $tags[] = ['tag' => $tag, 'value' => $value]; } @@ -1236,7 +1236,7 @@ function media_details($image, $auth, $rev='', $meta=false) { echo ''.NL; echo '
'.NL; echo '
'.$lang['reference'].':
'; - $media_usage = ft_mediause($image,true); + $media_usage = ft_mediause($image, true); if($media_usage !== []){ foreach($media_usage as $path){ echo '
'.html_wikilink($path).'
'; @@ -1367,8 +1367,8 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural if (!blank($query)) { $evt = new Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { - $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); - $quoted = preg_quote($evdata['query'],'/'); + $dir = utf8_encodeFN(str_replace(':', '/', $evdata['ns'])); + $quoted = preg_quote($evdata['query'], '/'); //apply globbing $quoted = str_replace(['\*', '\?'], ['.*', '.'], $quoted, $count); @@ -1389,8 +1389,8 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural } if (!$fullscreen) { - echo '

'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'

'.NL; - media_searchform($ns,$query); + echo '

'.sprintf($lang['searchmedia_in'], hsc($ns).':*').'

'.NL; + media_searchform($ns, $query); } if(!count($evdata['data'])){ @@ -1426,7 +1426,7 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false,$sort='natural * @return string html */ function media_printicon($filename, $size=''){ - [$ext] = mimetype(mediaFN($filename),false); + [$ext] = mimetype(mediaFN($filename), false); if (file_exists(DOKU_INC.'lib/images/fileicons/'.$size.'/'.$ext.'.png')) { $icon = DOKU_BASE.'lib/images/fileicons/'.$size.'/'.$ext.'.png'; @@ -1469,7 +1469,7 @@ function media_managerURL($params = false, $amp = '&', $abs = false, $params if ($params_array) return $gets; - return wl($ID,$gets,$abs,$amp); + return wl($ID, $gets, $abs, $amp); } /** @@ -1621,10 +1621,10 @@ function media_nstree($ns){ $ns = (string)getNS($ID); } - $ns_dir = utf8_encodeFN(str_replace(':','/',$ns)); + $ns_dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = []; - search($data,$conf['mediadir'],'search_index',['ns' => $ns_dir, 'nofiles' => true]); + search($data, $conf['mediadir'], 'search_index', ['ns' => $ns_dir, 'nofiles' => true]); // wrap a list with the root level around the other namespaces array_unshift($data, ['level' => 0, 'id' => '', 'open' =>'true', 'label' => '['.$lang['mediaroot'].']']); @@ -1650,7 +1650,7 @@ function media_nstree($ns){ } } - echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li'); + echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li'); } /** @@ -1799,7 +1799,7 @@ function media_get_token($id,$w,$h){ if ($w) $token .= '.'.$w; if ($h) $token .= '.'.$h; - return substr(PassHash::hmac('md5', $token, auth_cookiesalt()),0,6); + return substr(PassHash::hmac('md5', $token, auth_cookiesalt()), 0, 6); } return ''; @@ -1826,7 +1826,7 @@ function media_get_from_URL($url,$ext,$cache){ if ($cache==0) return false; if (!$conf['fetchsize']) return false; - $local = getCacheName(strtolower($url),".media.$ext"); + $local = getCacheName(strtolower($url), ".media.$ext"); $mtime = @filemtime($local); // 0 if not exists //decide if download needed: @@ -1869,9 +1869,9 @@ function media_image_download($url,$file){ if(!$data) return false; $fileexists = file_exists($file); - $fp = @fopen($file,"w"); + $fp = @fopen($file, "w"); if(!$fp) return false; - fwrite($fp,$data); + fwrite($fp, $data); fclose($fp); if(!$fileexists && $conf['fperm']) chmod($file, $conf['fperm']); @@ -1914,7 +1914,7 @@ function media_resize_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h){ } $cmd .= " $from $to"; - @exec($cmd,$out,$retval); + @exec($cmd, $out, $retval); if ($retval == 0) return true; return false; } @@ -1951,7 +1951,7 @@ function media_crop_imageIM($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x,$o } $cmd .= " $from $to"; - @exec($cmd,$out,$retval); + @exec($cmd, $out, $retval); if ($retval == 0) return true; return false; } @@ -2013,7 +2013,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= //keep png alpha channel if possible if($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')){ imagealphablending($newimg, false); - imagesavealpha($newimg,true); + imagesavealpha($newimg, true); } //keep gif transparent color if possible diff --git a/inc/pluginutils.php b/inc/pluginutils.php index a93cd4f60..770449861 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -11,7 +11,7 @@ use dokuwiki\Extension\AdminPlugin; use dokuwiki\Extension\PluginController; use dokuwiki\Extension\PluginInterface; -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); // note that only [a-z0-9]+ is officially supported, // this is only to support plugins that don't follow these conventions, too if(!defined('DOKU_PLUGIN_NAME_REGEX')) define('DOKU_PLUGIN_NAME_REGEX', '[a-zA-Z0-9\x7f-\xff]+'); @@ -31,7 +31,7 @@ function plugin_list($type='',$all=false) { /** @var $plugin_controller PluginController */ global $plugin_controller; - $plugins = $plugin_controller->getList($type,$all); + $plugins = $plugin_controller->getList($type, $all); sort($plugins, SORT_NATURAL|SORT_FLAG_CASE); return $plugins; } @@ -51,7 +51,7 @@ function plugin_load($type,$name,$new=false,$disabled=false) { /** @var $plugin_controller PluginController */ global $plugin_controller; - return $plugin_controller->load($type,$name,$new,$disabled); + return $plugin_controller->load($type, $name, $new, $disabled); } /** @@ -141,7 +141,7 @@ function plugin_getRequestAdminPlugin() if ($admin_plugin && !$admin_plugin->isAccessibleByCurrentUser()) { $admin_plugin = null; $INPUT->remove('page'); - msg('For admins only',-1); + msg('For admins only', -1); } } } diff --git a/inc/search.php b/inc/search.php index d270152f2..66722bb8b 100644 --- a/inc/search.php +++ b/inc/search.php @@ -39,7 +39,7 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){ $dh = @opendir($base.'/'.$dir); if(!$dh) return; while(($file = readdir($dh)) !== false){ - if(preg_match('/^[\._]/',$file)) continue; //skip hidden files and upper dirs + if(preg_match('/^[\._]/', $file)) continue; //skip hidden files and upper dirs if(is_dir($base.'/'.$dir.'/'.$file)){ $dirs[] = $dir.'/'.$file; continue; @@ -60,7 +60,7 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){ //give directories to userfunction then recurse foreach($dirs as $dir){ if (call_user_func_array($func, [&$data, $base, $dir, 'd', $lvl, $opts])){ - search($data,$base,$func,$opts,$dir,$lvl+1,$sort); + search($data, $base, $func, $opts, $dir, $lvl+1, $sort); } } //now handle the files @@ -108,11 +108,11 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1,$sort='natural'){ */ function search_qsearch(&$data,$base,$file,$type,$lvl,$opts){ $opts = [ - 'idmatch' => '(^|:)'.preg_quote($opts['query'],'/').'/', + 'idmatch' => '(^|:)'.preg_quote($opts['query'], '/').'/', 'listfiles' => true, 'pagesonly' => true ]; - return search_universal($data,$base,$file,$type,$lvl,$opts); + return search_universal($data, $base, $file, $type, $lvl, $opts); } /** @@ -140,7 +140,7 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ 'listfiles' => empty($opts['nofiles']), 'sneakyacl' => $conf['sneaky_index'], // Hacky, should rather use recmatch - 'depth' => preg_match('#^'.preg_quote($file, '#').'(/|$)#','/'.$ns) ? 0 : -1, + 'depth' => preg_match('#^'.preg_quote($file, '#').'(/|$)#', '/'.$ns) ? 0 : -1, ]; return search_universal($data, $base, $file, $type, $lvl, $opts); @@ -162,7 +162,7 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ */ function search_namespaces(&$data,$base,$file,$type,$lvl,$opts){ $opts = ['listdirs' => true]; - return search_universal($data,$base,$file,$type,$lvl,$opts); + return search_universal($data, $base, $file, $type, $lvl, $opts); } /** @@ -189,16 +189,16 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){ //we do nothing with directories if($type == 'd') { if(empty($opts['depth'])) return true; // recurse forever - $depth = substr_count($file,'/'); + $depth = substr_count($file, '/'); if($depth >= $opts['depth']) return false; // depth reached return true; } $info = []; - $info['id'] = pathID($file,true); + $info['id'] = pathID($file, true); if($info['id'] != cleanID($info['id'])){ if(!empty($opts['showmsg'])) - msg(hsc($info['id']).' is not a valid file name for DokuWiki - skipped',-1); + msg(hsc($info['id']).' is not a valid file name for DokuWiki - skipped', -1); return false; // skip non-valid files } @@ -217,14 +217,14 @@ function search_media(&$data,$base,$file,$type,$lvl,$opts){ $info['size'] = filesize($base.'/'.$file); $info['mtime'] = filemtime($base.'/'.$file); $info['writable'] = is_writable($base.'/'.$file); - if(preg_match("/\.(jpe?g|gif|png)$/",$file)){ + if(preg_match("/\.(jpe?g|gif|png)$/", $file)){ $info['isimg'] = true; $info['meta'] = new JpegMeta($base.'/'.$file); }else{ $info['isimg'] = false; } if(!empty($opts['hash'])){ - $info['hash'] = md5(io_readFile(mediaFN($info['id']),false)); + $info['hash'] = md5(io_readFile(mediaFN($info['id']), false)); } $data[] = $info; @@ -256,15 +256,15 @@ function search_mediafiles(&$data,$base,$file,$type,$lvl,$opts){ //we do nothing with directories if($type == 'd') { if(empty($opts['depth'])) return true; // recurse forever - $depth = substr_count($file,'/'); + $depth = substr_count($file, '/'); if($depth >= $opts['depth']) return false; // depth reached return true; } - $id = pathID($file,true); + $id = pathID($file, true); if($id != cleanID($id)){ if($opts['showmsg']) - msg(hsc($id).' is not a valid file name for DokuWiki - skipped',-1); + msg(hsc($id).' is not a valid file name for DokuWiki - skipped', -1); return false; // skip non-valid files } @@ -302,7 +302,7 @@ function search_list(&$data,$base,$file,$type,$lvl,$opts){ //we do nothing with directories if($type == 'd') return false; //only search txt files - if(substr($file,-4) == '.txt'){ + if(substr($file, -4) == '.txt'){ //check ACL $id = pathID($file); if(auth_quickaclcheck($id) < AUTH_READ){ @@ -333,11 +333,11 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ //we do nothing with directories if($type == 'd') return true; //only search txt files - if(substr($file,-4) != '.txt') return true; + if(substr($file, -4) != '.txt') return true; //simple stringmatching if (!empty($opts['query'])){ - if(strpos($file,(string) $opts['query']) !== false){ + if(strpos($file, (string) $opts['query']) !== false){ //check ACL $id = pathID($file); if(auth_quickaclcheck($id) < AUTH_READ){ @@ -369,7 +369,7 @@ function search_pagename(&$data,$base,$file,$type,$lvl,$opts){ */ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ if(isset($opts['depth']) && $opts['depth']){ - $parts = explode('/',ltrim($file,'/')); + $parts = explode('/', ltrim($file, '/')); if(($type == 'd' && count($parts) >= $opts['depth']) || ($type != 'd' && count($parts) > $opts['depth'])){ return false; // depth reached @@ -382,7 +382,7 @@ function search_allpages(&$data,$base,$file,$type,$lvl,$opts){ } //only search txt files - if(substr($file,-4) != '.txt') return true; + if(substr($file, -4) != '.txt') return true; $item = []; $item['id'] = pathID($file); @@ -422,7 +422,7 @@ function sort_search_fulltext($a,$b){ }elseif($a['count'] < $b['count']){ return 1; }else{ - return Sort::strcmp($a['id'],$b['id']); + return Sort::strcmp($a['id'], $b['id']); } } @@ -439,8 +439,8 @@ function sort_search_fulltext($a,$b){ */ function pathID($path,$keeptxt=false){ $id = utf8_decodeFN($path); - $id = str_replace('/',':',$id); - if(!$keeptxt) $id = preg_replace('#\.txt$#','',$id); + $id = str_replace('/', ':', $id); + if(!$keeptxt) $id = preg_replace('#\.txt$#', '', $id); $id = trim($id, ':'); return $id; } @@ -488,10 +488,10 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ $return = true; // get ID and check if it is a valid one - $item['id'] = pathID($file,($type == 'd' || !empty($opts['keeptxt']))); + $item['id'] = pathID($file, ($type == 'd' || !empty($opts['keeptxt']))); if($item['id'] != cleanID($item['id'])){ if(!empty($opts['showmsg'])){ - msg(hsc($item['id']).' is not a valid file name for DokuWiki - skipped',-1); + msg(hsc($item['id']).' is not a valid file name for DokuWiki - skipped', -1); } return false; // skip non-valid files } @@ -502,7 +502,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ if(empty($opts['depth'])){ $return = true; // recurse forever }else{ - $depth = substr_count($file,'/'); + $depth = substr_count($file, '/'); if($depth >= $opts['depth']){ $return = false; // depth reached }else{ @@ -511,7 +511,7 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ } if ($return) { - $match = empty($opts['recmatch']) || preg_match('/'.$opts['recmatch'].'/',$file); + $match = empty($opts['recmatch']) || preg_match('/'.$opts['recmatch'].'/', $file); if (!$match) { return false; // doesn't match } @@ -534,15 +534,15 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ if(empty($opts['listdirs'])) return $return; //neither list nor recurse forbidden items: if(empty($opts['skipacl']) && !empty($opts['sneakyacl']) && $item['perm'] < AUTH_READ) return false; - if(!empty($opts['dirmatch']) && !preg_match('/'.$opts['dirmatch'].'/',$file)) return $return; - if(!empty($opts['nsmatch']) && !preg_match('/'.$opts['nsmatch'].'/',$item['ns'])) return $return; + if(!empty($opts['dirmatch']) && !preg_match('/'.$opts['dirmatch'].'/', $file)) return $return; + if(!empty($opts['nsmatch']) && !preg_match('/'.$opts['nsmatch'].'/', $item['ns'])) return $return; }else{ if(empty($opts['listfiles'])) return $return; if(empty($opts['skipacl']) && $item['perm'] < AUTH_READ) return $return; - if(!empty($opts['pagesonly']) && (substr($file,-4) != '.txt')) return $return; + if(!empty($opts['pagesonly']) && (substr($file, -4) != '.txt')) return $return; if(empty($opts['showhidden']) && isHiddenPage($item['id'])) return $return; - if(!empty($opts['filematch']) && !preg_match('/'.$opts['filematch'].'/',$file)) return $return; - if(!empty($opts['idmatch']) && !preg_match('/'.$opts['idmatch'].'/',$item['id'])) return $return; + if(!empty($opts['filematch']) && !preg_match('/'.$opts['filematch'].'/', $file)) return $return; + if(!empty($opts['idmatch']) && !preg_match('/'.$opts['idmatch'].'/', $item['id'])) return $return; } // still here? prepare the item @@ -560,8 +560,8 @@ function search_universal(&$data,$base,$file,$type,$lvl,$opts){ } if($type == 'f'){ - if(!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base.'/'.$file,false)); - if(!empty($opts['firsthead'])) $item['title'] = p_get_first_heading($item['id'],METADATA_DONT_RENDER); + if(!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base.'/'.$file, false)); + if(!empty($opts['firsthead'])) $item['title'] = p_get_first_heading($item['id'], METADATA_DONT_RENDER); } // finally add the item diff --git a/inc/template.php b/inc/template.php index f8d795f7d..461592010 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1105,7 +1105,7 @@ function tpl_get_img_meta() { $t = [$tag[0]]; } if(isset($tag[3]) && is_array($tag[3])) { - $t = array_merge($t,$tag[3]); + $t = array_merge($t, $tag[3]); } $value = tpl_img_getTag($t); if ($value) { @@ -1383,7 +1383,7 @@ function tpl_mediaContent($fromajax = false, $sort='natural') { if($do == 'filesinuse') { media_filesinuse($INUSE, $IMG); } elseif($do == 'filelist') { - media_filelist($NS, $AUTH, $JUMPTO,false,$sort); + media_filelist($NS, $AUTH, $JUMPTO, false, $sort); } elseif($do == 'searchlist') { media_searchlist($INPUT->str('q'), $NS, $AUTH); } else { diff --git a/inc/toolbar.php b/inc/toolbar.php index b441cbbe8..50707d5a9 100644 --- a/inc/toolbar.php +++ b/inc/toolbar.php @@ -262,16 +262,16 @@ function toolbar_signature(){ global $INPUT; $sig = $conf['signature']; - $sig = dformat(null,$sig); - $sig = str_replace('@USER@',$INPUT->server->str('REMOTE_USER'),$sig); + $sig = dformat(null, $sig); + $sig = str_replace('@USER@', $INPUT->server->str('REMOTE_USER'), $sig); if (is_null($INFO)) { $sig = str_replace(['@NAME@', '@MAIL@'], '', $sig); } else { $sig = str_replace('@NAME@', $INFO['userinfo']['name'] ?? "", $sig); $sig = str_replace('@MAIL@', $INFO['userinfo']['mail'] ?? "", $sig); } - $sig = str_replace('@DATE@',dformat(),$sig); - $sig = str_replace('\\\\n','\\n',$sig); + $sig = str_replace('@DATE@', dformat(), $sig); + $sig = str_replace('\\\\n', '\\n', $sig); return json_encode($sig, JSON_THROW_ON_ERROR); } diff --git a/lib/exe/css.php b/lib/exe/css.php index 68aa07bb0..3501746dc 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -10,9 +10,9 @@ use dokuwiki\Cache\Cache; use dokuwiki\Extension\Event; if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ .'/../../'); -if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) -if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here -if(!defined('NL')) define('NL',"\n"); +if(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching) +if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here +if(!defined('NL')) define('NL', "\n"); require_once(DOKU_INC.'inc/init.php'); // Main (don't run when UNIT test) @@ -44,7 +44,7 @@ function css_out(){ } // decide from where to get the template - $tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t'))); + $tpl = trim(preg_replace('/[^\w-]+/', '', $INPUT->str('t'))); if(!$tpl) $tpl = $conf['template']; // load style.ini @@ -177,8 +177,8 @@ function css_out(){ // embed small images right into the stylesheet if($conf['cssdatauri']){ - $base = preg_quote(DOKU_BASE,'#'); - $css = preg_replace_callback('#(url\([ \'"]*)('.$base.')(.*?(?:\.(png|gif)))#i','css_datauri',$css); + $base = preg_quote(DOKU_BASE, '#'); + $css = preg_replace_callback('#(url\([ \'"]*)('.$base.')(.*?(?:\.(png|gif)))#i', 'css_datauri', $css); } http_cached_finish($cache->cache, $css); @@ -369,14 +369,14 @@ function css_filetypes(){ $exts = []; if($dh = opendir(DOKU_INC.'lib/images/fileicons/svg')){ while(false !== ($file = readdir($dh))){ - if(preg_match('/(.*?)\.svg$/i',$file, $match)){ + if(preg_match('/(.*?)\.svg$/i', $file, $match)){ $exts[] = strtolower($match[1]); } } closedir($dh); } foreach($exts as $ext){ - $class = preg_replace('/[^_\-a-z0-9]+/','_',$ext); + $class = preg_replace('/[^_\-a-z0-9]+/', '_', $ext); echo ".mf_$class {"; echo ' background-image: url('.DOKU_BASE.'lib/images/fileicons/svg/'.$ext.'.svg)'; echo '}'; @@ -427,8 +427,8 @@ class DokuCssFile { $this->location = $location; - $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#',[$this, 'replacements'],$css); - $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#',[$this, 'replacements'],$css); + $css = preg_replace_callback('#(url\( *)([\'"]?)(.*?)(\2)( *\))#', [$this, 'replacements'], $css); + $css = preg_replace_callback('#(@import\s+)([\'"])(.*?)(\2)#', [$this, 'replacements'], $css); return $css; } @@ -449,7 +449,7 @@ class DokuCssFile { } $basedir = array_map('preg_quote_cb', $basedir); - $regex = '/^('.implode('|',$basedir).')/'; + $regex = '/^('.implode('|', $basedir).')/'; $this->relative_path = preg_replace($regex, '', dirname($this->filepath)); } @@ -475,7 +475,7 @@ class DokuCssFile { $match[3] = $this->location . $match[3]; } - return implode('',array_slice($match,1)); + return implode('', array_slice($match, 1)); } } @@ -552,15 +552,15 @@ function css_compress($css){ $css = preg_replace_callback('/(([\'"]).*?(?int('rev'); // this makes some general info available as well as the info about the // "parent" page -$INFO = array_merge(pageinfo(),mediainfo()); +$INFO = array_merge(pageinfo(), mediainfo()); $tmp = []; Event::createAndTrigger('DETAIL_STARTED', $tmp); @@ -29,7 +29,7 @@ $ERROR = false; $AUTH = auth_quickaclcheck($IMG); if($AUTH >= AUTH_READ){ // check if image exists - $SRC = mediaFN($IMG,$REV); + $SRC = mediaFN($IMG, $REV); if(!file_exists($SRC)){ //doesn't exist! http_status(404); diff --git a/lib/exe/js.php b/lib/exe/js.php index 391432aea..45f84f696 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -12,9 +12,9 @@ use splitbrain\JSStrip\Exception as JSStripException; use splitbrain\JSStrip\JSStrip; if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__ .'/../../'); -if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) -if(!defined('NL')) define('NL',"\n"); -if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT',1); // we gzip ourself here +if(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching) +if(!defined('NL')) define('NL', "\n"); +if(!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here require_once(DOKU_INC.'inc/init.php'); // Main (don't run when UNIT test) @@ -38,7 +38,7 @@ function js_out(){ global $INPUT; // decide from where to get the template - $tpl = trim(preg_replace('/[^\w-]+/','',$INPUT->str('t'))); + $tpl = trim(preg_replace('/[^\w-]+/', '', $INPUT->str('t'))); if(!$tpl) $tpl = $conf['template']; // array of core files @@ -70,7 +70,7 @@ function js_out(){ ]; // add possible plugin scripts and userscript - $files = array_merge($files,js_pluginscripts()); + $files = array_merge($files, js_pluginscripts()); if(is_array($config_cascade['userscript']['default'])) { foreach($config_cascade['userscript']['default'] as $userscript) { $files[] = $userscript; @@ -81,7 +81,7 @@ function js_out(){ Event::createAndTrigger('JS_SCRIPT_LIST', $files); // The generated script depends on some dynamic options - $cache = new Cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)),'.js'); + $cache = new Cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].md5(serialize($files)), '.js'); $cache->setEvent('JS_CACHE_USE'); $cache_files = array_merge($files, getConfigFiles('main')); @@ -124,7 +124,7 @@ function js_out(){ // load files foreach($files as $file){ if(!file_exists($file)) continue; - $ismin = (substr($file,-7) == '.min.js'); + $ismin = (substr($file, -7) == '.min.js'); $debugjs = ($conf['allowdebug'] && strpos($file, DOKU_INC.'lib/scripts/') !== 0); echo "\n\n/* XXXXXXXXXX begin of ".str_replace(DOKU_INC, '', $file) ." XXXXXXXXXX */\n\n"; @@ -176,14 +176,14 @@ function js_load($file){ static $loaded = []; $data = io_readFile($file); - while(preg_match('#/\*\s*DOKUWIKI:include(_once)?\s+([\w\.\-_/]+)\s*\*/#',$data,$match)){ + while(preg_match('#/\*\s*DOKUWIKI:include(_once)?\s+([\w\.\-_/]+)\s*\*/#', $data, $match)){ $ifile = $match[2]; // is it a include_once? if($match[1]){ $base = PhpString::basename($ifile); if(array_key_exists($base, $loaded) && $loaded[$base] === true){ - $data = str_replace($match[0], '' ,$data); + $data = str_replace($match[0], '', $data); continue; } $loaded[$base] = true; @@ -198,7 +198,7 @@ function js_load($file){ $idata .= io_readFile($ifile); if ($ismin) $idata .= "\n/* END NOCOMPRESS */\n"; } - $data = str_replace($match[0],$idata,$data); + $data = str_replace($match[0], $idata, $data); } echo "$data\n"; } @@ -316,7 +316,7 @@ function js_templatestrings($tpl) { * @return string */ function js_escape($string){ - return str_replace('\\\\n','\\n',addslashes($string)); + return str_replace('\\\\n', '\\n', addslashes($string)); } /** diff --git a/lib/exe/manifest.php b/lib/exe/manifest.php index 47a8da131..7391c7fe7 100644 --- a/lib/exe/manifest.php +++ b/lib/exe/manifest.php @@ -4,7 +4,7 @@ use dokuwiki\Manifest; if (!defined('DOKU_INC')) { define('DOKU_INC', __DIR__ . '/../../'); } -if(!defined('NOSESSION')) define('NOSESSION',true); // no session or auth required here +if(!defined('NOSESSION')) define('NOSESSION', true); // no session or auth required here require_once(DOKU_INC . 'inc/init.php'); if (!actionOK('manifest')) { diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index bfcab20c8..f57b5286f 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -2,11 +2,11 @@ use dokuwiki\Extension\Event; - if(!defined('DOKU_INC')) define('DOKU_INC',__DIR__.'/../../'); - define('DOKU_MEDIAMANAGER',1); + if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__.'/../../'); + define('DOKU_MEDIAMANAGER', 1); // for multi uploader: - @ini_set('session.use_only_cookies',0); + @ini_set('session.use_only_cookies', 0); require_once(DOKU_INC.'inc/init.php'); @@ -14,24 +14,24 @@ use dokuwiki\Extension\Event; global $lang; global $conf; // handle passed message - if($INPUT->str('msg1')) msg(hsc($INPUT->str('msg1')),1); - if($INPUT->str('err')) msg(hsc($INPUT->str('err')),-1); + if($INPUT->str('msg1')) msg(hsc($INPUT->str('msg1')), 1); + if($INPUT->str('err')) msg(hsc($INPUT->str('err')), -1); global $DEL; // get namespace to display (either direct or from deletion order) if($INPUT->str('delete')){ - $DEL = cleanID($INPUT->str('delete')); - $IMG = $DEL; - $NS = getNS($DEL); + $DEL = cleanID($INPUT->str('delete')); + $IMG = $DEL; + $NS = getNS($DEL); }elseif($INPUT->str('edit')){ - $IMG = cleanID($INPUT->str('edit')); - $NS = getNS($IMG); + $IMG = cleanID($INPUT->str('edit')); + $NS = getNS($IMG); }elseif($INPUT->str('img')){ - $IMG = cleanID($INPUT->str('img')); - $NS = getNS($IMG); + $IMG = cleanID($INPUT->str('img')); + $NS = getNS($IMG); }else{ - $NS = cleanID($INPUT->str('ns')); - $IMG = null; + $NS = cleanID($INPUT->str('ns')); + $IMG = null; } global $INFO, $JSINFO; @@ -50,82 +50,82 @@ use dokuwiki\Extension\Event; // do not display the manager if user does not have read access if($AUTH < AUTH_READ && !$fullscreen) { - http_status(403); - die($lang['accessdenied']); + http_status(403); + die($lang['accessdenied']); } // handle flash upload if(isset($_FILES['Filedata'])){ - $_FILES['upload'] =& $_FILES['Filedata']; - $JUMPTO = media_upload($NS,$AUTH); - if($JUMPTO == false){ - http_status(400); - echo 'Upload failed'; + $_FILES['upload'] =& $_FILES['Filedata']; + $JUMPTO = media_upload($NS, $AUTH); + if($JUMPTO == false){ + http_status(400); + echo 'Upload failed'; } - echo 'ok'; - exit; + echo 'ok'; + exit; } // give info on PHP caught upload errors if(!empty($_FILES['upload']['error'])){ - switch($_FILES['upload']['error']){ - case 1: + switch($_FILES['upload']['error']){ + case 1: case 2: - msg(sprintf($lang['uploadsize'], - filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1); - break; - default: - msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1); + msg(sprintf($lang['uploadsize'], + filesize_h(php_to_byte(ini_get('upload_max_filesize')))), -1); + break; + default: + msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')', -1); } - unset($_FILES['upload']); + unset($_FILES['upload']); } // handle upload if(!empty($_FILES['upload']['tmp_name'])){ - $JUMPTO = media_upload($NS,$AUTH); - if($JUMPTO) $NS = getNS($JUMPTO); + $JUMPTO = media_upload($NS, $AUTH); + if($JUMPTO) $NS = getNS($JUMPTO); } // handle meta saving if($IMG && @array_key_exists('save', $INPUT->arr('do'))){ - $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); + $JUMPTO = media_metasave($IMG, $AUTH, $INPUT->arr('meta')); } if($IMG && ($INPUT->str('mediado') == 'save' || @array_key_exists('save', $INPUT->arr('mediado')))) { - $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); + $JUMPTO = media_metasave($IMG, $AUTH, $INPUT->arr('meta')); } if ($INPUT->int('rev') && $conf['mediarevisions']) $REV = $INPUT->int('rev'); if($INPUT->str('mediado') == 'restore' && $conf['mediarevisions']){ - $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH); + $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH); } // handle deletion if($DEL) { - $res = 0; - if(checkSecurityToken()) { - $res = media_delete($DEL,$AUTH); + $res = 0; + if(checkSecurityToken()) { + $res = media_delete($DEL, $AUTH); } - if ($res & DOKU_MEDIA_DELETED) { - $msg = sprintf($lang['deletesucc'], noNS($DEL)); - if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { - // current namespace was removed. redirecting to root ns passing msg along - send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. - rawurlencode($msg).'&edid='.$INPUT->str('edid')); - } - msg($msg,1); + if ($res & DOKU_MEDIA_DELETED) { + $msg = sprintf($lang['deletesucc'], noNS($DEL)); + if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { + // current namespace was removed. redirecting to root ns passing msg along + send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. + rawurlencode($msg).'&edid='.$INPUT->str('edid')); + } + msg($msg, 1); } elseif ($res & DOKU_MEDIA_INUSE) { - msg(sprintf($lang['mediainuse'],noNS($DEL)),0); + msg(sprintf($lang['mediainuse'], noNS($DEL)), 0); } else { - msg(sprintf($lang['deletefail'],noNS($DEL)),-1); + msg(sprintf($lang['deletefail'], noNS($DEL)), -1); } } // finished - start output if (!$fullscreen) { - header('Content-Type: text/html; charset=utf-8'); - include(template('mediamanager.php')); + header('Content-Type: text/html; charset=utf-8'); + include(template('mediamanager.php')); } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ diff --git a/lib/exe/opensearch.php b/lib/exe/opensearch.php index d335ae779..35656c021 100644 --- a/lib/exe/opensearch.php +++ b/lib/exe/opensearch.php @@ -8,9 +8,9 @@ * @author Andreas Gohr */ -if(!defined('DOKU_INC')) define('DOKU_INC',__DIR__.'/../../'); -if(!defined('NOSESSION')) define('NOSESSION',true); // we do not use a session or authentication here (better caching) -if(!defined('NL')) define('NL',"\n"); +if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__.'/../../'); +if(!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching) +if(!defined('NL')) define('NL', "\n"); require_once(DOKU_INC.'inc/init.php'); // try to be clever about the favicon location diff --git a/lib/exe/taskrunner.php b/lib/exe/taskrunner.php index 0ccb4352d..8a63ecbe5 100644 --- a/lib/exe/taskrunner.php +++ b/lib/exe/taskrunner.php @@ -11,7 +11,7 @@ use dokuwiki\TaskRunner; if (!defined('DOKU_INC')) { define('DOKU_INC', __DIR__ . '/../../'); } -define('DOKU_DISABLE_GZIP_OUTPUT',1); +define('DOKU_DISABLE_GZIP_OUTPUT', 1); require_once DOKU_INC.'inc/init.php'; session_write_close(); //close session diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index 1713b53e3..854de4bf9 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -936,7 +936,7 @@ class helper_plugin_extension_extension extends Plugin $file .= $name; $fileexists = file_exists($file); - $fp = @fopen($file,"w"); + $fp = @fopen($file, "w"); if (!$fp) return false; fwrite($fp, $data); fclose($fp); diff --git a/lib/plugins/testing/action.php b/lib/plugins/testing/action.php index b98d8bb63..7f374b5e9 100644 --- a/lib/plugins/testing/action.php +++ b/lib/plugins/testing/action.php @@ -21,6 +21,6 @@ class action_plugin_testing extends ActionPlugin { public function dokuwikiStarted() { $param = []; Event::createAndTrigger('TESTING_PLUGIN_INSTALLED', $param); - msg('The testing plugin is enabled and should be disabled.',-1); + msg('The testing plugin is enabled and should be disabled.', -1); } } diff --git a/lib/tpl/dokuwiki/detail.php b/lib/tpl/dokuwiki/detail.php index 319f43a8f..0b12ec0ba 100644 --- a/lib/tpl/dokuwiki/detail.php +++ b/lib/tpl/dokuwiki/detail.php @@ -15,7 +15,7 @@ if (!defined('DOKU_INC')) die(); - <?php echo hsc(tpl_img_getTag('IPTC.Headline',$IMG))?> + <?php echo hsc(tpl_img_getTag('IPTC.Headline', $IMG))?> [<?php echo strip_tags($conf['title'])?>] @@ -37,7 +37,7 @@ if (!defined('DOKU_INC')) die(); -
+
@@ -51,14 +51,14 @@ if (!defined('DOKU_INC')) die();

- +
'.$lang['reference'].':'; - $media_usage = ft_mediause($IMG,true); + $media_usage = ft_mediause($IMG, true); if($media_usage !== []){ foreach($media_usage as $path){ echo '
'.html_wikilink($path).'
'; diff --git a/lib/tpl/index.php b/lib/tpl/index.php index c18f6f36e..b584c1f7e 100644 --- a/lib/tpl/index.php +++ b/lib/tpl/index.php @@ -9,8 +9,8 @@ * @author Anika Henke */ // phpcs:disable PSR1.Files.SideEffects -if(!defined('DOKU_INC')) define('DOKU_INC',__DIR__.'/../../'); -if(!defined('NOSESSION')) define('NOSESSION',1); +if(!defined('DOKU_INC')) define('DOKU_INC', __DIR__.'/../../'); +if(!defined('NOSESSION')) define('NOSESSION', 1); require_once(DOKU_INC.'inc/init.php'); ?> @@ -56,7 +56,7 @@ if (!empty($ini)) { echo ''.hsc($key).''; echo ''.hsc($val).''; echo ''; - if(preg_match('/^#[0-f]{3,6}$/i',$val)){ + if(preg_match('/^#[0-f]{3,6}$/i', $val)){ echo '
 
'; } echo ''; -- 2.11.4.GIT