diff --git a/CHANGELOG.md b/CHANGELOG.md
index b59cbe4e5..99b0257ff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,9 +19,9 @@
- 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))
- 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) ([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))
- 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) ([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))
## [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)
diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php
index ae7dab672..bfe4d467c 100644
--- a/library/attach_mod/displaying_torrent.php
+++ b/library/attach_mod/displaying_torrent.php
@@ -448,7 +448,7 @@ if ($tor_reged && $tor_info) {
'ROW_BGR' => $row_bgr,
'NAME' => ($peer['update_time']) ? $name : "$name",
'PEER_ID' => isset($peer['peer_id']) ? get_user_torrent_client($peer['peer_id']) : $lang['UNKNOWN'],
- 'COUNTRY' => render_flag(countryByIP($ip, $port), false),
+ 'COUNTRY' => render_flag(getCountryByIP($ip, $port), false),
'COMPL_PRC' => $compl_perc,
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "$up_tot" : $up_tot,
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "$down_tot" : $down_tot,
diff --git a/library/includes/cron/cron_run.php b/library/includes/cron/cron_run.php
index b1dd95781..cf8deb0e4 100644
--- a/library/includes/cron/cron_run.php
+++ b/library/includes/cron/cron_run.php
@@ -45,7 +45,7 @@ foreach ($cron_jobs as $job) {
if (is_file($job_script)) {
$cron_start_time = utime();
- $cron_runtime_log = '';
+ $cron_runtime_log = [];
$cron_write_log = (CRON_LOG_ENABLED && (CRON_FORCE_LOG || $job['log_enabled'] >= 1));
$cron_sql_log_file = CRON_LOG_DIR . '/SQL-' . basename($job['cron_script']);
@@ -83,9 +83,10 @@ foreach ($cron_jobs as $job) {
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
- if ($cron_runtime_log) {
+ if (is_countable($cron_runtime_log)) {
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
- bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . '/' . basename($runtime_log_file));
+ $cron_runtime_log[] = '';
+ bb_log($cron_runtime_log, CRON_LOG_DIR . '/' . basename($runtime_log_file));
}
}
diff --git a/library/includes/cron/jobs/cache_gc.php b/library/includes/cron/jobs/cache_gc.php
index 549d8447f..a39a9ce0d 100644
--- a/library/includes/cron/jobs/cache_gc.php
+++ b/library/includes/cron/jobs/cache_gc.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";
}
}
diff --git a/library/includes/cron/jobs/demo_mode.php b/library/includes/cron/jobs/demo_mode.php
index 46113a2d7..4f4c07910 100644
--- a/library/includes/cron/jobs/demo_mode.php
+++ b/library/includes/cron/jobs/demo_mode.php
@@ -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'];
}
$temp_line = '';
}
diff --git a/library/includes/cron/jobs/update_geolite_db.php b/library/includes/cron/jobs/update_geolite_db.php
index 7399c28f2..6d5e71b56 100644
--- a/library/includes/cron/jobs/update_geolite_db.php
+++ b/library/includes/cron/jobs/update_geolite_db.php
@@ -20,17 +20,17 @@ $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";
+ $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\n";
+ $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\n";
+ $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)\n";
+ $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]]);
@@ -39,43 +39,44 @@ $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";
+ $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 . "\n";
+ $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 . "\n";
+ $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\n";
+ $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)) {
- $cron_runtime_log .= date('Y-m-d H:i:s') . " -- GeoLite file successfully saved ($file_date)\n";
+ 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)\n";
+ $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...\n";
+ $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\n";
+ $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\n";
+ $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\n";
+ $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\n";
+ $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\n";
+ $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 . "\n";
+ $cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Invalid response from server: " . $json_response;
}
diff --git a/library/includes/datastore/build_check_updates.php b/library/includes/datastore/build_check_updates.php
index ff3638b6d..6f72f72e1 100644
--- a/library/includes/datastore/build_check_updates.php
+++ b/library/includes/datastore/build_check_updates.php
@@ -25,7 +25,7 @@ if ($updater_content !== false) {
if (is_array($json_response) && !empty($json_response)) {
$get_version = $json_response['tag_name'];
- $version_code_actual = (int)trim(str_replace(['.', 'v', ','], '', $get_version));
+ $version_code_actual = (int)trim(str_replace(['.', 'v'], '', $get_version));
$has_update = VERSION_CODE < $version_code_actual;
// Save current version & latest available
diff --git a/library/includes/functions.php b/library/includes/functions.php
index 9da7fd870..086379d6e 100644
--- a/library/includes/functions.php
+++ b/library/includes/functions.php
@@ -2148,22 +2148,21 @@ function getBanInfo(int $userId = null): ?array
*/
function readUpdaterFile(): array|bool
{
- $str = [];
+ if (!is_file(UPDATER_FILE)) {
+ return false;
+ }
+ $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;
+ return [
+ 'previous_version' => is_numeric($str[0]) ? (int)$str[0] : 0,
+ 'latest_version' => is_numeric($str[1]) ? (int)$str[1] : 0
+ ];
}
/**
@@ -2173,7 +2172,7 @@ function readUpdaterFile(): array|bool
* @param int $port
* @return mixed|string|null
*/
-function countryByIP(string $ipAddress, int $port = 1111): mixed
+function getCountryByIP(string $ipAddress, int $port = 1111): mixed
{
global $lang;
diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php
index 4fe5ca47f..6edf70195 100644
--- a/library/includes/init_bb.php
+++ b/library/includes/init_bb.php
@@ -28,7 +28,7 @@ define('USER_IP', $user_ip);
define('IN_DEMO_MODE', env('APP_DEMO_MODE', false));
// Version code
-define('VERSION_CODE', (int)trim(str_replace(['.', 'v', ','], '', $bb_cfg['tp_version'])));
+define('VERSION_CODE', (int)trim(str_replace(['.', 'v'], '', $bb_cfg['tp_version'])));
/**
* @param $contents
@@ -403,6 +403,10 @@ $userdata =& $user->data;
/**
* Check for updates
*/
+$updaterFile = readUpdaterFile();
+if ($updaterFile && ($updaterFile['previous_version'] < VERSION_CODE)) {
+ define('IN_UPDATER', true);
+}
/**
* Cron
diff --git a/styles/templates/default/css/globals.css b/styles/templates/default/css/globals.css
index f49eaa9a7..0ed195039 100644
--- a/styles/templates/default/css/globals.css
+++ b/styles/templates/default/css/globals.css
@@ -597,6 +597,11 @@ input.long {
padding-right: 20px;
}
+.buttons input {
+ padding-left: 7px;
+ padding-right: 7px;
+}
+
.buttons input:hover {
border: 1px solid #DEDEDE;
background: #FFF;