2015-02-04 19:21:50 +00:00
|
|
|
<?php
|
2016-05-14 08:55:50 +00:00
|
|
|
//Loading configuration file
|
|
|
|
require_once "includes/config.php";
|
|
|
|
|
2015-02-07 18:59:25 +00:00
|
|
|
//If the value d doesn't exist, redirect back to front page *1
|
2015-02-04 19:21:50 +00:00
|
|
|
if(isset($_GET['d'])) {
|
2015-02-07 18:59:25 +00:00
|
|
|
//Include the core file with the functions
|
2016-05-14 08:55:50 +00:00
|
|
|
include_once(CONFIG_ROOT_PATH.'includes/core.php');
|
2015-02-04 19:21:50 +00:00
|
|
|
switch ($_GET['d']) {
|
2015-10-07 20:53:11 +00:00
|
|
|
//Uploading with HTML response and errors
|
2015-02-04 19:21:50 +00:00
|
|
|
case 'upload':
|
2015-10-05 17:18:37 +00:00
|
|
|
//If no file is being posted, show the error page and exit.
|
2015-02-23 18:12:20 +00:00
|
|
|
if(empty($_FILES['file']['name'])){
|
2016-05-14 08:55:50 +00:00
|
|
|
include_once(CONFIG_ROOT_PATH.'error.php');
|
2015-10-05 17:18:37 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2015-02-07 18:59:25 +00:00
|
|
|
//Set the name value to the original filename
|
2015-02-07 18:19:38 +00:00
|
|
|
$name = $_FILES['file']['name'];
|
2015-02-11 16:29:54 +00:00
|
|
|
$arg = 'custom_original';
|
2015-02-07 18:59:25 +00:00
|
|
|
//If the value name contains a custom name, set the name value
|
2015-02-07 18:19:38 +00:00
|
|
|
if(!empty($_POST['name'])){
|
2015-02-07 18:20:34 +00:00
|
|
|
$name = $_POST['name'];}
|
2015-02-10 15:02:20 +00:00
|
|
|
//If value contains anything, keep original filename
|
2015-02-11 16:12:50 +00:00
|
|
|
if(!empty($_POST['randomname'])){
|
|
|
|
$name = $_FILES['file']['name'];
|
2015-02-11 16:29:54 +00:00
|
|
|
$arg = 'random';}
|
2015-02-07 18:59:25 +00:00
|
|
|
//Call the save function which sends the file+name
|
2015-10-07 20:53:11 +00:00
|
|
|
save_file($_FILES['file']['tmp_name'], $name, $arg, 'normal');
|
|
|
|
break;
|
|
|
|
//Uploading without HTML response or errors
|
|
|
|
case 'upload-tool':
|
|
|
|
//If no file is being posted, show the error page and exit.
|
|
|
|
if(empty($_FILES['file']['name'])){
|
|
|
|
exit('You did not send a file, try again.');
|
|
|
|
}
|
|
|
|
//Set the name value to the original filename
|
|
|
|
$name = $_FILES['file']['name'];
|
|
|
|
$arg = 'custom_original';
|
|
|
|
//If the value name contains a custom name, set the name value
|
|
|
|
if(!empty($_POST['name'])){
|
|
|
|
$name = $_POST['name'];}
|
|
|
|
//If value contains anything, keep original filename
|
|
|
|
if(!empty($_POST['randomname'])){
|
|
|
|
$name = $_FILES['file']['name'];
|
|
|
|
$arg = 'random';}
|
|
|
|
//Call the save function which sends the file+name
|
|
|
|
save_file($_FILES['file']['tmp_name'], $name, $arg, 'tool');
|
2015-02-07 18:19:38 +00:00
|
|
|
break;
|
2015-02-04 19:21:50 +00:00
|
|
|
case 'extend-time':
|
|
|
|
break;
|
|
|
|
default:
|
2015-02-07 18:59:25 +00:00
|
|
|
//If no correct valid argument for the api to perform on, tell them to enter a valid one
|
2016-05-14 08:55:50 +00:00
|
|
|
exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg '.CONFIG_ROOT_URL.'/api.php?d=upload-tool');
|
2015-02-04 19:21:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}else{
|
2015-02-07 18:59:25 +00:00
|
|
|
//*1
|
2015-02-11 02:35:02 +00:00
|
|
|
header('Location: index.html');
|
2015-02-04 19:21:50 +00:00
|
|
|
}
|