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