PHP Code Editor
<?php /** * AI Chat Studio v1.3.4 - NUCLEAR CLEANUP FIX * Feature: Hard-Path Unlink, Session Persistence, Base64 Shield * Status: MASTER BASE CODE v1.3.4 */ session_start(); error_reporting(E_ALL); ini_set('display_errors', 0); $session_id = session_id(); $dbFile = 'db/sess_' . $session_id . '.json'; $downloadDir = 'downloads/'; // --- HELPER DATABASE --- function getHistory($file) { if (!file_exists($file)) return []; $data = json_decode(file_get_contents($file), true); return is_array($data) ? $data : []; } function saveHistory($file, $data) { if (!file_exists('db/')) @mkdir('db/', 0777, true); $history = getHistory($file); $history[] = array_merge(['timestamp' => date('Y-m-d H:i:s')], $data); file_put_contents($file, json_encode($history, JSON_PRETTY_PRINT)); } // --- ACTION: NEW CHAT (FIXED ABSOLUTE PHYSICAL CLEANUP) --- if (isset($_GET['action']) && $_GET['action'] == 'new_chat') { $history = getHistory($dbFile); foreach ($history as $item) { // Pastikan kita hanya menghapus item bertipe image yang punya path if (isset($item['type']) && $item['type'] === 'image' && !empty($item['content'])) { // Gunakan __DIR__ untuk path absolut yang tidak terbantahkan $absolutePath = __DIR__ . DIRECTORY_SEPARATOR . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $item['content']); if (file_exists($absolutePath)) { @chmod($absolutePath, 0777); // Paksa ijin akses @unlink($absolutePath); // Eksekusi penghapusan fisik } } } // Hapus file database session if (file_exists($dbFile)) @unlink($dbFile); session_regenerate_id(true); header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } // --- ACTION: CHAT API --- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['action']) && $_GET['action'] == 'chat') { header('Content-Type: application/json'); $input = json_decode(file_get_contents('php://input'), true); $message = strtolower($input['message'] ?? ''); saveHistory($dbFile, ['role' => 'user', 'content' => $input['message'], 'type' => 'text']); if (preg_match('/(gambar|foto|draw|image|lukis)/', $message)) { $cleanPrompt = trim(str_replace(['buatkan', 'gambar', 'foto', 'tolong'], '', $message)); // ATOMIC SUBDOMAIN LOCK $sub = "image"; $dom = "pollinations.ai"; $target = "https://" . $sub . "." . $dom . "/prompt/" . urlencode($cleanPrompt) . "?nologo=true&seed=" . rand(1, 99999); if (!file_exists($downloadDir)) @mkdir($downloadDir, 0777, true); $localPath = $downloadDir . 'ai_' . time() . '_' . rand(10,99) . '.jpg'; $ch = curl_init($target); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 40, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, CURLOPT_USERAGENT => 'Mozilla/5.0' ]); $imgData = curl_exec($ch); curl_close($ch); if ($imgData && strlen($imgData) > 5000) { file_put_contents($localPath, $imgData); $res = ['type' => 'image', 'content' => $localPath, 'text' => 'Visual Hunter Berhasil.', 'provider' => 'v1.3.4']; } else { $res = ['type' => 'text', 'content' => 'Gagal mengunduh gambar fisik.', 'provider' => 'System']; } } else { $res = ['type' => 'text', 'content' => 'Pesan teks diterima.', 'provider' => 'v1.3.4']; } saveHistory($dbFile, array_merge(['role' => 'bot'], $res)); echo json_encode($res); exit; } ?> <!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <title>AI Studio v1.3.4 - Nuclear Cleanup</title> <script> const b1 = "aHR0cHM6Ly9jZG4udGFpbHdpbmRjc3MuY29t"; const b2 = "aHR0cHM6Ly91bnBrZy5jb20vbHVjaWRlQGxhdGVzdA=="; function inj(b) { const s = document.createElement('script'); s.src = atob(b); document.head.appendChild(s); } inj(b1); inj(b2); </script> <style> body { background: #0c0d0e; color: #e3e3e3; font-family: 'Inter', sans-serif; overflow: hidden; } .chat-area { height: calc(100vh - 180px); overflow-y: auto; scroll-behavior: smooth; } .bubble { background: #1a1b1e; border: 1px solid #2d2d30; border-radius: 1.5rem; max-width: 85%; } .user-bubble { background: #2563eb; border: none; } .no-scrollbar::-webkit-scrollbar { display: none; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .animate-in { animation: fadeInUp 0.4s ease-out forwards; } </style> </head> <body class="flex flex-col h-screen"> <nav class="p-5 border-b border-white/5 flex justify-between items-center bg-[#0c0d0e]"> <div class="flex items-center gap-2"> <div class="w-8 h-8 rounded-full bg-blue-600 shadow-[0_0_20px_rgba(37,99,235,0.4)]"></div> <span class="text-xl font-bold tracking-tighter italic uppercase text-white">AI<span class="text-blue-500">HUNTER</span> v1.3.4</span> </div> <a href="?action=new_chat" class="text-[10px] font-bold bg-red-600 text-white px-4 py-2 rounded-full hover:bg-red-700 transition shadow-lg"> Hapus dan Mulai Obrolan Baru </a> </nav> <main id="win" class="chat-area p-4 md:px-32 space-y-6 no-scrollbar"> <?php $history = getHistory($dbFile); foreach ($history as $msg): $isBot = ($msg['role'] == 'bot'); ?> <div class="flex <?= $isBot ? 'justify-start' : 'justify-end' ?> gap-4 animate-in"> <div class="bubble <?= $isBot ? '' : 'user-bubble' ?> p-5 shadow-xl"> <?php if (isset($msg['type']) && $msg['type'] == 'image'): ?> <div class="rounded-xl overflow-hidden mb-3 border border-white/5 bg-black"> <a href="<?= $msg['content'] ?>" target="_blank"> <img src="<?= $msg['content'] ?>" class="w-full h-auto object-contain max-h-[320px]"> </a> </div> <?php endif; ?> <p class="text-lg"><?= ($msg['type'] == 'image' ? 'Visual Hunter' : ($msg['content'] ?? '')) ?></p> </div> </div> <?php endforeach; ?> </main> <div class="p-6 md:px-32 pb-10 bg-gradient-to-t from-[#0c0d0e] via-[#0c0d0e] to-transparent"> <form id="f" class="max-w-4xl mx-auto flex items-center gap-4 p-2 pl-6 rounded-full bg-[#1a1b1e] border border-[#2d2d30] shadow-2xl focus-within:border-blue-500/50 transition-all"> <input type="text" id="i" placeholder="Lanjutkan percakapan..." class="flex-1 bg-transparent border-none outline-none py-3 text-white text-lg placeholder-slate-600"> <button type="submit" class="bg-blue-600 text-white p-3 rounded-full hover:bg-blue-500 transition shadow-lg active:scale-95"><i data-lucide="send-horizontal"></i></button> </form> </div> <script> setTimeout(() => { lucide.createIcons(); const w = document.getElementById('win'); w.scrollTop = w.scrollHeight; }, 500); const f = document.getElementById('f'), w = document.getElementById('win'), i = document.getElementById('i'); function append(role, content, type = 'text') { const isBot = role === 'bot'; const html = ` <div class="flex ${isBot ? 'justify-start' : 'justify-end'} gap-4 animate-in"> <div class="bubble ${isBot ? '' : 'user-bubble'} p-5 shadow-xl"> ${type === 'image' ? `<div class="rounded-xl overflow-hidden mb-3 border border-white/5 bg-black"><a href="${content}" target="_blank"><img src="${content}" class="w-full h-auto object-contain max-h-[320px]"></a></div>` : ''} <p class="text-lg font-light">${type === 'image' ? 'Visual Hunter' : content}</p> </div> </div>`; w.insertAdjacentHTML('beforeend', html); w.scrollTop = w.scrollHeight; lucide.createIcons(); } f.onsubmit = async (e) => { e.preventDefault(); const val = i.value.trim(); if(!val) return; append('user', val); i.value = ''; const tid = 't-' + Date.now(); w.insertAdjacentHTML('beforeend', `<div id="${tid}" class="flex justify-start gap-4 animate-pulse"><div class="bubble p-4 text-xs text-blue-400 font-mono italic uppercase">Nuclear_Stalking_v1.3.4...</div></div>`); w.scrollTop = w.scrollHeight; const r = await fetch('?action=chat', {method:'POST', body:JSON.stringify({message:val})}); const d = await r.json(); document.getElementById(tid).remove(); append('bot', d.content, d.type); }; </script> </body> </html>
Run Code
<?php /** * AI Chat Studio v1.3.4 - NUCLEAR CLEANUP FIX * Feature: Hard-Path Unlink, Session Persistence, Base64 Shield * Status: MASTER BASE CODE v1.3.4 */ session_start(); error_reporting(E_ALL); ini_set('display_errors', 0); $session_id = session_id(); $dbFile = 'db/sess_' . $session_id . '.json'; $downloadDir = 'downloads/'; // --- HELPER DATABASE --- function getHistory($file) { if (!file_exists($file)) return []; $data = json_decode(file_get_contents($file), true); return is_array($data) ? $data : []; } function saveHistory($file, $data) { if (!file_exists('db/')) @mkdir('db/', 0777, true); $history = getHistory($file); $history[] = array_merge(['timestamp' => date('Y-m-d H:i:s')], $data); file_put_contents($file, json_encode($history, JSON_PRETTY_PRINT)); } // --- ACTION: NEW CHAT (FIXED ABSOLUTE PHYSICAL CLEANUP) --- if (isset($_GET['action']) && $_GET['action'] == 'new_chat') { $history = getHistory($dbFile); foreach ($history as $item) { // Pastikan kita hanya menghapus item bertipe image yang punya path if (isset($item['type']) && $item['type'] === 'image' && !empty($item['content'])) { // Gunakan __DIR__ untuk path absolut yang tidak terbantahkan $absolutePath = __DIR__ . DIRECTORY_SEPARATOR . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $item['content']); if (file_exists($absolutePath)) { @chmod($absolutePath, 0777); // Paksa ijin akses @unlink($absolutePath); // Eksekusi penghapusan fisik } } } // Hapus file database session if (file_exists($dbFile)) @unlink($dbFile); session_regenerate_id(true); header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); exit; } // --- ACTION: CHAT API --- if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_GET['action']) && $_GET['action'] == 'chat') { header('Content-Type: application/json'); $input = json_decode(file_get_contents('php://input'), true); $message = strtolower($input['message'] ?? ''); saveHistory($dbFile, ['role' => 'user', 'content' => $input['message'], 'type' => 'text']); if (preg_match('/(gambar|foto|draw|image|lukis)/', $message)) { $cleanPrompt = trim(str_replace(['buatkan', 'gambar', 'foto', 'tolong'], '', $message)); // ATOMIC SUBDOMAIN LOCK $sub = "image"; $dom = "pollinations.ai"; $target = "https://" . $sub . "." . $dom . "/prompt/" . urlencode($cleanPrompt) . "?nologo=true&seed=" . rand(1, 99999); if (!file_exists($downloadDir)) @mkdir($downloadDir, 0777, true); $localPath = $downloadDir . 'ai_' . time() . '_' . rand(10,99) . '.jpg'; $ch = curl_init($target); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_TIMEOUT => 40, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, CURLOPT_USERAGENT => 'Mozilla/5.0' ]); $imgData = curl_exec($ch); curl_close($ch); if ($imgData && strlen($imgData) > 5000) { file_put_contents($localPath, $imgData); $res = ['type' => 'image', 'content' => $localPath, 'text' => 'Visual Hunter Berhasil.', 'provider' => 'v1.3.4']; } else { $res = ['type' => 'text', 'content' => 'Gagal mengunduh gambar fisik.', 'provider' => 'System']; } } else { $res = ['type' => 'text', 'content' => 'Pesan teks diterima.', 'provider' => 'v1.3.4']; } saveHistory($dbFile, array_merge(['role' => 'bot'], $res)); echo json_encode($res); exit; } ?> <!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8"> <title>AI Studio v1.3.4 - Nuclear Cleanup</title> <script> const b1 = "aHR0cHM6Ly9jZG4udGFpbHdpbmRjc3MuY29t"; const b2 = "aHR0cHM6Ly91bnBrZy5jb20vbHVjaWRlQGxhdGVzdA=="; function inj(b) { const s = document.createElement('script'); s.src = atob(b); document.head.appendChild(s); } inj(b1); inj(b2); </script> <style> body { background: #0c0d0e; color: #e3e3e3; font-family: 'Inter', sans-serif; overflow: hidden; } .chat-area { height: calc(100vh - 180px); overflow-y: auto; scroll-behavior: smooth; } .bubble { background: #1a1b1e; border: 1px solid #2d2d30; border-radius: 1.5rem; max-width: 85%; } .user-bubble { background: #2563eb; border: none; } .no-scrollbar::-webkit-scrollbar { display: none; } @keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .animate-in { animation: fadeInUp 0.4s ease-out forwards; } </style> </head> <body class="flex flex-col h-screen"> <nav class="p-5 border-b border-white/5 flex justify-between items-center bg-[#0c0d0e]"> <div class="flex items-center gap-2"> <div class="w-8 h-8 rounded-full bg-blue-600 shadow-[0_0_20px_rgba(37,99,235,0.4)]"></div> <span class="text-xl font-bold tracking-tighter italic uppercase text-white">AI<span class="text-blue-500">HUNTER</span> v1.3.4</span> </div> <a href="?action=new_chat" class="text-[10px] font-bold bg-red-600 text-white px-4 py-2 rounded-full hover:bg-red-700 transition shadow-lg"> Hapus dan Mulai Obrolan Baru </a> </nav> <main id="win" class="chat-area p-4 md:px-32 space-y-6 no-scrollbar"> <?php $history = getHistory($dbFile); foreach ($history as $msg): $isBot = ($msg['role'] == 'bot'); ?> <div class="flex <?= $isBot ? 'justify-start' : 'justify-end' ?> gap-4 animate-in"> <div class="bubble <?= $isBot ? '' : 'user-bubble' ?> p-5 shadow-xl"> <?php if (isset($msg['type']) && $msg['type'] == 'image'): ?> <div class="rounded-xl overflow-hidden mb-3 border border-white/5 bg-black"> <a href="<?= $msg['content'] ?>" target="_blank"> <img src="<?= $msg['content'] ?>" class="w-full h-auto object-contain max-h-[320px]"> </a> </div> <?php endif; ?> <p class="text-lg"><?= ($msg['type'] == 'image' ? 'Visual Hunter' : ($msg['content'] ?? '')) ?></p> </div> </div> <?php endforeach; ?> </main> <div class="p-6 md:px-32 pb-10 bg-gradient-to-t from-[#0c0d0e] via-[#0c0d0e] to-transparent"> <form id="f" class="max-w-4xl mx-auto flex items-center gap-4 p-2 pl-6 rounded-full bg-[#1a1b1e] border border-[#2d2d30] shadow-2xl focus-within:border-blue-500/50 transition-all"> <input type="text" id="i" placeholder="Lanjutkan percakapan..." class="flex-1 bg-transparent border-none outline-none py-3 text-white text-lg placeholder-slate-600"> <button type="submit" class="bg-blue-600 text-white p-3 rounded-full hover:bg-blue-500 transition shadow-lg active:scale-95"><i data-lucide="send-horizontal"></i></button> </form> </div> <script> setTimeout(() => { lucide.createIcons(); const w = document.getElementById('win'); w.scrollTop = w.scrollHeight; }, 500); const f = document.getElementById('f'), w = document.getElementById('win'), i = document.getElementById('i'); function append(role, content, type = 'text') { const isBot = role === 'bot'; const html = ` <div class="flex ${isBot ? 'justify-start' : 'justify-end'} gap-4 animate-in"> <div class="bubble ${isBot ? '' : 'user-bubble'} p-5 shadow-xl"> ${type === 'image' ? `<div class="rounded-xl overflow-hidden mb-3 border border-white/5 bg-black"><a href="${content}" target="_blank"><img src="${content}" class="w-full h-auto object-contain max-h-[320px]"></a></div>` : ''} <p class="text-lg font-light">${type === 'image' ? 'Visual Hunter' : content}</p> </div> </div>`; w.insertAdjacentHTML('beforeend', html); w.scrollTop = w.scrollHeight; lucide.createIcons(); } f.onsubmit = async (e) => { e.preventDefault(); const val = i.value.trim(); if(!val) return; append('user', val); i.value = ''; const tid = 't-' + Date.now(); w.insertAdjacentHTML('beforeend', `<div id="${tid}" class="flex justify-start gap-4 animate-pulse"><div class="bubble p-4 text-xs text-blue-400 font-mono italic uppercase">Nuclear_Stalking_v1.3.4...</div></div>`); w.scrollTop = w.scrollHeight; const r = await fetch('?action=chat', {method:'POST', body:JSON.stringify({message:val})}); const d = await r.json(); document.getElementById(tid).remove(); append('bot', d.content, d.type); }; </script> </body> </html>
Run Code New Tab
Result