Uguu/api.php

35 lines
1.2 KiB
PHP
Raw Normal View History

2015-02-04 16:21:50 -03:00
<?php
2015-02-07 15:59:25 -03:00
//If the value d doesn't exist, redirect back to front page *1
2015-02-04 16:21:50 -03:00
if(isset($_GET['d'])) {
2015-02-07 15:59:25 -03:00
//Include the core file with the functions
2015-02-11 14:18:00 -03:00
include_once('includes/core.php');
2015-02-04 16:21:50 -03:00
switch ($_GET['d']) {
case 'upload':
2015-02-23 11:33:49 -03:00
//If no file is being posted, exit
if(empty($_FILES['file'])){
exit('You fucked up, nothing to do.');}
2015-02-07 15:59:25 -03:00
//Set the name value to the original filename
2015-02-07 15:19:38 -03:00
$name = $_FILES['file']['name'];
2015-02-11 13:29:54 -03:00
$arg = 'custom_original';
2015-02-07 15:59:25 -03:00
//If the value name contains a custom name, set the name value
2015-02-07 15:19:38 -03:00
if(!empty($_POST['name'])){
2015-02-07 15:20:34 -03:00
$name = $_POST['name'];}
2015-02-10 12:02:20 -03:00
//If value contains anything, keep original filename
2015-02-11 13:12:50 -03:00
if(!empty($_POST['randomname'])){
$name = $_FILES['file']['name'];
2015-02-11 13:29:54 -03:00
$arg = 'random';}
2015-02-07 15:59:25 -03:00
//Call the save function which sends the file+name
2015-02-11 13:12:50 -03:00
save_file($_FILES['file']['tmp_name'], $name, $arg);
2015-02-07 15:19:38 -03:00
break;
2015-02-04 16:21:50 -03:00
case 'extend-time':
break;
default:
2015-02-07 15:59:25 -03:00
//If no correct valid argument for the api to perform on, tell them to enter a valid one
2015-02-04 16:21:50 -03:00
exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
break;
}
}else{
2015-02-07 15:59:25 -03:00
//*1
2015-02-10 23:35:02 -03:00
header('Location: index.html');
2015-02-04 16:21:50 -03:00
}