'YOUR_MAMBAPANEL_API_KEY', // Replace with your API key 'url' => 'https://mambapanel.com/api/v1/face', 'max_file_size' => 5 * 1024 * 1024, // 5MB 'allowed_types' => ['image/jpeg', 'image/png'], 'timeout' => 30 // API timeout in seconds ]); $message = ''; $results = null; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['image'])) { try { // Validate file upload if ($_FILES['image']['error'] !== UPLOAD_ERR_OK) { throw new Exception('File upload failed'); } // Validate file size if ($_FILES['image']['size'] > API_CONFIG['max_file_size']) { throw new Exception('File size must be less than 5MB'); } // Validate file type $file_type = mime_content_type($_FILES['image']['tmp_name']); if (!in_array($file_type, API_CONFIG['allowed_types'])) { throw new Exception('Only JPG and PNG files are allowed'); } // Prepare API request $image_data = base64_encode(file_get_contents($_FILES['image']['tmp_name'])); $data = json_encode(['image' => $image_data]); // Initialize cURL $ch = curl_init(API_CONFIG['url']); curl_setopt_array($ch, [ CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', "Authorization: Bearer " . API_CONFIG['key'] ], CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data, CURLOPT_TIMEOUT => API_CONFIG['timeout'] ]); // Execute API request $response = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('API request failed: ' . curl_error($ch)); } $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code !== 200) { throw new Exception('API returned error code: ' . $http_code); } $results = json_decode($response, true); if (!$results['success']) { throw new Exception($results['message'] ?? 'Unknown API error'); } $message = 'Search completed successfully!'; } catch (Exception $e) { $message = 'Error: ' . $e->getMessage(); } } ?>