mirror of
https://github.com/Rouji/single_php_filehost.git
synced 2025-04-10 19:08:45 +00:00
Replace URL building code with $SITE_URL global
This commit is contained in:
parent
56d07290c4
commit
95fdab7aac
24
index.php
24
index.php
@ -9,7 +9,6 @@ $ID_LENGTH=3; //length of the random file ID
|
|||||||
$STORE_PATH="files/"; //directory to store uploaded files in
|
$STORE_PATH="files/"; //directory to store uploaded files in
|
||||||
$LOG_PATH=null; //path to log uploads + resulting links to
|
$LOG_PATH=null; //path to log uploads + resulting links to
|
||||||
$DOWNLOAD_PATH="%s"; //the path part of the download url. %s = placeholder for filename
|
$DOWNLOAD_PATH="%s"; //the path part of the download url. %s = placeholder for filename
|
||||||
$HTTP_PROTO="https"; //protocol to use in links
|
|
||||||
$SITE_URL=site_url();
|
$SITE_URL=site_url();
|
||||||
$MAX_EXT_LEN=7; //max. length for file extensions
|
$MAX_EXT_LEN=7; //max. length for file extensions
|
||||||
$EXTERNAL_HOOK=null;
|
$EXTERNAL_HOOK=null;
|
||||||
@ -109,7 +108,7 @@ function store_file($name, $tmpfile, $formatted = false)
|
|||||||
{
|
{
|
||||||
global $STORE_PATH;
|
global $STORE_PATH;
|
||||||
global $ID_LENGTH;
|
global $ID_LENGTH;
|
||||||
global $HTTP_PROTO;
|
global $SITE_URL;
|
||||||
global $DOWNLOAD_PATH;
|
global $DOWNLOAD_PATH;
|
||||||
global $MAX_FILESIZE;
|
global $MAX_FILESIZE;
|
||||||
global $EXTERNAL_HOOK;
|
global $EXTERNAL_HOOK;
|
||||||
@ -183,10 +182,8 @@ function store_file($name, $tmpfile, $formatted = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//print the download link of the file
|
//print the download link of the file
|
||||||
$url = sprintf('%s://%s/'.$DOWNLOAD_PATH,
|
$url = sprintf($SITE_URL.'%s', $basename);
|
||||||
$HTTP_PROTO,
|
|
||||||
$_SERVER["HTTP_HOST"],
|
|
||||||
$basename);
|
|
||||||
if ($formatted)
|
if ($formatted)
|
||||||
{
|
{
|
||||||
printf('<pre>Access your file here: <a href="%s">%s</a></pre>', $url, $url);
|
printf('<pre>Access your file here: <a href="%s">%s</a></pre>', $url, $url);
|
||||||
@ -267,7 +264,7 @@ function purge_files()
|
|||||||
// send a ShareX custom uploader config as .json
|
// send a ShareX custom uploader config as .json
|
||||||
function send_sharex_config()
|
function send_sharex_config()
|
||||||
{
|
{
|
||||||
global $HTTP_PROTO;
|
global $SITE_URL;
|
||||||
$host = $_SERVER["HTTP_HOST"];
|
$host = $_SERVER["HTTP_HOST"];
|
||||||
$filename = $host.".sxcu";
|
$filename = $host.".sxcu";
|
||||||
$content = <<<EOT
|
$content = <<<EOT
|
||||||
@ -275,7 +272,7 @@ function send_sharex_config()
|
|||||||
"Name": "$host",
|
"Name": "$host",
|
||||||
"DestinationType": "ImageUploader, FileUploader",
|
"DestinationType": "ImageUploader, FileUploader",
|
||||||
"RequestType": "POST",
|
"RequestType": "POST",
|
||||||
"RequestURL": "$HTTP_PROTO://$host/",
|
"RequestURL": "$SITE_URL",
|
||||||
"FileFormName": "file",
|
"FileFormName": "file",
|
||||||
"ResponseType": "Text"
|
"ResponseType": "Text"
|
||||||
}
|
}
|
||||||
@ -289,14 +286,14 @@ EOT;
|
|||||||
// send a Hupl uploader config as .hupl (which is just JSON)
|
// send a Hupl uploader config as .hupl (which is just JSON)
|
||||||
function send_hupl_config()
|
function send_hupl_config()
|
||||||
{
|
{
|
||||||
global $HTTP_PROTO;
|
global $SITE_URL;
|
||||||
$host = $_SERVER["HTTP_HOST"];
|
$host = $_SERVER["HTTP_HOST"];
|
||||||
$filename = $host.".hupl";
|
$filename = $host.".hupl";
|
||||||
$content = <<<EOT
|
$content = <<<EOT
|
||||||
{
|
{
|
||||||
"name": "$host",
|
"name": "$host",
|
||||||
"type": "http",
|
"type": "http",
|
||||||
"targetUrl": "$HTTP_PROTO://$host/",
|
"targetUrl": "$SITE_URL",
|
||||||
"fileParam": "file"
|
"fileParam": "file"
|
||||||
}
|
}
|
||||||
EOT;
|
EOT;
|
||||||
@ -311,15 +308,14 @@ EOT;
|
|||||||
function print_index()
|
function print_index()
|
||||||
{
|
{
|
||||||
global $ADMIN_EMAIL;
|
global $ADMIN_EMAIL;
|
||||||
global $HTTP_PROTO;
|
global $SITE_URL;
|
||||||
global $MAX_FILEAGE;
|
global $MAX_FILEAGE;
|
||||||
global $MAX_FILESIZE;
|
global $MAX_FILESIZE;
|
||||||
global $MIN_FILEAGE;
|
global $MIN_FILEAGE;
|
||||||
global $DECAY_EXP;
|
global $DECAY_EXP;
|
||||||
|
|
||||||
$url = $HTTP_PROTO."://".$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
|
$sharex_url = $SITE_URL."?sharex";
|
||||||
$sharex_url = $url."?sharex";
|
$hupl_url = $SITE_URL."?hupl";
|
||||||
$hupl_url = $url."?hupl";
|
|
||||||
|
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
Loading…
Reference in New Issue
Block a user