]> jfr.im git - uguu.git/blame - api.php
Delete tools.txt
[uguu.git] / api.php
CommitLineData
78b2d83e 1<?php
2f98035a
PAB
2//Loading configuration file
3require_once "includes/config.php";
4
362ed96d 5//If the value d doesn't exist, redirect back to front page *1
78b2d83e 6if(isset($_GET['d'])) {
362ed96d 7 //Include the core file with the functions
2f98035a 8 include_once(CONFIG_ROOT_PATH.'includes/core.php');
78b2d83e 9 switch ($_GET['d']) {
f6df8f51 10 //Uploading with HTML response and errors
78b2d83e 11 case 'upload':
0591f08b 12 //If no file is being posted, show the error page and exit.
09b91eae 13 if(empty($_FILES['file']['name'])){
2f98035a 14 include_once(CONFIG_ROOT_PATH.'error.php');
0591f08b
JD
15 exit(0);
16 }
362ed96d 17 //Set the name value to the original filename
f6de5bc0 18 $name = $_FILES['file']['name'];
64c27042 19 $arg = 'custom_original';
362ed96d 20 //If the value name contains a custom name, set the name value
f6de5bc0 21 if(!empty($_POST['name'])){
ff3c1102 22 $name = $_POST['name'];}
b628f750 23 //If value contains anything, keep original filename
0f429b06
GJ
24 if(!empty($_POST['randomname'])){
25 $name = $_FILES['file']['name'];
64c27042 26 $arg = 'random';}
362ed96d 27 //Call the save function which sends the file+name
f6df8f51
GJ
28 save_file($_FILES['file']['tmp_name'], $name, $arg, 'normal');
29 break;
30 //Uploading without HTML response or errors
31 case 'upload-tool':
32 //If no file is being posted, show the error page and exit.
33 if(empty($_FILES['file']['name'])){
34 exit('You did not send a file, try again.');
35 }
36 //Set the name value to the original filename
37 $name = $_FILES['file']['name'];
38 $arg = 'custom_original';
39 //If the value name contains a custom name, set the name value
40 if(!empty($_POST['name'])){
41 $name = $_POST['name'];}
42 //If value contains anything, keep original filename
43 if(!empty($_POST['randomname'])){
44 $name = $_FILES['file']['name'];
45 $arg = 'random';}
46 //Call the save function which sends the file+name
47 save_file($_FILES['file']['tmp_name'], $name, $arg, 'tool');
f6de5bc0 48 break;
78b2d83e
GJ
49 case 'extend-time':
50 break;
51 default:
362ed96d 52 //If no correct valid argument for the api to perform on, tell them to enter a valid one
2f98035a 53 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');
78b2d83e
GJ
54 break;
55 }
56}else{
362ed96d 57 //*1
6e46f9b0 58 header('Location: index.html');
78b2d83e 59}