]> jfr.im git - uguu.git/blobdiff - api.php
Merge pull request #3 from nixxquality/nixxquality-patch-1
[uguu.git] / api.php
diff --git a/api.php b/api.php
index b867dfc6f2064cc972a95c563523af99968b529a..8b2a78d7ac75ea0608db24430ab838f05d040259 100644 (file)
--- a/api.php
+++ b/api.php
@@ -1,27 +1,31 @@
 <?php
+//If the value d doesn't exist, redirect back to front page *1
 if(isset($_GET['d'])) {
-    include_once('core.php');
+    //Include the core file with the functions
+    include_once('includes/core.php');
     switch ($_GET['d']) {
-
         case 'upload':
+        //Set the name value to the original filename
        $name = $_FILES['file']['name'];
-       
+       $arg = 'custom_original';
+       //If the value name contains a custom name, set the name value
        if(!empty($_POST['name'])){
        $name = $_POST['name'];}
-       
-       save_file($_FILES['file']['tmp_name'], $name);
+       //If value contains anything, keep original filename
+       if(!empty($_POST['randomname'])){
+        $name = $_FILES['file']['name'];
+       $arg = 'random';}
+       //Call the save function which sends the file+name
+       save_file($_FILES['file']['tmp_name'], $name, $arg);
        break;
-       
-        case 'upload-sharex':
-
-        break;
-
         case 'extend-time':
             break;
        default:
+       //If no correct valid argument for the api to perform on, tell them to enter a valid one
        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{
-    exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload');
+    //*1
+    header('Location: index.html');
 }