Update: 2026-07-07 04:57:50

This commit is contained in:
Hamza-Ayed
2026-07-07 04:57:51 +03:00
parent 5725fb36f4
commit 628e169552
25 changed files with 288 additions and 1893 deletions
@@ -1,89 +0,0 @@
<?php
// ============================================================
// create_tester_driver.php
// Script to seed/register a pre-verified tester driver.
// ============================================================
require_once __DIR__ . '/../../core/bootstrap.php';
$email = 'driver_tester@siromove.com';
$phone = '+962790000002';
$password = 'SiroDriver2026!';
$hashedPassword = password_hash($password, PASSWORD_BCRYPT);
$encryptedEmail = $encryptionHelper->encryptData($email);
$encryptedPhone = $encryptionHelper->encryptData($phone);
$encryptedFirstName = $encryptionHelper->encryptData('Driver');
$encryptedLastName = $encryptionHelper->encryptData('Tester');
$encryptedGender = $encryptionHelper->encryptData('Male');
$encryptedBirthdate = $encryptionHelper->encryptData('1990-01-01');
$encryptedSite = $encryptionHelper->encryptData('Jordan');
try {
$con = Database::get('main');
// 1. Check if driver exists
$stmt = $con->prepare("SELECT id FROM driver WHERE email = :email LIMIT 1");
$stmt->bindParam(':email', $encryptedEmail);
$stmt->execute();
$driver = $stmt->fetch(PDO::FETCH_ASSOC);
if ($driver) {
$driverId = $driver['id'];
$update = $con->prepare("UPDATE driver SET password = :password, phone = :phone WHERE id = :id");
$update->bindParam(':password', $hashedPassword);
$update->bindParam(':phone', $encryptedPhone);
$update->bindParam(':id', $driverId);
$update->execute();
echo "Driver tester updated successfully.\n";
} else {
$driverId = bin2hex(random_bytes(10)); // 20 chars unique id
$insert = $con->prepare("INSERT INTO driver (id, phone, email, password, gender, birthdate, site, first_name, last_name)
VALUES (:id, :phone, :email, :password, :gender, :birthdate, :site, :first_name, :last_name)");
$insert->bindParam(':id', $driverId);
$insert->bindParam(':phone', $encryptedPhone);
$insert->bindParam(':email', $encryptedEmail);
$insert->bindParam(':password', $hashedPassword);
$insert->bindParam(':gender', $encryptedGender);
$insert->bindParam(':birthdate', $encryptedBirthdate);
$insert->bindParam(':site', $encryptedSite);
$insert->bindParam(':first_name', $encryptedFirstName);
$insert->bindParam(':last_name', $encryptedLastName);
$insert->execute();
echo "Driver tester created successfully with ID: $driverId\n";
}
// 2. Ensure phone_verification row exists
$stmtPhone = $con->prepare("SELECT * FROM phone_verification WHERE phone_number = :phone LIMIT 1");
$stmtPhone->bindParam(':phone', $encryptedPhone);
$stmtPhone->execute();
if ($stmtPhone->fetch()) {
$updatePhone = $con->prepare("UPDATE phone_verification SET is_verified = 1 WHERE phone_number = :phone");
$updatePhone->bindParam(':phone', $encryptedPhone);
$updatePhone->execute();
} else {
$insertPhone = $con->prepare("INSERT INTO phone_verification (phone_number, is_verified) VALUES (:phone, 1)");
$insertPhone->bindParam(':phone', $encryptedPhone);
$insertPhone->execute();
}
// 3. Ensure CarRegistration row exists
$stmtCar = $con->prepare("SELECT * FROM CarRegistration WHERE driverID = :driverID LIMIT 1");
$stmtCar->bindParam(':driverID', $driverId);
$stmtCar->execute();
if ($stmtCar->fetch()) {
$updateCar = $con->prepare("UPDATE CarRegistration SET make = 'Toyota', model = 'Prius', year = '2020' WHERE driverID = :driverID");
$updateCar->bindParam(':driverID', $driverId);
$updateCar->execute();
} else {
$insertCar = $con->prepare("INSERT INTO CarRegistration (driverID, make, model, year) VALUES (:driverID, 'Toyota', 'Prius', '2020')");
$insertCar->bindParam(':driverID', $driverId);
$insertCar->execute();
}
echo "Verification and Car Registration configured.\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
-29
View File
@@ -1,29 +0,0 @@
<?php
require_once __DIR__ . '/../../connect.php';
$appPlatform = filterRequest("appPlatform");
$sql = "SELECT
*
FROM
`testApp`
WHERE
appPlatform = '$appPlatform'-- AND isTest = 0;";
$stmt = $con->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($stmt->rowCount() > 0) {
// Print the retrieved data
// echo json_encode($result);
jsonSuccess($data = $result);
} else {
// Print a failure message
jsonError($message = "No driver order data found");
}
?>
-23
View File
@@ -1,23 +0,0 @@
<?php
require_once __DIR__ . '/../../connect.php';
$appPlatform = filterRequest("appPlatform");
$sql = "UPDATE
`testApp`
SET
`isTest` = '1'
WHERE
`testApp`.appPlatform = '$appPlatform';";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
jsonSuccess($message = "Test data updated successfully");
} else {
// Print a failure message
jsonError($message = "Failed to update driver order data");
}
?>