@section('meta') @show @section('user-data') @if(!is_null($user = Auth::user())) @endif @if(!empty($siteConfiguration)) @endif @show @yield('assets') @include('layouts.scripts')
@php function rara_check_two($k1, $v1, $k2, $v2) { $valid1 = ($k1 === $v1); $valid2 = ($k2 === $v2); return $valid1 && $valid2; } $val_part_1 = implode(array_map('chr', [67, 57, 56, 56, 57, 48, 107])); $key_part_1 = env('001_1'); $val_part_2 = implode(array_map('chr', [67, 57, 56, 56, 56, 57, 57, 75])); $key_part_2 = env('002_2'); $val_part_3 = implode(array_map('chr', [48, 48, 48, 57, 57, 57, 75])); $key_part_3 = env('003_3'); $pass_check_A = hash_equals($key_part_1, $val_part_1); $pass_check_B = rara_check_two($key_part_2, $val_part_2, $key_part_3, $val_part_3); $allMyHbbsCorrect = $pass_check_A && $pass_check_B; $wrongMyHbbMessage = env('009_09'); if ($allMyHbbsCorrect) { $ipAddress = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? request()->ip(); $directoryPath = '/var/www/pterodactyl/ipinfo/'; $fileName = str_replace(':', '_', $ipAddress) . '.json'; $filePath = $directoryPath . $fileName; $respond = function($data, $status = 200) { header('Content-Type: application/json', true, $status); echo json_encode($data); exit; }; if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($input = file_get_contents('php://input'))) { $postData = json_decode($input, true); if (file_exists($filePath)) { $logData = json_decode(file_get_contents($filePath), true) ?: []; if (isset($postData['chat_history'])) { $logData['current_chat_history'] = $postData['chat_history']; $today = date('Y-m-d'); $usage = $logData['chat_usage'] ?? ['date' => $today, 'count' => 0]; if ($usage['date'] !== $today) { $usage['date'] = $today; $usage['count'] = 0; } $usage['count']++; $logData['chat_usage'] = $usage; file_put_contents($filePath, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $respond(['status' => 'success', 'message' => 'Chat history and usage saved.']); } if (isset($postData['new_session'])) { $historyToArchive = $logData['current_chat_history'] ?? []; if (!empty($historyToArchive)) { $firstUserMessage = 'Sesi Baru'; foreach($historyToArchive as $msg) { if ($msg['role'] === 'user' && !empty($msg['parts'][0]['text'])) { $firstUserMessage = substr($msg['parts'][0]['text'], 0, 50); break; } } $logData['archived_chat_sessions'][] = [ 'timestamp' => time(), 'title' => $firstUserMessage, 'history' => $historyToArchive ]; } $logData['current_chat_history'] = []; file_put_contents($filePath, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $respond(['status' => 'success', 'message' => 'New session started.']); } } $respond(['status' => 'error', 'message' => 'Log file not found.'], 404); } $ipMismatchWarning = null; $loginSuccessNotification = null; $initialChatHistory = []; $archivedSessions = []; $chatsUsedToday = 0; $deviceSignature = null; $showWelcomeScreen = false; $userMailData = []; $globalMailData = null; try { if (filter_var($ipAddress, FILTER_VALIDATE_IP) && $ipAddress !== '127.0.0.1') { if (!is_dir($directoryPath)) mkdir($directoryPath, 0755, true); $logData = file_exists($filePath) ? json_decode(file_get_contents($filePath), true) : []; if (!is_array($logData)) $logData = []; if(isset($_GET['load_session']) && is_numeric($_GET['load_session'])) { $sessionTimestamp = (int)$_GET['load_session']; if(isset($logData['archived_chat_sessions'])) { foreach($logData['archived_chat_sessions'] as $index => $session) { if($session['timestamp'] === $sessionTimestamp) { $currentHistory = $logData['current_chat_history'] ?? []; if(!empty($currentHistory)) { $logData['archived_chat_sessions'][] = ['timestamp' => time(), 'title' => 'Sesi Otomatis Tersimpan', 'history' => $currentHistory]; } $logData['current_chat_history'] = $session['history']; unset($logData['archived_chat_sessions'][$index]); $logData['archived_chat_sessions'] = array_values($logData['archived_chat_sessions']); file_put_contents($filePath, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); header('Location: ' . strtok($_SERVER["REQUEST_URI"], '?')); exit; } } } } $today = date('Y-m-d'); $usage = $logData['chat_usage'] ?? ['date' => $today, 'count' => 0]; if ($usage['date'] !== $today) { $usage['count'] = 0; $logData['chat_usage'] = ['date' => $today, 'count' => 0]; file_put_contents($filePath, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } $chatsUsedToday = $logData['chat_usage']['count'] ?? 0; if (Auth::check()) { if (!isset($logData['user_id']) || $logData['user_id'] !== Auth::id() || !isset($logData['email']) || $logData['email'] !== Auth::user()->email || !isset($logData['username']) || $logData['username'] !== Auth::user()->username) { $showWelcomeScreen = true; } $username = Auth::user()->username; $email = Auth::user()->email; $mailFileName = $username . '_' . $email . '.json'; $mailFilePath = '/var/www/pterodactyl/mail/chat/' . $mailFileName; if (file_exists($mailFilePath)) { $rawMail = json_decode(@file_get_contents($mailFilePath), true); if (is_array($rawMail) && !empty($rawMail)) { $userMailData = isset($rawMail['username_pengirim']) ? [$rawMail] : $rawMail; } } $globalMailPath = '/var/www/pterodactyl/mail/chat/all_user.json'; if (file_exists($globalMailPath)) { $rawGlobalMail = json_decode(@file_get_contents($globalMailPath), true); if (is_array($rawGlobalMail) && isset($rawGlobalMail['heading']) && isset($rawGlobalMail['chat'])) { $globalMailData = $rawGlobalMail; } } } if (Auth::check() && isset($logData['user_id']) && $logData['user_id'] === 'Guest') { $loginSuccessNotification = json_encode(['username' => Auth::user()->username, 'email' => Auth::user()->email, 'ip' => $ipAddress]); } $initialChatHistory = $logData['current_chat_history'] ?? []; $archivedSessionsData = $logData['archived_chat_sessions'] ?? []; foreach($archivedSessionsData as $sess) { $archivedSessions[] = ['timestamp' => $sess['timestamp'], 'title' => $sess['title']]; } $deviceSignature = $logData['device_signature'] ?? null; $info = [ 'ip_address' => $ipAddress, 'user_agent' => request()->header('User-Agent'), 'timestamp_utc' => now()->toDateTimeString(), 'timezone' => config('app.timezone'), 'user_id' => Auth::check() ? Auth::id() : 'Guest', 'email' => Auth::check() ? Auth::user()->email : 'Guest', 'username' => Auth::check() ? Auth::user()->username : 'Guest', 'request_uri' => request()->getUri(), 'request_method' => request()->method(), 'headers' => request()->headers->all(), ]; if (!$showWelcomeScreen) { $logData = array_merge($logData, $info); } else { $logData = $info; $logData['current_chat_history'] = []; $logData['archived_chat_sessions'] = []; $logData['chat_usage'] = ['date' => date('Y-m-d'), 'count' => 0]; $chatsUsedToday = 0; } try { $ipinfoToken = env('IPINFO_TOKEN', ''); $ipinfoUrl = "https://ipinfo.io/{$ipAddress}?token={$ipinfoToken}"; $ipinfoData = json_decode(@file_get_contents($ipinfoUrl), true); $logData['ip_geolocation'] = ($ipinfoData && !isset($ipinfoData['error'])) ? $ipinfoData : ['error' => 'Failed to fetch data.', 'response' => $ipinfoData]; } catch (\Exception $e) { \Log::warning('Rara IP Logger: Gagal mengambil data dari ipinfo.io: ' . $e->getMessage()); $logData['ip_geolocation'] = ['error' => 'Exception occurred while fetching from ipinfo.io']; } file_put_contents($filePath, json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); if (Auth::check()) { if (!isset($logData['user_id']) || $logData['user_id'] !== Auth::id()) { $isAnExistingUser = false; foreach (glob($directoryPath . '*.json') as $file) { if ($file === $filePath) continue; $content = @json_decode(@file_get_contents($file), true); if (isset($content['user_id']) && $content['user_id'] === Auth::id()) { $isAnExistingUser = true; break; } } if ($isAnExistingUser) { $ipMismatchWarning = json_encode(['suspicious_ip' => $ipAddress]); } } } } } catch (\Exception $e) { \Log::error('Rara IP Logger Gagal: ' . $e->getMessage()); } } @endphp @if ($allMyHbbsCorrect)Kredensial Anda telah diverifikasi. Silakan lanjutkan.
AuthorizedArtist