Initial commit with updated Auth and media ignored
This commit is contained in:
0
auth/sms/error_log
Normal file
0
auth/sms/error_log
Normal file
28
auth/sms/getSender.php
Normal file
28
auth/sms/getSender.php
Normal 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");
|
||||
}
|
||||
|
||||
?>
|
||||
68
auth/sms/sms_to_user_change_fingerprint.php
Normal file
68
auth/sms/sms_to_user_change_fingerprint.php
Normal 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"]);
|
||||
?>
|
||||
27
auth/sms/updatePhoneInvalidSMS.php
Normal file
27
auth/sms/updatePhoneInvalidSMS.php
Normal 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");
|
||||
}
|
||||
?>
|
||||
23
auth/sms/updatePhoneInvalidSMSPassenger.php
Normal file
23
auth/sms/updatePhoneInvalidSMSPassenger.php
Normal 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");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user