thumb: prefix data path only for numeric roots
[minimedit.git] / thumb / index.php
index b49ca6ef47be6270f485de9509f1387a8fe6676a..5327192d0be49e85632679f256cacb5fa91b2306 100644 (file)
@@ -1,16 +1,16 @@
 <?php
 ob_clean();
 
-list ($height, $imgarg) = explode('/', ltrim($Args, '/'), 2);
+list ($height, $imgpath) = explode('/', ltrim($Args, '/'), 2);
 $width= 1000;
-$imgpath = "data/$imgarg";
+$imgpath = preg_replace('{^(?=[0-9]+/)}', 'data/', $imgpath, 1);
 
 if (!file_exists($imgpath)) {
        http_response_code(404);
        exit;
 }
 
-$target = preg_replace("{^data/}", "thumb/$height/", $imgpath, 1);
+$target = "thumb/$height/$imgpath";
 if (!file_exists($target)) {
        @mkdir(dirname($target), 0777, TRUE);