From 933e4b3283f0416ca3f2ec4358d629a6b7f678b2 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Wed, 4 Oct 2023 23:26:47 +0700 Subject: [PATCH] Minor improvements (#297) * Minor improvements * Update CHANGELOG.md * Update config.php * Update admin_ug_auth.php * Updated * Update admin_disallow.php * Update admin_ranks.php * Update admin_smilies.php * Update scrape.php * Update scrape.php * Update view_torrent.php --- CHANGELOG.md | 8 ++++++++ admin/admin_attach_cp.php | 2 +- admin/admin_disallow.php | 4 ++-- admin/admin_ranks.php | 12 ++++++------ admin/admin_smilies.php | 6 +++--- admin/admin_ug_auth.php | 14 ++++++++++++-- admin/index.php | 2 +- bt/scrape.php | 12 ++++-------- common.php | 5 ++++- library/ajax/manage_admin.php | 9 ++++++--- library/ajax/manage_user.php | 2 +- library/ajax/mod_action.php | 5 ++++- library/ajax/sitemap.php | 7 +++++-- library/ajax/user_register.php | 7 +++++-- library/ajax/view_torrent.php | 2 +- library/config.php | 16 ++++++++-------- library/includes/core/mysql.php | 6 ++++-- library/includes/cron/cron_init.php | 5 ++++- library/includes/init_bb.php | 2 -- 19 files changed, 79 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dfe7f64..d4d2c2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 📖 Change Log +## [v2.1.5-2023.10](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.10) (2023-11-04) +[Full Changelog](https://github.com/torrentpier/torrentpier-lts/compare/v2.1.5-2023.09...v2.1.5-2023.10) + +**Merged pull requests:** + +- Release v2.1.5-2023.10 🎉 +- Minor improvements [\#297](https://github.com/torrentpier/torrentpier-lts/pull/297) ([belomaxorka](https://github.com/belomaxorka)) + ## [v2.1.5-2023.09](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.09) (2023-10-04) [Full Changelog](https://github.com/torrentpier/torrentpier-lts/compare/v2.1.5-2023.08-HotFix...v2.1.5-2023.09) diff --git a/admin/admin_attach_cp.php b/admin/admin_attach_cp.php index 5acce941..46db6c71 100644 --- a/admin/admin_attach_cp.php +++ b/admin/admin_attach_cp.php @@ -302,7 +302,7 @@ if ($view == 'search') } $s_forums = ''; - $list_cat = []; + $list_cat = array(); while ($row = DB()->sql_fetchrow($result)) { //sf $s_forums .= ''; diff --git a/admin/admin_disallow.php b/admin/admin_disallow.php index d10f4b40..54720397 100644 --- a/admin/admin_disallow.php +++ b/admin/admin_disallow.php @@ -17,7 +17,7 @@ if (isset($_POST['add_name'])) if ($disallowed_user == '') { - bb_die($lang['FIELDS_EMPTY']); + bb_die($lang['FIELDS_EMPTY'] . '

'. sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '', '') . '

'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } if( validate_username($disallowed_user) ) { @@ -94,4 +94,4 @@ $template->assign_vars(array( 'S_FORM_ACTION' => 'admin_disallow.php', )); -print_page('admin_disallow.tpl', 'admin'); \ No newline at end of file +print_page('admin_disallow.tpl', 'admin'); diff --git a/admin/admin_ranks.php b/admin/admin_ranks.php index 641ea54e..00227fb6 100644 --- a/admin/admin_ranks.php +++ b/admin/admin_ranks.php @@ -48,7 +48,7 @@ if ($mode != '') { if (empty($rank_id)) { - bb_die($lang['MUST_SELECT_RANK']); + bb_die($lang['MUST_SELECT_RANK'] . '

' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } $sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_id = $rank_id"; @@ -100,7 +100,7 @@ if ($mode != '') if ($rank_title == '') { - bb_die($lang['MUST_SELECT_RANK']); + bb_die($lang['MUST_SELECT_RANK'] . '

' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } if ($special_rank == 1) @@ -127,7 +127,7 @@ if ($mode != '') $sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id"; if (!$result = DB()->sql_query($sql)) { - bb_die($lang['NO_UPDATE_RANKS']); + bb_die($lang['NO_UPDATE_RANKS'] . '

' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } } $sql = "UPDATE " . BB_RANKS . " @@ -186,7 +186,7 @@ if ($mode != '') $sql = "UPDATE " . BB_USERS . " SET user_rank = 0 WHERE user_rank = $rank_id"; if (!$result = DB()->sql_query($sql)) { - bb_die($lang['NO_UPDATE_RANKS']); + bb_die($lang['NO_UPDATE_RANKS'] . '

' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } $datastore->update('ranks'); @@ -195,7 +195,7 @@ if ($mode != '') } else { - bb_die($lang['MUST_SELECT_RANK']); + bb_die($lang['MUST_SELECT_RANK'] . '

' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } } else @@ -251,4 +251,4 @@ else } } -print_page('admin_ranks.tpl', 'admin'); \ No newline at end of file +print_page('admin_ranks.tpl', 'admin'); diff --git a/admin/admin_smilies.php b/admin/admin_smilies.php index a1f013b7..893163a9 100644 --- a/admin/admin_smilies.php +++ b/admin/admin_smilies.php @@ -20,7 +20,7 @@ else $delimeter = '=+:'; $s_hidden_fields = ''; -$smiley_paks = []; +$smiley_paks = array(); // Read a listing of uploaded smilies for use in the add or edit smliey code $dir = @opendir(BB_ROOT . $bb_cfg['smilies_path']); @@ -277,7 +277,7 @@ else if ( $mode != '' ) // If no code was entered complain if ($smile_code == '' || $smile_url == '') { - bb_die($lang['FIELDS_EMPTY']); + bb_die($lang['FIELDS_EMPTY'] . '

' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } // Convert < and > to proper htmlentities for parsing @@ -309,7 +309,7 @@ else if ( $mode != '' ) // If no code was entered complain if ($smile_code == '' || $smile_url == '') { - bb_die($lang['FIELDS_EMPTY']); + bb_die($lang['FIELDS_EMPTY'] . '

' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '', '') . '

' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', '')); } // Convert < and > to proper htmlentities for parsing diff --git a/admin/admin_ug_auth.php b/admin/admin_ug_auth.php index 0a048014..ceb1e422 100644 --- a/admin/admin_ug_auth.php +++ b/admin/admin_ug_auth.php @@ -75,7 +75,12 @@ if ($submit && $mode == 'user') { if ($userdata['user_id'] == $user_id || $user_id == GUEST_UID || $user_id == BOT_UID) { - bb_die($lang['AUTH_GENERAL_ERROR']); + $message = $lang['AUTH_GENERAL_ERROR'] .'

