mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 02:27:34 -07:00
Minor improvements (#1452)
* Minor improvements * Updated * Create updater.php * Revert "Create updater.php" This reverts commitbe2f3d5006
. * Revert "Updated" This reverts commit6aae9339cd
. * Updated * Update board_maintenance.php * Updated * Updated * Update build_check_updates.php * Updated * Update board_maintenance.php * Update functions.php * Updated * Update defines.php * Updated * Updated * Updater * Updated * Update .gitignore * Update * Update updater.php * Updated * Update tracker.php * Update .htaccess * Update tracker.php * Update tracker.tpl * Update CHANGELOG.md
This commit is contained in:
parent
b7b110906b
commit
24dbd25d9b
12 changed files with 110 additions and 39 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ data/uploads
|
|||
internal_data/atom
|
||||
internal_data/cache
|
||||
internal_data/log
|
||||
internal_data/updater.ver
|
||||
sitemap
|
||||
internal_data/triggers
|
||||
library/config.local.php
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
- Improved app debug [\#1438](https://github.com/torrentpier/torrentpier/pull/1438) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Demo mode: Allow registering torrents by default [\#1440](https://github.com/torrentpier/torrentpier/pull/1440) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Code refactoring [\#1441](https://github.com/torrentpier/torrentpier/pull/1441) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Minor improvements [\#1435](https://github.com/torrentpier/torrentpier/pull/1435), [\#1443](https://github.com/torrentpier/torrentpier/pull/1443), [\#1446](https://github.com/torrentpier/torrentpier/pull/1446), [\#1450](https://github.com/torrentpier/torrentpier/pull/1450) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- New Crowdin updates [\#1444](https://github.com/torrentpier/torrentpier/pull/1444), [\#1447](https://github.com/torrentpier/torrentpier/pull/1447) ([Exileum](https://github.com/Exileum))
|
||||
- Minor improvements [\#1435](https://github.com/torrentpier/torrentpier/pull/1435), [\#1443](https://github.com/torrentpier/torrentpier/pull/1443), [\#1446](https://github.com/torrentpier/torrentpier/pull/1446), [\#1450](https://github.com/torrentpier/torrentpier/pull/1450), [\#1452](https://github.com/torrentpier/torrentpier/pull/1452) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- Updated deps [\#1454](https://github.com/torrentpier/torrentpier/pull/1454), [\#1455](https://github.com/torrentpier/torrentpier/pull/1455) ([belomaxorka](https://github.com/belomaxorka))
|
||||
- New Crowdin updates [\#1444](https://github.com/torrentpier/torrentpier/pull/1444), [\#1447](https://github.com/torrentpier/torrentpier/pull/1447), [\#1453](https://github.com/torrentpier/torrentpier/pull/1453) ([Exileum](https://github.com/Exileum))
|
||||
|
||||
## [v2.4.2](https://github.com/torrentpier/torrentpier/tree/v2.4.2) (2024-03-30)
|
||||
[Full Changelog](https://github.com/torrentpier/torrentpier/compare/v2.4.1...v2.4.2)
|
||||
|
|
|
@ -15,6 +15,12 @@ if (!$stats = $datastore->get('stats')) {
|
|||
$stats = $datastore->get('stats');
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
if (!$update_data = $datastore->get('check_updates')) {
|
||||
$datastore->update('check_updates');
|
||||
$update_data = $datastore->get('check_updates');
|
||||
}
|
||||
|
||||
// Generate relevant output
|
||||
if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
||||
$module = [];
|
||||
|
@ -77,27 +83,12 @@ if (isset($_GET['pane']) && $_GET['pane'] == 'left') {
|
|||
]);
|
||||
|
||||
// Check for updates
|
||||
if (!$json_response = CACHE('bb_cache')->get('check_for_updates')) {
|
||||
$json_response = false;
|
||||
$context = stream_context_create(['http' => ['header' => 'User-Agent: TorrentPier Updater. With love!']]);
|
||||
$updater_content = file_get_contents(UPDATER_URL, context: $context);
|
||||
if ($updater_content !== false) {
|
||||
$json_response = json_decode(utf8_encode($updater_content), true);
|
||||
CACHE('bb_cache')->set('check_for_updates', $json_response, 1200);
|
||||
}
|
||||
}
|
||||
if (is_array($json_response)) {
|
||||
$get_version = $json_response['tag_name'];
|
||||
$version_code = (int)trim(str_replace(['.', 'v', ','], '', strstr($bb_cfg['tp_version'], '-', true)));
|
||||
$version_code_actual = (int)trim(str_replace(['.', 'v', ','], '', $get_version));
|
||||
|
||||
$template->assign_block_vars('updater', [
|
||||
'UPDATE_AVAILABLE' => $version_code < $version_code_actual,
|
||||
'NEW_VERSION_NUMBER' => $get_version,
|
||||
'NEW_VERSION_SIZE' => isset($json_response['assets'][0]['size']) ? humn_size($json_response['assets'][0]['size']) : false,
|
||||
'NEW_VERSION_DL_LINK' => $json_response['assets'][0]['browser_download_url'] ?? $json_response['html_url']
|
||||
]);
|
||||
}
|
||||
$template->assign_block_vars('updater', [
|
||||
'UPDATE_AVAILABLE' => $update_data['available_update'],
|
||||
'NEW_VERSION_NUMBER' => $update_data['latest_version'],
|
||||
'NEW_VERSION_SIZE' => $update_data['latest_version_size'],
|
||||
'NEW_VERSION_DL_LINK' => $update_data['latest_version_link']
|
||||
]);
|
||||
|
||||
// Get forum statistics
|
||||
$total_posts = $stats['postcount'];
|
||||
|
|
|
@ -11,10 +11,6 @@ if (!defined('BB_ROOT')) {
|
|||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// System
|
||||
define('APP_NAME', 'TorrentPier');
|
||||
define('UPDATER_URL', 'https://api.github.com/repos/torrentpier/torrentpier/releases/latest');
|
||||
|
||||
// Path (trailing slash '/' at the end: XX_PATH - without, XX_DIR - with)
|
||||
define('ADMIN_DIR', BB_PATH . '/admin');
|
||||
define('DATA_DIR', BB_PATH . '/data');
|
||||
|
@ -32,6 +28,11 @@ define('SITEMAP_DIR', BB_PATH . '/sitemap');
|
|||
define('IMAGES_DIR', BB_PATH . '/styles/images');
|
||||
define('TEMPLATES_DIR', BB_PATH . '/styles/templates');
|
||||
|
||||
// System
|
||||
define('APP_NAME', 'TorrentPier');
|
||||
define('UPDATER_URL', 'https://api.github.com/repos/torrentpier/torrentpier/releases/latest');
|
||||
define('UPDATER_FILE', INT_DATA_DIR . '/updater.ver');
|
||||
|
||||
// Templates
|
||||
define('ADMIN_TPL_DIR', TEMPLATES_DIR . '/admin/');
|
||||
define('XS_USE_ISSET', '1');
|
||||
|
|
|
@ -58,3 +58,6 @@ if (empty($bb_cfg['bt_announce_url'])) {
|
|||
if (IN_DEMO_MODE) {
|
||||
DB()->query("UPDATE " . BB_FORUMS . " SET allow_reg_tracker = 1 WHERE allow_reg_tracker = 0");
|
||||
}
|
||||
|
||||
// Check for updates
|
||||
$datastore->rm('check_updates');
|
||||
|
|
45
library/includes/datastore/build_check_updates.php
Normal file
45
library/includes/datastore/build_check_updates.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||||
*
|
||||
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
|
||||
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||
*/
|
||||
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
$data = [];
|
||||
|
||||
$context = stream_context_create(['http' => ['header' => 'User-Agent: TorrentPier Updater. With love!']]);
|
||||
$updater_content = file_get_contents(UPDATER_URL, context: $context);
|
||||
|
||||
$json_response = false;
|
||||
if ($updater_content !== false) {
|
||||
$json_response = json_decode(utf8_encode($updater_content), true);
|
||||
}
|
||||
|
||||
if (is_array($json_response) && !empty($json_response)) {
|
||||
$get_version = $json_response['tag_name'];
|
||||
$version_code_actual = (int)trim(str_replace(['.', 'v', ','], '', $get_version));
|
||||
$has_update = VERSION_CODE < $version_code_actual;
|
||||
|
||||
// Save current version & latest available
|
||||
if ($has_update) {
|
||||
file_write(VERSION_CODE . "\n" . $version_code_actual, UPDATER_FILE, replace_content: true);
|
||||
}
|
||||
|
||||
// Build data array
|
||||
$data = [
|
||||
'available_update' => $has_update,
|
||||
'latest_version' => $get_version,
|
||||
'latest_version_size' => isset($json_response['assets'][0]['size']) ? humn_size($json_response['assets'][0]['size']) : false,
|
||||
'latest_version_link' => $json_response['assets'][0]['browser_download_url'] ?? $json_response['html_url']
|
||||
];
|
||||
}
|
||||
|
||||
$this->store('check_updates', $data);
|
|
@ -2132,3 +2132,28 @@ function getBanInfo(int $userId = null): ?array
|
|||
|
||||
return $bans[$userId] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read updater file
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
function readUpdaterFile(): array|bool
|
||||
{
|
||||
$str = [];
|
||||
|
||||
if ($updaterFile = fopen(UPDATER_FILE, 'r')) {
|
||||
while (!feof($updaterFile)) {
|
||||
$str[] = trim(fgets($updaterFile));
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($str)) {
|
||||
return [
|
||||
'previous_version' => (int)$str[0],
|
||||
'latest_version' => (int)$str[1],
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ define('USER_IP', $user_ip);
|
|||
// Initialize demo mode
|
||||
define('IN_DEMO_MODE', env('APP_DEMO_MODE', false));
|
||||
|
||||
// Version code
|
||||
define('VERSION_CODE', (int)trim(str_replace(['.', 'v', ','], '', strstr($bb_cfg['tp_version'], '-', true))));
|
||||
|
||||
/**
|
||||
* @param $contents
|
||||
* @return string
|
||||
|
|
|
@ -3014,7 +3014,7 @@ $lang['ATOM_GLOBAL_FEED'] = 'Global feed for all forums';
|
|||
$lang['HASH_INVALID'] = 'Hash %s is invalid';
|
||||
$lang['HASH_NOT_FOUND'] = 'Release with hash %s not found';
|
||||
|
||||
$lang['TERMS_EMPTY_TEXT'] = '[align=center]The text of this page is edited at: %s. This line can see only administrators.[/align]';
|
||||
$lang['TERMS_EMPTY_TEXT'] = '[align=center]The text of this page is edited at: [url]%s[/url]. This line can see only administrators.[/align]';
|
||||
$lang['TERMS_EXPLAIN'] = 'On this page, you can specify the text of the basic rules of the resource is displayed to users.';
|
||||
|
||||
$lang['TR_STATS'] = [
|
||||
|
|
|
@ -39,6 +39,7 @@ class Common
|
|||
*/
|
||||
public $known_items = [
|
||||
'cat_forums' => 'build_cat_forums.php',
|
||||
'check_updates' => 'build_check_updates.php',
|
||||
'jumpbox' => 'build_cat_forums.php',
|
||||
'viewtopic_forum_select' => 'build_cat_forums.php',
|
||||
'latest_news' => 'build_cat_forums.php',
|
||||
|
|
|
@ -251,12 +251,12 @@ ajax.callback.view_post = function(data) {
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="50%">
|
||||
<!-- IF TOR_STATUS -->
|
||||
<fieldset style="margin-top: 0;">
|
||||
<legend>{L_TORRENT_STATUS}</legend>
|
||||
<div>{TOR_STATUS}</div>
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF TOR_STATUS -->
|
||||
<fieldset style="margin-top: 0;">
|
||||
<legend>{L_TORRENT_STATUS}</legend>
|
||||
<div>{TOR_STATUS}</div>
|
||||
</fieldset>
|
||||
<!-- ENDIF -->
|
||||
<fieldset style="margin-top: 0;">
|
||||
<legend>{L_SHOW_COLUMN}</legend>
|
||||
<div>
|
||||
|
|
10
tracker.php
10
tracker.php
|
@ -46,7 +46,7 @@ $lastvisit = (!IS_GUEST) ? $userdata['user_lastvisit'] : '';
|
|||
$search_id = (isset($_GET['search_id']) && is_string($_GET['search_id'])) ? $_GET['search_id'] : '';
|
||||
$session_id = $userdata['session_id'];
|
||||
|
||||
$status = $_POST['status'] ?? false;
|
||||
$status = is_countable($_POST['status']) ? $_POST['status'] : false;
|
||||
|
||||
$cat_forum = $tor_to_show = $search_in_forums_ary = [];
|
||||
$title_match_sql = $title_match_q = $search_in_forums_csv = '';
|
||||
|
@ -605,7 +605,7 @@ if ($allowed_forums) {
|
|||
if ($tor_type) {
|
||||
$SQL['WHERE'][] = "tor.tor_type IN(1,2)";
|
||||
}
|
||||
if (is_countable($status)) {
|
||||
if ($status) {
|
||||
$SQL['WHERE'][] = "tor.tor_status IN(" . implode(', ', $status) . ")";
|
||||
}
|
||||
|
||||
|
@ -819,13 +819,13 @@ $search_all_opt = '<option value="' . $search_all . '" value="fs-' . $search_all
|
|||
$cat_forum_select = "\n" . '<select id="fs-main" style="width: 100%;" name="' . $forum_key . '[]" multiple size="' . $forum_select_size . "\">\n" . $search_all_opt . $opt . "</select>\n";
|
||||
|
||||
// Status select
|
||||
if (IS_AM && $bb_cfg['tracker']['search_by_tor_status']) {
|
||||
if ($bb_cfg['tracker']['search_by_tor_status']) {
|
||||
$statuses = '<table border="0" cellpadding="0" cellspacing="0">';
|
||||
foreach (array_chunk($bb_cfg['tor_icons'], 2, true) as $statuses_part) {
|
||||
$statuses .= '<tr>';
|
||||
foreach ($statuses_part as $status_id => $status_styles) {
|
||||
$checked = (is_countable($status) && in_array($status_id, $status)) ? 'checked' : '';
|
||||
$statuses .= '<td><p class="chbox"><input type="checkbox" name="status[]" value="' . $status_id . '"' . $checked . '>' . $status_styles . ' ' . $lang['TOR_STATUS_NAME'][$status_id] . '</p></td>';
|
||||
$checked_status = in_array($status_id, $status) ? 'checked' : '';
|
||||
$statuses .= '<td><p class="chbox"><input type="checkbox" name="status[]" value="' . $status_id . '"' . $checked_status . '>' . $status_styles . ' ' . $lang['TOR_STATUS_NAME'][$status_id] . '</p></td>';
|
||||
}
|
||||
$statuses .= '</tr>';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue