From 576ab6041e6822ec7bf196a828459560024b5460 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 23 May 2026 18:39:58 +0300 Subject: [PATCH] Deploy: 2026-05-23 18:39:58 --- backend/includes/WhatsApp.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/backend/includes/WhatsApp.php b/backend/includes/WhatsApp.php index fd417d4..bc5a43c 100644 --- a/backend/includes/WhatsApp.php +++ b/backend/includes/WhatsApp.php @@ -114,14 +114,32 @@ class WhatsAppClient { return; } + // Use jsDelivr CDN to bypass GitHub User-Agent blocks and rate limiting $fonts = [ - 'Roboto-Bold.ttf' => 'https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Bold.ttf', - 'Lora-Bold.ttf' => 'https://github.com/google/fonts/raw/main/ofl/lora/Lora-Bold.ttf' + 'Roboto-Bold.ttf' => 'https://cdn.jsdelivr.net/gh/google/fonts@main/apache/roboto/static/Roboto-Bold.ttf', + 'Lora-Bold.ttf' => 'https://cdn.jsdelivr.net/gh/google/fonts@main/ofl/lora/Lora-Bold.ttf' ]; foreach ($fonts as $filename => $url) { $path = $fontDir . '/' . $filename; - if (!file_exists($path) || @filesize($path) < 20000) { + + // Validate if file exists and starts with valid TTF signatures + $isValid = false; + if (file_exists($path) && filesize($path) > 20000) { + $fp = @fopen($path, 'rb'); + if ($fp) { + $sig = fread($fp, 4); + fclose($fp); + // Match TTF signatures: 0x00010000, 'OTTO', 'true' + if ($sig === "\x00\x01\x00\x00" || $sig === "OTTO" || $sig === "true") { + $isValid = true; + } + } + } + + if (!$isValid) { + @unlink($path); // Delete invalid/corrupted file + // Try file_get_contents first $content = @file_get_contents($url); if ($content !== false && strlen($content) > 20000) {