'; + $message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '', '') .'

'; + $message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''); + + bb_die($message); + unset($message); } DB()->query("UPDATE ". BB_USERS ." SET user_level = ". ADMIN ." WHERE user_id = $user_id LIMIT 1"); @@ -95,7 +100,12 @@ if ($submit && $mode == 'user') // ignore if you're trying to change yourself from an admin to user! if ($userdata['user_id'] == $user_id) { - bb_die($lang['AUTH_SELF_ERROR']); + $message = $lang['AUTH_SELF_ERROR'] .'

'; + $message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '', '') .'

'; + $message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '', ''); + + bb_die($message); + unset($message); } // Update users level, reset to USER DB()->query("UPDATE ". BB_USERS ." SET user_level = ". USER ." WHERE user_id = $user_id LIMIT 1"); diff --git a/admin/index.php b/admin/index.php index 43cc23aa..4c935cde 100644 --- a/admin/index.php +++ b/admin/index.php @@ -5,7 +5,7 @@ require('./pagestart.php'); // Generate relevant output if (isset($_GET['pane']) && $_GET['pane'] == 'left') { - $module = []; + $module = array(); if (!$module = CACHE('bb_cache')->get('admin_module_' . $user->id)) { $dir = @opendir('.'); diff --git a/bt/scrape.php b/bt/scrape.php index 800ba482..6d434178 100644 --- a/bt/scrape.php +++ b/bt/scrape.php @@ -12,11 +12,7 @@ if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) $_GET['info_hash'] = $_GET['?info_hash']; } -if (!isset($_GET['info_hash'])) -{ - msg_die('info_hash was not provided'); -} -if (strlen($_GET['info_hash']) != 20) +if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20) { msg_die('Invalid info_hash: ' . bin2hex($_GET['info_hash'])); } @@ -50,9 +46,9 @@ $row = DB()->fetch_row(" "); $output['files'][$info_hash] = array( - 'complete' => (int) $row['seeders'], - 'downloaded' => (int) $row['complete_count'], - 'incomplete' => (int) $row['leechers'], + 'complete' => (int) $row['seeders'], + 'downloaded' => (int) $row['complete_count'], + 'incomplete' => (int) $row['leechers'], ); echo bencode($output); diff --git a/common.php b/common.php index 9ec04066..822b320a 100644 --- a/common.php +++ b/common.php @@ -1,5 +1,6 @@ = 50303)) die('TorrentPier II requires PHP version 5.3.3+. Your PHP version '. PHP_VERSION); if (isset($_REQUEST['GLOBALS'])) die(); ignore_user_abort(true); @@ -30,11 +31,13 @@ if (file_exists(BB_ROOT . 'library/config.local.php')) { require(BB_ROOT . 'library/config.local.php'); } -elseif (file_exists(BB_ROOT . 'library/config.php')) +else { require(BB_ROOT . 'library/config.php'); } +if (!defined('BB_CFG_LOADED')) trigger_error('Configuration file could not be loaded', E_USER_ERROR); + // Get mods config if (file_exists(BB_ROOT . 'library/config.mods.php')) { diff --git a/library/ajax/manage_admin.php b/library/ajax/manage_admin.php index 7d71217d..c270e5a1 100644 --- a/library/ajax/manage_admin.php +++ b/library/ajax/manage_admin.php @@ -4,7 +4,10 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $userdata, $lang, $bb_cfg; -$mode = (string) $this->request['mode']; +if (!$mode = (string) $this->request['mode']) +{ + $this->ajax_die('invalid mode (empty)'); +} switch ($mode) { @@ -59,7 +62,7 @@ switch ($mode) if (!is_file($bb_cfg['sphinx_config_path'].".log")) { - file_put_contents($bb_cfg['sphinx_config_path'].".log", "##############################".date("H:i:s", TIMENOW)."##############################\r\n\r\n\r\n\r\n", FILE_APPEND); + file_put_contents($bb_cfg['sphinx_config_path'].".log", "####Logger from dimka3210.####".date("H:i:s", TIMENOW)."##############################\r\n\r\n\r\n\r\n", FILE_APPEND); } file_put_contents($bb_cfg['sphinx_config_path'].".log", "##############################".date("H:i:s", TIMENOW)."##############################\r\n", FILE_APPEND); @@ -116,4 +119,4 @@ switch ($mode) $this->ajax_die('Invalid mode'); } -$this->response['mode'] = $mode; \ No newline at end of file +$this->response['mode'] = $mode; diff --git a/library/ajax/manage_user.php b/library/ajax/manage_user.php index 43ef2966..775ba8e8 100644 --- a/library/ajax/manage_user.php +++ b/library/ajax/manage_user.php @@ -4,7 +4,7 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $userdata, $lang, $bb_cfg; -if (!$user_id = $this->request['user_id']) +if (!$user_id = intval($this->request['user_id'])) { $this->ajax_die($lang['NO_USER_ID_SPECIFIED']); } diff --git a/library/ajax/mod_action.php b/library/ajax/mod_action.php index 713b99a1..859363ee 100644 --- a/library/ajax/mod_action.php +++ b/library/ajax/mod_action.php @@ -4,7 +4,10 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $userdata, $bb_cfg, $lang, $datastore, $log_action; -$mode = (string) $this->request['mode']; +if (!$mode = (string) $this->request['mode']) +{ + $this->ajax_die('invalid mode (empty)'); +} switch ($mode) { diff --git a/library/ajax/sitemap.php b/library/ajax/sitemap.php index a6705949..0c1db0ed 100644 --- a/library/ajax/sitemap.php +++ b/library/ajax/sitemap.php @@ -4,7 +4,10 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $bb_cfg, $lang; -$mode = (string) $this->request['mode']; +if (!$mode = (string) $this->request['mode']) +{ + $this->ajax_die('invalid mode (empty)'); +} $map = new sitemap(); $html = ''; @@ -43,4 +46,4 @@ switch ($mode) } $this->response['html'] = $html; -$this->response['mode'] = $mode; \ No newline at end of file +$this->response['mode'] = $mode; diff --git a/library/ajax/user_register.php b/library/ajax/user_register.php index 61860a6a..464901a9 100644 --- a/library/ajax/user_register.php +++ b/library/ajax/user_register.php @@ -4,7 +4,10 @@ if (!defined('IN_AJAX')) die(basename(__FILE__)); global $bb_cfg, $lang, $userdata; -$mode = (string) $this->request['mode']; +if (!$mode = (string) $this->request['mode']) +{ + $this->ajax_die('invalid mode (empty)'); +} $html = ''; switch($mode) @@ -72,4 +75,4 @@ switch($mode) } $this->response['html'] = $html; -$this->response['mode'] = $mode; \ No newline at end of file +$this->response['mode'] = $mode; diff --git a/library/ajax/view_torrent.php b/library/ajax/view_torrent.php index a9adf48e..eb6d9c27 100644 --- a/library/ajax/view_torrent.php +++ b/library/ajax/view_torrent.php @@ -17,7 +17,7 @@ $torrent = DB()->fetch_row("SELECT at.attach_id, at.physical_filename FROM ". BB if (!$torrent) $this->ajax_die($lang['EMPTY_ATTACH_ID']); $filename = get_attachments_dir() .'/'. $torrent['physical_filename']; -if (!file_exists($filename) || (false === ($file_contents = file_get_contents($filename)))) +if (!@file_exists($filename) || (false === ($file_contents = @file_get_contents($filename)))) { if (IS_AM) { diff --git a/library/config.php b/library/config.php index 40b4a9f7..1b34df6f 100644 --- a/library/config.php +++ b/library/config.php @@ -15,8 +15,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? idn_to_utf8($_SERVER['SERVER_ $domain_ssl = false; // Version info -$bb_cfg['tp_version'] = '2.1.5-2023.09'; -$bb_cfg['tp_release_date'] = '04-10-2023'; +$bb_cfg['tp_version'] = '2.1.5-2023.10'; +$bb_cfg['tp_release_date'] = '04-11-2023'; $bb_cfg['tp_release_state'] = 'LTS'; $bb_cfg['tp_zf_version'] = '2.4.13'; @@ -281,6 +281,8 @@ $bb_cfg['user_session_gc_ttl'] = 1800; // number of seconds that a s $bb_cfg['session_cache_gc_ttl'] = 1200; // sec $bb_cfg['max_last_visit_days'] = 14; // days $bb_cfg['last_visit_update_intrv'] = 3600; // sec +$bb_cfg['last_visit_date_format'] = 'Y-m-d H:i'; // формат даты последнего визита на сайте +$bb_cfg['last_activity_date_format'] = 'Y-m-d H:i'; // формат даты последней активности на сайте // Registration $bb_cfg['invalid_logins'] = 5; // Количество неверных попыток ввода пароля, перед выводом проверки капчей @@ -288,6 +290,7 @@ $bb_cfg['new_user_reg_disabled'] = false; // Запретить рег $bb_cfg['unique_ip'] = false; // Запретить регистрацию нескольких учетных записей с одного ip $bb_cfg['new_user_reg_restricted'] = false; // Ограничить регистрацию новых пользователей по времени с 01:00 до 17:00 $bb_cfg['reg_email_activation'] = true; // Требовать активацию учетной записи по email +$bb_cfg['reg_date_format'] = 'Y-m-d H:i'; // формат даты регистрации / даты вступления пользователя // Email $bb_cfg['emailer_disabled'] = false; // отключить ли отправку почты с сайта @@ -382,18 +385,14 @@ define('CRON_ALLOWED', TRIGGERS_DIR .'cron_allowed'); define('CRON_RUNNING', TRIGGERS_DIR .'cron_running'); // Date format -$bb_cfg['date_format'] = 'Y-m-d'; // общий формат даты (оставлено для обратной совместимости. Если есть возможность, то используйте лучше одну из переменных ниже, исходя из целей) -$bb_cfg['current_time_date_format'] = 'd-M H:i'; // формат блока "текущее время" на сайте -$bb_cfg['reg_date_format'] = 'Y-m-d H:i'; // формат даты регистрации / даты вступления пользователя -$bb_cfg['last_visit_date_format'] = 'Y-m-d H:i'; // формат даты последнего визита на сайте -$bb_cfg['last_activity_date_format'] = 'Y-m-d H:i'; // формат даты последней активности на сайте -$bb_cfg['last_post_date_format'] = 'd-M-y H:i'; // формат даты последнего поста (на странице просмотра форума и на главной) +$bb_cfg['date_format'] = 'Y-m-d'; // общий формат даты (оставлено для обратной совместимости) // Subforums $bb_cfg['sf_on_first_page_only'] = true; // Forums $bb_cfg['allowed_topics_per_page'] = array(50, 100, 150, 200, 250, 300); +$bb_cfg['last_post_date_format'] = 'd-M-y H:i'; // формат даты последнего поста (на странице просмотра форума и на главной) // Topics $bb_cfg['show_quick_reply'] = true; // показывать форму быстрого ответа @@ -499,6 +498,7 @@ $bb_cfg['mem_on_start'] = (MEM_USAGE) ? memory_get_usage() : 0; $bb_cfg['translate_dates'] = true; // in displaying time $bb_cfg['use_word_censor'] = true; // использовать цензор слов $bb_cfg['show_jumpbox'] = true; // показывать ли jumpbox +$bb_cfg['current_time_date_format'] = 'd-M H:i'; // формат блока "текущее время" на сайте $bb_cfg['allow_change'] = array( 'language' => true, diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index 442c72e2..437a3a5a 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -732,8 +732,10 @@ class sql_db } } - @define('IN_FIRST_SLOW_QUERY', true); - + if (!defined('IN_FIRST_SLOW_QUERY')) + { + define('IN_FIRST_SLOW_QUERY', true); + } CACHE('bb_cache')->set('dont_log_slow_query', $new_priority, $ignoring_time); } diff --git a/library/includes/cron/cron_init.php b/library/includes/cron/cron_init.php index a2fbca92..1b9bfac1 100644 --- a/library/includes/cron/cron_init.php +++ b/library/includes/cron/cron_init.php @@ -30,7 +30,10 @@ function cron_get_file_lock () function cron_track_running ($mode) { - @define('CRON_STARTMARK', TRIGGERS_DIR .'cron_started_at_'. date('Y-m-d_H-i-s') .'_by_pid_'. getmypid()); + if (!defined('CRON_STARTMARK')) + { + define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid()); + } if ($mode == 'start') { diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php index 5f1bb367..66938f62 100644 --- a/library/includes/init_bb.php +++ b/library/includes/init_bb.php @@ -1,8 +1,6 @@ = 50303)) die('TorrentPier II requires PHP version 5.3.3+. Your PHP version '. PHP_VERSION); -if (!defined('BB_CFG_LOADED')) trigger_error('Configuration file could not be loaded', E_USER_ERROR); // Define some basic configuration arrays unset($stopwords, $synonyms_match, $synonyms_replace);