mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 10:37:30 -07:00
Show client country in seeders / leechers list 🌍 (#1478)
* Show client country in seeders / leechers list * Update functions.php * Update functions.php * Update functions.php * Updated * Update displaying_torrent.php * Update functions.php * Update viewtopic_torrent.tpl * Update viewtopic_torrent.tpl * Update functions.php * Update functions.php * Update functions.php * Update functions.php * Update config.php * Updated * Updated * Updated * Updated * Update update_geolite_db.php * Update update_geolite_db.php * Updated * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Updated * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Update update_geolite_db.php * Updated * Update viewtopic_torrent.tpl * Updated * Update composer.lock * Update defines.php * Updated * Update init_bb.php * Update CHANGELOG.md
This commit is contained in:
parent
2fa3520872
commit
459fba6b86
20 changed files with 475 additions and 89 deletions
|
@ -50,7 +50,7 @@ if ($posts_days = (int)$bb_cfg['posts_cache_days_keep']) {
|
|||
}
|
||||
|
||||
// Autofill announcer url
|
||||
if (empty($bb_cfg['bt_announce_url'])) {
|
||||
if (empty($bb_cfg['bt_announce_url']) || ($bb_cfg['bt_announce_url'] === 'https://localhost/bt/announce.php')) {
|
||||
bb_update_config(['bt_announce_url' => FULL_URL . 'bt/announce.php']);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,6 @@ global $cron_runtime_log;
|
|||
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
|
||||
if (method_exists(CACHE($cache_name), 'gc')) {
|
||||
$changes = CACHE($cache_name)->gc();
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') . " -- " . str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) . " del: $changes\n";
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- " . str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) . " del: $changes\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ foreach (file($dump_path) as $line) {
|
|||
$temp_line .= $line;
|
||||
if (str_ends_with(trim($line), ';')) {
|
||||
if (!DB()->query($temp_line)) {
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') . " -- Error performing query: " . $temp_line . " | " . DB()->sql_error()['message'] . "\n";
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Error performing query: " . $temp_line . " | " . DB()->sql_error()['message'] . "\n";
|
||||
}
|
||||
$temp_line = '';
|
||||
}
|
||||
|
|
81
library/includes/cron/jobs/update_geolite_db.php
Normal file
81
library/includes/cron/jobs/update_geolite_db.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?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)\n";
|
||||
}
|
||||
|
||||
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\n";
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot create old GeoLite file\n";
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot find GeoLite file (It's okay)\n";
|
||||
}
|
||||
|
||||
$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 . "\n";
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot access to: " . $repo_link . "\n";
|
||||
}
|
||||
|
||||
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 . "\n";
|
||||
$get_file = file_get_contents($download_link);
|
||||
if ($get_file !== false) {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- GeoLite file obtained\n";
|
||||
file_put_contents($save_path, $get_file); // Save new GeoLite file!
|
||||
if (is_file($save_path)) {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- GeoLite file successfully saved ($file_date)\n";
|
||||
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)\n";
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Reverting all changes...\n";
|
||||
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\n";
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot revert changes, because cannot rename old file\n";
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot revert changes, old file not found\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- GeoLite file not obtained\n";
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Cannot find link to download\n";
|
||||
}
|
||||
} else {
|
||||
$cron_runtime_log .= date('Y-m-d H:i:s') . " -- Invalid response from server: " . $json_response . "\n";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue