fix tracker url and takeinvite.php

This commit is contained in:
xiaomlove
2021-02-28 02:47:13 +08:00
parent 9d6f25670a
commit 3bf4b83826
5 changed files with 21 additions and 11 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ if (!file_exists($rootpath . '.env')) {
$installScriptRelativePath = 'install/install.php';
$installScriptFile = $rootpath . "public/$installScriptRelativePath";
if (file_exists($installScriptFile)) {
header('Location: ' . getBaseUrl() . $installScriptRelativePath);
header('Location: ' . getBaseUrl() . '/' . $installScriptRelativePath);
exit(0);
}
}
+3
View File
@@ -2715,6 +2715,9 @@ function set_langfolder_cookie($folder, $expires = 0x7fffffff)
function get_protocol_prefix()
{
global $securelogin;
if (isHttps()) {
return "https://";
}
if ($securelogin == "yes") {
return "https://";
} elseif ($securelogin == "no") {
+8 -2
View File
@@ -387,10 +387,16 @@ function arr_set(&$array, $key, $value)
return $array;
}
function isHttps()
{
$result = !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) !== 'off');
return $result;
}
function getSchemeAndHttpHost()
{
$isHttps = !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) !== 'off');
$isHttps = isHttps();
$protocol = $isHttps ? 'https' : 'http';
$port = $_SERVER['SERVER_PORT'];
$result = "$protocol://" . $_SERVER['HTTP_HOST'];
@@ -411,5 +417,5 @@ function getBaseUrl()
} else {
$url .= $requestUri;
}
return $url;
return trim($url, '/');
}
+2 -1
View File
@@ -89,7 +89,8 @@ if (strlen($CURUSER['passkey']) != 32) {
}
$dict = bdec_file($fn, $max_torrent_size);
$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?passkey=$CURUSER[passkey]";
//$dict['value']['announce']['value'] = $ssl_torrent . $base_announce_url . "?passkey=$CURUSER[passkey]";
$dict['value']['announce']['value'] = getSchemeAndHttpHost() . "/announce.php?passkey=$CURUSER[passkey]";
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
/*if ($announce_urls[1] != "") // add multi-tracker
+7 -7
View File
@@ -14,7 +14,7 @@ function bark($msg) {
exit;
}
$id = $CURUSER[id];
$id = $CURUSER['id'];
$email = unesc(htmlspecialchars(trim($_POST["email"])));
$email = safe_email($email);
if (!$email)
@@ -48,13 +48,13 @@ $hash = md5(mt_rand(1,10000).$CURUSER['username'].TIMENOW.$CURUSER['passhash'])
$title = $SITENAME.$lang_takeinvite['mail_tilte'];
sql_query("INSERT INTO invites (inviter, invitee, hash, time_invited) VALUES ('".mysql_real_escape_string($id)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($hash)."', " . sqlesc(date("Y-m-d H:i:s")) . ")");
sql_query("UPDATE users SET invites = invites - 1 WHERE id = ".mysql_real_escape_string($id)."") or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE users SET invites = invites - 1 WHERE id = ".mysql_real_escape_string($id)) or sqlerr(__FILE__, __LINE__);
$signupUrl = getBaseUrl() . "/signup.php?type=invite&invitenumber=$hash";
$message = <<<EOD
{$lang_takeinvite['mail_one']}{$arr[username]}{$lang_takeinvite['mail_two']}
<b><a href="javascript:void(null)" onclick="window.open('http://$BASEURL/signup.php?type=invite&invitenumber=$hash')">{$lang_takeinvite['mail_here']}</a></b><br />
http://$BASEURL/signup.php?type=invite&invitenumber=$hash
<br />{$lang_takeinvite['mail_three']}$invite_timeout{$lang_takeinvite['mail_four']}{$arr[username]}{$lang_takeinvite['mail_five']}<br />
{$lang_takeinvite['mail_one']}{$arr['username']}{$lang_takeinvite['mail_two']}
<b><a href="javascript:void(null)" onclick="window.open($signupUrl)">{$lang_takeinvite['mail_here']}</a></b><br />
$signupUrl
<br />{$lang_takeinvite['mail_three']}$invite_timeout{$lang_takeinvite['mail_four']}{$arr['username']}{$lang_takeinvite['mail_five']}<br />
$body
<br /><br />{$lang_takeinvite['mail_six']}
EOD;