diff --git a/include/core.php b/include/core.php index 8e6cceef..c37c30d5 100644 --- a/include/core.php +++ b/include/core.php @@ -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); } } diff --git a/include/functions.php b/include/functions.php index 7454b720..1e535c3c 100644 --- a/include/functions.php +++ b/include/functions.php @@ -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") { diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 7c495421..ced860cd 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -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, '/'); } diff --git a/public/download.php b/public/download.php index c747d645..35921b3b 100644 --- a/public/download.php +++ b/public/download.php @@ -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 diff --git a/public/takeinvite.php b/public/takeinvite.php index cc80c51e..64b03921 100644 --- a/public/takeinvite.php +++ b/public/takeinvite.php @@ -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 = <<{$lang_takeinvite['mail_here']}
-http://$BASEURL/signup.php?type=invite&invitenumber=$hash -
{$lang_takeinvite['mail_three']}$invite_timeout{$lang_takeinvite['mail_four']}{$arr[username]}{$lang_takeinvite['mail_five']}
+{$lang_takeinvite['mail_one']}{$arr['username']}{$lang_takeinvite['mail_two']} +{$lang_takeinvite['mail_here']}
+$signupUrl +
{$lang_takeinvite['mail_three']}$invite_timeout{$lang_takeinvite['mail_four']}{$arr['username']}{$lang_takeinvite['mail_five']}
$body

{$lang_takeinvite['mail_six']} EOD;