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