Merge pull request #460 from Exileum/feature/php_713

Update required PHP version to 7.1.3
This commit is contained in:
Yuriy Pikhtarev 2018-06-24 16:51:52 +03:00 committed by GitHub
commit c1fb1479ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 1678 additions and 378 deletions

1
.gitignore vendored
View file

@ -2,7 +2,6 @@
.idea .idea
.php_cs.cache .php_cs.cache
composer.phar composer.phar
composer.lock
configs/local.php configs/local.php
data/avatars data/avatars
data/torrent_files data/torrent_files

View file

@ -28,8 +28,8 @@ and go from there. The documentation will be translated into english in the near
* Apache / nginx * Apache / nginx
* MySQL / MariaDB / Percona * MySQL / MariaDB / Percona
* PHP: 5.6 / 7.0 / 7.1 * PHP: 7.1 / 7.2 / 7.3
* PHP Extensions: bcmath, intl, tidy (optional), xml * PHP Extensions: bcmath, intl, tidy (optional), xml, xmlwriter
## Installation ## Installation

View file

@ -158,8 +158,8 @@ if ($confirm && count($delete_id_list) > 0) {
$hidden_fields .= '<input type="hidden" name="u_id" value="' . $uid . '" />'; $hidden_fields .= '<input type="hidden" name="u_id" value="' . $uid . '" />';
$hidden_fields .= '<input type="hidden" name="start" value="' . $start . '" />'; $hidden_fields .= '<input type="hidden" name="start" value="' . $start . '" />';
for ($i = 0, $iMax = count($delete_id_list); $i < $iMax; $i++) { foreach ($delete_id_list as $iValue) {
$hidden_fields .= '<input type="hidden" name="delete_id_list[]" value="' . $delete_id_list[$i] . '" />'; $hidden_fields .= '<input type="hidden" name="delete_id_list[]" value="' . $iValue . '" />';
} }
print_confirmation(array( print_confirmation(array(
@ -382,8 +382,8 @@ if ($view === 'attachments') {
for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) { for ($i = 0, $iMax = count($attachments); $i < $iMax; $i++) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" />'; $delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" />';
for ($j = 0, $jMax = count($delete_id_list); $j < $jMax; $j++) { foreach ($delete_id_list as $jValue) {
if ($delete_id_list[$j] == $attachments[$i]['attach_id']) { if ($jValue == $attachments[$i]['attach_id']) {
$delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" checked="checked" />'; $delete_box = '<input type="checkbox" name="delete_id_list[]" value="' . (int)$attachments[$i]['attach_id'] . '" checked="checked" />';
break; break;
} }

View file

@ -133,23 +133,25 @@ $select_pm_size_mode = size_select('pm_size', $pm_size);
if ($search_imagick) { if ($search_imagick) {
$imagick = ''; $imagick = '';
if (preg_match('/convert/i', $imagick)) { if (false !== stripos($imagick, "convert")) {
return true; return true;
} elseif ($imagick != 'none') { }
if (!preg_match('/WIN/i', PHP_OS)) {
if ($imagick != 'none') {
if (!false !== stripos(PHP_OS, "WIN")) {
$retval = @exec('whereis convert'); $retval = @exec('whereis convert');
$paths = explode(' ', $retval); $paths = explode(' ', $retval);
if (is_array($paths)) { if (is_array($paths)) {
for ($i = 0, $iMax = count($paths); $i < $iMax; $i++) { foreach ($paths as $i => $iValue) {
$path = basename($paths[$i]); $path = basename($paths[$i]);
if ($path == 'convert') { if ($path == 'convert') {
$imagick = $paths[$i]; $imagick = $iValue;
} }
} }
} }
} elseif (preg_match('/WIN/i', PHP_OS)) { } elseif (false !== stripos(PHP_OS, "WIN")) {
$path = 'c:/imagemagick/convert.exe'; $path = 'c:/imagemagick/convert.exe';
if (!@file_exists(amod_realpath($path))) { if (!@file_exists(amod_realpath($path))) {
@ -344,7 +346,9 @@ if ($check_image_cat) {
// Does the target directory exist, is it a directory and writeable // Does the target directory exist, is it a directory and writeable
if (!@file_exists(amod_realpath($upload_dir))) { if (!@file_exists(amod_realpath($upload_dir))) {
mkdir($upload_dir, 0755); if (!mkdir($upload_dir, 0755) && !is_dir($upload_dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $upload_dir));
}
@chmod($upload_dir, 0777); @chmod($upload_dir, 0777);
if (!@file_exists(amod_realpath($upload_dir))) { if (!@file_exists(amod_realpath($upload_dir))) {

View file

@ -14,7 +14,7 @@ if (!empty($setmodules)) {
} }
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
$mode = isset($_GET['mode']) ? $_GET['mode'] : ''; $mode = $_GET['mode'] ?? '';
$return_links = array( $return_links = array(
'index' => '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'), 'index' => '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'),
@ -34,7 +34,7 @@ if (!$result = DB()->sql_query($sql)) {
$config_value = $row['config_value']; $config_value = $row['config_value'];
$default_config[$config_name] = $config_value; $default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
if ($config_name == 'seed_bonus_points' || if ($config_name == 'seed_bonus_points' ||

View file

@ -14,11 +14,11 @@ if (!empty($setmodules)) {
return; return;
} }
$mode = isset($_GET['mode']) ? $_GET['mode'] : ''; $mode = $_GET['mode'] ?? '';
$job_id = isset($_GET['id']) ? (int)$_GET['id'] : ''; $job_id = isset($_GET['id']) ? (int)$_GET['id'] : '';
$submit = isset($_POST['submit']); $submit = isset($_POST['submit']);
$jobs = isset($_POST['select']) ? implode(',', $_POST['select']) : ''; $jobs = isset($_POST['select']) ? implode(',', $_POST['select']) : '';
$cron_action = isset($_POST['cron_action']) ? $_POST['cron_action'] : ''; $cron_action = $_POST['cron_action'] ?? '';
if ($mode == 'run' && !$job_id) { if ($mode == 'run' && !$job_id) {
define('BB_ROOT', './../'); define('BB_ROOT', './../');
@ -40,7 +40,7 @@ foreach ($sql as $row) {
$config_value = $row['config_value']; $config_value = $row['config_value'];
$default_config[$config_name] = $config_value; $default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
bb_update_config(array($config_name => $new[$config_name])); bb_update_config(array($config_name => $new[$config_name]));

View file

@ -238,9 +238,9 @@ if ($submit && $mode == 'groups') {
$allowed_list = array(); $allowed_list = array();
for ($i = 0, $iMax = count($group_allowed_list); $i < $iMax; $i++) { foreach ($group_allowed_list as $iValue) {
for ($j = 0, $jMax = count($group_change_list); $j < $jMax; $j++) { for ($j = 0, $jMax = count($group_change_list); $j < $jMax; $j++) {
if ($group_allowed_list[$i] == $group_change_list[$j]) { if ($iValue == $group_change_list[$j]) {
$allowed_list[$j] = 1; $allowed_list[$j] = 1;
} }
} }
@ -371,7 +371,7 @@ if ($mode == 'groups') {
$template->assign_vars(array( $template->assign_vars(array(
'TPL_ATTACH_EXTENSION_GROUPS' => true, 'TPL_ATTACH_EXTENSION_GROUPS' => true,
'ADD_GROUP_NAME' => isset($extension_group) ? $extension_group : '', 'ADD_GROUP_NAME' => $extension_group ?? '',
'MAX_FILESIZE' => $max_add_filesize, 'MAX_FILESIZE' => $max_add_filesize,
'S_FILESIZE' => size_select('add_size_select', $size), 'S_FILESIZE' => size_select('add_size_select', $size),
'S_ADD_DOWNLOAD_MODE' => download_select('add_download_mode'), 'S_ADD_DOWNLOAD_MODE' => download_select('add_download_mode'),
@ -456,8 +456,8 @@ if ($add_forum && $e_mode == 'perm' && $group) {
$add_forums_list = get_var('entries', array(0)); $add_forums_list = get_var('entries', array(0));
$add_all_forums = false; $add_all_forums = false;
for ($i = 0, $iMax = count($add_forums_list); $i < $iMax; $i++) { foreach ($add_forums_list as $iValue) {
if ($add_forums_list[$i] == 0) { if ($iValue == 0) {
$add_all_forums = true; $add_all_forums = true;
} }
} }
@ -491,9 +491,9 @@ if ($add_forum && $e_mode == 'perm' && $group) {
} }
// Generate array for Auth_Pack, do not add doubled forums // Generate array for Auth_Pack, do not add doubled forums
for ($i = 0, $iMax = count($add_forums_list); $i < $iMax; $i++) { foreach ($add_forums_list as $i => $iValue) {
if (!in_array($add_forums_list[$i], $auth_p)) { if (!in_array($add_forums_list[$i], $auth_p)) {
$auth_p[] = $add_forums_list[$i]; $auth_p[] = $iValue;
} }
} }
@ -528,9 +528,9 @@ if ($delete_forum && $e_mode == 'perm' && $group) {
$auth_p = array(); $auth_p = array();
// Generate array for Auth_Pack, delete the chosen ones // Generate array for Auth_Pack, delete the chosen ones
for ($i = 0, $iMax = count($auth_p2); $i < $iMax; $i++) { foreach ($auth_p2 as $i => $iValue) {
if (!in_array($auth_p2[$i], $delete_forums_list)) { if (!in_array($auth_p2[$i], $delete_forums_list)) {
$auth_p[] = $auth_p2[$i]; $auth_p[] = $iValue;
} }
} }

View file

@ -45,7 +45,7 @@ $forumname = '';
if (isset($_REQUEST['addforum']) || isset($_REQUEST['addcategory'])) { if (isset($_REQUEST['addforum']) || isset($_REQUEST['addcategory'])) {
$mode = isset($_REQUEST['addforum']) ? 'addforum' : 'addcat'; $mode = isset($_REQUEST['addforum']) ? 'addforum' : 'addcat';
if ($mode == 'addforum' && isset($_POST['addforum']) && isset($_POST['forumname']) && is_array($_POST['addforum'])) { if (isset($_POST['addforum'], $_POST['forumname']) && $mode == 'addforum' && is_array($_POST['addforum'])) {
$req_cat_id = array_keys($_POST['addforum']); $req_cat_id = array_keys($_POST['addforum']);
$cat_id = reset($req_cat_id); $cat_id = reset($req_cat_id);
$forumname = stripslashes($_POST['forumname'][$cat_id]); $forumname = stripslashes($_POST['forumname'][$cat_id]);
@ -559,15 +559,17 @@ if ($mode) {
$move_down_forum_id = false; $move_down_forum_id = false;
$forums = $cat_forums[$cat_id]['f_ord']; $forums = $cat_forums[$cat_id]['f_ord'];
$forum_order = $forum_info['forum_order']; $forum_order = $forum_info['forum_order'];
$prev_forum = isset($forums[$forum_order - 10]) ? $forums[$forum_order - 10] : false; $prev_forum = $forums[$forum_order - 10] ?? false;
$next_forum = isset($forums[$forum_order + 10]) ? $forums[$forum_order + 10] : false; $next_forum = $forums[$forum_order + 10] ?? false;
// move selected forum ($forum_id) UP // move selected forum ($forum_id) UP
if ($move < 0 && $prev_forum) { if ($move < 0 && $prev_forum) {
if ($forum_info['forum_parent'] && $prev_forum['forum_parent'] != $forum_info['forum_parent']) { if ($forum_info['forum_parent'] && $prev_forum['forum_parent'] != $forum_info['forum_parent']) {
$show_main_page = true; $show_main_page = true;
break; break;
} elseif ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order)) { }
if ($move_down_forum_id = get_prev_root_forum_id($forums, $forum_order)) {
$move_up_forum_id = $forum_id; $move_up_forum_id = $forum_id;
$move_down_ord_val = (get_sf_count($forum_id) + 1) * 10; $move_down_ord_val = (get_sf_count($forum_id) + 1) * 10;
$move_up_ord_val = ((get_sf_count($move_down_forum_id) + 1) * 10) + $move_down_ord_val; $move_up_ord_val = ((get_sf_count($move_down_forum_id) + 1) * 10) + $move_down_ord_val;
@ -578,7 +580,9 @@ if ($mode) {
if ($forum_info['forum_parent'] && $next_forum['forum_parent'] != $forum_info['forum_parent']) { if ($forum_info['forum_parent'] && $next_forum['forum_parent'] != $forum_info['forum_parent']) {
$show_main_page = true; $show_main_page = true;
break; break;
} elseif ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order)) { }
if ($move_up_forum_id = get_next_root_forum_id($forums, $forum_order)) {
$move_down_forum_id = $forum_id; $move_down_forum_id = $forum_id;
$move_down_forum_order = $forum_order; $move_down_forum_order = $forum_order;
$move_down_ord_val = (get_sf_count($move_up_forum_id) + 1) * 10; $move_down_ord_val = (get_sf_count($move_up_forum_id) + 1) * 10;

View file

@ -87,7 +87,7 @@ if (!empty($_POST['edit']) || !empty($_POST['new'])) {
$release_group = isset($_POST['release_group']) ? (int)$_POST['release_group'] : 0; $release_group = isset($_POST['release_group']) ? (int)$_POST['release_group'] : 0;
$group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : ''; $group_name = isset($_POST['group_name']) ? trim($_POST['group_name']) : '';
$group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : ''; $group_desc = isset($_POST['group_description']) ? trim($_POST['group_description']) : '';
$group_moderator = isset($_POST['username']) ? $_POST['username'] : ''; $group_moderator = $_POST['username'] ?? '';
if ($group_name === '') { if ($group_name === '') {
bb_die($lang['NO_GROUP_NAME']); bb_die($lang['NO_GROUP_NAME']);

View file

@ -14,4 +14,5 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
/** @noinspection ForgottenDebugOutputInspection */
phpinfo(); phpinfo();

View file

@ -15,7 +15,7 @@ if (!empty($setmodules)) {
require __DIR__ . '/pagestart.php'; require __DIR__ . '/pagestart.php';
if (isset($_GET['mode']) || isset($_POST['mode'])) { if (isset($_GET['mode']) || isset($_POST['mode'])) {
$mode = isset($_GET['mode']) ? $_GET['mode'] : $_POST['mode']; $mode = $_GET['mode'] ?? $_POST['mode'];
} else { } else {
// //
// These could be entered via a form button // These could be entered via a form button

View file

@ -134,7 +134,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
} }
// get the db sizes // get the db sizes
list($search_data_size, $search_index_size, $search_tables_size) = get_db_sizes(); [$search_data_size, $search_index_size, $search_tables_size] = get_db_sizes();
// get the post subject/text of each post // get the post subject/text of each post
$result = DB()->query(" $result = DB()->query("
@ -290,7 +290,7 @@ if ($mode == 'submit' || $mode == 'refresh') {
} }
// get the db sizes // get the db sizes
list($search_data_size, $search_index_size, $search_tables_size) = get_db_sizes(); [$search_data_size, $search_index_size, $search_tables_size] = get_db_sizes();
// calculate the final (estimated) values // calculate the final (estimated) values
$final_search_tables_size = ''; $final_search_tables_size = '';

View file

@ -24,7 +24,7 @@ if (!$result = DB()->sql_query($sql)) {
$config_name = $row['config_name']; $config_name = $row['config_name'];
$config_value = $row['config_value']; $config_value = $row['config_value'];
$default_config[$config_name] = $config_value; $default_config[$config_name] = $config_value;
$new[$config_name] = isset($_POST[$config_name]) ? $_POST[$config_name] : $default_config[$config_name]; $new[$config_name] = $_POST[$config_name] ?? $default_config[$config_name];
if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) { if (isset($_POST['submit']) && $row['config_value'] != $new[$config_name]) {
$new_params[$config_name] = $new[$config_name]; $new_params[$config_name] = $new[$config_name];

View file

@ -16,7 +16,7 @@ require __DIR__ . '/pagestart.php';
// Check to see what mode we should operate in // Check to see what mode we should operate in
if (isset($_POST['mode']) || isset($_GET['mode'])) { if (isset($_POST['mode']) || isset($_GET['mode'])) {
$mode = isset($_POST['mode']) ? $_POST['mode'] : $_GET['mode']; $mode = $_POST['mode'] ?? $_GET['mode'];
$mode = htmlspecialchars($mode); $mode = htmlspecialchars($mode);
} else { } else {
$mode = ''; $mode = '';
@ -77,7 +77,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
bb_die('Could not read smiley pak file'); bb_die('Could not read smiley pak file');
} }
for ($i = 0, $iMax = count($fcontents); $i < $iMax; $i++) { foreach ($fcontents as $i => $iValue) {
$smile_data = explode($delimeter, trim(addslashes($fcontents[$i]))); $smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
for ($j = 2, $jMax = count($smile_data); $j < $jMax; $j++) { for ($j = 2, $jMax = count($smile_data); $j < $jMax; $j++) {
@ -239,8 +239,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
} }
// Convert < and > to proper htmlentities for parsing // Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code); $smile_code = str_replace(['<', '>'], ['&lt;', '&gt;'], $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Proceed with updating the smiley table // Proceed with updating the smiley table
$sql = 'UPDATE ' . BB_SMILIES . " $sql = 'UPDATE ' . BB_SMILIES . "
@ -255,10 +254,10 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
break; break;
case 'savenew': case 'savenew':
$smile_code = isset($_POST['smile_code']) ? $_POST['smile_code'] : $_GET['smile_code']; $smile_code = $_POST['smile_code'] ?? $_GET['smile_code'];
$smile_url = isset($_POST['smile_url']) ? $_POST['smile_url'] : $_GET['smile_url']; $smile_url = $_POST['smile_url'] ?? $_GET['smile_url'];
$smile_url = bb_ltrim(basename($smile_url), "'"); $smile_url = bb_ltrim(basename($smile_url), "'");
$smile_emotion = isset($_POST['smile_emotion']) ? $_POST['smile_emotion'] : $_GET['smile_emotion']; $smile_emotion = $_POST['smile_emotion'] ?? $_GET['smile_emotion'];
$smile_code = trim($smile_code); $smile_code = trim($smile_code);
$smile_url = trim($smile_url); $smile_url = trim($smile_url);
$smile_emotion = trim($smile_emotion); $smile_emotion = trim($smile_emotion);
@ -269,8 +268,7 @@ if (isset($_GET['import_pack']) || isset($_POST['import_pack'])) {
} }
// Convert < and > to proper htmlentities for parsing // Convert < and > to proper htmlentities for parsing
$smile_code = str_replace('<', '&lt;', $smile_code); $smile_code = str_replace(['<', '>'], ['&lt;', '&gt;'], $smile_code);
$smile_code = str_replace('>', '&gt;', $smile_code);
// Save the data to the smiley table // Save the data to the smiley table
$sql = 'INSERT INTO ' . BB_SMILIES . " (code, smile_url, emoticon) $sql = 'INSERT INTO ' . BB_SMILIES . " (code, smile_url, emoticon)

View file

@ -44,7 +44,7 @@ if (isset($_POST['submit'])) {
if (isset($_POST['ban_email'])) { if (isset($_POST['ban_email'])) {
$email_list_temp = explode(',', $_POST['ban_email']); $email_list_temp = explode(',', $_POST['ban_email']);
for ($i = 0, $iMax = count($email_list_temp); $i < $iMax; $i++) { foreach ($email_list_temp as $i => $iValue) {
if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i]))) { if (preg_match('/^(([a-z0-9&\'\.\-_\+])|(\*))+@(([a-z0-9\-])|(\*))+\.([a-z0-9\-]+\.)*?[a-z]+$/is', trim($email_list_temp[$i]))) {
$email_list[] = trim($email_list_temp[$i]); $email_list[] = trim($email_list_temp[$i]);
} }

View file

@ -251,7 +251,7 @@ if (!isset($_REQUEST['dosearch'])) {
$text = sprintf($lang['SEARCH_FOR_USERNAME'], strip_tags(htmlspecialchars(stripslashes($username)))); $text = sprintf($lang['SEARCH_FOR_USERNAME'], strip_tags(htmlspecialchars(stripslashes($username))));
$username = preg_replace('/\*/', '%', trim(strip_tags(strtolower($username)))); $username = str_replace("\*", '%', trim(strip_tags(strtolower($username))));
if (false !== strpos($username, '%')) { if (false !== strpos($username, '%')) {
$op = 'LIKE'; $op = 'LIKE';
@ -272,7 +272,7 @@ if (!isset($_REQUEST['dosearch'])) {
$text = sprintf($lang['SEARCH_FOR_EMAIL'], strip_tags(htmlspecialchars(stripslashes($email)))); $text = sprintf($lang['SEARCH_FOR_EMAIL'], strip_tags(htmlspecialchars(stripslashes($email))));
$email = preg_replace('/\*/', '%', trim(strip_tags(strtolower($email)))); $email = str_replace("\*", '%', trim(strip_tags(strtolower($email))));
if (false !== strpos($email, '%')) { if (false !== strpos($email, '%')) {
$op = 'LIKE'; $op = 'LIKE';
@ -313,7 +313,7 @@ if (!isset($_REQUEST['dosearch'])) {
$where_sql = ''; $where_sql = '';
$where_sql .= ($ip_in_sql != '') ? "poster_ip IN ($ip_in_sql)" : ''; $where_sql .= ($ip_in_sql != '') ? "poster_ip IN ($ip_in_sql)" : '';
$where_sql .= ($ip_like_sql != '') ? ($where_sql != '') ? " OR $ip_like_sql" : "$ip_like_sql" : ''; $where_sql .= ($ip_like_sql != '') ? ($where_sql != '') ? " OR $ip_like_sql" : (string)$ip_like_sql : '';
if (!$where_sql) { if (!$where_sql) {
bb_die('invalid request'); bb_die('invalid request');
@ -340,7 +340,7 @@ if (!isset($_REQUEST['dosearch'])) {
} }
$where_sql = ''; $where_sql = '';
$where_sql .= ($ip_in_sql != '') ? "user_last_ip IN ($ip_in_sql)" : ''; $where_sql .= ($ip_in_sql != '') ? "user_last_ip IN ($ip_in_sql)" : '';
$where_sql .= ($ip_like_sql_flylast != '') ? ($where_sql != '') ? " OR $ip_like_sql_flylast" : "$ip_like_sql_flylast" : ''; $where_sql .= ($ip_like_sql_flylast != '') ? ($where_sql != '') ? " OR $ip_like_sql_flylast" : (string)$ip_like_sql_flylast : '';
$sql = 'SELECT user_id FROM ' . BB_USERS . ' WHERE user_id <> ' . GUEST_UID . " AND ($where_sql) GROUP BY user_id"; $sql = 'SELECT user_id FROM ' . BB_USERS . ' WHERE user_id <> ' . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
if (!$result = DB()->sql_query($sql)) { if (!$result = DB()->sql_query($sql)) {
bb_die('Could not count users #2'); bb_die('Could not count users #2');
@ -357,7 +357,7 @@ if (!isset($_REQUEST['dosearch'])) {
} }
$where_sql = ''; $where_sql = '';
$where_sql .= ($ip_in_sql != '') ? "user_reg_ip IN ($ip_in_sql)" : ''; $where_sql .= ($ip_in_sql != '') ? "user_reg_ip IN ($ip_in_sql)" : '';
$where_sql .= ($ip_like_sql_flyreg != '') ? ($where_sql != '') ? " OR $ip_like_sql_flyreg" : "$ip_like_sql_flyreg" : ''; $where_sql .= ($ip_like_sql_flyreg != '') ? ($where_sql != '') ? " OR $ip_like_sql_flyreg" : (string)$ip_like_sql_flyreg : '';
$sql = 'SELECT user_id FROM ' . BB_USERS . ' WHERE user_id <> ' . GUEST_UID . " AND ($where_sql) GROUP BY user_id"; $sql = 'SELECT user_id FROM ' . BB_USERS . ' WHERE user_id <> ' . GUEST_UID . " AND ($where_sql) GROUP BY user_id";
if (!$result = DB()->sql_query($sql)) { if (!$result = DB()->sql_query($sql)) {
bb_die('Could not count users #3'); bb_die('Could not count users #3');
@ -567,7 +567,7 @@ if (!isset($_REQUEST['dosearch'])) {
$text = strip_tags(htmlspecialchars(stripslashes($userfield_value))); $text = strip_tags(htmlspecialchars(stripslashes($userfield_value)));
$userfield_value = preg_replace('/\*/', '%', trim(strip_tags(strtolower($userfield_value)))); $userfield_value = str_replace("\*", '%', trim(strip_tags(strtolower($userfield_value))));
if (false !== strpos($userfield_value, '%')) { if (false !== strpos($userfield_value, '%')) {
$op = 'LIKE'; $op = 'LIKE';

View file

@ -34,7 +34,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
ksort($module); ksort($module);
foreach ($module as $cat => $action_array) { foreach ($module as $cat => $action_array) {
$cat = (!empty($lang[$cat])) ? $lang[$cat] : preg_replace('/_/', ' ', $cat); $cat = (!empty($lang[$cat])) ? $lang[$cat] : str_replace("_", ' ', $cat);
$template->assign_block_vars('catrow', array( $template->assign_block_vars('catrow', array(
'ADMIN_CATEGORY' => $cat, 'ADMIN_CATEGORY' => $cat,
@ -46,7 +46,7 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
foreach ($action_array as $action => $file) { foreach ($action_array as $action => $file) {
$row_class = !($row_count % 2) ? 'row1' : 'row2'; $row_class = !($row_count % 2) ? 'row1' : 'row2';
$action = (!empty($lang[$action])) ? $lang[$action] : preg_replace('/_/', ' ', $action); $action = (!empty($lang[$action])) ? $lang[$action] : str_replace("_", ' ', $action);
$template->assign_block_vars('catrow.modulerow', array( $template->assign_block_vars('catrow.modulerow', array(
'ROW_CLASS' => $row_class, 'ROW_CLASS' => $row_class,

View file

@ -20,7 +20,7 @@ if (empty($_SERVER['HTTP_USER_AGENT'])) {
// Ignore 'completed' event // Ignore 'completed' event
if (isset($_GET['event']) && $_GET['event'] === 'completed') { if (isset($_GET['event']) && $_GET['event'] === 'completed') {
dummy_exit(mt_rand(600, 1200)); dummy_exit(random_int(600, 1200));
} }
$announce_interval = $bb_cfg['announce_interval']; $announce_interval = $bb_cfg['announce_interval'];
@ -71,7 +71,7 @@ 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 = isset($$passkey_key) ? $$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)

View file

@ -248,7 +248,7 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
$old_name = $file; $old_name = $file;
$ext = ''; $ext = '';
if (preg_match('#^(.+)(\.[^\\\/]+)$#', $file, $matches)) { if (preg_match('#^(.+)(\.[^\\\/]+)$#', $file, $matches)) {
list($old_name, $ext) = $matches; [$old_name, $ext] = $matches;
} }
$new_name = $old_name . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . $ext; $new_name = $old_name . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . $ext;
clearstatcache(); clearstatcache();
@ -461,7 +461,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
if (!defined('IN_TRACKER')) { if (!defined('IN_TRACKER')) {
require INC_DIR . '/init_bb.php'; require INC_DIR . '/init_bb.php';
} else { } else {
define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : mt_rand(1000, 65000))); define('DUMMY_PEER', pack('Nn', ip2long($_SERVER['REMOTE_ADDR']), !empty($_GET['port']) ? (int)$_GET['port'] : random_int(1000, 65000)));
function dummy_exit($interval = 1800) function dummy_exit($interval = 1800)
{ {
@ -480,7 +480,7 @@ if (!defined('IN_TRACKER')) {
if (!defined('IN_ADMIN')) { if (!defined('IN_ADMIN')) {
// Exit if tracker is disabled via ON/OFF trigger // Exit if tracker is disabled via ON/OFF trigger
if (file_exists(BB_DISABLED)) { if (file_exists(BB_DISABLED)) {
dummy_exit(mt_rand(60, 2400)); dummy_exit(random_int(60, 2400));
} }
} }
} }

View file

@ -35,18 +35,20 @@
"docs": "https://docs.torrentpier.com/" "docs": "https://docs.torrentpier.com/"
}, },
"require": { "require": {
"php": "^5.6 || ^7.0", "php": "^7.1.3",
"bugsnag/bugsnag": "^3.5", "bugsnag/bugsnag": "3.13.0",
"filp/whoops": "^2.1", "filp/whoops": "^2.2.0",
"gigablah/sphinxphp": "^2.0", "gigablah/sphinxphp": "2.0.8",
"google/recaptcha": "^1.1", "google/recaptcha": "1.1.3",
"longman/ip-tools": "^1.2", "longman/ip-tools": "1.2.1",
"roave/security-advisories": "dev-master", "rych/bencode": "1.0.0",
"rych/bencode": "^1.0", "samdark/sitemap": "2.2.0",
"samdark/sitemap": "^2.0", "swiftmailer/swiftmailer": "6.0.2",
"swiftmailer/swiftmailer": "^5.4", "symfony/dotenv": "4.1.0",
"symfony/dotenv": "^3.3", "symfony/var-dumper": "4.1.0"
"symfony/var-dumper": "^3.3" },
"require-dev": {
"roave/security-advisories": "dev-master"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

1304
composer.lock generated Normal file

File diff suppressed because it is too large Load diff

7
dl.php
View file

@ -128,7 +128,6 @@ for ($i = 0; $i < $num_auth_pages && $authorised == false; $i++) {
$topic_id = $row['topic_id']; $topic_id = $row['topic_id'];
$forum_id = $row['forum_id']; $forum_id = $row['forum_id'];
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata); $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
set_die_append_msg($forum_id, $topic_id); set_die_append_msg($forum_id, $topic_id);
@ -181,11 +180,12 @@ if ($download_mode == PHYSICAL_LINK) {
$url = make_url($upload_dir . '/' . $attachment['physical_filename']); $url = make_url($upload_dir . '/' . $attachment['physical_filename']);
header('Location: ' . $url); header('Location: ' . $url);
exit; exit;
} else { }
if (IS_GUEST && !bb_captcha('check')) { if (IS_GUEST && !bb_captcha('check')) {
global $template; global $template;
$redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/'); $redirect_url = $_POST['redirect_url'] ?? $_SERVER['HTTP_REFERER'] ?? '/';
$message = '<form action="' . DOWNLOAD_URL . $attachment['attach_id'] . '" method="post">'; $message = '<form action="' . DOWNLOAD_URL . $attachment['attach_id'] . '" method="post">';
$message .= $lang['CAPTCHA'] . ':'; $message .= $lang['CAPTCHA'] . ':';
$message .= '<div class="mrg_10" align="center">' . bb_captcha('get') . '</div>'; $message .= '<div class="mrg_10" align="center">' . bb_captcha('get') . '</div>';
@ -204,4 +204,3 @@ if ($download_mode == PHYSICAL_LINK) {
send_file_to_browser($attachment, $upload_dir); send_file_to_browser($attachment, $upload_dir);
exit; exit;
}

View file

@ -13,9 +13,9 @@ require __DIR__ . '/common.php';
$user->session_start(array('req_login' => true)); $user->session_start(array('req_login' => true));
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : ''; $mode = $_REQUEST['mode'] ?? '';
$type = isset($_POST['type']) ? $_POST['type'] : ''; $type = $_POST['type'] ?? '';
$id = isset($_POST['id']) ? $_POST['id'] : 0; $id = $_POST['id'] ?? 0;
$timecheck = TIMENOW - 600; $timecheck = TIMENOW - 600;
if (!$mode) { if (!$mode) {

View file

@ -40,8 +40,6 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
} else { } else {
$www = ''; $www = '';
} }
return;
} }
$user->session_start(array('req_login' => true)); $user->session_start(array('req_login' => true));

View file

@ -238,7 +238,7 @@ foreach ($cat_forums as $cid => $c) {
'FORUM_DESC' => $f['forum_desc'], 'FORUM_DESC' => $f['forum_desc'],
'POSTS' => commify($f['forum_posts']), 'POSTS' => commify($f['forum_posts']),
'TOPICS' => commify($f['forum_topics']), 'TOPICS' => commify($f['forum_topics']),
'LAST_SF_ID' => isset($f['last_sf_id']) ? $f['last_sf_id'] : null, 'LAST_SF_ID' => $f['last_sf_id'] ?? null,
'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '', 'MODERATORS' => isset($moderators[$fid]) ? implode(', ', $moderators[$fid]) : '',
'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'], 'FORUM_FOLDER_ALT' => ($new) ? $lang['NEW'] : $lang['OLD'],
)); ));

View file

@ -128,7 +128,7 @@ switch ($field) {
foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4) as $s => $m) { foreach (array('KB' => 1, 'MB' => 2, 'GB' => 3, 'TB' => 4) as $s => $m) {
if (strpos($this->request['value'], $s) !== false) { if (strpos($this->request['value'], $s) !== false) {
$value *= pow(1024, $m); $value *= (1024 ** $m);
break; break;
} }
} }

View file

@ -47,7 +47,7 @@ switch ($mode) {
$dir = $template->cachedir; $dir = $template->cachedir;
$res = @opendir($dir); $res = @opendir($dir);
while (($file = readdir($res)) !== false) { while (($file = readdir($res)) !== false) {
if (substr($file, 0, $match_len) === $match) { if (0 === strpos($file, $match)) {
@unlink($dir . $file); @unlink($dir . $file);
} }
} }

View file

@ -31,12 +31,12 @@ function attach_mod_get_lang($language_file)
$file = LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/' . $language_file . '.php'; $file = LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/' . $language_file . '.php';
if (file_exists($file)) { if (file_exists($file)) {
return $bb_cfg['default_lang']; return $bb_cfg['default_lang'];
} else { }
$file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php'; $file = LANG_ROOT_DIR . '/' . $attach_config['board_lang'] . '/' . $language_file . '.php';
if (file_exists($file)) { if (file_exists($file)) {
return $attach_config['board_lang']; return $attach_config['board_lang'];
} }
}
bb_die('Attachment mod language file does not exist: language/' . $attach_config['board_lang'] . '/' . $language_file . '.php'); bb_die('Attachment mod language file does not exist: language/' . $attach_config['board_lang'] . '/' . $language_file . '.php');
} }

View file

@ -25,7 +25,7 @@ function init_complete_extensions_data()
global $allowed_extensions, $display_categories, $download_modes, $upload_icons; global $allowed_extensions, $display_categories, $download_modes, $upload_icons;
if (!$extension_informations = get_extension_informations()) { if (!$extension_informations = get_extension_informations()) {
$extension_informations = $GLOBALS['datastore']->update('attach_extensions'); //get_extension_informations() $GLOBALS['datastore']->update('attach_extensions');
$extension_informations = get_extension_informations(); $extension_informations = get_extension_informations();
} }
$allowed_extensions = array(); $allowed_extensions = array();
@ -213,7 +213,7 @@ function display_attachments($post_id)
if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && (int)$attach_config['img_display_inlined']) { if (@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT && (int)$attach_config['img_display_inlined']) {
if ((int)$attach_config['img_link_width'] != 0 || (int)$attach_config['img_link_height'] != 0) { if ((int)$attach_config['img_link_width'] != 0 || (int)$attach_config['img_link_height'] != 0) {
list($width, $height) = image_getdimension($filename); [$width, $height] = image_getdimension($filename);
if ($width == 0 && $height == 0) { if ($width == 0 && $height == 0) {
$image = true; $image = true;

View file

@ -40,7 +40,7 @@ $template->assign_vars(array(
// Define show peers mode (count only || user names with complete % || full details) // Define show peers mode (count only || user names with complete % || full details)
$cfg_sp_mode = $bb_cfg['bt_show_peers_mode']; $cfg_sp_mode = $bb_cfg['bt_show_peers_mode'];
$get_sp_mode = (isset($_GET['spmode'])) ? $_GET['spmode'] : ''; $get_sp_mode = $_GET['spmode'] ?? '';
$s_mode = 'count'; $s_mode = 'count';
@ -167,14 +167,14 @@ if ($tor_reged && $tor_info) {
$bt_userdata = DB()->fetch_row($sql); $bt_userdata = DB()->fetch_row($sql);
$user_status = isset($bt_userdata['user_status']) ? $bt_userdata['user_status'] : null; $user_status = $bt_userdata['user_status'] ?? null;
if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) { if (($min_ratio_dl || $min_ratio_warn) && $user_status != DL_STATUS_COMPLETE && $bt_user_id != $poster_id && $tor_type != TOR_TYPE_GOLD) {
if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) { if (($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
$dl_allowed = ($user_ratio > $min_ratio_dl); $dl_allowed = ($user_ratio > $min_ratio_dl);
} }
if ((isset($user_ratio) && isset($min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) { if ((isset($user_ratio, $min_ratio_warn) && $user_ratio < $min_ratio_warn && TR_RATING_LIMITS) || ($bt_userdata['u_down_total'] < MIN_DL_FOR_RATIO)) {
$template->assign_vars(array( $template->assign_vars(array(
'SHOW_RATIO_WARN' => true, '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']),
@ -384,7 +384,7 @@ if ($tor_reged && $tor_info) {
define('SEEDER_EXIST', true); define('SEEDER_EXIST', true);
$seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders"; $seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#seeders";
$template->assign_block_vars("$x_full", array( $template->assign_block_vars((string)$x_full, array(
'SEED_ORD_ACT' => $seed_order_action, 'SEED_ORD_ACT' => $seed_order_action,
'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s' 'SEEDERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s'
)); ));
@ -406,7 +406,7 @@ if ($tor_reged && $tor_info) {
define('LEECHER_EXIST', true); define('LEECHER_EXIST', true);
$leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#leechers"; $leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&amp;spmode=full#leechers";
$template->assign_block_vars("$x_full", array( $template->assign_block_vars((string)$x_full, array(
'LEECH_ORD_ACT' => $leech_order_action, 'LEECH_ORD_ACT' => $leech_order_action,
'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s', 'LEECHERS_UP_TOT' => humn_size($sp_up_tot[$x], 0, 'KB') . '/s',
'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s' 'LEECHERS_DOWN_TOT' => humn_size($sp_down_tot[$x], 0, 'KB') . '/s'

View file

@ -101,7 +101,7 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
for ($i = 0; $i < $last_element; $i++) { for ($i = 0; $i < $last_element; $i++) {
$num_iterations = $last_element - $i; $num_iterations = $last_element - $i;
for ($j = 0; $j < $num_iterations; $j++) { foreach ($sort_array as $j => $jValue) {
// do checks based on key // do checks based on key
$switch = false; $switch = false;
if (!$string_sort) { if (!$string_sort) {
@ -117,7 +117,7 @@ function sort_multi_array($sort_array, $key, $sort_order, $pre_string_sort = 0)
} }
if ($switch) { if ($switch) {
$temp = $sort_array[$j]; $temp = $jValue;
$sort_array[$j] = $sort_array[$j + 1]; $sort_array[$j] = $sort_array[$j + 1];
$sort_array[$j + 1] = $temp; $sort_array[$j + 1] = $temp;
} }

View file

@ -68,7 +68,7 @@ function base64_unpack($string)
for ($i = 1; $i <= $length; $i++) { for ($i = 1; $i <= $length; $i++) {
$pos = $length - $i; $pos = $length - $i;
$operand = strpos($chars, $string[$pos]); $operand = strpos($chars, $string[$pos]);
$exponent = pow($base, $i - 1); $exponent = $base ** ($i - 1);
$decValue = $operand * $exponent; $decValue = $operand * $exponent;
$number += $decValue; $number += $decValue;
} }
@ -87,7 +87,7 @@ function auth_pack($auth_array)
$one_char = $two_char = false; $one_char = $two_char = false;
$auth_cache = ''; $auth_cache = '';
for ($i = 0, $iMax = count($auth_array); $i < $iMax; $i++) { foreach ($auth_array as $i => $iValue) {
$val = base64_pack((int)$auth_array[$i]); $val = base64_pack((int)$auth_array[$i]);
if (strlen($val) == 1 && !$one_char) { if (strlen($val) == 1 && !$one_char) {
$auth_cache .= $one_char_encoding; $auth_cache .= $one_char_encoding;
@ -114,7 +114,7 @@ function auth_unpack($auth_cache)
$auth = []; $auth = [];
$auth_len = 1; $auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) {
$forum_auth = $auth_cache[$pos]; $forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) { if ($forum_auth == $one_char_encoding) {
$auth_len = 1; $auth_len = 1;
@ -149,7 +149,7 @@ function is_forum_authed($auth_cache, $check_forum_id)
$auth = []; $auth = [];
$auth_len = 1; $auth_len = 1;
for ($pos = 0; $pos < strlen($auth_cache); $pos += $auth_len) { for ($pos = 0, $posMax = strlen($auth_cache); $pos < $posMax; $pos += $auth_len) {
$forum_auth = $auth_cache[$pos]; $forum_auth = $auth_cache[$pos];
if ($forum_auth == $one_char_encoding) { if ($forum_auth == $one_char_encoding) {
$auth_len = 1; $auth_len = 1;
@ -266,7 +266,7 @@ function get_attachments_from_post($post_id_array)
$post_id_array[] = $post_id; $post_id_array[] = $post_id;
} }
$post_id_array = implode(', ', array_map('intval', $post_id_array)); $post_id_array = implode(', ', array_map('\intval', $post_id_array));
if ($post_id_array == '') { if ($post_id_array == '') {
return $attachments; return $attachments;
@ -304,7 +304,7 @@ function get_total_attach_filesize($attach_ids)
return 0; return 0;
} }
$attach_ids = implode(', ', array_map('intval', $attach_ids)); $attach_ids = implode(', ', array_map('\intval', $attach_ids));
if (!$attach_ids) { if (!$attach_ids) {
return 0; return 0;
@ -412,7 +412,7 @@ function get_extension($filename)
*/ */
function delete_extension($filename) function delete_extension($filename)
{ {
return substr($filename, 0, strrpos(strtolower(trim($filename)), '.')); return substr($filename, 0, strripos(trim($filename), '.'));
} }
/** /**
@ -535,7 +535,7 @@ function attach_mod_sql_escape($text)
return DB()->escape_string($text); return DB()->escape_string($text);
} }
return str_replace("'", "''", str_replace('\\', '\\\\', $text)); return str_replace(['\\', "'"], ['\\\\', "''"], $text);
} }
/** /**

View file

@ -27,7 +27,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (!is_array($attach_id_array)) { if (!is_array($attach_id_array)) {
if (false !== strpos($attach_id_array, ', ')) { if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array); $attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) { } elseif (false !== strpos($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array); $attach_id_array = explode(',', $attach_id_array);
} else { } else {
$attach_id = (int)$attach_id_array; $attach_id = (int)$attach_id_array;
@ -68,7 +68,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (false !== strpos($post_id_array, ', ')) { if (false !== strpos($post_id_array, ', ')) {
$post_id_array = explode(', ', $post_id_array); $post_id_array = explode(', ', $post_id_array);
} elseif (strstr($post_id_array, ',')) { } elseif (false !== strpos($post_id_array, ',')) {
$post_id_array = explode(',', $post_id_array); $post_id_array = explode(',', $post_id_array);
} else { } else {
$post_id = (int)$post_id_array; $post_id = (int)$post_id_array;
@ -113,7 +113,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
if (!is_array($attach_id_array)) { if (!is_array($attach_id_array)) {
if (false !== strpos($attach_id_array, ', ')) { if (false !== strpos($attach_id_array, ', ')) {
$attach_id_array = explode(', ', $attach_id_array); $attach_id_array = explode(', ', $attach_id_array);
} elseif (strstr($attach_id_array, ',')) { } elseif (false !== strpos($attach_id_array, ',')) {
$attach_id_array = explode(',', $attach_id_array); $attach_id_array = explode(',', $attach_id_array);
} else { } else {
$attach_id = (int)$attach_id_array; $attach_id = (int)$attach_id_array;
@ -171,7 +171,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
} }
//bt end //bt end
for ($i = 0, $iMax = count($attach_id_array); $i < $iMax; $i++) { foreach ($attach_id_array as $i => $iValue) {
$sql = 'SELECT attach_id $sql = 'SELECT attach_id
FROM ' . BB_ATTACHMENTS . ' FROM ' . BB_ATTACHMENTS . '
WHERE attach_id = ' . (int)$attach_id_array[$i]; WHERE attach_id = ' . (int)$attach_id_array[$i];

View file

@ -188,7 +188,7 @@ function quota_limit_select($select_name, $default_quota = 0)
} }
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) { foreach ($quota_name as $i => $iValue) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : ''; $selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>'; $quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
} }
@ -219,7 +219,7 @@ function default_quota_limit_select($select_name, $default_quota = 0)
} }
DB()->sql_freeresult($result); DB()->sql_freeresult($result);
for ($i = 0, $iMax = count($quota_name); $i < $iMax; $i++) { foreach ($quota_name as $i => $iValue) {
$selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : ''; $selected = ($quota_name[$i]['quota_limit_id'] == $default_quota) ? ' selected="selected"' : '';
$quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>'; $quota_select .= '<option value="' . $quota_name[$i]['quota_limit_id'] . '"' . $selected . '>' . $quota_name[$i]['quota_desc'] . '</option>';
} }

View file

@ -26,13 +26,13 @@ function get_img_size_format($width, $height)
round($width * ($max_width / $width)), round($width * ($max_width / $width)),
round($height * ($max_width / $width)) round($height * ($max_width / $width))
); );
} else { }
return array( return array(
round($width * ($max_width / $height)), round($width * ($max_width / $height)),
round($height * ($max_width / $height)) round($height * ($max_width / $height))
); );
} }
}
/** /**
* Check if imagick is present * Check if imagick is present
@ -44,9 +44,9 @@ function is_imagick()
if ($attach_config['img_imagick'] != '') { if ($attach_config['img_imagick'] != '') {
$imagick = $attach_config['img_imagick']; $imagick = $attach_config['img_imagick'];
return true; return true;
} else {
return false;
} }
return false;
} }
/** /**
@ -103,15 +103,13 @@ function create_thumbnail($source, $new_file, $mimetype)
return false; return false;
} }
list($width, $height, $type, ) = getimagesize($source); [$width, $height, $type,] = getimagesize($source);
if (!$width || !$height) { if (!$width || !$height) {
return false; return false;
} }
list($new_width, $new_height) = get_img_size_format($width, $height); [$new_width, $new_height] = get_img_size_format($width, $height);
$tmp_path = $old_file = '';
$used_imagick = false; $used_imagick = false;

View file

@ -456,7 +456,7 @@ $bb_cfg['use_ajax_posts'] = true;
$bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx $bb_cfg['search_engine_type'] = 'mysql'; // none, mysql, sphinx
$bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1'; $bb_cfg['sphinx_topic_titles_host'] = '127.0.0.1';
$bb_cfg['sphinx_topic_titles_port'] = 3312; $bb_cfg['sphinx_topic_titles_port'] = 3312;
$bb_cfg['sphinx_config_path'] = realpath("../install/sphinx/sphinx.conf"); $bb_cfg['sphinx_config_path'] = '../install/sphinx/sphinx.conf';
$bb_cfg['disable_ft_search_in_posts'] = false; // disable searching in post bodies $bb_cfg['disable_ft_search_in_posts'] = false; // disable searching in post bodies
$bb_cfg['disable_search_for_guest'] = true; $bb_cfg['disable_search_for_guest'] = true;
$bb_cfg['allow_search_in_bool_mode'] = true; $bb_cfg['allow_search_in_bool_mode'] = true;

View file

@ -200,7 +200,7 @@ function strip_quotes($text)
do { do {
$pos = strpos($lowertext, '[quote', $curpos); $pos = strpos($lowertext, '[quote', $curpos);
if ($pos !== false) { if ($pos !== false) {
$start_pos["$pos"] = 'start'; $start_pos[(string)$pos] = 'start';
$curpos = $pos + 6; $curpos = $pos + 6;
} }
} while ($pos !== false); } while ($pos !== false);
@ -215,7 +215,7 @@ function strip_quotes($text)
do { do {
$pos = strpos($lowertext, '[/quote', $curpos); $pos = strpos($lowertext, '[/quote', $curpos);
if ($pos !== false) { if ($pos !== false) {
$end_pos["$pos"] = 'end'; $end_pos[(string)$pos] = 'end';
$curpos = $pos + 8; $curpos = $pos + 8;
} }
} while ($pos !== false); } while ($pos !== false);
@ -259,7 +259,7 @@ function strip_quotes($text)
// recursion. // recursion.
if ($stack) { if ($stack) {
foreach ($stack as $pos) { foreach ($stack as $pos) {
unset($pos_list["$pos"]); unset($pos_list[(string)$pos]);
} }
} }
} while ($stack); } while ($stack);
@ -338,9 +338,7 @@ function extract_search_words($text)
$text = preg_replace('/(\w*?)&#?[0-9a-z]+;(\w*?)/iu', '', $text); $text = preg_replace('/(\w*?)&#?[0-9a-z]+;(\w*?)/iu', '', $text);
// Remove URL's ((www|ftp)\.[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]*?) // Remove URL's ((www|ftp)\.[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]*?)
$text = preg_replace('#\b[a-z0-9]+://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+(/[0-9a-z\?\.%_\-\+=&/]+)?#u', ' ', $text); $text = preg_replace('#\b[a-z0-9]+://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+(/[0-9a-z\?\.%_\-\+=&/]+)?#u', ' ', $text);
$text = str_replace('[url=', ' ', $text); $text = str_replace(['[url=', '?', '!'], ' ', $text);
$text = str_replace('?', ' ', $text);
$text = str_replace('!', ' ', $text);
$text = strip_bbcode($text); $text = strip_bbcode($text);

View file

@ -14,21 +14,21 @@ if (!defined('BB_ROOT')) {
function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div) function get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div)
{ {
global $bb_cfg; global $bb_cfg;
$ext = isset($bb_cfg['file_id_ext'][$ext_id]) ? $bb_cfg['file_id_ext'][$ext_id] : ''; $ext = $bb_cfg['file_id_ext'][$ext_id] ?? '';
return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : ''); return ($base_path ? "$base_path/" : '') . floor($id / $first_div) . '/' . ($id % $sec_div) . '/' . $id . ($ext ? ".$ext" : '');
} }
function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100) function get_avatar_path($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100)
{ {
global $bb_cfg; global $bb_cfg;
$base_path = isset($base_path) ? $base_path : $bb_cfg['avatars']['upload_path']; $base_path = $base_path ?? $bb_cfg['avatars']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div);
} }
function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100) function get_attach_path($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100)
{ {
global $bb_cfg; global $bb_cfg;
$base_path = isset($base_path) ? $base_path : $bb_cfg['attach']['upload_path']; $base_path = $base_path ?? $bb_cfg['attach']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div); return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div);
} }
@ -104,8 +104,8 @@ function get_last_read($topic_id = 0, $forum_id = 0)
{ {
global $tracking_topics, $tracking_forums, $user; global $tracking_topics, $tracking_forums, $user;
$t = isset($tracking_topics[$topic_id]) ? $tracking_topics[$topic_id] : 0; $t = $tracking_topics[$topic_id] ?? 0;
$f = isset($tracking_forums[$forum_id]) ? $tracking_forums[$forum_id] : 0; $f = $tracking_forums[$forum_id] ?? 0;
return max($t, $f, $user->data['user_lastvisit']); return max($t, $f, $user->data['user_lastvisit']);
} }
@ -587,9 +587,9 @@ function bt_show_ip($ip, $port = '')
$ip = decode_ip($ip); $ip = decode_ip($ip);
$ip .= ($port) ? ":$port" : ''; $ip .= ($port) ? ":$port" : '';
return $ip; return $ip;
} else {
return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip);
} }
return ($bb_cfg['bt_show_ip_only_moder']) ? false : decode_ip_xx($ip);
} }
function bt_show_port($port) function bt_show_port($port)
@ -598,9 +598,9 @@ function bt_show_port($port)
if (IS_AM) { if (IS_AM) {
return $port; return $port;
} else {
return ($bb_cfg['bt_show_port_only_moder']) ? false : $port;
} }
return ($bb_cfg['bt_show_port_only_moder']) ? false : $port;
} }
function decode_ip_xx($ip) function decode_ip_xx($ip)
@ -678,7 +678,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) { if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) {
return (is_array($default)) ? array() : $default; return (is_array($default)) ? array() : $default;
} }
$_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name]; $_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]))) { if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) {
@ -689,13 +689,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
if (!is_array($default)) { if (!is_array($default)) {
$type = gettype($default); $type = gettype($default);
} else { } else {
list($key_type, $type) = $default; [$key_type, $type] = $default;
$type = gettype($type); $type = gettype($type);
$key_type = gettype($key_type); $key_type = gettype($key_type);
if ($type == 'array') { if ($type == 'array') {
reset($default); reset($default);
$default = current($default); $default = current($default);
list($sub_key_type, $sub_type) = $default; [$sub_key_type, $sub_type] = $default;
$sub_type = gettype($sub_type); $sub_type = gettype($sub_type);
$sub_type = ($sub_type == 'array') ? 'NULL' : $sub_type; $sub_type = ($sub_type == 'array') ? 'NULL' : $sub_type;
$sub_key_type = gettype($sub_key_type); $sub_key_type = gettype($sub_key_type);
@ -741,11 +741,11 @@ function get_username($user_id)
$usernames[$row['user_id']] = $row['username']; $usernames[$row['user_id']] = $row['username'];
} }
return $usernames; return $usernames;
} else { }
$row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1"); $row = DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1");
return $row['username']; return $row['username'];
} }
}
function get_user_id($username) function get_user_id($username)
{ {
@ -846,9 +846,9 @@ function get_attachments_dir($cfg = null)
if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':')) { if ($cfg['upload_dir'][0] == '/' || ($cfg['upload_dir'][0] != '/' && $cfg['upload_dir'][1] == ':')) {
return $cfg['upload_dir']; return $cfg['upload_dir'];
} else {
return BB_ROOT . $cfg['upload_dir'];
} }
return BB_ROOT . $cfg['upload_dir'];
} }
function bb_get_config($table, $from_db = false, $update_cache = true) function bb_get_config($table, $from_db = false, $update_cache = true)
@ -1386,7 +1386,7 @@ function bb_realpath($path)
function login_redirect($url = '') function login_redirect($url = '')
{ {
redirect(LOGIN_URL . '?redirect=' . (($url) ?: (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'))); redirect(LOGIN_URL . '?redirect=' . (($url) ?: ($_SERVER['REQUEST_URI'] ?? '/')));
} }
function meta_refresh($url, $time = 5) function meta_refresh($url, $time = 5)
@ -1453,9 +1453,9 @@ function get_forum_display_sort_option($selected_row = 0, $action = 'list', $lis
// build list // build list
if ($action == 'list') { if ($action == 'list') {
for ($i = 0, $iMax = count($listrow['lang_key']); $i < $iMax; $i++) { foreach ($listrow['lang_key'] as $i => $iValue) {
$selected = ($i == $selected_row) ? ' selected="selected"' : ''; $selected = ($i == $selected_row) ? ' selected="selected"' : '';
$l_value = (isset($lang[$listrow['lang_key'][$i]])) ? $lang[$listrow['lang_key'][$i]] : $listrow['lang_key'][$i]; $l_value = $lang[$listrow['lang_key'][$i]] ?? $iValue;
$res .= '<option value="' . $i . '"' . $selected . '>' . $l_value . '</option>'; $res .= '<option value="' . $i . '"' . $selected . '>' . $l_value . '</option>';
} }
} else { } else {
@ -1543,7 +1543,7 @@ if (!function_exists('array_intersect_key')) {
// Check arrays // Check arrays
$array_count = count($args); $array_count = count($args);
for ($i = 0; $i !== $array_count; $i++) { foreach ($args as $i => $iValue) {
if (!is_array($args[$i])) { if (!is_array($args[$i])) {
user_error('array_intersect_key() Argument #' . user_error('array_intersect_key() Argument #' .
($i + 1) . ' is not an array', E_USER_WARNING); ($i + 1) . ' is not an array', E_USER_WARNING);
@ -1612,7 +1612,7 @@ function get_topic_icon($topic, $is_unread = null)
global $bb_cfg, $images; global $bb_cfg, $images;
$t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']); $t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']);
$is_unread = null === $is_unread ? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']) : $is_unread; $is_unread = $is_unread ?? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']);
if ($topic['topic_status'] == TOPIC_MOVED) { if ($topic['topic_status'] == TOPIC_MOVED) {
$folder_image = $images['folder']; $folder_image = $images['folder'];
@ -1789,8 +1789,7 @@ function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
if ($bb_cfg['search_engine_type'] == 'sphinx') { if ($bb_cfg['search_engine_type'] == 'sphinx') {
$text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3" $text = preg_replace('#(?<=\S)\-#u', ' ', $text); // "1-2-3" -> "1 2 3"
$text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно) $text = preg_replace('#[^0-9a-zA-Zа-яА-ЯёЁ\-_*|]#u', ' ', $text); // допустимые символы (кроме " которые отдельно)
$text = str_replace('-', ' -', $text); // - только в начале слова $text = str_replace(['-', '*'], [' -', '* '], $text); // только в начале / конце слова
$text = str_replace('*', '* ', $text); // * только в конце слова
$text = preg_replace('#\s*\|\s*#u', '|', $text); // "| " -> "|" $text = preg_replace('#\s*\|\s*#u', '|', $text); // "| " -> "|"
$text = preg_replace('#\|+#u', ' | ', $text); // "||" -> "|" $text = preg_replace('#\|+#u', ' | ', $text); // "||" -> "|"
$text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // одиночные " - ", " * " $text = preg_replace('#(?<=\s)[\-*]+\s#u', ' ', $text); // одиночные " - ", " * "
@ -1835,7 +1834,7 @@ function log_sphinx_error($err_type, $err_msg, $query = '')
} }
} }
function get_title_match_topics($title_match_sql, $forum_ids = []) function get_title_match_topics($title_match_sql, array $forum_ids = [])
{ {
global $bb_cfg, $sphinx, $userdata, $title_match, $lang; global $bb_cfg, $sphinx, $userdata, $title_match, $lang;
@ -2011,10 +2010,6 @@ function get_avatar($user_id, $ext_id, $allow_avatar = true, $size = true, $heig
{ {
global $bb_cfg; global $bb_cfg;
if ($size) {
// TODO размеры: s, m, l + кеширование
}
$height = !$height ? 'height="' . $height . '"' : ''; $height = !$height ? 'height="' . $height . '"' : '';
$width = !$width ? 'width="' . $width . '"' : ''; $width = !$width ? 'width="' . $width . '"' : '';

View file

@ -14,8 +14,8 @@ if (!defined('BB_ROOT')) {
/** /**
* Check PHP version * Check PHP version
*/ */
if (version_compare(PHP_VERSION, '5.6', '<')) { if (PHP_VERSION_ID < 70103) {
die('TorrentPier requires PHP version 5.6+. Your PHP version ' . PHP_VERSION); die('TorrentPier requires PHP version 7.1.3+. Your PHP version ' . PHP_VERSION);
} }
/** /**

View file

@ -331,14 +331,14 @@ foreach ($profile_fields as $field => $can_edit) {
$update_user_opt = array( $update_user_opt = array(
# 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change # 'user_opt_name' => ($reg_mode) ? #reg_value : #in_login_change
'user_viewemail' => ($reg_mode) ? false : true, 'user_viewemail' => $reg_mode ? false : true,
'user_viewonline' => ($reg_mode) ? false : true, 'user_viewonline' => $reg_mode ? false : true,
'user_notify' => ($reg_mode) ? true : true, 'user_notify' => $reg_mode ? true : true,
'user_notify_pm' => ($reg_mode) ? true : true, 'user_notify_pm' => $reg_mode ? true : true,
'user_porn_forums' => ($reg_mode) ? false : true, 'user_porn_forums' => $reg_mode ? false : true,
'user_dls' => ($reg_mode) ? false : true, 'user_dls' => $reg_mode ? false : true,
'user_callseed' => ($reg_mode) ? true : true, 'user_callseed' => $reg_mode ? true : true,
'user_retracker' => ($reg_mode) ? true : true, 'user_retracker' => $reg_mode ? true : true,
); );
foreach ($update_user_opt as $opt => $can_change_opt) { foreach ($update_user_opt as $opt => $can_change_opt) {

View file

@ -37,11 +37,10 @@ if (preg_match('/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si', $_SERVER['QUERY_STRING
} elseif (!empty($_POST['redirect'])) { } elseif (!empty($_POST['redirect'])) {
$redirect_url = str_replace('&amp;', '&', htmlspecialchars($_POST['redirect'])); $redirect_url = str_replace('&amp;', '&', htmlspecialchars($_POST['redirect']));
} elseif (!empty($_SERVER['HTTP_REFERER']) && ($parts = @parse_url($_SERVER['HTTP_REFERER']))) { } elseif (!empty($_SERVER['HTTP_REFERER']) && ($parts = @parse_url($_SERVER['HTTP_REFERER']))) {
$redirect_url = (isset($parts['path']) ? $parts['path'] : "index.php") . (isset($parts['query']) ? '?' . $parts['query'] : ''); $redirect_url = ($parts['path'] ?? "index.php") . (isset($parts['query']) ? '?' . $parts['query'] : '');
} }
$redirect_url = str_replace('&admin=1', '', $redirect_url); $redirect_url = str_replace(['&admin=1', '?admin=1'], '', $redirect_url);
$redirect_url = str_replace('?admin=1', '', $redirect_url);
if (!$redirect_url || false !== strpos(urldecode($redirect_url), "\n") || false !== strpos(urldecode($redirect_url), "\r") || false !== strpos(urldecode($redirect_url), ';url')) { if (!$redirect_url || false !== strpos(urldecode($redirect_url), "\n") || false !== strpos(urldecode($redirect_url), "\r") || false !== strpos(urldecode($redirect_url), ';url')) {
$redirect_url = "index.php"; $redirect_url = "index.php";
@ -56,8 +55,8 @@ if (isset($_REQUEST['admin']) && !IS_AM) {
$mod_admin_login = (IS_AM && !$user->data['session_admin']); $mod_admin_login = (IS_AM && !$user->data['session_admin']);
// login username & password // login username & password
$login_username = ($mod_admin_login) ? $userdata['username'] : (isset($_POST['login_username']) ? $_POST['login_username'] : ''); $login_username = ($mod_admin_login) ? $userdata['username'] : ($_POST['login_username'] ?? '');
$login_password = isset($_POST['login_password']) ? $_POST['login_password'] : ''; $login_password = $_POST['login_password'] ?? '';
// Проверка на неверную комбинацию логин/пароль // Проверка на неверную комбинацию логин/пароль
$need_captcha = false; $need_captcha = false;

View file

@ -147,7 +147,7 @@ $template->assign_vars(array(
// per-letter selection end // per-letter selection end
$sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")"; $sql = "SELECT username, user_id, user_rank, user_opt, user_posts, user_regdate, user_from, user_website, user_email FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")";
if ($username) { if ($username) {
$username = preg_replace('/\*/', '%', clean_username($username)); $username = str_replace("\*", '%', clean_username($username));
$letter_sql = "username LIKE '" . DB()->escape($username) . "'"; $letter_sql = "username LIKE '" . DB()->escape($username) . "'";
} }
$sql .= ($letter_sql) ? " AND $letter_sql" : ''; $sql .= ($letter_sql) ? " AND $letter_sql" : '';

View file

@ -70,9 +70,9 @@ function validate_mode_condition($request_index, $mod_action = '')
} }
// Obtain initial vars // Obtain initial vars
$forum_id = isset($_REQUEST['f']) ? $_REQUEST['f'] : 0; $forum_id = $_REQUEST['f'] ?? 0;
$topic_id = isset($_REQUEST['t']) ? $_REQUEST['t'] : 0; $topic_id = $_REQUEST['t'] ?? 0;
$post_id = isset($_REQUEST['p']) ? $_REQUEST['p'] : 0; $post_id = $_REQUEST['p'] ?? 0;
$start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0; $start = isset($_REQUEST['start']) ? abs((int)$_REQUEST['start']) : 0;
$confirmed = isset($_POST['confirm']); $confirmed = isset($_POST['confirm']);
@ -166,7 +166,7 @@ if (!$is_auth['auth_mod']) {
// Redirect to login page if not admin session // Redirect to login page if not admin session
if ($is_moderator && !$userdata['session_admin']) { if ($is_moderator && !$userdata['session_admin']) {
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : $_SERVER['REQUEST_URI']; $redirect = $_POST['redirect'] ?? $_SERVER['REQUEST_URI'];
redirect(LOGIN_URL . "?redirect=$redirect&admin=1"); redirect(LOGIN_URL . "?redirect=$redirect&admin=1");
} }
@ -189,7 +189,7 @@ switch ($mode) {
bb_die($lang['NONE_SELECTED']); bb_die($lang['NONE_SELECTED']);
} }
$req_topics = isset($_POST['topic_id_list']) ? $_POST['topic_id_list'] : $topic_id; $req_topics = $_POST['topic_id_list'] ?? $topic_id;
validate_topics($forum_id, $req_topics, $topic_titles); validate_topics($forum_id, $req_topics, $topic_titles);
if (!$req_topics || !($topic_csv = get_id_csv($req_topics))) { if (!$req_topics || !($topic_csv = get_id_csv($req_topics))) {
@ -370,10 +370,10 @@ switch ($mode) {
//mpd //mpd
$delete_posts = isset($_POST['delete_posts']); $delete_posts = isset($_POST['delete_posts']);
$split = (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond'])); $split = (isset($_POST['split_type_all']) || isset($_POST['split_type_beyond']));
$posts = (isset($_POST['post_id_list'])) ? $_POST['post_id_list'] : array(); $posts = $_POST['post_id_list'] ?? array();
$start = /* (isset($_POST['start'])) ? intval($_POST['start']) : */ $start = /* (isset($_POST['start'])) ? intval($_POST['start']) : */
0; 0;
$topic_first_post_id = (isset($topic_row['topic_first_post_id'])) ? $topic_row['topic_first_post_id'] : ''; $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 = array();

View file

@ -324,7 +324,7 @@ if (($delete || $mode == 'delete') && !$confirm) {
$username = (!empty($_POST['username'])) ? clean_username($_POST['username']) : ''; $username = (!empty($_POST['username'])) ? clean_username($_POST['username']) : '';
$subject = (!empty($_POST['subject'])) ? clean_title($_POST['subject']) : ''; $subject = (!empty($_POST['subject'])) ? clean_title($_POST['subject']) : '';
$message = (!empty($_POST['message'])) ? prepare_message($_POST['message']) : ''; $message = (!empty($_POST['message'])) ? prepare_message($_POST['message']) : '';
$attach_rg_sig = (isset($_POST['attach_rg_sig']) && isset($_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? 1 : 0; $attach_rg_sig = (isset($_POST['attach_rg_sig'], $_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? 1 : 0;
$poster_rg_id = (isset($_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? (int)$_POST['poster_rg'] : 0; $poster_rg_id = (isset($_POST['poster_rg']) && $_POST['poster_rg'] != -1) ? (int)$_POST['poster_rg'] : 0;
\TorrentPier\Legacy\Post::prepare_post($mode, $post_data, $error_msg, $username, $subject, $message); \TorrentPier\Legacy\Post::prepare_post($mode, $post_data, $error_msg, $username, $subject, $message);
@ -527,7 +527,7 @@ if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
} }
} }
//bt //bt
$topic_dl_type = (isset($post_info['topic_dl_type'])) ? $post_info['topic_dl_type'] : 0; $topic_dl_type = $post_info['topic_dl_type'] ?? 0;
if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod'])) { if ($post_info['allow_reg_tracker'] && $post_data['first_post'] && ($topic_dl_type || $is_auth['auth_mod'])) {
$sql = " $sql = "

View file

@ -1046,7 +1046,6 @@ if ($mode == 'read') {
$replacement_word = array(); $replacement_word = array();
obtain_word_list($orig_word, $replacement_word); obtain_word_list($orig_word, $replacement_word);
$preview_message = htmlCHR($privmsg_message, false, ENT_NOQUOTES);
$preview_message = bbcode2html($privmsg_message); $preview_message = bbcode2html($privmsg_message);
if (count($orig_word)) { if (count($orig_word)) {
@ -1287,7 +1286,7 @@ if ($mode == 'read') {
$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_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']);
$select_msg_days = ''; $select_msg_days = '';
for ($i = 0; $i < count($previous_days); $i++) { for ($i = 0, $iMax = count($previous_days); $i < $iMax; $i++) {
$selected = ($msg_days == $previous_days[$i]) ? ' selected="selected"' : ''; $selected = ($msg_days == $previous_days[$i]) ? ' selected="selected"' : '';
$select_msg_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>'; $select_msg_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
} }

View file

@ -70,7 +70,7 @@ $tracking_forums = get_tracks('forum');
if ($mode =& $_REQUEST['mode']) { if ($mode =& $_REQUEST['mode']) {
// This handles the simple windowed user search functions called from various other scripts // This handles the simple windowed user search functions called from various other scripts
if ($mode == 'searchuser') { if ($mode == 'searchuser') {
$username = isset($_POST['search_username']) ? $_POST['search_username'] : ''; $username = $_POST['search_username'] ?? '';
username_search($username); username_search($username);
exit; exit;
} }
@ -517,7 +517,7 @@ if ($post_mode) {
$SQL['GROUP BY'][] = "item_id"; $SQL['GROUP BY'][] = "item_id";
$SQL['ORDER BY'][] = ($new_posts && $join_p) ? "p.topic_id ASC, p.post_time ASC" : "$order $sort"; $SQL['ORDER BY'][] = ($new_posts && $join_p) ? "p.topic_id ASC, p.post_time ASC" : "$order $sort";
$SQL['LIMIT'][] = "$search_limit"; $SQL['LIMIT'][] = (string)$search_limit;
$items_display = fetch_search_ids($SQL); $items_display = fetch_search_ids($SQL);
} elseif (!$items_display = array_slice($items_found, $start, $per_page)) { } elseif (!$items_display = array_slice($items_found, $start, $per_page)) {
@ -726,7 +726,7 @@ else {
} }
$SQL['GROUP BY'][] = "item_id"; $SQL['GROUP BY'][] = "item_id";
$SQL['LIMIT'][] = "$search_limit"; $SQL['LIMIT'][] = (string)$search_limit;
if ($egosearch) { if ($egosearch) {
$SQL['ORDER BY'][] = 'max_post_time DESC'; $SQL['ORDER BY'][] = 'max_post_time DESC';
@ -767,7 +767,7 @@ else {
$SQL['WHERE'][] = "t.forum_id NOT IN($excluded_forums_csv)"; $SQL['WHERE'][] = "t.forum_id NOT IN($excluded_forums_csv)";
} }
$SQL['LIMIT'][] = "$per_page"; $SQL['LIMIT'][] = (string)$per_page;
// Fetch topics data // Fetch topics data
$topic_rows = array(); $topic_rows = array();
@ -918,7 +918,7 @@ function username_search($search_match)
$username_list = ''; $username_list = '';
if (!empty($search_match)) { if (!empty($search_match)) {
$username_search = preg_replace('/\*/', '%', clean_username($search_match)); $username_search = str_replace("\*", '%', clean_username($search_match));
$sql = " $sql = "
SELECT username SELECT username

View file

@ -107,8 +107,8 @@ class CronHelper
*/ */
public static function trackRunning($mode) public static function trackRunning($mode)
{ {
if (!defined('START_MARK')) { if (!\defined('START_MARK')) {
define('START_MARK', TRIGGERS_DIR . '/cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid()); \define('START_MARK', TRIGGERS_DIR . '/cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid());
} }
if ($mode === 'start') { if ($mode === 'start') {

View file

@ -239,9 +239,10 @@ class Common
$where_sql $where_sql
"; ";
$topic_csv = array(); $topic_csv = [];
foreach (DB()->fetch_rowset($sql) as $row) { foreach (DB()->fetch_rowset($sql) as $row) {
/** @noinspection UnsupportedStringOffsetOperationsInspection */
$topic_csv[] = $row['topic_id']; $topic_csv[] = $row['topic_id'];
$log_topics[] = $row; $log_topics[] = $row;
$sync_forums[$row['forum_id']] = true; $sync_forums[$row['forum_id']] = true;
@ -660,7 +661,7 @@ class Common
$log_action->admin('mod_post_delete', array( $log_action->admin('mod_post_delete', array(
'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', array(
'forum_id' => $row['forum_id'], 'forum_id' => $row['forum_id'],

View file

@ -22,7 +22,7 @@ class Cron
*/ */
public static function run_jobs($jobs) public static function run_jobs($jobs)
{ {
define('IN_CRON', true); \define('IN_CRON', true);
$sql = "SELECT cron_script FROM " . BB_CRON . " WHERE cron_id IN ($jobs)"; $sql = "SELECT cron_script FROM " . BB_CRON . " WHERE cron_id IN ($jobs)";
if (!$result = DB()->sql_query($sql)) { if (!$result = DB()->sql_query($sql)) {

View file

@ -105,9 +105,9 @@ class Torrent
foreach ($default_cfg as $config_name => $config_value) { foreach ($default_cfg as $config_name => $config_value) {
$template->assign_vars(array( $template->assign_vars(array(
'L_' . strtoupper($config_name) => isset($lang[$config_name]) ? $lang[$config_name] : '', 'L_' . strtoupper($config_name) => $lang[$config_name] ?? '',
'L_' . strtoupper($config_name) . '_EXPL' => isset($lang[$config_name . '_expl']) ? $lang[$config_name . '_expl'] : '', 'L_' . strtoupper($config_name) . '_EXPL' => $lang[$config_name . '_expl'] ?? '',
'L_' . strtoupper($config_name) . '_HEAD' => isset($lang[$config_name . '_head']) ? $lang[$config_name . '_head'] : '', 'L_' . strtoupper($config_name) . '_HEAD' => $lang[$config_name . '_head'] ?? '',
)); ));
} }
} }

View file

@ -71,7 +71,7 @@ class Ajax
// Check that requested action is valid // Check that requested action is valid
$action = $this->action; $action = $this->action;
if (!$action || !is_string($action)) { if (!$action || !\is_string($action)) {
$this->ajax_die('no action specified'); $this->ajax_die('no action specified');
} elseif (!$action_params =& $this->valid_actions[$action]) { } elseif (!$action_params =& $this->valid_actions[$action]) {
$this->ajax_die('invalid action: ' . $action); $this->ajax_die('invalid action: ' . $action);
@ -179,8 +179,8 @@ class Ajax
$response_js = json_encode($this->response); $response_js = json_encode($this->response);
if (GZIP_OUTPUT_ALLOWED && !defined('NO_GZIP')) { if (GZIP_OUTPUT_ALLOWED && !\defined('NO_GZIP')) {
if (UA_GZIP_SUPPORTED && strlen($response_js) > 2000) { if (UA_GZIP_SUPPORTED && \strlen($response_js) > 2000) {
header('Content-Encoding: gzip'); header('Content-Encoding: gzip');
$response_js = gzencode($response_js, 1); $response_js = gzencode($response_js, 1);
} }

View file

@ -84,7 +84,7 @@ class Atom
} }
$topics[] = $topic; $topics[] = $topic;
} }
if (!count($topics)) { if (!\count($topics)) {
@unlink($file_path); @unlink($file_path);
return false; return false;
} }
@ -138,7 +138,7 @@ class Atom
} }
$topics[] = $topic; $topics[] = $topic;
} }
if (!count($topics)) { if (!\count($topics)) {
@unlink($file_path); @unlink($file_path);
return false; return false;
} }
@ -163,7 +163,7 @@ 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;
$dir = dirname($file_path); $dir = \dirname($file_path);
if (!file_exists($dir)) { if (!file_exists($dir)) {
if (!bb_mkdir($dir)) { if (!bb_mkdir($dir)) {
return false; return false;
@ -195,7 +195,7 @@ class Atom
$orig_word = array(); $orig_word = array();
$replacement_word = array(); $replacement_word = array();
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);
} }
$topic_title = wbr($topic_title); $topic_title = wbr($topic_title);

View file

@ -48,7 +48,7 @@ class Attach
$this->attachment_extension_list = get_var('extension_list', ['']); $this->attachment_extension_list = get_var('extension_list', ['']);
$this->attachment_mimetype_list = get_var('mimetype_list', ['']); $this->attachment_mimetype_list = get_var('mimetype_list', ['']);
$this->filename = (isset($_FILES['fileupload']) && isset($_FILES['fileupload']['name']) && $_FILES['fileupload']['name'] !== 'none') ? trim(stripslashes($_FILES['fileupload']['name'])) : ''; $this->filename = (isset($_FILES['fileupload'], $_FILES['fileupload']['name']) && $_FILES['fileupload']['name'] !== 'none') ? trim(stripslashes($_FILES['fileupload']['name'])) : '';
$this->attachment_list = get_var('attachment_list', ['']); $this->attachment_list = get_var('attachment_list', ['']);
$this->attachment_thumbnail_list = get_var('attach_thumbnail_list', [0]); $this->attachment_thumbnail_list = get_var('attach_thumbnail_list', [0]);
@ -247,7 +247,7 @@ class Attach
} }
} }
$this->num_attachments = count($this->attachment_list); $this->num_attachments = \count($this->attachment_list);
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 = \count($actual_list); $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 = \count($this->attachment_list); $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 = \count($actual_id_list); $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,11 +532,11 @@ 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 = \count($this->attachment_list); $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')) {
define('TORRENT_ATTACH_ID', $this->attachment_id_list[$i]); \define('TORRENT_ATTACH_ID', $this->attachment_id_list[$i]);
} }
//bt end //bt end
@ -574,8 +574,8 @@ class Attach
$attach_id = DB()->sql_nextid(); $attach_id = DB()->sql_nextid();
//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')) {
define('TORRENT_ATTACH_ID', $attach_id); \define('TORRENT_ATTACH_ID', $attach_id);
} }
//bt end //bt end
@ -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 = \count($this->attachment_list); $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 = \count($this->attachment_list); $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 {
@ -907,7 +907,7 @@ class Attach
// Check Image Size, if it's an image // Check Image Size, if it's an image
if (!$error && !IS_ADMIN && $cat_id === IMAGE_CAT) { if (!$error && !IS_ADMIN && $cat_id === IMAGE_CAT) {
list($width, $height) = image_getdimension($upload_dir . '/' . $this->attach_filename); [$width, $height] = image_getdimension($upload_dir . '/' . $this->attach_filename);
if ($width && $height && (int)$attach_config['img_max_width'] && (int)$attach_config['img_max_height']) { if ($width && $height && (int)$attach_config['img_max_width'] && (int)$attach_config['img_max_height']) {
if ($width > (int)$attach_config['img_max_width'] || $height > (int)$attach_config['img_max_height']) { if ($width > (int)$attach_config['img_max_width'] || $height > (int)$attach_config['img_max_height']) {

View file

@ -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 ((\count($this->attachment_list) > 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)) {

View file

@ -281,7 +281,7 @@ class BBCode
$url = 'http://' . $url; $url = 'http://' . $url;
} }
if (in_array(parse_url($url, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) { if (\in_array(parse_url($url, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) {
$link = "<a href=\"$url\" class=\"postLink\">$url_name</a>"; $link = "<a href=\"$url\" class=\"postLink\">$url_name</a>";
} else { } else {
$link = "<a href=\"$url\" class=\"postLink\" rel=\"nofollow\">$url_name</a>"; $link = "<a href=\"$url\" class=\"postLink\" rel=\"nofollow\">$url_name</a>";
@ -352,7 +352,7 @@ class BBCode
$href = $m[1]; $href = $m[1];
$name = (mb_strlen($href, 'UTF-8') > $max_len) ? mb_substr($href, 0, $max_len - 19) . '...' . mb_substr($href, -16) : $href; $name = (mb_strlen($href, 'UTF-8') > $max_len) ? mb_substr($href, 0, $max_len - 19) . '...' . mb_substr($href, -16) : $href;
if (in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) { if (\in_array(parse_url($href, PHP_URL_HOST), $bb_cfg['nofollow']['allowed_url']) || $bb_cfg['nofollow']['disabled']) {
$link = "<a href=\"$href\" class=\"postLink\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\">$name</a>";
} else { } else {
$link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>"; $link = "<a href=\"$href\" class=\"postLink\" rel=\"nofollow\">$name</a>";

View file

@ -60,13 +60,13 @@ class Apc extends Common
$this->num_queries++; $this->num_queries++;
return apc_delete($this->prefix . $name); return apc_delete($this->prefix . $name);
} else {
return apc_clear_cache();
} }
return apc_clear_cache();
} }
public function is_installed() public function is_installed()
{ {
return function_exists('apc_fetch'); return \function_exists('apc_fetch');
} }
} }

View file

@ -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) ? array() : false;
} }
/** /**

View file

@ -46,7 +46,7 @@ class File extends Common
public function set($name, $value, $ttl = 86400) public function set($name, $value, $ttl = 86400)
{ {
if (!function_exists('var_export')) { if (!\function_exists('var_export')) {
return false; return false;
} }

View file

@ -97,9 +97,9 @@ class Memcache extends Common
$this->num_queries++; $this->num_queries++;
return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false; return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false;
} else {
return ($this->connected) ? $this->memcache->flush() : false;
} }
return ($this->connected) ? $this->memcache->flush() : false;
} }
public function is_installed() public function is_installed()

View file

@ -85,9 +85,9 @@ class Redis extends Common
$this->num_queries++; $this->num_queries++;
return true; return true;
} else {
return false;
} }
return false;
} }
public function rm($name = '') public function rm($name = '')
@ -104,9 +104,9 @@ class Redis extends Common
$this->num_queries++; $this->num_queries++;
return ($this->connected) ? $this->redis->del($this->prefix . $name) : false; return ($this->connected) ? $this->redis->del($this->prefix . $name) : false;
} else {
return ($this->connected) ? $this->redis->flushDB() : false;
} }
return ($this->connected) ? $this->redis->flushDB() : false;
} }
public function is_installed() public function is_installed()

View file

@ -44,11 +44,11 @@ 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) ? array() : false;
} }
$this->db->shard($name); $this->db->shard($name);
$cached_items = array(); $cached_items = array();
$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);
$name_ary = $name_sql = (array)$name; $name_ary = $name_sql = (array)$name;
@ -59,7 +59,7 @@ class Sqlite extends Common
SELECT cache_name, cache_value SELECT cache_name, cache_value
FROM " . $this->cfg['table_name'] . " FROM " . $this->cfg['table_name'] . "
WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . " WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
LIMIT " . count($name) . " LIMIT " . \count($name) . "
"); ");
$this->db->debug('start', 'unserialize()'); $this->db->debug('start', 'unserialize()');
@ -76,11 +76,11 @@ class Sqlite extends Common
} }
} }
// return // return
if (is_array($this->prefix . $name)) { if (\is_array($this->prefix . $name)) {
return $cached_items; return $cached_items;
} else {
return isset($cached_items[$name]) ? $cached_items[$name] : false;
} }
return $cached_items[$name] ?? false;
} }
public function set($name, $value, $ttl = 604800) public function set($name, $value, $ttl = 604800)

View file

@ -70,7 +70,7 @@ class SqliteCommon extends Common
if ($type == 'none') { if ($type == 'none') {
return; return;
} }
if (is_array($name)) { if (\is_array($name)) {
trigger_error('cannot shard: $name is array', E_USER_ERROR); trigger_error('cannot shard: $name is array', E_USER_ERROR);
} }
@ -128,7 +128,7 @@ class SqliteCommon extends Common
public function fetch_row($query) public function fetch_row($query)
{ {
$result = $this->query($query); $result = $this->query($query);
return is_resource($result) ? $result->fetchArray(SQLITE3_ASSOC) : false; return \is_resource($result) ? $result->fetchArray(SQLITE3_ASSOC) : false;
} }
public function fetch_rowset($query) public function fetch_rowset($query)
@ -143,7 +143,7 @@ class SqliteCommon extends Common
public function changes() public function changes()
{ {
return is_resource($this->dbh) ? $this->dbh->changes() : 0; return \is_resource($this->dbh) ? $this->dbh->changes() : 0;
} }
public function escape($str) public function escape($str)
@ -153,7 +153,7 @@ class SqliteCommon extends Common
public function get_error_msg() public function get_error_msg()
{ {
return 'SQLite error #' . ($err_code = $this->dbh->lastErrorCode()) . ': ' . $this->dbh->lastErrorMsg(); return 'SQLite error #' . $this->dbh->lastErrorCode() . ': ' . $this->dbh->lastErrorMsg();
} }
public function rm($name = '') public function rm($name = '')

View file

@ -60,15 +60,15 @@ class Xcache extends Common
$this->num_queries++; $this->num_queries++;
return xcache_unset($this->prefix . $name); return xcache_unset($this->prefix . $name);
} else { }
xcache_clear_cache(XC_TYPE_PHP, 0); xcache_clear_cache(XC_TYPE_PHP, 0);
xcache_clear_cache(XC_TYPE_VAR, 0); xcache_clear_cache(XC_TYPE_VAR, 0);
return; return;
} }
}
public function is_installed() public function is_installed()
{ {
return function_exists('xcache_get'); return \function_exists('xcache_get');
} }
} }

View file

@ -102,9 +102,9 @@ class Caches
{ {
if (!empty($cfg['shard_type']) && $cfg['shard_type'] != 'none') { if (!empty($cfg['shard_type']) && $cfg['shard_type'] != 'none') {
return $this->cfg['db_dir'] . $name . '_*' . $ext; return $this->cfg['db_dir'] . $name . '_*' . $ext;
} else {
return $this->cfg['db_dir'] . $name . $ext;
} }
return $this->cfg['db_dir'] . $name . $ext;
} }
public function get_table_schema($cfg) public function get_table_schema($cfg)

View file

@ -66,7 +66,7 @@ class Html
foreach ($params as $opt_name => $opt_val) { foreach ($params as $opt_name => $opt_val) {
$opt_name = rtrim($opt_name); $opt_name = rtrim($opt_name);
if (is_array($opt_val)) { if (\is_array($opt_val)) {
$this->cur_attr =& $this->cur_attr[$opt_name]; $this->cur_attr =& $this->cur_attr[$opt_name];
$label = htmlCHR(str_short($opt_name, $this->max_length)); $label = htmlCHR(str_short($opt_name, $this->max_length));
@ -112,7 +112,7 @@ class Html
public function _array2html_rec($array, $ul, $li) public function _array2html_rec($array, $ul, $li)
{ {
foreach ($array as $k => $v) { foreach ($array as $k => $v) {
if (is_array($v)) { if (\is_array($v)) {
$this->out .= "<$li><span class=\"b\">$k</span><$ul>"; $this->out .= "<$li><span class=\"b\">$k</span><$ul>";
$this->_array2html_rec($v, $ul, $li); $this->_array2html_rec($v, $ul, $li);
$this->out .= "</$ul></$li>"; $this->out .= "</$ul></$li>";

View file

@ -92,7 +92,7 @@ class Upload
// img // img
if ($this->cfg['max_width'] || $this->cfg['max_height']) { if ($this->cfg['max_width'] || $this->cfg['max_height']) {
if ($img_info = getimagesize($this->file['tmp_name'])) { if ($img_info = getimagesize($this->file['tmp_name'])) {
list($width, $height, $type, $attr) = $img_info; [$width, $height, $type, $attr] = $img_info;
// redefine ext // redefine ext
if (!$width || !$height || !$type || !isset($this->img_types[$type])) { if (!$width || !$height || !$type || !isset($this->img_types[$type])) {
@ -112,7 +112,7 @@ class Upload
} }
} }
// check ext // check ext
if ($uploaded_only && (!isset($this->ext_ids[$this->file_ext]) || !in_array($this->file_ext, $this->cfg['allowed_ext'], true))) { if ($uploaded_only && (!isset($this->ext_ids[$this->file_ext]) || !\in_array($this->file_ext, $this->cfg['allowed_ext'], true))) {
$this->errors[] = sprintf($lang['UPLOAD_ERROR_NOT_ALLOWED'], htmlCHR($this->file_ext)); $this->errors[] = sprintf($lang['UPLOAD_ERROR_NOT_ALLOWED'], htmlCHR($this->file_ext));
return false; return false;
} }
@ -137,9 +137,9 @@ class Upload
if ($mode == 'attach') { if ($mode == 'attach') {
$file_path = get_attach_path($params['topic_id']); $file_path = get_attach_path($params['topic_id']);
return $this->_move($file_path); return $this->_move($file_path);
} else {
trigger_error("Invalid upload mode: $mode", E_USER_ERROR);
} }
trigger_error("Invalid upload mode: $mode", E_USER_ERROR);
} }
/** /**
@ -148,7 +148,7 @@ class Upload
*/ */
public function _move($file_path) public function _move($file_path)
{ {
$dir = dirname($file_path); $dir = \dirname($file_path);
if (!file_exists($dir)) { if (!file_exists($dir)) {
if (!bb_mkdir($dir)) { if (!bb_mkdir($dir)) {
$this->errors[] = "Cannot create dir: $dir"; $this->errors[] = "Cannot create dir: $dir";

View file

@ -155,8 +155,8 @@ class User
$ip_check_u = substr(USER_IP, 0, 6); $ip_check_u = substr(USER_IP, 0, 6);
if ($ip_check_s == $ip_check_u) { if ($ip_check_s == $ip_check_u) {
if ($this->data['user_id'] != GUEST_UID && defined('IN_ADMIN')) { if ($this->data['user_id'] != GUEST_UID && \defined('IN_ADMIN')) {
define('SID_GET', "sid={$this->data['session_id']}"); \define('SID_GET', "sid={$this->data['session_id']}");
} }
$session_id = $this->sessiondata['sid'] = $this->data['session_id']; $session_id = $this->sessiondata['sid'] = $this->data['session_id'];
@ -194,13 +194,13 @@ class User
$this->session_create($userdata, true); $this->session_create($userdata, true);
} }
define('IS_GUEST', !$this->data['session_logged_in']); \define('IS_GUEST', !$this->data['session_logged_in']);
define('IS_ADMIN', !IS_GUEST && (int)$this->data['user_level'] === ADMIN); \define('IS_ADMIN', !IS_GUEST && (int)$this->data['user_level'] === ADMIN);
define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD); \define('IS_MOD', !IS_GUEST && (int)$this->data['user_level'] === MOD);
define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER); \define('IS_GROUP_MEMBER', !IS_GUEST && (int)$this->data['user_level'] === GROUP_MEMBER);
define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER); \define('IS_USER', !IS_GUEST && (int)$this->data['user_level'] === USER);
define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']])); \define('IS_SUPER_ADMIN', IS_ADMIN && isset($bb_cfg['super_admins'][$this->data['user_id']]));
define('IS_AM', IS_ADMIN || IS_MOD); \define('IS_AM', IS_ADMIN || IS_MOD);
$this->set_shortcuts(); $this->set_shortcuts();
@ -272,7 +272,7 @@ class User
if (!$session_time = $this->data['user_session_time']) { if (!$session_time = $this->data['user_session_time']) {
$last_visit = TIMENOW; $last_visit = TIMENOW;
define('FIRST_LOGON', true); \define('FIRST_LOGON', true);
} elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) { } elseif ($session_time < (TIMENOW - $bb_cfg['last_visit_update_intrv'])) {
$last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days'])); $last_visit = max($session_time, (TIMENOW - 86400 * $bb_cfg['max_last_visit_days']));
} }
@ -312,8 +312,8 @@ class User
$this->set_session_cookies($user_id); $this->set_session_cookies($user_id);
if ($login && (defined('IN_ADMIN') || $mod_admin_session)) { if ($login && (\defined('IN_ADMIN') || $mod_admin_session)) {
define('SID_GET', "sid=$session_id"); \define('SID_GET', "sid=$session_id");
} }
Sessions::cache_set_userdata($this->data); Sessions::cache_set_userdata($this->data);
@ -406,7 +406,9 @@ class User
Sessions::cache_update_userdata($this->data); Sessions::cache_update_userdata($this->data);
return $this->data; return $this->data;
} elseif ($new_session_userdata = $this->session_create($userdata, false)) { }
if ($new_session_userdata = $this->session_create($userdata, false)) {
// Removing guest sessions from this IP // Removing guest sessions from this IP
DB()->query(" DB()->query("
DELETE FROM " . BB_SESSIONS . " DELETE FROM " . BB_SESSIONS . "
@ -415,9 +417,9 @@ class User
"); ");
return $new_session_userdata; return $new_session_userdata;
} else {
trigger_error("Could not start session : login", E_USER_ERROR);
} }
trigger_error("Could not start session : login", E_USER_ERROR);
} }
} }
@ -556,17 +558,17 @@ class User
{ {
global $bb_cfg, $theme, $source_lang, $DeltaTime; global $bb_cfg, $theme, $source_lang, $DeltaTime;
if (defined('LANG_DIR')) { if (\defined('LANG_DIR')) {
return; return;
} // prevent multiple calling } // prevent multiple calling
define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/'); \define('DEFAULT_LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/'); \define('SOURCE_LANG_DIR', LANG_ROOT_DIR . '/source/');
if ($this->data['user_id'] != GUEST_UID) { if ($this->data['user_id'] != GUEST_UID) {
if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) { if ($this->data['user_lang'] && $this->data['user_lang'] != $bb_cfg['default_lang']) {
$bb_cfg['default_lang'] = basename($this->data['user_lang']); $bb_cfg['default_lang'] = basename($this->data['user_lang']);
define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/'); \define('LANG_DIR', LANG_ROOT_DIR . '/' . $bb_cfg['default_lang'] . '/');
} }
if (isset($this->data['user_timezone'])) { if (isset($this->data['user_timezone'])) {
@ -577,8 +579,8 @@ class User
$this->data['user_lang'] = $bb_cfg['default_lang']; $this->data['user_lang'] = $bb_cfg['default_lang'];
$this->data['user_timezone'] = $bb_cfg['board_timezone']; $this->data['user_timezone'] = $bb_cfg['board_timezone'];
if (!defined('LANG_DIR')) { if (!\defined('LANG_DIR')) {
define('LANG_DIR', DEFAULT_LANG_DIR); \define('LANG_DIR', DEFAULT_LANG_DIR);
} }
/** Temporary place source language to the global */ /** Temporary place source language to the global */
@ -590,8 +592,7 @@ class User
/** Place user language to the global */ /** Place user language to the global */
global $lang; global $lang;
require(LANG_DIR . 'main.php'); require(LANG_DIR . 'main.php');
setlocale(LC_ALL, isset($bb_cfg['lang'][$this->data['user_lang']]['locale']) ? setlocale(LC_ALL, $bb_cfg['lang'][$this->data['user_lang']]['locale'] ?? 'en_US.UTF-8');
$bb_cfg['lang'][$this->data['user_lang']]['locale'] : 'en_US.UTF-8');
$lang += $source_lang; $lang += $source_lang;
$theme = setup_style(); $theme = setup_style();
@ -648,7 +649,7 @@ class User
} elseif (!empty($_COOKIE['opt_js'])) { } elseif (!empty($_COOKIE['opt_js'])) {
$opt_js = json_decode($_COOKIE['opt_js'], true); $opt_js = json_decode($_COOKIE['opt_js'], true);
if (is_array($opt_js)) { if (\is_array($opt_js)) {
$this->opt_js = array_merge($this->opt_js, $opt_js); $this->opt_js = array_merge($this->opt_js, $opt_js);
} }
} }

View file

@ -73,6 +73,6 @@ class Apc extends Common
public function is_installed() public function is_installed()
{ {
return function_exists('apc_fetch'); return \function_exists('apc_fetch');
} }
} }

View file

@ -56,7 +56,7 @@ class Common
{ {
foreach ((array)$items as $item) { foreach ((array)$items as $item) {
// игнор уже поставленного в очередь либо уже извлеченного // игнор уже поставленного в очередь либо уже извлеченного
if (!in_array($item, $this->queued_items) && !isset($this->data[$item])) { if (!\in_array($item, $this->queued_items) && !isset($this->data[$item])) {
$this->queued_items[] = $item; $this->queued_items[] = $item;
} }
} }

View file

@ -63,7 +63,7 @@ class Sqlite extends Common
return; return;
} }
$prefix_len = strlen($this->prefix); $prefix_len = \strlen($this->prefix);
$prefix_sql = SQLite3::escapeString($this->prefix); $prefix_sql = SQLite3::escapeString($this->prefix);
array_deep($items, 'SQLite3::escapeString'); array_deep($items, 'SQLite3::escapeString');

View file

@ -70,7 +70,7 @@ class SqliteCommon extends Common
if ($type == 'none') { if ($type == 'none') {
return; return;
} }
if (is_array($name)) { if (\is_array($name)) {
trigger_error('cannot shard: $name is array', E_USER_ERROR); trigger_error('cannot shard: $name is array', E_USER_ERROR);
} }
@ -128,7 +128,7 @@ class SqliteCommon extends Common
public function fetch_row($query) public function fetch_row($query)
{ {
$result = $this->query($query); $result = $this->query($query);
return is_resource($result) ? $result->fetchArray(SQLITE3_ASSOC) : false; return \is_resource($result) ? $result->fetchArray(SQLITE3_ASSOC) : false;
} }
public function fetch_rowset($query) public function fetch_rowset($query)
@ -143,7 +143,7 @@ class SqliteCommon extends Common
public function changes() public function changes()
{ {
return is_resource($this->dbh) ? $this->dbh->changes() : 0; return \is_resource($this->dbh) ? $this->dbh->changes() : 0;
} }
public function escape($str) public function escape($str)
@ -153,7 +153,7 @@ class SqliteCommon extends Common
public function get_error_msg() public function get_error_msg()
{ {
return 'SQLite error #' . ($err_code = $this->dbh->lastErrorCode()) . ': ' . $this->dbh->lastErrorMsg(); return 'SQLite error #' . $this->dbh->lastErrorCode() . ': ' . $this->dbh->lastErrorMsg();
} }
public function rm($name = '') public function rm($name = '')

View file

@ -74,6 +74,6 @@ class Xcache extends Common
public function is_installed() public function is_installed()
{ {
return function_exists('xcache_get'); return \function_exists('xcache_get');
} }
} }

View file

@ -51,7 +51,7 @@ class Dbs
{ {
$srv_name = $this->get_srv_name($srv_name_or_alias); $srv_name = $this->get_srv_name($srv_name_or_alias);
if (!is_object($this->srv[$srv_name])) { if (!\is_object($this->srv[$srv_name])) {
$this->srv[$srv_name] = new SqlDb($this->cfg[$srv_name]); $this->srv[$srv_name] = new SqlDb($this->cfg[$srv_name]);
$this->srv[$srv_name]->db_server = $srv_name; $this->srv[$srv_name]->db_server = $srv_name;
} }

View file

@ -24,7 +24,7 @@ class Group
{ {
global $datastore; global $datastore;
if (is_array($user_id)) { if (\is_array($user_id)) {
$user_id = implode(',', $user_id); $user_id = implode(',', $user_id);
} }
$user_groups_in = ($user_id !== 'all') ? "AND ug.user_id IN($user_id)" : ''; $user_groups_in = ($user_id !== 'all') ? "AND ug.user_id IN($user_id)" : '';
@ -219,7 +219,7 @@ class Group
*/ */
public static function store_permissions($group_id, $auth_ary) public static function store_permissions($group_id, $auth_ary)
{ {
if (empty($auth_ary) || !is_array($auth_ary)) { if (empty($auth_ary) || !\is_array($auth_ary)) {
return; return;
} }
@ -244,7 +244,7 @@ class Group
*/ */
private static function update_user_permissions($user_id = 'all') private static function update_user_permissions($user_id = 'all')
{ {
if (is_array($user_id)) { if (\is_array($user_id)) {
$user_id = implode(',', $user_id); $user_id = implode(',', $user_id);
} }
$delete_in = ($user_id !== 'all') ? " WHERE user_id IN($user_id)" : ''; $delete_in = ($user_id !== 'all') ? " WHERE user_id IN($user_id)" : '';

View file

@ -70,7 +70,7 @@ class LogAction
} }
$sql_ary = [ $sql_ary = [
'log_type_id' => (int)$this->log_type["$type_name"], 'log_type_id' => (int)$this->log_type[(string)$type_name],
'log_user_id' => (int)$user_id, 'log_user_id' => (int)$user_id,
'log_user_ip' => (string)$session_ip, 'log_user_ip' => (string)$session_ip,
'log_forum_id' => (int)$forum_id, 'log_forum_id' => (int)$forum_id,

View file

@ -51,7 +51,7 @@ class Poll
} }
// проверять на "< 3" -- 2 варианта ответа + заголовок // проверять на "< 3" -- 2 варианта ответа + заголовок
if (count($this->poll_votes) < 3 || count($this->poll_votes) > $this->max_votes + 1) { if (\count($this->poll_votes) < 3 || \count($this->poll_votes) > $this->max_votes + 1) {
global $lang; global $lang;
return $this->err_msg = sprintf($lang['NEW_POLL_VOTES'], $this->max_votes); return $this->err_msg = sprintf($lang['NEW_POLL_VOTES'], $this->max_votes);
} }

View file

@ -368,7 +368,7 @@ class Post
$orig_word = $replacement_word = array(); $orig_word = $replacement_word = array();
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);
} }
@ -376,8 +376,8 @@ class Post
$unwatch_topic = make_url(TOPIC_URL . "$topic_id&unwatch=topic"); $unwatch_topic = make_url(TOPIC_URL . "$topic_id&unwatch=topic");
foreach ($watch_list as $row) { foreach ($watch_list as $row) {
/** @var TorrentPier\Legacy\Emailer() $emailer */ /** @var Emailer $emailer */
$emailer = new TorrentPier\Legacy\Emailer(); $emailer = new Emailer;
$emailer->set_from([$bb_cfg['board_email'] => $bb_cfg['sitename']]); $emailer->set_from([$bb_cfg['board_email'] => $bb_cfg['sitename']]);
$emailer->set_to([$row['user_email'] => $row['username']]); $emailer->set_to([$row['user_email'] => $row['username']]);
@ -442,9 +442,9 @@ class Post
return; return;
} }
$post_username = $post_subject = $post_text = $poster_ip = ''; $post_username = $post_text = $poster_ip = '';
$post_time = $current_time = TIMENOW; $post_time = TIMENOW;
if ($mode == 'after_move') { if ($mode == 'after_move') {
if (!$forum_id || !$old_forum_id) { if (!$forum_id || !$old_forum_id) {

View file

@ -22,7 +22,7 @@ class Sessions
*/ */
private static function ignore_cached_userdata() private static function ignore_cached_userdata()
{ {
return defined('IN_PM') ? true : false; return \defined('IN_PM') ? true : false;
} }
/** /**

View file

@ -190,7 +190,7 @@ class Sitemap
{ {
$file = $url . urlencode($map); $file = $url . urlencode($map);
if (function_exists('curl_init')) { if (\function_exists('curl_init')) {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file); curl_setopt($ch, CURLOPT_URL, $file);

View file

@ -127,7 +127,7 @@ class SqlDb
if (!$this->link) { if (!$this->link) {
$this->init(); $this->init();
} }
if (is_array($query)) { if (\is_array($query)) {
$query = $this->build_sql($query); $query = $this->build_sql($query);
} }
if (SQL_PREPEND_SRC_COMM) { if (SQL_PREPEND_SRC_COMM) {
@ -258,7 +258,7 @@ class SqlDb
$row = mysqli_fetch_assoc($result); $row = mysqli_fetch_assoc($result);
if ($field_name) { if ($field_name) {
return isset($row[$field_name]) ? $row[$field_name] : false; return $row[$field_name] ?? false;
} }
return $row; return $row;
@ -389,13 +389,13 @@ class SqlDb
} }
switch (true) { switch (true) {
case is_string($v): case \is_string($v):
return "'" . $this->escape_string($v) . "'"; return "'" . $this->escape_string($v) . "'";
case is_int($v): case \is_int($v):
return "$v"; return (string)$v;
case is_bool($v): case \is_bool($v):
return ($v) ? '1' : '0'; return ($v) ? '1' : '0';
case is_float($v): case \is_float($v):
return "'$v'"; return "'$v'";
case null === $v: case null === $v:
return 'NULL'; return 'NULL';
@ -437,7 +437,7 @@ class SqlDb
$dont_escape = $data_already_escaped; $dont_escape = $data_already_escaped;
$check_type = $check_data_type_in_escape; $check_type = $check_data_type_in_escape;
if (empty($input_ary) || !is_array($input_ary)) { if (empty($input_ary) || !\is_array($input_ary)) {
$this->trigger_error(__FUNCTION__ . ' - wrong params: $input_ary'); $this->trigger_error(__FUNCTION__ . ' - wrong params: $input_ary');
} }
@ -733,7 +733,7 @@ class SqlDb
} }
if ($this->link and $ext = mysqli_info($this->link)) { if ($this->link and $ext = mysqli_info($this->link)) {
$info[] = "$ext"; $info[] = (string)$ext;
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) { } elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
$info[] = "$aff rows"; $info[] = "$aff rows";
} }
@ -767,8 +767,8 @@ class SqlDb
} }
} }
if (!defined('IN_FIRST_SLOW_QUERY')) { if (!\defined('IN_FIRST_SLOW_QUERY')) {
define('IN_FIRST_SLOW_QUERY', true); \define('IN_FIRST_SLOW_QUERY', true);
} }
CACHE('bb_cache')->set('dont_log_slow_query', $new_priority, $ignoring_time); CACHE('bb_cache')->set('dont_log_slow_query', $new_priority, $ignoring_time);
@ -898,7 +898,7 @@ class SqlDb
$msg = implode(LOG_SEPR, $msg); $msg = implode(LOG_SEPR, $msg);
$msg .= ($info = $this->query_info()) ? ' # ' . $info : ''; $msg .= ($info = $this->query_info()) ? ' # ' . $info : '';
$msg .= ' # ' . $this->debug_find_source() . ' '; $msg .= ' # ' . $this->debug_find_source() . ' ';
$msg .= defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']); $msg .= \defined('IN_CRON') ? 'cron' : basename($_SERVER['REQUEST_URI']);
bb_log($msg . LOG_LF, $log_file); bb_log($msg . LOG_LF, $log_file);
} }
@ -909,7 +909,7 @@ class SqlDb
*/ */
public function log_slow_query($log_file = 'sql_slow_bb') public function log_slow_query($log_file = 'sql_slow_bb')
{ {
if (!defined('IN_FIRST_SLOW_QUERY') && CACHE('bb_cache')->get('dont_log_slow_query')) { if (!\defined('IN_FIRST_SLOW_QUERY') && CACHE('bb_cache')->get('dont_log_slow_query')) {
return; return;
} }
$this->log_query($log_file); $this->log_query($log_file);
@ -968,7 +968,7 @@ class SqlDb
$query = "SELECT * FROM $m[1] WHERE $m[2]"; $query = "SELECT * FROM $m[1] WHERE $m[2]";
} }
if (preg_match('#^SELECT#', $query)) { if (0 === strpos($query, "SELECT")) {
$html_table = false; $html_table = false;
if ($result = mysqli_query($this->link, "EXPLAIN $query")) { if ($result = mysqli_query($this->link, "EXPLAIN $query")) {

View file

@ -308,12 +308,12 @@ class Template
if (false !== strpos($blockname, '.')) { if (false !== strpos($blockname, '.')) {
// Nested block. // Nested block.
$blocks = explode('.', $blockname); $blocks = explode('.', $blockname);
$blockcount = count($blocks) - 1; $blockcount = \count($blocks) - 1;
$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[\count($str) - 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
@ -405,7 +405,7 @@ class Template
public function generate_block_varref($namespace, $varname) public function generate_block_varref($namespace, $varname)
{ {
// Strip the trailing period. // Strip the trailing period.
$namespace = substr($namespace, 0, strlen($namespace) - 1); $namespace = substr($namespace, 0, -1);
// Get a reference to the data block for this namespace. // Get a reference to the data block for this namespace.
$varref = $this->generate_block_data_ref($namespace, true); $varref = $this->generate_block_data_ref($namespace, true);
@ -436,7 +436,7 @@ class Template
{ {
// Get an array of the blocks involved. // Get an array of the blocks involved.
$blocks = explode('.', $blockname); $blocks = explode('.', $blockname);
$blockcount = count($blocks) - 1; $blockcount = \count($blocks) - 1;
if ($include_last_iterator) { if ($include_last_iterator) {
return '$' . $blocks[$blockcount] . '_item'; return '$' . $blocks[$blockcount] . '_item';
} }
@ -461,7 +461,7 @@ class Template
// Break it up into lines and put " -->" back. // Break it up into lines and put " -->" back.
$code_lines = explode(' -->', $code); $code_lines = explode(' -->', $code);
$count = count($code_lines); $count = \count($code_lines);
for ($i = 0; $i < ($count - 1); $i++) { for ($i = 0; $i < ($count - 1); $i++) {
$code_lines[$i] .= ' -->'; $code_lines[$i] .= ' -->';
} }
@ -480,7 +480,7 @@ class Template
// replace all short php tags // replace all short php tags
$new_code = array(); $new_code = array();
$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];
$pos = strpos($line, '<?'); $pos = strpos($line, '<?');
@ -503,7 +503,7 @@ class Template
$code_lines = $new_code; $code_lines = $new_code;
// main loop // main loop
$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];
// reset keyword type // reset keyword type
@ -565,7 +565,7 @@ class Template
*/ */
if ($keyword_type == XS_TAG_BEGIN) { if ($keyword_type == XS_TAG_BEGIN) {
$params = explode(' ', $params_str); $params = explode(' ', $params_str);
$num_params = count($params); $num_params = \count($params);
// get variable name // get variable name
if ($num_params == 1) { if ($num_params == 1) {
$var = $params[0]; $var = $params[0];
@ -629,7 +629,7 @@ class Template
*/ */
if ($keyword_type == XS_TAG_END) { if ($keyword_type == XS_TAG_END) {
$params = explode(' ', $params_str); $params = explode(' ', $params_str);
$num_params = count($params); $num_params = \count($params);
if ($num_params == 1) { if ($num_params == 1) {
$var = $params[0]; $var = $params[0];
} elseif ($num_params == 2 && $params[0] === '') { } elseif ($num_params == 2 && $params[0] === '') {
@ -672,7 +672,7 @@ class Template
*/ */
if ($keyword_type == XS_TAG_INCLUDE) { if ($keyword_type == XS_TAG_INCLUDE) {
$params = explode(' ', $params_str); $params = explode(' ', $params_str);
$num_params = count($params); $num_params = \count($params);
if ($num_params != 1) { if ($num_params != 1) {
$compiled[] = $keyword_str; $compiled[] = $keyword_str;
continue; continue;
@ -737,14 +737,14 @@ class Template
*/ */
public function _compile_text($code) public function _compile_text($code)
{ {
if (strlen($code) < 3) { if (\strlen($code) < 3) {
return $code; return $code;
} }
// 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 = array();
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 = \count($varrefs[1]);
$search = array(); $search = array();
$replace = array(); $replace = array();
for ($i = 0; $i < $varcount; $i++) { for ($i = 0; $i < $varcount; $i++) {
@ -754,7 +754,7 @@ class Template
$search[] = $varrefs[0][$i]; $search[] = $varrefs[0][$i];
$replace[] = $new; $replace[] = $new;
} }
if (count($search) > 0) { if (\count($search) > 0) {
$code = str_replace($search, $replace, $code); $code = str_replace($search, $replace, $code);
} }
// This will handle the remaining root-level varrefs // This will handle the remaining root-level varrefs
@ -782,7 +782,7 @@ class Template
[^\s(),]+)/x', $tag_args, $match); [^\s(),]+)/x', $tag_args, $match);
$tokens = $match[0]; $tokens = $match[0];
$tokens_cnt = count($tokens); $tokens_cnt = \count($tokens);
$is_arg_stack = array(); $is_arg_stack = array();
for ($i = 0; $i < $tokens_cnt; $i++) { for ($i = 0; $i < $tokens_cnt; $i++) {
@ -838,11 +838,11 @@ class Template
case 'is': case 'is':
$is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
$is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); $is_arg = implode(' ', \array_slice($tokens, $is_arg_start, $i - $is_arg_start));
$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, \count($tokens), $new_tokens);
$i = $is_arg_start; $i = $is_arg_start;
break; break;
@ -864,9 +864,9 @@ class Template
} elseif (!empty($m[4])) { } elseif (!empty($m[4])) {
$token = ($tokens_cnt == 1) ? "!empty(\$V['{$m[4]}'])" : "\$V['{$m[4]}']"; $token = ($tokens_cnt == 1) ? "!empty(\$V['{$m[4]}'])" : "\$V['{$m[4]}']";
} elseif (!empty($m[5])) { } elseif (!empty($m[5])) {
$token = ($tokens_cnt == 1) ? "!empty({$m[5]})" : "{$m[5]}"; $token = ($tokens_cnt == 1) ? "!empty({$m[5]})" : (string)($m[5]);
} elseif (!empty($m[7])) { } elseif (!empty($m[7])) {
$token = ($tokens_cnt == 1) ? "defined('{$m[7]}') && {$m[7]}" : "{$m[7]}"; $token = ($tokens_cnt == 1) ? "defined('{$m[7]}') && {$m[7]}" : (string)($m[7]);
} }
} }
break; break;
@ -983,13 +983,13 @@ class Template
// adding language variable (eg: "english" or "german") // adding language variable (eg: "english" or "german")
// can be used to make truly multi-lingual templates // can be used to make truly multi-lingual templates
$this->vars['LANG'] = isset($this->vars['LANG']) ? $this->vars['LANG'] : $bb_cfg['default_lang']; $this->vars['LANG'] = $this->vars['LANG'] ?? $bb_cfg['default_lang'];
// adding current template // adding current template
$tpl = $this->root . '/'; $tpl = $this->root . '/';
if (substr($tpl, 0, 2) === './') { if (0 === strpos($tpl, './')) {
$tpl = substr($tpl, 2, strlen($tpl)); $tpl = substr($tpl, 2, \strlen($tpl));
} }
$this->vars['TEMPLATE'] = isset($this->vars['TEMPLATE']) ? $this->vars['TEMPLATE'] : $tpl; $this->vars['TEMPLATE'] = $this->vars['TEMPLATE'] ?? $tpl;
$this->vars['TEMPLATE_NAME'] = isset($this->vars['TEMPLATE_NAME']) ? $this->vars['TEMPLATE_NAME'] : $this->tpl; $this->vars['TEMPLATE_NAME'] = $this->vars['TEMPLATE_NAME'] ?? $this->tpl;
} }
} }

View file

@ -332,7 +332,7 @@ class Torrent
$ann = (@$tor['announce']) ? $tor['announce'] : ''; $ann = (@$tor['announce']) ? $tor['announce'] : '';
$announce_urls['main_url'] = $bb_cfg['bt_announce_url']; $announce_urls['main_url'] = $bb_cfg['bt_announce_url'];
if (!$ann || !in_array($ann, $announce_urls)) { if (!$ann || !\in_array($ann, $announce_urls)) {
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']); $msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
return self::torrent_error_exit($msg); return self::torrent_error_exit($msg);
} }
@ -340,7 +340,7 @@ class Torrent
$info = (@$tor['info']) ? $tor['info'] : array(); $info = (@$tor['info']) ? $tor['info'] : array();
if (!isset($info['name']) || !isset($info['piece length']) || !isset($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']);
} }
@ -363,7 +363,7 @@ class Torrent
if (isset($info['length'])) { if (isset($info['length'])) {
$totallen = (float)$info['length']; $totallen = (float)$info['length'];
} elseif (isset($info['files']) && is_array($info['files'])) { } elseif (isset($info['files']) && \is_array($info['files'])) {
foreach ($info['files'] as $fn => $f) { foreach ($info['files'] as $fn => $f) {
$totallen += (float)$f['length']; $totallen += (float)$f['length'];
} }
@ -550,7 +550,7 @@ class Torrent
if (!empty($_COOKIE['explain'])) { if (!empty($_COOKIE['explain'])) {
$out = "attach path: $filename<br /><br />"; $out = "attach path: $filename<br /><br />";
$tor['info']['pieces'] = '[...] ' . strlen($tor['info']['pieces']) . ' bytes'; $tor['info']['pieces'] = '[...] ' . \strlen($tor['info']['pieces']) . ' bytes';
$out .= print_r($tor, true); $out .= print_r($tor, true);
bb_die("<pre>$out</pre>"); bb_die("<pre>$out</pre>");
} }

View file

@ -62,7 +62,7 @@ class TorrentFileList
$info['name'] =& $info['name.utf-8']; $info['name'] =& $info['name.utf-8'];
} }
if (isset($info['files']) && is_array($info['files'])) { if (isset($info['files']) && \is_array($info['files'])) {
$this->root_dir = isset($info['name']) ? '../' . clean_tor_dirname($info['name']) : '...'; $this->root_dir = isset($info['name']) ? '../' . clean_tor_dirname($info['name']) : '...';
$this->multiple = true; $this->multiple = true;
@ -70,13 +70,13 @@ class TorrentFileList
if (isset($f['path.utf-8'])) { if (isset($f['path.utf-8'])) {
$f['path'] =& $f['path.utf-8']; $f['path'] =& $f['path.utf-8'];
} }
if (!isset($f['path']) || !is_array($f['path'])) { if (!isset($f['path']) || !\is_array($f['path'])) {
continue; continue;
} }
array_deep($f['path'], 'clean_tor_dirname'); array_deep($f['path'], 'clean_tor_dirname');
$length = isset($f['length']) ? (float)$f['length'] : 0; $length = isset($f['length']) ? (float)$f['length'] : 0;
$subdir_count = count($f['path']) - 1; $subdir_count = \count($f['path']) - 1;
if ($subdir_count > 0) { if ($subdir_count > 0) {
$name = array_pop($f['path']); $name = array_pop($f['path']);
@ -91,7 +91,7 @@ class TorrentFileList
$cur_files_ary =& $cur_files_ary[$subdir]; $cur_files_ary =& $cur_files_ary[$subdir];
if ($j === $subdir_count) { if ($j === $subdir_count) {
if (is_string($cur_files_ary)) { if (\is_string($cur_files_ary)) {
$GLOBALS['bnc_error'] = 1; $GLOBALS['bnc_error'] = 1;
break; break;
} }

View file

@ -93,7 +93,7 @@ class Validate
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) { if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
return $lang['EMAIL_INVALID']; return $lang['EMAIL_INVALID'];
} }
if (strlen($email) > USEREMAIL_MAX_LENGTH) { if (\strlen($email) > USEREMAIL_MAX_LENGTH) {
return $lang['EMAIL_TOO_LONG']; return $lang['EMAIL_TOO_LONG'];
} }

View file

@ -46,7 +46,7 @@ class WordsRate
$this->del_text_hl = $text; $this->del_text_hl = $text;
// длинное сообщение // длинное сообщение
if (strlen($text) > 600) { if (\strlen($text) > 600) {
return $this->words_rate; return $this->words_rate;
} }
// вырезаем цитаты если содержит +1 // вырезаем цитаты если содержит +1

View file

@ -10,7 +10,7 @@
global $bb_cfg, $page_cfg, $template, $images, $lang; global $bb_cfg, $page_cfg, $template, $images, $lang;
$width = $height = array(); $width = $height = array();
$template_name = basename(dirname(__FILE__)); $template_name = basename(__DIR__);
$_img = BB_ROOT . 'styles/images/'; $_img = BB_ROOT . 'styles/images/';
$_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/'; $_main = BB_ROOT . 'styles/' . basename(TEMPLATES_DIR) . '/' . $template_name . '/images/';

View file

@ -690,8 +690,8 @@ if ($allowed_forums) {
$passkey = DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$user_id . " LIMIT 1"); $passkey = DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$user_id . " LIMIT 1");
// Build torrents table // Build torrents table
foreach (DB()->fetch_rowset($sql) as $tor) { foreach (DB()->fetch_rowset($sql) as $tor) {
$dl = isset($tor['speed_down']) ? $tor['speed_down'] : 0; $dl = $tor['speed_down'] ?? 0;
$ul = isset($tor['speed_up']) ? $tor['speed_up'] : 0; $ul = $tor['speed_up'] ?? 0;
$seeds = $tor['seeders']; $seeds = $tor['seeders'];
$leechs = $tor['leechers']; $leechs = $tor['leechers'];

View file

@ -82,7 +82,7 @@ $mod_redirect_url = '';
$tor_status = -1; // all by default $tor_status = -1; // all by default
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : $_SERVER['REQUEST_URI']; $redirect = $_POST['redirect'] ?? $_SERVER['REQUEST_URI'];
$redirect = url_arg($redirect, 'mod', 1, '&'); $redirect = url_arg($redirect, 'mod', 1, '&');
$mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1"; $mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1";
@ -456,7 +456,7 @@ foreach ($topic_rowset as $topic) {
'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '', 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '',
'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '',
'ATTACH' => isset($topic['topic_attachment']) ? $topic['topic_attachment'] : false, 'ATTACH' => $topic['topic_attachment'] ?? false,
'STATUS' => $topic['topic_status'], 'STATUS' => $topic['topic_status'],
'TYPE' => $topic['topic_type'], 'TYPE' => $topic['topic_type'],
'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker']), 'DL' => ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker']),

View file

@ -182,7 +182,7 @@ $moderation = (!empty($_REQUEST['mod']) && $is_auth['auth_mod']);
$mod_redirect_url = ''; $mod_redirect_url = '';
if ($is_auth['auth_mod']) { if ($is_auth['auth_mod']) {
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : @$_SERVER['REQUEST_URI']; $redirect = $_POST['redirect'] ?? @$_SERVER['REQUEST_URI'];
$redirect = url_arg($redirect, 'mod', 1, '&'); $redirect = url_arg($redirect, 'mod', 1, '&');
$mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1"; $mod_redirect_url = LOGIN_URL . "?redirect=$redirect&admin=1";
@ -798,7 +798,7 @@ foreach ($is_auth as $name => $is) {
} }
$template->assign_vars(array( $template->assign_vars(array(
'PG_ROW_CLASS' => isset($pg_row_class) ? $pg_row_class : 'row1', 'PG_ROW_CLASS' => $pg_row_class ?? 'row1',
)); ));
if (IS_ADMIN) { if (IS_ADMIN) {