Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae723a75f6 | ||
|
|
e7785c9b2d |
@@ -100,6 +100,7 @@ try {
|
|||||||
$sentSms = 0;
|
$sentSms = 0;
|
||||||
$sentWhatsApp = 0;
|
$sentWhatsApp = 0;
|
||||||
$dispatchedPassengers = [];
|
$dispatchedPassengers = [];
|
||||||
|
$fcmErrors = [];
|
||||||
|
|
||||||
// 6. Save broadcast promo for this campaign (Option 1 - promos table adjustment)
|
// 6. Save broadcast promo for this campaign (Option 1 - promos table adjustment)
|
||||||
$sqlPromo = "INSERT INTO promos
|
$sqlPromo = "INSERT INTO promos
|
||||||
@@ -157,8 +158,14 @@ try {
|
|||||||
$logStmt->execute([$passengerId, $countryCode, $regionName]);
|
$logStmt->execute([$passengerId, $countryCode, $regionName]);
|
||||||
$dispatchedPassengers[] = $passengerId;
|
$dispatchedPassengers[] = $passengerId;
|
||||||
$pushSent = true;
|
$pushSent = true;
|
||||||
|
} else {
|
||||||
|
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => $fcmResult];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => 'Token decryption failed'];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => 'No token in DB'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$pushSent) {
|
if (!$pushSent) {
|
||||||
@@ -224,7 +231,8 @@ try {
|
|||||||
'requested_country' => $countryCode,
|
'requested_country' => $countryCode,
|
||||||
'total_passengers_in_db' => count($allPassengers),
|
'total_passengers_in_db' => count($allPassengers),
|
||||||
'matched_targets' => count($targets),
|
'matched_targets' => count($targets),
|
||||||
'distribution' => $debugCounts
|
'distribution' => $debugCounts,
|
||||||
|
'fcm_errors' => $fcmErrors ?? []
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -53,32 +53,6 @@ class EncryptionHelper
|
|||||||
$decoded = base64_decode($cipherText, true);
|
$decoded = base64_decode($cipherText, true);
|
||||||
if ($decoded === false) return false;
|
if ($decoded === false) return false;
|
||||||
|
|
||||||
// محاولة أولى: استخراج IV عشوائي من أول 16 بايت (كما كان في encrypt_decrypt.php)
|
|
||||||
if (strlen($decoded) >= 16) {
|
|
||||||
$iv = substr($decoded, 0, 16);
|
|
||||||
$payload = substr($decoded, 16);
|
|
||||||
if (strlen($payload) > 0) {
|
|
||||||
$decrypted_rand = openssl_decrypt($payload, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $iv);
|
|
||||||
if ($decrypted_rand !== false) {
|
|
||||||
$pad = ord($decrypted_rand[strlen($decrypted_rand) - 1]);
|
|
||||||
if ($pad >= 1 && $pad <= 16) {
|
|
||||||
// Check if padding is valid
|
|
||||||
$isValidPad = true;
|
|
||||||
for ($i = 1; $i <= $pad; $i++) {
|
|
||||||
if (ord($decrypted_rand[strlen($decrypted_rand) - $i]) !== $pad) {
|
|
||||||
$isValidPad = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($isValidPad) {
|
|
||||||
return substr($decrypted_rand, 0, -$pad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// محاولة ثانية: IV ثابت
|
|
||||||
$decrypted = openssl_decrypt($decoded, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $this->cbcIv);
|
$decrypted = openssl_decrypt($decoded, self::ALGO_CBC, $this->key, OPENSSL_RAW_DATA, $this->cbcIv);
|
||||||
if ($decrypted === false) return false;
|
if ($decrypted === false) return false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user