fixing errors
This commit is contained in:
parent
a251e37178
commit
0b22cc2f02
@ -18,7 +18,15 @@ function db() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_permission($page = null, $user_id = null) {
|
function check_permission($page = null, $user_id = null) {
|
||||||
if (!$user_id) $user_id = $_SESSION['user_id'] ?? null;
|
// Safely access session
|
||||||
|
if (!$user_id) {
|
||||||
|
if (isset($_SESSION) && isset($_SESSION['user_id'])) {
|
||||||
|
$user_id = $_SESSION['user_id'];
|
||||||
|
} else {
|
||||||
|
$user_id = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$page) $page = basename($_SERVER['PHP_SELF']);
|
if (!$page) $page = basename($_SERVER['PHP_SELF']);
|
||||||
if (!$user_id) return ['view' => 0, 'add' => 0, 'edit' => 0, 'delete' => 0];
|
if (!$user_id) return ['view' => 0, 'add' => 0, 'edit' => 0, 'delete' => 0];
|
||||||
|
|
||||||
|
|||||||
@ -3,19 +3,28 @@ if (session_status() === PHP_SESSION_NONE) {
|
|||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load environment variables from the root .env file (if present)
|
||||||
|
*/
|
||||||
function load_dotenv_lang(): void {
|
function load_dotenv_lang(): void {
|
||||||
static $loaded = false;
|
static $loaded = false;
|
||||||
if ($loaded) return;
|
if ($loaded) return;
|
||||||
$envPath = realpath(__DIR__ . '/../../.env'); // executor/.env
|
$envPath = realpath(__DIR__ . '/../../.env'); // executor/.env
|
||||||
if ($envPath && is_readable($envPath)) {
|
if ($envPath && is_readable($envPath)) {
|
||||||
$lines = @file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];
|
$lines = @file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
foreach ($lines as $line) {
|
if ($lines !== false) {
|
||||||
if ($line[0] === '#' || trim($line) === '') continue;
|
foreach ($lines as $line) {
|
||||||
if (!str_contains($line, '=')) continue;
|
$line = trim($line);
|
||||||
[$k, $v] = array_map('trim', explode('=', $line, 2));
|
if ($line === '' || $line[0] === '#') continue;
|
||||||
$v = trim($v, "' ");
|
if (!str_contains($line, '=')) continue;
|
||||||
if ($k !== '' && (getenv($k) === false || getenv($k) === '')) {
|
[$k, $v] = array_map('trim', explode('=', $line, 2));
|
||||||
putenv("{$k}={$v}");
|
if ($k === '') continue;
|
||||||
|
$v = trim($v, "' ");
|
||||||
|
if (getenv($k) === false || getenv($k) === '') {
|
||||||
|
putenv("{$k}={$v}");
|
||||||
|
$_ENV[$k] = $v;
|
||||||
|
$_SERVER[$k] = $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$loaded = true;
|
$loaded = true;
|
||||||
@ -132,7 +141,7 @@ $translations = [
|
|||||||
'company_profile' => 'Settings',
|
'company_profile' => 'Settings',
|
||||||
'user_profile' => 'User Profile',
|
'user_profile' => 'User Profile',
|
||||||
'logo' => 'Logo',
|
'logo' => 'Logo',
|
||||||
'favicon' => 'Aيقونة الموقع',
|
'favicon' => 'أيقونة الموقع',
|
||||||
'email' => 'Email',
|
'email' => 'Email',
|
||||||
'address_en' => 'Address (EN)',
|
'address_en' => 'Address (EN)',
|
||||||
'address_ar' => 'Address (AR)',
|
'address_ar' => 'Address (AR)',
|
||||||
@ -377,7 +386,7 @@ $translations = [
|
|||||||
'update_status' => 'تحديث الحالة',
|
'update_status' => 'تحديث الحالة',
|
||||||
'update' => 'تحديث',
|
'update' => 'تحديث',
|
||||||
'remaining_amount' => 'المبلغ المتبقي',
|
'remaining_amount' => 'المبلغ المتبقي',
|
||||||
'add_payment' => 'إضافة دفعة',
|
'add_payment' => 'إإضافة دفعة',
|
||||||
'payment_method' => 'طريقة الدفع',
|
'payment_method' => 'طريقة الدفع',
|
||||||
'customer_details' => 'تفاصيل العميل',
|
'customer_details' => 'تفاصيل العميل',
|
||||||
'order_date' => 'تاريخ الطلب',
|
'order_date' => 'تاريخ الطلب',
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once __DIR__ . '/db/config.php';
|
require_once __DIR__ . '/db/config.php';
|
||||||
if ($_SESSION['role'] === 'limited_viewer') { die('Access Denied'); }
|
|
||||||
require_once __DIR__ . '/includes/lang.php';
|
require_once __DIR__ . '/includes/lang.php';
|
||||||
|
|
||||||
|
if (($_SESSION['role'] ?? 'cashier') === 'limited_viewer') { die('Access Denied'); }
|
||||||
|
|
||||||
$order_id = $_GET['id'] ?? null;
|
$order_id = $_GET['id'] ?? null;
|
||||||
if (!$order_id) {
|
if (!$order_id) {
|
||||||
die("Order ID is required");
|
die("Order ID is required");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user