Преглед изворни кода

[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 година
родитељ
комит
deac5ad2fe
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      data/web/resource.php

+ 9 - 0
data/web/resource.php

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