Browse Source

[Web] Fix resource.php and /cache/ warning message

If http://mail.example.tld/cache/ or http://mail.example.tld/resource.php are called without the required parameters it returns one or two warnings
Vincent Simon 3 years ago
parent
commit
deac5ad2fe
1 changed files with 9 additions and 0 deletions
  1. 9 0
      data/web/resource.php

+ 9 - 0
data/web/resource.php

@@ -1,6 +1,15 @@
 <?php
 <?php
 
 
+if (!isset($_GET['file']) ) {
+    http_response_code(404);
+    exit;
+}
 $pathinfo = pathinfo($_GET['file']);
 $pathinfo = pathinfo($_GET['file']);
+
+if (!array_key_exists('extension', $pathinfo)) {
+    http_response_code(404);
+    exit;
+}
 $extension = strtolower($pathinfo['extension']);
 $extension = strtolower($pathinfo['extension']);
 
 
 $filepath = '/tmp/' . $pathinfo['basename'];
 $filepath = '/tmp/' . $pathinfo['basename'];