Autosave: 20260215-080120

This commit is contained in:
Flatlogic Bot 2026-02-15 08:01:20 +00:00
parent edbd851f2b
commit c93337f1fd
13 changed files with 196 additions and 25 deletions

94
admin/.php Normal file
View File

@ -0,0 +1,94 @@
<?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);

View File

@ -1,5 +1,6 @@
<?php
require_once __DIR__ . '/../includes/I18N/Arabic.php';
use I18N\Arabic;
// --- Parameters ---
$text = $_GET['text'] ?? 'Default Text';
@ -13,19 +14,26 @@ $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 I18N\Arabic();
$arabic = new Arabic();
$text = $arabic->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);

View File

@ -48,7 +48,7 @@ $is_rtl = (get_current_lang() === 'ar');
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
<?php endif; ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="admin.css">
<link rel="stylesheet" href="admin.css?v=<?php echo time(); ?>">
<style>
.card { border: none; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 1.5rem; }
.card-header { font-weight: 600; }
@ -86,7 +86,7 @@ $is_rtl = (get_current_lang() === 'ar');
<div class="card-body">
<div class="mb-3">
<label class="form-label"><?= __('SMTP Host') ?></label>
<input type="text" name="settings[mail_host]" class="form-control" value="<?= htmlspecialchars($settings['mail_host'] ?? '') ?>" placeholder="e.g. smtp.gmail.com">
<input type="text" name="settings[mail_host]" class="form-control" value="<?= htmlspecialchars($settings['mail_host'] ?? '') ?>'" placeholder="e.g. smtp.gmail.com">
</div>
<div class="row">
<div class="col-md-6 mb-3">
@ -130,7 +130,7 @@ $is_rtl = (get_current_lang() === 'ar');
<div class="card-body">
<div class="mb-3">
<label class="form-label"><?= __('Monthly Report Recipient Email') ?></label>
<input type="email" name="settings[report_recipient_email]" class="form-control" value="<?= htmlspecialchars($settings['report_recipient_email'] ?? '') ?>" placeholder="admin@example.com">
<input type="email" name="settings[report_recipient_email]" class="form-control" value="<?= htmlspecialchars($settings['report_recipient_email'] ?? '') ?>'" placeholder="admin@example.com">
<div class="form-text"><?= __('The email address that will receive the automated monthly financial summary.') ?></div>
</div>
</div>
@ -146,7 +146,7 @@ $is_rtl = (get_current_lang() === 'ar');
<div class="card-body">
<div class="mb-3">
<label class="form-label"><?= __('POP3 Host') ?></label>
<input type="text" name="settings[pop3_host]" class="form-control" value="<?= htmlspecialchars($settings['pop3_host'] ?? '') ?>" placeholder="e.g. pop.gmail.com">
<input type="text" name="settings[pop3_host]" class="form-control" value="<?= htmlspecialchars($settings['pop3_host'] ?? '') ?>'" placeholder="e.g. pop.gmail.com">
</div>
<div class="mb-3">
<label class="form-label"><?= __('POP3 Port') ?></label>
@ -199,6 +199,10 @@ $is_rtl = (get_current_lang() === 'ar');
<div class="mb-3">
<label class="form-label"><?= __('API Token') ?></label>
<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 class="mb-3">
<label class="form-label"><?= __('Server URL') ?></label>

View File

