From c93337f1fd274b461551437edec1f1b805a7b262 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 15 Feb 2026 08:01:20 +0000 Subject: [PATCH] Autosave: 20260215-080120 --- admin/.php | 94 +++++++++++++++++++ admin/generate_card.php | 14 ++- admin/settings.php | 12 ++- checkout.php | 14 ++- checkout_log.txt | 24 +++++ db/config.php | 5 +- .../20260215_add_wablas_api_secret.sql | 1 + db/thawani_config.php | 3 +- includes/header.php | 5 +- index.php | 10 +- service-worker.js | 30 +++++- test.php | 2 + test2.php | 7 ++ 13 files changed, 196 insertions(+), 25 deletions(-) create mode 100644 admin/.php create mode 100644 checkout_log.txt create mode 100644 db/migrations/20260215_add_wablas_api_secret.sql create mode 100644 test.php create mode 100644 test2.php diff --git a/admin/.php b/admin/.php new file mode 100644 index 0000000..5df5df3 --- /dev/null +++ b/admin/.php @@ -0,0 +1,94 @@ +utf8Glyphs($text); +} + +// --- Image Generation --- +header('Content-Type: image/png'); +$image = imagecreatefrompng($template_image); +imagealphablending($image, true); +imagesavealpha($image, true); + +// Colors +$text_color = imagecolorallocate($image, 0, 0, 0); // Black + +// --- Text Wrapping and Positioning --- +$lines = []; +if ($lang === 'ar') { + // Simple reverse for RTL line wrapping (basic) + $words = explode(' ', $text); + $line = ''; + foreach ($words as $word) { + $new_line = $line . ' ' . $word; + $bbox = imagettfbbox($font_size, 0, $font_file, $new_line); + $line_width = abs($bbox[2] - $bbox[0]); + if ($line_width > ($width - 80)) { // 40px margin + $lines[] = $line; + $line = $word; + } else { + $line = $new_line; + } + } + $lines[] = $line; +} else { + $words = explode(' ', $text); + $line = ''; + foreach ($words as $word) { + $new_line = $line . ($line ? ' ' : '') . $word; + $bbox = imagettfbbox($font_size, 0, $font_file, $new_line); + $line_width = abs($bbox[2] - $bbox[0]); + if ($line_width > ($width - 80)) { // 40px margin + $lines[] = $line; + $line = $word; + } else { + $line = $new_line; + } + } + $lines[] = $line; +} + + +// Calculate total text height +$total_text_height = count($lines) * ($font_size * 1.5); +$y_start = ($height - $total_text_height) / 2; + +// Draw text line by line +foreach ($lines as $i => $line) { + $line = trim($line); + $bbox = imagettfbbox($font_size, 0, $font_file, $line); + $line_width = abs($bbox[2] - $bbox[0]); + $x = ($width - $line_width) / 2; + $y = $y_start + ($i * $font_size * 1.5); + imagettftext($image, $font_size, 0, $x, $y, $text_color, $font_file, $line); +} + + +// --- Output --- +imagepng($image); +imagedestroy($image); diff --git a/admin/generate_card.php b/admin/generate_card.php index e8553ea..5df5df3 100644 --- a/admin/generate_card.php +++ b/admin/generate_card.php @@ -1,5 +1,6 @@ utf8Glyphs($text); } // --- Image Generation --- -header('Content-Type: image/jpeg'); +header('Content-Type: image/png'); $image = imagecreatefrompng($template_image); +imagealphablending($image, true); +imagesavealpha($image, true); // Colors $text_color = imagecolorallocate($image, 0, 0, 0); // Black @@ -82,5 +90,5 @@ foreach ($lines as $i => $line) { // --- Output --- -imagejpeg($image); +imagepng($image); imagedestroy($image); diff --git a/admin/settings.php b/admin/settings.php index 2ed8880..210fad5 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -48,7 +48,7 @@ $is_rtl = (get_current_lang() === 'ar'); - + - + +