diff --git a/backend/ride/mishwari/test.php b/backend/ride/mishwari/test.php deleted file mode 100644 index 871acb43..00000000 --- a/backend/ride/mishwari/test.php +++ /dev/null @@ -1,30 +0,0 @@ -prepare($sql); -$stmt->execute(); - -if ($stmt->rowCount() > 0) { - $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); - - // فك التشفير للحقول الحساسة - foreach ($rows as &$row) { - $row['phone'] = $encryptionHelper->decryptData($row['phone']); - $row['email'] = $encryptionHelper->decryptData($row['email']); - $row['gender'] = $encryptionHelper->decryptData($row['gender']); - $row['birthdate'] = $encryptionHelper->decryptData($row['birthdate']); - $row['site'] = $encryptionHelper->decryptData($row['site']); - $row['first_name'] = $encryptionHelper->decryptData($row['first_name']); - $row['last_name'] = $encryptionHelper->decryptData($row['last_name']); - $row['sosPhone'] = $encryptionHelper->decryptData($row['sosPhone']); - $row['education'] = $encryptionHelper->decryptData($row['education']); - $row['employmentType'] = $encryptionHelper->decryptData($row['employmentType']); - $row['maritalStatus'] = $encryptionHelper->decryptData($row['maritalStatus']); - } - - jsonSuccess($rows); -} else { - jsonError("No passengers found"); -} -?> \ No newline at end of file diff --git a/backend/ride/rides/test_notification.php b/backend/ride/rides/test_notification.php deleted file mode 100644 index 4ed89a64..00000000 --- a/backend/ride/rides/test_notification.php +++ /dev/null @@ -1,46 +0,0 @@ - 'dispatch_order', - 'drivers_ids' => json_encode([$driverId]), - 'ride_id' => $rideId, - 'payload' => $payload -]; - -$ch = curl_init($socketUrl); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_POST, true); -curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); -curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-internal-key: $INTERNAL_KEY"]); -curl_setopt($ch, CURLOPT_TIMEOUT, 3); - -$response = curl_exec($ch); -$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); - -if (curl_errno($ch)) { - die("Curl error: " . curl_error($ch)); -} -curl_close($ch); - -echo "HTTP Code: $httpCode\n"; -echo "Response: $response\n"; diff --git a/backend/test_add_driver_and_car.php b/backend/test_add_driver_and_car.php new file mode 100644 index 00000000..24884d4a --- /dev/null +++ b/backend/test_add_driver_and_car.php @@ -0,0 +1,205 @@ +encryptData($phone); + $encEmail = $encryptionHelper->encryptData($email); + $encFirstName = $encryptionHelper->encryptData($first_name); + $encLastName = $encryptionHelper->encryptData($last_name); + $encNameArabic = $encryptionHelper->encryptData("$first_name $last_name"); + $encGender = $encryptionHelper->encryptData($gender); + $encNationalNumber = $national_number ? $encryptionHelper->encryptData($national_number) : ''; + $encBirthdate = $encryptionHelper->encryptData($birthdate); + $encSite = $encryptionHelper->encryptData($site); + $encOwner = $encryptionHelper->encryptData($owner); + $encCarPlate = $encryptionHelper->encryptData($car_plate); + $encVin = $encryptionHelper->encryptData($vin); + + $passwordHashed = password_hash($password, PASSWORD_DEFAULT); + + $con = Database::get('main'); + + /* ================== التحقق من التكرار ================== */ + $dup = $con->prepare("SELECT id FROM driver WHERE phone = :p OR email = :e"); + $dup->execute([':p' => $encPhone, ':e' => $encEmail]); + if ($dup->rowCount() > 0) { + jsonError("Phone or email already registered."); + exit; + } + + $con->beginTransaction(); + + /* ================== 1) إدراج السائق ================== */ + $sqlDriver = " + INSERT INTO driver ( + id, phone, email, password, gender, license_type, national_number, + name_arabic, issue_date, expiry_date, license_categories, + address, licenseIssueDate, status, birthdate, site, + first_name, last_name, accountBank, bankCode, + employmentType, maritalStatus, fullNameMaritial, expirationDate, + created_at, updated_at + ) VALUES ( + :id, :phone, :email, :pwd, :gender, :license_type, :national_number, + :name_arabic, :issue_date, :expiry_date, :license_categories, + :address, :licenseIssueDate, :status, :birthdate, :site, + :first_name, :last_name, :accountBank, :bankCode, + :employmentType, :maritalStatus, :fullNameMaritial, :expirationDate, + NOW(), NOW() + ) + "; + $insD = $con->prepare($sqlDriver); + $insD->execute([ + ':id' => $driverId, + ':phone' => $encPhone, + ':email' => $encEmail, + ':pwd' => $passwordHashed, + ':gender' => $encGender, + ':license_type' => $license_type, + ':national_number' => $encNationalNumber, + ':name_arabic' => $encNameArabic, + ':issue_date' => '2020-01-01', + ':expiry_date' => '2030-01-01', + ':license_categories' => 'B', + ':address' => $encSite, + ':licenseIssueDate' => '2020-01-01', + ':status' => 'pending_review', + ':birthdate' => $encBirthdate, + ':site' => $encSite, + ':first_name' => $encFirstName, + ':last_name' => $encLastName, + ':accountBank' => 'yet', + ':bankCode' => 'CIB', + ':employmentType' => $employmentType, + ':maritalStatus' => 'Single', + ':fullNameMaritial' => '', + ':expirationDate' => date('Y-m-d', strtotime('+5 years')), + ]); + + /* ================== 2) إدراج السيارة ================== */ + $sqlCar = " + INSERT INTO CarRegistration ( + driverID, vin, car_plate, make, model, year, expiration_date, + color, owner, color_hex, fuel, + vehicle_category_id, fuel_type_id, + isDefault, created_at, status + ) VALUES ( + :driverID, :vin, :car_plate, :make, :model, :year, :expiration_date, + :color, :owner, :color_hex, :fuel, + :vehicle_category_id, :fuel_type_id, + :isDefault, NOW(), 'active' + ) + "; + $insC = $con->prepare($sqlCar); + $insC->execute([ + ':driverID' => $driverId, + ':vin' => $encVin, + ':car_plate' => $encCarPlate, + ':make' => $make, + ':model' => $model, + ':year' => $year, + ':expiration_date' => $expiration_date, + ':color' => $color, + ':owner' => $encOwner, + ':color_hex' => $color_hex, + ':fuel' => $fuel, + ':vehicle_category_id' => 1, + ':fuel_type_id' => 1, + ':isDefault' => 1, + ]); + + $carRegID = $con->lastInsertId(); + + /* ================== 3) توكن السائق ================== */ + $token = bin2hex(random_bytes(20)); + $sqlToken = " + INSERT INTO driverToken (token, captain_id, fingerPrint, created_at) + VALUES (:token, :captain_id, :fingerPrint, NOW()) + "; + $con->prepare($sqlToken)->execute([ + ':token' => $token, + ':captain_id' => $driverId, + ':fingerPrint' => 'test_fingerprint', + ]); + + /* ================== 4) توثيق رقم الهاتف ================== */ + $sqlPhoneVer = " + INSERT INTO phone_verification (phone_number, driverId, email, token_code, expiration_time, is_verified, created_at) + VALUES (:phone, :driverId, :email, :token_code, DATE_ADD(NOW(), INTERVAL 1 YEAR), 1, NOW()) + "; + $con->prepare($sqlPhoneVer)->execute([ + ':phone' => $encPhone, + ':driverId' => $driverId, + ':email' => $encEmail, + ':token_code' => $encryptionHelper->encryptData('999'), + ]); + + /* ================== Commit ================== */ + $con->commit(); + + printSuccess([ + 'driverID' => $driverId, + 'carRegID' => $carRegID, + 'status' => 'success', + 'message' => "Driver $first_name $last_name created successfully with status pending_review.", + ]); + +} catch (Exception $e) { + if (isset($con) && $con instanceof PDO && $con->inTransaction()) { + $con->rollBack(); + } + error_log("[test_add_driver] " . $e->getMessage()); + jsonError($e->getMessage()); +} diff --git a/backend/test_api.php b/backend/test_api.php deleted file mode 100644 index b4d3025f..00000000 --- a/backend/test_api.php +++ /dev/null @@ -1,14 +0,0 @@ -flushAll(); - -$ch = curl_init('https://jordan-siro.intaleqapp.com/backend/loginFirstTime.php'); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_HEADER, true); -curl_setopt($ch, CURLOPT_POST, true); -curl_setopt($ch, CURLOPT_POSTFIELDS, 'id=new&password=unknown&aud=passenger-app:ios'); -$response = curl_exec($ch); -curl_close($ch); - -echo "RAW RESPONSE:\n"; -echo $response;