<?php $action = $_GET['action']; /* ************************* Actions ************************* */ if ($action == 'listdirectory') { $directory = base64_decode($_GET['directory']); $data = ListDirectory($directory); $data = SortFiles($data); echo json_encode($data); } if ($action == 'path') { $directory = base64_decode($_GET['directory']); $base = base64_decode($_GET['base']); $data = GetPath($base, $directory); echo json_encode($data); } if ($action == 'download') { $file = base64_decode($_GET['file']); DownloadFile($file); } if ($action == 'delete') { $file = base64_decode($_GET['file']); echo DeleteFile($file); } if ($action == 'newdir') { $curdir = base64_decode($_GET['curdir']); $name = base64_decode($_GET['name']); echo NewDir($curdir, $name); } if ($action == 'rename') { $oldname = base64_decode($_GET['old']);
if (is_file($path)) { AnalyzeFile($path); } echo "</body>\n</html>"; } elseif (array_key_exists('id', $_REQUEST) && strlen($_REQUEST['id']) && ctype_alnum($_REQUEST['id'])) { echo "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n"; $path = GetPath(trim($_REQUEST['id'])); if (is_file($path)) { AnalyzeFile($path); } else { echo "Invalid ID"; } echo "</body>\n</html>"; } elseif (array_key_exists('imgfile', $_FILES) && array_key_exists('tmp_name', $_FILES['imgfile']) && is_file($_FILES['imgfile']['tmp_name'])) { $id = sha1(file_get_contents($_FILES['imgfile']['tmp_name'])); $path = GetPath($id); if (!is_file($path)) { $dir = dirname($path); if (!is_dir($dir)) { mkdir($dir, 0777, true); } move_uploaded_file($_FILES['imgfile']['tmp_name'], $path); } $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http'; header("Location: {$protocol}://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?id={$id}"); } else { echo "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n"; echo "No image file provided"; echo "</body>\n</html>"; } function GetPath($id)
$backUrl .= $back[$i] . "/"; } $backUrl = rtrim($backUrl, "/"); $html .= " <a class=\"btn btn-default btn-sm\" onclick=\"getFolderPath('" . $backUrl . "')\"><i class=\"fa fa-level-up\"></i> Up</a>"; } $html .= "</td><td class=\"text-right\" colspan=\"4\">"; // path $html .= "<i class=\"fa fa-home\"></i> "; if ($_POST["path"] == "") { $html .= "/"; } else { $html .= $_POST["path"]; } $html .= "</td></tr>"; // get files/folders $html .= GetPath($_POST["path"]) . "</table>"; system\Helper::arcReturnJSON(["html" => $html]); } function GetPath($path) { $fullPath = system\Helper::arcGetPath(true) . "assets/" . $path . "/"; $webPath = system\Helper::arcGetPath() . "assets" . $path; $files = scandir($fullPath); $html = ""; foreach ($files as $file) { if ($file != "." && $file != "..") { $html .= "<tr>" . "<td style=\"width: 10px;\"><input type=\"checkbox\" id=\"{$file}\" onchange=\"mark('{$path}/{$file}')\"><label for=\"{$file}\"></label></td>"; if (is_dir($fullPath . $file)) { // folder $fi = new FilesystemIterator($fullPath . $file, FilesystemIterator::SKIP_DOTS); $html .= "<td><i class=\"fa fa-folder-o\"></i> <a class=\"clickable\" onclick=\"getFolderPath('{$path}/{$file}')\">{$file}</a></td>" . "<td style=\"width: 10px;\">folder</td>" . "<td style=\"width: 10px;\">-</td>" . "<td style=\"width: 100px;\">" . iterator_count($fi) . ngettext(" item", " items", iterator_count($fi)) . "</td>" . "<td style=\"width: 100px;\">" . date("d M Y", filectime($fullPath . $file)) . "</td>";
* PHP Version 5 * * @package WhoseCode * @copyright PHPDetroit 2012 * @license MIT (license.txt) */ // Turn on output buffering ob_start(); // Define environment if ($_SERVER['SERVER_NAME'] == 'localhost') { define("ENVIRONMENT", "development"); } else { define("ENVIRONMENT", "production"); } // Get library include 'library/functions.core.php'; // Get task $Path = GetPath(); switch ($Path) { case 'index': $include = 'templates/index.html.php'; break; default: header('HTTP/1.0 404 Not Found'); exit('Uh, oh! Page not found.'); } include 'templates/header.html.php'; include $include; include 'templates/footer.html.php'; // Flush the output buffer ob_end_flush();