Skip to content

Commit

Permalink
Minor improvements (#297)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
belomaxorka committed Oct 4, 2023
1 parent 4d99225 commit 933e4b3
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 47 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion admin/admin_attach_cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
}

$s_forums = '';
$list_cat = [];
$list_cat = array();
while ($row = DB()->sql_fetchrow($result))
{ //sf
$s_forums .= '<option value="' . $row['forum_id'] . '">' . (($row['forum_parent']) ? HTML_SF_SPACER : '') . htmlCHR($row['forum_name']) . '</option>';
Expand Down
4 changes: 2 additions & 2 deletions admin/admin_disallow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

if ($disallowed_user == '')
{
bb_die($lang['FIELDS_EMPTY']);
bb_die($lang['FIELDS_EMPTY'] . '<br /><br />'. sprintf($lang['CLICK_RETURN_DISALLOWADMIN'], '<a href="admin_disallow.php">', '</a>') . '<br /><br />'. sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
if( validate_username($disallowed_user) )
{
Expand Down Expand Up @@ -94,4 +94,4 @@
'S_FORM_ACTION' => 'admin_disallow.php',
));

print_page('admin_disallow.tpl', 'admin');
print_page('admin_disallow.tpl', 'admin');
12 changes: 6 additions & 6 deletions admin/admin_ranks.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{
if (empty($rank_id))
{
bb_die($lang['MUST_SELECT_RANK']);
bb_die($lang['MUST_SELECT_RANK'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}

$sql = "SELECT * FROM " . BB_RANKS . " WHERE rank_id = $rank_id";
Expand Down Expand Up @@ -100,7 +100,7 @@

if ($rank_title == '')
{
bb_die($lang['MUST_SELECT_RANK']);
bb_die($lang['MUST_SELECT_RANK'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}

if ($special_rank == 1)
Expand All @@ -127,7 +127,7 @@
$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'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
$sql = "UPDATE " . BB_RANKS . "
Expand Down Expand Up @@ -186,7 +186,7 @@
$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'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}

$datastore->update('ranks');
Expand All @@ -195,7 +195,7 @@
}
else
{
bb_die($lang['MUST_SELECT_RANK']);
bb_die($lang['MUST_SELECT_RANK'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_RANKADMIN'], '<a href="admin_ranks.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}
}
else
Expand Down Expand Up @@ -251,4 +251,4 @@
}
}

print_page('admin_ranks.tpl', 'admin');
print_page('admin_ranks.tpl', 'admin');
6 changes: 3 additions & 3 deletions admin/admin_smilies.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$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']);
Expand Down Expand Up @@ -277,7 +277,7 @@
// If no code was entered complain
if ($smile_code == '' || $smile_url == '')
{
bb_die($lang['FIELDS_EMPTY']);
bb_die($lang['FIELDS_EMPTY'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}

// Convert < and > to proper htmlentities for parsing
Expand Down Expand Up @@ -309,7 +309,7 @@
// If no code was entered complain
if ($smile_code == '' || $smile_url == '')
{
bb_die($lang['FIELDS_EMPTY']);
bb_die($lang['FIELDS_EMPTY'] . '<br /><br />' . sprintf($lang['CLICK_RETURN_SMILEADMIN'], '<a href="admin_smilies.php">', '</a>') . '<br /><br />' . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>'));
}

// Convert < and > to proper htmlentities for parsing
Expand Down
14 changes: 12 additions & 2 deletions admin/admin_ug_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
{
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'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');

bb_die($message);
unset($message);
}

DB()->query("UPDATE ". BB_USERS ." SET user_level = ". ADMIN ." WHERE user_id = $user_id LIMIT 1");
Expand All @@ -95,7 +100,12 @@
// 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'] .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_USERAUTH'], '<a href="admin_ug_auth.php?mode='. $mode .'">', '</a>') .'<br /><br />';
$message .= sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], '<a href="index.php?pane=right">', '</a>');

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");
Expand Down
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// 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('.');
Expand Down
12 changes: 4 additions & 8 deletions bt/scrape.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
$_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']));
}
Expand Down Expand Up @@ -50,9 +46,9 @@ function msg_die ($msg)
");

$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);
Expand Down
5 changes: 4 additions & 1 deletion common.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

if (!(PHP_VERSION_ID >= 50303)) die('TorrentPier II requires PHP version 5.3.3+. Your PHP version '. PHP_VERSION);
if (isset($_REQUEST['GLOBALS'])) die();

ignore_user_abort(true);
Expand Down Expand Up @@ -30,11 +31,13 @@
{
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'))
{
Expand Down
9 changes: 6 additions & 3 deletions library/ajax/manage_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

global $userdata, $lang, $bb_cfg;

$mode = (string) $this->request['mode'];
if (!$mode = (string) $this->request['mode'])
{
$this->ajax_die('invalid mode (empty)');
}

switch ($mode)
{
Expand Down Expand Up @@ -59,7 +62,7 @@

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);
Expand Down Expand Up @@ -116,4 +119,4 @@
$this->ajax_die('Invalid mode');
}

$this->response['mode'] = $mode;
$this->response['mode'] = $mode;
2 changes: 1 addition & 1 deletion library/ajax/manage_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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']);
}
Expand Down
5 changes: 4 additions & 1 deletion library/ajax/mod_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

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)
{
Expand Down
7 changes: 5 additions & 2 deletions library/ajax/sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

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 = '';

Expand Down Expand Up @@ -43,4 +46,4 @@
}

$this->response['html'] = $html;
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;
7 changes: 5 additions & 2 deletions library/ajax/user_register.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

global $bb_cfg, $lang, $userdata;

$mode = (string) $this->request['mode'];
if (!$mode = (string) $this->request['mode'])
{
$this->ajax_die('invalid mode (empty)');
}

$html = '<img src="./styles/images/good.gif">';
switch($mode)
Expand Down Expand Up @@ -72,4 +75,4 @@
}

$this->response['html'] = $html;
$this->response['mode'] = $mode;
$this->response['mode'] = $mode;
2 changes: 1 addition & 1 deletion library/ajax/view_torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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)
{
Expand Down
16 changes: 8 additions & 8 deletions library/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
$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';

Expand Down Expand Up @@ -281,13 +281,16 @@
$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; // Количество неверных попыток ввода пароля, перед выводом проверки капчей
$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; // отключить ли отправку почты с сайта
Expand Down Expand Up @@ -382,18 +385,14 @@
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; // показывать форму быстрого ответа
Expand Down Expand Up @@ -499,6 +498,7 @@
$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,
Expand Down
6 changes: 4 additions & 2 deletions library/includes/core/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,10 @@ function expect_slow_query ($ignoring_time = 60, $new_priority = 10)
}
}

@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);
}

Expand Down
5 changes: 4 additions & 1 deletion library/includes/cron/cron_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand Down
2 changes: 0 additions & 2 deletions library/includes/init_bb.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

if (!defined('BB_ROOT')) die(basename(__FILE__));
if (!(PHP_VERSION_ID >= 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);
Expand Down

0 comments on commit 933e4b3

Please sign in to comment.