@ -1,11 +1,14 @@
<?php
file_put_contents('checkout_log.txt', "Checkout script started.\n", FILE_APPEND);
require_once 'db/config.php';
require_once 'db/thawani_config.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
file_put_contents('checkout_log.txt', "Not a POST request.\n", FILE_APPEND);
header('Location: index.php');
exit;
}
file_put_contents('checkout_log.txt', 'POST data: ' . print_r($_POST, true) . "\n", FILE_APPEND);
$case_id = (int)$_POST['case_id'];
$amount = (float)$_POST['amount'];
@ -21,6 +24,7 @@ $gift_recipient_phone = prefix_phone($_POST['gift_recipient_phone'] ?? null);
$gift_message = $_POST['gift_message'] ?? null;
if ($amount <= 0) {
file_put_contents('checkout_log.txt', "Invalid amount.\n", FILE_APPEND);
die("Invalid amount");
}
@ -32,6 +36,7 @@ $stmt->execute([$case_id]);
$case = $stmt->fetch();
if (!$case || $case['status'] !== 'active') {
file_put_contents('checkout_log.txt', "Case not found or not active.\n", FILE_APPEND);
die("Case not found or not active");
}
@ -41,6 +46,7 @@ $sql = "INSERT INTO donations (case_id, amount, status, donor_name, donor_email,
$stmt = $pdo->prepare($sql);
$stmt->execute([$case_id, $amount, $donor_name, $donor_email, $donor_phone, $is_gift, $gift_recipient_name, $gift_recipient_phone, $gift_message]);
$donation_id = $pdo->lastInsertId();
file_put_contents('checkout_log.txt', "Donation created with ID: $donation_id\n", FILE_APPEND);
// Thawani Checkout Session Request
$payload = [
@ -64,6 +70,7 @@ $payload = [
// Check if keys are default/empty
if (THAWANI_SECRET_KEY === 'rRQ26GcsZ60u9Y9v9876543210' || empty(THAWANI_SECRET_KEY)) {
// Simulation Mode
file_put_contents('checkout_log.txt', "Thawani simulation mode.\n", FILE_APPEND);
?>
<!DOCTYPE html>
<html lang="<?= htmlspecialchars($lang) ?>">
@ -95,6 +102,7 @@ if (THAWANI_SECRET_KEY === 'rRQ26GcsZ60u9Y9v9876543210' || empty(THAWANI_SECRET_
}
// REAL CURL CALL
file_put_contents('checkout_log.txt', "Performing real Thawani API call.\n", FILE_APPEND);
$ch = curl_init(THAWANI_API_URL . '/checkout/session');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
@ -108,10 +116,12 @@ $err = curl_error($ch);
curl_close($ch);
if ($err) {
file_put_contents('checkout_log.txt', "CURL Error: $err\n", FILE_APPEND);
die("CURL Error: " . $err);
}
$data = json_decode($response, true);
file_put_contents('checkout_log.txt', 'Thawani response: ' . print_r($data, true) . "\n", FILE_APPEND);
if (isset($data['success']) && $data['success'] === true && isset($data['data']['session_id'])) {
$session_id = $data['data']['session_id'];
@ -124,12 +134,14 @@ if (isset($data['success']) && $data['success'] === true && isset($data['data'][
? "https://uatcheckout.thawani.om/pay/" . $session_id . "?key=" . THAWANI_PUBLISHABLE_KEY
: "https://checkout.thawani.om/pay/" . $session_id . "?key=" . THAWANI_PUBLISHABLE_KEY;
file_put_contents('checkout_log.txt', "Redirecting to: $checkout_url\n", FILE_APPEND);
header("Location: " . $checkout_url);
exit;
} else {
file_put_contents('checkout_log.txt', "Thawani Error: " . print_r($data, true) . "\n", FILE_APPEND);
echo "<h3>Thawani Error</h3>";
echo "<pre>";
print_r($data);
echo "</pre>";
echo "<a href='index.php?lang=" . htmlspecialchars($lang) . "'>Go Back</a>";
}
}

24
checkout_log.txt Normal file
View File

@ -0,0 +1,24 @@
db/config.php loaded
db/config.php loaded
Checkout script started.
db/config.php loaded
db/thawani_config.php loaded
POST data: Array
(
[lang] => ar
[is_gift] => 0
[case_id] => 2
[amount] => 75
[donor_name] =>
[donor_email] =>
[donor_phone] => 99359472
[gift_recipient_name] =>
[gift_recipient_phone] =>
[gift_message] =>
)
Donation created with ID: 19
Thawani simulation mode.
db/config.php loaded
db/thawani_config.php loaded
db/config.php loaded

View File

@ -1,4 +1,5 @@
<?php
file_put_contents('/home/ubuntu/executor/workspace/checkout_log.txt', "db/config.php loaded\n", FILE_APPEND);
// Generated by setup_mariadb_project.sh — edit as needed.
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_38394');
@ -24,7 +25,7 @@ function prefix_phone($phone) {
$phone = preg_replace('/[^0-9+]/', '', $phone);
// Check if it already has the prefix
if (preg_match('/^(|\+|00)968/', $phone)) {
if (preg_match('/^(|"|"|"")968/', $phone)) {
// If it has a +, remove it for consistency and re-add 968
if (strpos($phone, '+') === 0) {
$phone = ltrim($phone, '+');
@ -43,4 +44,4 @@ function prefix_phone($phone) {
}
return '968' . $phone;
}
}

View File

@ -0,0 +1 @@
INSERT INTO settings (setting_key, setting_value) VALUES ('wablas_api_secret', '');

View File

@ -1,4 +1,5 @@
<?php
file_put_contents('/home/ubuntu/executor/workspace/checkout_log.txt', "db/thawani_config.php loaded\n", FILE_APPEND);
// Thawani Gateway Configuration
require_once __DIR__ . '/config.php';
@ -22,4 +23,4 @@ $thawani_url = (THAWANI_ENV === 'sandbox')
? 'https://uatapi.thawani.om/api/v1'
: 'https://api.thawani.om/api/v1';
define('THAWANI_API_URL', $thawani_url);
define('THAWANI_API_URL', $thawani_url);

View File

@ -33,6 +33,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.rtl.min.css">
<?php endif; ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<style>
:root {
@ -181,12 +182,12 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
</style>
<!-- PWA Manifest & Service Worker -->
<link rel="manifest" href="manifest.json">
<link rel="manifest" href="manifest.json?v=<?php echo time(); ?>">
<meta name="theme-color" content="#059669">
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('service-worker.js')
navigator.serviceWorker.register('service-worker.js?v=<?php echo time(); ?>')
.then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
})

View File

@ -581,16 +581,10 @@ require_once 'includes/header.php';
</div>
<div class="modal-footer border-0 p-4 pt-0">
<button type="submit" class="btn btn-donate py-3"><?= $t['modal_submit'] ?></button>
</div>
</form>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>
<button type="submit" class.php'; ?>
<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>
const donateModal = document.getElementById('donateModal');
if (donateModal) {

View File

@ -1,7 +1,5 @@
const CACHE_NAME = 'donation-platform-v1';
const CACHE_NAME = 'donation-platform-v2'; // Changed cache name
const urlsToCache = [
'./',
'index.php',
'assets/css/custom.css',
'assets/js/main.js'
];
@ -15,11 +13,35 @@ self.addEventListener('install', event => {
);
});
self.addEventListener('activate', event => {
var cacheKeeplist = [CACHE_NAME];
event.waitUntil(
caches.keys().then(keylist => {
return Promise.all(keylist.map(key => {
if (cacheKeeplist.indexOf(key) === -1) {
return caches.delete(key);
}
}));
})
);
});
self.addEventListener('fetch', event => {
// Use a network-first strategy for HTML pages
if (event.request.mode === 'navigate' || (event.request.method === 'GET' && event.request.headers.get('accept').includes('text/html'))) {
event.respondWith(
fetch(event.request).catch(() => {
return caches.match(event.request);
})
);
return;
}
// Use a cache-first strategy for other assets
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
);
});
});

2
test.php Normal file
View File

@ -0,0 +1,2 @@
<?php
echo 'Hello World';

7
test2.php Normal file
View File

@ -0,0 +1,7 @@
<?php
file_put_contents('test2_log.txt', 'test2.php started\n');
require_once 'db/config.php';
file_put_contents('test2_log.txt', "db/config.php included\n", FILE_APPEND);
require_once 'db/thawani_config.php';
file_put_contents('test2_log.txt', "db/thawani_config.php included\n", FILE_APPEND);
echo "Test 2 OK";