]> git.p6c8.net - jirafeau_mojo42.git/blobdiff - script.php
[TASK] move docker CMD command to separate file
[jirafeau_mojo42.git] / script.php
index 695f6db13a54f4d740c008941b36d7496e9a477f..b8c4bcf10e92e0bce463ada017e7ecb875fa7608 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  *  Jirafeau, your web file repository
- *  Copyright (C) 2015  Jerome Jutteau <j.jutteau@gmail.com>
+ *  Copyright (C) 2015  Jerome Jutteau <jerome@jutteau.fr>
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU Affero General Public License as
  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-/*
- * This file permits to easyly script file sending, receiving, deleting, ...
- * If you don't want this feature, you can simply delete this file from your
- * web directory.
- */
+/* This file offer a kind of API for jirafeau. */
+
 define('JIRAFEAU_ROOT', dirname(__FILE__) . '/');
 
 require(JIRAFEAU_ROOT . 'lib/settings.php');
@@ -35,8 +32,6 @@ require(JIRAFEAU_ROOT . 'lib/lang.php');
  * Be sure PHP's safe mode is off.
  */
 @set_time_limit(0);
-/* Remove errors. */
-@error_reporting(0);
 
 if ($_SERVER['REQUEST_METHOD'] == "GET" && count($_GET) == 0) {
     require(JIRAFEAU_ROOT . 'lib/template/header.php');
@@ -70,7 +65,7 @@ if (has_error()) {
 /* Upload file */
 if (isset($_FILES['file']) && is_writable(VAR_FILES)
     && is_writable(VAR_LINKS)) {
-    if (isset ($_POST['upload_password'])) {
+    if (isset($_POST['upload_password'])) {
         if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
             echo 'Error 3: Invalid password';
             exit;
@@ -132,11 +127,16 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         exit;
     }
 
-    $res = jirafeau_upload($_FILES['file'],
-                           isset($_POST['one_time_download']),
-                           $key, $time, get_ip_address($cfg),
-                           $cfg['enable_crypt'], $cfg['link_name_length'],
-                           $cfg['file_hash']);
+    $res = jirafeau_upload(
+        $_FILES['file'],
+        isset($_POST['one_time_download']),
+        $key,
+        $time,
+        get_ip_address($cfg),
+        $cfg['enable_crypt'],
+        $cfg['link_name_length'],
+        $cfg['file_hash']
+    );
 
     if (empty($res) || $res['error']['has_error']) {
         echo 'Error 6 ' . $res['error']['why'];
@@ -201,7 +201,6 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
     $r = fopen(VAR_FILES . $p . $link['hash'], 'r');
     while (!feof($r)) {
         print fread($r, 1024);
-        ob_flush();
     }
     fclose($r);
 
@@ -304,7 +303,7 @@ if [ -n "$one_time" ]; then
     options="$options -F one_time_download=1"
 fi
 
-f [ -n "$upload_password" ]; then
+if [ -n "$upload_password" ]; then
     options="$options -F upload_password=$upload_password"
 fi
 
@@ -390,7 +389,6 @@ elif [ "$1" == "delete" ]; then
     $curl $proxy "$2"
 fi
 <?php
-
     } else {
         echo 'Error 12';
         exit;
@@ -398,7 +396,7 @@ fi
 }
 /* Initialize an asynchronous upload. */
 elseif (isset($_GET['init_async'])) {
-    if (isset($_POST['upload_password'])){
+    if (isset($_POST['upload_password'])) {
         if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
             echo 'Error 20: Invalid password';
             exit;
@@ -463,12 +461,14 @@ elseif (isset($_GET['init_async'])) {
                 break;
         }
     }
-    echo jirafeau_async_init($_POST['filename'],
-                              $type,
-                              isset($_POST['one_time_download']),
-                              $key,
-                              $time,
-                              get_ip_address($cfg));
+    echo jirafeau_async_init(
+        $_POST['filename'],
+        $type,
+        isset($_POST['one_time_download']),
+        $key,
+        $time,
+        get_ip_address($cfg)
+    );
 }
 /* Continue an asynchronous upload. */
 elseif (isset($_GET['push_async'])) {
@@ -477,10 +477,12 @@ elseif (isset($_GET['push_async'])) {
         || (!isset($_POST['code']))) {
         echo 'Error 23';
     } else {
-        echo jirafeau_async_push($_POST['ref'],
-                                  $_FILES['data'],
-                                  $_POST['code'],
-                                  $cfg['maximal_upload_size']);
+        echo jirafeau_async_push(
+            $_POST['ref'],
+            $_FILES['data'],
+            $_POST['code'],
+            $cfg['maximal_upload_size']
+        );
     }
 }
 /* Finalize an asynchronous upload. */

patrick-canterino.de