mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Miscellaneous static analysis improvements for php 7.1 (#620)
* Miscellaneous static analysis improvements for php 7.1 * Update changes.txt
This commit is contained in:
parent
4e8e181d8c
commit
7019d31353
37 changed files with 156 additions and 151 deletions
|
@ -767,6 +767,8 @@ print_page('admin_forums.tpl', 'admin');
|
||||||
*/
|
*/
|
||||||
function get_info($mode, $id)
|
function get_info($mode, $id)
|
||||||
{
|
{
|
||||||
|
$table = null;
|
||||||
|
$idfield = null;
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'category':
|
case 'category':
|
||||||
$table = BB_CATEGORIES;
|
$table = BB_CATEGORIES;
|
||||||
|
@ -812,6 +814,10 @@ function get_info($mode, $id)
|
||||||
*/
|
*/
|
||||||
function get_list($mode, $id, $select)
|
function get_list($mode, $id, $select)
|
||||||
{
|
{
|
||||||
|
$table = null;
|
||||||
|
$idfield = null;
|
||||||
|
$order = null;
|
||||||
|
$namefield = null;
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'category':
|
case 'category':
|
||||||
$table = BB_CATEGORIES;
|
$table = BB_CATEGORIES;
|
||||||
|
@ -861,6 +867,10 @@ function get_list($mode, $id, $select)
|
||||||
*/
|
*/
|
||||||
function renumber_order($mode, $cat = 0)
|
function renumber_order($mode, $cat = 0)
|
||||||
{
|
{
|
||||||
|
$table = null;
|
||||||
|
$catfield = null;
|
||||||
|
$orderfield = null;
|
||||||
|
$idfield = null;
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'category':
|
case 'category':
|
||||||
$table = BB_CATEGORIES;
|
$table = BB_CATEGORIES;
|
||||||
|
|
|
@ -489,6 +489,7 @@ function get_rebuild_session_details($id, $details = 'all')
|
||||||
function get_processed_posts($mode = 'session')
|
function get_processed_posts($mode = 'session')
|
||||||
{
|
{
|
||||||
global $last_session_data;
|
global $last_session_data;
|
||||||
|
$row = [];
|
||||||
|
|
||||||
if ($mode == 'total') {
|
if ($mode == 'total') {
|
||||||
$sql = 'SELECT SUM(session_posts) as posts FROM ' . BB_SEARCH_REBUILD;
|
$sql = 'SELECT SUM(session_posts) as posts FROM ' . BB_SEARCH_REBUILD;
|
||||||
|
@ -542,6 +543,7 @@ function clear_search_tables($mode = '')
|
||||||
// We limit the result to 200, in order to avoid white (255).
|
// We limit the result to 200, in order to avoid white (255).
|
||||||
function create_percent_color($percent)
|
function create_percent_color($percent)
|
||||||
{
|
{
|
||||||
|
$percent_color = null;
|
||||||
$percent_ary = array(
|
$percent_ary = array(
|
||||||
'r' => array(86, 100),
|
'r' => array(86, 100),
|
||||||
'g' => array(0, 50),
|
'g' => array(0, 50),
|
||||||
|
|
|
@ -45,33 +45,21 @@ if (!isset($_GET[$passkey_key]) || !is_string($_GET[$passkey_key]) || strlen($_G
|
||||||
|
|
||||||
// Input var names
|
// Input var names
|
||||||
// String
|
// String
|
||||||
$input_vars_str = array(
|
$input_vars_str = ['info_hash', 'peer_id', 'event', $passkey_key];
|
||||||
'info_hash',
|
|
||||||
'peer_id',
|
|
||||||
'event',
|
|
||||||
$passkey_key,
|
|
||||||
);
|
|
||||||
// Numeric
|
// Numeric
|
||||||
$input_vars_num = array(
|
$input_vars_num = ['port', 'uploaded', 'downloaded', 'left', 'numwant', 'compact'];
|
||||||
'port',
|
|
||||||
'uploaded',
|
|
||||||
'downloaded',
|
|
||||||
'left',
|
|
||||||
'numwant',
|
|
||||||
'compact',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Init received data
|
// Init received data
|
||||||
// String
|
// String
|
||||||
foreach ($input_vars_str as $var_name) {
|
foreach ($input_vars_str as $var_name) {
|
||||||
$$var_name = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
|
${$var_name} = isset($_GET[$var_name]) ? (string)$_GET[$var_name] : null;
|
||||||
}
|
}
|
||||||
// Numeric
|
// Numeric
|
||||||
foreach ($input_vars_num as $var_name) {
|
foreach ($input_vars_num as $var_name) {
|
||||||
$$var_name = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
|
${$var_name} = isset($_GET[$var_name]) ? (float)$_GET[$var_name] : null;
|
||||||
}
|
}
|
||||||
// Passkey
|
// Passkey
|
||||||
$passkey = $$passkey_key ?? null;
|
$passkey = ${$passkey_key} ?? null;
|
||||||
|
|
||||||
// Verify request
|
// Verify request
|
||||||
// Required params (info_hash, peer_id, port, uploaded, downloaded, left, passkey)
|
// Required params (info_hash, peer_id, port, uploaded, downloaded, left, passkey)
|
||||||
|
@ -351,7 +339,7 @@ if ($stopped) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store peer info in cache
|
// Store peer info in cache
|
||||||
$lp_info = array(
|
$lp_info = [
|
||||||
'downloaded' => (float)$downloaded,
|
'downloaded' => (float)$downloaded,
|
||||||
'releaser' => (int)$releaser,
|
'releaser' => (int)$releaser,
|
||||||
'seeder' => (int)$seeder,
|
'seeder' => (int)$seeder,
|
||||||
|
@ -360,7 +348,7 @@ $lp_info = array(
|
||||||
'uploaded' => (float)$uploaded,
|
'uploaded' => (float)$uploaded,
|
||||||
'user_id' => (int)$user_id,
|
'user_id' => (int)$user_id,
|
||||||
'tor_type' => (int)$tor_type,
|
'tor_type' => (int)$tor_type,
|
||||||
);
|
];
|
||||||
|
|
||||||
$lp_info_cached = CACHE('tr_cache')->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE);
|
$lp_info_cached = CACHE('tr_cache')->set(PEER_HASH_PREFIX . $peer_hash, $lp_info, PEER_HASH_EXPIRE);
|
||||||
|
|
||||||
|
@ -387,13 +375,10 @@ if (!$output) {
|
||||||
$peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
|
$peers .= pack('Nn', ip2long(decode_ip($peer['ip'])), $peer['port']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$peers = array();
|
$peers = [];
|
||||||
|
|
||||||
foreach ($rowset as $peer) {
|
foreach ($rowset as $peer) {
|
||||||
$peers[] = array(
|
$peers[] = ['ip' => decode_ip($peer['ip']), 'port' => (int)$peer['port']];
|
||||||
'ip' => decode_ip($peer['ip']),
|
|
||||||
'port' => (int)$peer['port'],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,13 +397,13 @@ if (!$output) {
|
||||||
$leechers = $row['leechers'];
|
$leechers = $row['leechers'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = array(
|
$output = [
|
||||||
'interval' => (int)$announce_interval,
|
'interval' => (int)$announce_interval,
|
||||||
'min interval' => (int)$announce_interval,
|
'min interval' => (int)$announce_interval,
|
||||||
'peers' => $peers,
|
'peers' => $peers,
|
||||||
'complete' => (int)$seeders,
|
'complete' => (int)$seeders,
|
||||||
'incomplete' => (int)$leechers,
|
'incomplete' => (int)$leechers,
|
||||||
);
|
];
|
||||||
|
|
||||||
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
|
$peers_list_cached = CACHE('tr_cache')->set(PEERS_LIST_PREFIX . $topic_id, $output, PEERS_LIST_EXPIRE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,11 @@ $row = DB()->fetch_row("
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
");
|
");
|
||||||
|
|
||||||
$output['files'][$info_hash] = array(
|
$output['files'][$info_hash] = [
|
||||||
'complete' => (int)$row['seeders'],
|
'complete' => (int)$row['seeders'],
|
||||||
'downloaded' => (int)$row['complete_count'],
|
'downloaded' => (int)$row['complete_count'],
|
||||||
'incomplete' => (int)$row['leechers'],
|
'incomplete' => (int)$row['leechers'],
|
||||||
);
|
];
|
||||||
|
|
||||||
echo \Rych\Bencode\Bencode::encode($output);
|
echo \Rych\Bencode\Bencode::encode($output);
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,4 @@ UPDATE `bb_smilies` SET `code` = ':cd:', `smile_url` = 'cd.gif', `emoticon` = 'c
|
||||||
// 2.3.1-rc2
|
// 2.3.1-rc2
|
||||||
ALTER TABLE `bb_search_results` CHANGE `search_id` `search_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
|
ALTER TABLE `bb_search_results` CHANGE `search_id` `search_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
|
||||||
ALTER TABLE `bb_users` CHANGE `autologin_id` `autologin_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
|
ALTER TABLE `bb_users` CHANGE `autologin_id` `autologin_id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';
|
||||||
|
|
||||||
// 2.3.1-rc3
|
|
||||||
DELETE FROM `bb_config` WHERE `config_name` = 'cron_enabled';
|
DELETE FROM `bb_config` WHERE `config_name` = 'cron_enabled';
|
||||||
|
|
|
@ -473,6 +473,7 @@ function _set_var(&$result, $var, $type, $multibyte = false)
|
||||||
*/
|
*/
|
||||||
function get_var($var_name, $default, $multibyte = false)
|
function get_var($var_name, $default, $multibyte = false)
|
||||||
{
|
{
|
||||||
|
$type = null;
|
||||||
if (!isset($_REQUEST[$var_name]) ||
|
if (!isset($_REQUEST[$var_name]) ||
|
||||||
(is_array($_REQUEST[$var_name]) && !is_array($default)) ||
|
(is_array($_REQUEST[$var_name]) && !is_array($default)) ||
|
||||||
(is_array($default) && !is_array($_REQUEST[$var_name]))) {
|
(is_array($default) && !is_array($_REQUEST[$var_name]))) {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0)
|
function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0, $user_id = 0)
|
||||||
{
|
{
|
||||||
|
$lang = [];
|
||||||
// Generate Array, if it's not an array
|
// Generate Array, if it's not an array
|
||||||
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) {
|
if ($post_id_array === 0 && $attach_id_array === 0 && $page === 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -51,6 +51,10 @@ function read_byte($fp)
|
||||||
*/
|
*/
|
||||||
function image_getdimension($file)
|
function image_getdimension($file)
|
||||||
{
|
{
|
||||||
|
$xmax = null;
|
||||||
|
$xmin = null;
|
||||||
|
$ymax = null;
|
||||||
|
$ymin = null;
|
||||||
$size = @getimagesize($file);
|
$size = @getimagesize($file);
|
||||||
|
|
||||||
if ($size[0] != 0 || $size[1] != 0) {
|
if ($size[0] != 0 || $size[1] != 0) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ function attach_build_auth_levels($is_auth, &$s_auth_can)
|
||||||
function attachment_quota_settings($admin_mode, $submit = false, $mode)
|
function attachment_quota_settings($admin_mode, $submit = false, $mode)
|
||||||
{
|
{
|
||||||
global $template, $lang, $attach_config;
|
global $template, $lang, $attach_config;
|
||||||
|
$this_userdata = [];
|
||||||
|
|
||||||
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
|
if ($attach_config['upload_dir'][0] == '/' || ($attach_config['upload_dir'][0] != '/' && $attach_config['upload_dir'][1] == ':')) {
|
||||||
$upload_dir = $attach_config['upload_dir'];
|
$upload_dir = $attach_config['upload_dir'];
|
||||||
|
|
|
@ -98,6 +98,7 @@ function download_select($select_name, $group_id = 0)
|
||||||
function category_select($select_name, $group_id = 0)
|
function category_select($select_name, $group_id = 0)
|
||||||
{
|
{
|
||||||
global $types_category, $modes_category;
|
global $types_category, $modes_category;
|
||||||
|
$category_type = null;
|
||||||
|
|
||||||
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
|
$sql = 'SELECT group_id, cat_id FROM ' . BB_EXTENSION_GROUPS;
|
||||||
|
|
||||||
|
@ -172,6 +173,7 @@ function size_select($select_name, $size_compare)
|
||||||
function quota_limit_select($select_name, $default_quota = 0)
|
function quota_limit_select($select_name, $default_quota = 0)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
$quota_name = [];
|
||||||
|
|
||||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||||
|
|
||||||
|
@ -203,6 +205,7 @@ function quota_limit_select($select_name, $default_quota = 0)
|
||||||
function default_quota_limit_select($select_name, $default_quota = 0)
|
function default_quota_limit_select($select_name, $default_quota = 0)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
$quota_name = [];
|
||||||
|
|
||||||
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
$sql = 'SELECT quota_limit_id, quota_desc FROM ' . BB_QUOTA_LIMITS . ' ORDER BY quota_limit ASC';
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ function get_supported_image_types($type)
|
||||||
function create_thumbnail($source, $new_file, $mimetype)
|
function create_thumbnail($source, $new_file, $mimetype)
|
||||||
{
|
{
|
||||||
global $attach_config, $imagick;
|
global $attach_config, $imagick;
|
||||||
|
$image = null;
|
||||||
|
|
||||||
$source = amod_realpath($source);
|
$source = amod_realpath($source);
|
||||||
$min_filesize = (int)$attach_config['img_min_thumb_filesize'];
|
$min_filesize = (int)$attach_config['img_min_thumb_filesize'];
|
||||||
|
|
|
@ -290,7 +290,7 @@ function strip_bbcode($message, $stripquotes = true, $fast_and_dirty = false, $s
|
||||||
if ($fast_and_dirty) {
|
if ($fast_and_dirty) {
|
||||||
// any old thing in square brackets
|
// any old thing in square brackets
|
||||||
$find[] = '#\[.*/?\]#siU';
|
$find[] = '#\[.*/?\]#siU';
|
||||||
$replace = '';
|
$replace = [];
|
||||||
|
|
||||||
$message = preg_replace($find, $replace, $message);
|
$message = preg_replace($find, $replace, $message);
|
||||||
} // the preferable way to remove bbcode
|
} // the preferable way to remove bbcode
|
||||||
|
|
|
@ -419,6 +419,7 @@ function delta_time($timestamp_1, $timestamp_2 = TIMENOW, $granularity = 'auto')
|
||||||
|
|
||||||
function get_select($select, $selected = null, $return_as = 'html', $first_opt = '»» Выбрать ')
|
function get_select($select, $selected = null, $return_as = 'html', $first_opt = '»» Выбрать ')
|
||||||
{
|
{
|
||||||
|
$select_name = null;
|
||||||
$select_ary = array();
|
$select_ary = array();
|
||||||
|
|
||||||
switch ($select) {
|
switch ($select) {
|
||||||
|
@ -921,6 +922,7 @@ function bb_update_config($params, $table = BB_CONFIG)
|
||||||
|
|
||||||
function get_db_stat($mode)
|
function get_db_stat($mode)
|
||||||
{
|
{
|
||||||
|
$sql = null;
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'usercount':
|
case 'usercount':
|
||||||
$sql = "SELECT COUNT(user_id) AS total FROM " . BB_USERS;
|
$sql = "SELECT COUNT(user_id) AS total FROM " . BB_USERS;
|
||||||
|
@ -1480,7 +1482,7 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis
|
||||||
|
|
||||||
// get the good list
|
// get the good list
|
||||||
$list_name = 'forum_display_' . $list;
|
$list_name = 'forum_display_' . $list;
|
||||||
$listrow = $$list_name;
|
$listrow = ${$list_name};
|
||||||
|
|
||||||
// init the result
|
// init the result
|
||||||
$res = '';
|
$res = '';
|
||||||
|
|
|
@ -219,13 +219,14 @@ class Common
|
||||||
{
|
{
|
||||||
global $lang, $log_action;
|
global $lang, $log_action;
|
||||||
|
|
||||||
|
$topic_csv = [];
|
||||||
$prune = ($mode_or_topic_id === 'prune');
|
$prune = ($mode_or_topic_id === 'prune');
|
||||||
|
|
||||||
if (!$prune and !$topic_csv = get_id_csv($mode_or_topic_id)) {
|
if (!$prune and !$topic_csv = get_id_csv($mode_or_topic_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log_topics = $sync_forums = array();
|
$log_topics = $sync_forums = [];
|
||||||
|
|
||||||
if ($prune) {
|
if ($prune) {
|
||||||
$sync_forums[$forum_id] = true;
|
$sync_forums[$forum_id] = true;
|
||||||
|
@ -300,7 +301,7 @@ class Common
|
||||||
");
|
");
|
||||||
|
|
||||||
// Get array for atom update
|
// Get array for atom update
|
||||||
$atom_csv = array();
|
$atom_csv = [];
|
||||||
foreach (DB()->fetch_rowset('SELECT user_id FROM ' . $tmp_user_posts) as $at) {
|
foreach (DB()->fetch_rowset('SELECT user_id FROM ' . $tmp_user_posts) as $at) {
|
||||||
$atom_csv[] = $at['user_id'];
|
$atom_csv[] = $at['user_id'];
|
||||||
}
|
}
|
||||||
|
@ -394,11 +395,11 @@ class Common
|
||||||
$row['topic_title'] = '<i>' . $lang['TOPIC_MOVED'] . '</i> ' . $row['topic_title'];
|
$row['topic_title'] = '<i>' . $lang['TOPIC_MOVED'] . '</i> ' . $row['topic_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$log_action->mod('mod_topic_delete', array(
|
$log_action->mod('mod_topic_delete', [
|
||||||
'forum_id' => $row['forum_id'],
|
'forum_id' => $row['forum_id'],
|
||||||
'topic_id' => $row['topic_id'],
|
'topic_id' => $row['topic_id'],
|
||||||
'topic_title' => $row['topic_title'],
|
'topic_title' => $row['topic_title'],
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,8 +449,8 @@ class Common
|
||||||
|
|
||||||
$sql = "SELECT * FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND topic_status != " . TOPIC_MOVED . " $where_sql";
|
$sql = "SELECT * FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND topic_status != " . TOPIC_MOVED . " $where_sql";
|
||||||
|
|
||||||
$topics = array();
|
$topics = [];
|
||||||
$sync_forums = array($to_forum_id => true);
|
$sync_forums = [$to_forum_id => true];
|
||||||
|
|
||||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||||
if ($row['forum_id'] != $to_forum_id) {
|
if ($row['forum_id'] != $to_forum_id) {
|
||||||
|
@ -464,10 +465,10 @@ class Common
|
||||||
|
|
||||||
// Insert topic in the old forum that indicates that the topic has moved
|
// Insert topic in the old forum that indicates that the topic has moved
|
||||||
if ($leave_shadow) {
|
if ($leave_shadow) {
|
||||||
$shadows = array();
|
$shadows = [];
|
||||||
|
|
||||||
foreach ($topics as $topic_id => $row) {
|
foreach ($topics as $topic_id => $row) {
|
||||||
$shadows[] = array(
|
$shadows[] = [
|
||||||
'forum_id' => $row['forum_id'],
|
'forum_id' => $row['forum_id'],
|
||||||
'topic_title' => $row['topic_title'],
|
'topic_title' => $row['topic_title'],
|
||||||
'topic_poster' => $row['topic_poster'],
|
'topic_poster' => $row['topic_poster'],
|
||||||
|
@ -481,7 +482,7 @@ class Common
|
||||||
'topic_last_post_id' => $row['topic_last_post_id'],
|
'topic_last_post_id' => $row['topic_last_post_id'],
|
||||||
'topic_moved_id' => $topic_id,
|
'topic_moved_id' => $topic_id,
|
||||||
'topic_last_post_time' => $row['topic_last_post_time'],
|
'topic_last_post_time' => $row['topic_last_post_time'],
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
if ($sql_args = DB()->build_array('MULTI_INSERT', $shadows)) {
|
if ($sql_args = DB()->build_array('MULTI_INSERT', $shadows)) {
|
||||||
DB()->query("INSERT INTO " . BB_TOPICS . $sql_args);
|
DB()->query("INSERT INTO " . BB_TOPICS . $sql_args);
|
||||||
|
@ -505,12 +506,12 @@ class Common
|
||||||
|
|
||||||
// Log action
|
// Log action
|
||||||
foreach ($topics as $topic_id => $row) {
|
foreach ($topics as $topic_id => $row) {
|
||||||
$log_action->mod('mod_topic_move', array(
|
$log_action->mod('mod_topic_move', [
|
||||||
'forum_id' => $row['forum_id'],
|
'forum_id' => $row['forum_id'],
|
||||||
'forum_id_new' => $to_forum_id,
|
'forum_id_new' => $to_forum_id,
|
||||||
'topic_id' => $topic_id,
|
'topic_id' => $topic_id,
|
||||||
'topic_title' => $row['topic_title'],
|
'topic_title' => $row['topic_title'],
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -556,7 +557,7 @@ class Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect data for logs, sync..
|
// Collect data for logs, sync..
|
||||||
$log_topics = $sync_forums = $sync_topics = $sync_users = array();
|
$log_topics = $sync_forums = $sync_topics = $sync_users = [];
|
||||||
|
|
||||||
if ($del_user_posts) {
|
if ($del_user_posts) {
|
||||||
$sync_topics = DB()->fetch_rowset("SELECT DISTINCT topic_id FROM " . BB_POSTS . " WHERE poster_id IN($user_csv)", 'topic_id');
|
$sync_topics = DB()->fetch_rowset("SELECT DISTINCT topic_id FROM " . BB_POSTS . " WHERE poster_id IN($user_csv)", 'topic_id');
|
||||||
|
@ -599,7 +600,7 @@ class Common
|
||||||
if ($del_user_posts) {
|
if ($del_user_posts) {
|
||||||
$where_sql = "poster_id IN($user_csv)";
|
$where_sql = "poster_id IN($user_csv)";
|
||||||
|
|
||||||
$exclude_posts_ary = array();
|
$exclude_posts_ary = [];
|
||||||
foreach (DB()->fetch_rowset("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_poster IN($user_csv)") as $row) {
|
foreach (DB()->fetch_rowset("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_poster IN($user_csv)") as $row) {
|
||||||
$exclude_posts_ary[] = $row['topic_first_post_id'];
|
$exclude_posts_ary[] = $row['topic_first_post_id'];
|
||||||
}
|
}
|
||||||
|
@ -658,16 +659,10 @@ class Common
|
||||||
|
|
||||||
// Log action
|
// Log action
|
||||||
if ($del_user_posts) {
|
if ($del_user_posts) {
|
||||||
$log_action->admin('mod_post_delete', array(
|
$log_action->admin('mod_post_delete', ['log_msg' => 'user: ' . self::get_usernames_for_log($user_id) . "<br />posts: $deleted_posts_count"]);
|
||||||
'log_msg' => 'user: ' . self::get_usernames_for_log($user_id) . "<br />posts: $deleted_posts_count",
|
|
||||||
));
|
|
||||||
} elseif (!\defined('IN_CRON')) {
|
} elseif (!\defined('IN_CRON')) {
|
||||||
foreach ($log_topics as $row) {
|
foreach ($log_topics as $row) {
|
||||||
$log_action->mod('mod_post_delete', array(
|
$log_action->mod('mod_post_delete', ['forum_id' => $row['forum_id'], 'topic_id' => $row['topic_id'], 'topic_title' => $row['topic_title']]);
|
||||||
'forum_id' => $row['forum_id'],
|
|
||||||
'topic_id' => $row['topic_id'],
|
|
||||||
'topic_title' => $row['topic_title'],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,9 +705,7 @@ class Common
|
||||||
$user_csv = get_id_csv($user_id);
|
$user_csv = get_id_csv($user_id);
|
||||||
|
|
||||||
// LOG
|
// LOG
|
||||||
$log_action->admin('adm_user_delete', array(
|
$log_action->admin('adm_user_delete', ['log_msg' => self::get_usernames_for_log($user_id)]);
|
||||||
'log_msg' => self::get_usernames_for_log($user_id),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Avatar
|
// Avatar
|
||||||
$result = DB()->query("SELECT user_id, avatar_ext_id FROM " . BB_USERS . " WHERE avatar_ext_id > 0 AND user_id IN($user_csv)");
|
$result = DB()->query("SELECT user_id, avatar_ext_id FROM " . BB_USERS . " WHERE avatar_ext_id > 0 AND user_id IN($user_csv)");
|
||||||
|
@ -795,7 +788,7 @@ class Common
|
||||||
*/
|
*/
|
||||||
private static function get_usernames_for_log($user_id)
|
private static function get_usernames_for_log($user_id)
|
||||||
{
|
{
|
||||||
$users_log_msg = array();
|
$users_log_msg = [];
|
||||||
|
|
||||||
if ($user_csv = get_id_csv($user_id)) {
|
if ($user_csv = get_id_csv($user_id)) {
|
||||||
$sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN($user_csv)";
|
$sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN($user_csv)";
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Torrent
|
||||||
|
|
||||||
if (isset($_POST[$field_name])) {
|
if (isset($_POST[$field_name])) {
|
||||||
// Get new status
|
// Get new status
|
||||||
$in_sql = array();
|
$in_sql = [];
|
||||||
|
|
||||||
foreach ($_POST[$field_name] as $i => $val) {
|
foreach ($_POST[$field_name] as $i => $val) {
|
||||||
$in_sql[] = (int)$val;
|
$in_sql[] = (int)$val;
|
||||||
|
@ -66,7 +66,7 @@ class Torrent
|
||||||
global $template;
|
global $template;
|
||||||
|
|
||||||
foreach ($default_cfg as $config_name => $config_value) {
|
foreach ($default_cfg as $config_name => $config_value) {
|
||||||
$template->assign_vars(array(strtoupper($config_name) => htmlspecialchars($cfg[$config_name])));
|
$template->assign_vars([strtoupper($config_name) => htmlspecialchars($cfg[$config_name])]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,15 +82,15 @@ class Torrent
|
||||||
|
|
||||||
foreach ($default_cfg as $config_name => $config_value) {
|
foreach ($default_cfg as $config_name => $config_value) {
|
||||||
// YES/NO 'checked="checked"'
|
// YES/NO 'checked="checked"'
|
||||||
$template->assign_vars(array(
|
$template->assign_vars([
|
||||||
strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? HTML_CHECKED : '',
|
strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? HTML_CHECKED : '',
|
||||||
strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? HTML_CHECKED : '',
|
strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? HTML_CHECKED : '',
|
||||||
));
|
]);
|
||||||
// YES/NO lang vars
|
// YES/NO lang vars
|
||||||
$template->assign_vars(array(
|
$template->assign_vars([
|
||||||
'L_' . strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? "<u>$lang[YES]</u>" : $lang['YES'],
|
'L_' . strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? "<u>$lang[YES]</u>" : $lang['YES'],
|
||||||
'L_' . strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? "<u>$lang[NO]</u>" : $lang['NO'],
|
'L_' . strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? "<u>$lang[NO]</u>" : $lang['NO'],
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,11 +104,11 @@ class Torrent
|
||||||
global $template, $lang;
|
global $template, $lang;
|
||||||
|
|
||||||
foreach ($default_cfg as $config_name => $config_value) {
|
foreach ($default_cfg as $config_name => $config_value) {
|
||||||
$template->assign_vars(array(
|
$template->assign_vars([
|
||||||
'L_' . strtoupper($config_name) => $lang[$config_name] ?? '',
|
'L_' . strtoupper($config_name) => $lang[$config_name] ?? '',
|
||||||
'L_' . strtoupper($config_name) . '_EXPL' => $lang[$config_name . '_expl'] ?? '',
|
'L_' . strtoupper($config_name) . '_EXPL' => $lang[$config_name . '_expl'] ?? '',
|
||||||
'L_' . strtoupper($config_name) . '_HEAD' => $lang[$config_name . '_head'] ?? '',
|
'L_' . strtoupper($config_name) . '_HEAD' => $lang[$config_name . '_head'] ?? '',
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class Torrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_update_config(array($config_name => $config_value), $table_name);
|
bb_update_config([$config_name => $config_value], $table_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ class Atom
|
||||||
public static function update_forum_feed($forum_id, $forum_data)
|
public static function update_forum_feed($forum_id, $forum_data)
|
||||||
{
|
{
|
||||||
global $bb_cfg, $lang;
|
global $bb_cfg, $lang;
|
||||||
|
$sql = null;
|
||||||
$file_path = $bb_cfg['atom']['path'] . '/f/' . $forum_id . '.atom';
|
$file_path = $bb_cfg['atom']['path'] . '/f/' . $forum_id . '.atom';
|
||||||
$select_tor_sql = $join_tor_sql = '';
|
$select_tor_sql = $join_tor_sql = '';
|
||||||
if ($forum_id == 0) {
|
if ($forum_id == 0) {
|
||||||
|
@ -70,7 +71,7 @@ class Atom
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
$topics_tmp = DB()->fetch_rowset($sql);
|
$topics_tmp = DB()->fetch_rowset($sql);
|
||||||
$topics = array();
|
$topics = [];
|
||||||
foreach ($topics_tmp as $topic) {
|
foreach ($topics_tmp as $topic) {
|
||||||
if (isset($topic['topic_status'])) {
|
if (isset($topic['topic_status'])) {
|
||||||
if ($topic['topic_status'] == TOPIC_MOVED) {
|
if ($topic['topic_status'] == TOPIC_MOVED) {
|
||||||
|
@ -124,7 +125,7 @@ class Atom
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
";
|
";
|
||||||
$topics_tmp = DB()->fetch_rowset($sql);
|
$topics_tmp = DB()->fetch_rowset($sql);
|
||||||
$topics = array();
|
$topics = [];
|
||||||
foreach ($topics_tmp as $topic) {
|
foreach ($topics_tmp as $topic) {
|
||||||
if (isset($topic['topic_status'])) {
|
if (isset($topic['topic_status'])) {
|
||||||
if ($topic['topic_status'] == TOPIC_MOVED) {
|
if ($topic['topic_status'] == TOPIC_MOVED) {
|
||||||
|
@ -163,6 +164,8 @@ class Atom
|
||||||
private static function create_atom($file_path, $mode, $id, $title, $topics)
|
private static function create_atom($file_path, $mode, $id, $title, $topics)
|
||||||
{
|
{
|
||||||
global $lang;
|
global $lang;
|
||||||
|
$date = null;
|
||||||
|
$time = null;
|
||||||
$dir = \dirname($file_path);
|
$dir = \dirname($file_path);
|
||||||
if (!file_exists($dir)) {
|
if (!file_exists($dir)) {
|
||||||
if (!bb_mkdir($dir)) {
|
if (!bb_mkdir($dir)) {
|
||||||
|
@ -192,8 +195,8 @@ class Atom
|
||||||
$tor_size = str_replace(' ', ' ', ' [' . humn_size($topic['tor_size']) . ']');
|
$tor_size = str_replace(' ', ' ', ' [' . humn_size($topic['tor_size']) . ']');
|
||||||
}
|
}
|
||||||
$topic_title = $topic['topic_title'];
|
$topic_title = $topic['topic_title'];
|
||||||
$orig_word = array();
|
$orig_word = [];
|
||||||
$replacement_word = array();
|
$replacement_word = [];
|
||||||
obtain_word_list($orig_word, $replacement_word);
|
obtain_word_list($orig_word, $replacement_word);
|
||||||
if (\count($orig_word)) {
|
if (\count($orig_word)) {
|
||||||
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
|
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
|
||||||
|
|
|
@ -247,7 +247,7 @@ class Attach
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->num_attachments = \count($this->attachment_list);
|
$this->num_attachments = is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0;
|
||||||
|
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
if ($mode === 'newtopic' || $mode === 'reply' || $mode === 'editpost') {
|
if ($mode === 'newtopic' || $mode === 'reply' || $mode === 'editpost') {
|
||||||
|
@ -315,7 +315,7 @@ class Attach
|
||||||
|
|
||||||
// restore values :)
|
// restore values :)
|
||||||
if (isset($_POST['attachment_list'])) {
|
if (isset($_POST['attachment_list'])) {
|
||||||
for ($i = 0, $iMax = \count($actual_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($actual_list) || $actual_list instanceof \Countable ? \count($actual_list) : 0; $i < $iMax; $i++) {
|
||||||
$restore = false;
|
$restore = false;
|
||||||
$del_thumb = false;
|
$del_thumb = false;
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ class Attach
|
||||||
|
|
||||||
$this->attachment_comment_list = [];
|
$this->attachment_comment_list = [];
|
||||||
|
|
||||||
for ($i = 0, $iMax = \count($this->attachment_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0; $i < $iMax; $i++) {
|
||||||
$this->attachment_comment_list[$i] = $actual_comment_list[$i];
|
$this->attachment_comment_list[$i] = $actual_comment_list[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ class Attach
|
||||||
$attachment_id = 0;
|
$attachment_id = 0;
|
||||||
$actual_element = 0;
|
$actual_element = 0;
|
||||||
|
|
||||||
for ($i = 0, $iMax = \count($actual_id_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($actual_id_list) || $actual_id_list instanceof \Countable ? \count($actual_id_list) : 0; $i < $iMax; $i++) {
|
||||||
if (isset($_POST['update_attachment'][$actual_id_list[$i]])) {
|
if (isset($_POST['update_attachment'][$actual_id_list[$i]])) {
|
||||||
$attachment_id = (int)$actual_id_list[$i];
|
$attachment_id = (int)$actual_id_list[$i];
|
||||||
$actual_element = $i;
|
$actual_element = $i;
|
||||||
|
@ -532,7 +532,7 @@ class Attach
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mode === 'attach_list') {
|
if ($mode === 'attach_list') {
|
||||||
for ($i = 0, $iMax = \count($this->attachment_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0; $i < $iMax; $i++) {
|
||||||
if ($this->attachment_id_list[$i]) {
|
if ($this->attachment_id_list[$i]) {
|
||||||
//bt
|
//bt
|
||||||
if ($this->attachment_extension_list[$i] === TORRENT_EXT && !\defined('TORRENT_ATTACH_ID')) {
|
if ($this->attachment_extension_list[$i] === TORRENT_EXT && !\defined('TORRENT_ATTACH_ID')) {
|
||||||
|
@ -659,7 +659,7 @@ class Attach
|
||||||
|
|
||||||
if ($this->attachment_list) {
|
if ($this->attachment_list) {
|
||||||
$hidden = '';
|
$hidden = '';
|
||||||
for ($i = 0, $iMax = \count($this->attachment_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0; $i < $iMax; $i++) {
|
||||||
$hidden .= '<input type="hidden" name="attachment_list[]" value="' . $this->attachment_list[$i] . '" />';
|
$hidden .= '<input type="hidden" name="attachment_list[]" value="' . $this->attachment_list[$i] . '" />';
|
||||||
$hidden .= '<input type="hidden" name="filename_list[]" value="' . $this->attachment_filename_list[$i] . '" />';
|
$hidden .= '<input type="hidden" name="filename_list[]" value="' . $this->attachment_filename_list[$i] . '" />';
|
||||||
$hidden .= '<input type="hidden" name="extension_list[]" value="' . $this->attachment_extension_list[$i] . '" />';
|
$hidden .= '<input type="hidden" name="extension_list[]" value="' . $this->attachment_extension_list[$i] . '" />';
|
||||||
|
@ -691,7 +691,7 @@ class Attach
|
||||||
'TPL_POSTED_ATTACHMENTS' => true,
|
'TPL_POSTED_ATTACHMENTS' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
for ($i = 0, $iMax = \count($this->attachment_list); $i < $iMax; $i++) {
|
for ($i = 0, $iMax = is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0; $i < $iMax; $i++) {
|
||||||
if (@$this->attachment_id_list[$i] == 0) {
|
if (@$this->attachment_id_list[$i] == 0) {
|
||||||
$download_link = $upload_dir . '/' . basename($this->attachment_list[$i]);
|
$download_link = $upload_dir . '/' . basename($this->attachment_list[$i]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,7 +38,7 @@ class AttachPosting extends Attach
|
||||||
$this->do_insert_attachment('attach_list', 'post', $post_id);
|
$this->do_insert_attachment('attach_list', 'post', $post_id);
|
||||||
$this->do_insert_attachment('last_attachment', 'post', $post_id);
|
$this->do_insert_attachment('last_attachment', 'post', $post_id);
|
||||||
|
|
||||||
if ((\count($this->attachment_list) > 0 || $this->post_attach) && !isset($_POST['update_attachment'])) {
|
if (((is_array($this->attachment_list) || $this->attachment_list instanceof \Countable ? \count($this->attachment_list) : 0) > 0 || $this->post_attach) && !isset($_POST['update_attachment'])) {
|
||||||
$sql = 'UPDATE ' . BB_POSTS . ' SET post_attachment = 1 WHERE post_id = ' . (int)$post_id;
|
$sql = 'UPDATE ' . BB_POSTS . ' SET post_attachment = 1 WHERE post_id = ' . (int)$post_id;
|
||||||
|
|
||||||
if (!DB()->sql_query($sql)) {
|
if (!DB()->sql_query($sql)) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Common
|
||||||
if ($get_miss_key_callback) {
|
if ($get_miss_key_callback) {
|
||||||
return $get_miss_key_callback($name);
|
return $get_miss_key_callback($name);
|
||||||
}
|
}
|
||||||
return \is_array($name) ? array() : false;
|
return \is_array($name) ? [] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ class Common
|
||||||
public $sql_timetotal = 0;
|
public $sql_timetotal = 0;
|
||||||
public $cur_query_time = 0;
|
public $cur_query_time = 0;
|
||||||
|
|
||||||
public $dbg = array();
|
public $dbg = [];
|
||||||
public $dbg_id = 0;
|
public $dbg_id = 0;
|
||||||
public $dbg_enabled = false;
|
public $dbg_enabled = false;
|
||||||
public $cur_query;
|
public $cur_query;
|
||||||
|
|
|
@ -29,6 +29,7 @@ class File extends Common
|
||||||
|
|
||||||
public function get($name, $get_miss_key_callback = '', $ttl = 0)
|
public function get($name, $get_miss_key_callback = '', $ttl = 0)
|
||||||
{
|
{
|
||||||
|
$filecache = [];
|
||||||
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
||||||
|
|
||||||
$this->cur_query = "cache->get('$name')";
|
$this->cur_query = "cache->get('$name')";
|
||||||
|
@ -55,10 +56,7 @@ class File extends Common
|
||||||
|
|
||||||
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
$filename = $this->dir . clean_filename($this->prefix . $name) . '.php';
|
||||||
$expire = TIMENOW + $ttl;
|
$expire = TIMENOW + $ttl;
|
||||||
$cache_data = array(
|
$cache_data = ['expire' => $expire, 'value' => $value];
|
||||||
'expire' => $expire,
|
|
||||||
'value' => $value,
|
|
||||||
);
|
|
||||||
|
|
||||||
$filecache = "<?php\n";
|
$filecache = "<?php\n";
|
||||||
$filecache .= "if (!defined('BB_ROOT')) die(basename(__FILE__));\n";
|
$filecache .= "if (!defined('BB_ROOT')) die(basename(__FILE__));\n";
|
||||||
|
@ -107,6 +105,7 @@ class File extends Common
|
||||||
|
|
||||||
public function gc($expire_time = TIMENOW)
|
public function gc($expire_time = TIMENOW)
|
||||||
{
|
{
|
||||||
|
$filecache = [];
|
||||||
$clear = false;
|
$clear = false;
|
||||||
|
|
||||||
if (is_dir($this->dir)) {
|
if (is_dir($this->dir)) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Sqlite extends Common
|
||||||
public $used = true;
|
public $used = true;
|
||||||
public $db;
|
public $db;
|
||||||
public $prefix;
|
public $prefix;
|
||||||
public $cfg = array(
|
public $cfg = [
|
||||||
'db_file_path' => '/path/to/cache.db.sqlite',
|
'db_file_path' => '/path/to/cache.db.sqlite',
|
||||||
'table_name' => 'cache',
|
'table_name' => 'cache',
|
||||||
'table_schema' => 'CREATE TABLE cache (
|
'table_schema' => 'CREATE TABLE cache (
|
||||||
|
@ -32,7 +32,7 @@ class Sqlite extends Common
|
||||||
'pconnect' => true,
|
'pconnect' => true,
|
||||||
'con_required' => true,
|
'con_required' => true,
|
||||||
'log_name' => 'CACHE',
|
'log_name' => 'CACHE',
|
||||||
);
|
];
|
||||||
|
|
||||||
public function __construct($cfg, $prefix = null)
|
public function __construct($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
|
@ -44,10 +44,10 @@ class Sqlite extends Common
|
||||||
public function get($name, $get_miss_key_callback = '', $ttl = 604800)
|
public function get($name, $get_miss_key_callback = '', $ttl = 604800)
|
||||||
{
|
{
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return \is_array($name) ? array() : false;
|
return \is_array($name) ? [] : false;
|
||||||
}
|
}
|
||||||
$this->db->shard($name);
|
$this->db->shard($name);
|
||||||
$cached_items = array();
|
$cached_items = [];
|
||||||
$this->prefix_len = \strlen($this->prefix);
|
$this->prefix_len = \strlen($this->prefix);
|
||||||
$this->prefix_sql = SQLite3::escapeString($this->prefix);
|
$this->prefix_sql = SQLite3::escapeString($this->prefix);
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,16 @@ use SQLite3;
|
||||||
*/
|
*/
|
||||||
class SqliteCommon extends Common
|
class SqliteCommon extends Common
|
||||||
{
|
{
|
||||||
public $cfg = array(
|
public $cfg = [
|
||||||
'db_file_path' => 'sqlite.db',
|
'db_file_path' => 'sqlite.db',
|
||||||
'table_name' => 'table_name',
|
'table_name' => 'table_name',
|
||||||
'table_schema' => 'CREATE TABLE table_name (...)',
|
'table_schema' => 'CREATE TABLE table_name (...)',
|
||||||
'pconnect' => true,
|
'pconnect' => true,
|
||||||
'con_required' => true,
|
'con_required' => true,
|
||||||
'log_name' => 'SQLite',
|
'log_name' => 'SQLite',
|
||||||
'shard_type' => 'none', # none, string, int (тип перевичного ключа для шардинга)
|
'shard_type' => 'none', # none, string, int (тип перевичного ключа для шардинга)
|
||||||
'shard_val' => 0, # для string - кол. начальных символов, для int - делитель (будет использован остаток от деления)
|
'shard_val' => 0, # для string - кол. начальных символов, для int - делитель (будет использован остаток от деления)
|
||||||
);
|
];
|
||||||
public $engine = 'SQLite';
|
public $engine = 'SQLite';
|
||||||
public $dbh;
|
public $dbh;
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
|
@ -134,7 +134,7 @@ class SqliteCommon extends Common
|
||||||
public function fetch_rowset($query)
|
public function fetch_rowset($query)
|
||||||
{
|
{
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
$rowset = array();
|
$rowset = [];
|
||||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$rowset[] = $row;
|
$rowset[] = $row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ class File extends Common
|
||||||
|
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
|
$item = null;
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
$src = $this->_debug_find_caller('enqueue');
|
$src = $this->_debug_find_caller('enqueue');
|
||||||
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
||||||
|
|
|
@ -86,6 +86,7 @@ class Memcache extends Common
|
||||||
|
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
|
$item = null;
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
$src = $this->_debug_find_caller('enqueue');
|
$src = $this->_debug_find_caller('enqueue');
|
||||||
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
||||||
|
|
|
@ -84,6 +84,7 @@ class Redis extends Common
|
||||||
|
|
||||||
public function _fetch_from_store()
|
public function _fetch_from_store()
|
||||||
{
|
{
|
||||||
|
$item = null;
|
||||||
if (!$items = $this->queued_items) {
|
if (!$items = $this->queued_items) {
|
||||||
$src = $this->_debug_find_caller('enqueue');
|
$src = $this->_debug_find_caller('enqueue');
|
||||||
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
trigger_error("Datastore: item '$item' already enqueued [$src]", E_USER_ERROR);
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Sqlite extends Common
|
||||||
public $engine = 'SQLite';
|
public $engine = 'SQLite';
|
||||||
public $db;
|
public $db;
|
||||||
public $prefix;
|
public $prefix;
|
||||||
public $cfg = array(
|
public $cfg = [
|
||||||
'db_file_path' => '/path/to/datastore.db.sqlite',
|
'db_file_path' => '/path/to/datastore.db.sqlite',
|
||||||
'table_name' => 'datastore',
|
'table_name' => 'datastore',
|
||||||
'table_schema' => 'CREATE TABLE datastore (
|
'table_schema' => 'CREATE TABLE datastore (
|
||||||
|
@ -31,7 +31,7 @@ class Sqlite extends Common
|
||||||
'pconnect' => true,
|
'pconnect' => true,
|
||||||
'con_required' => true,
|
'con_required' => true,
|
||||||
'log_name' => 'DATASTORE',
|
'log_name' => 'DATASTORE',
|
||||||
);
|
];
|
||||||
|
|
||||||
public function __construct($cfg, $prefix = null)
|
public function __construct($cfg, $prefix = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,16 +17,16 @@ use SQLite3;
|
||||||
*/
|
*/
|
||||||
class SqliteCommon extends Common
|
class SqliteCommon extends Common
|
||||||
{
|
{
|
||||||
public $cfg = array(
|
public $cfg = [
|
||||||
'db_file_path' => 'sqlite.db',
|
'db_file_path' => 'sqlite.db',
|
||||||
'table_name' => 'table_name',
|
'table_name' => 'table_name',
|
||||||
'table_schema' => 'CREATE TABLE table_name (...)',
|
'table_schema' => 'CREATE TABLE table_name (...)',
|
||||||
'pconnect' => true,
|
'pconnect' => true,
|
||||||
'con_required' => true,
|
'con_required' => true,
|
||||||
'log_name' => 'SQLite',
|
'log_name' => 'SQLite',
|
||||||
'shard_type' => 'none', # none, string, int (тип перевичного ключа для шардинга)
|
'shard_type' => 'none', # none, string, int (тип перевичного ключа для шардинга)
|
||||||
'shard_val' => 0, # для string - кол. начальных символов, для int - делитель (будет использован остаток от деления)
|
'shard_val' => 0, # для string - кол. начальных символов, для int - делитель (будет использован остаток от деления)
|
||||||
);
|
];
|
||||||
public $engine = 'SQLite';
|
public $engine = 'SQLite';
|
||||||
public $dbh;
|
public $dbh;
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
|
@ -134,7 +134,7 @@ class SqliteCommon extends Common
|
||||||
public function fetch_rowset($query)
|
public function fetch_rowset($query)
|
||||||
{
|
{
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
$rowset = array();
|
$rowset = [];
|
||||||
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
$rowset[] = $row;
|
$rowset[] = $row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ class DateDelta
|
||||||
*/
|
*/
|
||||||
public function getDelta($first, $last)
|
public function getDelta($first, $last)
|
||||||
{
|
{
|
||||||
|
$delta = [];
|
||||||
if ($last < $first) {
|
if ($last < $first) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Dev
|
||||||
$log = '';
|
$log = '';
|
||||||
|
|
||||||
foreach ($db_obj->dbg as $i => $dbg) {
|
foreach ($db_obj->dbg as $i => $dbg) {
|
||||||
$id = "sql_{$i}_" . mt_rand();
|
$id = "sql_{$i}_" . random_int(0, mt_getrandmax());
|
||||||
$sql = short_query($dbg['sql'], true);
|
$sql = short_query($dbg['sql'], true);
|
||||||
$time = sprintf('%.4f', $dbg['time']);
|
$time = sprintf('%.4f', $dbg['time']);
|
||||||
$perc = @sprintf('[%2d]', $dbg['time'] * 100 / $db_obj->sql_timetotal);
|
$perc = @sprintf('[%2d]', $dbg['time'] * 100 / $db_obj->sql_timetotal);
|
||||||
|
|
|
@ -109,12 +109,12 @@ class Group
|
||||||
*/
|
*/
|
||||||
public static function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time = TIMENOW)
|
public static function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time = TIMENOW)
|
||||||
{
|
{
|
||||||
$args = DB()->build_array('INSERT', array(
|
$args = DB()->build_array('INSERT', [
|
||||||
'group_id' => (int)$group_id,
|
'group_id' => (int)$group_id,
|
||||||
'user_id' => (int)$user_id,
|
'user_id' => (int)$user_id,
|
||||||
'user_pending' => (int)$user_pending,
|
'user_pending' => (int)$user_pending,
|
||||||
'user_time' => (int)$user_time,
|
'user_time' => (int)$user_time,
|
||||||
));
|
]);
|
||||||
DB()->query("REPLACE INTO " . BB_USER_GROUP . $args);
|
DB()->query("REPLACE INTO " . BB_USER_GROUP . $args);
|
||||||
|
|
||||||
if (!$user_pending) {
|
if (!$user_pending) {
|
||||||
|
@ -223,14 +223,14 @@ class Group
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values = array();
|
$values = [];
|
||||||
|
|
||||||
foreach ($auth_ary as $forum_id => $permission) {
|
foreach ($auth_ary as $forum_id => $permission) {
|
||||||
$values[] = array(
|
$values[] = [
|
||||||
'group_id' => (int)$group_id,
|
'group_id' => (int)$group_id,
|
||||||
'forum_id' => (int)$forum_id,
|
'forum_id' => (int)$forum_id,
|
||||||
'forum_perm' => (int)$permission,
|
'forum_perm' => (int)$permission,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
$values = DB()->build_array('MULTI_INSERT', $values);
|
$values = DB()->build_array('MULTI_INSERT', $values);
|
||||||
|
|
||||||
|
|
|
@ -194,10 +194,7 @@ class Post
|
||||||
add_search_words($post_id, stripslashes($s_post_message), stripslashes($s_post_subject));
|
add_search_words($post_id, stripslashes($s_post_message), stripslashes($s_post_subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
update_post_html(array(
|
update_post_html(['post_id' => $post_id, 'post_text' => $post_message]);
|
||||||
'post_id' => $post_id,
|
|
||||||
'post_text' => $post_message,
|
|
||||||
));
|
|
||||||
|
|
||||||
//Обновление кеша новостей на главной
|
//Обновление кеша новостей на главной
|
||||||
if ($bb_cfg['show_latest_news']) {
|
if ($bb_cfg['show_latest_news']) {
|
||||||
|
@ -345,7 +342,7 @@ class Post
|
||||||
|
|
||||||
if ($mode != 'delete') {
|
if ($mode != 'delete') {
|
||||||
if ($mode == 'reply') {
|
if ($mode == 'reply') {
|
||||||
$update_watched_sql = $user_id_sql = array();
|
$update_watched_sql = $user_id_sql = [];
|
||||||
|
|
||||||
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
|
$sql = DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
|
||||||
|
|
||||||
|
@ -365,7 +362,7 @@ class Post
|
||||||
");
|
");
|
||||||
|
|
||||||
if ($watch_list) {
|
if ($watch_list) {
|
||||||
$orig_word = $replacement_word = array();
|
$orig_word = $replacement_word = [];
|
||||||
obtain_word_list($orig_word, $replacement_word);
|
obtain_word_list($orig_word, $replacement_word);
|
||||||
|
|
||||||
if (\count($orig_word)) {
|
if (\count($orig_word)) {
|
||||||
|
@ -384,13 +381,13 @@ class Post
|
||||||
$emailer->set_subject(sprintf($lang['EMAILER_SUBJECT']['TOPIC_NOTIFY'], $topic_title));
|
$emailer->set_subject(sprintf($lang['EMAILER_SUBJECT']['TOPIC_NOTIFY'], $topic_title));
|
||||||
|
|
||||||
$emailer->set_template('topic_notify', $row['user_lang']);
|
$emailer->set_template('topic_notify', $row['user_lang']);
|
||||||
$emailer->assign_vars(array(
|
$emailer->assign_vars([
|
||||||
'TOPIC_TITLE' => html_entity_decode($topic_title),
|
'TOPIC_TITLE' => html_entity_decode($topic_title),
|
||||||
'SITENAME' => $bb_cfg['sitename'],
|
'SITENAME' => $bb_cfg['sitename'],
|
||||||
'USERNAME' => $row['username'],
|
'USERNAME' => $row['username'],
|
||||||
'U_TOPIC' => $u_topic,
|
'U_TOPIC' => $u_topic,
|
||||||
'U_STOP_WATCHING_TOPIC' => $unwatch_topic,
|
'U_STOP_WATCHING_TOPIC' => $unwatch_topic,
|
||||||
));
|
]);
|
||||||
|
|
||||||
$emailer->send();
|
$emailer->send();
|
||||||
|
|
||||||
|
@ -455,7 +452,7 @@ class Post
|
||||||
FROM " . BB_FORUMS . "
|
FROM " . BB_FORUMS . "
|
||||||
WHERE forum_id IN($forum_id, $old_forum_id)";
|
WHERE forum_id IN($forum_id, $old_forum_id)";
|
||||||
|
|
||||||
$forum_names = array();
|
$forum_names = [];
|
||||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||||
$forum_names[$row['forum_id']] = htmlCHR($row['forum_name']);
|
$forum_names[$row['forum_id']] = htmlCHR($row['forum_name']);
|
||||||
}
|
}
|
||||||
|
@ -531,17 +528,17 @@ class Post
|
||||||
|
|
||||||
// Topic posts block
|
// Topic posts block
|
||||||
foreach ($review_posts as $i => $post) {
|
foreach ($review_posts as $i => $post) {
|
||||||
$template->assign_block_vars('review', array(
|
$template->assign_block_vars('review', [
|
||||||
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
|
'ROW_CLASS' => !($i % 2) ? 'row1' : 'row2',
|
||||||
'POSTER' => profile_url($post),
|
'POSTER' => profile_url($post),
|
||||||
'POSTER_NAME_JS' => addslashes($post['username']),
|
'POSTER_NAME_JS' => addslashes($post['username']),
|
||||||
'POST_DATE' => bb_date($post['post_time'], $bb_cfg['post_date_format']),
|
'POST_DATE' => bb_date($post['post_time'], $bb_cfg['post_date_format']),
|
||||||
'MESSAGE' => get_parsed_post($post),
|
'MESSAGE' => get_parsed_post($post),
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars([
|
||||||
'TPL_TOPIC_REVIEW' => (bool)$review_posts,
|
'TPL_TOPIC_REVIEW' => (bool)$review_posts,
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ class Sessions
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$user->session_start(array('req_login' => $req_login));
|
$user->session_start(['req_login' => $req_login]);
|
||||||
|
|
||||||
return $user->data;
|
return $user->data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,7 @@ class SqlDb
|
||||||
*/
|
*/
|
||||||
public function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
public function sql_fetchfield($field, $rownum = -1, $query_id = 0)
|
||||||
{
|
{
|
||||||
|
$result = null;
|
||||||
if (!$query_id) {
|
if (!$query_id) {
|
||||||
$query_id = $this->query_result;
|
$query_id = $this->query_result;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +735,7 @@ class SqlDb
|
||||||
|
|
||||||
if ($this->link and $ext = mysqli_info($this->link)) {
|
if ($this->link and $ext = mysqli_info($this->link)) {
|
||||||
$info[] = (string)$ext;
|
$info[] = (string)$ext;
|
||||||
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
|
} elseif (!$num && ($aff = $this->affected_rows() and $aff != -1)) {
|
||||||
$info[] = "$aff rows";
|
$info[] = "$aff rows";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ class Template
|
||||||
$str = &$this->_tpldata;
|
$str = &$this->_tpldata;
|
||||||
for ($i = 0; $i < $blockcount; $i++) {
|
for ($i = 0; $i < $blockcount; $i++) {
|
||||||
$str = &$str[$blocks[$i] . '.'];
|
$str = &$str[$blocks[$i] . '.'];
|
||||||
$str = &$str[\count($str) - 1];
|
$str = &$str[(is_array($str) || $str instanceof \Countable ? \count($str) : 0) - 1];
|
||||||
}
|
}
|
||||||
// Now we add the block that we're actually assigning to.
|
// Now we add the block that we're actually assigning to.
|
||||||
// We're adding a new iteration to this block with the given
|
// We're adding a new iteration to this block with the given
|
||||||
|
@ -446,6 +446,7 @@ class Template
|
||||||
|
|
||||||
public function compile_code($filename, $code)
|
public function compile_code($filename, $code)
|
||||||
{
|
{
|
||||||
|
$pos3 = null;
|
||||||
// $filename - file to load code from. used if $code is empty
|
// $filename - file to load code from. used if $code is empty
|
||||||
// $code - tpl code
|
// $code - tpl code
|
||||||
|
|
||||||
|
@ -455,8 +456,8 @@ class Template
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace <!-- (END)PHP --> tags
|
// Replace <!-- (END)PHP --> tags
|
||||||
$search = array('<!-- PHP -->', '<!-- ENDPHP -->');
|
$search = ['<!-- PHP -->', '<!-- ENDPHP -->'];
|
||||||
$replace = array('<' . '?php ', ' ?' . '>');
|
$replace = ['<' . '?php ', ' ?' . '>'];
|
||||||
$code = str_replace($search, $replace, $code);
|
$code = str_replace($search, $replace, $code);
|
||||||
|
|
||||||
// Break it up into lines and put " -->" back.
|
// Break it up into lines and put " -->" back.
|
||||||
|
@ -467,19 +468,19 @@ class Template
|
||||||
}
|
}
|
||||||
|
|
||||||
$block_nesting_level = 0;
|
$block_nesting_level = 0;
|
||||||
$block_names = array();
|
$block_names = [];
|
||||||
$block_names[0] = '.';
|
$block_names[0] = '.';
|
||||||
$block_items = array();
|
$block_items = [];
|
||||||
$count_if = 0;
|
$count_if = 0;
|
||||||
|
|
||||||
// prepare array for compiled code
|
// prepare array for compiled code
|
||||||
$compiled = array();
|
$compiled = [];
|
||||||
|
|
||||||
// array of switches
|
// array of switches
|
||||||
$sw = array();
|
$sw = [];
|
||||||
|
|
||||||
// replace all short php tags
|
// replace all short php tags
|
||||||
$new_code = array();
|
$new_code = [];
|
||||||
$line_count = \count($code_lines);
|
$line_count = \count($code_lines);
|
||||||
for ($i = 0; $i < $line_count; $i++) {
|
for ($i = 0; $i < $line_count; $i++) {
|
||||||
$line = $code_lines[$i];
|
$line = $code_lines[$i];
|
||||||
|
@ -742,11 +743,11 @@ class Template
|
||||||
}
|
}
|
||||||
// change template varrefs into PHP varrefs
|
// change template varrefs into PHP varrefs
|
||||||
// This one will handle varrefs WITH namespaces
|
// This one will handle varrefs WITH namespaces
|
||||||
$varrefs = array();
|
$varrefs = [];
|
||||||
preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
|
preg_match_all('#\{(([a-z0-9\-_]+?\.)+)([a-z0-9\-_]+?)\}#is', $code, $varrefs);
|
||||||
$varcount = \count($varrefs[1]);
|
$varcount = is_array($varrefs[1]) || $varrefs[1] instanceof \Countable ? \count($varrefs[1]) : 0;
|
||||||
$search = array();
|
$search = [];
|
||||||
$replace = array();
|
$replace = [];
|
||||||
for ($i = 0; $i < $varcount; $i++) {
|
for ($i = 0; $i < $varcount; $i++) {
|
||||||
$namespace = $varrefs[1][$i];
|
$namespace = $varrefs[1][$i];
|
||||||
$varname = $varrefs[3][$i];
|
$varname = $varrefs[3][$i];
|
||||||
|
@ -782,8 +783,8 @@ class Template
|
||||||
[^\s(),]+)/x', $tag_args, $match);
|
[^\s(),]+)/x', $tag_args, $match);
|
||||||
|
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
$tokens_cnt = \count($tokens);
|
$tokens_cnt = is_array($tokens) || $tokens instanceof \Countable ? \count($tokens) : 0;
|
||||||
$is_arg_stack = array();
|
$is_arg_stack = [];
|
||||||
|
|
||||||
for ($i = 0; $i < $tokens_cnt; $i++) {
|
for ($i = 0; $i < $tokens_cnt; $i++) {
|
||||||
$token = &$tokens[$i];
|
$token = &$tokens[$i];
|
||||||
|
@ -842,7 +843,7 @@ class Template
|
||||||
|
|
||||||
$new_tokens = $this->_parse_is_expr($is_arg, \array_slice($tokens, $i + 1));
|
$new_tokens = $this->_parse_is_expr($is_arg, \array_slice($tokens, $i + 1));
|
||||||
|
|
||||||
array_splice($tokens, $is_arg_start, \count($tokens), $new_tokens);
|
array_splice($tokens, $is_arg_start, is_array($tokens) || $tokens instanceof \Countable ? \count($tokens) : 0, $new_tokens);
|
||||||
|
|
||||||
$i = $is_arg_start;
|
$i = $is_arg_start;
|
||||||
break;
|
break;
|
||||||
|
@ -892,6 +893,7 @@ class Template
|
||||||
*/
|
*/
|
||||||
public function _parse_is_expr($is_arg, $tokens)
|
public function _parse_is_expr($is_arg, $tokens)
|
||||||
{
|
{
|
||||||
|
$expr = null;
|
||||||
$expr_end = 0;
|
$expr_end = 0;
|
||||||
$negate_expr = false;
|
$negate_expr = false;
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Torrent
|
||||||
if ($row = DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id LIMIT 1")) {
|
if ($row = DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id LIMIT 1")) {
|
||||||
$info_hash = $row['info_hash'];
|
$info_hash = $row['info_hash'];
|
||||||
}
|
}
|
||||||
self::ocelot_update_tracker('delete_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id));
|
self::ocelot_update_tracker('delete_torrent', ['info_hash' => rawurlencode($info_hash), 'id' => $topic_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete torrent
|
// Delete torrent
|
||||||
|
@ -257,7 +257,7 @@ class Torrent
|
||||||
if ($row = DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
if ($row = DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||||
$info_hash = $row['info_hash'];
|
$info_hash = $row['info_hash'];
|
||||||
}
|
}
|
||||||
self::ocelot_update_tracker('update_torrent', array('info_hash' => rawurlencode($info_hash), 'freetorrent' => $tor_status_gold));
|
self::ocelot_update_tracker('update_torrent', ['info_hash' => rawurlencode($info_hash), 'freetorrent' => $tor_status_gold]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +275,7 @@ class Torrent
|
||||||
{
|
{
|
||||||
global $bb_cfg, $lang, $reg_mode;
|
global $bb_cfg, $lang, $reg_mode;
|
||||||
|
|
||||||
|
$announce_urls = [];
|
||||||
$attach_id = (int)$attach_id;
|
$attach_id = (int)$attach_id;
|
||||||
$reg_mode = $mode;
|
$reg_mode = $mode;
|
||||||
|
|
||||||
|
@ -338,7 +339,7 @@ class Torrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$info = (@$tor['info']) ? $tor['info'] : array();
|
$info = (@$tor['info']) ? $tor['info'] : [];
|
||||||
|
|
||||||
if (!isset($info['name'], $info['piece length'], $info['pieces']) || \strlen($info['pieces']) % 20 != 0) {
|
if (!isset($info['name'], $info['piece length'], $info['pieces']) || \strlen($info['pieces']) % 20 != 0) {
|
||||||
return self::torrent_error_exit($lang['TORFILE_INVALID']);
|
return self::torrent_error_exit($lang['TORFILE_INVALID']);
|
||||||
|
@ -350,7 +351,7 @@ class Torrent
|
||||||
|
|
||||||
// Ocelot
|
// Ocelot
|
||||||
if ($bb_cfg['ocelot']['enabled']) {
|
if ($bb_cfg['ocelot']['enabled']) {
|
||||||
self::ocelot_update_tracker('add_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id, 'freetorrent' => 0));
|
self::ocelot_update_tracker('add_torrent', ['info_hash' => rawurlencode($info_hash), 'id' => $topic_id, 'freetorrent' => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash_sql' LIMIT 1")) {
|
if ($row = DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash_sql' LIMIT 1")) {
|
||||||
|
@ -468,7 +469,7 @@ class Torrent
|
||||||
$passkey_val = $bt_userdata['auth_key'];
|
$passkey_val = $bt_userdata['auth_key'];
|
||||||
|
|
||||||
if ($bb_cfg['ocelot']['enabled']) {
|
if ($bb_cfg['ocelot']['enabled']) {
|
||||||
self::ocelot_update_tracker('add_user', array('id' => $user_id, 'passkey' => $passkey_val));
|
self::ocelot_update_tracker('add_user', ['id' => $user_id, 'passkey' => $passkey_val]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,19 +511,16 @@ class Torrent
|
||||||
if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) {
|
if ($bb_cfg['bt_del_addit_ann_urls'] || $bb_cfg['bt_disable_dht']) {
|
||||||
unset($tor['announce-list']);
|
unset($tor['announce-list']);
|
||||||
} elseif (isset($tor['announce-list'])) {
|
} elseif (isset($tor['announce-list'])) {
|
||||||
$tor['announce-list'] = array_merge($tor['announce-list'], array(array($announce)));
|
$tor['announce-list'] = array_merge($tor['announce-list'], [[$announce]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add retracker
|
// Add retracker
|
||||||
if (isset($bb_cfg['tracker']['retracker']) && $bb_cfg['tracker']['retracker']) {
|
if (isset($bb_cfg['tracker']['retracker']) && $bb_cfg['tracker']['retracker']) {
|
||||||
if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) {
|
if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) {
|
||||||
if (!isset($tor['announce-list'])) {
|
if (!isset($tor['announce-list'])) {
|
||||||
$tor['announce-list'] = array(
|
$tor['announce-list'] = [[$announce], [$bb_cfg['tracker']['retracker_host']]];
|
||||||
array($announce),
|
|
||||||
array($bb_cfg['tracker']['retracker_host'])
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$tor['announce-list'] = array_merge($tor['announce-list'], array(array($bb_cfg['tracker']['retracker_host'])));
|
$tor['announce-list'] = array_merge($tor['announce-list'], [[$bb_cfg['tracker']['retracker_host']]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -604,7 +602,7 @@ class Torrent
|
||||||
if (DB()->affected_rows() == 1) {
|
if (DB()->affected_rows() == 1) {
|
||||||
// Ocelot
|
// Ocelot
|
||||||
if ($bb_cfg['ocelot']['enabled']) {
|
if ($bb_cfg['ocelot']['enabled']) {
|
||||||
self::ocelot_update_tracker('change_passkey', array('oldpasskey' => $old_passkey, 'newpasskey' => $passkey_val));
|
self::ocelot_update_tracker('change_passkey', ['oldpasskey' => $old_passkey, 'newpasskey' => $passkey_val]);
|
||||||
}
|
}
|
||||||
return $passkey_val;
|
return $passkey_val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TorrentFileList
|
||||||
$subdir = $f['path'][$i];
|
$subdir = $f['path'][$i];
|
||||||
|
|
||||||
if (!isset($cur_files_ary[$subdir])) {
|
if (!isset($cur_files_ary[$subdir])) {
|
||||||
$cur_files_ary[$subdir] = array();
|
$cur_files_ary[$subdir] = [];
|
||||||
}
|
}
|
||||||
$cur_files_ary =& $cur_files_ary[$subdir];
|
$cur_files_ary =& $cur_files_ary[$subdir];
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Validate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Запрещено
|
// Запрещено
|
||||||
$banned_names = array();
|
$banned_names = [];
|
||||||
|
|
||||||
foreach (DB()->fetch_rowset("SELECT disallow_username FROM " . BB_DISALLOW . " ORDER BY NULL") as $row) {
|
foreach (DB()->fetch_rowset("SELECT disallow_username FROM " . BB_DISALLOW . " ORDER BY NULL") as $row) {
|
||||||
$banned_names[] = str_replace('\*', '.*?', preg_quote($row['disallow_username'], '#u'));
|
$banned_names[] = str_replace('\*', '.*?', preg_quote($row['disallow_username'], '#u'));
|
||||||
|
@ -119,7 +119,7 @@ class Validate
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($check_ban_and_taken) {
|
if ($check_ban_and_taken) {
|
||||||
$banned_emails = array();
|
$banned_emails = [];
|
||||||
|
|
||||||
foreach (DB()->fetch_rowset("SELECT ban_email FROM " . BB_BANLIST . " ORDER BY NULL") as $row) {
|
foreach (DB()->fetch_rowset("SELECT ban_email FROM " . BB_BANLIST . " ORDER BY NULL") as $row) {
|
||||||
$banned_emails[] = str_replace('\*', '.*?', preg_quote($row['ban_email'], '#'));
|
$banned_emails[] = str_replace('\*', '.*?', preg_quote($row['ban_email'], '#'));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue