From d7442e00b8ee277938adaca3b83f814e0d67b432 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 20 Apr 2017 01:45:06 -0400 Subject: Add dynamic file proxy script Entry point df.php, meaning dynamic file or direct file, added as a means of serving user-supplied content while enforcing access-controls in PHP. --- app/df.php | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 app/df.php (limited to 'app/df.php') diff --git a/app/df.php b/app/df.php new file mode 100644 index 0000000..a425d57 --- /dev/null +++ b/app/df.php @@ -0,0 +1,102 @@ +objtype == "user") + return true; + + return $user->canAccess($obj); +} + +/* + * Respond to users' requests for dynamic files + */ +function main(string $dir, string $guid) : void +{ + try + { + if (basename($guid) != $guid || $guid == "") + return; + + if (!checkPermissions($guid, $dir == "heads")) + return; + + switch ($dir) + { + case "heads": + if (file_exists("dynmic/heads/" . $guid)) + serveResource("dynmic/heads/" . $guid); + else + serveResource("static/img/null.jpg"); + break; + + case "bgs": + serveResource("dynmic/bgs/" . $guid); + break; + } + } + catch (Exception $e) + { + /* fail silently */ + } +} + +main($_REQUEST['d'], $_REQUEST['f']); + +?> -- cgit v1.2.3