mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Unqualified function/constant reference and much more
Signed-off-by: Yuriy Pikhtarev <iglix@me.com>
This commit is contained in:
parent
b08f6e898b
commit
78af495048
68 changed files with 273 additions and 277 deletions
|
@ -47,7 +47,7 @@ switch ($mode) {
|
|||
$dir = $template->cachedir;
|
||||
$res = @opendir($dir);
|
||||
while (($file = readdir($res)) !== false) {
|
||||
if (substr($file, 0, $match_len) === $match) {
|
||||
if (0 === strpos($file, $match)) {
|
||||
@unlink($dir . $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');
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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']),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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>';
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -456,7 +456,7 @@ $bb_cfg['use_ajax_posts'] = true;
|
|||
$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx
|
||||
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
|
||||
$bb_cfg['sphinx_topic_titles_port'] = 3312;
|
||||
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf");
|
||||
$bb_cfg['sphinx_config_path'] = '../install/sphinx/sphinx.conf';
|
||||
$bb_cfg['disable_ft_search_in_posts'] = false; // disable searching in post bodies
|
||||
$bb_cfg['disable_search_for_guest'] = true;
|
||||
$bb_cfg['allow_search_in_bool_mode'] = true;
|
||||
|
|
|
@ -338,9 +338,7 @@ function extract_search_words($text)
|
|||
$text = preg_replace('/(\w*?)&#?[0-9a-z]+;(\w*?)/iu', '', $text);
|
||||
// Remove URL's ((www|ftp)\.[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]*?)
|
||||
$text = preg_replace('#\b[a-z0-9]+://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+(/[0-9a-z\?\.%_\-\+=&/]+)?#u', ' ', $text);
|
||||
$text = str_replace('[url=', ' ', $text);
|
||||
$text = str_replace('?', ' ', $text);
|
||||
$text = str_replace('!', ' ', $text);
|
||||
$text = str_replace(['[url=', '?', '!'], ' ', $text);
|
||||
|
||||
$text = strip_bbcode($text);
|
||||
|
||||
|
|
|
@ -587,9 +587,9 @@ function bt_show_ip($ip, $port = '')
|
|||
$ip = decode_ip($ip);
|
||||
$ip .= ($port) ? ":$port" : '';
|
||||
return $ip;
|
||||
} else {
|
||||
return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip);
|
||||
}
|
||||
|
||||
return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip);
|
||||
}
|
||||
|
||||
function bt_show_port($port)
|
||||
|
@ -598,9 +598,9 @@ function bt_show_port($port)
|
|||
|
||||
if (IS_AM) {
|
||||
return $port;
|
||||
} else {
|
||||
return ($bb_cfg['bt_show_port_only_moder']) ? false : $port;
|
||||
}
|
||||
|
||||
return ($bb_cfg['bt_show_port_only_moder']) ? false : $port;
|
||||
}
|
||||
|
||||
function decode_ip_xx($ip)
|
||||
|
@ -741,10 +741,10 @@ function get_username($user_id)
|
|||
$usernames[$row['user_id']] = $row['username'];
|
||||
}
|
||||
return $usernames;
|
||||
} else {
|
||||
$row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1");
|
||||
return $row['username'];
|
||||
}
|
||||
|
||||
$row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1");
|
||||
return $row['username'];
|
||||
}
|
||||
|
||||
function get_user_id($username)
|
||||
|
@ -846,9 +846,9 @@ function get_attachments_dir($cfg = null)
|
|||
|
||||
if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':')) {
|
||||
return $cfg['upload_dir'];
|
||||
} else {
|
||||
return BB_ROOT . $cfg['upload_dir'];
|
||||
}
|
||||
|
||||
return BB_ROOT . $cfg['upload_dir'];
|
||||
}
|
||||
|
||||
function bb_get_config($table, $from_db = false, $update_cache = true)
|
||||
|
@ -1453,9 +1453,9 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis
|
|||
|
||||
// build list
|
||||
if ($action == 'list') {
|
||||
for ($i = 0, $iMax = count($listrow['lang_key']); $i < $iMax; $i++) {
|
||||
foreach ($listrow['lang_key'] as $i => $iValue) {
|
||||
$selected = ($i == $selected_row) ? ' selected="selected"' : '';
|
||||
$l_value = $lang[$listrow['lang_key'][$i]] ?? $listrow['lang_key'][$i];
|
||||
$l_value = $lang[$listrow['lang_key'][$i]] ?? $iValue;
|
||||
$res .= '<option value="' . $i . '"' . $selected . '>' . $l_value . '</option>';
|
||||
}
|
||||
} else {
|
||||
|
@ -1543,7 +1543,7 @@ if (!function_exists('array_intersect_key')) {
|
|||
|
||||
// Check arrays
|
||||
$array_count = count($args);
|
||||
for ($i = 0; $i !== $array_count; $i++) {
|
||||
foreach ($args as $i => $iValue) {
|
||||
if (!is_array($args[$i])) {
|
||||
user_error('array_intersect_key() Argument #' .
|
||||
($i + 1) . ' is not an array', E_USER_WARNING);
|
||||
|
@ -1789,8 +1789,7 @@ function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
|
|||
if ($bb_cfg['search_engine_type'] == 'sphinx') {
|
||||
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
|
||||
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно)
|
||||
$text = str_replace('-', ' -', $text); // - только в начале слова
|
||||
$text = str_replace('*', '* ', $text); // * только в конце слова
|
||||
$text = str_replace(['-', '*'], [' -', '* '], $text); // только в начале / конце слова
|
||||
$text = preg_replace('#\s*\|\s*#u', '|', $text); // "| " -> "|"
|
||||
$text = preg_replace('#\|+#u', ' | ', $text); // "||" -> "|"
|
||||
$text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // одиночные " - ", " * "
|
||||
|
@ -1835,7 +1834,7 @@ function log_sphinx_error($err_type, $err_msg, $query = '')
|
|||
}
|
||||
}
|
||||
|
||||
function get_title_match_topics($title_match_sql, $forum_ids = [])
|
||||
function get_title_match_topics($title_match_sql, array $forum_ids = [])
|
||||
{
|
||||
global $bb_cfg, $sphinx, $userdata, $title_match, $lang;
|
||||
|
||||
|
@ -2011,10 +2010,6 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $size = true, $heig
|
|||
{
|
||||
global $bb_cfg;
|
||||
|
||||
if ($size) {
|
||||
// TODO размеры: s, m, l + кеширование
|
||||
}
|
||||
|
||||
$height = !$height ? 'height="' . $height . '"' : '';
|
||||
$width = !$width ? 'width="' . $width . '"' : '';
|
||||
|
||||
|
|
|
@ -331,14 +331,14 @@ foreach ($profile_fields as $field => $can_edit) {
|
|||
|
||||
$update_user_opt = array(
|
||||
# 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change
|
||||
'user_viewemail' => ($reg_mode) ? false : true,
|
||||
'user_viewonline' => ($reg_mode) ? false : true,
|
||||
'user_notify' => ($reg_mode) ? true : true,
|
||||
'user_notify_pm' => ($reg_mode) ? true : true,
|
||||
'user_porn_forums' => ($reg_mode) ? false : true,
|
||||
'user_dls' => ($reg_mode) ? false : true,
|
||||
'user_callseed' => ($reg_mode) ? true : true,
|
||||
'user_retracker' => ($reg_mode) ? true : true,
|
||||
'user_viewemail' => $reg_mode ? false : true,
|
||||
'user_viewonline' => $reg_mode ? false : true,
|
||||
'user_notify' => $reg_mode ? true : true,
|
||||
'user_notify_pm' => $reg_mode ? true : true,
|
||||
'user_porn_forums' => $reg_mode ? false : true,
|
||||
'user_dls' => $reg_mode ? false : true,
|
||||
'user_callseed' => $reg_mode ? true : true,
|
||||
'user_retracker' => $reg_mode ? true : true,
|
||||
);
|
||||
|
||||
foreach ($update_user_opt as $opt => $can_change_opt) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue