Update: 2026-06-11 18:22:57

This commit is contained in:
Hamza-Ayed
2026-06-11 18:22:59 +03:00
parent c5170a88d2
commit 727068b668
629 changed files with 46050 additions and 46109 deletions

View File

@@ -0,0 +1,35 @@
<?php
include "../../connect.php";
// Sanitize and validate input
$driverId = filterRequest("driverId");
$issueDate = filterRequest("IssueDate");
$inspectionResult = filterRequest("InspectionResult");
// Prepare SQL statement
$sql = "INSERT INTO criminalDocuments (driverId, IssueDate, InspectionResult)
VALUES (:driverId, :issueDate, :inspectionResult)";
try {
$stmt = $con->prepare($sql);
// Bind parameters
$stmt->bindParam(':driverId', $driverId, PDO::PARAM_INT);
$stmt->bindParam(':issueDate', $issueDate, PDO::PARAM_STR);
$stmt->bindParam(':inspectionResult', $inspectionResult, PDO::PARAM_STR);
// Execute the statement
$stmt->execute();
// Check if the insertion was successful
if ($stmt->rowCount() > 0) {
printSuccess("Criminal document data saved successfully");
} else {
printFailure("Failed to save criminal document data");
}
} catch (PDOException $e) {
// Log the error and print a generic failure message
error_log("Database Error: " . $e->getMessage());
printFailure("An error occurred while saving the data");
}
?>

View File

@@ -0,0 +1,19 @@
<?php
include "../../connect.php";
$id = filterRequest("id");
$sql = "UPDATE `driver` SET `status`='deleteFromHimself' WHERE `id`=$id'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = "Record deleted successfully");
} else {
// Print a failure message
printFailure($message = "Failed to delete record");
}
?>

View File

@@ -0,0 +1,22 @@
<?php
include "../../connect.php";
$driverID = filterRequest("id");
$sql = "SELECT `accountBank` FROM `driver` WHERE `id`='$driverID'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,23 @@
<?php
include "../../connect.php";
// $driverID = filterRequest("id");
$sql = "
SELECT * FROM `promptDriverIDEgypt`";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Fetch the record
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
printSuccess( $row);
}
else{
// Print a failure message
printFailure($message = "No wallet record found");
}
?>

View File

@@ -0,0 +1,67 @@
<?php
include "../../connect.php";
$email = filterRequest('email');
$phone = filterRequest('phone');
$password = filterRequest('password');
// Hash the password
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$sql = "SELECT
driver.id,
driver.phone,
driver.email,
driver.password,
driver.gender,
driver.birthdate,
driver.site,
driver.first_name,
driver.last_name,
driver.education,
driver.employmentType,
driver.maritalStatus,
driver.created_at,
driver.updated_at,
email_verifications.verified
FROM
driver
LEFT JOIN email_verifications ON email_verifications.email = driver.email
WHERE
driver.phone = :phone AND driver.email = :email ";
$stmt = $con->prepare($sql);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':phone', $phone);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
if ($count > 0) {
$stored_password = $data[0]['password'];
if (password_verify($password, $stored_password)) {
unset($data[0]['password']);
echo json_encode([
"status" => "success",
"count" => $count,
"data" => $data
]);
} else {
// The password is incorrect
echo json_encode([
"status" => "Failure",
"data" => "Incorrect password."
]);
// printFailure("Incorrect password.");
}
} else {
// The user does not exist
echo json_encode([
"status" => "Failure",
"data" => "User does not exist."
]);
// printFailure("User does not exist.");
}
$conn->close();
?>

View File

@@ -0,0 +1,56 @@
<?php
include "../../connect.php";
$email = filterRequest('email');
$driverID = filterRequest('id');
$sql = "SELECT
driver.id,
driver.phone,
driver.email,
driver.gender,
driver.birthdate,
driver.site,
driver.first_name,
driver.last_name,
driver.bankCode,
driver.accountBank,
driver.education,
driver.employmentType,
driver.maritalStatus,
driver.created_at,
driver.updated_at,
phone_verification.is_verified
FROM
driver
LEFT JOIN phone_verification ON phone_verification.phone_number = driver.phone
WHERE
driver.email = :email AND driver.id = :id AND `phone_verification`.`is_verified`='1' ";
$stmt = $con->prepare($sql);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':id', $driverID);
$stmt->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = $stmt->rowCount();
if ($count > 0) {
echo json_encode([
"status" => "success",
"count" => $count,
"data" => $data
]);
} else {
// The user does not exist
// echo json_encode([
// "status" => "Failure",
// "data" => "User does not exist."
// ]);
printFailure("User does not exist.");
}
$stmt = null; // Close the statement
$con = null; // Close the connection
exit();

View File

