1
0
mirror of https://github.com/Rouji/single_php_filehost.git synced 2025-04-07 01:49:34 +00:00

move $_SERVER['REQUEST_URI'] out of SITE_URL

the code needs 2 things:
- the URL without any path after the host, e.g. to append file download
  paths to
- the whole URL including path (and potentially including the php file's
  name!), e.g. to add ?sharex to

those shouldn't have been mashed together, and with this, aren't anymore

part of 
This commit is contained in:
Andreas Hackl 2024-06-08 16:39:22 +02:00
parent eca6db53b7
commit 561d44cdde
No known key found for this signature in database

View File

@ -23,7 +23,12 @@ class CONFIG
public static function SITE_URL() : string public static function SITE_URL() : string
{ {
$proto = ($_SERVER['HTTPS'] ?? 'off') == 'on' || CONFIG::FORCE_HTTPS ? 'https' : 'http'; $proto = ($_SERVER['HTTPS'] ?? 'off') == 'on' || CONFIG::FORCE_HTTPS ? 'https' : 'http';
return "$proto://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; return "$proto://{$_SERVER['HTTP_HOST']}";
}
public static function SCRIPT_URL() : string
{
return CONFIG::SITE_URL().$_SERVER['REQUEST_URI'];
} }
}; };
@ -173,7 +178,7 @@ function store_file(string $name, string $tmpfile, bool $formatted = false) : vo
} }
//print the download link of the file //print the download link of the file
$url = sprintf(CONFIG::SITE_URL().CONFIG::DOWNLOAD_PATH, $basename); $url = sprintf(CONFIG::SITE_URL().'/'.CONFIG::DOWNLOAD_PATH, $basename);
if ($formatted) if ($formatted)
{ {
@ -258,7 +263,7 @@ function send_text_file(string $filename, string $content) : void
function send_sharex_config() : void function send_sharex_config() : void
{ {
$name = $_SERVER['SERVER_NAME']; $name = $_SERVER['SERVER_NAME'];
$site_url = str_replace("?sharex", "", CONFIG::SITE_URL()); $site_url = str_replace("?sharex", "", CONFIG::SCRIPT_URL());
send_text_file($name.'.sxcu', <<<EOT send_text_file($name.'.sxcu', <<<EOT
{ {
"Name": "$name", "Name": "$name",
@ -275,7 +280,7 @@ EOT);
function send_hupl_config() : void function send_hupl_config() : void
{ {
$name = $_SERVER['SERVER_NAME']; $name = $_SERVER['SERVER_NAME'];
$site_url = str_replace("?hupl", "", CONFIG::SITE_URL()); $site_url = str_replace("?hupl", "", CONFIG::SCRIPT_URL());
send_text_file($name.'.hupl', <<<EOT send_text_file($name.'.hupl', <<<EOT
{ {
"name": "$name", "name": "$name",
@ -290,7 +295,7 @@ EOT);
// use it, how to upload, etc. // use it, how to upload, etc.
function print_index() : void function print_index() : void
{ {
$site_url = CONFIG::SITE_URL(); $site_url = CONFIG::SCRIPT_URL();
$sharex_url = $site_url.'?sharex'; $sharex_url = $site_url.'?sharex';
$hupl_url = $site_url.'?hupl'; $hupl_url = $site_url.'?hupl';
$decay = CONFIG::DECAY_EXP; $decay = CONFIG::DECAY_EXP;