adjust language selector

This commit is contained in:
Ibnu Maksum
2024-08-15 15:33:44 +07:00
parent 960d141246
commit 6740b0212d
6 changed files with 48 additions and 61 deletions

View File

@ -241,25 +241,24 @@ switch ($action) {
case 'language-update-post':
global $root_path;
if (!empty($_POST['language'])) {
$selected_language = $_POST['language'];
$selected_language = _req('lang', 'english');
$_SESSION['user_language'] = $selected_language;
$_SESSION['user_language'] = $selected_language;
$lan_file = $root_path . File::pathFixer('system/lan/' . $selected_language . '.json');
$lan_file = $root_path . File::pathFixer('system/lan/' . $selected_language . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
r2($_SERVER['HTTP_REFERER'], 's', Lang::T('Languge set to ' . $selected_language));
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
r2($_SERVER['HTTP_REFERER'], 's', ucwords($selected_language));
break;
default:

View File

@ -21,7 +21,7 @@ switch ($action) {
$p = ORM::for_table('tbl_plans')->find_one($bill['plan_id']);
$dvc = Package::getDevice($p);
if ($_app_stage != 'demo') {
try{
try {
if (file_exists($dvc)) {
require_once $dvc;
if ((new $p['device'])->online_customer($user, $bill['routers'])) {
@ -36,7 +36,7 @@ switch ($action) {
} else {
die(Lang::T('-'));
}
}catch (Exception $e) {
} catch (Exception $e) {
die(Lang::T('Failed to connect to device'));
}
}
@ -47,14 +47,31 @@ switch ($action) {
break;
case 'inbox_unread':
$count = ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->whereRaw('date_read is null')->count('id');
if($count>0){
if ($count > 0) {
echo $count;
}
die();
case 'inbox':
$inboxs = ORM::for_table('tbl_customers_inbox')->selects(['id', 'subject', 'date_created'])->where('customer_id', $user['id'])->whereRaw('date_read is null')->order_by_desc('date_created')->limit(10)->find_many();
foreach($inboxs as $inbox){
echo '<li><a href="'.U.'mail/view/'.$inbox['id'].'">'.$inbox['subject'].'<br><sub class="text-muted">'.Lang::dateTimeFormat($inbox['date_created']).'</sub></a></li>';
foreach ($inboxs as $inbox) {
echo '<li><a href="' . U . 'mail/view/' . $inbox['id'] . '">' . $inbox['subject'] . '<br><sub class="text-muted">' . Lang::dateTimeFormat($inbox['date_created']) . '</sub></a></li>';
}
die();
case 'language':
$select = _get('select');
$folders = [];
$files = scandir('system/lan/');
foreach ($files as $file) {
if (is_file('system/lan/' . $file) && !in_array($file, ['index.html', 'country.json', '.DS_Store'])) {
$file = str_replace(".json", "", $file);
if(!empty($file)){
echo '<li><a href="' . U . 'accounts/language-update-post&lang=' . $file. '">';
if($select == $file){
echo '<span class="glyphicon glyphicon-ok"></span> ';
}
echo ucwords($file) . '</a></li>';
}
}
}
die();
default: