]> git.p6c8.net - jirafeau_mojo42.git/blobdiff - script.php
fix: favicon location
[jirafeau_mojo42.git] / script.php
index 3f7d2f7205b356c6ef609b393129d427cc8aa67c..600b1d5cc9f702955a9a1d558e27fc1ef3cf0612 100644 (file)
@@ -25,8 +25,8 @@ require(JIRAFEAU_ROOT . 'lib/settings.php');
 require(JIRAFEAU_ROOT . 'lib/functions.php');
 require(JIRAFEAU_ROOT . 'lib/lang.php');
 
 require(JIRAFEAU_ROOT . 'lib/functions.php');
 require(JIRAFEAU_ROOT . 'lib/lang.php');
 
- global $script_langages;
- $script_langages = array('bash' => 'Bash');
+global $script_langages;
+$script_langages = array('bash' => 'Bash');
 
 /* Operations may take a long time.
  * Be sure PHP's safe mode is off.
 
 /* Operations may take a long time.
  * Be sure PHP's safe mode is off.
@@ -62,23 +62,34 @@ if (has_error()) {
     exit;
 }
 
     exit;
 }
 
+session_start();
+
 /* Upload file */
 if (isset($_FILES['file']) && is_writable(VAR_FILES)
     && is_writable(VAR_LINKS)) {
 /* Upload file */
 if (isset($_FILES['file']) && is_writable(VAR_FILES)
     && is_writable(VAR_LINKS)) {
-    if (isset ($_POST['upload_password'])) {
-        if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
+    if (!jirafeau_user_session_logged()) {
+        if (isset($_POST['upload_password']) &&
+            !jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
             echo 'Error 3: Invalid password';
             exit;
             echo 'Error 3: Invalid password';
             exit;
-        }
-    } else {
-        if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), null)) {
+        } elseif (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), null)) {
             echo 'Error 2: No password nor allowed IP';
             exit;
         }
     }
             echo 'Error 2: No password nor allowed IP';
             exit;
         }
     }
+
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
+        if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){
+            if (!preg_match($cfg['download_password_policy_regex'], $key)){
+                echo 'Error 14: The download password is not complying to the security standards.';
+                exit;
+            }
+        }
+    }elseif ($cfg['download_password_requirement'] !== 'optional'){
+        echo 'Error 13: The parameter password is required.';
+        exit;
     }
 
     $time = time();
     }
 
     $time = time();
@@ -99,6 +110,9 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
             case 'week':
                 $time += JIRAFEAU_WEEK;
                 break;
             case 'week':
                 $time += JIRAFEAU_WEEK;
                 break;
+            case 'fortnight':
+                $time += JIRAFEAU_FORTNIGHT;
+                break;
             case 'month':
                 $time += JIRAFEAU_MONTH;
                 break;
             case 'month':
                 $time += JIRAFEAU_MONTH;
                 break;
@@ -108,7 +122,7 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
             case 'year':
                 $time += JIRAFEAU_YEAR;
                 break;
             case 'year':
                 $time += JIRAFEAU_YEAR;
                 break;
-           default:
+            default:
                 $time = JIRAFEAU_INFINITY;
                 break;
         }
                 $time = JIRAFEAU_INFINITY;
                 break;
         }
@@ -127,11 +141,22 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         exit;
     }
 
         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']);
+    if ($cfg['store_uploader_ip']) {
+        $ip = get_ip_address($cfg);
+    } else {
+        $ip = "";
+    }
+
+    $res = jirafeau_upload(
+        $_FILES['file'],
+        isset($_POST['one_time_download']),
+        $key,
+        $time,
+        $ip,
+        $cfg['enable_crypt'],
+        $cfg['link_name_length'],
+        $cfg['file_hash']
+    );
 
     if (empty($res) || $res['error']['has_error']) {
         echo 'Error 6 ' . $res['error']['why'];
 
     if (empty($res) || $res['error']['has_error']) {
         echo 'Error 6 ' . $res['error']['why'];
@@ -150,6 +175,15 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
+        if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){
+            if (!preg_match($cfg['download_password_policy_regex'], $key)){
+                echo 'Error 14: The download password is not complying to the security standards.';
+                exit;
+            }
+        }
+    }elseif ($cfg['download_password_requirement'] !== 'optional'){
+        echo 'Error 13: The parameter password is required.';
+        exit;
     }
     $d = '';
     if (isset($_GET['d'])) {
     }
     $d = '';
     if (isset($_GET['d'])) {
@@ -246,8 +280,8 @@ if [ -n "$JIRAFEAU_ONE_TIME" ]; then
     one_time='1'
 fi
 
     one_time='1'
 fi
 
-if [ -n "$UPLOAD_PASSWD" ]; then
-    upload_password="$JIRAFEAU_UPLOAD_PASSWORD"
+if [ -n "$JIRAFEAU_UPLOAD_PASSWD" ]; then
+    upload_password="$JIRAFEAU_UPLOAD_PASSWD"
 fi
 
 if [ -z "$curl" ]; then
 fi
 
 if [ -z "$curl" ]; then
@@ -279,9 +313,9 @@ if [ -z "$2" ]; then
     echo "    $0 delete URL"
     echo
     echo "Global variables to export:"
     echo "    $0 delete URL"
     echo
     echo "Global variables to export:"
-    echo "    JIRAFEAU_PROXY: Domain and port of proxy server, eg. »proxysever.example.com:3128«"
+    echo "    JIRAFEAU_PROXY: Domain and port of proxy server, eg. »proxyserver.example.com:3128«"
     echo "    JIRAFEAU_URL : URI to Jirafeau installation with trailing slash, eg. »https://example.com/jirafeau/«"
     echo "    JIRAFEAU_URL : URI to Jirafeau installation with trailing slash, eg. »https://example.com/jirafeau/«"
-    echo "    JIRAFEAU_TIME : expiration time, eg. »minute«, »hour«, »day«, »week«, »month«, »quarter«, »year« or »none«"
+    echo "    JIRAFEAU_TIME : expiration time, eg. »minute«, »hour«, »day«, »week«, fortnight, »month«, »quarter«, »year« or »none«"
     echo "    JIRAFEAU_ONE_TIME : self-destroy after first download, eg. »1« to enable or »« (empty) to disable"
     echo "    JIRAFEAU_CURL : alternative path to curl binary"
     echo "    JIRAFEAU_UPLOAD_PASSWD : upload password"
     echo "    JIRAFEAU_ONE_TIME : self-destroy after first download, eg. »1« to enable or »« (empty) to disable"
     echo "    JIRAFEAU_CURL : alternative path to curl binary"
     echo "    JIRAFEAU_UPLOAD_PASSWD : upload password"
@@ -367,12 +401,12 @@ if [ "$1" == "send" ]; then
     echo
     echo "Download via API:"
     if [[ $key_code ]]; then
     echo
     echo "Download via API:"
     if [[ $key_code ]]; then
-        echo "    ${0} get ${url}${apipage}?h=$code&k=$key_code [PASSWORD}"
+        echo "    ${0} get ${url}${apipage}?h=$code&k=$key_code [PASSWORD]"
     else
     else
-        echo "    ${0} get ${url}${apipage}?h=$code [PASSWORD}"
+        echo "    ${0} get ${url}${apipage}?h=$code [PASSWORD]"
     fi
     echo "Delete via API:"
     fi
     echo "Delete via API:"
-    echo "    ${0} delete ${url}${downloadpage}?h=$code&d=$del_code"
+    echo "    ${0} delete \"${url}${downloadpage}?h=$code&d=$del_code\""
 
 elif [ "$1" == "get" ]; then
     if [ -z "$password" ]; then
 
 elif [ "$1" == "get" ]; then
     if [ -z "$password" ]; then
@@ -381,10 +415,9 @@ elif [ "$1" == "get" ]; then
         $curl $proxy -OJ -X POST -F key=$password "$2"
     fi
 elif [ "$1" == "delete" ]; then
         $curl $proxy -OJ -X POST -F key=$password "$2"
     fi
 elif [ "$1" == "delete" ]; then
-    $curl $proxy "$2"
+    $curl $proxy "$2" --data-raw "do_delete=1%2F" | grep "div class" |sed -e "s/<[^>]\+>//g"
 fi
 <?php
 fi
 <?php
-
     } else {
         echo 'Error 12';
         exit;
     } else {
         echo 'Error 12';
         exit;
@@ -392,7 +425,8 @@ fi
 }
 /* Initialize an asynchronous upload. */
 elseif (isset($_GET['init_async'])) {
 }
 /* Initialize an asynchronous upload. */
 elseif (isset($_GET['init_async'])) {
-    if (isset($_POST['upload_password'])){
+    if (jirafeau_user_session_logged()) {
+    } elseif (isset($_POST['upload_password'])) {
         if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
             echo 'Error 20: Invalid password';
             exit;
         if (!jirafeau_challenge_upload($cfg, get_ip_address($cfg), $_POST['upload_password'])) {
             echo 'Error 20: Invalid password';
             exit;
@@ -417,6 +451,15 @@ elseif (isset($_GET['init_async'])) {
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
     $key = '';
     if (isset($_POST['key'])) {
         $key = $_POST['key'];
+        if ($cfg['download_password_requirement'] !== 'generated' && $cfg['download_password_policy'] === 'regex'){
+            if (!preg_match($cfg['download_password_policy_regex'], $key)){
+                echo 'Error 14: The download password is not complying to the security standards.';
+                exit;
+            }
+        }
+    }elseif ($cfg['download_password_requirement'] !== 'optional'){
+        echo 'Error 13: The parameter password is required.';
+        exit;
     }
 
     // Check if one time download is enabled
     }
 
     // Check if one time download is enabled
@@ -443,6 +486,9 @@ elseif (isset($_GET['init_async'])) {
             case 'week':
                 $time += JIRAFEAU_WEEK;
                 break;
             case 'week':
                 $time += JIRAFEAU_WEEK;
                 break;
+            case 'fortnight':
+                $time += JIRAFEAU_FORTNIGHT;
+                break;
             case 'month':
                 $time += JIRAFEAU_MONTH;
                 break;
             case 'month':
                 $time += JIRAFEAU_MONTH;
                 break;
@@ -457,12 +503,21 @@ elseif (isset($_GET['init_async'])) {
                 break;
         }
     }
                 break;
         }
     }
-    echo jirafeau_async_init($_POST['filename'],
-                              $type,
-                              isset($_POST['one_time_download']),
-                              $key,
-                              $time,
-                              get_ip_address($cfg));
+
+    if ($cfg['store_uploader_ip']) {
+        $ip = get_ip_address($cfg);
+    } else {
+        $ip = "";
+    }
+
+    echo jirafeau_async_init(
+        $_POST['filename'],
+        $type,
+        isset($_POST['one_time_download']),
+        $key,
+        $time,
+        $ip
+    );
 }
 /* Continue an asynchronous upload. */
 elseif (isset($_GET['push_async'])) {
 }
 /* Continue an asynchronous upload. */
 elseif (isset($_GET['push_async'])) {
@@ -471,10 +526,12 @@ elseif (isset($_GET['push_async'])) {
         || (!isset($_POST['code']))) {
         echo 'Error 23';
     } else {
         || (!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. */
     }
 }
 /* Finalize an asynchronous upload. */

patrick-canterino.de