Deploy: 2026-05-23 18:30:59
This commit is contained in:
31
backend/api/debug-fonts.php
Normal file
31
backend/api/debug-fonts.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$fontDir = __DIR__ . '/../fonts';
|
||||||
|
$files = [];
|
||||||
|
|
||||||
|
if (is_dir($fontDir)) {
|
||||||
|
$dirFiles = scandir($fontDir);
|
||||||
|
foreach ($dirFiles as $file) {
|
||||||
|
if ($file === '.' || $file === '..') continue;
|
||||||
|
$path = $fontDir . '/' . $file;
|
||||||
|
$files[$file] = [
|
||||||
|
'exists' => true,
|
||||||
|
'size' => filesize($path),
|
||||||
|
'readable' => is_readable($path),
|
||||||
|
'md5' => md5_file($path)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$gdInfo = function_exists('gd_info') ? gd_info() : 'Not available';
|
||||||
|
$ttfSupport = function_exists('imagettftext');
|
||||||
|
|
||||||
|
echo json_encode([
|
||||||
|
'font_dir_exists' => is_dir($fontDir),
|
||||||
|
'font_dir_path' => realpath($fontDir),
|
||||||
|
'files' => $files,
|
||||||
|
'gd_info' => $gdInfo,
|
||||||
|
'imagettftext_exists' => $ttfSupport
|
||||||
|
], JSON_PRETTY_PRINT);
|
||||||
|
?>
|
||||||
@@ -116,10 +116,10 @@ class WhatsAppClient {
|
|||||||
|
|
||||||
foreach ($fonts as $filename => $url) {
|
foreach ($fonts as $filename => $url) {
|
||||||
$path = $fontDir . '/' . $filename;
|
$path = $fontDir . '/' . $filename;
|
||||||
if (!file_exists($path) || @filesize($path) < 1000) {
|
if (!file_exists($path) || @filesize($path) < 20000) {
|
||||||
// Try file_get_contents first
|
// Try file_get_contents first
|
||||||
$content = @file_get_contents($url);
|
$content = @file_get_contents($url);
|
||||||
if ($content !== false && strlen($content) > 1000) {
|
if ($content !== false && strlen($content) > 20000) {
|
||||||
@file_put_contents($path, $content);
|
@file_put_contents($path, $content);
|
||||||
} elseif (function_exists('curl_init')) {
|
} elseif (function_exists('curl_init')) {
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
@@ -129,7 +129,7 @@ class WhatsAppClient {
|
|||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
|
||||||
$content = curl_exec($ch);
|
$content = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
if ($content && strlen($content) > 1000) {
|
if ($content && strlen($content) > 20000) {
|
||||||
@file_put_contents($path, $content);
|
@file_put_contents($path, $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,10 +167,10 @@ class WhatsAppClient {
|
|||||||
$availableFonts = [];
|
$availableFonts = [];
|
||||||
if (function_exists('imagettftext')) {
|
if (function_exists('imagettftext')) {
|
||||||
$fontDir = __DIR__ . '/../fonts';
|
$fontDir = __DIR__ . '/../fonts';
|
||||||
if (file_exists($fontDir . '/Roboto-Bold.ttf') && @filesize($fontDir . '/Roboto-Bold.ttf') > 1000) {
|
if (file_exists($fontDir . '/Roboto-Bold.ttf') && @filesize($fontDir . '/Roboto-Bold.ttf') > 20000) {
|
||||||
$availableFonts[] = $fontDir . '/Roboto-Bold.ttf';
|
$availableFonts[] = $fontDir . '/Roboto-Bold.ttf';
|
||||||
}
|
}
|
||||||
if (file_exists($fontDir . '/CourierPrime-Bold.ttf') && @filesize($fontDir . '/CourierPrime-Bold.ttf') > 1000) {
|
if (file_exists($fontDir . '/CourierPrime-Bold.ttf') && @filesize($fontDir . '/CourierPrime-Bold.ttf') > 20000) {
|
||||||
$availableFonts[] = $fontDir . '/CourierPrime-Bold.ttf';
|
$availableFonts[] = $fontDir . '/CourierPrime-Bold.ttf';
|
||||||
}
|
}
|
||||||
if (!empty($availableFonts)) {
|
if (!empty($availableFonts)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user