sendError(400); } if ($_GET["share"] === "submit") { if (empty($_POST["files"]) || is_array($_POST["files"]) === false) { sendError(400); } $pathID = Access::verifyCurrentPathAccess(); $shareID = loadPicFile("helpers/share/submit.php", array("pathID" => $pathID, "files" => $_POST["files"])); if (!$shareID) { sendError(500); } header("Content-type: text/plain"); echo $shareID; } elseif ($_GET["share"] === "receive") { if (empty($_POST["shareID"])) { sendError(400); } $decodedShareID = loadPicFile("helpers/share/receive.php", array("shareID" => $_POST["shareID"])); if (!$decodedShareID) { sendError(404); } list($pathID, $files) = $decodedShareID; $allowedPaths = Access::getAllowedPaths(); if (!isset($allowedPaths[$pathID])) { sendError(404); } header("Content-type: application/json"); echo json_encode(array("path" => $pathID, "files" => $files)); } else { sendError(404); }
<?php if (empty($_POST)) { $appConf = loadPicFile("conf/app.json"); $pathSelect = PicDB::newSelect(); $pathSelect->cols(array("id", "name"))->from("paths")->where("id IN (:ids)")->bindValue("ids", Access::getAllowedPaths()); $templateVars = array("paths" => PicDB::fetch($pathSelect, "pairs"), "imageSizes" => $appConf["image_sizes"]); if (isset($appConf["mapbox"])) { $templateVars["mapboxConf"] = $appConf["mapbox"]; } loadPicTemplate("templates/filebrowser.phtml", $templateVars); exit; } $path = Access::getCurrentPath(); if (!empty($_POST["relpath"])) { $relpath = loadPicFile("helpers/filenamereject.php", array("filename" => $_POST["relpath"])); if (!is_dir($path->path . "/" . $relpath)) { sendError(404); } } use Symfony\Component\Finder\Finder; $directoryFinder = new Finder(); $directoryFinder->directories()->ignoreUnreadableDirs()->depth(0)->sortByName(); if ($path->hasPermission("symlinks")) { $directoryFinder->followLinks(); } if (!empty($relpath)) { $directoryFinder->path($relpath)->depth(substr_count($relpath, "/") + 1); } if ($path->hasPermission("nsfw") === false) { $directoryFinder->notPath("/.*\\/NSFW\\/.*/")->notPath("/NSFW\\/.*/")->notPath("/.*\\/NSFW/");