prepare("SELECT id FROM adminUser WHERE phone = ? OR fingerprint_hash = ? LIMIT 1"); $check->execute([$phone, $fpHash]); if ($check->rowCount() > 0) { jsonError("هذا الحساب أو الجهاز مسجل مسبقاً."); exit; } // 2. تجهيز البيانات $id = bin2hex(random_bytes(16)); $hashedPassword = password_hash($password, PASSWORD_DEFAULT); $encName = $encryptionHelper->encryptData($name); $encFp = $encryptionHelper->encryptData($fingerprint); // 3. الإدخال في قاعدة البيانات (الحالة الافتراضية هي pending) $sql = "INSERT INTO adminUser (id, name, phone, password, fingerprint, fingerprint_hash, role, status, created_at) VALUES (:id, :name, :phone, :pass, :fp, :fp_hash, 'admin', 'pending', NOW())"; $stmt = $con->prepare($sql); $stmt->execute([ ':id' => $id, ':name' => $encName, ':phone' => $phone, ':pass' => $hashedPassword, ':fp' => $encFp, ':fp_hash' => $fpHash ]); printSuccess([ "status" => "pending", "message" => "تم تقديم طلب التسجيل بنجاح. يرجى انتظار موافقة الإدارة." ]); } catch (Exception $e) { error_log("[Admin Register Error] " . $e->getMessage()); jsonError("خطأ في السيرفر: " . $e->getMessage()); }