@@ -0,0 +1,110 @@
<?php
include "../../connect.php";
try {
// Collect and validate input data
$requiredFields = ["phone", "email", "password", "gender", "birthdate", "first_name", "last_name"];
$inputData = [];
foreach ($requiredFields as $field) {
$inputData[$field] = filterRequest($field);
if (empty($inputData[$field])) {
printFailure("Missing required field: $field");
}
}
// Collect optional fields
$optionalFields = [
"id", "license_type", "national_number", "name_arabic", "name_english",
"issue_date", "expiry_date", "license_categories", "address", "card_id",
"occupation", "licenseIssueDate", "religion", "status", "site",
"education", "employmentType", "maritalStatus"
];
foreach ($optionalFields as $field) {
$inputData[$field] = filterRequest($field);
}
// Generate driver ID if not provided
// $inputData['id'] = empty($inputData['id']) ? sha1(uniqid()) : $inputData['id'];
// Hash password
$inputData['hashedPassword'] = password_hash($inputData['password'], PASSWORD_DEFAULT);
// Set default site if not specified
$inputData['site'] = ($inputData['site'] === null || $inputData['site'] === "") ? "Not specified" : $inputData['site'];
// Check if the phone number or email address already exists
$stmt = $con->prepare("SELECT * FROM driver WHERE phone = :phone OR email = :email");
$stmt->bindParam(':phone', $inputData['phone'], PDO::PARAM_STR);
$stmt->bindParam(':email', $inputData['email'], PDO::PARAM_STR);
$stmt->execute();
if ($stmt->rowCount() > 0) {
printFailure("The email or phone number is already registered.");
}
// Prepare SQL for inserting new driver
$sql = "
INSERT INTO `driver` (
`id`, `phone`, `email`, `password`, `gender`, `license_type`, `national_number`,
`name_arabic`, `name_english`, `issue_date`, `expiry_date`, `license_categories`,
`address`, `card_id`, `occupation`, `licenseIssueDate`, `religion`, `status`,
`birthdate`, `site`, `first_name`, `last_name`, `education`,
`employmentType`, `maritalStatus`, `created_at`, `updated_at`
) VALUES (
:id, :phone, :email, :hashedPassword, :gender, :license_type, :national_number,
:name_arabic, :name_english, :issue_date, :expiry_date, :license_categories,
:address, :card_id, :occupation, :licenseIssueDate, :religion, :status,
:birthdate, :site, :first_name, :last_name, :education,
:employmentType, :maritalStatus, NOW(), NOW()
)
";
$stmt = $con->prepare($sql);
if (!$stmt) {
throw new Exception("Failed to prepare statement: " . $con->error);
}
// Bind parameters
$paramsToBind = [
'id', 'phone', 'email', 'hashedPassword', 'gender', 'license_type', 'national_number',
'name_arabic', 'name_english', 'issue_date', 'expiry_date', 'license_categories',
'address', 'card_id', 'occupation', 'licenseIssueDate', 'religion', 'status',
'birthdate', 'site', 'first_name', 'last_name', 'education',
'employmentType', 'maritalStatus'
];
foreach ($paramsToBind as $param) {
if (isset($inputData[$param])) {
$stmt->bindValue(":$param", $inputData[$param], PDO::PARAM_STR);
} else {
$stmt->bindValue(":$param", null, PDO::PARAM_STR);
}
}
// Log SQL and parameters for debugging
error_log("SQL: " . $sql);
error_log("Params: " . print_r($inputData, true));
// Execute the statement
if (!$stmt->execute()) {
throw new Exception("Failed to execute statement: " . $stmt->errorInfo()[2]);
}
// Check if the record was successfully saved
if ($stmt->rowCount() > 0) {
printSuccess($inputData['id']);
} else {
printFailure("Failed to save driver data");
}
} catch (PDOException $e) {
error_log("Database error: " . $e->getMessage());
printFailure("A database error occurred: " . $e->getMessage());
} catch (Exception $e) {
error_log("An error occurred: " . $e->getMessage());
printFailure("An error occurred: " . $e->getMessage());
}

View File

@@ -0,0 +1,19 @@
<?php
include "../../connect.php";
$id = filterRequest("id");
$sql = "DELETE FROM `passengers` WHERE `id`='$id'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print a success message
printSuccess($message = "Record deleted successfully");
} else {
// Print a failure message
printFailure($message = "Failed to delete record");
}
?>

View File

@@ -0,0 +1,44 @@
<?php
include "../../connect.php";
$phone_number = filterRequest("phone_number");
$driverId = filterRequest("driverId");
$email = filterRequest("email");
$token_code = filterRequest("token_code");
$expiration_time = filterRequest("expiration_time"); // Assuming this is a timestamp
// Check if the phone number already exists
$sql = "SELECT * FROM `phone_verification` WHERE `phone_number` = '$phone_number'";
$stmt = $con->prepare($sql);
$stmt->execute();
$rowCount = $stmt->rowCount();
if ($rowCount > 0) {
// The phone number already exists, so update the data
$sql = "UPDATE `phone_verification` SET `token_code` = '$token_code', `expiration_time` = DATE_ADD(NOW(), INTERVAL 5 MINUTE) WHERE `phone_number` = '$phone_number'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// The update was successful
printSuccess($message = "Phone verification data updated successfully");
} else {
// The update was unsuccessful
printFailure($message = "Failed to update phone verification data");
}
} else {
// The phone number does not exist, so insert the data
$sql = "INSERT INTO `phone_verification` (`phone_number`, `driverId` ,`email`,`token_code`, `expiration_time`, `is_verified`, `created_at`) VALUES ('$phone_number','$driverId','$email', '$token_code', DATE_ADD(NOW(), INTERVAL 5 MINUTE), 0, NOW())";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// The insertion was successful
printSuccess($message = "Phone verification data saved successfully");
} else {
// The insertion was unsuccessful
printFailure($message = "Failed to save phone verification data");
}
}
?>

