From c655fc89cf2df1b6315dab5cbd55eed67cfde634 Mon Sep 17 00:00:00 2001 From: Exile Date: Wed, 13 May 2015 03:53:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=B8=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/admin_mass_email.php | 4 +- callseed.php | 2 +- common.php | 4 +- install/upgrade/r496-user_birthday.php | 2 +- library/TorrentPier/Poll.php | 3 +- library/TorrentPier/Sessions.php | 5 ++- library/TorrentPier/Template.php | 44 ++++++++++--------- .../TorrentPier/Text/ReflectionTypeHint.php | 1 - library/TorrentPier/Upload.php | 4 +- library/TorrentPier/emailer.php | 15 ++++--- library/TorrentPier/sitemap.php | 3 ++ .../cron/jobs/prune_inactive_users.php | 4 +- library/includes/cron/jobs/tr_seed_bonus.php | 2 +- library/includes/datastore/build_stats.php | 10 ++--- library/includes/functions.php | 2 +- library/includes/functions_post.php | 2 +- library/includes/init_bb.php | 10 +---- memberlist.php | 2 +- 18 files changed, 65 insertions(+), 54 deletions(-) diff --git a/admin/admin_mass_email.php b/admin/admin_mass_email.php index 38230907e..a752bc913 100644 --- a/admin/admin_mass_email.php +++ b/admin/admin_mass_email.php @@ -40,7 +40,7 @@ if (isset($_POST['submit'])) AND ug.user_pending = 0 AND u.user_id = ug.user_id AND u.user_active = 1 - AND u.user_id NOT IN(". EXCLUDED_USERS_CSV . $user_id_sql .") + AND u.user_id NOT IN(". EXCLUDED_USERS . $user_id_sql .") "); } else @@ -49,7 +49,7 @@ if (isset($_POST['submit'])) SELECT username, user_email, user_lang FROM ". BB_USERS ." WHERE user_active = 1 - AND user_id NOT IN(". EXCLUDED_USERS_CSV . $user_id_sql .") + AND user_id NOT IN(". EXCLUDED_USERS . $user_id_sql .") "); } diff --git a/callseed.php b/callseed.php index dd7fec431..5ee29a021 100644 --- a/callseed.php +++ b/callseed.php @@ -40,7 +40,7 @@ $user_list = DB()->fetch_rowset(" LEFT JOIN ". BB_BT_TRACKER ." tr ON(tr.user_id = dl.user_id) WHERE dl.topic_id = $topic_id AND dl.user_status IN (". DL_STATUS_COMPLETE.", ". DL_STATUS_DOWN.") - AND dl.user_id NOT IN ({$userdata['user_id']}, ". EXCLUDED_USERS_CSV . $ban_user_id .") + AND dl.user_id NOT IN ({$userdata['user_id']}, ". EXCLUDED_USERS . $ban_user_id .") AND u.user_active = 1 GROUP BY dl.user_id "); diff --git a/common.php b/common.php index 004a38494..582506552 100644 --- a/common.php +++ b/common.php @@ -72,7 +72,9 @@ function DB ($db_alias = 'db1') return $DBS->get_db_obj($db_alias); } -// cache +/** + * Cache + */ require(INC_DIR . 'cache/common.php'); require(INC_DIR . 'datastore/common.php'); diff --git a/install/upgrade/r496-user_birthday.php b/install/upgrade/r496-user_birthday.php index 014284236..1d84435f9 100644 --- a/install/upgrade/r496-user_birthday.php +++ b/install/upgrade/r496-user_birthday.php @@ -14,7 +14,7 @@ if ($confirm) { DB()->query("ALTER TABLE ". BB_USERS ." CHANGE COLUMN user_birthday user_birthday_old int(11) NOT NULL DEFAULT 0 AFTER user_gender"); DB()->query("ALTER TABLE ". BB_USERS ." ADD user_birthday date NOT NULL DEFAULT '0000-00-00' AFTER user_gender"); - $sql = "SELECT user_id, user_birthday_old FROM ". BB_USERS ." WHERE user_birthday_old != 0 AND user_id NOT IN ('". EXCLUDED_USERS_CSV ."')"; + $sql = "SELECT user_id, user_birthday_old FROM ". BB_USERS ." WHERE user_birthday_old != 0 AND user_id NOT IN ('". EXCLUDED_USERS ."')"; foreach (DB()->fetch_rowset($sql) as $row) { diff --git a/library/TorrentPier/Poll.php b/library/TorrentPier/Poll.php index a2cadbd70..7f19c73be 100644 --- a/library/TorrentPier/Poll.php +++ b/library/TorrentPier/Poll.php @@ -14,6 +14,7 @@ class Poll * @type array */ private $_poll_votes = []; + /** * @type int */ @@ -105,4 +106,4 @@ class Poll DB()->query("DELETE FROM " . BB_POLL_USERS . " WHERE topic_id = $topic_id"); CACHE('bb_poll_data')->rm("poll_$topic_id"); } -} +} \ No newline at end of file diff --git a/library/TorrentPier/Sessions.php b/library/TorrentPier/Sessions.php index 4e2af1f81..66c1a5953 100644 --- a/library/TorrentPier/Sessions.php +++ b/library/TorrentPier/Sessions.php @@ -1,5 +1,8 @@ _tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value // If it's a root-level variable, it'll be like this: $this->vars[varname] == value or $this->_tpldata['.'][0][varname] == value // Array "vars" is added for easier access to data - var $_tpldata = array('.' => array(0 => array())); + var $_tpldata = ['.' => [0 => []]]; var $vars; // Hash of filenames for each template handle - var $files = array(); - var $files_cache = array(); // array of cache files that exists - var $files_cache2 = array(); // array of cache files (exists or not exists) + var $files = []; + var $files_cache = []; // array of cache files that exists + var $files_cache2 = []; // array of cache files (exists or not exists) // Root template directory var $root = ''; @@ -28,10 +32,10 @@ class Template var $tpldef = 'default'; // This will hash handle names to the compiled code for that handle - var $compiled_code = array(); + var $compiled_code = []; // This will hold the uncompiled code for that handle. - var $uncompiled_code = array(); + var $uncompiled_code = []; // Cache settings var $use_cache = 1; @@ -45,7 +49,7 @@ class Template var $cur_tpl = ''; // List of replacements (tpl files in this list will be replaced with other tpl files) - var $replace = array(); + var $replace = []; // Counter for include var $include_count = 0; @@ -61,7 +65,7 @@ class Template var $preparse = ''; var $postparse = ''; - var $lang = array(); + var $lang = []; /** * Constructor. Installs XS mod on first run or updates it and sets the root dir. @@ -86,7 +90,7 @@ class Template */ function destroy() { - $this->_tpldata = array('.' => array(0 => array())); + $this->_tpldata = ['.' => [0 => []]]; $this->vars = &$this->_tpldata['.'][0]; $this->xs_started = 0; } @@ -444,8 +448,8 @@ class Template } // Replace tags - $search = array('', ''); - $replace = array('<' . '?php ', ' ?' . '>'); + $search = ['', '']; + $replace = ['<' . '?php ', ' ?' . '>']; $code = str_replace($search, $replace, $code); // Break it up into lines and put " -->" back @@ -456,19 +460,19 @@ class Template } $block_nesting_level = 0; - $block_names = array(); + $block_names = []; $block_names[0] = "."; - $block_items = array(); + $block_items = []; $count_if = 0; // Prepare array for compiled code - $compiled = array(); + $compiled = []; // Array of switches - $sw = array(); + $sw = []; // Replace all short php tags - $new_code = array(); + $new_code = []; $line_count = count($code_lines); for ($i = 0; $i < $line_count; $i++) { $line = $code_lines[$i]; @@ -729,11 +733,11 @@ class Template return $code; } // Change template varrefs into PHP varrefs. This one will handle varrefs WITH namespaces - $varrefs = array(); + $varrefs = []; preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs); $varcount = sizeof($varrefs[1]); - $search = array(); - $replace = array(); + $search = []; + $replace = []; for ($i = 0; $i < $varcount; $i++) { $namespace = $varrefs[1][$i]; $varname = $varrefs[3][$i]; @@ -766,7 +770,7 @@ class Template $tokens = $match[0]; $tokens_cnt = count($tokens); - $is_arg_stack = array(); + $is_arg_stack = []; for ($i = 0; $i < $tokens_cnt; $i++) { $token = &$tokens[$i]; diff --git a/library/TorrentPier/Text/ReflectionTypeHint.php b/library/TorrentPier/Text/ReflectionTypeHint.php index 021aa5ffb..c66f2f8ea 100644 --- a/library/TorrentPier/Text/ReflectionTypeHint.php +++ b/library/TorrentPier/Text/ReflectionTypeHint.php @@ -1,6 +1,5 @@ vars = array( + $this->vars = [ 'BOARD_EMAIL' => $bb_cfg['board_email'], 'SITENAME' => $bb_cfg['board_email_sitename'], 'EMAIL_SIG' => !empty($bb_cfg['board_email_sig']) ? "-- \n{$bb_cfg['board_email_sig']}" : '', - ); + ]; } // Resets all the data (address, template file, etc etc to default function reset () { - $this->addresses = array(); + $this->addresses = []; $this->msg = $this->extra_headers = ''; $this->set_default_vars(); } @@ -163,7 +166,7 @@ class emailer // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable $drop_header = ''; - $match = array(); + $match = []; if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) { $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject'); diff --git a/library/TorrentPier/sitemap.php b/library/TorrentPier/sitemap.php index 942f11b73..37686755f 100644 --- a/library/TorrentPier/sitemap.php +++ b/library/TorrentPier/sitemap.php @@ -2,6 +2,9 @@ // @todo переписать +/** + * Class sitemap + */ class sitemap { var $home = ''; diff --git a/library/includes/cron/jobs/prune_inactive_users.php b/library/includes/cron/jobs/prune_inactive_users.php index a170d8168..7ca8f8510 100644 --- a/library/includes/cron/jobs/prune_inactive_users.php +++ b/library/includes/cron/jobs/prune_inactive_users.php @@ -19,7 +19,7 @@ while (true) AND user_lastvisit = 0 AND user_session_time = 0 AND user_regdate <= ". (TIMENOW - 86400 * $not_activated_days) ." - AND user_id NOT IN(". EXCLUDED_USERS_CSV .") + AND user_id NOT IN(". EXCLUDED_USERS .") LIMIT $users_per_cycle"); foreach ($sql as $row) @@ -34,7 +34,7 @@ while (true) WHERE user_level = 0 AND user_posts = 0 AND user_lastvisit <= ". (TIMENOW - 86400 * $not_active_days) ." - AND user_id NOT IN(". EXCLUDED_USERS_CSV .") + AND user_id NOT IN(". EXCLUDED_USERS .") LIMIT $users_per_cycle"); foreach ($sql as $row) diff --git a/library/includes/cron/jobs/tr_seed_bonus.php b/library/includes/cron/jobs/tr_seed_bonus.php index 3cc379c26..862adca9c 100644 --- a/library/includes/cron/jobs/tr_seed_bonus.php +++ b/library/includes/cron/jobs/tr_seed_bonus.php @@ -47,7 +47,7 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se AND b.release_count <= $release AND u.user_regdate < $user_regdate AND u.user_active = 1 - AND u.user_id not IN(". EXCLUDED_USERS_CSV .") + AND u.user_id not IN(". EXCLUDED_USERS .") "); } diff --git a/library/includes/datastore/build_stats.php b/library/includes/datastore/build_stats.php index 30d3cc851..e5e7a69c5 100644 --- a/library/includes/datastore/build_stats.php +++ b/library/includes/datastore/build_stats.php @@ -7,7 +7,7 @@ global $bb_cfg; $data = array(); // usercount -$row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .")"); +$row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS .")"); $data['usercount'] = number_format($row['usercount']); // newestuser @@ -38,9 +38,9 @@ if ($bb_cfg['tor_stats']) // gender stat if ($bb_cfg['gender']) { - $male = DB()->fetch_row("SELECT COUNT(user_id) AS male FROM ". BB_USERS ." WHERE user_gender = ". MALE ." AND user_id NOT IN(". EXCLUDED_USERS_CSV .")"); - $female = DB()->fetch_row("SELECT COUNT(user_id) AS female FROM ". BB_USERS ." WHERE user_gender = ". FEMALE ." AND user_id NOT IN(". EXCLUDED_USERS_CSV .")"); - $unselect = DB()->fetch_row("SELECT COUNT(user_id) AS unselect FROM ". BB_USERS ." WHERE user_gender = 0 AND user_id NOT IN(". EXCLUDED_USERS_CSV .")"); + $male = DB()->fetch_row("SELECT COUNT(user_id) AS male FROM ". BB_USERS ." WHERE user_gender = ". MALE ." AND user_id NOT IN(". EXCLUDED_USERS .")"); + $female = DB()->fetch_row("SELECT COUNT(user_id) AS female FROM ". BB_USERS ." WHERE user_gender = ". FEMALE ." AND user_id NOT IN(". EXCLUDED_USERS .")"); + $unselect = DB()->fetch_row("SELECT COUNT(user_id) AS unselect FROM ". BB_USERS ." WHERE user_gender = 0 AND user_id NOT IN(". EXCLUDED_USERS .")"); $data['male'] = $male['male']; $data['female'] = $female['female']; @@ -52,7 +52,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) { $sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday FROM ". BB_USERS ." - WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") + WHERE user_id NOT IN(". EXCLUDED_USERS .") AND user_birthday != '0000-00-00' AND user_active = 1 ORDER BY user_level DESC, username diff --git a/library/includes/functions.php b/library/includes/functions.php index ac819b389..92a2c9bf1 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2683,4 +2683,4 @@ function delete_user_sessions ($user_id) $user_id = get_id_csv($user_id); DB()->query("DELETE FROM ". BB_SESSIONS ." WHERE session_user_id IN($user_id)"); -} +} \ No newline at end of file diff --git a/library/includes/functions_post.php b/library/includes/functions_post.php index ded560045..6094d0927 100644 --- a/library/includes/functions_post.php +++ b/library/includes/functions_post.php @@ -358,7 +358,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi $watch_list = DB()->fetch_rowset("SELECT u.username, u.user_id, u.user_email, u.user_lang FROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u WHERE tw.topic_id = $topic_id - AND tw.user_id NOT IN (". $userdata['user_id'] .", ". EXCLUDED_USERS_CSV . $user_id_sql .") + AND tw.user_id NOT IN (". $userdata['user_id'] .", ". EXCLUDED_USERS . $user_id_sql .") AND tw.notify_status = ". TOPIC_WATCH_NOTIFIED ." AND u.user_id = tw.user_id AND u.user_active = 1 diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 5b50cda80..e53fb32d3 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -86,12 +86,7 @@ define('ADMIN', 1); define('MOD', 2); define('GROUP_MEMBER', 20); define('CP_HOLDER', 25); - -$excluded_users = [ - GUEST_UID, - BOT_UID, -]; -define('EXCLUDED_USERS_CSV', implode(',', $excluded_users)); +define('EXCLUDED_USERS', implode(',', [GUEST_UID, BOT_UID])); // User related define('USER_ACTIVATION_NONE', 0); @@ -351,7 +346,6 @@ define('XS_TAG_ELSEIF', 7); define('XS_TAG_ENDIF', 8); define('XS_TAG_BEGINELSE', 11); - if (!empty($banned_user_agents)) { foreach ($banned_user_agents as $agent) @@ -448,7 +442,7 @@ $datastore->enqueue(['cat_forums']); if (!$bb_cfg['board_startdate']) { bb_update_config(['board_startdate' => TIMENOW]); - DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id IN(2, ". EXCLUDED_USERS_CSV .")"); + DB()->query("UPDATE ". BB_USERS ." SET user_regdate = ". TIMENOW ." WHERE user_id IN(2, ". EXCLUDED_USERS .")"); } // Cron diff --git a/memberlist.php b/memberlist.php index 84eb16b9a..768f56d14 100644 --- a/memberlist.php +++ b/memberlist.php @@ -151,7 +151,7 @@ $template->assign_vars(array( )); // per-letter selection end -$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .")"; +$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS .")"; if ( $username ) { $username = preg_replace('/\*/', '%', clean_username($username));