Update: 2026-06-24 22:56:39
This commit is contained in:
@@ -131,30 +131,15 @@ function sendNabehOtp(string $receiver, string $otp, string $method = '', string
|
||||
// Strip symbols for Nabeh endpoint
|
||||
$phoneRaw = preg_replace('/\D+/', '', $receiver);
|
||||
|
||||
// Map method/type
|
||||
$type = 'text';
|
||||
if ($method === 'voice') {
|
||||
$type = 'voice';
|
||||
// Map method/type (Image OTP is the default and only media method allowed)
|
||||
$type = 'image';
|
||||
if ($method === 'text') {
|
||||
$type = 'text';
|
||||
} elseif ($method === 'image') {
|
||||
$type = 'image';
|
||||
} elseif ($method === 'text') {
|
||||
$type = 'text';
|
||||
} else {
|
||||
// Strict alternating using Redis
|
||||
global $redis;
|
||||
$type = 'image'; // default
|
||||
if ($redis) {
|
||||
try {
|
||||
$lastType = $redis->get('nabeh_last_type');
|
||||
$type = ($lastType === 'image') ? 'voice' : 'image';
|
||||
$redis->set('nabeh_last_type', $type);
|
||||
} catch (Exception $e) {
|
||||
error_log("⚠️ [Nabeh OTP Redis alternate] Error toggling type: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
// Fallback to random if Redis is not connected
|
||||
$type = (random_int(0, 1) === 0) ? 'image' : 'voice';
|
||||
}
|
||||
// If no method specified or if 'voice' was requested, force default to 'image'
|
||||
$type = 'image';
|
||||
}
|
||||
|
||||
$appName = 'سيرو رايدر';
|
||||
|
||||
@@ -34,6 +34,15 @@ class EncryptionHelper
|
||||
return self::PREFIX_GCM . base64_encode($iv . $tag . $encrypted);
|
||||
}
|
||||
|
||||
// ─── تشفير نص باستخدام AES-256-CBC الحتمي ──
|
||||
public function encryptDataDeterministic(string $plainText): string
|
||||
{
|
||||
$plainText = mb_convert_encoding($plainText, 'UTF-8');
|
||||
$padded = $this->addPadding($plainText);
|
||||
$encrypted = openssl_encrypt($padded, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $this->cbcIv);
|
||||
return base64_encode($encrypted);
|
||||
}
|
||||
|
||||
// ─── فك تشفير نص (يدعم CBC والـ GCM المستقبلي) ───────────
|
||||
public function decryptData(string $cipherText): string|false
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user