diff --git a/init.php b/init.php index c6072656..76c9cd27 100644 --- a/init.php +++ b/init.php @@ -322,3 +322,16 @@ function _alert($text, $type = 'success', $url = "home", $time = 3) if (!isset($api_secret)) { $api_secret = $db_password; } + +function displayMaintenanceMessage(): void +{ + global $config, $ui; + $date = $config['maintenance_date']; + if ($date){ + $ui->assign('date', $date); + } + http_response_code(503); + $ui->assign('companyName', $config['CompanyName']); + $ui->display('maintenance.tpl'); + die(); +} diff --git a/system/controllers/login.php b/system/controllers/login.php index cb246dec..663d3c02 100644 --- a/system/controllers/login.php +++ b/system/controllers/login.php @@ -5,6 +5,11 @@ * by https://t.me/ibnux **/ + $maintenance_mode = $config['maintenance_mode']; + if ($maintenance_mode == true){ + displayMaintenanceMessage(); + } + if (User::getID()) { r2(U . 'home'); } diff --git a/system/controllers/settings.php b/system/controllers/settings.php index 4419720f..b259c668 100644 --- a/system/controllers/settings.php +++ b/system/controllers/settings.php @@ -704,12 +704,12 @@ switch ($action) { $suc = 0; $fal = 0; $json = json_decode(file_get_contents($_FILES['json']['tmp_name']), true); - try{ + try { ORM::raw_execute("SET FOREIGN_KEY_CHECKS=0;"); } catch (Throwable $e) { } catch (Exception $e) { } - try{ + try { ORM::raw_execute("SET GLOBAL FOREIGN_KEY_CHECKS=0;"); } catch (Throwable $e) { } catch (Exception $e) { @@ -717,7 +717,7 @@ switch ($action) { foreach ($json as $table => $records) { ORM::raw_execute("TRUNCATE $table;"); foreach ($records as $rec) { - try{ + try { $t = ORM::for_table($table)->create(); foreach ($rec as $k => $v) { if ($k != 'id') { @@ -736,12 +736,12 @@ switch ($action) { } } } - try{ + try { ORM::raw_execute("SET FOREIGN_KEY_CHECKS=1;"); } catch (Throwable $e) { } catch (Exception $e) { } - try{ + try { ORM::raw_execute("SET GLOBAL FOREIGN_KEY_CHECKS=1;"); } catch (Throwable $e) { } catch (Exception $e) { @@ -770,6 +770,40 @@ switch ($action) { r2(U . 'settings/language', 's', Lang::T('Translation saved Successfully')); break; + case 'maintenance': + if (!in_array($admin['user_type'], ['SuperAdmin', 'Admin'])) { + _alert(Lang::T('You do not have permission to access this page'), 'danger', "dashboard"); + exit; + } + if (_post('save') == 'save') { + $status = isset($_POST['maintenance_mode']) ? 1 : 0; // Checkbox returns 1 if checked, otherwise 0 + $date = isset($_POST['maintenance_date']) ? $_POST['maintenance_date'] : null; + + $settings = [ + 'maintenance_mode' => $status, + 'maintenance_date' => $date + ]; + + foreach ($settings as $key => $value) { + $d = ORM::for_table('tbl_appconfig')->where('setting', $key)->find_one(); + if ($d) { + $d->value = $value; + $d->save(); + } else { + $d = ORM::for_table('tbl_appconfig')->create(); + $d->setting = $key; + $d->value = $value; + $d->save(); + } + } + + r2(U . "settings/maintenance", 's', Lang::T('Settings Saved Successfully')); + } + $ui->assign('_c', $config); + $ui->assign('_title', Lang::T('Maintenance Mode Settings')); + $ui->display('maintenance-mode.tpl'); + break; + default: $ui->display('a404.tpl'); } diff --git a/ui/ui/maintenance-mode.tpl b/ui/ui/maintenance-mode.tpl new file mode 100644 index 00000000..860bd5ec --- /dev/null +++ b/ui/ui/maintenance-mode.tpl @@ -0,0 +1,96 @@ +{include file="sections/header.tpl"} + + + +
+
+
+
+
{Lang::T('Maintenance Mode')}
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+ +{include file="sections/footer.tpl"} \ No newline at end of file diff --git a/ui/ui/maintenance.tpl b/ui/ui/maintenance.tpl new file mode 100644 index 00000000..6095f52b --- /dev/null +++ b/ui/ui/maintenance.tpl @@ -0,0 +1,212 @@ + + + + + Site is down for maintenance + + + + + + + + + + +
+
+
+
+
+
+
+

{Lang::T('Site is temporarily unavailable.')}

+

{Lang::T('Scheduled maintenance is currently in progress. Please check back soon.')}

+

{Lang::T('We apologize for any inconvenience.')}
— {Lang::T('The ')} {$companyName} {Lang::T(' + Team.')}

+
+ {if $date}
+

+

+

+

+
+ {/if} +
+
+ {if $date} + + {/if} + + + \ No newline at end of file diff --git a/ui/ui/sections/header.tpl b/ui/ui/sections/header.tpl index 2e8d0219..12ee84fa 100644 --- a/ui/ui/sections/header.tpl +++ b/ui/ui/sections/header.tpl @@ -88,7 +88,7 @@ } {if isset($xheader)} - {$xheader} + {$xheader} {/if} @@ -158,71 +158,71 @@ {$_MENU_AFTER_DASHBOARD} {if !in_array($_admin['user_type'],['Report'])} -
  • - - {Lang::T('Customer')} - - - - - -
  • - {$_MENU_AFTER_CUSTOMERS} -
  • - - {Lang::T('Services')} - - - - - -
  • +
  • + + {Lang::T('Customer')} + + + + + +
  • + {$_MENU_AFTER_CUSTOMERS} +
  • + + {Lang::T('Services')} + + + + + +
  • {/if} {$_MENU_AFTER_SERVICES} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])} -
  • - - {Lang::T('Internet Plan')} - - - - - -
  • +
  • + + {Lang::T('Internet Plan')} + + + + + +
  • {/if} {$_MENU_AFTER_PLANS}
  • @@ -260,64 +260,64 @@
  • {$_MENU_AFTER_MESSAGE} {if in_array($_admin['user_type'],['SuperAdmin','Admin'])} -
  • - - {Lang::T('Network')} - - - - - -
  • - {$_MENU_AFTER_NETWORKS} - {if $_c['radius_enable']} -
  • - - {Lang::T('Radius')} - - - - - +
  • + + {Lang::T('Network')} + + + + + +
  • + {$_MENU_AFTER_NETWORKS} + {if $_c['radius_enable']} +
  • + + {Lang::T('Radius')} + + + + + +
  • + {/if} + {$_MENU_AFTER_RADIUS} +
  • + + {Lang::T("Static Pages")} + + + + + +
  • {/if} {$_MENU_AFTER_PAGES}