]> jfr.im git - uguu.git/blame - api.php
Update README.md
[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']) {
78b2d83e 7 case 'upload':
3c944009
GJ
8 //If no file is being posted, exit
9 if(empty($_FILES['file'])){
10 exit('You fucked up, nothing to do.');}
362ed96d 11 //Set the name value to the original filename
f6de5bc0 12 $name = $_FILES['file']['name'];
64c27042 13 $arg = 'custom_original';
362ed96d 14 //If the value name contains a custom name, set the name value
f6de5bc0 15 if(!empty($_POST['name'])){
ff3c1102 16 $name = $_POST['name'];}
b628f750 17 //If value contains anything, keep original filename
0f429b06
GJ
18 if(!empty($_POST['randomname'])){
19 $name = $_FILES['file']['name'];
64c27042 20 $arg = 'random';}
362ed96d 21 //Call the save function which sends the file+name
0f429b06 22 save_file($_FILES['file']['tmp_name'], $name, $arg);
f6de5bc0 23 break;
78b2d83e
GJ
24 case 'extend-time':
25 break;
26 default:
362ed96d 27 //If no correct valid argument for the api to perform on, tell them to enter a valid one
78b2d83e
GJ
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{
362ed96d 32 //*1
6e46f9b0 33 header('Location: index.html');
78b2d83e 34}