mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
improve get_tracker_schema_and_host()
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.5');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-06-22');
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.9.6');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2025-06-25');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -670,7 +670,7 @@ function command_exists($command): bool
|
||||
return !(trim(exec("command -v $command")) == '');
|
||||
}
|
||||
|
||||
function get_tracker_schema_and_host($combine = false): array|string
|
||||
function get_tracker_schema_and_host($trackerUrlId, $combine = false): array|string
|
||||
{
|
||||
/*
|
||||
global $https_announce_urls, $announce_urls;
|
||||
@@ -706,12 +706,18 @@ function get_tracker_schema_and_host($combine = false): array|string
|
||||
return $ssl_torrent . $base_announce_url;
|
||||
}
|
||||
*/
|
||||
$url = \App\Models\TrackerUrl::getById(0);
|
||||
$log = "tracker_url_id: $trackerUrlId, combine: $combine";
|
||||
$url = \App\Models\TrackerUrl::getById($trackerUrlId);
|
||||
if (empty($url)) {
|
||||
return $combine ? "" : [];
|
||||
$ssl_torrent = isHttps() ? 'https://' : 'http://';
|
||||
$base_announce_url = sprintf("%s/%s", \App\Models\Setting::getBaseUrl(), DEFAULT_TRACKER_URI);
|
||||
$log .= ", ById no value";
|
||||
} else {
|
||||
$ssl_torrent = parse_url($url, PHP_URL_SCHEME) . "://" ;
|
||||
$base_announce_url = substr($url, strlen($ssl_torrent));
|
||||
$log .= ", ById has value";
|
||||
}
|
||||
$ssl_torrent = parse_url($url, PHP_URL_SCHEME) . "://" ;
|
||||
$base_announce_url = parse_url($url, PHP_URL_HOST);
|
||||
do_log("$log, ssl_torrent: $ssl_torrent, base_announce_url: $base_announce_url");
|
||||
if ($combine) {
|
||||
return $ssl_torrent . $base_announce_url;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ if (strlen($CURUSER['passkey']) != 32) {
|
||||
sql_query("UPDATE users SET passkey=".sqlesc($CURUSER['passkey'])." WHERE id=".sqlesc($CURUSER['id']));
|
||||
}
|
||||
$dict = \Rhilip\Bencode\Bencode::load($fn);
|
||||
$dict['announce'] = \App\Models\TrackerUrl::getById($CURUSER['tracker_url_id']) . "?passkey=" . $CURUSER['passkey'];
|
||||
$dict['announce'] = get_tracker_schema_and_host($CURUSER['tracker_url_id'], true) . "?passkey=" . $CURUSER['passkey'];
|
||||
$dict['comment'] = getSchemeAndHttpHost(true) . "/details.php?id=" . $id;
|
||||
do_log(sprintf("[ANNOUNCE_URL], user: %s, torrent: %s, url: %s", $CURUSER['id'] ?? '', $id, $dict['announce']));
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,7 @@ stdhead($lang_upload['head_upload']);
|
||||
<table border="1" cellspacing="0" cellpadding="5" width="97%">
|
||||
<tr>
|
||||
<td class='colhead' colspan='2' align='center'>
|
||||
<?php echo $lang_upload['text_tracker_url'] ?>: <b><?php echo get_tracker_schema_and_host(true)?></b>
|
||||
<?php echo $lang_upload['text_tracker_url'] ?>: <b><?php echo get_tracker_schema_and_host($CURUSER['tracker_url_id'], true)?></b>
|
||||
<?php
|
||||
if(!is_writable(getFullDirectory($torrent_dir)))
|
||||
print("<br /><br /><b>ATTENTION</b>: Torrent directory isn't writable. Please contact the administrator about this problem!");
|
||||
|
||||
Reference in New Issue
Block a user