Minor improvements (#882)

* Minor improvements

* Updated

* Updated

* Updated

* Update privmsg.php

* Updated

* Update admin_attach_cp.php
This commit is contained in:
Roman Kelesidis 2023-09-04 01:01:01 +07:00 committed by GitHub
commit 4b453de64a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
75 changed files with 699 additions and 735 deletions

View file

@ -56,7 +56,7 @@ if ($view === 'username') {
$sort_order = 'DESC';
} else {
$view = 'stats';
$mode_types_text = array();
$mode_types_text = [];
$sort_order = 'ASC';
}
@ -148,7 +148,7 @@ $delete_id_list = get_var('delete_id_list', array(0));
$confirm = isset($_POST['confirm']);
if ($confirm && count($delete_id_list) > 0) {
$attachments = array();
$attachments = [];
delete_attachment(0, $delete_id_list);
} elseif ($delete && count($delete_id_list) > 0) {
@ -181,7 +181,7 @@ if ($submit_change && $view === 'attachments') {
$attach_download_count_list = get_var('attach_count_list', array(0));
// Generate correct Change List
$attachments = array();
$attachments = [];
for ($i = 0, $iMax = count($attach_change_list); $i < $iMax; $i++) {
$attachments['_' . $attach_change_list[$i]]['comment'] = $attach_comment_list[$i];
@ -330,7 +330,7 @@ if ($view === 'attachments') {
$s_hidden = '<input type="hidden" name="u_id" value="' . (int)$uid . '" />';
$template->assign_block_vars('switch_user_based', array());
$template->assign_block_vars('switch_user_based', []);
$template->assign_vars(array(
'S_USER_HIDDEN' => $s_hidden,
@ -356,7 +356,7 @@ if ($view === 'attachments') {
$total_rows = $num_attach_ids;
$attach_id = array();
$attach_id = [];
for ($j = 0; $j < $num_attach_ids; $j++) {
$attach_id[] = (int)$attach_ids[$j]['attach_id'];
@ -427,7 +427,7 @@ if ($view === 'attachments') {
$post_title = str_short($post_title, 30);
}
$view_topic = BB_ROOT . 'viewtopic.php?' . POST_POST_URL . '=' . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id'];
$view_topic = BB_ROOT . POST_URL . $ids[$j]['post_id'] . '#' . $ids[$j]['post_id'];
$post_titles[] = '<a href="' . $view_topic . '" class="gen" target="_blank">' . $post_title . '</a>';
} else {

View file

@ -171,7 +171,7 @@ if ($search_imagick) {
// Check Settings
if ($check_upload) {
// Some tests...
$attach_config = array();
$attach_config = [];
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
@ -266,7 +266,7 @@ if ($mode == 'cats') {
$sql = 'SELECT group_name, cat_id FROM ' . BB_EXTENSION_GROUPS . ' WHERE cat_id > 0 ORDER BY cat_id';
$s_assigned_group_images = array();
$s_assigned_group_images = [];
if (!($result = DB()->sql_query($sql))) {
bb_die('Could not get group names from ' . BB_EXTENSION_GROUPS);
@ -294,7 +294,7 @@ if ($mode == 'cats') {
if (!is_imagick() && !@extension_loaded('gd')) {
$new_attach['img_create_thumbnail'] = '0';
} else {
$template->assign_block_vars('switch_thumbnail_support', array());
$template->assign_block_vars('switch_thumbnail_support', []);
}
$template->assign_vars(array(
@ -319,7 +319,7 @@ if ($mode == 'cats') {
// Check Cat Settings
if ($check_image_cat) {
// Some tests...
$attach_config = array();
$attach_config = [];
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
@ -386,7 +386,7 @@ if ($submit && $mode == 'quota') {
$filesize_list = get_var('max_filesize_list', array(0));
$size_select_list = get_var('size_select_list', array(''));
$allowed_list = array();
$allowed_list = [];
for ($i = 0, $iMax = count($quota_change_list); $i < $iMax; $i++) {
$filesize_list[$i] = ($size_select_list[$i] == 'kb') ? round($filesize_list[$i] * 1024) : (($size_select_list[$i] == 'mb') ? round($filesize_list[$i] * 1048576) : $filesize_list[$i]);
@ -519,7 +519,7 @@ if ($mode == 'quota' && $e_mode == 'view_quota') {
bb_die('Invalid call');
}
$template->assign_block_vars('switch_quota_limit_desc', array());
$template->assign_block_vars('switch_quota_limit_desc', []);
$sql = 'SELECT * FROM ' . BB_QUOTA_LIMITS . ' WHERE quota_limit_id = ' . (int)$quota_id . ' LIMIT 1';

View file

@ -148,7 +148,7 @@ switch ($mode) {
$run_day[$i] = $i;
}
$schedule = array();
$schedule = [];
foreach ($lang['SCHEDULE'] as $type => $key) {
$schedule[$key] = $type;
}

View file

@ -48,7 +48,7 @@ $delete_forum = isset($_POST['del_forum']);
$submit = isset($_POST['submit']);
// Get Attachment Config
$attach_config = array();
$attach_config = [];
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
@ -69,7 +69,7 @@ if ($submit && $mode == 'extensions') {
$group_select_list = get_var('group_select', array(0));
// Generate correct Change List
$extensions = array();
$extensions = [];
for ($i = 0, $iMax = count($extension_change_list); $i < $iMax; $i++) {
$extensions['_' . $extension_change_list[$i]]['comment'] = $extension_explain_list[$i];
@ -236,7 +236,7 @@ if ($submit && $mode == 'groups') {
$filesize_list = get_var('max_filesize_list', array(0));
$size_select_list = get_var('size_select_list', array(''));
$allowed_list = array();
$allowed_list = [];
foreach ($group_allowed_list as $iValue) {
for ($j = 0, $jMax = count($group_change_list); $j < $jMax; $j++) {
@ -485,7 +485,7 @@ if ($add_forum && $e_mode == 'perm' && $group) {
DB()->sql_freeresult($result);
if (trim($row['forum_permissions']) == '') {
$auth_p = array();
$auth_p = [];
} else {
$auth_p = auth_unpack($row['forum_permissions']);
}
@ -525,7 +525,7 @@ if ($delete_forum && $e_mode == 'perm' && $group) {
DB()->sql_freeresult($result);
$auth_p2 = auth_unpack(trim($row['forum_permissions']));
$auth_p = array();
$auth_p = [];
// Generate array for Auth_Pack, delete the chosen ones
foreach ($auth_p2 as $i => $iValue) {
@ -560,13 +560,13 @@ if ($e_mode == 'perm' && $group) {
$group_name = $row['group_name'];
$allowed_forums = trim($row['forum_permissions']);
$forum_perm = array();
$forum_perm = [];
if ($allowed_forums == '') {
$forum_perm[0]['forum_id'] = 0;
$forum_perm[0]['forum_name'] = $lang['PERM_ALL_FORUMS'];
} else {
$forum_p = array();
$forum_p = [];
$act_id = 0;
$forum_p = auth_unpack($allowed_forums);
$sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' WHERE forum_id IN (' . implode(', ', $forum_p) . ')';
@ -614,7 +614,7 @@ if ($e_mode == 'perm' && $group) {
);
}
$empty_perm_forums = array();
$empty_perm_forums = [];
$sql = 'SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' WHERE auth_attachments < ' . AUTH_ADMIN;

View file

@ -693,7 +693,7 @@ if (!$mode || $show_main_page) {
}
// Okay, let's build the index
$gen_cat = array();
$gen_cat = [];
$bgr_class_1 = 'prow1';
$bgr_class_2 = 'prow2';
@ -923,7 +923,7 @@ function renumber_order($mode, $cat = 0)
*/
function get_cat_forums($cat_id = false)
{
$forums = array();
$forums = [];
$where_sql = '';
if ($cat_id = (int)$cat_id) {
@ -1019,7 +1019,7 @@ function get_orphan_sf()
global $cat_forums;
$last_root = 0;
$bad_sf_ary = array();
$bad_sf_ary = [];
foreach ($cat_forums as $cid => $c) {
foreach ($c['f'] as $fid => $f) {

View file

@ -205,7 +205,7 @@ if ($log_count == $per_page + 1) {
generate_pagination($url, $items_count, $per_page, $start);
$filter = array();
$filter = [];
if ($log_rowset) {
$log_type = $log_action->log_type;
@ -323,7 +323,7 @@ if ($log_rowset) {
'FILTER_USERS' => !empty($filter['users']),
));
} else {
$template->assign_block_vars('log_not_found', array());
$template->assign_block_vars('log_not_found', []);
}
// Select

View file

@ -157,7 +157,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
$expire_time = $start_time + $time_limit - 5;
$start_post_id = $end_post_id = $num_rows = 0;
$timer_expired = false;
$words_sql = array();
$words_sql = [];
while ($row = DB()->fetch_next($result) and !$timer_expired) {
set_time_limit(600);
@ -367,7 +367,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_STOPPED'], $last_saved_post_id, $total_posts_processed, $last_saved_date);
$clear_search_disabled = 'disabled';
$template->assign_block_vars('start_select_input', array());
$template->assign_block_vars('start_select_input', []);
} elseif ($last_session_data['rebuild_session_status'] == REBUILD_SEARCH_ABORTED) {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_ABORTED'], $last_saved_post_id, $total_posts_processed, $last_saved_date);
// check if the interrupted cycle has finished
@ -376,7 +376,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
}
$clear_search_disabled = 'disabled';
$template->assign_block_vars('start_select_input', array());
$template->assign_block_vars('start_select_input', []);
} else {
// when finished
@ -384,17 +384,17 @@ if ($mode == 'submit' || $mode == 'refresh') {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED_NEW'], $last_saved_post_id, $total_posts_processed, $last_saved_date, $total_posts - $total_posts_processed);
$clear_search_disabled = 'disabled';
$template->assign_block_vars('start_select_input', array());
$template->assign_block_vars('start_select_input', []);
} else {
$last_saved_processing = sprintf($lang['INFO_PROCESSING_FINISHED'], $total_posts, $last_saved_date);
$template->assign_block_vars('start_text_input', array());
$template->assign_block_vars('start_text_input', []);
}
}
$template->assign_block_vars('last_saved_info', array());
$template->assign_block_vars('last_saved_info', []);
} else {
$template->assign_block_vars('start_text_input', array());
$template->assign_block_vars('start_text_input', []);
}
// create the output of page

View file

@ -19,7 +19,7 @@ $sql = 'SELECT * FROM ' . BB_CONFIG;
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not query config information in admin_sitemap');
} else {
$new_params = array();
$new_params = [];
while ($row = DB()->sql_fetchrow($result)) {
$config_name = $row['config_name'];

View file

@ -26,7 +26,7 @@ $cat_id = isset($_REQUEST['c']) ? (int)$_REQUEST['c'] : 0;
$mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
$submit = isset($_REQUEST['submit']);
$group_data = array();
$group_data = [];
$forum_auth_fields = array(
'auth_view',
@ -108,7 +108,7 @@ if ($submit && $mode == 'user') {
//
// Submit new USER permissions
//
$auth = array();
$auth = [];
if (!empty($_POST['auth']) && is_array($_POST['auth'])) {
array_deep($_POST['auth'], 'intval');
@ -139,7 +139,7 @@ elseif ($submit && $mode == 'group' && (!empty($_POST['auth']) && is_array($_POS
bb_die($lang['GROUP_NOT_EXIST']);
}
$auth = array();
$auth = [];
array_deep($_POST['auth'], 'intval');
foreach ($_POST['auth'] as $f_id => $bf_ary) {
@ -185,8 +185,8 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
$ug_data = $this_userdata;
$ug_data['session_logged_in'] = 1;
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_USER_ONLY);
$g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, array(), UG_PERM_GROUP_ONLY);
$u_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, [], UG_PERM_USER_ONLY);
$g_access = auth(AUTH_ALL, AUTH_LIST_ALL, $ug_data, [], UG_PERM_GROUP_ONLY);
foreach ($forums['c'] as $c_id => $c_data) {
$template->assign_block_vars('c', array(
@ -276,7 +276,7 @@ if ($mode == 'user' && (!empty($_POST['username']) || $user_id)) {
</select>
';
$template->assign_block_vars('switch_user_auth', array());
$template->assign_block_vars('switch_user_auth', []);
$template->assign_vars(array(
'TPL_AUTH_UG_MAIN' => true,

View file

@ -31,7 +31,7 @@ if (!isset($_REQUEST['dosearch'])) {
$group_list = '';
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('groups_exist', array());
$template->assign_block_vars('groups_exist', []);
while ($row = DB()->sql_fetchrow($result)) {
$group_list .= '<option value="' . $row['group_id'] . '">' . strip_tags(htmlspecialchars($row['group_name'])) . '</option>';
@ -44,7 +44,7 @@ if (!isset($_REQUEST['dosearch'])) {
}
$rank_select_box = '';
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('ranks_exist', array());
$template->assign_block_vars('ranks_exist', []);
while ($row = DB()->sql_fetchrow($result)) {
$rank = $row['rank_title'];
$rank_id = $row['rank_id'];
@ -63,10 +63,10 @@ if (!isset($_REQUEST['dosearch'])) {
bb_die('Could not select forum data');
}
$forums = array();
$forums = [];
if (DB()->num_rows($result) != 0) {
$template->assign_block_vars('forums_exist', array());
$template->assign_block_vars('forums_exist', []);
$last_cat_id = -1;
$forums_list = '';
@ -912,7 +912,7 @@ if (!isset($_REQUEST['dosearch'])) {
unset($banned);
$banned = array();
$banned = [];
while ($row = DB()->sql_fetchrow($result)) {
$banned[$row['user_id']] = true;

View file

@ -22,7 +22,7 @@ $peers_in_last_minutes = [30, 15, 5, 1];
$peers_in_last_sec_limit = 300;
$announce_interval = (int)$bb_cfg['announce_interval'];
$stat = array();
$stat = [];
define('TMP_TRACKER_TABLE', 'tmp_tracker');
@ -59,7 +59,7 @@ $stat += DB()->fetch_row('SELECT COUNT(DISTINCT topic_id) AS tor_with_seeder FRO
$stat += DB()->fetch_row('SELECT COUNT(*) AS tor_all, SUM(size) AS torrents_size FROM ' . BB_BT_TORRENTS);
// Last xx minutes
$peers_in_last_min = array();
$peers_in_last_min = [];
foreach ($peers_in_last_minutes as $t) {
$row = DB()->fetch_row('
SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' WHERE update_time >= ' . (TIMENOW - 60 * $t) . '
@ -67,7 +67,7 @@ foreach ($peers_in_last_minutes as $t) {
$peers_in_last_min[$t] = (int)$row['peers'];
}
// Last xx seconds
$peers_in_last_sec = array();
$peers_in_last_sec = [];
$rowset = DB()->fetch_rowset('SELECT COUNT(*) AS peers FROM ' . TMP_TRACKER_TABLE . ' GROUP BY update_time ORDER BY update_time DESC LIMIT ' . $peers_in_last_sec_limit);
foreach ($rowset as $cnt => $row) {
$peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt % 15)) ? " \n" : '');

View file

@ -91,7 +91,7 @@ if (file_exists(BB_PATH . '/library/config.local.php')) {
* Server variables initialize
*/
$server_protocol = $bb_cfg['cookie_secure'] ? 'https://' : 'http://';
$server_port = in_array((int)$bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port'];
$server_port = in_array((int)$bb_cfg['server_port'], [80, 443], true) ? '' : ':' . $bb_cfg['server_port'];
define('FORUM_PATH', $bb_cfg['script_path']);
define('FULL_URL', $server_protocol . $bb_cfg['server_name'] . $server_port . $bb_cfg['script_path']);
unset($server_protocol, $server_port);
@ -152,11 +152,11 @@ switch ($bb_cfg['datastore_type']) {
break;
case 'sqlite':
$default_cfg = array(
$default_cfg = [
'db_file_path' => $bb_cfg['cache']['db_dir'] . 'datastore.sqlite.db',
'pconnect' => true,
'con_required' => true,
);
];
$datastore = new TorrentPier\Legacy\Datastore\Sqlite($default_cfg, $bb_cfg['cache']['prefix']);
break;
@ -265,7 +265,7 @@ function verify_id($id, $length): bool
function clean_filename($fname)
{
static $s = array('\\', '/', ':', '*', '?', '"', '<', '>', '|', ' ');
static $s = ['\\', '/', ':', '*', '?', '"', '<', '>', '|', ' '];
return str_replace($s, '_', str_compact($fname));
}

10
dl.php
View file

@ -13,10 +13,10 @@ define('NO_GZIP', true);
require __DIR__ . '/common.php';
require ATTACH_DIR . '/attachment_mod.php';
$datastore->enqueue(array(
$datastore->enqueue([
'attach_extensions',
'cat_forums',
));
'cat_forums'
]);
$download_id = request_var('id', 0);
$thumbnail = request_var('thumb', 0);
@ -194,9 +194,7 @@ if (IS_GUEST && !$bb_cfg['captcha']['disabled'] && !bb_captcha('check')) {
$message .= '<input type="button" class="bold" value="' . $lang['GO_BACK'] . '" onclick="document.location.href = \'' . $redirect_url . '\';" />';
$message .= '</form>';
$template->assign_vars(array(
'ERROR_MESSAGE' => $message,
));
$template->assign_vars(['ERROR_MESSAGE' => $message]);
require(PAGE_HEADER);
require(PAGE_FOOTER);

View file

@ -78,16 +78,16 @@ if ($mode == 'dl_delete' && $topic_id) {
}
if (!$confirmed) {
$hidden_fields = array(
$hidden_fields = [
't' => $topic_id,
'mode' => 'dl_delete',
);
];
print_confirmation(array(
print_confirmation([
'QUESTION' => $lang['DL_LIST_DEL_CONFIRM'],
'FORM_ACTION' => 'dl_list.php',
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
]);
}
clear_dl_list($topic_id);
@ -95,7 +95,7 @@ if ($mode == 'dl_delete' && $topic_id) {
}
// Update DL status
$req_topics_ary = $topics_ary = array();
$req_topics_ary = $topics_ary = [];
// Get topics selected by user
if ($mode == 'set_topics_dl_status') {
@ -120,14 +120,14 @@ if ($req_topics_sql = implode(',', $req_topics_ary)) {
}
if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')) {
$new_dlstatus_ary = array();
$new_dlstatus_ary = [];
foreach ($topics_ary as $topic_id) {
$new_dlstatus_ary[] = array(
$new_dlstatus_ary[] = [
'user_id' => (int)$user->id,
'topic_id' => (int)$topic_id,
'user_status' => (int)$new_dl_status,
);
];
}
$new_dlstatus_sql = DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);

View file

@ -12,7 +12,7 @@ define('BB_SCRIPT', 'feed');
require __DIR__ . '/common.php';
// Init userdata
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
$mode = $_REQUEST['mode'] ?? '';
$type = $_POST['type'] ?? '';
@ -29,7 +29,7 @@ if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) {
$sql = "SELECT allow_reg_tracker, forum_name FROM " . BB_FORUMS . " WHERE forum_id = $id LIMIT 1";
if (!$forum_data = DB()->fetch_row($sql)) {
if ($id == 0) {
$forum_data = array();
$forum_data = [];
} else {
bb_simple_die($lang['ATOM_ERROR'] . ' #1');
}

View file

@ -18,7 +18,7 @@ $s_member_groups = $s_pending_groups = $s_member_groups_opt = $s_pending_groups_
$select_sort_mode = $select_sort_order = '';
// Init userdata
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
set_die_append_msg();
@ -28,7 +28,7 @@ $per_page = $bb_cfg['group_members_per_page'];
$view_mode = isset($_REQUEST['view']) ? (string)$_REQUEST['view'] : null;
$rel_limit = 50;
$group_info = array();
$group_info = [];
$is_moderator = false;
if ($group_id) {
@ -43,7 +43,7 @@ if ($group_id) {
if (!$group_id) {
// Show the main screen where the user can select a group.
$groups = array();
$groups = [];
$pending = 10;
$member = 20;
@ -92,7 +92,7 @@ if (!$group_id) {
continue;
}
$data = array('id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']);
$data = ['id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']];
$groups[$type][$row['group_name']] = $data;
}
@ -123,18 +123,18 @@ if (!$group_id) {
$s_hidden_fields = '';
foreach ($groups as $type => $grp) {
$template->assign_block_vars('groups', array(
$template->assign_block_vars('groups', [
'MEMBERSHIP' => $lang["GROUP_MEMBER_{$type}"],
'GROUP_SELECT' => build_group($grp),
));
'GROUP_SELECT' => build_group($grp)
]);
}
$template->assign_vars(array(
$template->assign_vars([
'SELECT_GROUP' => true,
'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
'S_USERGROUP_ACTION' => 'group.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
'S_HIDDEN_FIELDS' => $s_hidden_fields
]);
} else {
if (IS_ADMIN) {
redirect('admin/admin_groups.php');
@ -176,12 +176,12 @@ if (!$group_id) {
$emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_REQUEST']);
$emailer->set_template('group_request', $moderator['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'USER' => $userdata['username'],
'SITENAME' => $bb_cfg['sitename'],
'GROUP_MODERATOR' => $moderator['username'],
'U_GROUP' => make_url(GROUP_URL . $group_id),
));
'U_GROUP' => make_url(GROUP_URL . $group_id)
]);
$emailer->send();
}
@ -217,11 +217,11 @@ if (!$group_id) {
$emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_ADDED']);
$emailer->set_template('group_added', $row['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'GROUP_NAME' => $group_info['group_name'],
'U_GROUP' => make_url(GROUP_URL . $group_id),
));
'U_GROUP' => make_url(GROUP_URL . $group_id)
]);
$emailer->send();
}
@ -229,7 +229,7 @@ if (!$group_id) {
if (((!empty($_POST['approve']) || !empty($_POST['deny'])) && !empty($_POST['pending_members'])) || (!empty($_POST['remove']) && !empty($_POST['members']))) {
$members = (!empty($_POST['approve']) || !empty($_POST['deny'])) ? $_POST['pending_members'] : $_POST['members'];
$sql_in = array();
$sql_in = [];
foreach ($members as $members_id) {
$sql_in[] = (int)$members_id;
}
@ -275,11 +275,11 @@ if (!$group_id) {
$emailer->set_subject($lang['EMAILER_SUBJECT']['GROUP_APPROVED']);
$emailer->set_template('group_approved', $row['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'GROUP_NAME' => $group_info['group_name'],
'U_GROUP' => make_url(GROUP_URL . $group_id),
));
'U_GROUP' => make_url(GROUP_URL . $group_id)
]);
$emailer->send();
}
@ -317,10 +317,10 @@ if (!$group_id) {
$group_details = $lang['ARE_GROUP_MODERATOR'];
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
} elseif ($is_group_member || $is_group_pending_member) {
$template->assign_vars(array(
$template->assign_vars([
'SHOW_UNSUBSCRIBE_CONTROLS' => true,
'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending',
));
]);
$group_details = ($is_group_pending_member) ? $lang['PENDING_THIS_GROUP'] : $lang['MEMBER_THIS_GROUP'];
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
} elseif (IS_GUEST) {
@ -357,7 +357,7 @@ if (!$group_id) {
}
$i = 0;
$template->assign_vars(array(
$template->assign_vars([
'ROW_NUMBER' => $i + ($start + 1),
'GROUP_INFO' => true,
'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
@ -395,7 +395,7 @@ if (!$group_id) {
'S_ORDER_SELECT' => $select_sort_order,
'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id",
));
]);
switch ($view_mode) {
case 'releases':
@ -440,20 +440,18 @@ if (!$group_id) {
foreach ($releases as $i => $release) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('releases', array(
$template->assign_block_vars('releases', [
'ROW_NUMBER' => $i + ($start + 1),
'ROW_CLASS' => $row_class,
'RELEASER' => profile_url(array('user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank'])),
'RELEASER' => profile_url(['user_id' => $release['poster_id'], 'username' => $release['username'], 'user_rank' => $release['user_rank']]),
'AVATAR_IMG' => get_avatar($release['poster_id'], $release['avatar_ext_id'], !bf($release['user_opt'], 'user_opt', 'dis_avatar'), 50, 50),
'RELEASE_NAME' => sprintf('<a href="%s">%s</a>', TOPIC_URL . $release['topic_id'], htmlCHR($release['topic_title'])),
'RELEASE_TIME' => bb_date($release['topic_time']),
'RELEASE_FORUM' => sprintf('<a href="%s">%s</a>', FORUM_URL . $release['forum_id'], htmlCHR($release['forum_name'])),
));
]);
}
$template->assign_vars(array(
'RELEASES' => true,
));
$template->assign_vars(['RELEASES' => true]);
break;
@ -499,7 +497,7 @@ if (!$group_id) {
if ($group_info['group_type'] != GROUP_HIDDEN || $is_group_member || $is_moderator) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('member', array(
$template->assign_block_vars('member', [
'ROW_NUMBER' => $i + ($start + 1),
'ROW_CLASS' => $row_class,
'USER' => profile_url($member),
@ -511,23 +509,23 @@ if (!$group_id) {
'PM' => $member_info['pm'],
'EMAIL' => $member_info['email'],
'WWW' => $member_info['www'],
'TIME' => $member_info['user_time'],
));
'TIME' => $member_info['user_time']
]);
if ($is_moderator) {
$template->assign_block_vars('member.switch_mod_option', array());
$template->assign_block_vars('member.switch_mod_option', []);
}
}
}
// No group members
if (!$members_count) {
$template->assign_block_vars('switch_no_members', array());
$template->assign_block_vars('switch_no_members', []);
}
// No group members
if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator) {
$template->assign_block_vars('switch_hidden_group', array());
$template->assign_block_vars('switch_hidden_group', []);
}
// Pending
@ -554,7 +552,7 @@ if (!$group_id) {
$user_select = '<input type="checkbox" name="member[]" value="' . $user_id . '">';
$template->assign_block_vars('pending', array(
$template->assign_block_vars('pending', [
'ROW_CLASS' => $row_class,
'AVATAR_IMG' => $member_info['avatar'],
'USER' => profile_url($member),
@ -563,21 +561,19 @@ if (!$group_id) {
'POSTS' => $member_info['posts'],
'USER_ID' => $user_id,
'PM' => $member_info['pm'],
'EMAIL' => $member_info['email'],
));
'EMAIL' => $member_info['email']
]);
}
$template->assign_vars(array(
'PENDING_USERS' => true,
));
$template->assign_vars(['PENDING_USERS' => true]);
}
$template->assign_vars(array('MEMBERS' => true));
$template->assign_vars(['MEMBERS' => true]);
}
if ($is_moderator) {
$template->assign_block_vars('switch_mod_option', array());
$template->assign_block_vars('switch_add_member', array());
$template->assign_block_vars('switch_mod_option', []);
$template->assign_block_vars('switch_add_member', []);
}
}

View file

@ -14,10 +14,10 @@ require __DIR__ . '/common.php';
$page_cfg['include_bbcode_js'] = true;
// Start session management
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
$group_id = isset($_REQUEST[POST_GROUPS_URL]) ? (int)$_REQUEST[POST_GROUPS_URL] : null;
$group_info = array();
$group_info = [];
$is_moderator = false;
$submit = !empty($_POST['submit']);
@ -38,7 +38,7 @@ if ($is_moderator) {
if (!empty($_FILES['avatar']['name']) && $bb_cfg['group_avatars']['up_allowed']) {
$upload = new TorrentPier\Legacy\Common\Upload();
if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) {
if ($upload->init($bb_cfg['group_avatars'], $_FILES['avatar']) and $upload->store('avatar', ['user_id' => GROUP_AVATAR_MASK . $group_id, 'avatar_ext_id' => $group_info['avatar_ext_id']])) {
$avatar_ext_id = (int)$upload->file_ext_id;
} else {
bb_die(implode($upload->errors));
@ -59,7 +59,7 @@ if ($is_moderator) {
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
$template->assign_vars(array(
$template->assign_vars([
'PAGE_TITLE' => $lang['GROUP_CONTROL_PANEL'],
'GROUP_NAME' => htmlCHR($group_info['group_name']),
'GROUP_ID' => $group_id,
@ -79,10 +79,10 @@ if ($is_moderator) {
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
));
]);
$template->set_filenames(array('body' => 'group_edit.tpl'));
$template->assign_vars(array('PAGE_TITLE' => $lang['GROUP_CONFIGURATION']));
$template->set_filenames(['body' => 'group_edit.tpl']);
$template->assign_vars(['PAGE_TITLE' => $lang['GROUP_CONFIGURATION']]);
require(PAGE_HEADER);

View file

@ -11,9 +11,9 @@ define('BB_SCRIPT', 'index');
require __DIR__ . '/common.php';
$page_cfg['load_tpl_vars'] = array(
'post_icons',
);
$page_cfg['load_tpl_vars'] = [
'post_icons'
];
// Show last topic
$show_last_topic = true;
@ -25,11 +25,11 @@ $show_online_users = true;
// Show subforums
$show_subforums = true;
$datastore->enqueue(array(
$datastore->enqueue([
'stats',
'moderators',
'cat_forums',
));
'cat_forums'
]);
if ($bb_cfg['show_latest_news']) {
$datastore->enqueue('latest_news');
@ -121,15 +121,15 @@ $sql = "
ORDER BY c.cat_order, f.forum_order
';
$replace_in_parent = array(
$replace_in_parent = [
'last_post_id',
'last_post_time',
'last_post_user_id',
'last_post_username',
'last_post_user_rank',
'last_topic_title',
'last_topic_id',
);
'last_topic_id'
];
$cache_name = 'index_sql_' . md5($sql);
if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) {
@ -168,7 +168,7 @@ if (!$cat_forums = CACHE('bb_cache')->get($cache_name)) {
}
// Obtain list of moderators
$moderators = array();
$moderators = [];
if (!$mod = $datastore->get('moderators')) {
$datastore->update('moderators');
$mod = $datastore->get('moderators');
@ -193,25 +193,23 @@ $datastore->rm('moderators');
// Build index page
$forums_count = 0;
foreach ($cat_forums as $cid => $c) {
$template->assign_block_vars('h_c', array(
$template->assign_block_vars('h_c', [
'H_C_ID' => $cid,
'H_C_TITLE' => $cat_title_html[$cid],
'H_C_CHEKED' => in_array($cid, preg_split('/[-]+/', $hide_cat_opt)) ? 'checked' : '',
));
]);
$template->assign_vars(array(
'H_C_AL_MESS' => $hide_cat_opt && !$showhide,
));
$template->assign_vars(['H_C_AL_MESS' => $hide_cat_opt && !$showhide]);
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
continue;
}
$template->assign_block_vars('c', array(
$template->assign_block_vars('c', [
'CAT_ID' => $cid,
'CAT_TITLE' => $cat_title_html[$cid],
'U_VIEWCAT' => CAT_URL . $cid,
));
]);
foreach ($c['f'] as $fid => $f) {
if (!$fname_html =& $forum_name_html[$fid]) {
@ -228,15 +226,15 @@ foreach ($cat_forums as $cid => $c) {
}
if ($is_sf) {
$template->assign_block_vars('c.f.sf', array(
$template->assign_block_vars('c.f.sf', [
'SF_ID' => $fid,
'SF_NAME' => $fname_html,
'SF_NEW' => $new ? ' new' : '',
));
'SF_NEW' => $new ? ' new' : ''
]);
continue;
}
$template->assign_block_vars('c.f', array(
$template->assign_block_vars('c.f', [
'FORUM_FOLDER_IMG' => $folder_image,
'FORUM_ID' => $fid,
'FORUM_NAME' => $fname_html,
@ -245,22 +243,22 @@ foreach ($cat_forums as $cid => $c) {
'TOPICS' => commify($f['forum_topics']),
'LAST_SF_ID' => $f['last_sf_id'] ?? null,
'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '',
'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD'],
));
'FORUM_FOLDER_ALT' => $new ? $lang['NEW'] : $lang['OLD']
]);
if ($f['last_post_id']) {
$template->assign_block_vars('c.f.last', array(
$template->assign_block_vars('c.f.last', [
'LAST_TOPIC_ID' => $f['last_topic_id'],
'LAST_TOPIC_TIP' => $f['last_topic_title'],
'LAST_TOPIC_TITLE' => wbr(str_short($f['last_topic_title'], $last_topic_max_len)),
'LAST_POST_TIME' => bb_date($f['last_post_time'], $bb_cfg['last_post_date_format']),
'LAST_POST_USER' => profile_url(array('username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank'])),
));
'LAST_POST_USER' => profile_url(['username' => str_short($f['last_post_username'], 15), 'user_id' => $f['last_post_user_id'], 'user_rank' => $f['last_post_user_rank']]),
]);
}
}
}
$template->assign_vars(array(
$template->assign_vars([
'SHOW_FORUMS' => $forums_count,
'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST,
'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : $lang['HOME'],
@ -310,7 +308,7 @@ $template->assign_vars(array(
'SHOW_LAST_TOPIC' => $show_last_topic,
'BOARD_START' => $bb_cfg['show_board_start_index'] ? ($lang['BOARD_STARTED'] . ':&nbsp;' . '<b>' . bb_date($bb_cfg['board_startdate']) . '</b>') : false,
));
]);
// Set tpl vars for bt_userdata
if ($bb_cfg['bt_show_dl_stat_on_index'] && !IS_GUEST) {
@ -324,17 +322,15 @@ if ($bb_cfg['show_latest_news']) {
$latest_news = $datastore->get('latest_news');
}
$template->assign_vars(array(
'SHOW_LATEST_NEWS' => true,
));
$template->assign_vars(['SHOW_LATEST_NEWS' => true]);
foreach ($latest_news as $news) {
$template->assign_block_vars('news', array(
$template->assign_block_vars('news', [
'NEWS_TOPIC_ID' => $news['topic_id'],
'NEWS_TITLE' => str_short($news['topic_title'], $bb_cfg['max_news_title']),
'NEWS_TIME' => bb_date($news['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($news['topic_time'], $news['topic_id'], $news['forum_id']),
));
]);
}
}
@ -345,22 +341,20 @@ if ($bb_cfg['show_network_news']) {
$network_news = $datastore->get('network_news');
}
$template->assign_vars(array(
'SHOW_NETWORK_NEWS' => true,
));
$template->assign_vars(['SHOW_NETWORK_NEWS' => true]);
foreach ($network_news as $net) {
$template->assign_block_vars('net', array(
$template->assign_block_vars('net', [
'NEWS_TOPIC_ID' => $net['topic_id'],
'NEWS_TITLE' => str_short($net['topic_title'], $bb_cfg['max_net_title']),
'NEWS_TIME' => bb_date($net['topic_time'], 'd-M', false),
'NEWS_IS_NEW' => is_unread($net['topic_time'], $net['topic_id'], $net['forum_id']),
));
]);
}
}
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$week_list = $today_list = array();
$week_list = $today_list = [];
$week_all = $today_all = false;
if (!empty($stats['birthday_week_list'])) {
@ -393,10 +387,10 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$today_list = $lang['NOBIRTHDAY_TODAY'];
}
$template->assign_vars(array(
$template->assign_vars([
'WHOSBIRTHDAY_WEEK' => $week_list,
'WHOSBIRTHDAY_TODAY' => $today_list,
));
'WHOSBIRTHDAY_TODAY' => $today_list
]);
}
// Allow cron
@ -413,7 +407,7 @@ if (IS_AM) {
define('SHOW_ONLINE', $show_online_users);
if (isset($_GET['map'])) {
$template->assign_vars(array('PAGE_TITLE' => $lang['FORUM_MAP']));
$template->assign_vars(['PAGE_TITLE' => $lang['FORUM_MAP']]);
}
print_page('index.tpl');

View file

@ -126,7 +126,7 @@ switch ($field) {
$table = BB_BT_USERS;
$value = (float)str_replace(',', '.', $this->request['value']);
foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4, 'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8) as $s => $m) {
foreach (['KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4, 'PB' => 5, 'EB' => 6, 'ZB' => 7, 'YB' => 8] as $s => $m) {
if (stripos($this->request['value'], $s) !== false) {
$value *= (1024 ** $m);
break;

View file

@ -31,7 +31,7 @@ switch ($mode) {
WHERE ug.user_id = $user_id
ORDER BY g.group_name
";
$html = array();
$html = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$class = ($row['user_pending']) ? 'med' : 'med bold';
$class .= ($row['group_moderator'] == $user_id) ? ' colorMod' : '';

View file

@ -19,9 +19,9 @@ $html = '';
switch ($mode) {
case 'birthday_week':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
$datastore->enqueue([
'stats'
]);
$users = [];
@ -37,9 +37,9 @@ switch ($mode) {
case 'birthday_today':
$stats = $datastore->get('stats');
$datastore->enqueue(array(
'stats',
));
$datastore->enqueue([
'stats'
]);
$users = [];
@ -56,12 +56,12 @@ switch ($mode) {
case 'get_forum_mods':
$forum_id = (int)$this->request['forum_id'];
$datastore->enqueue(array(
$datastore->enqueue([
'moderators',
'cat_forums',
));
'cat_forums'
]);
$moderators = array();
$moderators = [];
$mod = $datastore->get('moderators');
if (isset($mod['mod_users'][$forum_id])) {

View file

@ -69,12 +69,12 @@ switch ($mode) {
}
// Log action
$log_action->mod('mod_topic_renamed', array(
$log_action->mod('mod_topic_renamed', [
'forum_id' => $t_data['forum_id'],
'topic_id' => $topic_id,
'topic_title' => $old_title,
'topic_title_new' => $new_title,
));
'topic_title_new' => $new_title
]);
$this->response['topic_id'] = $topic_id;
$this->response['topic_title'] = $new_title;

View file

@ -30,11 +30,11 @@ if (!$post) {
$this->ajax_die('not post');
}
$data = array(
$data = [
'mc_comment' => ($mc_type) ? $mc_text : '',
'mc_type' => $mc_type,
'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0,
);
'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0
];
$sql_args = DB()->build_array('UPDATE', $data);
DB()->query("UPDATE " . BB_POSTS . " SET $sql_args WHERE post_id = $post_id");

View file

@ -48,8 +48,8 @@ if (isset($this->request['post_id'])) {
}
if (!defined('WORD_LIST_OBTAINED')) {
$orig_word = array();
$replace_word = array();
$orig_word = [];
$replace_word = [];
obtain_word_list($orig_word, $replace_word);
define('WORD_LIST_OBTAINED', true);
}
@ -142,10 +142,10 @@ switch ($this->request['type']) {
$s_text = str_replace('\n', "\n", $text);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_text), stripslashes($s_topic_title));
update_post_html(array(
update_post_html([
'post_id' => $post_id,
'post_text' => $text,
));
'post_text' => $text
]);
}
} else {
$this->ajax_die($lang['EMPTY_MESSAGE']);
@ -276,10 +276,10 @@ switch ($this->request['type']) {
$s_message = str_replace('\n', "\n", $message);
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title));
update_post_html(array(
update_post_html([
'post_id' => $post_id,
'post_text' => $message,
));
'post_text' => $message
]);
if ($bb_cfg['topic_notify_enabled']) {
$notify = !empty($this->request['notify']);

View file

@ -60,7 +60,7 @@ switch ($mode) {
preg_match('#\d+#', (string)$this->request['tpl_rules'], $m);
$tpl_rules_post_id = isset($m[0]) ? (int)$m[0] : 0;
$sql_args = array(
$sql_args = [
'tpl_name' => (string)$tpl_name,
'tpl_src_form' => (string)$tpl_src_form,
'tpl_src_title' => (string)$tpl_src_title,
@ -68,8 +68,8 @@ switch ($mode) {
'tpl_comment' => (string)$tpl_comment,
'tpl_rules_post_id' => (int)$tpl_rules_post_id,
'tpl_last_edit_tm' => (int)TIMENOW,
'tpl_last_edit_by' => (int)$userdata['user_id'],
);
'tpl_last_edit_by' => (int)$userdata['user_id']
];
break;
}
// выполнение

View file

@ -48,7 +48,7 @@ function get_config()
{
global $bb_cfg;
$attach_config = array();
$attach_config = [];
$sql = 'SELECT * FROM ' . BB_ATTACH_CONFIG;
@ -67,7 +67,7 @@ function get_config()
}
// Get Attachment Config
$attach_config = array();
$attach_config = [];
if (!$attach_config = CACHE('bb_cache')->get('attach_config')) {
$attach_config = get_config();

View file

@ -11,11 +11,11 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$allowed_extensions = array();
$display_categories = array();
$download_modes = array();
$upload_icons = array();
$attachments = array();
$allowed_extensions = [];
$display_categories = [];
$download_modes = [];
$upload_icons = [];
$attachments = [];
/**
* Create needed arrays for Extension Assignments
@ -28,7 +28,7 @@ function init_complete_extensions_data()
$GLOBALS['datastore']->update('attach_extensions');
$extension_informations = get_extension_informations();
}
$allowed_extensions = array();
$allowed_extensions = [];
for ($i = 0, $size = count($extension_informations); $i < $size; $i++) {
$extension = strtolower(trim($extension_informations[$i]['extension']));
@ -116,7 +116,7 @@ function init_display_post_attachments($switch_attachment)
return;
}
$post_id_array = array();
$post_id_array = [];
for ($i = 0; $i < $total_posts; $i++) {
if ($postrow[$i]['post_attachment'] == 1) {
@ -173,7 +173,7 @@ function display_attachments($post_id)
return;
}
$template->assign_block_vars('postrow.attach', array());
$template->assign_block_vars('postrow.attach', []);
for ($i = 0; $i < $num_attachments; $i++) {
// Some basic things...
@ -200,9 +200,7 @@ function display_attachments($post_id)
if (!in_array($attachments['_' . $post_id][$i]['extension'], $allowed_extensions)) {
$denied = true;
$template->assign_block_vars('postrow.attach.denyrow', array(
'L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension']))
);
$template->assign_block_vars('postrow.attach.denyrow', ['L_DENIED' => sprintf($lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachments['_' . $post_id][$i]['extension'])]);
}
if (!$denied || IS_ADMIN) {
@ -246,13 +244,13 @@ function display_attachments($post_id)
$download_link = false;
}
$template->assign_block_vars('postrow.attach.cat_images', array(
$template->assign_block_vars('postrow.attach.cat_images', [
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => $img_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
'COMMENT' => $comment
]);
// Directly Viewed Image ... update the download count
if (!$download_link) {
@ -274,14 +272,14 @@ function display_attachments($post_id)
$thumb_source = $thumbnail_filename;
}
$template->assign_block_vars('postrow.attach.cat_thumb_images', array(
$template->assign_block_vars('postrow.attach.cat_thumb_images', [
'DOWNLOAD_NAME' => $display_name,
'S_UPLOAD_IMAGE' => $upload_image,
'IMG_SRC' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'],
'IMG_THUMB_SRC' => $thumb_source,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
));
'COMMENT' => $comment
]);
}
// bt
@ -291,15 +289,15 @@ function display_attachments($post_id)
$target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : '';
// display attachment
$template->assign_block_vars('postrow.attach.attachrow', array(
$template->assign_block_vars('postrow.attach.attachrow', [
'U_DOWNLOAD_LINK' => BB_ROOT . DL_URL . $attachments['_' . $post_id][$i]['attach_id'],
'S_UPLOAD_IMAGE' => $upload_image,
'DOWNLOAD_NAME' => $display_name,
'FILESIZE' => $filesize,
'COMMENT' => $comment,
'TARGET_BLANK' => $target_blank,
'DOWNLOAD_COUNT' => declension((int)$attachments['_' . $post_id][$i]['download_count'], 'times'),
));
'DOWNLOAD_COUNT' => declension((int)$attachments['_' . $post_id][$i]['download_count'], 'times')
]);
}
}
}

View file

@ -28,15 +28,15 @@ $upload_image = '<img src="' . $images['icon_dn'] . '" alt="' . $lang['DL_TORREN
$peers_cnt = $seed_count = 0;
$seeders = $leechers = '';
$tor_info = array();
$tor_info = [];
$template->assign_vars(array(
$template->assign_vars([
'SEED_COUNT' => false,
'LEECH_COUNT' => false,
'TOR_SPEED_UP' => false,
'TOR_SPEED_DOWN' => false,
'SHOW_RATIO_WARN' => false,
));
'SHOW_RATIO_WARN' => false
]);
// Define show peers mode (count only || user names with complete % || full details)
$cfg_sp_mode = $bb_cfg['bt_show_peers_mode'];
@ -90,7 +90,7 @@ if ($tor_auth_reg || $tor_auth_del) {
$display_name = '[' . $bb_cfg['server_name'] . '].t' . $bt_topic_id . '.torrent';
if (!$tor_reged) {
$template->assign_block_vars('postrow.attach.tor_not_reged', array(
$template->assign_block_vars('postrow.attach.tor_not_reged', [
'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link,
'ATTACH_ID' => $attach_id,
@ -101,10 +101,10 @@ if (!$tor_reged) {
'DOWNLOAD_COUNT' => declension((int)$download_count, 'times'),
'POSTED_TIME' => $tor_file_time,
));
]);
if ($comment) {
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', ['COMMENT' => $comment]);
}
} else {
$sql = "SELECT bt.*, u.user_id, u.username, u.user_rank
@ -126,13 +126,13 @@ if ($tor_reged && !$tor_info) {
}
if ($tor_auth) {
$template->assign_vars(array(
$template->assign_vars([
'TOR_CONTROLS' => true,
'TOR_ATTACH_ID' => $attach_id,
));
'TOR_ATTACH_ID' => $attach_id
]);
if ($t_data['self_moderated'] || $is_auth['auth_mod']) {
$template->assign_vars(array('AUTH_MOVE' => true));
$template->assign_vars(['AUTH_MOVE' => true]);
}
}
@ -175,21 +175,21 @@ if ($tor_reged && $tor_info) {
}
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(
$template->assign_vars([
'SHOW_RATIO_WARN' => true,
'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help']),
));
'RATIO_WARN_MSG' => sprintf($lang['BT_RATIO_WARNING_MSG'], $min_ratio_dl, $bb_cfg['ratio_url_help'])
]);
}
}
if (!$dl_allowed) {
$template->assign_block_vars('postrow.attach.tor_reged', array());
$template->assign_vars(array(
$template->assign_block_vars('postrow.attach.tor_reged', []);
$template->assign_vars([
'TOR_BLOCKED' => true,
'TOR_BLOCKED_MSG' => sprintf($lang['BT_LOW_RATIO_FOR_DL'], round($user_ratio, 2), "search.php?dlu=$bt_user_id&amp;dlc=1"),
));
]);
} else {
$template->assign_block_vars('postrow.attach.tor_reged', array(
$template->assign_block_vars('postrow.attach.tor_reged', [
'DOWNLOAD_NAME' => $display_name,
'TRACKER_LINK' => $tracker_link,
'ATTACH_ID' => $attach_id,
@ -218,22 +218,22 @@ if ($tor_reged && $tor_info) {
'REGED_DELTA' => delta_time($tor_info['reg_time']),
'TORRENT_SIZE' => humn_size($tor_size),
'COMPLETED' => declension((int)$tor_info['complete_count'], 'times'),
));
]);
if ($comment) {
$template->assign_block_vars('postrow.attach.tor_reged.comment', array('COMMENT' => $comment));
$template->assign_block_vars('postrow.attach.tor_reged.comment', ['COMMENT' => $comment]);
}
}
if ($bb_cfg['show_tor_info_in_dl_list']) {
$template->assign_vars(array(
$template->assign_vars([
'SHOW_DL_LIST' => true,
'SHOW_DL_LIST_TOR_INFO' => true,
'TOR_SIZE' => humn_size($tor_size),
'TOR_LONGEVITY' => delta_time($tor_info['reg_time']),
'TOR_COMPLETED' => declension($tor_info['complete_count'], 'times'),
));
]);
}
// Show peers
@ -250,7 +250,7 @@ if ($tor_reged && $tor_info) {
}
if (isset($_REQUEST['porder'])) {
$peer_orders = array(
$peer_orders = [
'name' => 'u.username',
'ip' => 'tr.ip',
'port' => 'tr.port',
@ -259,8 +259,8 @@ if ($tor_reged && $tor_info) {
'cdown' => 'tr.downloaded',
'sup' => 'tr.speed_up',
'sdown' => 'tr.speed_down',
'time' => 'tr.update_time',
);
'time' => 'tr.update_time'
];
foreach ($peer_orders as $get_key => $order_by_value) {
if ($_REQUEST['porder'] == $get_key) {
@ -299,11 +299,11 @@ if ($tor_reged && $tor_info) {
if ($peers = DB()->fetch_rowset($sql)) {
$peers_cnt = count($peers);
$cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = array();
$cnt = $tr = $sp_up = $sp_down = $sp_up_tot = $sp_down_tot = [];
$cnt['s'] = $tr['s'] = $sp_up['s'] = $sp_down['s'] = $sp_up_tot['s'] = $sp_down_tot['s'] = 0;
$cnt['l'] = $tr['l'] = $sp_up['l'] = $sp_down['l'] = $sp_up_tot['l'] = $sp_down_tot['l'] = 0;
$max_up = $max_down = $max_sp_up = $max_sp_down = array();
$max_up = $max_down = $max_sp_up = $max_sp_down = [];
$max_up['s'] = $max_down['s'] = $max_sp_up['s'] = $max_sp_down['s'] = 0;
$max_up['l'] = $max_down['l'] = $max_sp_up['l'] = $max_sp_down['l'] = 0;
$max_up_id['s'] = $max_down_id['s'] = $max_sp_up_id['s'] = $max_sp_down_id['s'] = ($peers_cnt + 1);
@ -348,7 +348,7 @@ if ($tor_reged && $tor_info) {
}
if ($s_mode == 'count') {
$tmp = array();
$tmp = [];
$tmp[0]['seeder'] = $tmp[0]['username'] = $tmp[1]['username'] = 0;
$tmp[1]['seeder'] = 1;
$tmp[0]['username'] = (int)@$peers[0]['leechers'];
@ -357,10 +357,10 @@ if ($tor_reged && $tor_info) {
$tor_speed_down = (int)@$peers[0]['speed_down'];
$peers = $tmp;
$template->assign_vars(array(
$template->assign_vars([
'TOR_SPEED_UP' => ($tor_speed_up) ? humn_size($tor_speed_up, 0, 'KB') . '/s' : '0 KB/s',
'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s',
));
'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s'
]);
}
foreach ($peers as $pid => $peer) {
@ -384,18 +384,18 @@ if ($tor_reged && $tor_info) {
if (!defined('SEEDER_EXIST')) {
define('SEEDER_EXIST', true);
$seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders";
$seed_order_action = TOPIC_URL . "$bt_topic_id&amp;spmode=full#seeders";
$template->assign_block_vars((string)$x_full, array(
$template->assign_block_vars((string)$x_full, [
'SEED_ORD_ACT' => $seed_order_action,
'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s'
));
]);
if ($ip) {
$template->assign_block_vars("$x_full.iphead", array());
$template->assign_block_vars("$x_full.iphead", []);
}
if ($port !== false) {
$template->assign_block_vars("$x_full.porthead", array());
$template->assign_block_vars("$x_full.porthead", []);
}
}
$compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0;
@ -406,19 +406,19 @@ if ($tor_reged && $tor_info) {
if (!defined('LEECHER_EXIST')) {
define('LEECHER_EXIST', true);
$leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#leechers";
$leech_order_action = TOPIC_URL . "$bt_topic_id&amp;spmode=full#leechers";
$template->assign_block_vars((string)$x_full, array(
$template->assign_block_vars((string)$x_full, [
'LEECH_ORD_ACT' => $leech_order_action,
'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s',
'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s'
));
]);
if ($ip) {
$template->assign_block_vars("$x_full.iphead", array());
$template->assign_block_vars("$x_full.iphead", []);
}
if ($port !== false) {
$template->assign_block_vars("$x_full.porthead", array());
$template->assign_block_vars("$x_full.porthead", []);
}
}
$compl_size = ($peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
@ -437,7 +437,7 @@ if ($tor_reged && $tor_info) {
$row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : '';
$tr[$x]++;
$template->assign_block_vars("$x_full.$x_row", array(
$template->assign_block_vars("$x_full.$x_row", [
'ROW_BGR' => $row_bgr,
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
'COMPL_PRC' => $compl_perc,
@ -450,14 +450,14 @@ if ($tor_reged && $tor_info) {
'SPEED_UP_RAW' => $peer['speed_up'],
'SPEED_DOWN_RAW' => $peer['speed_down'],
'UPD_EXP_TIME' => ($peer['update_time']) ? $lang['DL_UPD'] . bb_date($peer['update_time'], 'd-M-y H:i') . ' &middot; ' . delta_time($peer['update_time']) . $lang['TOR_BACK'] : $lang['DL_STOPPED'],
'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : '',
));
'TOR_RATIO' => ($up_ratio) ? $lang['USER_RATIO'] . "UL/DL: $up_ratio" : ''
]);
if ($ip) {
$template->assign_block_vars("$x_full.$x_row.ip", array('IP' => $ip));
$template->assign_block_vars("$x_full.$x_row.ip", ['IP' => $ip]);
}
if ($port !== false) {
$template->assign_block_vars("$x_full.$x_row.port", array('PORT' => $port));
$template->assign_block_vars("$x_full.$x_row.port", ['PORT' => $port]);
}
} // Count only & only names modes
else {
@ -478,17 +478,17 @@ if ($tor_reged && $tor_info) {
if ($s_mode != 'full' && $seeders) {
$seeders[strlen($seeders) - 9] = ' ';
$template->assign_vars(array(
$template->assign_vars([
'SEED_LIST' => $seeders,
'SEED_COUNT' => ($seed_count) ?: 0,
));
]);
}
if ($s_mode != 'full' && $leechers) {
$leechers[strlen($leechers) - 9] = ' ';
$template->assign_vars(array(
$template->assign_vars([
'LEECH_LIST' => $leechers,
'LEECH_COUNT' => ($leech_count) ?: 0,
));
]);
}
}
unset($peers);
@ -497,27 +497,27 @@ if ($tor_reged && $tor_info) {
if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST'))) {
$last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : $lang['NEVER'];
$template->assign_vars(array(
'SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time),
));
$template->assign_vars(['SEEDER_LAST_SEEN' => sprintf($lang['SEEDER_LAST_SEEN'], $last_seen_time)]);
}
}
$template->assign_block_vars('tor_title', array('U_DOWNLOAD_LINK' => $download_link));
$template->assign_block_vars('tor_title', ['U_DOWNLOAD_LINK' => $download_link]);
if ($peers_cnt > $max_peers_before_overflow && $s_mode == 'full') {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_overflow));
$template->assign_vars(array('PEERS_OVERFLOW' => true));
$template->assign_vars([
'PEERS_OVERFLOW' => true,
'PEERS_DIV_STYLE' => $peers_div_style_overflow
]);
} else {
$template->assign_vars(array('PEERS_DIV_STYLE' => $peers_div_style_normal));
$template->assign_vars(['PEERS_DIV_STYLE' => $peers_div_style_normal]);
}
}
if ($bb_cfg['bt_allow_spmode_change'] && $s_mode != 'full') {
$template->assign_vars(array(
$template->assign_vars([
'PEERS_FULL_LINK' => true,
'SPMODE_FULL_HREF' => "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders",
));
'SPMODE_FULL_HREF' => TOPIC_URL . "$bt_topic_id&amp;spmode=full#seeders"
]);
}
$template->assign_vars(array(

View file

@ -55,7 +55,7 @@ function base64_unpack($string)
for ($i = 1; $i <= $length; $i++) {
$pos = $length - $i;
$operand = strpos($chars, (string) $string[$pos]);
$operand = strpos($chars, (string)$string[$pos]);
$exponent = $base ** ($i - 1);
$decValue = $operand * $exponent;
$number += $decValue;
@ -454,7 +454,7 @@ function _set_var(&$result, $var, $type, $multibyte = false)
$result = $var;
if ($type == 'string') {
$result = trim(str_replace(array("\r\n", "\r", '\xFF'), array("\n", "\n", ' '), $result));
$result = trim(str_replace(["\r\n", "\r", '\xFF'], ["\n", "\n", ' '], $result));
// 2.0.x is doing addslashes on all variables
$result = stripslashes($result);
if ($multibyte) {

View file

@ -23,7 +23,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
}
if ($post_id_array === 0 && $attach_id_array !== 0) {
$post_id_array = array();
$post_id_array = [];
if (!is_array($attach_id_array)) {
if (false !== strpos($attach_id_array, ', ')) {
@ -32,7 +32,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
$attach_id_array = explode(',', $attach_id_array);
} else {
$attach_id = (int)$attach_id_array;
$attach_id_array = array();
$attach_id_array = [];
$attach_id_array[] = $attach_id;
}
}
@ -74,7 +74,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
} else {
$post_id = (int)$post_id_array;
$post_id_array = array();
$post_id_array = [];
$post_id_array[] = $post_id;
}
}
@ -85,7 +85,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
// First of all, determine the post id and attach_id
if ($attach_id_array === 0) {
$attach_id_array = array();
$attach_id_array = [];
// Get the attach_ids to fill the array
$whereclause = 'WHERE post_id IN (' . implode(', ', $post_id_array) . ')';
@ -119,7 +119,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
} else {
$attach_id = (int)$attach_id_array;
$attach_id_array = array();
$attach_id_array = [];
$attach_id_array[] = $attach_id;
}
}
@ -147,7 +147,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
bb_die($lang['ERROR_DELETED_ATTACHMENTS']);
}
$torrents_sql = array();
$torrents_sql = [];
while ($row = DB()->sql_fetchrow($result)) {
$torrents_sql[] = $row['topic_id'];

View file

@ -109,11 +109,11 @@ function image_getdimension($file)
if (!$error) {
fclose($fp);
return array(
return [
$width,
$height,
6
);
];
}
$error = false;
@ -147,11 +147,11 @@ function image_getdimension($file)
if (!$error) {
fclose($fp);
return array(
return [
$width,
$height,
1
);
];
}
$error = false;
@ -199,11 +199,11 @@ function image_getdimension($file)
if (!$error) {
fclose($fp);
return array(
return [
$width,
$height,
2
);
];
}
$error = false;
@ -245,11 +245,11 @@ function image_getdimension($file)
if (!$error) {
fclose($fp);
return array(
return [
$width,
$height,
7
);
];
}
fclose($fp);

View file

@ -98,10 +98,10 @@ function attachment_quota_settings($admin_mode, $mode, $submit = false)
}
DB()->sql_freeresult($result);
$template->assign_vars(array(
$template->assign_vars([
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('user_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota),
));
'S_SELECT_PM_QUOTA' => quota_limit_select('user_pm_quota', $pm_quota)
]);
}
if ($admin_mode == 'user' && $submit && @$_POST['delete_user']) {
@ -148,10 +148,10 @@ function attachment_quota_settings($admin_mode, $mode, $submit = false)
}
DB()->sql_freeresult($result);
$template->assign_vars(array(
$template->assign_vars([
'S_SELECT_UPLOAD_QUOTA' => quota_limit_select('group_upload_quota', $upload_quota),
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota),
));
'S_SELECT_PM_QUOTA' => quota_limit_select('group_pm_quota', $pm_quota)
]);
}
if ($admin_mode == 'group' && $submit && isset($_POST['group_delete'])) {

View file

@ -120,8 +120,8 @@ function category_select($select_name, $group_id = 0)
}
}
$types = array(NONE_CAT);
$modes = array('none');
$types = [NONE_CAT];
$modes = ['none'];
for ($i = 0, $iMax = count($types_category); $i < $iMax; $i++) {
$types[] = $types_category[$i];
@ -152,8 +152,8 @@ function size_select($select_name, $size_compare)
{
global $lang;
$size_types_text = array($lang['BYTES'], $lang['KB'], $lang['MB']);
$size_types = array('b', 'kb', 'mb');
$size_types_text = [$lang['BYTES'], $lang['KB'], $lang['MB']];
$size_types = ['b', 'kb', 'mb'];
$select_field = '<select name="' . $select_name . '">';

View file

@ -22,16 +22,16 @@ function get_img_size_format($width, $height)
$max_width = 400;
if ($width > $height) {
return array(
return [
round($width * ($max_width / $width)),
round($height * ($max_width / $width))
);
];
}
return array(
return [
round($width * ($max_width / $height)),
round($height * ($max_width / $height))
);
];
}
/**
@ -78,14 +78,14 @@ function get_supported_image_types($type)
break;
}
return array(
return [
'gd' => (bool)$new_type,
'format' => $new_type,
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
);
];
}
return array('gd' => false);
return ['gd' => false];
}
/**

View file

@ -194,7 +194,7 @@ function strip_quotes($text)
$lowertext = strtolower($text);
// find all [quote tags
$start_pos = array();
$start_pos = [];
$curpos = 0;
do {
$pos = strpos($lowertext, '[quote', $curpos);
@ -209,7 +209,7 @@ function strip_quotes($text)
}
// find all [/quote] tags
$end_pos = array();
$end_pos = [];
$curpos = 0;
do {
$pos = strpos($lowertext, '[/quote', $curpos);
@ -230,7 +230,7 @@ function strip_quotes($text)
do {
// build a stack that represents when a quote tag is opened
// and add non-quote text to the new string
$stack = array();
$stack = [];
$newtext = '[...] ';
$substr_pos = 0;
foreach ($pos_list as $pos => $type) {
@ -278,8 +278,8 @@ function strip_quotes($text)
*/
function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $showlinks = true)
{
$find = array();
$replace = array();
$find = [];
$replace = [];
if ($stripquotes) {
// [quote=username] and [quote]
@ -315,7 +315,7 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s
$message = str_replace($m[0], $m[2], $message);
}
$replace = array('[*]', '[hr]', '[br]', '[align=center]', '[align=left]', '[align=right]');
$replace = ['[*]', '[hr]', '[br]', '[align=center]', '[align=left]', '[align=right]'];
$message = str_replace($replace, ' ', $message);
}
@ -331,7 +331,7 @@ function extract_search_words($text)
$max_word_len = $bb_cfg['search_max_word_len'];
$text = ' ' . str_compact(strip_tags(mb_strtolower($text))) . ' ';
$text = str_replace(array('&#91;', '&#93;'), array('[', ']'), $text);
$text = str_replace(['&#91;', '&#93;'], ['[', ']'], $text);
// HTML entities like &nbsp;
$text = preg_replace('/(\w*?)&#?[0-9a-z]+;(\w*?)/iu', '', $text);
@ -348,7 +348,7 @@ function extract_search_words($text)
$text = array_unique(explode(' ', str_compact($text)));
// short & long words 2
$text_out = array();
$text_out = [];
foreach ($text as $word) {
if (mb_strlen($word) > $min_word_len && mb_strlen($word) <= $max_word_len) {
$text_out[] = $word;
@ -368,7 +368,7 @@ function add_search_words($post_id, $post_message, $topic_title = '', $only_retu
global $bb_cfg;
$text = $topic_title . ' ' . $post_message;
$words = ($text) ? extract_search_words($text) : array();
$words = ($text) ? extract_search_words($text) : [];
if ($only_return_words || $bb_cfg['search_engine_type'] == 'sphinx') {
return implode("\n", $words);
@ -393,8 +393,8 @@ function bbcode2html($text)
if (!isset($bbcode)) {
$bbcode = new TorrentPier\Legacy\BBCode();
}
$orig_word = array();
$replacement_word = array();
$orig_word = [];
$replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
if (count($orig_word)) {
$text = preg_replace($orig_word, $replacement_word, $text);
@ -429,10 +429,10 @@ function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
// Posts cache
if ($bb_cfg['use_posts_cache']) {
DB()->shutdown['post_html'][] = array(
DB()->shutdown['post_html'][] = [
'post_id' => (int)$postrow['post_id'],
'post_html' => (string)$message,
);
'post_html' => (string)$message
];
}
return $message;

View file

@ -35,7 +35,7 @@ if ($cron_jobs) {
require(CRON_DIR . 'cron_run.php');
// Update cron_last_check
bb_update_config(array('cron_last_check' => TIMENOW + 10));
bb_update_config(['cron_last_check' => TIMENOW + 10]);
} else {
bb_log(date('H:i:s - ') . getmypid() . ' --x- no active jobs found ----------------------------------------------' . LOG_LF, CRON_LOG_DIR . '/cron_check');
}

View file

@ -50,7 +50,7 @@ foreach ($cron_jobs as $job) {
$cron_sql_log_file = CRON_LOG_DIR . '/SQL-' . basename($job['cron_script']);
if ($cron_write_log) {
$msg = array();
$msg = [];
$msg[] = 'start';
$msg[] = date('m-d');
$msg[] = date('H:i:s');
@ -74,7 +74,7 @@ foreach ($cron_jobs as $job) {
}
if ($cron_write_log) {
$msg = array();
$msg = [];
$msg[] = ' end';
$msg[] = date('m-d');
$msg[] = date('H:i:s');

View file

@ -21,8 +21,8 @@ $db_max_packet = 800000;
$sql_limit = 3000;
$check_attachments = false;
$orphan_files = $orphan_db_attach = $orphan_tor = array();
$posts_without_attach = $topics_without_attach = array();
$orphan_files = $orphan_db_attach = $orphan_tor = [];
$posts_without_attach = $topics_without_attach = [];
DB()->query("
CREATE TEMPORARY TABLE $tmp_attach_tbl (
@ -38,7 +38,7 @@ $attach_dir = get_attachments_dir();
// Get all names of existed attachments and insert them into $tmp_attach_tbl
if ($dir = @opendir($attach_dir)) {
$check_attachments = true;
$files = array();
$files = [];
$f_len = 0;
while (false !== ($f = readdir($dir))) {
@ -52,7 +52,7 @@ if ($dir = @opendir($attach_dir)) {
if ($f_len > $db_max_packet) {
$files = implode(',', $files);
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
$files = array();
$files = [];
$f_len = 0;
}
}

View file

@ -12,14 +12,14 @@ if (!defined('BB_ROOT')) {
}
// Delete staled dl-status records
$keeping_dlstat = array(
$keeping_dlstat = [
DL_STATUS_WILL => (int)$bb_cfg['dl_will_days_keep'],
DL_STATUS_DOWN => (int)$bb_cfg['dl_down_days_keep'],
DL_STATUS_COMPLETE => (int)$bb_cfg['dl_complete_days_keep'],
DL_STATUS_CANCEL => (int)$bb_cfg['dl_cancel_days_keep'],
);
DL_STATUS_CANCEL => (int)$bb_cfg['dl_cancel_days_keep']
];
$delete_dlstat_sql = array();
$delete_dlstat_sql = [];
foreach ($keeping_dlstat as $dl_status => $days_to_keep) {
if ($days_to_keep) {

View file

@ -12,10 +12,10 @@ if (!defined('BB_ROOT')) {
}
// Lock tables
DB()->lock(array(
DB()->lock([
BB_TOPICS . ' t',
BUF_TOPIC_VIEW . ' buf',
));
BUF_TOPIC_VIEW . ' buf'
]);
// Flash buffered records
DB()->query("

View file

@ -16,7 +16,7 @@ $users_per_cycle = 1000;
while (true) {
@set_time_limit(600);
$prune_users = $not_activated_users = $not_active_users = array();
$prune_users = $not_activated_users = $not_active_users = [];
if ($not_activated_days = (int)$bb_cfg['user_not_activated_days_keep']) {
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "

View file

@ -18,10 +18,10 @@ $user_session_gc_time = $user_session_expire_time - (int)$bb_cfg['user_session_g
$admin_session_gc_time = $admin_session_expire_time;
// ############################ Tables LOCKED ################################
DB()->lock(array(
DB()->lock([
BB_USERS . ' u',
BB_SESSIONS . ' s',
));
BB_SESSIONS . ' s'
]);
// Update user's session time
DB()->query("

View file

@ -29,10 +29,10 @@ DB()->expect_slow_query(600);
// Update dlstat (part 1)
if ($bb_cfg['tracker']['update_dlstat']) {
// ############################ Tables LOCKED ################################
DB()->lock(array(
DB()->lock([
BB_BT_TRACKER,
NEW_BB_BT_LAST_TORSTAT,
));
NEW_BB_BT_LAST_TORSTAT
]);
// Get PER TORRENT user's dlstat from tracker
DB()->query("

View file

@ -19,7 +19,7 @@ $last_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_last_seen_days_keep'];
$never_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_never_seen_days_keep'];
$limit_sql = 3000;
$topics_sql = $attach_sql = array();
$topics_sql = $attach_sql = [];
$sql = "SELECT topic_id, attach_id
FROM " . BB_BT_TORRENTS . "

View file

@ -35,7 +35,7 @@ while (true) {
set_time_limit(600);
$end_id = $start_id + $per_cycle - 1;
$val = array();
$val = [];
if (!$bb_cfg['ocelot']['enabled']) {
$sql = "
@ -135,7 +135,7 @@ if ($bb_cfg['torhelp_enabled']) {
$tor_downloaded_days_ago = 60; // ">="
$user_last_seen_online = 15; // minutes
$users_limit = 3000;
$dl_status_ary = array(DL_STATUS_COMPLETE);
$dl_status_ary = [DL_STATUS_COMPLETE];
define('NEW_BB_BT_TORHELP', 'new_torhelp');
define('OLD_BB_BT_TORHELP', 'old_torhelp');
@ -153,7 +153,7 @@ if ($bb_cfg['torhelp_enabled']) {
ORDER BY session_time DESC
LIMIT $users_limit
";
$online_users_ary = array();
$online_users_ary = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$online_users_ary[] = $row['uid'];

View file

@ -16,23 +16,23 @@ global $bf, $bb_cfg;
//
// cat_forums
//
$data = array(
'not_auth_forums' => array(
'guest_view' => array(),
'guest_read' => array(),
'user_view' => array(),
'user_read' => array(),
),
'tracker_forums' => array(),
'cat_title_html' => array(),
'forum_name_html' => array(),
'c' => array(), // also has $data['c']['cat_id']['forums'] key
'f' => array(), // also has $data['f']['forum_id']['subforums'] key
);
$data = [
'not_auth_forums' => [
'guest_view' => [],
'guest_read' => [],
'user_view' => [],
'user_read' => []
],
'tracker_forums' => [],
'cat_title_html' => [],
'forum_name_html' => [],
'c' => [], // also has $data['c']['cat_id']['forums'] key
'f' => [] // also has $data['f']['forum_id']['subforums'] key
];
// Store only these fields from BB_FORUMS in $data['f']
$forum_store_fields = array_flip(array_keys($bf['forum_perm']));
$forum_store_fields += array_flip(array(
$forum_store_fields += array_flip([
'forum_id',
'cat_id',
'forum_name',
@ -40,8 +40,8 @@ $forum_store_fields += array_flip(array(
'forum_status',
'forum_posts',
'forum_topics',
'forum_parent',
));
'forum_parent'
]);
// Categories
$sql = "SELECT * FROM " . BB_CATEGORIES . " ORDER BY cat_order";
@ -106,10 +106,10 @@ $this->store('cat_forums', $data);
//
// jumpbox
//
$data = array(
$data = [
'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'viewforum.php?f=\'+this.value;"'),
'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'viewforum.php?f=\'+this.value;"'),
);
];
$this->store('jumpbox', $data);
@ -119,9 +119,7 @@ file_write($data['user'], AJAX_HTML_DIR . '/jumpbox_user.html', false, true, tru
//
// viewtopic_forum_select
//
$data = array(
'viewtopic_forum_select' => get_forum_select('admin', 'new_forum_id'),
);
$data = ['viewtopic_forum_select' => get_forum_select('admin', 'new_forum_id')];
$this->store('viewtopic_forum_select', $data);

View file

@ -11,14 +11,14 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$data = array(
'name_users' => array(), // only by personal permissions
'name_groups' => array(), // only visible to all users
'mod_users' => array(), // only by personal permissions
'mod_groups' => array(), // only visible to all users
'moderators' => array(), // all moderators
'admins' => array(), // all admins
);
$data = [
'name_users' => [], // only by personal permissions
'name_groups' => [], // only visible to all users
'mod_users' => [], // only by personal permissions
'mod_groups' => [], // only visible to all users
'moderators' => [], // all moderators
'admins' => [] // all admins
];
// name_users
// mod_users

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$ranks = array();
$ranks = [];
$sql = "SELECT * FROM " . BB_RANKS;

View file

@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
global $bb_cfg;
$smilies = array();
$smilies = [];
$rowset = DB()->fetch_rowset("SELECT * FROM " . BB_SMILIES);
sort($rowset);

View file

@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
global $bb_cfg;
$data = array();
$data = [];
// usercount
$row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")");
@ -68,27 +68,27 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled']) {
$date_today = bb_date(TIMENOW, 'md', false);
$date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day'] * 86400), 'md', false);
$birthday_today_list = $birthday_week_list = array();
$birthday_today_list = $birthday_week_list = [];
foreach ($sql as $row) {
$user_birthday = bb_date(strtotime($row['user_birthday']), 'md', false);
if ($user_birthday > $date_today && $user_birthday <= $date_forward) {
// user are having birthday within the next days
$birthday_week_list[] = array(
$birthday_week_list[] = [
'user_id' => $row['user_id'],
'username' => $row['username'],
'user_rank' => $row['user_rank'],
'user_birthday' => $row['user_birthday'],
);
'user_birthday' => $row['user_birthday']
];
} elseif ($user_birthday == $date_today) {
//user have birthday today
$birthday_today_list[] = array(
$birthday_today_list[] = [
'user_id' => $row['user_id'],
'username' => $row['username'],
'user_rank' => $row['user_rank'],
'user_birthday' => $row['user_birthday'],
);
'user_birthday' => $row['user_birthday']
];
}
}

View file

@ -260,13 +260,13 @@ function setbit(&$int, $bit_num, $on)
forum auth levels, this will prevent the auth function having to do its own
lookup
*/
function auth($type, $forum_id, $ug_data, array $f_access = array(), $group_perm = UG_PERM_BOTH)
function auth($type, $forum_id, $ug_data, array $f_access = [], $group_perm = UG_PERM_BOTH)
{
global $lang, $bf, $datastore;
$is_guest = true;
$is_admin = false;
$auth = $auth_fields = $u_access = array();
$auth = $auth_fields = $u_access = [];
$add_auth_type_desc = ($forum_id != AUTH_LIST_ALL);
//
@ -437,7 +437,7 @@ function delta_time($timestamp_1, $timestamp_2 = TIMENOW, $granularity = 'auto')
function get_select($select, $selected = null, $return_as = 'html', $first_opt = '&raquo;&raquo; Выбрать ')
{
$select_name = null;
$select_ary = array();
$select_ary = [];
switch ($select) {
case 'groups':
@ -680,13 +680,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
{
if (!$cookie && isset($_COOKIE[$var_name])) {
if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) {
return (is_array($default)) ? array() : $default;
return (is_array($default)) ? [] : $default;
}
$_REQUEST[$var_name] = $_POST[$var_name] ?? $_GET[$var_name];
}
if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) {
return (is_array($default)) ? array() : $default;
return (is_array($default)) ? [] : $default;
}
$var = $_REQUEST[$var_name];
@ -708,7 +708,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
if (is_array($var)) {
$_var = $var;
$var = array();
$var = [];
foreach ($_var as $k => $v) {
set_var($k, $k, $key_type);
@ -737,10 +737,10 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
function get_username($user_id)
{
if (empty($user_id)) {
return is_array($user_id) ? array() : false;
return is_array($user_id) ? [] : false;
}
if (is_array($user_id)) {
$usernames = array();
$usernames = [];
foreach (DB()->fetch_rowset("SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN(" . get_id_csv($user_id) . ")") as $row) {
$usernames[$row['user_id']] = $row['username'];
}
@ -893,7 +893,7 @@ function get_attachments_dir($cfg = null)
function bb_get_config($table, $from_db = false, $update_cache = true)
{
if ($from_db or !$cfg = CACHE('bb_config')->get("config_{$table}")) {
$cfg = array();
$cfg = [];
foreach (DB()->fetch_rowset("SELECT * FROM $table") as $row) {
$cfg[$row['config_name']] = $row['config_value'];
}
@ -906,7 +906,7 @@ function bb_get_config($table, $from_db = false, $update_cache = true)
function bb_update_config($params, $table = BB_CONFIG)
{
$updates = array();
$updates = [];
foreach ($params as $name => $val) {
$updates[] = array(
'config_name' => $name,
@ -1038,7 +1038,7 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
if (null === $max_length) {
$max_length = HTML_SELECT_MAX_LENGTH;
}
$select = null === $all_forums_option ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option);
$select = null === $all_forums_option ? [] : array($lang['ALL_AVAILABLE'] => $all_forums_option);
if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums');
$forums = $datastore->get('cat_forums');
@ -1889,17 +1889,20 @@ function profile_url($data)
return $profile;
}
function get_avatar($user_id, $ext_id, $allow_avatar = true)
function get_avatar($user_id, $ext_id, $allow_avatar = true, $height = '', $width = '')
{
global $bb_cfg;
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['no_avatar']) . '" alt="' . $user_id . '" />';
$height = $height ? 'height="' . $height . '"' : '';
$width = $width ? 'width="' . $width . '"' : '';
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['no_avatar']) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
if ($user_id == BOT_UID && $bb_cfg['avatars']['bot_avatar']) {
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['bot_avatar']) . '" alt="' . $user_id . '" />';
$user_avatar = '<img src="' . make_url($bb_cfg['avatars']['display_path'] . $bb_cfg['avatars']['bot_avatar']) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
} elseif ($allow_avatar && $ext_id) {
if (file_exists(get_avatar_path($user_id, $ext_id))) {
$user_avatar = '<img src="' . make_url(get_avatar_path($user_id, $ext_id, $bb_cfg['avatars']['display_path'])) . '" alt="' . $user_id . '" />';
$user_avatar = '<img src="' . make_url(get_avatar_path($user_id, $ext_id, $bb_cfg['avatars']['display_path'])) . '" alt="' . $user_id . '" ' . $height . ' ' . $width . ' />';
}
}

View file

@ -46,7 +46,7 @@ $sql = "
foreach (DB()->fetch_rowset($sql) as $u) {
if ($u['session_logged_in']) {
$stat = array();
$stat = [];
$name = profile_url($u);
$level = $u['user_level'];
@ -85,7 +85,7 @@ foreach (DB()->fetch_rowset($sql) as $u) {
}
if ($ulist) {
$inline = $block = $short = array();
$inline = $block = $short = [];
foreach ($ulist as $level => $users) {
if (empty($users)) {

View file

@ -222,7 +222,7 @@ if (!empty($bb_cfg['page']['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torh
WHERE topic_id IN(" . $userdata['torhelp'] . ")
LIMIT 8
";
$torhelp_topics = array();
$torhelp_topics = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$torhelp_topics[] = '<a href="viewtopic.php?t=' . $row['topic_id'] . '">' . $row['topic_title'] . '</a>';
@ -236,7 +236,7 @@ if (!empty($bb_cfg['page']['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torh
// Login box
$in_out = ($logged_in) ? 'in' : 'out';
$template->assign_block_vars("switch_user_logged_{$in_out}", array());
$template->assign_block_vars("switch_user_logged_{$in_out}", []);
if (!IS_GUEST) {
header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');

View file

@ -21,7 +21,7 @@ if (!$forum_id || !$f_data = DB()->fetch_row($sql)) {
bb_die($lang['FORUM_NOT_EXIST']);
}
// tpl_data
$tpl_data = array();
$tpl_data = [];
$sql = "SELECT * FROM " . BB_TOPIC_TPL . " WHERE tpl_id = {$f_data['forum_tpl_id']} LIMIT 1";
if (!$f_data['forum_tpl_id'] || !$tpl_data = DB()->fetch_row($sql)) {

View file

@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
$announce_urls = array();
$announce_urls = [];
// Here you can define additional allowed announce urls
// For example, if you want to add http://demo.torrentpier.com

View file

@ -34,7 +34,7 @@ if (($is_auth['auth_mod']) && ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL)) {
$template->assign_vars(array('S_DL_DELETE' => $s_dl_delete));
}
$dl_cat = $dl_count = array();
$dl_cat = $dl_count = [];
if ($show_dl_list) {
foreach ($dl_status_css as $i => $desc) {
@ -58,9 +58,9 @@ if ($show_dl_list) {
if ($dl_info = DB()->fetch_rowset($sql)) {
if ($count_mode) {
$template->assign_block_vars('dl_counts', array());
$template->assign_block_vars('dl_counts', []);
} else {
$template->assign_block_vars('dl_users', array());
$template->assign_block_vars('dl_users', []);
}
foreach ($dl_info as $rid => $u) {
@ -99,7 +99,7 @@ if ($show_dl_list) {
}
}
} else {
$template->assign_block_vars('dl_list_none', array());
$template->assign_block_vars('dl_list_none', []);
}
}

View file

@ -54,12 +54,12 @@ if (isset($_POST['bonus_id'])) {
bb_die($message);
} else {
$template->assign_vars(array(
$template->assign_vars([
'U_USER_PROFILE' => PROFILE_URL . $user_id,
'S_MODE_ACTION' => BONUS_URL,
'PAGE_TITLE' => $lang['EXCHANGE_BONUS'],
'MY_BONUS' => sprintf($lang['MY_BONUS'], $user_points),
));
'MY_BONUS' => sprintf($lang['MY_BONUS'], $user_points)
]);
foreach ($price_row as $i => $price) {
if (!$price || !$upload_row[$i]) {
@ -67,12 +67,12 @@ if (isset($_POST['bonus_id'])) {
}
$class = ($user_points >= $price) ? 'seed' : 'leech';
$template->assign_block_vars('bonus_upload', array(
$template->assign_block_vars('bonus_upload', [
'ROW_CLASS' => !($i % 2) ? 'row2' : 'row1',
'ID' => $i,
'DESC' => sprintf($lang['BONUS_UPLOAD_DESC'], humn_size($upload_row[$i] * 1024 * 1024 * 1024)),
'PRICE' => sprintf($lang['BONUS_UPLOAD_PRICE'], $class, sprintf('%.2f', $price)),
));
'PRICE' => sprintf($lang['BONUS_UPLOAD_PRICE'], $class, sprintf('%.2f', $price))
]);
}
print_page('usercp_bonus.tpl');

View file

@ -28,7 +28,7 @@ if (!$userdata['session_logged_in']) {
redirect(LOGIN_URL . "?redirect=profile.php&mode=email&" . POST_USERS_URL . "=$user_id");
}
$errors = array();
$errors = [];
$sql = "SELECT username, user_id, user_rank, user_email, user_lang
FROM " . BB_USERS . "
@ -60,12 +60,12 @@ if ($row = DB()->fetch_row($sql)) {
$emailer->set_subject($subject);
$emailer->set_template('profile_send_email', $user_lang);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'FROM_USERNAME' => $userdata['username'],
'TO_USERNAME' => $username,
'MESSAGE' => $message,
));
'MESSAGE' => $message
]);
$emailer->send();
@ -73,12 +73,12 @@ if ($row = DB()->fetch_row($sql)) {
}
}
$template->assign_vars(array(
$template->assign_vars([
'USERNAME' => profile_url($row),
'S_HIDDEN_FIELDS' => '',
'S_POST_ACTION' => "profile.php?mode=email&amp;" . POST_USERS_URL . "=$user_id",
'ERROR_MESSAGE' => ($errors) ? implode('<br />', array_unique($errors)) : '',
));
'ERROR_MESSAGE' => ($errors) ? implode('<br />', array_unique($errors)) : ''
]);
print_page('usercp_email.tpl');

View file

@ -23,22 +23,20 @@ if (IS_ADMIN) {
$gen_simple_header = true;
}
$template->assign_vars(array(
'NEW_USER' => $new_user,
));
$template->assign_vars(['NEW_USER' => $new_user]);
}
$can_register = (IS_GUEST || IS_ADMIN);
$submit = !empty($_POST['submit']);
$errors = array();
$errors = [];
$adm_edit = false; // редактирование админом чужого профиля
require INC_DIR . '/bbcode.php';
$pr_data = array(); // данные редактируемого либо регистрационного профиля
$db_data = array(); // данные для базы: регистрационные либо измененные данные юзера
$tp_data = array(); // данные для tpl
$pr_data = []; // данные редактируемого либо регистрационного профиля
$db_data = []; // данные для базы: регистрационные либо измененные данные юзера
$tp_data = []; // данные для tpl
// Данные профиля
switch ($mode) {
@ -69,16 +67,16 @@ switch ($mode) {
}
// field => can_edit
$profile_fields = array(
$profile_fields = [
'username' => true,
'user_password' => true,
'user_email' => true,
'user_timezone' => true,
'user_lang' => true,
'user_opt' => true,
);
'user_opt' => true
];
$pr_data = array(
$pr_data = [
'user_id' => GUEST_UID,
'username' => '',
'user_password' => '',
@ -86,8 +84,8 @@ switch ($mode) {
'user_timezone' => $bb_cfg['board_timezone'],
'user_lang' => $bb_cfg['default_lang'],
'user_opt' => 0,
'avatar_ext_id' => 0,
);
'avatar_ext_id' => 0
];
break;
/**
@ -99,7 +97,7 @@ switch ($mode) {
}
// field => can_edit
$profile_fields = array(
$profile_fields = [
'user_active' => IS_ADMIN,
'username' => IS_ADMIN || $bb_cfg['allow_namechange'],
'user_password' => true,
@ -118,8 +116,8 @@ switch ($mode) {
'user_sig' => true,
'user_occ' => true,
'user_interests' => true,
'tpl_name' => true,
);
'tpl_name' => true
];
// Выбор профиля: для юзера свой, для админа любой
if (IS_ADMIN && !empty($_REQUEST['u'])) {
@ -322,7 +320,7 @@ foreach ($profile_fields as $field => $can_edit) {
$user_opt = $pr_data['user_opt'];
$reg_mode = ($mode == 'register');
$update_user_opt = array(
$update_user_opt = [
# 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change
'user_viewemail' => $reg_mode ? false : true,
'user_viewonline' => $reg_mode ? false : true,
@ -332,7 +330,7 @@ foreach ($profile_fields as $field => $can_edit) {
'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) {
if ($submit && (isset($_POST[$opt]) && $can_change_opt || $reg_mode)) {
@ -571,13 +569,13 @@ if ($submit && !$errors) {
$emailer->set_subject($email_subject);
$emailer->set_template($email_template, $user_lang);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'WELCOME_MSG' => sprintf($lang['WELCOME_SUBJECT'], $bb_cfg['sitename']),
'USERNAME' => html_entity_decode($username),
'PASSWORD' => $new_pass,
'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $new_user_id . '&act_key=' . $db_data['user_actkey'])
));
]);
$emailer->send();
}
@ -603,11 +601,11 @@ if ($submit && !$errors) {
$emailer->set_subject($lang['EMAILER_SUBJECT']['USER_ACTIVATE']);
$emailer->set_template('user_activate', $pr_data['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'USERNAME' => html_entity_decode($username),
'U_ACTIVATE' => make_url("profile.php?mode=activate&u={$pr_data['user_id']}&act_key=$user_actkey"),
));
]);
$emailer->send();
@ -646,7 +644,7 @@ if ($submit && !$errors) {
$template->assign_vars($tp_data);
$template->assign_vars(array(
$template->assign_vars([
'PAGE_TITLE' => ($mode == 'editprofile') ? $lang['EDIT_PROFILE'] . ($adm_edit ? " :: {$pr_data['username']}" : '') : $lang['REGISTER'],
'SHOW_REG_AGREEMENT' => ($mode == 'register' && !IS_ADMIN),
'ERROR_MESSAGE' => ($errors) ? implode('<br />', array_unique($errors)) : '',
@ -671,6 +669,6 @@ $template->assign_vars(array(
'PR_USER_ID' => $pr_data['user_id'],
'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&amp;reset_autologin=1&amp;sid={$userdata['session_id']}",
));
]);
print_page('usercp_register.tpl');

View file

@ -30,7 +30,7 @@ if (isset($_POST['submit'])) {
if (!$row['user_active']) {
bb_die($lang['NO_SEND_ACCOUNT_INACTIVE']);
}
if (in_array($row['user_level'], array(MOD, ADMIN))) {
if (in_array($row['user_level'], [MOD, ADMIN])) {
bb_die($lang['NO_SEND_ACCOUNT']);
}
@ -54,12 +54,12 @@ if (isset($_POST['submit'])) {
$emailer->set_subject($lang['EMAILER_SUBJECT']['USER_ACTIVATE_PASSWD']);
$emailer->set_template('user_activate_passwd', $row['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'SITENAME' => $bb_cfg['sitename'],
'USERNAME' => $username,
'PASSWORD' => $user_password,
'U_ACTIVATE' => make_url('profile.php?mode=activate&' . POST_USERS_URL . '=' . $user_id . '&act_key=' . $user_actkey)
));
]);
$emailer->send();
@ -74,12 +74,12 @@ if (isset($_POST['submit'])) {
$email = $username = '';
}
$template->assign_vars(array(
$template->assign_vars([
'USERNAME' => $username,
'EMAIL' => $email,
'CAPTCHA_HTML' => ($need_captcha) ? bb_captcha('get') : '',
'S_HIDDEN_FIELDS' => '',
'S_PROFILE_ACTION' => "profile.php?mode=sendpassword",
));
'S_PROFILE_ACTION' => 'profile.php?mode=sendpassword'
]);
print_page('usercp_sendpasswd.tpl');

View file

@ -28,10 +28,10 @@ if (isset($_POST['topic_id_list'])) {
}
}
$template->assign_vars(array(
$template->assign_vars([
'PAGE_TITLE' => $lang['WATCHED_TOPICS'],
'S_FORM_ACTION' => BB_ROOT . 'profile.php?mode=watch',
));
'S_FORM_ACTION' => BB_ROOT . 'profile.php?mode=watch'
]);
$sql = "SELECT COUNT(topic_id) as watch_count FROM " . BB_TOPICS_WATCH . " WHERE user_id = $user_id";
if (!($result = DB()->sql_query($sql))) {
@ -62,7 +62,7 @@ if ($watch_count > 0) {
for ($i = 0, $iMax = count($watch); $i < $iMax; $i++) {
$is_unread = is_unread($watch[$i]['topic_last_post_time'], $watch[$i]['topic_id'], $watch[$i]['forum_id']);
$template->assign_block_vars('watch', array(
$template->assign_block_vars('watch', [
'ROW_CLASS' => (!($i % 2)) ? 'row1' : 'row2',
'POST_ID' => $watch[$i]['topic_first_post_id'],
'TOPIC_ID' => $watch[$i]['topic_id'],
@ -73,21 +73,21 @@ if ($watch_count > 0) {
'U_FORUM' => FORUM_URL . $watch[$i]['forum_id'],
'REPLIES' => $watch[$i]['topic_replies'],
'AUTHOR' => profile_url($watch[$i]),
'LAST_POST' => bb_date($watch[$i]['topic_last_post_time']) . '<br />' . profile_url(array('user_id' => $watch[$i]['last_user_id'], 'username' => $watch[$i]['last_username'], 'user_rank' => $watch[$i]['last_user_rank'])),
'LAST_POST' => bb_date($watch[$i]['topic_last_post_time']) . '<br />' . profile_url(['user_id' => $watch[$i]['last_user_id'], 'username' => $watch[$i]['last_username'], 'user_rank' => $watch[$i]['last_user_rank']]),
'LAST_POST_ID' => $watch[$i]['topic_last_post_id'],
'IS_UNREAD' => $is_unread,
'TOPIC_ICON' => get_topic_icon($watch[$i], $is_unread),
'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], $bb_cfg['posts_per_page']),
));
'PAGINATION' => ($watch[$i]['topic_status'] == TOPIC_MOVED) ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], $bb_cfg['posts_per_page'])
]);
}
$template->assign_vars(array(
$template->assign_vars([
'MATCHES' => (count($watch) == 1) ? sprintf($lang['FOUND_SEARCH_MATCH'], count($watch)) : sprintf($lang['FOUND_SEARCH_MATCHES'], count($watch)),
'PAGINATION' => generate_pagination(BB_ROOT . 'profile.php?mode=watch', $watch_count, $per_page, $start),
'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], (floor($start / $per_page) + 1), ceil($watch_count / $per_page)),
'U_PER_PAGE' => BB_ROOT . 'profile.php?mode=watch',
'PER_PAGE' => $per_page,
));
'PER_PAGE' => $per_page
]);
}
DB()->sql_freeresult($result);
} else {

View file

@ -13,10 +13,10 @@ if (!defined('BB_ROOT')) {
require INC_DIR . '/bbcode.php';
$datastore->enqueue(array(
$datastore->enqueue([
'ranks',
'cat_forums',
));
'cat_forums'
]);
if (!$userdata['session_logged_in']) {
redirect(LOGIN_URL . "?redirect={$_SERVER['REQUEST_URI']}");
@ -42,7 +42,7 @@ if ($user_rank = $profiledata['user_rank'] and isset($ranks[$user_rank])) {
$rank_style = $ranks[$user_rank]['rank_style'];
}
if (IS_ADMIN) {
$rank_select = array($lang['NONE'] => 0);
$rank_select = [$lang['NONE'] => 0];
foreach ($ranks as $row) {
$rank_select[$row['rank_title']] = $row['rank_id'];
}
@ -74,7 +74,7 @@ if (bf($profiledata['user_opt'], 'user_opt', 'dis_sig')) {
$signature = bbcode2html($signature);
}
$template->assign_vars(array(
$template->assign_vars([
'PAGE_TITLE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
'USERNAME' => $profiledata['username'],
'PROFILE_USER_ID' => $profiledata['user_id'],
@ -117,10 +117,10 @@ $template->assign_vars(array(
'SHOW_ROLE' => (IS_AM || $profile_user_id || $profiledata['user_active']),
'GROUP_MEMBERSHIP' => false,
'TRAF_STATS' => !(IS_AM || $profile_user_id),
));
]);
if (IS_ADMIN) {
$group_membership = array();
$group_membership = [];
$sql = "
SELECT COUNT(g.group_id) AS groups_cnt, g.group_single_user, ug.user_pending
FROM " . BB_USER_GROUP . " ug
@ -151,14 +151,12 @@ if (IS_ADMIN) {
}
$group_membership = implode(', ', $group_membership);
}
$template->assign_vars(array(
$template->assign_vars([
'GROUP_MEMBERSHIP' => (bool)$group_membership,
'GROUP_MEMBERSHIP_TXT' => $group_membership,
));
'GROUP_MEMBERSHIP_TXT' => $group_membership
]);
} elseif (IS_MOD) {
$template->assign_vars(array(
'SHOW_GROUP_MEMBERSHIP' => ($profiledata['user_level'] != USER),
));
$template->assign_vars(['SHOW_GROUP_MEMBERSHIP' => ($profiledata['user_level'] != USER)]);
}
// Show users torrent-profile
@ -170,14 +168,14 @@ if (IS_AM || $profile_user_id || !bf($profiledata['user_opt'], 'user_opt', 'user
if (IS_AM || $profile_user_id) {
show_bt_userdata($profiledata['user_id']);
} else {
$template->assign_vars(array(
$template->assign_vars([
'DOWN_TOTAL_BYTES' => false,
'MIN_DL_BYTES' => false,
));
]);
}
if (IS_ADMIN) {
$ajax_user_opt = json_encode(array(
$ajax_user_opt = json_encode([
'dis_avatar' => bf($profiledata['user_opt'], 'user_opt', 'dis_avatar'),
'dis_sig' => bf($profiledata['user_opt'], 'user_opt', 'dis_sig'),
'dis_passkey' => bf($profiledata['user_opt'], 'user_opt', 'dis_passkey'),
@ -185,17 +183,17 @@ if (IS_ADMIN) {
'dis_post' => bf($profiledata['user_opt'], 'user_opt', 'dis_post'),
'dis_post_edit' => bf($profiledata['user_opt'], 'user_opt', 'dis_post_edit'),
'dis_topic' => bf($profiledata['user_opt'], 'user_opt', 'dis_topic'),
), JSON_THROW_ON_ERROR);
], JSON_THROW_ON_ERROR);
$template->assign_vars(array(
$template->assign_vars([
'EDITABLE_TPLS' => true,
'AJAX_USER_OPT' => $ajax_user_opt,
'U_MANAGE' => "profile.php?mode=editprofile&amp;u={$profiledata['user_id']}",
'U_PERMISSIONS' => "admin/admin_ug_auth.php?mode=user&amp;u={$profiledata['user_id']}",
));
]);
}
$user_restrictions = array();
$user_restrictions = [];
if (bf($profiledata['user_opt'], 'user_opt', 'dis_avatar')) {
$user_restrictions[] = $lang['HIDE_AVATARS'];

View file

@ -11,7 +11,7 @@ if (!defined('IN_PROFILE')) {
die(basename(__FILE__));
}
$releasing = $seeding = $leeching = array();
$releasing = $seeding = $leeching = [];
$releasing_count = $seeding_count = $leeching_count = 0;
// Auth
@ -51,7 +51,7 @@ if ($releasing) {
foreach ($releasing as $i => $row) {
$topic_title = wbr($row['topic_title']);
$template->assign_block_vars('released', array(
$template->assign_block_vars('released', [
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'FORUM_NAME' => htmlCHR($row['forum_name']),
'TOPIC_TITLE' => ($row['update_time']) ? $topic_title : "<s>$topic_title</s>",
@ -61,7 +61,7 @@ if ($releasing) {
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_UP' => ($row['speed_up']) ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-',
));
]);
$releasing_count++;
}
@ -71,7 +71,7 @@ if ($seeding) {
foreach ($seeding as $i => $row) {
$topic_title = wbr($row['topic_title']);
$template->assign_block_vars('seed', array(
$template->assign_block_vars('seed', [
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'FORUM_NAME' => htmlCHR($row['forum_name']),
'TOPIC_TITLE' => ($row['update_time']) ? $topic_title : "<s>$topic_title</s>",
@ -81,7 +81,7 @@ if ($seeding) {
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_UP' => ($row['speed_up']) ? humn_size($row['speed_up'], 0, 'KB') . '/s' : '-',
));
]);
$seeding_count++;
}
@ -93,7 +93,7 @@ if ($leeching) {
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $row['size']) : 0;
$topic_title = wbr($row['topic_title']);
$template->assign_block_vars('leech', array(
$template->assign_block_vars('leech', [
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'FORUM_NAME' => htmlCHR($row['forum_name']),
'TOPIC_TITLE' => ($row['update_time']) ? $topic_title : "<s>$topic_title</s>",
@ -104,17 +104,17 @@ if ($leeching) {
'TOPIC_SEEDERS' => ($row['seeders']) ?: 0,
'TOPIC_LEECHERS' => ($row['leechers']) ?: 0,
'SPEED_DOWN' => ($row['speed_down']) ? humn_size($row['speed_down'], 0, 'KB') . '/s' : '-',
));
]);
$leeching_count++;
}
}
$template->assign_vars(array(
$template->assign_vars([
'SHOW_SEARCH_DL' => IS_AM || $profile_user_id,
'USERNAME' => $profiledata['username'],
'L_RELEASINGS' => "{$lang['RELEASING']}: " . (($releasing_count) ? "<b>$releasing_count</b>" : '0'),
'L_SEEDINGS' => "{$lang['SEEDING']}: " . (($seeding_count) ? "<b>$seeding_count</b>" : '0'),
'L_LEECHINGS' => "{$lang['LEECHING']}: " . (($leeching_count) ? "<b>$leeching_count</b>" : '0'),
'USER_DLS' => $releasing_count || $seeding_count || $leeching_count,
));
'USER_DLS' => $releasing_count || $seeding_count || $leeching_count
]);

View file

@ -26,7 +26,7 @@ if (!empty($_GET['logout'])) {
}
$redirect_url = "index.php";
$login_errors = array();
$login_errors = [];
// Requested redirect
if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING'], $matches)) {
@ -112,7 +112,7 @@ if (isset($_POST['login'])) {
// Login page
if (IS_GUEST || $mod_admin_login) {
$template->assign_vars(array(
$template->assign_vars([
'LOGIN_USERNAME' => htmlCHR($login_username),
'LOGIN_PASSWORD' => htmlCHR($login_password),
'ERROR_MESSAGE' => implode('<br />', $login_errors),
@ -120,8 +120,8 @@ if (IS_GUEST || $mod_admin_login) {
'REDIRECT_URL' => htmlCHR($redirect_url),
'CAPTCHA_HTML' => ($need_captcha && !$bb_cfg['captcha']['disabled']) ? bb_captcha('get') : '',
'PAGE_TITLE' => $lang['LOGIN'],
'S_LOGIN_ACTION' => LOGIN_URL,
));
'S_LOGIN_ACTION' => LOGIN_URL
]);
print_page('login.tpl');
}

View file

@ -13,7 +13,7 @@ require __DIR__ . '/common.php';
$page_cfg['use_tablesorter'] = true;
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
$start = abs((int)request_var('start', 0));
$mode = (string)request_var('mode', 'joined');
@ -24,7 +24,7 @@ $paginationusername = $username;
//
// Memberlist sorting
//
$mode_types_text = array(
$mode_types_text = [
$lang['SORT_JOINED'],
$lang['SORT_USERNAME'],
$lang['SORT_LOCATION'],
@ -32,9 +32,9 @@ $mode_types_text = array(
$lang['SORT_EMAIL'],
$lang['SORT_WEBSITE'],
$lang['SORT_TOP_TEN']
);
];
$mode_types = array(
$mode_types = [
'joined',
'username',
'location',
@ -42,7 +42,7 @@ $mode_types = array(
'email',
'website',
'topten'
);
];
// <select> mode
$select_sort_mode = '<select name="mode">';
@ -66,12 +66,12 @@ $select_sort_order .= '</select>';
//
// Generate page
//
$template->assign_vars(array(
$template->assign_vars([
'S_MODE_SELECT' => $select_sort_mode,
'S_ORDER_SELECT' => $select_sort_order,
'S_MODE_ACTION' => "memberlist.php",
'S_USERNAME' => $paginationusername,
));
]);
switch ($mode) {
case 'joined':
@ -139,10 +139,10 @@ $select_letter .= ($by_letter == 'others') ? '<b>' . $lang['OTHERS'] . '</b>&nbs
$select_letter .= ':&nbsp;';
$select_letter .= ($by_letter == 'all') ? '<b>' . $lang['ALL'] . '</b>' : '<a class="genmed" href="' . ("memberlist.php?letter=all&amp;mode=$mode&amp;order=$sort_order") . '">' . $lang['ALL'] . '</a>';
$template->assign_vars(array(
$template->assign_vars([
'S_LETTER_SELECT' => $select_letter,
'S_LETTER_HIDDEN' => '<input type="hidden" name="letter" value="' . $by_letter . '">',
));
]);
// per-letter selection end
$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email, avatar_ext_id FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")";
@ -160,7 +160,7 @@ if ($result = DB()->fetch_rowset($sql)) {
$user_info = generate_user_info($row);
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('memberrow', array(
$template->assign_block_vars('memberrow', [
'ROW_NUMBER' => $i + ($start + 1),
'ROW_CLASS' => $row_class,
'USER' => profile_url($row),
@ -172,13 +172,11 @@ if ($result = DB()->fetch_rowset($sql)) {
'PM' => $user_info['pm'],
'EMAIL' => $user_info['email'],
'WWW' => $user_info['www'],
'U_VIEWPROFILE' => PROFILE_URL . $user_id,
));
'U_VIEWPROFILE' => PROFILE_URL . $user_id
]);
}
} else {
$template->assign_block_vars('no_username', array(
'NO_USER_ID_SPECIFIED' => $lang['NO_USER_ID_SPECIFIED'],
));
$template->assign_block_vars('no_username', ['NO_USER_ID_SPECIFIED' => $lang['NO_USER_ID_SPECIFIED']]);
}
$paginationurl = "memberlist.php?mode=$mode&amp;order=$sort_order&amp;letter=$by_letter";
@ -198,8 +196,6 @@ if ($mode != 'topten' || $bb_cfg['topics_per_page'] < 10) {
DB()->sql_freeresult($result);
}
$template->assign_vars(array(
'PAGE_TITLE' => $lang['MEMBERLIST'],
));
$template->assign_vars(['PAGE_TITLE' => $lang['MEMBERLIST']]);
print_page('memberlist.tpl');

102
modcp.php
View file

@ -41,7 +41,7 @@ function return_msg_mcp($status_msg)
function validate_topics($forum_id, &$req_topics, &$topic_titles)
{
$valid_topics = $valid_titles = array();
$valid_topics = $valid_titles = [];
if ($topic_csv = get_id_csv($req_topics)) {
$sql = "SELECT topic_id, topic_title FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND forum_id = $forum_id";
@ -130,7 +130,7 @@ if ($topic_id) {
}
// Start session management
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
// Check if user did or did not confirm. If they did not, forward them to the last page they were on
if (isset($_POST['cancel']) || IS_GUEST) {
@ -173,7 +173,7 @@ if ($is_moderator && !$userdata['session_admin']) {
//
// Get required vars
//
$req_topics = $topic_csv = $topic_titles = $hidden_fields = array();
$req_topics = $topic_csv = $topic_titles = $hidden_fields = [];
switch ($mode) {
case 'delete':
@ -196,12 +196,12 @@ switch ($mode) {
bb_die($lang['NONE_SELECTED']);
}
$hidden_fields = array(
$hidden_fields = [
'sid' => $userdata['session_id'],
'mode' => $mode,
'f' => $forum_id,
't' => $topic_id,
);
't' => $topic_id
];
foreach ($req_topics as $req_topic_id) {
$hidden_fields['topic_id_list'][] = $req_topic_id;
}
@ -238,12 +238,12 @@ switch ($mode) {
$msg = ($result) ? $lang['TOPICS_REMOVED'] : $lang['NO_TOPICS_REMOVED'];
bb_die(return_msg_mcp($msg));
} else {
print_confirmation(array(
print_confirmation([
'QUESTION' => $lang['CONFIRM_DELETE_TOPIC'],
'ITEMS_LIST' => implode("\n</li>\n<li>\n", $topic_titles),
'FORM_ACTION' => "modcp.php",
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields)
]);
}
break;
@ -278,7 +278,7 @@ switch ($mode) {
$forum_select = get_forum_select($forum_select_mode, 'new_forum', $forum_id);
$template->assign_vars(array(
$template->assign_vars([
'TPL_MODCP_MOVE' => true,
'SHOW_LEAVESHADOW' => $is_moderator,
'SHOW_BOT_OPTIONS' => $is_moderator,
@ -290,9 +290,9 @@ switch ($mode) {
'S_FORUM_SELECT' => $forum_select,
'S_MODCP_ACTION' => "modcp.php",
'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
]);
$template->set_filenames(array('body' => 'modcp.tpl'));
$template->set_filenames(['body' => 'modcp.tpl']);
}
break;
@ -310,7 +310,7 @@ switch ($mode) {
AND topic_status != $new_topic_status
";
$topic_csv = array();
$topic_csv = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$topic_csv[] = $row['topic_id'];
@ -331,11 +331,11 @@ switch ($mode) {
$type = ($lock) ? 'mod_topic_lock' : 'mod_topic_unlock';
foreach ($log_topics as $topic_id => $topic_title) {
$log_action->mod($type, array(
$log_action->mod($type, [
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'topic_title' => $topic_title,
));
'topic_title' => $topic_title
]);
}
$msg = ($lock) ? $lang['TOPICS_LOCKED'] : $lang['TOPICS_UNLOCKED'];
@ -364,11 +364,11 @@ switch ($mode) {
// Log action
$type = ($set_download) ? 'mod_topic_set_downloaded' : 'mod_topic_unset_downloaded';
$log_action->mod($type, array(
$log_action->mod($type, [
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'topic_title' => get_topic_title($topic_id),
));
'topic_title' => get_topic_title($topic_id)
]);
$msg = ($set_download) ? $lang['TOPICS_DOWN_SETS'] : $lang['TOPICS_DOWN_UNSETS'];
bb_die(return_msg_mcp($msg));
@ -379,12 +379,12 @@ switch ($mode) {
//mpd
$delete_posts = isset($_POST['delete_posts']);
$split = (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond']));
$posts = $_POST['post_id_list'] ?? array();
$posts = $_POST['post_id_list'] ?? [];
$start = /* (isset($_POST['start'])) ? intval($_POST['start']) : */
0;
$topic_first_post_id = $topic_row['topic_first_post_id'] ?? '';
$post_id_sql = $req_post_id_sql = array();
$post_id_sql = $req_post_id_sql = [];
if (($split || $delete_posts) && ($posts && $topic_id && $forum_id && $topic_first_post_id) && $confirmed) {
foreach ($posts as $post_id) {
@ -489,22 +489,22 @@ switch ($mode) {
\TorrentPier\Legacy\Post::insert_post('after_split_to_new', $new_topic_id, $new_forum_id, $forum_id, $new_topic_id, '', $topic_id);
}
\TorrentPier\Legacy\Admin\Common::sync('topic', array($topic_id, $new_topic_id));
\TorrentPier\Legacy\Admin\Common::sync('forum', array($forum_id, $new_forum_id));
\TorrentPier\Legacy\Admin\Common::sync('topic', [$topic_id, $new_topic_id]);
\TorrentPier\Legacy\Admin\Common::sync('forum', [$forum_id, $new_forum_id]);
//bot
$message = $lang['TOPIC_SPLIT'] . '<br /><br /><a href="' . "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'] . '">' . $lang['TOPIC_SPLIT_OLD'] . '</a>';
$message .= ' &nbsp;::&nbsp; <a href="' . "viewtopic.php?" . POST_TOPIC_URL . "=$new_topic_id&amp;sid=" . $userdata['session_id'] . '">' . $lang['TOPIC_SPLIT_NEW'] . '</a>';
$message = $lang['TOPIC_SPLIT'] . '<br /><br /><a href="' . TOPIC_URL . "$topic_id&amp;sid=" . $userdata['session_id'] . '">' . $lang['TOPIC_SPLIT_OLD'] . '</a>';
$message .= ' &nbsp;::&nbsp; <a href="' . TOPIC_URL . "$new_topic_id&amp;sid=" . $userdata['session_id'] . '">' . $lang['TOPIC_SPLIT_NEW'] . '</a>';
// Log action
$log_action->mod('mod_topic_split', array(
$log_action->mod('mod_topic_split', [
'forum_id' => $forum_id,
'forum_id_new' => $new_forum_id,
'topic_id' => $topic_id,
'topic_title' => get_topic_title($topic_id),
'topic_id_new' => $new_topic_id,
'topic_title_new' => htmlCHR($_POST['subject']),
));
'topic_title_new' => htmlCHR($_POST['subject'])
]);
bb_die($message);
}
@ -534,13 +534,13 @@ switch ($mode) {
if (($total_posts = DB()->num_rows($result)) > 0) {
$postrow = DB()->sql_fetchrowset($result);
$template->assign_vars(array(
$template->assign_vars([
'FORUM_NAME' => htmlCHR($forum_name),
'U_VIEW_FORUM' => FORUM_URL . $forum_id,
'S_SPLIT_ACTION' => 'modcp.php',
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_FORUM_SELECT' => get_forum_select('admin', 'new_forum_id', $forum_id),
));
]);
for ($i = 0; $i < $total_posts; $i++) {
$post_id = $postrow[$i]['post_id'];
@ -559,7 +559,7 @@ switch ($mode) {
$row_class = !($i % 2) ? 'row1' : 'row2';
$template->assign_block_vars('postrow', array(
$template->assign_block_vars('postrow', [
'ROW_CLASS' => $row_class,
'POSTER_NAME' => wbr($poster),
'POST_DATE' => $post_date,
@ -567,8 +567,8 @@ switch ($mode) {
'CHECKBOX' => defined('BEGIN_CHECKBOX'),
'POST_ID' => $post_id,
'ROW_ID' => $i,
'CB_ID' => 'cb_' . $i,
));
'CB_ID' => 'cb_' . $i
]);
if ($post_id == $topic_first_post_id) {
define('BEGIN_CHECKBOX', true);
@ -576,7 +576,7 @@ switch ($mode) {
}
}
}
$template->set_filenames(array('body' => 'modcp_split.tpl'));
$template->set_filenames(['body' => 'modcp_split.tpl']);
break;
case 'ip':
@ -606,11 +606,11 @@ switch ($mode) {
$poster_id = $post_row['poster_id'];
$template->assign_vars(array(
$template->assign_vars([
'TPL_MODCP_IP' => true,
'IP' => $ip_this_post,
'U_LOOKUP_IP' => "modcp.php?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=$ip_this_post&amp;sid=" . $userdata['session_id'],
));
]);
//
// Get other IP's this user has posted under
@ -626,9 +626,7 @@ switch ($mode) {
$i = 0;
do {
if ($row['poster_ip'] == $post_row['poster_ip']) {
$template->assign_vars(array(
'POSTS' => $row['postings'],
));
$template->assign_vars(['POSTS' => $row['postings']]);
continue;
}
@ -637,12 +635,12 @@ switch ($mode) {
}
$ip = ($rdns_ip_num == $ip || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
$template->assign_block_vars('iprow', array(
$template->assign_block_vars('iprow', [
'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5',
'IP' => $ip,
'POSTS' => $row['postings'],
'U_LOOKUP_IP' => "modcp.php?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip . "&amp;sid=" . $userdata['session_id'],
));
]);
$i++;
} while ($row = DB()->sql_fetchrow($result));
@ -671,19 +669,19 @@ switch ($mode) {
$id = $row['user_id'];
$username = (!$row['username']) ? $lang['GUEST'] : $row['username'];
$template->assign_block_vars('userrow', array(
$template->assign_block_vars('userrow', [
'ROW_CLASS' => !($i % 2) ? 'row4' : 'row5',
'USERNAME' => wbr($username),
'POSTS' => $row['postings'],
'U_PROFILE' => ($id == GUEST_UID) ? "modcp.php?mode=ip&amp;p=$post_id&amp;t=$topic_id" : PROFILE_URL . $id,
'U_SEARCHPOSTS' => "search.php?search_author=1&amp;uid=$id",
));
]);
$i++;
} while ($row = DB()->sql_fetchrow($result));
}
$template->set_filenames(array('body' => 'modcp.tpl'));
$template->set_filenames(['body' => 'modcp.tpl']);
break;
case 'post_pin':
@ -701,7 +699,7 @@ switch ($mode) {
AND topic_show_first_post != $new_topic_status
";
$topic_csv = array();
$topic_csv = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$topic_csv[] = $row['topic_id'];
@ -722,11 +720,11 @@ switch ($mode) {
$type = ($pin) ? 'mod_post_pin' : 'mod_post_unpin';
foreach ($log_topics as $topic_id => $topic_title) {
$log_action->mod($type, array(
$log_action->mod($type, [
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'topic_title' => $topic_title,
));
'topic_title' => $topic_title
]);
}
$msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED'];
@ -742,7 +740,7 @@ switch ($mode) {
LIMIT 1
";
$topic_csv = array();
$topic_csv = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$topic_csv[] = $row['topic_id'];
@ -763,11 +761,11 @@ switch ($mode) {
$type = ($pin) ? 'mod_post_pin' : 'mod_post_unpin';
foreach ($log_topics as $topic_id => $topic_title) {
$log_action->mod($type, array(
$log_action->mod($type, [
'forum_id' => $forum_id,
'topic_id' => $topic_id,
'topic_title' => $topic_title,
));
]);
}
$msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED'];
@ -780,7 +778,7 @@ switch ($mode) {
break;
}
$template->assign_vars(array('PAGE_TITLE' => $lang['MOD_CP']));
$template->assign_vars(['PAGE_TITLE' => $lang['MOD_CP']]);
require(PAGE_HEADER);

View file

@ -12,7 +12,7 @@ define('BB_SCRIPT', 'vote');
require __DIR__ . '/common.php';
// Start session management
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
$mode = (string)@$_POST['mode'];
$topic_id = (int)@$_POST['topic_id'];

View file

@ -13,7 +13,9 @@ require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php';
require ATTACH_DIR . '/attachment_mod.php';
$page_cfg['load_tpl_vars'] = array('post_icons');
$page_cfg['load_tpl_vars'] = [
'post_icons'
];
$submit = (bool)@$_REQUEST['post'];
$preview = (bool)@$_REQUEST['preview'];
@ -28,11 +30,11 @@ $mode = (string)@$_REQUEST['mode'];
$confirm = isset($_POST['confirm']);
$refresh = $preview;
$orig_word = $replacement_word = array();
$orig_word = $replacement_word = [];
// Set topic type
$topic_type = (@$_POST['topictype']) ? (int)$_POST['topictype'] : POST_NORMAL;
$topic_type = in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ? $topic_type : POST_NORMAL;
$topic_type = in_array($topic_type, [POST_NORMAL, POST_STICKY, POST_ANNOUNCE]) ? $topic_type : POST_NORMAL;
$selected_rg = 0;
$switch_rg_sig = 0;
@ -52,7 +54,7 @@ $user->session_start();
set_die_append_msg($forum_id, $topic_id);
// What auth type do we need to check?
$is_auth = array();
$is_auth = [];
switch ($mode) {
case 'newtopic':
case 'new_rel':
@ -94,7 +96,7 @@ switch ($mode) {
// Various lookups to find topic_id, forum_id, post_id etc
$error_msg = '';
$post_data = array();
$post_data = [];
switch ($mode) {
case 'newtopic':
case 'new_rel':
@ -278,17 +280,15 @@ if (!IS_GUEST && $mode != 'newtopic' && ($submit || $preview || $mode == 'quote'
$topic_has_new_posts = true;
foreach ($rowset as $i => $row) {
$template->assign_block_vars('new_posts', array(
$template->assign_block_vars('new_posts', [
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
'POSTER' => profile_url($row),
'POSTER_NAME_JS' => addslashes($row['username']),
'POST_DATE' => bb_date($row['post_time'], $bb_cfg['post_date_format']),
'MESSAGE' => get_parsed_post($row),
));
'MESSAGE' => get_parsed_post($row)
]);
}
$template->assign_vars(array(
'TPL_SHOW_NEW_POSTS' => true,
));
$template->assign_vars(['TPL_SHOW_NEW_POSTS' => true]);
set_tracks(COOKIE_TOPIC, $tracking_topics, $topic_id);
unset($rowset);
@ -301,15 +301,15 @@ if (($delete || $mode == 'delete') && !$confirm) {
if (isset($_POST['cancel'])) {
redirect(POST_URL . "$post_id#$post_id");
}
$hidden_fields = array(
$hidden_fields = [
'p' => $post_id,
'mode' => 'delete',
);
print_confirmation(array(
'mode' => 'delete'
];
print_confirmation([
'QUESTION' => $lang['CONFIRM_DELETE'],
'FORM_ACTION' => POSTING_URL,
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields)
]);
} elseif (($submit || $confirm) && !$topic_has_new_posts) {
//
// Submit post (newtopic, edit, reply, etc.)
@ -347,13 +347,13 @@ if (($delete || $mode == 'delete') && !$confirm) {
if (!$post_data['first_post']) {
\TorrentPier\Legacy\Post::delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id);
} else {
redirect("modcp.php?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']);
redirect('modcp.php?' . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id']);
}
break;
}
if (!$error_msg) {
if (!in_array($mode, array('editpost', 'delete'))) {
if (!in_array($mode, ['editpost', 'delete'])) {
$user_id = ($mode == 'reply' || $mode == 'newtopic') ? $userdata['user_id'] : $post_data['poster_id'];
\TorrentPier\Legacy\Post::update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
}
@ -376,7 +376,7 @@ if (($delete || $mode == 'delete') && !$confirm) {
$forum_parent = $post_info['forum_parent'];
}
$count_rowset = DB()->fetch_rowset("SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_parent = $forum_parent");
$sub_forums = array();
$sub_forums = [];
foreach ($count_rowset as $count_row) {
if ($count_row['forum_id'] != $forum_id) {
$sub_forums[] = $count_row['forum_id'];
@ -432,14 +432,14 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) {
$preview_message = htmlCHR($message, false, ENT_NOQUOTES);
$preview_message = bbcode2html($preview_message);
$template->assign_vars(array(
$template->assign_vars([
'TPL_PREVIEW_POST' => true,
'TOPIC_TITLE' => wbr($preview_subject),
'POST_SUBJECT' => $preview_subject,
'POSTER_NAME' => $preview_username,
'POST_DATE' => bb_date(TIMENOW),
'PREVIEW_MSG' => $preview_message,
));
'PREVIEW_MSG' => $preview_message
]);
}
} else {
// User default entry point
@ -455,8 +455,8 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) {
if ($mode == 'quote') {
if (!defined('WORD_LIST_OBTAINED')) {
$orig_word = array();
$replace_word = array();
$orig_word = [];
$replace_word = [];
obtain_word_list($orig_word, $replace_word);
define('WORD_LIST_OBTAINED', true);
}
@ -489,9 +489,7 @@ if ($refresh || $error_msg || ($submit && $topic_has_new_posts)) {
}
if ($error_msg) {
$template->assign_vars(array(
'ERROR_MESSAGE' => $error_msg,
));
$template->assign_vars(['ERROR_MESSAGE' => $error_msg]);
}
if (IS_GUEST || ($mode == 'editpost' && $post_info['poster_id'] == GUEST_UID)) {
@ -508,7 +506,7 @@ if (!IS_GUEST) {
// Topic type selection
$topic_type_toggle = '';
if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
$template->assign_block_vars('switch_type_toggle', array());
$template->assign_block_vars('switch_type_toggle', []);
if ($is_auth['auth_sticky']) {
$topic_type_toggle .= '<label><input type="radio" name="topictype" value="' . POST_STICKY . '"';
@ -603,12 +601,10 @@ switch ($mode) {
// Generate smilies listing for page output
generate_smilies('inline');
$template->set_filenames(array(
'body' => 'posting.tpl',
));
$template->set_filenames(['body' => 'posting.tpl']);
// Output the data to the template
$template->assign_vars(array(
$template->assign_vars([
'FORUM_NAME' => htmlCHR($forum_name),
'PAGE_TITLE' => $page_title,
'POSTING_TYPE_TITLE' => $page_title,
@ -624,14 +620,14 @@ $template->assign_vars(array(
'POSTER_RGROUPS' => isset($poster_rgroups) && !empty($poster_rgroups) ? $poster_rgroups : '',
'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false,
'U_VIEWTOPIC' => ($mode == 'reply') ? "viewtopic.php?" . POST_TOPIC_URL . "=$topic_id&amp;postorder=desc" : '',
'U_VIEWTOPIC' => ($mode == 'reply') ? TOPIC_URL . "$topic_id&amp;postorder=desc" : '',
'S_NOTIFY_CHECKED' => ($notify_user) ? 'checked' : '',
'S_TYPE_TOGGLE' => $topic_type_toggle,
'S_TOPIC_ID' => $topic_id,
'S_POST_ACTION' => POSTING_URL,
'S_HIDDEN_FORM_FIELDS' => $hidden_form_fields,
));
]);
if ($mode == 'newtopic' || $post_data['first_post']) {
$template->assign_var('POSTING_SUBJECT');
@ -639,10 +635,10 @@ if ($mode == 'newtopic' || $post_data['first_post']) {
// Update post time
if ($mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) {
$template->assign_vars(array(
$template->assign_vars([
'SHOW_UPDATE_POST_TIME' => ($is_auth['auth_mod'] || ($post_data['poster_post'] && $post_info['post_time'] + 3600 * 3 > TIMENOW)),
'UPDATE_POST_TIME_CHECKED' => ($post_data['poster_post'] && ($post_info['post_time'] + 3600 * 2 > TIMENOW)),
));
]);
}
// Topic review

View file

@ -17,9 +17,9 @@ $privmsg_sent_id = $l_box_name = $to_username = $privmsg_subject = $privmsg_mess
// Page config
$page_cfg['use_tablesorter'] = true;
$page_cfg['load_tpl_vars'] = array(
'pm_icons',
);
$page_cfg['load_tpl_vars'] = [
'pm_icons'
];
//
// Is PM disabled?
@ -55,12 +55,12 @@ if ($folder =& $_REQUEST['folder']) {
}
// Start session management
$user->session_start(array('req_login' => true));
$user->session_start(['req_login' => true]);
$template->assign_vars(array(
$template->assign_vars([
'IN_PM' => true,
'QUICK_REPLY' => $bb_cfg['show_quick_reply'] && $folder == 'inbox' && $mode == 'read',
));
]);
//
// Cancel
@ -246,13 +246,13 @@ if ($mode == 'read') {
//
// Pick a folder, any folder, so long as it's one below ...
//
$post_urls = array(
'post' => PM_URL . "?mode=post",
'reply' => PM_URL . "?mode=reply&amp;" . POST_POST_URL . "=$privmsg_id",
'quote' => PM_URL . "?mode=quote&amp;" . POST_POST_URL . "=$privmsg_id",
'edit' => PM_URL . "?mode=edit&amp;" . POST_POST_URL . "=$privmsg_id"
);
$post_icons = array(
$post_urls = [
'post' => PM_URL . '?mode=post',
'reply' => PM_URL . '?mode=reply&amp;' . POST_POST_URL . "=$privmsg_id",
'quote' => PM_URL . '?mode=quote&amp;' . POST_POST_URL . "=$privmsg_id",
'edit' => PM_URL . '?mode=edit&amp;' . POST_POST_URL . "=$privmsg_id"
];
$post_icons = [
'post_img' => '<a href="' . $post_urls['post'] . '"><img src="' . $images['pm_postmsg'] . '" alt="' . $lang['POST_NEW_PM'] . '" border="0" /></a>',
'post' => '<a href="' . $post_urls['post'] . '">' . $lang['POST_NEW_PM'] . '</a>',
'reply_img' => '<a href="' . $post_urls['reply'] . '"><img src="' . $images['pm_replymsg'] . '" alt="' . $lang['POST_REPLY_PM'] . '" border="0" /></a>',
@ -261,7 +261,7 @@ if ($mode == 'read') {
'quote' => '<a href="' . $post_urls['quote'] . '">' . $lang['POST_QUOTE_PM'] . '</a>',
'edit_img' => '<a href="' . $post_urls['edit'] . '"><img src="' . $images['pm_editmsg'] . '" alt="' . $lang['EDIT_PM'] . '" border="0" /></a>',
'edit' => '<a href="' . $post_urls['edit'] . '">' . $lang['EDIT_PM'] . '</a>'
);
];
if ($folder == 'inbox') {
$post_img = $post_icons['post_img'];
@ -323,11 +323,9 @@ if ($mode == 'read') {
//
// Load templates
//
$template->set_filenames(array(
'body' => 'privmsgs_read.tpl')
);
$template->set_filenames(['body' => 'privmsgs_read.tpl']);
$template->assign_vars(array(
$template->assign_vars([
'INBOX' => $inbox_url,
'POST_PM_IMG' => $post_img,
@ -345,8 +343,8 @@ if ($mode == 'read') {
'BOX_NAME' => $l_box_name,
'S_PRIVMSGS_ACTION' => PM_URL . "?folder=$folder",
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
'S_HIDDEN_FIELDS' => $s_hidden_fields
]);
$username_from = $privmsg['username'];
$user_id_from = $privmsg['user_id'];
@ -374,8 +372,8 @@ if ($mode == 'read') {
$private_message = $privmsg['privmsgs_text'];
$orig_word = array();
$replacement_word = array();
$orig_word = [];
$replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
if (count($orig_word)) {
@ -388,8 +386,8 @@ if ($mode == 'read') {
//
// Dump it to the templating engine
//
$template->assign_vars(array(
'TO_USER' => profile_url(array('username' => $username_to, 'user_id' => $user_id_to, 'user_rank' => $privmsg['to_user_rank'])),
$template->assign_vars([
'TO_USER' => profile_url(['username' => $username_to, 'user_id' => $user_id_to, 'user_rank' => $privmsg['to_user_rank']]),
'FROM_USER' => profile_url($privmsg),
'QR_SUBJECT' => (!preg_match('/^Re:/', $post_subject) ? 'Re: ' : '') . $post_subject,
@ -406,30 +404,30 @@ if ($mode == 'read') {
'PROFILE_IMG' => $profile_img,
'PROFILE' => $profile,
'SEARCH_IMG' => $search_img,
'SEARCH' => $search,
));
'SEARCH' => $search
]);
} elseif (($delete && $mark_list) || $delete_all) {
if (isset($mark_list) && !is_array($mark_list)) {
// Set to empty array instead of '0' if nothing is selected.
$mark_list = array();
$mark_list = [];
}
if (!$confirmed) {
$delete = isset($_POST['delete']) ? 'delete' : 'deleteall';
$hidden_fields = array(
$hidden_fields = [
'mode' => $mode,
$delete => 1,
);
$delete => 1
];
foreach ($mark_list as $pm_id) {
$hidden_fields['mark'][] = (int)$pm_id;
}
print_confirmation(array(
print_confirmation([
'QUESTION' => (count($mark_list) == 1) ? $lang['CONFIRM_DELETE_PM'] : $lang['CONFIRM_DELETE_PMS'],
'FORM_ACTION' => PM_URL . "?folder=$folder",
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields),
));
'HIDDEN_FIELDS' => build_hidden_fields($hidden_fields)
]);
} elseif ($confirmed) {
$delete_sql_id = '';
@ -467,7 +465,7 @@ if ($mode == 'read') {
bb_die('Could not obtain id list to delete messages');
}
$mark_list = array();
$mark_list = [];
while ($row = DB()->sql_fetchrow($result)) {
$mark_list[] = $row['privmsgs_id'];
}
@ -502,7 +500,7 @@ if ($mode == 'read') {
}
if ($row = DB()->sql_fetchrow($result)) {
$update_users = $update_list = array();
$update_users = $update_list = [];
do {
switch ($row['privmsgs_type']) {
@ -665,7 +663,7 @@ if ($mode == 'read') {
}
if ($row = DB()->sql_fetchrow($result)) {
$update_users = $update_list = array();
$update_users = $update_list = [];
do {
switch ($row['privmsgs_type']) {
@ -915,13 +913,13 @@ if ($mode == 'read') {
$emailer->set_subject($lang['EMAILER_SUBJECT']['PRIVMSG_NOTIFY']);
$emailer->set_template('privmsg_notify', $to_userdata['user_lang']);
$emailer->assign_vars(array(
$emailer->assign_vars([
'USERNAME' => html_entity_decode($to_username),
'NAME_FROM' => $userdata['username'],
'MSG_SUBJECT' => html_entity_decode($privmsg_subject),
'SITENAME' => $bb_cfg['sitename'],
'U_INBOX' => make_url(PM_URL . "?folder=inbox&mode=read&p=$privmsg_sent_id"),
));
]);
$emailer->send();
}
@ -1049,8 +1047,8 @@ if ($mode == 'read') {
$page_title = $lang['SEND_PRIVATE_MESSAGE'];
if ($preview && !$error) {
$orig_word = array();
$replacement_word = array();
$orig_word = [];
$replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
$preview_message = bbcode2html($privmsg_message);
@ -1069,7 +1067,7 @@ if ($mode == 'read') {
$s_hidden_fields .= '<input type="hidden" name="' . POST_POST_URL . '" value="' . $privmsg_id . '" />';
}
$template->assign_vars(array(
$template->assign_vars([
'TPL_PREVIEW_POST' => true,
'TOPIC_TITLE' => wbr($preview_subject),
'POST_SUBJECT' => $preview_subject,
@ -1078,28 +1076,26 @@ if ($mode == 'read') {
'POST_DATE' => bb_date(TIMENOW),
'PREVIEW_MSG' => $preview_message,
'S_HIDDEN_FIELDS' => $s_hidden_fields,
));
'S_HIDDEN_FIELDS' => $s_hidden_fields
]);
}
//
// Start error handling
//
if ($error) {
$template->assign_vars(array('ERROR_MESSAGE' => $error_msg));
$template->assign_vars(['ERROR_MESSAGE' => $error_msg]);
}
//
// Load templates
//
$template->set_filenames(array(
'body' => 'posting.tpl')
);
$template->set_filenames(['body' => 'posting.tpl']);
//
// Enable extensions in posting_body
//
$template->assign_block_vars('switch_privmsg', array());
$template->assign_block_vars('switch_privmsg', []);
$template->assign_var('POSTING_USERNAME');
$post_a = '&nbsp;';
@ -1125,7 +1121,7 @@ if ($mode == 'read') {
$privmsg_subject = clean_title($privmsg_subject);
$template->assign_vars(array(
$template->assign_vars([
'SUBJECT' => htmlCHR($privmsg_subject),
'USERNAME' => $to_username,
'MESSAGE' => $privmsg_message,
@ -1142,9 +1138,9 @@ if ($mode == 'read') {
'S_HIDDEN_FORM_FIELDS' => $s_hidden_fields,
'S_POST_ACTION' => PM_URL,
'U_SEARCH_USER' => "search.php?mode=searchuser",
'U_VIEW_FORUM' => PM_URL,
));
'U_SEARCH_USER' => 'search.php?mode=searchuser',
'U_VIEW_FORUM' => PM_URL
]);
} else {
//
// Reset PM counters
@ -1156,11 +1152,11 @@ if ($mode == 'read') {
//
// Update unread status
//
\TorrentPier\Sessions::db_update_userdata($userdata, array(
\TorrentPier\Sessions::db_update_userdata($userdata, [
'user_unread_privmsg' => 'user_unread_privmsg + user_new_privmsg',
'user_new_privmsg' => 0,
'user_last_privmsg' => $userdata['session_start'],
));
'user_last_privmsg' => $userdata['session_start']
]);
$sql = "UPDATE " . BB_PRIVMSGS . "
SET privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "
@ -1178,11 +1174,9 @@ if ($mode == 'read') {
//
// Load templates
//
$template->set_filenames(array(
'body' => 'privmsgs.tpl')
);
$template->set_filenames(['body' => 'privmsgs.tpl']);
$orig_word = $replacement_word = array();
$orig_word = $replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
//
@ -1289,8 +1283,8 @@ if ($mode == 'read') {
//
// Build select box
//
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
$previous_days_text = array($lang['ALL_POSTS'], $lang['1_DAY'], $lang['7_DAYS'], $lang['2_WEEKS'], $lang['1_MONTH'], $lang['3_MONTHS'], $lang['6_MONTHS'], $lang['1_YEAR']);
$previous_days = [0, 1, 7, 14, 30, 90, 180, 364];
$previous_days_text = [$lang['ALL_POSTS'], $lang['1_DAY'], $lang['7_DAYS'], $lang['2_WEEKS'], $lang['1_MONTH'], $lang['3_MONTHS'], $lang['6_MONTHS'], $lang['1_YEAR']];
$select_msg_days = '';
for ($i = 0, $iMax = count($previous_days); $i < $iMax; $i++) {
@ -1351,7 +1345,7 @@ if ($mode == 'read') {
//
// Dump vars to template
//
$template->assign_vars(array(
$template->assign_vars([
'BOX_NAME' => $l_box_name,
'BOX_EXPL' => ($folder == 'outbox') ? $lang['OUTBOX_EXPL'] : '',
'INBOX' => $inbox_url,
@ -1374,8 +1368,8 @@ if ($mode == 'read') {
'S_POST_NEW_MSG' => $post_new_mesg_url,
'S_SELECT_MSG_DAYS' => $select_msg_days,
'U_POST_NEW_TOPIC' => PM_URL . "?mode=post",
));
'U_POST_NEW_TOPIC' => PM_URL . '?mode=post'
]);
//
// Okay, let's build the correct folder
@ -1416,29 +1410,26 @@ if ($mode == 'read') {
$row_class = !($i & 1) ? 'row1' : 'row2';
$i++;
$template->assign_block_vars('listrow', array(
$template->assign_block_vars('listrow', [
'ROW_CLASS' => $row_class,
'FROM' => $msg_user,
'SUBJECT' => htmlCHR($msg_subject),
'DATE' => $msg_date,
'PRIVMSG_FOLDER_IMG' => $icon_flag,
'L_PRIVMSG_FOLDER_ALT' => $icon_flag_alt,
'S_MARK_ID' => $privmsg_id,
'U_READ' => $u_subject,
));
'U_READ' => $u_subject
]);
} while ($row = DB()->sql_fetchrow($result));
generate_pagination(PM_URL . "?folder=$folder", $pm_total, $bb_cfg['topics_per_page'], $start);
} else {
$template->assign_block_vars("switch_no_messages", array());
$template->assign_block_vars('switch_no_messages', []);
}
}
$template->assign_vars(array('PAGE_TITLE' => @$page_title));
$template->assign_vars(['PAGE_TITLE' => @$page_title]);
require(PAGE_HEADER);

View file

@ -12,11 +12,11 @@ define('BB_SCRIPT', 'search');
require __DIR__ . '/common.php';
require INC_DIR . '/bbcode.php';
$page_cfg['load_tpl_vars'] = array(
$page_cfg['load_tpl_vars'] = [
'post_buttons',
'post_icons',
'topic_icons',
);
'topic_icons'
];
// Start session management
$user->session_start(array('req_login' => $bb_cfg['disable_search_for_guest']));
@ -61,7 +61,7 @@ if (isset($_POST['del_my_post'])) {
//
// Define censored word matches
//
$orig_word = $replacement_word = array();
$orig_word = $replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
$tracking_topics = get_tracks('topic');
@ -160,7 +160,7 @@ $order_opt = array(
'sql' => 't.topic_replies',
),
);
$order_select = array();
$order_select = [];
foreach ($order_opt as $val => $opt) {
$order_select[$opt['lang']] = $val;
}
@ -176,7 +176,7 @@ $sort_opt = array(
'sql' => ' DESC ',
),
);
$sort_select = array();
$sort_select = [];
foreach ($sort_opt as $val => $opt) {
$sort_select[$opt['lang']] = $val;
}
@ -208,7 +208,7 @@ $time_opt = array(
'sql' => TIMENOW - 86400 * 30,
),
);
$time_select = array();
$time_select = [];
foreach ($time_opt as $val => $opt) {
$time_select[$opt['lang']] = $val;
}
@ -222,7 +222,7 @@ $display_as_opt = array(
'lang' => $lang['MESSAGE'],
),
);
$display_as_select = array();
$display_as_select = [];
foreach ($display_as_opt as $val => $opt) {
$display_as_select[$opt['lang']] = $val;
}
@ -236,7 +236,7 @@ $chars_opt = array(
'lang' => $lang['BRIEFLY'],
),
);
$chars_select = array();
$chars_select = [];
foreach ($chars_opt as $val => $opt) {
$chars_select[$opt['lang']] = $val;
}
@ -404,7 +404,7 @@ if (!$items_found) {
}
}
$dl_status = array();
$dl_status = [];
if ($dl_cancel_val) {
$dl_status[] = DL_STATUS_CANCEL;
}
@ -549,7 +549,7 @@ if ($post_mode) {
if (!$unsorted_rows = DB()->fetch_rowset($sql)) {
bb_die($lang['NO_SEARCH_MATCH']);
}
$tmp = $sorted_rows = array();
$tmp = $sorted_rows = [];
foreach ($unsorted_rows as $row) {
$tmp[$row['post_id']] = $row;
@ -563,7 +563,7 @@ if ($post_mode) {
}
// Output page
$new_tracks = array();
$new_tracks = [];
foreach ($sorted_rows as $topic_id => $topic_posts) {
// Topic title block
@ -770,7 +770,7 @@ else {
$SQL['LIMIT'][] = (string)$per_page;
// Fetch topics data
$topic_rows = array();
$topic_rows = [];
foreach (DB()->fetch_rowset($SQL) as $row) {
$topic_rows[$row['topic_id']] = $row;
}
@ -845,7 +845,7 @@ function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)
{
global $lang, $search_id, $session_id, $items_found, $per_page;
$items_found = array();
$items_found = [];
foreach (DB()->fetch_rowset($sql) as $row) {
$items_found[] = $row['item_id'];
}
@ -878,7 +878,7 @@ function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)
$save_in_db[] = 'dl_will';
}
$curr_set = array();
$curr_set = [];
foreach ($save_in_db as $name) {
$curr_set[$GLOBALS["{$name}_key"]] = $GLOBALS["{$name}_val"];
}
@ -899,7 +899,7 @@ function prevent_huge_searches($SQL)
if ($bb_cfg['limit_max_search_results']) {
$SQL['select_options'][] = 'SQL_CALC_FOUND_ROWS';
$SQL['ORDER BY'] = array();
$SQL['ORDER BY'] = [];
$SQL['LIMIT'] = array('0');
if (DB()->query($SQL) and $row = DB()->fetch_row("SELECT FOUND_ROWS() AS rows_count")) {

View file

@ -115,9 +115,9 @@ class Poll
public static function get_poll_data_items_js($topic_id)
{
if (!$topic_id_csv = get_id_csv($topic_id)) {
return is_array($topic_id) ? array() : false;
return is_array($topic_id) ? [] : false;
}
$items = array();
$items = [];
if (!$poll_data = CACHE('bb_poll_data')->get("poll_$topic_id")) {
$poll_data = DB()->fetch_rowset("
@ -133,7 +133,7 @@ class Poll
$opt_text_for_js = htmlCHR($row['vote_text']);
$opt_result_for_js = (int)$row['vote_result'];
$items[$row['topic_id']][$row['vote_id']] = array($opt_text_for_js, $opt_result_for_js);
$items[$row['topic_id']][$row['vote_id']] = [$opt_text_for_js, $opt_result_for_js];
}
foreach ($items as $k => $v) {
$items[$k] = json_encode($v, JSON_THROW_ON_ERROR);

View file

@ -9,7 +9,7 @@
global $bb_cfg, $page_cfg, $template, $images, $lang;
$width = $height = array();
$width = $height = [];
$template_name = basename(__DIR__);
$_img = BB_ROOT . 'styles/images/';
@ -113,7 +113,7 @@ $images['voting_graphic'][4] = $_main . 'voting_bar.gif';
$images['progress_bar'] = $_main . 'progress_bar.gif';
$images['progress_bar_full'] = $_main . 'progress_bar_full.gif';
$template->assign_vars(array(
$template->assign_vars([
'IMG' => $_main,
'TEXT_BUTTONS' => $bb_cfg['text_buttons'],
'POST_BTN_SPACER' => $bb_cfg['text_buttons'] ? '&nbsp;' : '',
@ -124,12 +124,12 @@ $template->assign_vars(array(
'ATTACH_IMG_WIDTH_DECR_JS' => $bb_cfg['topic_left_column_witdh'] + $bb_cfg['attach_img_width_decr'],
'MAGNET_LINKS' => $bb_cfg['magnet_links_enabled'],
'FEED_IMG' => '<img src="' . $_main . 'feed.png" class="feed-small" alt="' . $lang['ATOM_FEED'] . '" />',
));
]);
// post_buttons
if (!empty($page_cfg['load_tpl_vars']) and $vars = array_flip($page_cfg['load_tpl_vars'])) {
if (isset($vars['post_buttons'])) {
$template->assign_vars(array(
$template->assign_vars([
'QUOTE_IMG' => $bb_cfg['text_buttons'] ? $lang['REPLY_WITH_QUOTE_TXTB'] : '<img src="' . $images['icon_quote'] . '" alt="' . $lang['REPLY_WITH_QUOTE_TXTB'] . '" title="' . $lang['REPLY_WITH_QUOTE'] . '" />',
'EDIT_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['EDIT_DELETE_POST_TXTB'] : '<img src="' . $images['icon_edit'] . '" alt="' . $lang['EDIT_DELETE_POST_TXTB'] . '" title="' . $lang['EDIT_POST'] . '" />',
'DELETE_POST_IMG' => $bb_cfg['text_buttons'] ? $lang['DELETE_POST_TXTB'] : '<img src="' . $images['icon_delpost'] . '" alt="' . $lang['DELETE_POST_TXTB'] . '" title="' . $lang['DELETE_POST'] . '" />',
@ -149,36 +149,36 @@ if (!empty($page_cfg['load_tpl_vars']) and $vars = array_flip($page_cfg['load_tp
'WWW_IMG' => $bb_cfg['text_buttons'] ? $lang['VISIT_WEBSITE_TXTB'] : '<img src="' . $images['icon_www'] . '" alt="' . $lang['VISIT_WEBSITE_TXTB'] . '" title="' . $lang['VISIT_WEBSITE'] . '" />',
'ICQ_IMG' => $bb_cfg['text_buttons'] ? $lang['ICQ_TXTB'] : '<img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ_TXTB'] . '" title="' . $lang['ICQ'] . '" />',
'EMAIL_URL' => BB_ROOT . "profile.php?mode=email&amp;u=",
'EMAIL_URL' => BB_ROOT . 'profile.php?mode=email&amp;u=',
'FORUM_URL' => BB_ROOT . FORUM_URL,
'ICQ_URL' => 'http://www.icq.com/people/',
'PM_URL' => BB_ROOT . PM_URL,
'PROFILE_URL' => BB_ROOT . PROFILE_URL,
));
'PROFILE_URL' => BB_ROOT . PROFILE_URL
]);
}
if (isset($vars['post_icons'])) {
$template->assign_vars(array(
$template->assign_vars([
'MINIPOST_IMG' => '<img src="' . $images['icon_minipost'] . '" class="icon1" alt="' . $lang['POST'] . '" />',
'ICON_GOTOPOST' => '<img src="' . $images['icon_gotopost'] . '" class="icon1" alt="' . $lang['GO'] . '" title="' . $lang['GOTO_PAGE'] . '" />',
'MINIPOST_IMG_NEW' => '<img src="' . $images['icon_minipost_new'] . '" class="icon1" alt="' . $lang['NEW'] . '" />',
'ICON_LATEST_REPLY' => '<img src="' . $images['icon_latest_reply'] . '" class="icon2" alt="' . $lang['LATEST'] . '" title="' . $lang['VIEW_LATEST_POST'] . '" />',
'ICON_NEWEST_REPLY' => '<img src="' . $images['icon_newest_reply'] . '" class="icon2" alt="' . $lang['NEWEST'] . '" title="' . $lang['VIEW_NEWEST_POST'] . '" />',
));
]);
}
if (isset($vars['topic_icons'])) {
$template->assign_vars(array(
$template->assign_vars([
'MOVED' => TOPIC_MOVED,
'ANNOUNCE' => POST_ANNOUNCE,
'STICKY' => POST_STICKY,
'LOCKED' => TOPIC_LOCKED,
));
'LOCKED' => TOPIC_LOCKED
]);
}
if (isset($vars['pm_icons'])) {
$template->assign_vars(array(
$template->assign_vars([
'INBOX_IMG' => '<img src="' . $images['pm_inbox'] . '" class="pm_box_icon" alt="" />',
'OUTBOX_IMG' => '<img src="' . $images['pm_outbox'] . '" class="pm_box_icon" alt="" />',
'SENTBOX_IMG' => '<img src="' . $images['pm_sentbox'] . '" class="pm_box_icon" alt="" />',
'SAVEBOX_IMG' => '<img src="' . $images['pm_savebox'] . '" class="pm_box_icon" alt="" />',
));
]);
}
}

View file

@ -14,9 +14,9 @@ require __DIR__ . '/common.php';
// Page config
$page_cfg['include_bbcode_js'] = true;
$page_cfg['use_tablesorter'] = true;
$page_cfg['load_tpl_vars'] = array(
'post_icons',
);
$page_cfg['load_tpl_vars'] = [
'post_icons'
];
// Session start
$user->session_start(array('req_login' => $bb_cfg['bt_tor_browse_only_reg']));
@ -48,7 +48,7 @@ $session_id = $userdata['session_id'];
$status = $_POST['status'] ?? false;
$cat_forum = $tor_to_show = $search_in_forums_ary = array();
$cat_forum = $tor_to_show = $search_in_forums_ary = [];
$title_match_sql = $title_match_q = $search_in_forums_csv = '';
$tr_error = $poster_error = false;
$row_num = $tor_count = 0;
@ -137,7 +137,7 @@ $order_opt = array(
'sql' => 'tor.seeder_last_seen',
),
);
$order_select = array();
$order_select = [];
foreach ($order_opt as $val => $opt) {
$order_select[$opt['lang']] = $val;
}
@ -181,7 +181,7 @@ $time_opt = array(
'sql' => TIMENOW - 86400 * 30,
),
);
$time_select = array();
$time_select = [];
foreach ($time_opt as $val => $opt) {
$time_select[$opt['lang']] = $val;
}
@ -217,7 +217,7 @@ $s_not_seen_opt = array(
'sql' => 0,
),
);
$s_not_seen_select = array();
$s_not_seen_select = [];
foreach ($s_not_seen_opt as $val => $opt) {
$s_not_seen_select[$opt['lang']] = $val;
}
@ -298,7 +298,7 @@ if (isset($_GET[$user_releases_key])) {
}
// Restore torrents list and search settings if we have valid $search_id
$tor_list_ary = array();
$tor_list_ary = [];
$tor_list_sql = '';
if ($search_id) {
@ -349,7 +349,7 @@ $datastore->rm('cat_forums');
if (!$set_default) {
// Search in forum or category
// Get requested cat_id
$search_in_forums_fary = array();
$search_in_forums_fary = [];
if ($req_cat_id =& $_REQUEST[$cat_key]) {
if (isset($cat_forum['c'][$req_cat_id])) {
@ -428,7 +428,7 @@ if (!$set_default) {
}
}
$dl_status = array();
$dl_status = [];
if ($dl_cancel_val) {
$dl_status[] = DL_STATUS_CANCEL;
}
@ -497,7 +497,7 @@ if ($allowed_forums) {
'sort',
'time',
);
$curr_set = array();
$curr_set = [];
foreach ($save_in_db as $name) {
$curr_set[${"{$name}_key"}] = ${"{$name}_val"};
}
@ -879,7 +879,7 @@ $save_through_pages = array(
'show_speed',
'tor_type',
);
$hidden_fields = array();
$hidden_fields = [];
foreach ($save_through_pages as $name) {
$hidden_fields['prev_' . ${"{$name}_key"}] = ${"{$name}_val"};
}

View file

@ -18,10 +18,10 @@ $last_topic_max_len = 40;
$title_match_key = 'nm';
$title_match_max_len = 60;
$page_cfg['load_tpl_vars'] = array(
$page_cfg['load_tpl_vars'] = [
'post_icons',
'topic_icons',
);
'topic_icons'
];
// Init request vars
$forum_id = (int)request_var('f', '');
@ -219,7 +219,7 @@ if ($is_auth['auth_mod']) {
$topics_per_page = $req_tpp;
}
$select_tpp = array();
$select_tpp = [];
foreach ($bb_cfg['allowed_topics_per_page'] as $tpp) {
$select_tpp[$tpp] = $tpp;
}
@ -313,7 +313,7 @@ if ($title_match =& $_REQUEST[$title_match_key]) {
}
// Get topics
$topic_ids = $topic_rowset = array();
$topic_ids = $topic_rowset = [];
// IDs
$sql = "
@ -353,7 +353,7 @@ if ($topics_csv = implode(',', $topic_ids)) {
}
// Define censored word matches
$orig_word = $replacement_word = array();
$orig_word = $replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
if ($forum_data['allow_reg_tracker']) {
@ -375,7 +375,7 @@ $template->assign_vars(array(
));
// User authorisation levels output
$u_auth = array();
$u_auth = [];
$u_auth[] = ($is_auth['auth_post']) ? $lang['RULES_POST_CAN'] : $lang['RULES_POST_CANNOT'];
$u_auth[] = ($is_auth['auth_reply']) ? $lang['RULES_REPLY_CAN'] : $lang['RULES_REPLY_CANNOT'];
$u_auth[] = ($is_auth['auth_edit']) ? $lang['RULES_EDIT_CAN'] : $lang['RULES_EDIT_CANNOT'];

View file

@ -17,11 +17,11 @@ $datastore->enqueue(array(
'cat_forums',
));
$page_cfg['load_tpl_vars'] = array(
$page_cfg['load_tpl_vars'] = [
'post_buttons',
'post_icons',
'topic_icons',
);
'topic_icons'
];
$newest = $next_topic_id = 0;
$start = isset($_GET['start']) ? abs((int)$_GET['start']) : 0;
@ -42,7 +42,7 @@ if ($userdata['session_admin']) {
$posts_per_page = $req_ppp;
}
$select_ppp = array();
$select_ppp = [];
foreach ($bb_cfg['allowed_posts_per_page'] as $ppp) {
$select_ppp[$ppp] = $ppp;
}
@ -367,7 +367,7 @@ if (!$ranks = $datastore->get('ranks')) {
}
// Define censored word matches
$orig_word = $replacement_word = array();
$orig_word = $replacement_word = [];
obtain_word_list($orig_word, $replacement_word);
// Censor topic title
@ -684,7 +684,7 @@ for ($i = 0; $i < $total_posts; $i++) {
$mc_class = '';
break;
}
$mc_select_type = array();
$mc_select_type = [];
foreach ($lang['MC_COMMENT'] as $key => $value) {
$mc_select_type[$key] = $value['type'];
}