mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
Minor improvements (#1481)
* Minor improvements * Updated * Update functions.php * Updated * Update .gitignore * Updated * Update CHANGELOG.md
This commit is contained in:
parent
9ada2c63b9
commit
f584cf5d29
11 changed files with 10 additions and 108 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -33,8 +33,6 @@ $RECYCLE.BIN/
|
||||||
*.lnk
|
*.lnk
|
||||||
*.bat
|
*.bat
|
||||||
*.ver
|
*.ver
|
||||||
*.mmdb
|
|
||||||
*.mmdb.old
|
|
||||||
|
|
||||||
### OSX ###
|
### OSX ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
- Demo mode: Allow registering torrents by default [\#1440](https://github.com/torrentpier/torrentpier/pull/1440) ([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))
|
||||||
- Temp: Removed showing forum description in `viewforum.php` [\#1465](https://github.com/torrentpier/torrentpier/pull/1465) ([belomaxorka](https://github.com/belomaxorka))
|
- Temp: Removed showing forum description in `viewforum.php` [\#1465](https://github.com/torrentpier/torrentpier/pull/1465) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Code refactoring [\#1441](https://github.com/torrentpier/torrentpier/pull/1441) ([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), [\#1452](https://github.com/torrentpier/torrentpier/pull/1452), [\#1458](https://github.com/torrentpier/torrentpier/pull/1458), [\#1461](https://github.com/torrentpier/torrentpier/pull/1461), [\#1462](https://github.com/torrentpier/torrentpier/pull/1462), [\#1467](https://github.com/torrentpier/torrentpier/pull/1467), [\#1469](https://github.com/torrentpier/torrentpier/pull/1469), [\#1472](https://github.com/torrentpier/torrentpier/pull/1472), [\#1477](https://github.com/torrentpier/torrentpier/pull/1477), [\#1480](https://github.com/torrentpier/torrentpier/pull/1480) ([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), [\#1452](https://github.com/torrentpier/torrentpier/pull/1452), [\#1458](https://github.com/torrentpier/torrentpier/pull/1458), [\#1461](https://github.com/torrentpier/torrentpier/pull/1461), [\#1462](https://github.com/torrentpier/torrentpier/pull/1462), [\#1467](https://github.com/torrentpier/torrentpier/pull/1467), [\#1469](https://github.com/torrentpier/torrentpier/pull/1469), [\#1472](https://github.com/torrentpier/torrentpier/pull/1472), [\#1477](https://github.com/torrentpier/torrentpier/pull/1477), [\#1480](https://github.com/torrentpier/torrentpier/pull/1480), [\#1481](https://github.com/torrentpier/torrentpier/pull/1481) ([belomaxorka](https://github.com/belomaxorka))
|
||||||
- Updated deps [\#1454](https://github.com/torrentpier/torrentpier/pull/1454), [\#1455](https://github.com/torrentpier/torrentpier/pull/1455), [\#1459](https://github.com/torrentpier/torrentpier/pull/1459), [\#1460](https://github.com/torrentpier/torrentpier/pull/1460) ([belomaxorka](https://github.com/belomaxorka))
|
- Updated deps [\#1454](https://github.com/torrentpier/torrentpier/pull/1454), [\#1455](https://github.com/torrentpier/torrentpier/pull/1455), [\#1459](https://github.com/torrentpier/torrentpier/pull/1459), [\#1460](https://github.com/torrentpier/torrentpier/pull/1460) ([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), [\#1468](https://github.com/torrentpier/torrentpier/pull/1468), [\#1473](https://github.com/torrentpier/torrentpier/pull/1473), [\#1476](https://github.com/torrentpier/torrentpier/pull/1476), [\#1479](https://github.com/torrentpier/torrentpier/pull/1479) ([Exileum](https://github.com/Exileum))
|
- 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), [\#1468](https://github.com/torrentpier/torrentpier/pull/1468), [\#1473](https://github.com/torrentpier/torrentpier/pull/1473), [\#1476](https://github.com/torrentpier/torrentpier/pull/1476), [\#1479](https://github.com/torrentpier/torrentpier/pull/1479) ([Exileum](https://github.com/Exileum))
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
"claviska/simpleimage": "^4.0",
|
"claviska/simpleimage": "^4.0",
|
||||||
"egulias/email-validator": "^4.0.1",
|
"egulias/email-validator": "^4.0.1",
|
||||||
"filp/whoops": "^2.15",
|
"filp/whoops": "^2.15",
|
||||||
"geoip2/geoip2": "^3.0",
|
|
||||||
"gigablah/sphinxphp": "2.0.8",
|
"gigablah/sphinxphp": "2.0.8",
|
||||||
"google/recaptcha": "^1.3",
|
"google/recaptcha": "^1.3",
|
||||||
"jacklul/monolog-telegram": "^3.1",
|
"jacklul/monolog-telegram": "^3.1",
|
||||||
|
|
|
@ -654,9 +654,6 @@ VALUES ('1', 'Attach maintenance', 'attach_maintenance.php', 'daily', '', '05:00
|
||||||
'0',
|
'0',
|
||||||
'0', '0'),
|
'0', '0'),
|
||||||
('1', 'Demo mode', 'demo_mode.php', 'daily', '', '05:00:00', '255', '', '', '', '1', 'demo_mode_cron', '1', '1',
|
('1', 'Demo mode', 'demo_mode.php', 'daily', '', '05:00:00', '255', '', '', '', '1', 'demo_mode_cron', '1', '1',
|
||||||
'0'),
|
|
||||||
('1', 'Update GeoLite DB', 'update_geolite_db.php', 'daily', '', '05:00:00', '255', '', '', '', '1',
|
|
||||||
'update_geolite_db', '1', '1',
|
|
||||||
'0');
|
'0');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
|
|
@ -448,7 +448,7 @@ if ($tor_reged && $tor_info) {
|
||||||
'ROW_BGR' => $row_bgr,
|
'ROW_BGR' => $row_bgr,
|
||||||
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
|
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
|
||||||
'PEER_ID' => isset($peer['peer_id']) ? get_user_torrent_client($peer['peer_id']) : $lang['UNKNOWN'],
|
'PEER_ID' => isset($peer['peer_id']) ? get_user_torrent_client($peer['peer_id']) : $lang['UNKNOWN'],
|
||||||
'COUNTRY' => render_flag(getCountryByIP($ip, $port), false),
|
'COUNTRY' => render_flag(infoByIP($ip, $port)['countryCode'], false),
|
||||||
'COMPL_PRC' => $compl_perc,
|
'COMPL_PRC' => $compl_perc,
|
||||||
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot,
|
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot,
|
||||||
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot,
|
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot,
|
||||||
|
|
|
@ -32,6 +32,7 @@ define('TEMPLATES_DIR', BB_PATH . '/styles/templates');
|
||||||
define('APP_NAME', 'TorrentPier');
|
define('APP_NAME', 'TorrentPier');
|
||||||
define('UPDATER_URL', 'https://api.github.com/repos/torrentpier/torrentpier/releases/latest');
|
define('UPDATER_URL', 'https://api.github.com/repos/torrentpier/torrentpier/releases/latest');
|
||||||
define('UPDATER_FILE', INT_DATA_DIR . '/updater.ver');
|
define('UPDATER_FILE', INT_DATA_DIR . '/updater.ver');
|
||||||
|
define('API_IP_URL', 'https://freeipapi.com/api/json/');
|
||||||
define('CHECK_REQIREMENTS', [
|
define('CHECK_REQIREMENTS', [
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'php_min_version' => '8.1.0',
|
'php_min_version' => '8.1.0',
|
||||||
|
|
|
@ -83,7 +83,7 @@ foreach ($cron_jobs as $job) {
|
||||||
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
|
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
|
||||||
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
|
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
|
||||||
|
|
||||||
if (is_countable($cron_runtime_log)) {
|
if (is_array($cron_runtime_log)) {
|
||||||
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
|
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
|
||||||
$cron_runtime_log[] = '';
|
$cron_runtime_log[] = '';
|
||||||
bb_log($cron_runtime_log, CRON_LOG_DIR . '/' . basename($runtime_log_file));
|
bb_log($cron_runtime_log, CRON_LOG_DIR . '/' . basename($runtime_log_file));
|
||||||
|
|
|
@ -1,82 +0,0 @@
|
||||||
<?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__));
|
|
||||||
}
|
|
||||||
|
|
||||||
set_time_limit(600);
|
|
||||||
|
|
||||||
global $cron_runtime_log;
|
|
||||||
|
|
||||||
$save_path = INT_DATA_DIR . '/GeoLite2-City.mmdb';
|
|
||||||
$old_file_path = INT_DATA_DIR . '/GeoLite2-City.mmdb.old';
|
|
||||||
$repo_link = 'https://api.github.com/repos/P3TERX/GeoLite.mmdb/releases/latest';
|
|
||||||
|
|
||||||
if (is_file($old_file_path) && unlink($old_file_path)) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Old GeoLite file successfully removed (First step)";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_file($save_path)) {
|
|
||||||
if (rename($save_path, $old_file_path)) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Successfully created old GeoLite file";
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot create old GeoLite file";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot find GeoLite file (It's okay)";
|
|
||||||
}
|
|
||||||
|
|
||||||
$context = stream_context_create(['http' => ['header' => 'User-Agent: ' . APP_NAME]]);
|
|
||||||
$repo_content = file_get_contents($repo_link, context: $context);
|
|
||||||
|
|
||||||
$json_response = false;
|
|
||||||
if ($repo_content !== false) {
|
|
||||||
$json_response = json_decode(utf8_encode($repo_content), true);
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Successfully connected to: " . $repo_link;
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot access to: " . $repo_link;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($json_response) && !empty($json_response)) {
|
|
||||||
$download_link = $json_response['assets'][1]['browser_download_url'];
|
|
||||||
$file_date = $json_response['name'] ?? '';
|
|
||||||
if (!empty($download_link)) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Link to download is valid: " . $download_link;
|
|
||||||
$get_file = file_get_contents($download_link);
|
|
||||||
$get_file_md5 = md5_file($download_link);
|
|
||||||
if ($get_file !== false) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- GeoLite file obtained. MD5: $get_file_md5";
|
|
||||||
file_put_contents($save_path, $get_file); // Save new GeoLite file!
|
|
||||||
if (is_file($save_path) && ($get_file_md5 === md5_file($save_path))) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- GeoLite file successfully saved ($file_date). MD5 hashes are identical";
|
|
||||||
if (is_file($old_file_path) && unlink($old_file_path)) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Old GeoLite file successfully removed (Second step)";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Reverting all changes...";
|
|
||||||
if (is_file($old_file_path)) {
|
|
||||||
if (rename($old_file_path, $save_path)) {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Successfully reverted";
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot revert changes, because cannot rename old file";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot revert changes, old file not found";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- GeoLite file not obtained";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Cannot find link to download";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Invalid response from server: " . $json_response;
|
|
||||||
}
|
|
|
@ -2166,26 +2166,17 @@ function readUpdaterFile(): array|bool
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show country ISO Code by user IP address
|
* IP Geolocation API
|
||||||
*
|
*
|
||||||
* @param string $ipAddress
|
* @param string $ipAddress
|
||||||
* @param int $port
|
* @param int $port
|
||||||
* @return mixed|string|null
|
* @return mixed|string|null
|
||||||
*/
|
*/
|
||||||
function getCountryByIP(string $ipAddress, int $port = 1111): mixed
|
function infoByIP(string $ipAddress, int $port = 0): mixed
|
||||||
{
|
{
|
||||||
global $lang;
|
|
||||||
|
|
||||||
if (!$data = CACHE('bb_ip2countries')->get($ipAddress . '_' . $port)) {
|
if (!$data = CACHE('bb_ip2countries')->get($ipAddress . '_' . $port)) {
|
||||||
$cityDbReader = new \GeoIp2\Database\Reader(INT_DATA_DIR . '/GeoLite2-City.mmdb');
|
$response = file_get_contents(API_IP_URL . $ipAddress);
|
||||||
try {
|
$data = json_decode($response, true);
|
||||||
$record = $cityDbReader->city($ipAddress);
|
|
||||||
$data = $record->country->isoCode;
|
|
||||||
} catch (\GeoIp2\Exception\AddressNotFoundException $e) {
|
|
||||||
$data = $lang['UNKNOWN'];
|
|
||||||
} catch (\MaxMind\Db\Reader\InvalidDatabaseException $e) {
|
|
||||||
bb_die($e->getMessage());
|
|
||||||
}
|
|
||||||
CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200);
|
CACHE('bb_ip2countries')->set($ipAddress . '_' . $port, $data, 1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,7 @@ ajax.callback.callseed = function (data) {
|
||||||
</table>
|
</table>
|
||||||
<!-- END lfull -->
|
<!-- END lfull -->
|
||||||
|
|
||||||
<div class="med tCenter mrg_4 warnColor1">{L_DL_INFO}</div>
|
<div class="med tCenter mrg_4 warnColor1">{L_DL_INFO}</div>
|
||||||
<hr>
|
|
||||||
<div class="med tCenter mrg_4">This DL-list includes GeoLite2 data created by MaxMind, available from <a target="_blank" href="https://www.maxmind.com">https://www.maxmind.com</a>.</div>
|
|
||||||
|
|
||||||
</div><!--/full_details-->
|
</div><!--/full_details-->
|
||||||
<!-- ENDIF / PEER_EXIST -->
|
<!-- ENDIF / PEER_EXIST -->
|
||||||
|
|
|
@ -46,7 +46,7 @@ $lastvisit = (!IS_GUEST) ? $userdata['user_lastvisit'] : '';
|
||||||
$search_id = (isset($_GET['search_id']) && is_string($_GET['search_id'])) ? $_GET['search_id'] : '';
|
$search_id = (isset($_GET['search_id']) && is_string($_GET['search_id'])) ? $_GET['search_id'] : '';
|
||||||
$session_id = $userdata['session_id'];
|
$session_id = $userdata['session_id'];
|
||||||
|
|
||||||
$status = (isset($_POST['status']) && is_countable($_POST['status'])) ? (array)$_POST['status'] : [];
|
$status = (isset($_POST['status']) && is_array($_POST['status'])) ? $_POST['status'] : [];
|
||||||
|
|
||||||
$cat_forum = $tor_to_show = $search_in_forums_ary = [];
|
$cat_forum = $tor_to_show = $search_in_forums_ary = [];
|
||||||
$title_match_sql = $title_match_q = $search_in_forums_csv = '';
|
$title_match_sql = $title_match_q = $search_in_forums_csv = '';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue