diff --git a/application/controllers/contest.php b/application/controllers/contest.php index 8c3539f4..d9ca6eb7 100644 --- a/application/controllers/contest.php +++ b/application/controllers/contest.php @@ -6,6 +6,16 @@ class Contest extends CI_Controller { // Displays available contests public function index() { + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } + // Load database items $this->load->model('contests'); $data['contests'] = $this->contests->list_contests(); @@ -20,6 +30,15 @@ class Contest extends CI_Controller { Displays contest logging view based on the ID provided, allowing users to log in contest mode giving them serial numbers and scoring information. */ public function view($id) { + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } // Load database information $this->load->model('contests'); diff --git a/application/controllers/dashboard.php b/application/controllers/dashboard.php index 8c2fc6dc..c30e1ec5 100644 --- a/application/controllers/dashboard.php +++ b/application/controllers/dashboard.php @@ -14,6 +14,15 @@ class Dashboard extends CI_Controller { // Database connections $this->load->model('logbook_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } // Store info $data['todays_qsos'] = $this->logbook_model->todays_qsos(); @@ -39,6 +48,7 @@ class Dashboard extends CI_Controller { function todays_map() { $this->load->model('logbook_model'); + // TODO: Auth $qsos = $this->logbook_model->get_todays_qsos(''); @@ -138,4 +148,4 @@ function qra2latlong($strQRA) $arLatLong = array($nLat,$nLong); return($arLatLong); -} \ No newline at end of file +} diff --git a/application/controllers/search.php b/application/controllers/search.php index b3d57be4..ba895c01 100644 --- a/application/controllers/search.php +++ b/application/controllers/search.php @@ -4,8 +4,18 @@ class Search extends CI_Controller { public function index() { + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } + $this->load->view('layout/header'); $this->load->view('search/main'); $this->load->view('layout/footer'); } -} \ No newline at end of file +} diff --git a/application/controllers/statistics.php b/application/controllers/statistics.php index 1d955ca5..4ff46496 100644 --- a/application/controllers/statistics.php +++ b/application/controllers/statistics.php @@ -5,7 +5,16 @@ class Statistics extends CI_Controller { public function index() { - + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied

Click here to log in as another user', 403); + } else { + redirect('user/login'); + } + } + // Database connections $this->load->model('logbook_model'); @@ -32,4 +41,4 @@ class Statistics extends CI_Controller { $this->load->view('statistics/index', $data); $this->load->view('layout/footer'); } -} \ No newline at end of file +} diff --git a/application/models/user_model.php b/application/models/user_model.php index 6f088935..bb55f170 100644 --- a/application/models/user_model.php +++ b/application/models/user_model.php @@ -202,6 +202,8 @@ class User_Model extends CI_Model { $user_hash = $this->session->userdata('user_hash'); if($this->_auth($user_id."-".$user_type, $user_hash)) { + // Freshen the session + $this->update_session($user_id); return 1; } else { $this->clear_session(); @@ -229,7 +231,13 @@ class User_Model extends CI_Model { // Checks a user's level of access against the given $level function authorize($level) { $u = $this->get_by_id($this->session->userdata('user_id')); - if(($this->validate_session()) && ($u->row()->user_type >= $level) || $this->config->item('use_auth') == FALSE) { + $l = $this->config->item('auth_mode'); + // Check to see if the minimum level of access is higher than + // the user's own level. If it is, use that. + if($this->config->item('auth_mode') > $level) { + $level = $this->config->item('auth_mode'); + } + if(($this->validate_session()) && ($u->row()->user_type >= $level) || $this->config->item('use_auth') == FALSE || $level == 0) { return 1; } else { return 0; diff --git a/application/views/layout/header.php b/application/views/layout/header.php index 9a8bbb39..304cd1dd 100644 --- a/application/views/layout/header.php +++ b/application/views/layout/header.php @@ -130,18 +130,21 @@ margin: 10px 0;

\ No newline at end of file +