fix rss download link + migrate bencode to rhilip/bencode

This commit is contained in:
xiaomlove
2021-06-09 02:23:09 +08:00
parent bf49c8c298
commit 5c4c2ccf8f
9 changed files with 185 additions and 329 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ function block_browser()
function benc_resp($d)
{
benc_resp_raw(benc(array('type' => 'dictionary', 'value' => $d)));
benc_resp_raw(\Rhilip\Bencode\Bencode::encode($d));
}
function benc_resp_raw($x) {
do_log($x);
@@ -60,7 +60,7 @@ function benc_resp_raw($x) {
}
function err($msg, $userid = 0, $torrentid = 0)
{
benc_resp(array('failure reason' => array('type' => 'string', 'value' => $msg)));
benc_resp(['failure reason' => $msg]);
exit();
}
function check_cheater($userid, $torrentid, $uploaded, $downloaded, $anctime, $seeders=0, $leechers=0){
+31
View File
@@ -584,3 +584,34 @@ function isRunningInConsole(): bool
{
return php_sapi_name() == 'cli';
}
function get_base_announce_url()
{
global $https_announce_urls, $announce_urls;
$httpsAnnounceUrls = array_filter($https_announce_urls);
$log = "cookie: " . json_encode($_COOKIE) . ", https_announce_urls: " . json_encode($httpsAnnounceUrls);
if ((isset($_COOKIE["c_secure_tracker_ssl"]) && $_COOKIE["c_secure_tracker_ssl"] == base64("yeah")) || !empty($httpsAnnounceUrls)) {
$log .= ", c_secure_tracker_ssl = base64('yeah'): " . base64("yeah") . ", or not empty https_announce_urls";
$tracker_ssl = true;
} else {
$tracker_ssl = false;
}
$log .= ", tracker_ssl: $tracker_ssl";
if ($tracker_ssl == true){
$ssl_torrent = "https://";
if ($https_announce_urls[0] != "") {
$log .= ", https_announce_urls not empty, use it";
$base_announce_url = $https_announce_urls[0];
} else {
$log .= ", https_announce_urls empty, use announce_urls[0]";
$base_announce_url = $announce_urls[0];
}
}
else{
$ssl_torrent = "http://";
$base_announce_url = $announce_urls[0];
}
do_log($log);
return $ssl_torrent . $base_announce_url;
}