2.4.3 — Tinyfilemanager
if (!$readonly) if ($action === 'mkdir' && isset($_POST['name'])) $newdir = $full_path . '/' . basename($_POST['name']); if (!file_exists($newdir)) mkdir($newdir, 0755);
// Show or hide hidden files (dot files) $show_hidden_files = false;
?> </div>
exit;
// Allowed extensions (empty = all) $allowed_extensions = array( 'jpg','jpeg','png','gif','pdf','txt','doc','docx','xls','xlsx', 'zip','tar','gz','mp3','mp4','php','html','css','js' );
if ($full_path === false || strpos($full_path, $root_path) !== 0) $full_path = $root_path; $current_path = '';
// Read-only users $read_only_users = array('user'); tinyfilemanager 2.4.3
// ============================================= // DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU DO // =============================================
<?php // TinyFileManager 2.4.3 // https://github.com/prasathmani/tinyfilemanager // Released under MIT License session_name('filemanager'); session_start();
// Root path for file manager $root_path = $_SERVER['DOCUMENT_ROOT']; $_GET['path'] : ''; $full_path = $root_path
<?php if (!$readonly): ?> <div class="upload-area"> <form method="post" enctype="multipart/form-data" id="uploadForm"> <input type="file" name="file" id="fileInput"> <button type="submit">Upload</button> </form> <form method="post" style="margin-top: 10px;"> <input type="hidden" name="action" value="mkdir"> <input type="text" name="name" placeholder="New folder name" required> <button type="submit">Create Folder</button> </form> </div> <?php endif; ?>
if ($action === 'delete' && isset($_POST['file'])) $target = $full_path . '/' . basename($_POST['file']); if (is_file($target)) unlink($target); if (is_dir($target)) array_map('unlink', glob($target . '/*')) && rmdir($target);
// Simple auth check function auth($users, $read_only_users = array()) if (!isset($_SESSION['loggedin'])) if (isset($_SERVER['PHP_AUTH_USER']) && isset($users[$_SERVER['PHP_AUTH_USER']])) $pass = $_SERVER['PHP_AUTH_PW']; $hash = $users[$_SERVER['PHP_AUTH_USER']]; if (password_verify($pass, $hash)) $_SESSION['loggedin'] = $_SERVER['PHP_AUTH_USER']; $_SESSION['readonly'] = in_array($_SERVER['PHP_AUTH_USER'], $read_only_users); return true; $_GET['path'] : ''
function list_directory($path, $show_hidden) $files = scandir($path); $result = array('dirs' => array(), 'files' => array()); foreach ($files as $file) if ($file === '.' sort($result['dirs']); sort($result['files']); return $result;
// Main logic $current_path = isset($_GET['path']) ? $_GET['path'] : ''; $full_path = $root_path . '/' . ltrim($current_path, '/'); $full_path = realpath($full_path);