= htmlspecialchars($config['panel_name']) ?>
خروجی کد:
'ست ادیت', 'api_key' => ''])); } $config = json_decode(file_get_contents($configFile), true); // پردازش درخواستهای AJAX if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { header('Content-Type: application/json'); // ذخیره تنظیمات if ($_POST['action'] === 'save_settings') { $config['panel_name'] = htmlspecialchars($_POST['panel_name']); $config['api_key'] = htmlspecialchars($_POST['api_key']); file_put_contents($configFile, json_encode($config)); echo json_encode(['success' => true]); exit; } // تست کلید API if ($_POST['action'] === 'test_api') { $apiKey = $_POST['api_key']; if (empty($apiKey)) { echo json_encode(['success' => false, 'msg_fa' => 'کلید API خالی است!', 'msg_en' => 'API Key is empty!']); exit; } // ارسال درخواست تست به OpenAI $ch = curl_init('https://api.openai.com/v1/models'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $apiKey"]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode === 200) { echo json_encode(['success' => true, 'msg_fa' => 'API متصل شد ✅', 'msg_en' => 'API Connected ✅']); } else { echo json_encode(['success' => false, 'msg_fa' => 'خطا در اتصال به API ❌', 'msg_en' => 'API Connection Failed ❌']); } exit; } // ساخت کد if ($_POST['action'] === 'generate') { $device = htmlspecialchars($_POST['device']); $plan = htmlspecialchars($_POST['plan']); $apiKey = $config['api_key']; if (empty($apiKey)) { // شبیهسازی در صورت نبود API $code = ""; if ($plan === "weak") { $code = "# Standard Settings for $device\ntouch.pressure.scale=0.1\nwindowsmgr.max_events_per_sec=60\ndebug.hwui.renderer=opengl\nro.min.fling_velocity=4000"; } else if ($plan === "medium") { $code = "# Smooth Settings for $device\ntouch.pressure.scale=0.005\nwindowsmgr.max_events_per_sec=90\nro.min.fling_velocity=8000"; } else { $code = "# VIP Aim & FPS for $device\ntouch.pressure.scale=0.001\nwindowsmgr.max_events_per_sec=120\nro.min.fling_velocity=12000\nro.max.fling_velocity=24000\nvendor.perf.gesture_boost=1\npersist.sys.nv_fps.limit=120\npointer_speed=7"; } echo json_encode(['success' => true, 'code' => $code . "\n\n(Generated via Simulation - No API Key set)"]); exit; } // اتصال واقعی به هوش مصنوعی $prompt = "Generate an android SetEdit configuration code for gaming (PUBG Mobile) for device: $device. Power level: $plan. Return ONLY the raw settings code in format: key=value without any markdown formatting or extra text."; $ch = curl_init('https://api.openai.com/v1/chat/completions'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', "Authorization: Bearer $apiKey" ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'model' => 'gpt-3.5-turbo', 'messages' => [['role' => 'user', 'content' => $prompt]], 'temperature' => 0.7 ])); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode === 200) { $data = json_decode($response, true); echo json_encode(['success' => true, 'code' => $data['choices'][0]['message']['content']]); } else { echo json_encode(['success' => false, 'code' => 'Error: Cannot communicate with API. HttpCode: ' . $httpCode]); } exit; } } ?>