Unqualified function/constant reference and much more

Signed-off-by: Yuriy Pikhtarev <iglix@me.com>
This commit is contained in:
Yuriy Pikhtarev 2018-06-24 16:35:13 +03:00
commit 78af495048
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
68 changed files with 273 additions and 277 deletions

View file

@ -31,11 +31,11 @@ function attach_mod_get_lang($language_file)
$file = LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/' . $language_file . '.php';
if (file_exists($file)) {
return $bb_cfg['default_lang'];
} else {
$file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php';
if (file_exists($file)) {
return $attach_config['board_lang'];
}
}
$file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php';
if (file_exists($file)) {
return $attach_config['board_lang'];
}
bb_die('Attachment mod language file does not exist: language/' . $attach_config['board_lang'] . '/' . $language_file . '.php');

View file

@ -25,7 +25,7 @@ function init_complete_extensions_data()
global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
if (!$extension_informations = get_extension_informations()) {
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations()
$GLOBALS['datastore']->update('attach_extensions');
$extension_informations = get_extension_informations();
}
$allowed_extensions = array();

View file

@ -174,7 +174,7 @@ if ($tor_reged && $tor_info) {
$dl_allowed = ($user_ratio > $min_ratio_dl);
}
if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) {
if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) {
$template->assign_vars(array(
'SHOW_RATIO_WARN' => true,
'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']),

View file

@ -101,7 +101,7 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
for ($i = 0; $i < $last_element; $i++) {
$num_iterations = $last_element - $i;
for ($j = 0; $j < $num_iterations; $j++) {
foreach ($sort_array as $j => $jValue) {
// do checks based on key
$switch = false;
if (!$string_sort) {
@ -117,7 +117,7 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
}
if ($switch) {
$temp = $sort_array[$j];
$temp = $jValue;
$sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp;
}

View file

@ -87,7 +87,7 @@ function auth_pack($auth_array)
$one_char = $two_char = false;
$auth_cache = '';
for ($i = 0, $iMax = count($auth_array); $i < $iMax; $i++) {
foreach ($auth_array as $i => $iValue) {
$val = base64_pack((int)$auth_array[$i]);
if (strlen($val) == 1 && !$one_char) {
$auth_cache .= $one_char_encoding;
@ -114,7 +114,7 @@ function auth_unpack($auth_cache)
$auth = [];
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) {
$forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
@ -149,7 +149,7 @@ function is_forum_authed($auth_cache, $check_forum_id)
$auth = [];
$auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) {
for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) {
$forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) {
$auth_len = 1;
@ -266,7 +266,7 @@ function get_attachments_from_post($post_id_array)
$post_id_array[] = $post_id;
}
$post_id_array = implode(', ', array_map('intval', $post_id_array));
$post_id_array = implode(', ', array_map('\intval', $post_id_array));
if ($post_id_array == '') {
return $attachments;
@ -304,7 +304,7 @@ function get_total_attach_filesize($attach_ids)
return 0;
}
$attach_ids = implode(', ', array_map('intval', $attach_ids));
$attach_ids = implode(', ', array_map('\intval', $attach_ids));
if (!$attach_ids) {
return 0;
@ -412,7 +412,7 @@ function get_extension($filename)
*/
function delete_extension($filename)
{
return substr($filename, 0, strrpos(strtolower(trim($filename)), '.'));
return substr($filename, 0, strripos(trim($filename), '.'));
}
/**
@ -535,7 +535,7 @@ function attach_mod_sql_escape($text)
return DB()->escape_string($text);
}
return str_replace("'", "''", str_replace('\\', '\\\\', $text));
return str_replace(['\\', "'"], ['\\\\', "''"], $text);
}
/**

View file

@ -27,7 +27,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (!is_array($attach_id_array)) {
if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
} elseif (false !== strpos($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = (int)$attach_id_array;
@ -68,7 +68,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (false !== strpos($post_id_array, ', ')) {
$post_id_array = explode(', ', $post_id_array);
} elseif (strstr($post_id_array, ',')) {
} elseif (false !== strpos($post_id_array, ',')) {
$post_id_array = explode(',', $post_id_array);
} else {
$post_id = (int)$post_id_array;
@ -113,7 +113,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (!is_array($attach_id_array)) {
if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) {
} elseif (false !== strpos($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = (int)$attach_id_array;
@ -171,7 +171,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
//bt end
for ($i = 0, $iMax = count($attach_id_array); $i < $iMax; $i++) {
foreach ($attach_id_array as $i => $iValue) {
$sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . '
WHERE attach_id = ' . (int)$attach_id_array[$i];

View file

@ -188,7 +188,7 @@ function quota_limit_select($select_name, $default_quota = 0)
}
DB()->sql_freeresult($result);
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) {
foreach ($quota_name as $i => $iValue) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}
@ -219,7 +219,7 @@ function default_quota_limit_select($select_name, $default_quota = 0)
}
DB()->sql_freeresult($result);
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) {
foreach ($quota_name as $i => $iValue) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
}

View file

@ -26,12 +26,12 @@ function get_img_size_format($width, $height)
round($width * ($max_width / $width)),
round($height * ($max_width / $width))
);
} else {
return array(
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
);
}
return array(
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
);
}
/**
@ -44,9 +44,9 @@ function is_imagick()
if ($attach_config['img_imagick'] != '') {
$imagick = $attach_config['img_imagick'];
return true;
} else {
return false;
}
return false;
}
/**
@ -111,8 +111,6 @@ function create_thumbnail($source, $new_file, $mimetype)
[$new_width, $new_height] = get_img_size_format($width, $height);
$tmp_path = $old_file = '';
$used_imagick = false;
if (is_imagick()) {