Initial commit with updated Auth and media ignored
This commit is contained in:
0
ride/profile/error_log
Normal file
0
ride/profile/error_log
Normal file
35
ride/profile/get.php
Normal file
35
ride/profile/get.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "SELECT * FROM `passengers` WHERE `id` = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) {
|
||||
unset($result['password']); // إخفاء الباسورد
|
||||
|
||||
// فك تشفير الحقول الحساسة
|
||||
$fieldsToDecrypt = [
|
||||
'phone', 'email', 'gender', 'birthdate', 'site',
|
||||
'first_name', 'last_name', 'sosPhone',
|
||||
'education', 'employmentType', 'maritalStatus'
|
||||
];
|
||||
|
||||
foreach ($fieldsToDecrypt as $field) {
|
||||
if (isset($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"data" => $result
|
||||
]);
|
||||
} else {
|
||||
jsonError("Failed to retrieve passenger data");
|
||||
}
|
||||
?>
|
||||
88
ride/profile/getCaptainProfile.php
Normal file
88
ride/profile/getCaptainProfile.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php'; // يوفر $con و $encryptionHelper
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "SELECT
|
||||
d.phone,
|
||||
d.email,
|
||||
d.gender,
|
||||
d.birthdate, -- مشفّر
|
||||
d.site,
|
||||
d.first_name,
|
||||
d.last_name,
|
||||
d.accountBank,
|
||||
d.created_at AS driver_created_at,
|
||||
d.updated_at AS driver_updated_at,
|
||||
v.id AS vehicle_id,
|
||||
v.driverID,
|
||||
v.make,
|
||||
v.model,
|
||||
v.car_plate,
|
||||
v.year,
|
||||
v.expiration_date,
|
||||
v.vin,
|
||||
v.color,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM ratingDriver rd
|
||||
WHERE rd.driver_id = d.id
|
||||
) AS ratingCount,
|
||||
(
|
||||
SELECT ROUND(AVG(rd.rating), 2)
|
||||
FROM ratingDriver rd
|
||||
WHERE rd.driver_id = d.id
|
||||
) AS ratingDriver
|
||||
FROM driver d
|
||||
LEFT JOIN CarRegistration v
|
||||
ON d.id = v.driverID
|
||||
WHERE d.id = :id";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$result) {
|
||||
jsonError("Failed to retrieve driver data");
|
||||
exit;
|
||||
}
|
||||
|
||||
// فك تشفير حقل birthdate أولاً لحساب العمر
|
||||
if (!empty($result['birthdate'])) {
|
||||
$result['birthdate'] = $encryptionHelper->decryptData($result['birthdate']);
|
||||
|
||||
try {
|
||||
$dob = new DateTime($result['birthdate']);
|
||||
$today = new DateTime();
|
||||
$age = $today->diff($dob)->y;
|
||||
} catch (Exception $e) {
|
||||
$age = null;
|
||||
}
|
||||
} else {
|
||||
$age = null;
|
||||
}
|
||||
$result['age'] = $age;
|
||||
|
||||
// فك تشفير بقية الحقول
|
||||
$driverFieldsToDecrypt = [
|
||||
'phone', 'email', 'gender', 'site',
|
||||
'first_name', 'last_name'
|
||||
];
|
||||
|
||||
foreach ($driverFieldsToDecrypt as $field) {
|
||||
if (!empty($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
// فك تشفير حقول السيارة
|
||||
$vehicleFieldsToDecrypt = ['vin', 'car_plate'];
|
||||
foreach ($vehicleFieldsToDecrypt as $field) {
|
||||
if (!empty($result[$field])) {
|
||||
$result[$field] = $encryptionHelper->decryptData($result[$field]);
|
||||
}
|
||||
}
|
||||
|
||||
jsonSuccess($result);
|
||||
?>
|
||||
37
ride/profile/update.php
Normal file
37
ride/profile/update.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$fields = [];
|
||||
$params = [":id" => $id];
|
||||
|
||||
$encryptedFields = [
|
||||
"phone", "sosPhone", "birthdate", "site", "gender",
|
||||
"first_name", "last_name", "education", "employmentType", "maritalStatus"
|
||||
];
|
||||
|
||||
foreach ($encryptedFields as $field) {
|
||||
if (isset($_POST[$field]) && !empty($_POST[$field])) {
|
||||
$value = filterRequest($field);
|
||||
$encryptedValue = $encryptionHelper->encryptData($value);
|
||||
$fields[] = "`$field` = :$field";
|
||||
$params[":$field"] = $encryptedValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
$setClause = implode(", ", $fields);
|
||||
$sql = "UPDATE `passengers` SET $setClause WHERE `id` = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Passenger data updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update passenger data");
|
||||
}
|
||||
} else {
|
||||
jsonError("No fields to update");
|
||||
}
|
||||
?>
|
||||
29
ride/profile/updateDriverEmail.php
Executable file
29
ride/profile/updateDriverEmail.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
$email = filterRequest("email");
|
||||
|
||||
// التحقق من وجود البيانات
|
||||
if (empty($id) || empty($email)) {
|
||||
jsonError("Missing required parameters");
|
||||
exit;
|
||||
}
|
||||
|
||||
// تشفير الإيميل
|
||||
$encryptedEmail = $encryptionHelper->encryptData($email);
|
||||
|
||||
// تنفيذ التحديث
|
||||
$sql = "UPDATE driver SET email = :email WHERE id = :id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$success = $stmt->execute([
|
||||
":email" => $encryptedEmail,
|
||||
":id" => $id
|
||||
]);
|
||||
|
||||
if ($success && $stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Email updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update email");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user