Deploy: 2026-05-23 02:02:00

This commit is contained in:
Hamza-Ayed
2026-05-23 02:02:00 +03:00
parent 6726fe89d6
commit 73fd2f2b1f

View File

@@ -28,9 +28,22 @@ class OTPController extends BaseController
if (function_exists('imagecreate')) { if (function_exists('imagecreate')) {
// Base image // Base image
$img = imagecreatetruecolor(400, 200); $img = imagecreatetruecolor(400, 200);
$bg = imagecolorallocate($img, 240, 248, 255); // Alice blue background
$textColor = imagecolorallocate($img, 15, 23, 42); // Dark text // Define high-contrast, beautiful color palettes [bg, text, line]
$lineColor = imagecolorallocate($img, 203, 213, 225); // Subtle lines $palettes = [
['bg' => [240, 248, 255], 'text' => [15, 23, 42], 'line' => [148, 163, 184]], // Light Blue / Dark Navy
['bg' => [255, 250, 240], 'text' => [67, 20, 7], 'line' => [252, 211, 77]], // Floral White / Dark Brown
['bg' => [240, 253, 244], 'text' => [6, 78, 59], 'line' => [110, 231, 183]], // Mint Green / Dark Green
['bg' => [254, 242, 242], 'text' => [127, 29, 29], 'line' => [252, 165, 165]], // Light Red / Dark Red
['bg' => [250, 245, 255], 'text' => [88, 28, 135], 'line' => [216, 180, 254]], // Light Purple / Dark Purple
['bg' => [255, 247, 237], 'text' => [154, 52, 18], 'line' => [253, 186, 116]], // Light Orange / Dark Orange
];
$palette = $palettes[array_rand($palettes)];
$bg = imagecolorallocate($img, $palette['bg'][0], $palette['bg'][1], $palette['bg'][2]);
$textColor = imagecolorallocate($img, $palette['text'][0], $palette['text'][1], $palette['text'][2]);
$lineColor = imagecolorallocate($img, $palette['line'][0], $palette['line'][1], $palette['line'][2]);
imagefill($img, 0, 0, $bg); imagefill($img, 0, 0, $bg);
@@ -39,17 +52,27 @@ class OTPController extends BaseController
imageline($img, rand(0, 400), rand(0, 200), rand(0, 400), rand(0, 200), $lineColor); imageline($img, rand(0, 400), rand(0, 200), rand(0, 400), rand(0, 200), $lineColor);
} }
// Create a temporary small image for the text (since built-in font 5 is small) // Add random noise dots
for ($i = 0; $i < 200; $i++) {
imagesetpixel($img, rand(0, 400), rand(0, 200), $lineColor);
}
// Create a temporary small image for the text
$tmp = imagecreatetruecolor(100, 40); $tmp = imagecreatetruecolor(100, 40);
$tmpBg = imagecolorallocate($tmp, 240, 248, 255); $tmpBg = imagecolorallocate($tmp, $palette['bg'][0], $palette['bg'][1], $palette['bg'][2]);
$tmpText = imagecolorallocate($tmp, 15, 23, 42); $tmpText = imagecolorallocate($tmp, $palette['text'][0], $palette['text'][1], $palette['text'][2]);
imagefill($tmp, 0, 0, $tmpBg); imagefill($tmp, 0, 0, $tmpBg);
$spacedCode = implode(' ', str_split($code)); $spacedCode = implode(' ', str_split($code)); // Slightly wider spacing
imagestring($tmp, 5, 10, 12, $spacedCode, $tmpText);
// Scale up the text image to the main image // Draw text multiple times with 1px offsets to create a bold effect
imagecopyresized($img, $tmp, 0, 0, 0, 0, 400, 200, 100, 40); imagestring($tmp, 5, 8, 12, $spacedCode, $tmpText);
imagestring($tmp, 5, 9, 12, $spacedCode, $tmpText); // Bold X
imagestring($tmp, 5, 8, 13, $spacedCode, $tmpText); // Bold Y
imagestring($tmp, 5, 9, 13, $spacedCode, $tmpText); // Bold XY
// Scale up the text image to the main image using resampled for smooth (non-pixelated) edges
imagecopyresampled($img, $tmp, 0, 0, 0, 0, 400, 200, 100, 40);
imagepng($img, $filepath); imagepng($img, $filepath);
imagedestroy($img); imagedestroy($img);
@@ -198,8 +221,7 @@ class OTPController extends BaseController
} else if ($type === 'image') { } else if ($type === 'image') {
// Generate OTP Image // Generate OTP Image
$imageUrl = $this->generateOtpImage($code); $imageUrl = $this->generateOtpImage($code);
$captionMsg = "مرحباً! هذا هو رمز التحقق الخاص بك لمتجر نابه. الرجاء عدم مشاركته."; ConversationFlowEngine::sendReply($session, $phone, '', $imageUrl);
ConversationFlowEngine::sendReply($session, $phone, $captionMsg, $imageUrl);
} else { } else {
// Send text // Send text
$textMsg = "رمز التحقق الخاص بك لمتجر نابه هو: *{$code}* \n الرجاء عدم مشاركته مع أي شخص."; $textMsg = "رمز التحقق الخاص بك لمتجر نابه هو: *{$code}* \n الرجاء عدم مشاركته مع أي شخص.";