first commit

This commit is contained in:
Hamza-Ayed
2026-06-09 08:40:31 +03:00
commit d8901e1a87
3161 changed files with 536187 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
require_once __DIR__ . '/../../connect.php';
$title = filterRequest("title");
$body = filterRequest("body");
$passengerID = filterRequest("passenger_id");
// SQL الآمن باستخدام placeholders
$sql = "INSERT INTO `notifications` (
`title`,
`body`,
`passenger_id`
) VALUES (
:title,
:body,
:passengerID
)";
$stmt = $con->prepare($sql);
$stmt->execute([
':title' => $title,
':body' => $body,
':passengerID' => $passengerID
]);
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Notification data saved successfully");
} else {
jsonError("Failed to save notification data");
}
?>

View File

@@ -0,0 +1,33 @@
<?php
require_once __DIR__ . '/../../connect.php';
$passenger_id = filterRequest("passenger_id");
$sql = "SELECT
`id`,
`title`,
`body`,
`passenger_id`,
`isShown`,
`created_at`,
`updated_at`
FROM
`notifications`
WHERE
`passenger_id` = :passenger_id
AND `created_at` >= CURDATE() - INTERVAL 7 DAY
ORDER BY `created_at` DESC
LIMIT 10";
$stmt = $con->prepare($sql);
$stmt->bindParam(':passenger_id', $passenger_id, PDO::PARAM_STR);
$stmt->execute();
$notifications = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($notifications) {
jsonSuccess($notifications);
} else {
jsonSuccess([], "No notification data found");
}
?>

View File

@@ -0,0 +1,42 @@
<?php
require_once __DIR__ . '/../../connect.php';
$id = filterRequest("id");
$fields = [];
$params = [':id' => $id];
$mapping = [
"title" => "title",
"body" => "body",
"passengerID" => "passenger_id",
"isShown" => "isShown",
"updatedAt" => "updated_at"
];
// تجهيز الـ SET والأرقام المقابلة
foreach ($mapping as $requestKey => $dbColumn) {
if (isset($_POST[$requestKey])) {
$value = filterRequest($requestKey);
$fields[] = "`$dbColumn` = :$requestKey";
$params[":$requestKey"] = $value;
}
}
if (empty($fields)) {
jsonError("No fields to update");
exit;
}
$setClause = implode(", ", $fields);
$sql = "UPDATE `notifications` SET $setClause WHERE `id` = :id";
$stmt = $con->prepare($sql);
$stmt->execute($params);
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Notification data updated successfully");
} else {
jsonError("Failed to update notification data");
}
?>