updating index page
This commit is contained in:
parent
c93337f1fd
commit
bad94e5628
94
admin/.php
94
admin/.php
@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once __DIR__ . '/../includes/I18N/Arabic.php';
|
|
||||||
use I18N\Arabic;
|
|
||||||
|
|
||||||
// --- Parameters ---
|
|
||||||
$text = $_GET['text'] ?? 'Default Text';
|
|
||||||
$lang = $_GET['lang'] ?? 'en';
|
|
||||||
$template = $_GET['template'] ?? 'default';
|
|
||||||
|
|
||||||
// --- Configuration ---
|
|
||||||
$width = 800;
|
|
||||||
$height = 600;
|
|
||||||
$font_size = 24;
|
|
||||||
$font_file = __DIR__ . '/../includes/fpdf/font/amiri.ttf';
|
|
||||||
$template_image = __DIR__ . '/../assets/images/card_templates/' . basename($template) . '.png';
|
|
||||||
|
|
||||||
if (!file_exists($font_file)) {
|
|
||||||
http_response_code(500);
|
|
||||||
die('Font file not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($template_image)) {
|
|
||||||
$template_image = __DIR__ . '/../assets/images/card_templates/default.png';
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- Text Processing for Arabic ---
|
|
||||||
if ($lang === 'ar') {
|
|
||||||
$arabic = new Arabic();
|
|
||||||
$text = $arabic->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);
|
|
||||||
@ -199,15 +199,15 @@ $is_rtl = (get_current_lang() === 'ar');
|
|||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label"><?= __('API Token') ?></label>
|
<label class="form-label"><?= __('API Token') ?></label>
|
||||||
<input type="password" name="settings[wablas_api_token]" class="form-control" value="<?= htmlspecialchars($settings['wablas_api_token'] ?? '') ?>">
|
<input type="password" name="settings[wablas_api_token]" class="form-control" value="<?= htmlspecialchars($settings['wablas_api_token'] ?? '') ?>">
|
||||||
</div>
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label"><?= __('Security Key') ?></label>
|
|
||||||
<input type="password" name="settings[wablas_api_secret]" class="form-control" value="<?= htmlspecialchars($settings['wablas_api_secret'] ?? '') ?>">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label"><?= __('Server URL') ?></label>
|
<label class="form-label"><?= __('Server URL') ?></label>
|
||||||
<input type="url" name="settings[wablas_server_url]" class="form-control" value="<?= htmlspecialchars($settings['wablas_server_url'] ?? 'https://console.wablas.com') ?>">
|
<input type="url" name="settings[wablas_server_url]" class="form-control" value="<?= htmlspecialchars($settings['wablas_server_url'] ?? 'https://console.wablas.com') ?>">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">WABLAS SECURITY KEY</label>
|
||||||
|
<input type="text" name="settings[wablas_api_secret]" class="form-control" value="<?= htmlspecialchars($settings['wablas_api_secret'] ?? '') ?>">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- WhatsApp Settings -->
|
<!-- WhatsApp Settings -->
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
db/config.php loaded
|
db/config.php loaded
|
||||||
db/config.php loaded
|
|
||||||
Checkout script started.
|
Checkout script started.
|
||||||
db/config.php loaded
|
db/config.php loaded
|
||||||
db/thawani_config.php loaded
|
db/thawani_config.php loaded
|
||||||
@ -8,7 +7,7 @@ POST data: Array
|
|||||||
[lang] => ar
|
[lang] => ar
|
||||||
[is_gift] => 0
|
[is_gift] => 0
|
||||||
[case_id] => 2
|
[case_id] => 2
|
||||||
[amount] => 75
|
[amount] => 50
|
||||||
[donor_name] =>
|
[donor_name] =>
|
||||||
[donor_email] =>
|
[donor_email] =>
|
||||||
[donor_phone] => 99359472
|
[donor_phone] => 99359472
|
||||||
@ -17,8 +16,6 @@ POST data: Array
|
|||||||
[gift_message] =>
|
[gift_message] =>
|
||||||
)
|
)
|
||||||
|
|
||||||
Donation created with ID: 19
|
Donation created with ID: 20
|
||||||
Thawani simulation mode.
|
Thawani simulation mode.
|
||||||
db/config.php loaded
|
db/config.php loaded
|
||||||
db/thawani_config.php loaded
|
|
||||||
db/config.php loaded
|
|
||||||
|
|||||||
14
index.php
14
index.php
@ -1,4 +1,4 @@
|
|||||||
<?php
|
'''<?php
|
||||||
require_once 'db/config.php';
|
require_once 'db/config.php';
|
||||||
|
|
||||||
// Language configuration
|
// Language configuration
|
||||||
@ -581,7 +581,14 @@ require_once 'includes/header.php';
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer border-0 p-4 pt-0">
|
<div class="modal-footer border-0 p-4 pt-0">
|
||||||
<button type="submit" class.php'; ?>
|
<button type="submit" class="btn btn-primary w-100 rounded-pill py-3 fw-bold"><?= $t['modal_submit'] ?></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require_once 'includes/footer.php'; ?>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
@ -642,4 +649,5 @@ require_once 'includes/header.php';
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
''
|
||||||
@ -7,9 +7,10 @@ class WablasService {
|
|||||||
$settings = $pdo->query("SELECT setting_key, setting_value FROM settings WHERE setting_key LIKE 'wablas_%'")->fetchAll(PDO::FETCH_KEY_PAIR);
|
$settings = $pdo->query("SELECT setting_key, setting_value FROM settings WHERE setting_key LIKE 'wablas_%'")->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
|
||||||
$token = $settings['wablas_api_token'] ?? '';
|
$token = $settings['wablas_api_token'] ?? '';
|
||||||
|
$secret = $settings['wablas_api_secret'] ?? '';
|
||||||
$serverUrl = $settings['wablas_server_url'] ?? '';
|
$serverUrl = $settings['wablas_server_url'] ?? '';
|
||||||
|
|
||||||
if (empty($token) || empty($serverUrl)) {
|
if (empty($token) || empty($serverUrl) || empty($secret)) {
|
||||||
error_log("Wablas settings missing.");
|
error_log("Wablas settings missing.");
|
||||||
return ['success' => false, 'error' => 'Settings missing'];
|
return ['success' => false, 'error' => 'Settings missing'];
|
||||||
}
|
}
|
||||||
@ -19,7 +20,10 @@ class WablasService {
|
|||||||
$data = ['phone' => $to, 'message' => $message];
|
$data = ['phone' => $to, 'message' => $message];
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Authorization: $token"]);
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
|
"Authorization: $token",
|
||||||
|
"Secret: $secret"
|
||||||
|
]);
|
||||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||||
@ -50,9 +54,10 @@ class WablasService {
|
|||||||
$settings = $pdo->query("SELECT setting_key, setting_value FROM settings WHERE setting_key LIKE 'wablas_%'")->fetchAll(PDO::FETCH_KEY_PAIR);
|
$settings = $pdo->query("SELECT setting_key, setting_value FROM settings WHERE setting_key LIKE 'wablas_%'")->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
|
||||||
$token = $settings['wablas_api_token'] ?? '';
|
$token = $settings['wablas_api_token'] ?? '';
|
||||||
|
$secret = $settings['wablas_api_secret'] ?? '';
|
||||||
$serverUrl = $settings['wablas_server_url'] ?? '';
|
$serverUrl = $settings['wablas_server_url'] ?? '';
|
||||||
|
|
||||||
if (empty($token) || empty($serverUrl)) {
|
if (empty($token) || empty($serverUrl) || empty($secret)) {
|
||||||
error_log("Wablas settings missing.");
|
error_log("Wablas settings missing.");
|
||||||
return ['success' => false, 'error' => 'Settings missing'];
|
return ['success' => false, 'error' => 'Settings missing'];
|
||||||
}
|
}
|
||||||
@ -70,6 +75,7 @@ class WablasService {
|
|||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
"Authorization: $token",
|
"Authorization: $token",
|
||||||
|
"Secret: $secret",
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
'Content-Length: ' . strlen($jsonData)
|
'Content-Length: ' . strlen($jsonData)
|
||||||
]);
|
]);
|
||||||
@ -209,4 +215,4 @@ class WablasService {
|
|||||||
|
|
||||||
return self::sendTemplatedMessage($case['contact_phone'], 'case_donation_notification', $vars, $lang);
|
return self::sendTemplatedMessage($case['contact_phone'], 'case_donation_notification', $vars, $lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user