coding style: control flow line breaks

This commit is contained in:
Andreas Gohr 2023-08-31 15:04:10 +02:00
parent cb7312c0f5
commit 7d34963b3e
42 changed files with 221 additions and 135 deletions

View File

@ -30,12 +30,6 @@
<exclude name="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse"/>
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
<exclude name="PSR12.ControlStructures.BooleanOperatorPlacement.FoundMixed"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpaceBeforeCloseBrace"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>

View File

@ -106,7 +106,8 @@ if ($conf['allowdebug'] && $ACT == 'debug') {
}
//send 404 for missing pages if configured or ID has special meaning to bots
if (!$INFO['exists'] &&
if (
!$INFO['exists'] &&
($conf['send404'] || preg_match('/^(robots\.txt|sitemap\.xml(\.gz)?|favicon\.ico|crossdomain\.xml)$/', $ID)) &&
($ACT == 'show' || (!is_array($ACT) && substr($ACT, 0, 7) == 'export_'))
) {

View File

@ -334,12 +334,14 @@ function rss_buildItems(&$rss, &$data, $opt)
$more = 'w=' . $size[0] . '&h=' . $size[1] . '&t=' . @filemtime(mediaFN($id));
$src_r = ml($id, $more, true, '&amp;', true);
}
if ($rev && $size = media_image_preview_size(
$id,
$rev,
new JpegMeta(mediaFN($id, $rev)),
300
)) {
if (
$rev && $size = media_image_preview_size(
$id,
$rev,
new JpegMeta(mediaFN($id, $rev)),
300
)
) {
$more = 'rev=' . $rev . '&w=' . $size[0] . '&h=' . $size[1];
$src_l = ml($id, $more, true, '&amp;', true);
}

View File

@ -47,7 +47,8 @@ class Save extends AbstractAction
throw new ActionException('edit');
}
//conflict check
if ($DATE != 0
if (
$DATE != 0
&& isset($INFO['meta']['date']['modified'])
&& $INFO['meta']['date']['modified'] > $DATE
) {

View File

@ -40,8 +40,10 @@ class CacheRenderer extends CacheParser
// for wiki pages, check metadata dependencies
$metadata = p_get_metadata($this->page);
if (!isset($metadata['relation']['references']) ||
empty($metadata['relation']['references'])) {
if (
!isset($metadata['relation']['references']) ||
empty($metadata['relation']['references'])
) {
return true;
}

View File

@ -508,7 +508,8 @@ abstract class ChangeLog
$lastTail = $tail;
// add a possible revision of external edit, create or deletion
if ($lastTail == $eof && $afterCount <= (int) ($max / 2) &&
if (
$lastTail == $eof && $afterCount <= (int) ($max / 2) &&
count($revs) && !$this->isCurrentRevision($revs[count($revs)-1])
) {
$revs[] = $this->currentRevision;

View File

@ -73,8 +73,10 @@ class Draft
if (!$conf['usedraft']) {
return false;
}
if (!$INPUT->post->has('wikitext') &&
!$EVENT_HANDLER->hasHandlerForEvent('DRAFT_SAVE')) {
if (
!$INPUT->post->has('wikitext') &&
!$EVENT_HANDLER->hasHandlerForEvent('DRAFT_SAVE')
) {
return false;
}
$draft = [

View File

@ -300,7 +300,8 @@ class PageFile
$oldmeta = p_read_metadata($this->id)['persistent'];
$meta = [];
if ($wasCreated &&
if (
$wasCreated &&
(empty($oldmeta['date']['created']) || $oldmeta['date']['created'] === $createdDate)
) {
// newly created

View File

@ -167,10 +167,12 @@ class HTTPClient
$unencodedData = $data;
// don't accept gzip if truncated bodies might occur
if ($this->max_bodysize &&
if (
$this->max_bodysize &&
!$this->max_bodysize_abort &&
isset($this->headers['Accept-encoding']) &&
$this->headers['Accept-encoding'] == 'gzip') {
$this->headers['Accept-encoding'] == 'gzip'
) {
unset($this->headers['Accept-encoding']);
}
@ -474,17 +476,21 @@ class HTTPClient
return false;
}
if (!$this->keep_alive ||
(isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) {
if (
!$this->keep_alive ||
(isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')
) {
// close socket
fclose($socket);
unset(self::$connections[$connectionId]);
}
// decode gzip if needed
if (isset($this->resp_headers['content-encoding']) &&
if (
isset($this->resp_headers['content-encoding']) &&
$this->resp_headers['content-encoding'] == 'gzip' &&
strlen($r_body) > 10 && substr($r_body, 0, 3) == "\x1f\x8b\x08") {
strlen($r_body) > 10 && substr($r_body, 0, 3) == "\x1f\x8b\x08"
) {
$this->resp_body = @gzinflate(substr($r_body, 10));
if ($this->resp_body === false) {
$this->error = 'Failed to decompress gzip encoded content';

View File

@ -742,7 +742,8 @@ class Mailer
$this->cleanHeaders();
// any recipients?
if (trim($this->headers['To']) === '' &&
if (
trim($this->headers['To']) === '' &&
trim($this->headers['Cc']) === '' &&
trim($this->headers['Bcc']) === ''
) return false;

View File

@ -92,8 +92,10 @@ class Block
if (trim($content)=='') {
//remove the whole paragraph
//array_splice($this->calls,$i); // <- this is much slower than the loop below
for ($x=$ccount; $x>$i;
$x--) array_pop($this->calls);
for (
$x=$ccount; $x>$i;
$x--
) array_pop($this->calls);
} else {
// remove ending linebreaks in the paragraph
$i=count($this->calls)-1;

View File

@ -225,7 +225,8 @@ class Table extends AbstractRewriter
$this->tableCalls[$key-1][1][0] = false;
for ($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) {
if ($this->tableCalls[$i][0] == 'tablecell_open' ||
if (
$this->tableCalls[$i][0] == 'tablecell_open' ||
$this->tableCalls[$i][0] == 'tableheader_open'
) {
if (false !== $this->tableCalls[$i][1][0]) {
@ -251,7 +252,8 @@ class Table extends AbstractRewriter
// can't cross thead/tbody boundary
if (!$this->countTableHeadRows || ($lastRow-1 != $this->countTableHeadRows)) {
for ($i = $lastRow-1; $i > 0; $i--) {
if ($this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' ||
if (
$this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' ||
$this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open'
) {
if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) {

View File

@ -466,9 +466,14 @@ 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");
}
}
@ -526,8 +531,10 @@ class Indexer
}
foreach ($wordlist as $i => $word) {
if ((!is_numeric($word) && strlen($word) < IDX_MINWORDLENGTH)
|| in_array($word, $stopwords, true))
if (
(!is_numeric($word) && strlen($word) < IDX_MINWORDLENGTH)
|| in_array($word, $stopwords, true)
)
unset($wordlist[$i]);
}
return array_values($wordlist);

View File

@ -45,8 +45,10 @@ class Mapper
return false;
}
if (@filesize($sitemap) &&
@filemtime($sitemap) > (time()-($conf['sitemap']*86400))) { // 60*60*24=86400
if (
@filesize($sitemap) &&
@filemtime($sitemap) > (time()-($conf['sitemap']*86400))
) { // 60*60*24=86400
Logger::debug('Sitemapper::generate(): Sitemap up to date');
return false;
}

View File

@ -87,7 +87,8 @@ class BulkSubscriptionSender extends SubscriptionSender
foreach ($changes as $rev) {
$n = 0;
$pagelog = new PageChangeLog($rev['id']);
while (!is_null($rev) && $rev['date'] >= $lastupdate &&
while (
!is_null($rev) && $rev['date'] >= $lastupdate &&
($INPUT->server->str('REMOTE_USER') === $rev['user'] ||
$rev['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT)
) {

View File

@ -47,7 +47,8 @@ class TaskRunner
$tmp = []; // No event data
$evt = new Event('INDEXER_TASKS_RUN', $tmp);
if ($evt->advise_before()) {
if (!(
if (
!(
$this->runIndexer() ||
$this->runSitemapper() ||
$this->sendDigest() ||
@ -106,9 +107,11 @@ class TaskRunner
// Trims the recent changes cache to the last $conf['changes_days'] recent
// changes or $conf['recent'] items, which ever is larger.
// The trimming is only done once a day.
if (file_exists($fn) &&
if (
file_exists($fn) &&
(@filemtime($fn . '.trimmed') + 86400) < time() &&
!file_exists($fn . '_tmp')) {
!file_exists($fn . '_tmp')
) {
@touch($fn . '.trimmed');
io_lock($fn);
$lines = file($fn);

View File

@ -440,7 +440,8 @@ class PageDiff extends Diff
]),
'attrs' => ['title' => $rev]
];
if (($side == 'older' && ($rev2 && $rev >= $rev2))
if (
($side == 'older' && ($rev2 && $rev >= $rev2))
|| ($side == 'newer' && ($rev <= $rev1))
) {
$options[$rev]['attrs']['disabled'] = 'disabled';

View File

@ -119,14 +119,16 @@ class Unicode
* Check for illegal sequences and codepoints.
*/
// From Unicode 3.1, non-shortest form is illegal
if (((2 === $mBytes) && ($mUcs4 < 0x0080)) ||
if (
((2 === $mBytes) && ($mUcs4 < 0x0080)) ||
((3 === $mBytes) && ($mUcs4 < 0x0800)) ||
((4 === $mBytes) && ($mUcs4 < 0x10000)) ||
(4 < $mBytes) ||
// From Unicode 3.2, surrogate characters are illegal
(($mUcs4 & 0xFFFFF800) === 0xD800) ||
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF)) {
($mUcs4 > 0x10FFFF)
) {
if ($strict) {
trigger_error(
'utf8_to_unicode: Illegal sequence or codepoint ' .

View File

@ -246,7 +246,8 @@ function auth_login($user, $pass, $sticky = false, $silent = false)
// get session info
if (isset($_SESSION[DOKU_COOKIE])) {
$session = $_SESSION[DOKU_COOKIE]['auth'];
if (isset($session) &&
if (
isset($session) &&
$auth->useSessionCache($user) &&
($session['time'] >= time() - $conf['auth_security_timeout']) &&
($session['user'] == $user) &&
@ -565,7 +566,7 @@ function auth_isMember($memberlist, $user, array $groups)
// compare cleaned values
foreach ($members as $member) {
if ($member == '@ALL' ) return true;
if ($member == '@ALL') return true;
if (!$auth->isCaseSensitive()) $member = PhpString::strtolower($member);
if ($member[0] == '@') {
$member = $auth->cleanGroup(substr($member, 1));
@ -992,7 +993,8 @@ function updateprofile()
$changes['mail'] = trim(preg_replace('/[\x00-\x1f:<>&%,;]+/', '', $changes['mail']));
// no empty name and email (except the backend doesn't support them)
if ((empty($changes['name']) && $auth->canDo('modName')) ||
if (
(empty($changes['name']) && $auth->canDo('modName')) ||
(empty($changes['mail']) && $auth->canDo('modMail'))
) {
msg($lang['profnoempty'], -1);

View File

@ -490,7 +490,8 @@ function idfilter($id, $ue = true)
if ($conf['useslash'] && $conf['userewrite']) {
$id = strtr($id, ':', '/');
} elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' &&
} elseif (
strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' &&
$conf['userewrite'] &&
strpos($INPUT->server->str('SERVER_SOFTWARE'), 'Microsoft-IIS') === false
) {
@ -1262,12 +1263,14 @@ function rawWikiSlices($range, $id, $rev = '')
function con($pre, $text, $suf, $pretty = false)
{
if ($pretty) {
if ($pre !== '' && substr($pre, -1) !== "\n" &&
if (
$pre !== '' && substr($pre, -1) !== "\n" &&
substr($text, 0, 1) !== "\n"
) {
$pre .= "\n";
}
if ($suf !== '' && substr($text, -1) !== "\n" &&
if (
$suf !== '' && substr($text, -1) !== "\n" &&
substr($suf, 0, 1) !== "\n"
) {
$text .= "\n";
@ -1871,7 +1874,8 @@ function send_redirect($url)
session_write_close();
// check if running on IIS < 6 with CGI-PHP
if ($INPUT->server->has('SERVER_SOFTWARE') && $INPUT->server->has('GATEWAY_INTERFACE') &&
if (
$INPUT->server->has('SERVER_SOFTWARE') && $INPUT->server->has('GATEWAY_INTERFACE') &&
(strpos($INPUT->server->str('GATEWAY_INTERFACE'), 'CGI') !== false) &&
(preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($INPUT->server->str('SERVER_SOFTWARE')), $matches)) &&
$matches[1] < 6

View File

@ -58,7 +58,7 @@ function mimetype($file, $knownonly = true)
function getMimeTypes()
{
static $mime = null;
if ( !$mime ) {
if (!$mime) {
$mime = retrieveConfig('mime', 'confToHash');
$mime = array_filter($mime);
}
@ -73,7 +73,7 @@ function getMimeTypes()
function getAcronyms()
{
static $acronyms = null;
if ( !$acronyms ) {
if (!$acronyms) {
$acronyms = retrieveConfig('acronyms', 'confToHash');
$acronyms = array_filter($acronyms, 'strlen');
}
@ -88,7 +88,7 @@ function getAcronyms()
function getSmileys()
{
static $smileys = null;
if ( !$smileys ) {
if (!$smileys) {
$smileys = retrieveConfig('smileys', 'confToHash');
$smileys = array_filter($smileys, 'strlen');
}
@ -103,7 +103,7 @@ function getSmileys()
function getEntities()
{
static $entities = null;
if ( !$entities ) {
if (!$entities) {
$entities = retrieveConfig('entities', 'confToHash');
$entities = array_filter($entities, 'strlen');
}
@ -118,7 +118,7 @@ function getEntities()
function getInterwiki()
{
static $wikis = null;
if ( !$wikis ) {
if (!$wikis) {
$wikis = retrieveConfig('interwiki', 'confToHash', [true]);
$wikis = array_filter($wikis, 'strlen');
@ -183,7 +183,7 @@ function getCdnUrls()
function getWordblocks()
{
static $wordblocks = null;
if ( !$wordblocks ) {
if (!$wordblocks) {
$wordblocks = retrieveConfig('wordblock', 'file', null, 'array_merge_with_removal');
}
return $wordblocks;
@ -197,7 +197,7 @@ function getWordblocks()
function getSchemes()
{
static $schemes = null;
if ( !$schemes ) {
if (!$schemes) {
$schemes = retrieveConfig('scheme', 'file', null, 'array_merge_with_removal');
$schemes = array_map('trim', $schemes);
$schemes = preg_replace('/^#.*/', '', $schemes);
@ -265,7 +265,7 @@ function confToHash($file, $lower = false)
{
$conf = [];
$lines = @file($file);
if ( !$lines ) return $conf;
if (!$lines) return $conf;
return linesToHash($lines, $lower);
}

View File

@ -70,7 +70,7 @@ function sendFile($file, $mime, $dl, $cache, $public = false, $orig = null, $csp
http_conditionalRequest($fmtime);
// Use the current $file if is $orig is not set.
if ( $orig == null ) {
if ($orig == null) {
$orig = $file;
}
@ -123,7 +123,7 @@ function rfc2231_encode($name, $value, $charset = 'utf-8', $lang = 'en')
static fn($match) => rawurlencode($match[0]),
$value
);
if ( $value != $internal ) {
if ($value != $internal) {
return ' '.$name.'*='.$charset."'".$lang."'".$internal;
} else {
return ' '.$name.'="'.$value.'"';

View File

@ -183,9 +183,11 @@ function ft_backlinks($id, $ignore_perms = false)
// check ACL permissions
foreach (array_keys($result) as $idx) {
if ((!$ignore_perms && (
if (
(!$ignore_perms && (
isHiddenPage($result[$idx]) || auth_quickaclcheck($result[$idx]) < AUTH_READ
)) || !page_exists($result[$idx], '', false)) {
)) || !page_exists($result[$idx], '', false)
) {
unset($result[$idx]);
}
}
@ -215,9 +217,11 @@ function ft_mediause($id, $ignore_perms = false)
// check ACL permissions
foreach (array_keys($result) as $idx) {
if ((!$ignore_perms && (
if (
(!$ignore_perms && (
isHiddenPage($result[$idx]) || auth_quickaclcheck($result[$idx]) < AUTH_READ
)) || !page_exists($result[$idx], '', false)) {
)) || !page_exists($result[$idx], '', false)
) {
unset($result[$idx]);
}
}
@ -324,8 +328,10 @@ function _ft_pageLookup(&$data)
// discard nonexistent pages
// check ACL permissions
foreach (array_keys($pages) as $idx) {
if (!isVisiblePage($idx) || !page_exists($idx) ||
auth_quickaclcheck($idx) < AUTH_READ) {
if (
!isVisiblePage($idx) || !page_exists($idx) ||
auth_quickaclcheck($idx) < AUTH_READ
) {
unset($pages[$idx]);
}
}

View File

@ -480,7 +480,7 @@ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = fa
} elseif ($item['level'] < $level) {
//close last item
$html .= '</li>'."\n";
while ($level > $item['level'] && $open > 0 ) {
while ($level > $item['level'] && $open > 0) {
//close higher lists
$html .= '</ul>'."\n".'</li>'."\n";
$level--;

View File

@ -281,8 +281,10 @@ function idx_listIndexLengths()
$docache = false;
} else {
clearstatcache();
if (file_exists($conf['indexdir'].'/lengths.idx')
&& (time() < @filemtime($conf['indexdir'].'/lengths.idx') + $conf['readdircache'])) {
if (
file_exists($conf['indexdir'].'/lengths.idx')
&& (time() < @filemtime($conf['indexdir'].'/lengths.idx') + $conf['readdircache'])
) {
if (
($lengths = @file($conf['indexdir'].'/lengths.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))
!== false

View File

@ -152,12 +152,14 @@ if (!defined('DOKU_TPLINC')) {
$httpAcceptEncoding = $_SERVER['HTTP_ACCEPT_ENCODING'] ?? '';
$conf['gzip_output'] &= (strpos($httpAcceptEncoding, 'gzip') !== false);
global $ACT;
if ($conf['gzip_output'] &&
if (
$conf['gzip_output'] &&
!defined('DOKU_DISABLE_GZIP_OUTPUT') &&
function_exists('ob_gzhandler') &&
// Disable compression when a (compressed) sitemap might be delivered
// See https://bugs.dokuwiki.org/index.php?do=details&task_id=2576
$ACT != 'sitemap') {
$ACT != 'sitemap'
) {
ob_start('ob_gzhandler');
}
@ -542,8 +544,10 @@ function is_ssl()
return false;
}
}
if (!isset($_SERVER['HTTPS']) ||
preg_match('/^(|off|false|disabled)$/i', $_SERVER['HTTPS'])) {
if (
!isset($_SERVER['HTTPS']) ||
preg_match('/^(|off|false|disabled)$/i', $_SERVER['HTTPS'])
) {
return false;
} else {
return true;

View File

@ -638,8 +638,10 @@ function io_download($url, $file, $useAttachment = false, $defaultName = '', $ma
if (isset($http->resp_headers['content-disposition'])) {
$content_disposition = $http->resp_headers['content-disposition'];
$match=[];
if (is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)) {
if (
is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
) {
$name = PhpString::basename($match[1]);
}
}

View File

@ -140,13 +140,15 @@ function load_autoload($name)
}
// Plugin loading
if (preg_match(
'/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' .
DOKU_PLUGIN_NAME_REGEX .
')(?:_([^_]+))?$/',
$name,
$m
)) {
if (
preg_match(
'/^(' . implode('|', PluginController::PLUGIN_TYPES) . ')_plugin_(' .
DOKU_PLUGIN_NAME_REGEX .
')(?:_([^_]+))?$/',
$name,
$m
)
) {
// try to load the wanted plugin file
$c = ((count($m) === 4) ? "/{$m[3]}" : '');
$plg = DOKU_PLUGIN . "{$m[2]}/{$m[1]}$c.php";

View File

@ -775,11 +775,13 @@ function media_tabs_files($selected_tab = '')
{
global $lang;
$tabs = [];
foreach ([
foreach (
[
'files' => 'mediaselect',
'upload' => 'media_uploadtab',
'search' => 'media_searchtab'
] as $tab => $caption) {
] as $tab => $caption
) {
$tabs[$tab] = [
'href' => media_managerURL(['tab_files' => $tab], '&'),
'caption' => $lang[$caption]
@ -849,10 +851,12 @@ function media_tab_files_options()
$form->setHiddenField('q', $INPUT->str('q'));
}
$form->addHTML('<ul>'.NL);
foreach ([
foreach (
[
'list' => ['listType', ['thumbs', 'rows']],
'sort' => ['sortBy', ['name', 'date']]
] as $group => $content) {
] as $group => $content
) {
$checked = "_media_get_{$group}_type";
$checked = $checked();
@ -1177,8 +1181,9 @@ function media_preview_buttons($image, $auth, $rev = '')
*/
function media_image_preview_size($image, $rev, $meta = false, $size = 500)
{
if (!preg_match("/\.(jpe?g|gif|png)$/", $image)
|| !file_exists($filename = mediaFN($image, $rev))
if (
!preg_match("/\.(jpe?g|gif|png)$/", $image)
|| !file_exists($filename = mediaFN($image, $rev))
) return [];
$info = getimagesize($filename);
@ -1887,7 +1892,8 @@ function media_get_from_URL($url, $ext, $cache)
$mtime = @filemtime($local); // 0 if not exists
//decide if download needed:
if (($mtime == 0) || // cache does not exist
if (
($mtime == 0) || // cache does not exist
($cache != -1 && $mtime < time() - $cache) // 'recache' and cache has expired
) {
if (media_image_download($url, $local)) {
@ -2080,7 +2086,7 @@ function media_resize_imageGD($ext, $from, $from_w, $from_h, $to, $to_w, $to_h,
if ($ext == 'gif' && function_exists('imagefill') && function_exists('imagecolorallocate')) {
if (function_exists('imagecolorsforindex') && function_exists('imagecolortransparent')) {
$transcolorindex = @imagecolortransparent($image);
if ($transcolorindex >= 0 ) { //transparent color exists
if ($transcolorindex >= 0) { //transparent color exists
$transcolor = @imagecolorsforindex($image, $transcolorindex);
$transcolorindex = @imagecolorallocate(
$newimg,

View File

@ -791,9 +791,11 @@ function p_xhtml_cached_geshi($code, $language, $wrapper = 'pre', array $options
$optionsmd5 = md5(serialize($options));
$cache = getCacheName($language . $code . $optionsmd5, ".code");
$ctime = @filemtime($cache);
if ($ctime && !$INPUT->bool('purge') &&
if (
$ctime && !$INPUT->bool('purge') &&
$ctime > filemtime(DOKU_INC . 'vendor/composer/installed.json') && // libraries changed
$ctime > filemtime(reset($config_cascade['main']['default']))) { // dokuwiki changed
$ctime > filemtime(reset($config_cascade['main']['default']))
) { // dokuwiki changed
$highlighted_code = io_readFile($cache, false);
} else {
$geshi = new GeSHi($code, $language);

View File

@ -379,8 +379,10 @@ function search_allpages(&$data, $base, $file, $type, $lvl, $opts)
{
if (isset($opts['depth']) && $opts['depth']) {
$parts = explode('/', ltrim($file, '/'));
if (($type == 'd' && count($parts) >= $opts['depth'])
|| ($type != 'd' && count($parts) > $opts['depth'])) {
if (
($type == 'd' && count($parts) >= $opts['depth'])
|| ($type != 'd' && count($parts) > $opts['depth'])
) {
return false; // depth reached
}
}

View File

@ -335,7 +335,7 @@ function tpl_metaheaders($alt = true)
if (($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) {
if ($INFO['exists']) {
//delay indexing:
if ((time() - $INFO['lastmod']) >= $conf['indexdelay'] && !isHiddenPage($ID) ) {
if ((time() - $INFO['lastmod']) >= $conf['indexdelay'] && !isHiddenPage($ID)) {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'index,follow'];
} else {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'noindex,nofollow'];
@ -419,7 +419,7 @@ function _tpl_metaheaders_action($data)
echo "<!--[if gte IE 9]><!-->\n"; // no scripts for old IE
}
foreach ($inst as $attr) {
if ( empty($attr) ) {
if (empty($attr)) {
continue; }
echo '<', $tag, ' ', buildAttributes($attr);
if (isset($attr['_data']) || $tag == 'script') {
@ -1678,7 +1678,7 @@ function tpl_subscribe()
*/
function tpl_flush()
{
if ( ob_get_level() > 0 ) ob_flush();
if (ob_get_level() > 0) ob_flush();
flush();
}

View File

@ -92,9 +92,11 @@ class admin_plugin_acl extends AdminPlugin
if ($this->who != '%USER%' && $this->who != '%GROUP%') { #keep wildcard as is
$this->who = $auth->cleanUser($this->who);
}
} elseif ($INPUT->str('acl_t') &&
} elseif (
$INPUT->str('acl_t') &&
$INPUT->str('acl_t') != '__u__' &&
$INPUT->str('acl_t') != '__g__') {
$INPUT->str('acl_t') != '__g__'
) {
$this->who = $INPUT->str('acl_t');
} elseif ($who) {
$this->who = $who;
@ -809,9 +811,11 @@ class admin_plugin_acl extends AdminPlugin
$usel = '';
$gsel = '';
if ($this->who &&
!in_array($this->who, $this->usersgroups) &&
!in_array($this->who, $this->specials)) {
if (
$this->who &&
!in_array($this->who, $this->usersgroups) &&
!in_array($this->who, $this->specials)
) {
if ($this->who[0] == '@') {
$gsel = ' selected="selected"';
} else {

View File

@ -159,7 +159,8 @@ class auth_plugin_authad extends AuthPlugin
public function checkPass($user, $pass)
{
global $INPUT;
if ($INPUT->server->str('REMOTE_USER') == $user &&
if (
$INPUT->server->str('REMOTE_USER') == $user &&
$this->conf['sso']
) return true;
@ -270,7 +271,8 @@ class auth_plugin_authad extends AuthPlugin
$info['expiresin'] = round(($info['expiresat'] - time())/(24*60*60));
// if this is the current user, warn him (once per request only)
if (($INPUT->server->str('REMOTE_USER') == $user) &&
if (
($INPUT->server->str('REMOTE_USER') == $user) &&
($info['expiresin'] <= $this->conf['expirywarn']) &&
!$this->msgshown
) {
@ -334,8 +336,10 @@ class auth_plugin_authad extends AuthPlugin
$user = PhpString::strtolower(trim($user));
// is this a known, valid domain or do we work without account suffix? if not discard
if ((!isset($this->conf[$domain]) || !is_array($this->conf[$domain])) &&
$this->conf['account_suffix'] !== '') {
if (
(!isset($this->conf[$domain]) || !is_array($this->conf[$domain])) &&
$this->conf['account_suffix'] !== ''
) {
$domain = '';
}
@ -409,7 +413,8 @@ class auth_plugin_authad extends AuthPlugin
$usermanager->setLastdisabled(true);
if (!isset($this->grpsusers[$this->filterToString($filter)])) {
$this->fillGroupUserArray($filter, $usermanager->getStart() + 3*$usermanager->getPagesize());
} elseif (count($this->grpsusers[$this->filterToString($filter)]) <
} elseif (
count($this->grpsusers[$this->filterToString($filter)]) <
$usermanager->getStart() + 3*$usermanager->getPagesize()
) {
$this->fillGroupUserArray(
@ -539,7 +544,8 @@ class auth_plugin_authad extends AuthPlugin
/** @var admin_plugin_usermanager $usermanager */
$usermanager = plugin_load("admin", "usermanager", false);
$usermanager->setLastdisabled(true);
if (!isset($this->grpsusers[$this->filterToString($filter)]) ||
if (
!isset($this->grpsusers[$this->filterToString($filter)]) ||
count($this->grpsusers[$this->filterToString($filter)]) < ($start+$limit)
) {
if (!isset($this->grpsusers[$this->filterToString($filter)])) {

View File

@ -69,7 +69,8 @@ class auth_plugin_authldap extends AuthPlugin
return false;
}
$this->bound = 2;
} elseif ($this->getConf('binddn') &&
} elseif (
$this->getConf('binddn') &&
$this->getConf('usertree') &&
$this->getConf('userfilter')
) {
@ -564,11 +565,12 @@ class auth_plugin_authldap extends AuthPlugin
//set protocol version and dependend options
if ($this->getConf('version')) {
if (!@ldap_set_option(
$this->con,
LDAP_OPT_PROTOCOL_VERSION,
$this->getConf('version')
)
if (
!@ldap_set_option(
$this->con,
LDAP_OPT_PROTOCOL_VERSION,
$this->getConf('version')
)
) {
msg('Setting LDAP Protocol version ' . $this->getConf('version') . ' failed', -1);
$this->debug('LDAP version set: ' . hsc(ldap_error($this->con)), 0, __LINE__, __FILE__);
@ -582,11 +584,12 @@ class auth_plugin_authldap extends AuthPlugin
}
// needs version 3
if ($this->getConf('referrals') > -1) {
if (!@ldap_set_option(
$this->con,
LDAP_OPT_REFERRALS,
$this->getConf('referrals')
)
if (
!@ldap_set_option(
$this->con,
LDAP_OPT_REFERRALS,
$this->getConf('referrals')
)
) {
msg('Setting LDAP referrals failed', -1);
$this->debug('LDAP referal set: ' . hsc(ldap_error($this->con)), 0, __LINE__, __FILE__);

View File

@ -21,8 +21,10 @@ class SettingNumeric extends SettingString
$valid = parent::update($input);
if ($valid && !(is_null($this->min) && is_null($this->max))) {
$numeric_local = (int) eval('return ' . $this->local . ';');
if ((!is_null($this->min) && $numeric_local < $this->min) ||
(!is_null($this->max) && $numeric_local > $this->max)) {
if (
(!is_null($this->min) && $numeric_local < $this->min) ||
(!is_null($this->max) && $numeric_local > $this->max)
) {
$this->error = true;
$this->input = $input;
$this->local = $local;

View File

@ -23,11 +23,13 @@ class SettingUndefined extends SettingHidden
public function html(\admin_plugin_config $plugin, $echo = false)
{
// determine the name the meta key would be called
if (preg_match(
'/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
$this->getKey(),
$undefined_setting_match
)) {
if (
preg_match(
'/^(?:plugin|tpl)' . Configuration::KEYMARKER . '.*?' . Configuration::KEYMARKER . '(.*)$/',
$this->getKey(),
$undefined_setting_match
)
) {
$undefined_setting_key = $undefined_setting_match[1];
} else {
$undefined_setting_key = $this->getKey();

View File

@ -919,7 +919,8 @@ class helper_plugin_extension_extension extends Plugin
if (isset($http->resp_headers['content-disposition'])) {
$content_disposition = $http->resp_headers['content-disposition'];
$match = [];
if (is_string($content_disposition) &&
if (
is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
) {
$name = PhpString::basename($match[1]);

View File

@ -588,7 +588,8 @@ class helper_plugin_extension_list extends Plugin
if ($extension->isGitControlled()) {
$errors .= '<p class="permerror">'.$this->getLang('git').'</p>';
}
if ($extension->isEnabled() &&
if (
$extension->isEnabled() &&
in_array('Auth', $extension->getTypes()) &&
$conf['authtype'] != $extension->getID()
) {

View File

@ -35,7 +35,8 @@ class helper_plugin_extension_repository extends Plugin
foreach ($list as $name) {
$cache = new Cache('##extension_manager##'.$name, '.repo');
if (!isset($this->loaded_extensions[$name]) &&
if (
!isset($this->loaded_extensions[$name]) &&
$this->hasAccess() &&
!$cache->useCache(['age' => 3600 * 24])
) {
@ -100,7 +101,8 @@ class helper_plugin_extension_repository extends Plugin
{
$cache = new Cache('##extension_manager##'.$name, '.repo');
if (!isset($this->loaded_extensions[$name]) &&
if (
!isset($this->loaded_extensions[$name]) &&
$this->hasAccess() &&
!$cache->useCache(['age' => 3600 * 24])
) {

View File

@ -42,7 +42,8 @@ class action_plugin_styling extends ActionPlugin
// set preview
$len = count($event->data['link']);
for ($i = 0; $i < $len; $i++) {
if ($event->data['link'][$i]['rel'] == 'stylesheet' &&
if (
$event->data['link'][$i]['rel'] == 'stylesheet' &&
strpos($event->data['link'][$i]['href'], 'lib/exe/css.php') !== false
) {
$event->data['link'][$i]['href'] .= '&preview=1&tseed='.time();

View File

@ -361,7 +361,7 @@ class admin_plugin_usermanager extends AdminPlugin
{
/** @var AuthPlugin $auth */
global $auth;
if (!$auth || !$auth->canDo('getUsers') ) {
if (!$auth || !$auth->canDo('getUsers')) {
return false;
}
@ -1058,7 +1058,8 @@ class admin_plugin_usermanager extends AdminPlugin
if (!$this->auth->canDo('addUser')) return false;
// check file uploaded ok.
if (empty($_FILES['import']['size']) ||
if (
empty($_FILES['import']['size']) ||
!empty($_FILES['import']['error']) && $this->isUploadedFile($_FILES['import']['tmp_name'])
) {
msg($this->lang['import_error_upload'], -1);