]> jfr.im git - uguu.git/blob - api.php
2f59766865f42711f545313548386fc30f4e4f1a
[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('core.php');
6 switch ($_GET['d']) {
7 case 'upload':
8 //Set the name value to the original filename
9 $name = $_FILES['file']['name'];
10 //If the value name contains a custom name, set the name value
11 if(!empty($_POST['name'])){
12 $name = $_POST['name'];}
13 //If value contains anything, keep original filename
14 if(!empty($_POST['originalname'])){
15 $name = $_FILES['file']['name'];}
16 //Remove any whitespace from name
17 $name = preg_replace('/\s+/', '', $name);
18 //Call the save function which sends the file+name
19 save_file($_FILES['file']['tmp_name'], $name);
20 break;
21 case 'extend-time':
22 break;
23 default:
24 //If no correct valid argument for the api to perform on, tell them to enter a valid one
25 exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
26 break;
27 }
28 }else{
29 //*1
30 header('Location: index.html);
31 }