]> jfr.im git - uguu.git/blob - api.php
lol cache
[uguu.git] / api.php
1 <?php
2 //If the value d doesn't exist, redirect back to front page *1
3 if(isset($_GET['d'])) {
4 //Include the core file with the functions
5 include_once('includes/core.php');
6 switch ($_GET['d']) {
7 case 'upload':
8 //If no file is being posted, exit
9 if(empty($_FILES['file'])){
10 exit('You fucked up, nothing to do.');}
11 //Set the name value to the original filename
12 $name = $_FILES['file']['name'];
13 $arg = 'custom_original';
14 //If the value name contains a custom name, set the name value
15 if(!empty($_POST['name'])){
16 $name = $_POST['name'];}
17 //If value contains anything, keep original filename
18 if(!empty($_POST['randomname'])){
19 $name = $_FILES['file']['name'];
20 $arg = 'random';}
21 //Call the save function which sends the file+name
22 save_file($_FILES['file']['tmp_name'], $name, $arg);
23 break;
24 case 'extend-time':
25 break;
26 default:
27 //If no correct valid argument for the api to perform on, tell them to enter a valid one
28 exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
29 break;
30 }
31 }else{
32 //*1
33 header('Location: index.html');
34 }