Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static code analyzer inspection, part 2 #230

Merged
merged 9 commits into from May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin/admin_attach_cp.php
Expand Up @@ -76,7 +76,7 @@
}

// Pagination ?
$do_pagination = ($view !== 'stats' && $view !== 'search') ? true : false;
$do_pagination = ($view !== 'stats' && $view !== 'search');

// Set Order
$order_by = '';
Expand Down Expand Up @@ -319,7 +319,7 @@
// 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 = '';

Expand Down
2 changes: 1 addition & 1 deletion admin/admin_attachments.php
Expand Up @@ -157,7 +157,7 @@
$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') {
Expand Down
16 changes: 8 additions & 8 deletions library/ajax/sitemap.php
Expand Up @@ -51,27 +51,27 @@
$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 .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://google.com/webmasters/sitemaps/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . '</a>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Google: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://google.com/webmasters/sitemaps/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://google.com/webmasters/sitemaps/ping?sitemap=' . $map_link . '</a>';
}

if (strpos($map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link), "OK") !== false) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://ping.blogs.yandex.ru/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://ping.blogs.yandex.ru/ping?sitemap=' . $map_link . '</a>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Yandex: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://ping.blogs.yandex.ru/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://ping.blogs.yandex.ru/ping?sitemap=' . $map_link . '</a>';
}

if ($map->send_url("http://www.bing.com/ping?sitemap=", $map_link)) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://www.bing.com/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://www.bing.com/ping?sitemap=' . $map_link . '</a>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Bing: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://www.bing.com/ping?sitemap=' . urlencode($map_link) . '" target="_blank">http://www.bing.com/ping?sitemap=' . $map_link . '</a>';
}

if (strpos($map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link), "Thanks for the ping") !== false) {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <font style="color: green;">' . $lang['SITEMAP_SENT'] . '</font>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <span style="color: green;">' . $lang['SITEMAP_SENT'] . '</span>';
} else {
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <font style="color: red;">' . $lang['SITEMAP_ERROR'] . '</font> URL: <a href="http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . urlencode($map_link) . '" target="_blank">http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . $map_link . '</a>';
$html .= '<br />' . $lang['SITEMAP_NOTIFY_SEARCH'] . ' Weblogs: <span style="color: red;">' . $lang['SITEMAP_ERROR'] . '</span> URL: <a href="http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . urlencode($map_link) . '" target="_blank">http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=' . $map_link . '</a>';
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion library/ajax/view_torrent.php
Expand Up @@ -89,7 +89,7 @@ public function get_filelist()
$filelist = $html->array2html($this->files_ary);
return "<div class=\"tor-root-dir\">{$this->root_dir}</div>$filelist";
} else {
return join('', $this->files_ary['/']);
return implode('', $this->files_ary['/']);
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/attach_mod/includes/functions_admin.php
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion library/attach_mod/includes/functions_attach.php
Expand Up @@ -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), '.');
Expand Down
14 changes: 7 additions & 7 deletions library/includes/bbcode.php
Expand Up @@ -220,7 +220,7 @@ function strip_quotes($text)
}
} while ($pos !== false);

if (sizeof($start_pos) == 0) {
if (count($start_pos) == 0) {
return $text;
}

Expand All @@ -235,7 +235,7 @@ function strip_quotes($text)
}
} while ($pos !== false);

if (sizeof($end_pos) == 0) {
if (count($end_pos) == 0) {
return $text;
}

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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");
Expand Down Expand Up @@ -543,7 +543,7 @@ public function bbcode2html($text)
$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);

Expand Down Expand Up @@ -623,7 +623,7 @@ private function spam_filter($text)
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);
Expand Down
2 changes: 1 addition & 1 deletion library/includes/cache/redis.php
Expand Up @@ -119,7 +119,7 @@ public function rm($name = '')

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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions library/includes/functions_torrent.php
Expand Up @@ -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++;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion library/includes/functions_upload.php
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion library/language/ru/main.php
Expand Up @@ -2422,7 +2422,7 @@

$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' => '&raquo; Выберите запуск',
'hourly' => 'ежечасно',
Expand Down