View File

@@ -0,0 +1,111 @@
<?php
include "../../connect.php";
$id = filterRequest("id");
// Check if any columns are set in the request
// if (!isset($_POST["phone"]) && !isset($_POST["email"]) && !isset($_POST["password"]) &&
// !isset($_POST["gender"]) && !isset($_POST["status"]) && !isset($_POST["birthdate"]) &&
// !isset($_POST["site"]) && !isset($_POST["first_name"]) && !isset($_POST["last_name"]) &&
// !isset($_POST["accountBank"]) && !isset($_POST["education"]) && !isset($_POST["employmentType"]) &&
// !isset($_POST["maritalStatus"]) && !isset($_POST["created_at"]) && !isset($_POST["updated_at"])) {
// // No data to update
// printFailure($message = "No driver data provided for update.");
// exit;
// }
// Create an empty array to store the column-value pairs
$columnValues = array();
// Add column-value pairs based on received data
if (isset($_POST["phone"])) {
$phone = filterRequest("phone");
$columnValues[] = "`phone` = '$phone'";
}
if (isset($_POST["email"])) {
$email = filterRequest("email");
$columnValues[] = "`email` = '$email'";
}
if (isset($_POST["password"])) {
$password = filterRequest("password");
$columnValues[] = "`password` = '$password'"; // Hash password before storing
}
if (isset($_POST["gender"])) {
$gender = filterRequest("gender");
$columnValues[] = "`gender` = '$gender'";
}
if (isset($_POST["status"])) {
$status = filterRequest("status");
$columnValues[] = "`status` = '$status'";
}
if (isset($_POST["birthdate"])) {
$birthdate = filterRequest("birthdate");
$columnValues[] = "`birthdate` = '$birthdate'";
}
if (isset($_POST["site"])) {
$site = filterRequest("site");
$columnValues[] = "`site` = '$site'";
}
if (isset($_POST["first_name"])) {
$first_name = filterRequest("first_name");
$columnValues[] = "`first_name` = '$first_name'";
}
if (isset($_POST["last_name"])) {
$last_name = filterRequest("last_name");
$columnValues[] = "`last_name` = '$last_name'";
}
if (isset($_POST["accountBank"])) {
$accountBank = filterRequest("accountBank");
$columnValues[] = "`accountBank` = '$accountBank'";
}
if (isset($_POST["education"])) {
$education = filterRequest("education");
$columnValues[] = "`education` = '$education'";
}
if (isset($_POST["employmentType"])) {
$employmentType = filterRequest("employmentType");
$columnValues[] = "`employmentType` = '$employmentType'";
}
if (isset($_POST["maritalStatus"])) {
$maritalStatus = filterRequest("maritalStatus");
$columnValues[] = "`maritalStatus` = '$maritalStatus'";
}
if (isset($_POST["bankCode"])) {
$bankCode = filterRequest("bankCode");
$columnValues[] = "`bankCode` = '$bankCode'";
}
if (isset($_POST["updated_at"])) {
$updatedAt = filterRequest("updated_at");
$columnValues[] = "`updated_at` = '$updatedAt'";
}
// Construct the SET clause of the update query
$setClause = implode(", ", $columnValues);
$sql = "UPDATE `driver` SET $setClause WHERE `id` = '$id'";
$stmt = $con->prepare($sql);
$stmt->execute();
if ($stmt->rowCount() > 0) {
// Print success message
printSuccess($message = "Driver data updated successfully");
} else {
// Print failure message
printFailure($message = "Failed to update driver data");
}
?>

View File

@@ -0,0 +1,33 @@
<?php
include "../../connect.php";
$phone_number = filterRequest("phone_number");
$token_code = filterRequest("token_code");
// Check if the phone number and token code match
$sql = "SELECT
`id`,
`phone_number`,
`token_code`,
`expiration_time`,
`is_verified`,
`created_at`
FROM
`phone_verification`
WHERE
`phone_number` = '$phone_number' AND `token_code` = '$token_code' AND `expiration_time` > NOW()";
$stmt = $con->prepare($sql);
$stmt->execute();
$result = $stmt->fetch();
if ($result) {
// $id = $result["id"];
$sql = "UPDATE `phone_verification` SET `is_verified` = 1 WHERE `phone_number` = $phone_number";
$stmt = $con->prepare($sql);
$stmt->execute();
printSuccess($message = "Your phone number has been verified.");
} else {
printFailure($message = "Your phone number could not be verified. Please try again.");
}
?>