From db9726774cc07ea3332d50627649168b602ffb8a Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sun, 25 Feb 2024 14:14:18 +0100 Subject: [PATCH] added a maintenance mode --- .gitignore | 1 + application/controllers/User.php | 9 +++++++-- application/models/User_model.php | 10 +++++++++- application/views/interface_assets/header.php | 8 +++++++- application/views/user/login.php | 5 +++++ index.php | 14 ++++++++++---- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 89839572a..27c58390c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ sync.sh *.p12 *.swp .debug +.maintenance .htaccess diff --git a/application/controllers/User.php b/application/controllers/User.php index 5d5442bac..5908a5a1a 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -707,8 +707,13 @@ class User extends CI_Controller { $this->input->set_cookie($cookie); redirect('dashboard'); } else { - $this->session->set_flashdata('error', 'Incorrect username or password!'); - redirect('user/login'); + if(ENVIRONMENT == 'maintenance') { + $this->session->set_flashdata('notice', 'Sorry. This instance is currently in maintenance mode. If this message appears unexpectedly or keeps showing up, please contact an administrator. Only administrators are currently allowed to log in.'); + redirect('user/login'); + } else { + $this->session->set_flashdata('error', 'Incorrect username or password!'); + redirect('user/login'); + } } } } diff --git a/application/models/User_model.php b/application/models/User_model.php index c9116b5d0..ce1524e45 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -417,7 +417,15 @@ class User_Model extends CI_Model { if($u->num_rows() != 0) { if($this->_auth($password, $u->row()->user_password)) { - return 1; + if (ENVIRONMENT != "maintenance") { + return 1; + } else { + if($u->row()->user_type != 99){ + return 0; + } else { + return 1; + } + } } } return 0; diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 497c4fd8c..1eb5e9d38 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -69,7 +69,13 @@