From 187ee44eda69f523ae1369ab9d8d167151446dc9 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 20:47:18 +0300 Subject: [PATCH 1/9] Callable name case mismatched in a call. --- library/includes/cache/redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/includes/cache/redis.php b/library/includes/cache/redis.php index cb002c33d..c1506e9aa 100644 --- a/library/includes/cache/redis.php +++ b/library/includes/cache/redis.php @@ -119,7 +119,7 @@ class cache_redis extends cache_common return ($this->connected) ? $this->redis->del($this->prefix . $name) : false; } else { - return ($this->connected) ? $this->redis->flushdb() : false; + return ($this->connected) ? $this->redis->flushDB() : false; } } From 0a9e9e02eb81ed68e1f0e41863e88aaf29968f74 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 20:47:56 +0300 Subject: [PATCH 2/9] Unnecessary semicolon. --- library/language/ru/main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/language/ru/main.php b/library/language/ru/main.php index 54e4aa21a..ed4ff38c1 100644 --- a/library/language/ru/main.php +++ b/library/language/ru/main.php @@ -2422,7 +2422,7 @@ $lang['REPAIR_CRON'] = 'Восстановить'; $lang['CRON_EDIT_HEAD_EDIT'] = 'Редактировать задачу'; $lang['CRON_EDIT_HEAD_ADD'] = 'Добавить задачу'; -$lang['CRON_SCRIPT_EXPL'] = 'название в папке "includes/cron/jobs/"';; +$lang['CRON_SCRIPT_EXPL'] = 'название в папке "includes/cron/jobs/"'; $lang['SCHEDULE'] = array( 'select' => '» Выберите запуск', 'hourly' => 'ежечасно', From 75ad3506c215511137dd9f7bebae6650ecdfae6d Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 20:50:05 +0300 Subject: [PATCH 3/9] Ternary operator could be simplified. --- admin/admin_attach_cp.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index d911e0be1..6e32a7d17 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -76,7 +76,7 @@ if ($view === 'username') { } // Pagination ? -$do_pagination = ($view !== 'stats' && $view !== 'search') ? true : false; +$do_pagination = ($view !== 'stats' && $view !== 'search'); // Set Order $order_by = ''; @@ -319,7 +319,7 @@ if ($view === 'username') { // Attachments if ($view === 'attachments') { $user_based = ($uid) ? true : false; - $search_based = (isset($_POST['search']) && $_POST['search']) ? true : false; + $search_based = (isset($_POST['search']) && $_POST['search']); $hidden_fields = ''; From 3712862832b4921de5041e29eb5f320de2e6d6a6 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 20:53:00 +0300 Subject: [PATCH 4/9] Deprecated HTML tag. --- library/ajax/sitemap.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/ajax/sitemap.php b/library/ajax/sitemap.php index 984eefb98..3403021b3 100644 --- a/library/ajax/sitemap.php +++ b/library/ajax/sitemap.php @@ -51,27 +51,27 @@ switch ($mode) { $map_link = make_url(SITEMAP_DIR . '/sitemap.xml'); if (strpos($map->send_url("http://google.com/webmasters/sitemaps/ping?sitemap=", $map_link), "successfully added") !== false) { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_SENT'] . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_SENT'] . ''; } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_ERROR'] . ' URL: http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: ' . $lang['SITEMAP_ERROR'] . ' URL: http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . ''; } if (strpos($map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link), "OK") !== false) { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: ' . $lang['SITEMAP_SENT'] . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: ' . $lang['SITEMAP_SENT'] . ''; } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: ' . $lang['SITEMAP_ERROR'] . ' URL: http://ping.blogs.yandex.ru/ping?sitemap=' . $map_link . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: ' . $lang['SITEMAP_ERROR'] . ' URL: http://ping.blogs.yandex.ru/ping?sitemap=' . $map_link . ''; } if ($map->send_url("http://www.bing.com/ping?sitemap=", $map_link)) { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_SENT'] . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_SENT'] . ''; } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_ERROR'] . ' URL: http://www.bing.com/ping?sitemap=' . $map_link . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: ' . $lang['SITEMAP_ERROR'] . ' URL: http://www.bing.com/ping?sitemap=' . $map_link . ''; } if (strpos($map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link), "Thanks for the ping") !== false) { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: ' . $lang['SITEMAP_SENT'] . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: ' . $lang['SITEMAP_SENT'] . ''; } else { - $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: ' . $lang['SITEMAP_ERROR'] . ' URL: http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . $map_link . ''; + $html .= '
' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: ' . $lang['SITEMAP_ERROR'] . ' URL: http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . $map_link . ''; } break; } From dcb828d983e1ab578d94e865eda43e376548a59f Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 20:57:12 +0300 Subject: [PATCH 5/9] Alias functions usage. --- admin/admin_attachments.php | 2 +- library/ajax/view_torrent.php | 2 +- library/includes/bbcode.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index 188657c60..d3e384bb0 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -157,7 +157,7 @@ if ($search_imagick) { $paths = explode(' ', $retval); if (is_array($paths)) { - for ($i = 0; $i < sizeof($paths); $i++) { + for ($i = 0; $iMax = count($paths); $i < $iMax; $i++) { $path = basename($paths[$i]); if ($path == 'convert') { diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index c9274178a..5cc22c5ca 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -89,7 +89,7 @@ class TorrentFileList $filelist = $html->array2html($this->files_ary); return "
{$this->root_dir}
$filelist"; } else { - return join('', $this->files_ary['/']); + return implode('', $this->files_ary['/']); } } diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index 8f335b7e8..3f3fcafc7 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -220,7 +220,7 @@ function strip_quotes($text) } } while ($pos !== false); - if (sizeof($start_pos) == 0) { + if (count($start_pos) == 0) { return $text; } @@ -235,7 +235,7 @@ function strip_quotes($text) } } while ($pos !== false); - if (sizeof($end_pos) == 0) { + if (count($end_pos) == 0) { return $text; } @@ -250,7 +250,7 @@ function strip_quotes($text) $newtext = '[...] '; $substr_pos = 0; foreach ($pos_list as $pos => $type) { - $stacksize = sizeof($stack); + $stacksize = count($stack); if ($type == 'start') { // empty stack, so add from the last close tag or the beginning of the string if ($stacksize == 0) { @@ -377,7 +377,7 @@ function extract_search_words($text) } $text = $text_out; - if (sizeof($text) > $max_words_count) { + if (count($text) > $max_words_count) { # shuffle($text); $text = array_splice($text, 0, $max_words_count); } @@ -393,7 +393,7 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu $words = ($text) ? extract_search_words($text) : array(); if ($only_return_words || $bb_cfg['search_engine_type'] == 'sphinx') { - return join("\n", $words); + return implode("\n", $words); } DB()->query("DELETE FROM " . BB_POSTS_SEARCH . " WHERE post_id = $post_id"); @@ -543,7 +543,7 @@ class bbcode $text = preg_replace_callback("#\[url=(www\.$url_exp)\]([^?\n\t].*?)\[/url\]#isu", array(&$this, 'url_callback'), $text); // Normalize block level tags wrapped with new lines - $block_tags = join('|', $this->block_tags); + $block_tags = implode('|', $this->block_tags); $text = str_replace("\n\n[hr]\n\n", '[br][hr][br]', $text); $text = preg_replace("#(\s*)(\[/?($block_tags)(.*?)\])(\s*)#", '$2', $text); @@ -623,7 +623,7 @@ class bbcode foreach ($found_spam as $keyword) { $spam_exp[] = preg_quote($keyword, '/'); } - $spam_exp = join('|', $spam_exp); + $spam_exp = implode('|', $spam_exp); $text = preg_replace("/($spam_exp)(\S*)/i", $spam_replace, $msg_decoded); $text = htmlCHR($text, false, ENT_NOQUOTES); From 1f44ed29aa79c57f7f8fb728733329ae6c387325 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 22:52:46 +0300 Subject: [PATCH 6/9] Type casting can be used. --- library/attach_mod/includes/functions_admin.php | 4 ++-- library/includes/functions_torrent.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/attach_mod/includes/functions_admin.php b/library/attach_mod/includes/functions_admin.php index 111412187..f416501e7 100644 --- a/library/attach_mod/includes/functions_admin.php +++ b/library/attach_mod/includes/functions_admin.php @@ -121,8 +121,8 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0) // do checks based on key $switch = false; if (!$string_sort) { - if (($sort_order == 'DESC' && intval(@$sort_array[$j][$key]) < intval(@$sort_array[$j + 1][$key])) || - ($sort_order == 'ASC' && intval(@$sort_array[$j][$key]) > intval(@$sort_array[$j + 1][$key]))) { + if (($sort_order == 'DESC' && (int)(@$sort_array[$j][$key]) < (int)(@$sort_array[$j + 1][$key])) || + ($sort_order == 'ASC' && (int)(@$sort_array[$j][$key]) > (int)(@$sort_array[$j + 1][$key]))) { $switch = true; } } else { diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 181604f7b..c386c1916 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -703,7 +703,7 @@ function bdecode_r($str, &$pos) return null; } else { $pos++; - return floatval(substr($str, $spos, $numlen)); + return (float)substr($str, $spos, $numlen); } } elseif ($str[$pos] == 'd') { $pos++; @@ -757,7 +757,7 @@ function bdecode_r($str, &$pos) if (($pos >= $strlen) || ($str[$pos] != ':')) { return null; } else { - $vallen = intval(substr($str, $spos, $numlen)); + $vallen = (int)substr($str, $spos, $numlen); $pos++; $val = substr($str, $pos, $vallen); From 22107054862932f87248643e7a203708252f0453 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 22:53:53 +0300 Subject: [PATCH 7/9] 'str(i)str(...)' could be replaced with 'str(i)pos(...)'. --- library/attach_mod/includes/functions_attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index 3080710c7..c4e86d0cb 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -410,7 +410,7 @@ function attachment_sync_topic($topics) */ function get_extension($filename) { - if (false === strstr($filename, '.')) { + if (false === strpos($filename, '.')) { return ''; } $extension = strrchr(strtolower($filename), '.'); From 72eb538a0a8bfbcb6c758d3ce37226d1d4c44f91 Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 23:02:09 +0300 Subject: [PATCH 8/9] Parameter could be declared as array. --- library/includes/functions_upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/includes/functions_upload.php b/library/includes/functions_upload.php index cebdaee8a..04c645152 100644 --- a/library/includes/functions_upload.php +++ b/library/includes/functions_upload.php @@ -59,7 +59,7 @@ class upload_common 8 => 'tiff', ); - public function init($cfg = array(), $post_params = array(), $uploaded_only = true) + public function init(array $cfg = [], array $post_params = [], $uploaded_only = true) { global $bb_cfg, $lang; From d40af070ae8a21513a931a7ae2036d8465210cdc Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Tue, 9 May 2017 23:05:30 +0300 Subject: [PATCH 9/9] Small for cycle bugfix. --- admin/admin_attachments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index d3e384bb0..a89fcca06 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -157,7 +157,7 @@ if ($search_imagick) { $paths = explode(' ', $retval); if (is_array($paths)) { - for ($i = 0; $iMax = count($paths); $i < $iMax; $i++) { + for ($i = 0, $iMax = count($paths); $i < $iMax; $i++) { $path = basename($paths[$i]); if ($path == 'convert') {