Стилистика

This commit is contained in:
Exile 2015-05-13 03:53:41 +03:00
commit c655fc89cf
18 changed files with 65 additions and 54 deletions

View file

@ -40,7 +40,7 @@ if (isset($_POST['submit']))
AND ug.user_pending = 0 AND ug.user_pending = 0
AND u.user_id = ug.user_id AND u.user_id = ug.user_id
AND u.user_active = 1 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 else
@ -49,7 +49,7 @@ if (isset($_POST['submit']))
SELECT username, user_email, user_lang SELECT username, user_email, user_lang
FROM ". BB_USERS ." FROM ". BB_USERS ."
WHERE user_active = 1 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 .")
"); ");
} }

View file

@ -40,7 +40,7 @@ $user_list = DB()->fetch_rowset("
LEFT JOIN ". BB_BT_TRACKER ." tr ON(tr.user_id = dl.user_id) LEFT JOIN ". BB_BT_TRACKER ." tr ON(tr.user_id = dl.user_id)
WHERE dl.topic_id = $topic_id WHERE dl.topic_id = $topic_id
AND dl.user_status IN (". DL_STATUS_COMPLETE.", ". DL_STATUS_DOWN.") 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 AND u.user_active = 1
GROUP BY dl.user_id GROUP BY dl.user_id
"); ");

View file

@ -72,7 +72,9 @@ function DB ($db_alias = 'db1')
return $DBS->get_db_obj($db_alias); return $DBS->get_db_obj($db_alias);
} }
// cache /**
* Cache
*/
require(INC_DIR . 'cache/common.php'); require(INC_DIR . 'cache/common.php');
require(INC_DIR . 'datastore/common.php'); require(INC_DIR . 'datastore/common.php');

View file

