Initial commit with updated Auth and media ignored

This commit is contained in:
Hamza-Ayed
2026-04-28 13:04:27 +03:00
commit 67af97474c
477 changed files with 66444 additions and 0 deletions

0
auth/sms/error_log Normal file
View File

28
auth/sms/getSender.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
require_once __DIR__ . '/../../connect.php';
$sql = "SELECT
*
FROM
`smsSender`
WHERE
id = '1'";
$stmt = $con->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($stmt->rowCount() > 0) {
jsonSuccess($data = $result);
} else {
jsonError($message = "No driver order data found");
}
?>

View File

@@ -0,0 +1,68 @@
<?php
require_once __DIR__ . '/../../connect.php';
// استقبال رقم الهاتف
$phone = filterRequest('phone');
$language = filterRequest('lang') ?? 'r';
// 1⃣ جلب بيانات API من البيئة
$username = "Sefer";
$password = getenv("SMS_PASSWORD_EGYPT");
$apiEndpoint = getenv("SMS_API_ENDPOINT");
$sender = "SEFER";
$appName = "Tripz";
if (!$password || !$apiEndpoint) {
jsonError("API configuration is missing");
exit;
}
// 2⃣ توليد كود OTP من السيرفر
$otp = rand(100000, 999999);
// 3⃣ تشفير البيانات قبل تخزينها
$phoneEncrypted = $encryptionHelper->encryptData($phone);
$otpEncrypted = $encryptionHelper->encryptData($otp);
// 4⃣ تخزين OTP في قاعدة البيانات
try {
$insertOtp = "INSERT INTO otp_verification_fingerPrint (phone, otp) VALUES (?, ?)";
$stmt = $con->prepare($insertOtp);
$stmt->execute([$phoneEncrypted, $otpEncrypted]);
} catch (PDOException $e) {
error_log("DB Insert Error: " . $e->getMessage());
jsonError("Failed to save OTP to the database");
exit;
}
// 5⃣ إرسال الرسالة عبر API
$message = "$appName app code is $otp\ncopy it to app";
$payload = json_encode([
"username" => $username,
"password" => $password,
"message" => $message,
"language" => $language,
"sender" => $sender,
"receiver" => $phone
]);
$ch = curl_init($apiEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// 6⃣ التحقق من نجاح الإرسال
if ($httpCode != 200) {
error_log("SMS API Failed. HTTP Code: $httpCode. Response: " . $response);
jsonError("Failed to send OTP SMS");
exit;
}
// 7⃣ إرجاع النتيجة
jsonSuccess(["message" => "OTP sent successfully"]);
?>

View File

@@ -0,0 +1,27 @@
<?php
// Include the database connection file
require_once __DIR__ . '/../../connect.php';
// Filter and encrypt the phone number input
$phone_number = filterRequest("phone_number");
$phone_number = $encryptionHelper->encryptData($phone_number);
// Prepare the SQL query to verify the phone
$sql = "UPDATE phone_verification SET is_verified = 1 WHERE phone_number = :phone_number";
// Prepare the statement
$stmt = $con->prepare($sql);
$stmt->bindParam(":phone_number", $phone_number);
// Execute the query
$stmt->execute();
$affectedRows = $stmt->rowCount();
// Check if the update was successful
if ($affectedRows > 0) {
jsonSuccess(["message" => "Phone number verified successfully"]);
} else {
jsonError("No phone number found or verification failed");
}
?>

View File

@@ -0,0 +1,23 @@
<?php
require_once __DIR__ . '/../../connect.php';
// استقبال وتشفير رقم الهاتف
$phone_number = filterRequest("phone_number");
$phone_number = $encryptionHelper->encryptData($phone_number);
// تنفيذ الاستعلام
$sql = "UPDATE phone_verification_passenger SET verified = 1 WHERE phone_number = :phone_number";
$stmt = $con->prepare($sql);
$stmt->bindParam(":phone_number", $phone_number);
$stmt->execute();
$affectedRows = $stmt->rowCount();
// إرجاع النتيجة
if ($affectedRows > 0) {
jsonSuccess(["message" => "Phone number verified successfully"]);
} else {
jsonError("No phone number found or verification failed");
}
?>