@ -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 ." 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"); 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) foreach (DB()->fetch_rowset($sql) as $row)
{ {

View file

@ -14,6 +14,7 @@ class Poll
* @type array * @type array
*/ */
private $_poll_votes = []; private $_poll_votes = [];
/** /**
* @type int * @type int
*/ */

View file

@ -1,5 +1,8 @@
<?php <?php
/**
* Class Sessions
*/
class Sessions class Sessions
{ {
/** /**

View file

@ -1,19 +1,23 @@
<?php <?php
// @todo заменить на Smarty или подобное
/**
* Class Template
*/
class Template class Template
{ {
// Variable that holds all the data we'll be substituting into the compiled templates // Variable that holds all the data we'll be substituting into the compiled templates
// This will end up being a multi-dimensional array like this: $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value // This will end up being a multi-dimensional array like this: $this->_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 // 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 // Array "vars" is added for easier access to data
var $_tpldata = array('.' => array(0 => array())); var $_tpldata = ['.' => [0 => []]];
var $vars; var $vars;
// Hash of filenames for each template handle // Hash of filenames for each template handle
var $files = array(); var $files = [];
var $files_cache = array(); // array of cache files that exists var $files_cache = []; // array of cache files that exists
var $files_cache2 = array(); // array of cache files (exists or not exists) var $files_cache2 = []; // array of cache files (exists or not exists)
// Root template directory // Root template directory
var $root = ''; var $root = '';
@ -28,10 +32,10 @@ class Template
var $tpldef = 'default'; var $tpldef = 'default';
// This will hash handle names to the compiled code for that handle // 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. // This will hold the uncompiled code for that handle.
var $uncompiled_code = array(); var $uncompiled_code = [];
// Cache settings // Cache settings
var $use_cache = 1; var $use_cache = 1;
@ -45,7 +49,7 @@ class Template
var $cur_tpl = ''; var $cur_tpl = '';
// List of replacements (tpl files in this list will be replaced with other tpl files) // List of replacements (tpl files in this list will be replaced with other tpl files)
var $replace = array(); var $replace = [];
// Counter for include // Counter for include
var $include_count = 0; var $include_count = 0;
@ -61,7 +65,7 @@ class Template
var $preparse = ''; var $preparse = '';
var $postparse = ''; var $postparse = '';
var $lang = array(); var $lang = [];
/** /**
* Constructor. Installs XS mod on first run or updates it and sets the root dir. * Constructor. Installs XS mod on first run or updates it and sets the root dir.
@ -86,7 +90,7 @@ class Template
*/ */
function destroy() function destroy()
{ {
$this->_tpldata = array('.' => array(0 => array())); $this->_tpldata = ['.' => [0 => []]];
$this->vars = &$this->_tpldata['.'][0]; $this->vars = &$this->_tpldata['.'][0];
$this->xs_started = 0; $this->xs_started = 0;
} }
@ -444,8 +448,8 @@ class Template
} }
// Replace <!-- (END)PHP --> tags // Replace <!-- (END)PHP --> tags
$search = array('<!-- PHP -->', '<!-- ENDPHP -->'); $search = ['<!-- PHP -->', '<!-- ENDPHP -->'];
$replace = array('<' . '?php ', ' ?' . '>'); $replace = ['<' . '?php ', ' ?' . '>'];
$code = str_replace($search, $replace, $code); $code = str_replace($search, $replace, $code);
// Break it up into lines and put " -->" back // Break it up into lines and put " -->" back
@ -456,19 +460,19 @@ class Template
} }
$block_nesting_level = 0; $block_nesting_level = 0;
$block_names = array(); $block_names = [];
$block_names[0] = "."; $block_names[0] = ".";
$block_items = array(); $block_items = [];
$count_if = 0; $count_if = 0;
// Prepare array for compiled code // Prepare array for compiled code
$compiled = array(); $compiled = [];
// Array of switches // Array of switches
$sw = array(); $sw = [];
// Replace all short php tags // Replace all short php tags
$new_code = array(); $new_code = [];
$line_count = count($code_lines); $line_count = count($code_lines);
for ($i = 0; $i < $line_count; $i++) { for ($i = 0; $i < $line_count; $i++) {
$line = $code_lines[$i]; $line = $code_lines[$i];
@ -729,11 +733,11 @@ class Template
return $code; return $code;
} }
// Change template varrefs into PHP varrefs. This one will handle varrefs WITH namespaces // 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); preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
$varcount = sizeof($varrefs[1]); $varcount = sizeof($varrefs[1]);
$search = array(); $search = [];
$replace = array(); $replace = [];
for ($i = 0; $i < $varcount; $i++) { for ($i = 0; $i < $varcount; $i++) {
$namespace = $varrefs[1][$i]; $namespace = $varrefs[1][$i];
$varname = $varrefs[3][$i]; $varname = $varrefs[3][$i];
@ -766,7 +770,7 @@ class Template
$tokens = $match[0]; $tokens = $match[0];
$tokens_cnt = count($tokens); $tokens_cnt = count($tokens);
$is_arg_stack = array(); $is_arg_stack = [];
for ($i = 0; $i < $tokens_cnt; $i++) { for ($i = 0; $i < $tokens_cnt; $i++) {
$token = &$tokens[$i]; $token = &$tokens[$i];

View file

@ -1,6 +1,5 @@
<?php <?php
/** /**
* A class for validating method parameters to allowed types via reflection. * A class for validating method parameters to allowed types via reflection.
* *

View file

@ -1,6 +1,8 @@
<?php <?php
/**
* Class Upload
*/
class Upload class Upload
{ {
/** /**

View file

@ -2,14 +2,17 @@
// @todo переписать // @todo переписать
/**
* Class emailer
*/
class emailer class emailer
{ {
var $msg, $subject, $extra_headers; var $msg, $subject, $extra_headers;
var $addresses, $reply_to, $from; var $addresses, $reply_to, $from;
var $use_smtp; var $use_smtp;
var $tpl_msg = array(); var $tpl_msg = [];
var $vars = array(); var $vars = [];
function emailer ($use_smtp/*$tpl_name, $sbj, $to_address*/) function emailer ($use_smtp/*$tpl_name, $sbj, $to_address*/)
{ {
@ -29,17 +32,17 @@ class emailer
{ {
global $bb_cfg; global $bb_cfg;
$this->vars = array( $this->vars = [
'BOARD_EMAIL' => $bb_cfg['board_email'], 'BOARD_EMAIL' => $bb_cfg['board_email'],
'SITENAME' => $bb_cfg['board_email_sitename'], 'SITENAME' => $bb_cfg['board_email_sitename'],
'EMAIL_SIG' => !empty($bb_cfg['board_email_sig']) ? "-- \n{$bb_cfg['board_email_sig']}" : '', '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 // Resets all the data (address, template file, etc etc to default
function reset () function reset ()
{ {
$this->addresses = array(); $this->addresses = [];
$this->msg = $this->extra_headers = ''; $this->msg = $this->extra_headers = '';
$this->set_default_vars(); $this->set_default_vars();
} }
@ -163,7 +166,7 @@ class emailer
// We now try and pull a subject from the email body ... if it exists, // We now try and pull a subject from the email body ... if it exists,
// do this here because the subject may contain a variable // do this here because the subject may contain a variable
$drop_header = ''; $drop_header = '';
$match = array(); $match = [];
if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
{ {
$this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject'); $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject');

View file

@ -2,6 +2,9 @@
// @todo переписать // @todo переписать
/**
* Class sitemap
*/
class sitemap class sitemap
{ {
var $home = ''; var $home = '';

View file

@ -19,7 +19,7 @@ while (true)
AND user_lastvisit = 0 AND user_lastvisit = 0
AND user_session_time = 0 AND user_session_time = 0
AND user_regdate <= ". (TIMENOW - 86400 * $not_activated_days) ." 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"); LIMIT $users_per_cycle");
foreach ($sql as $row) foreach ($sql as $row)
@ -34,7 +34,7 @@ while (true)
WHERE user_level = 0 WHERE user_level = 0
AND user_posts = 0 AND user_posts = 0
AND user_lastvisit <= ". (TIMENOW - 86400 * $not_active_days) ." 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"); LIMIT $users_per_cycle");
foreach ($sql as $row) foreach ($sql as $row)

View file

@ -47,7 +47,7 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se
AND b.release_count <= $release AND b.release_count <= $release
AND u.user_regdate < $user_regdate AND u.user_regdate < $user_regdate
AND u.user_active = 1 AND u.user_active = 1
AND u.user_id not IN(". EXCLUDED_USERS_CSV .") AND u.user_id not IN(". EXCLUDED_USERS .")
"); ");
} }

View file

@ -7,7 +7,7 @@ global $bb_cfg;
$data = array(); $data = array();
// usercount // 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']); $data['usercount'] = number_format($row['usercount']);
// newestuser // newestuser
@ -38,9 +38,9 @@ if ($bb_cfg['tor_stats'])
// gender stat // gender stat
if ($bb_cfg['gender']) 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 .")"); $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_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 .")");
$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 .")"); $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['male'] = $male['male'];
$data['female'] = $female['female']; $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 $sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday
FROM ". BB_USERS ." 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_birthday != '0000-00-00'
AND user_active = 1 AND user_active = 1
ORDER BY user_level DESC, username ORDER BY user_level DESC, username

View file

@ -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 $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 FROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u
WHERE tw.topic_id = $topic_id 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 tw.notify_status = ". TOPIC_WATCH_NOTIFIED ."
AND u.user_id = tw.user_id AND u.user_id = tw.user_id
AND u.user_active = 1 AND u.user_active = 1

View file

@ -86,12 +86,7 @@ define('ADMIN', 1);
define('MOD', 2); define('MOD', 2);
define('GROUP_MEMBER', 20); define('GROUP_MEMBER', 20);
define('CP_HOLDER', 25); define('CP_HOLDER', 25);
define('EXCLUDED_USERS', implode(',', [GUEST_UID, BOT_UID]));
$excluded_users = [
GUEST_UID,
BOT_UID,
];
define('EXCLUDED_USERS_CSV', implode(',', $excluded_users));
// User related // User related
define('USER_ACTIVATION_NONE', 0); define('USER_ACTIVATION_NONE', 0);
@ -351,7 +346,6 @@ define('XS_TAG_ELSEIF', 7);
define('XS_TAG_ENDIF', 8); define('XS_TAG_ENDIF', 8);
define('XS_TAG_BEGINELSE', 11); define('XS_TAG_BEGINELSE', 11);
if (!empty($banned_user_agents)) if (!empty($banned_user_agents))
{ {
foreach ($banned_user_agents as $agent) foreach ($banned_user_agents as $agent)
@ -448,7 +442,7 @@ $datastore->enqueue(['cat_forums']);
if (!$bb_cfg['board_startdate']) if (!$bb_cfg['board_startdate'])
{ {
bb_update_config(['board_startdate' => TIMENOW]); 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 // Cron

View file

@ -151,7 +151,7 @@ $template->assign_vars(array(
)); ));
// per-letter selection end // 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 ) if ( $username )
{ {
$username = preg_replace('/\*/', '%', clean_username($username)); $username = preg_replace('/\*/', '%', clean_username($username));