From 45657aa0b55e7ec3b28daf9e56d6677a2afadafc Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Wed, 17 Feb 2021 14:11:45 -0500 Subject: [PATCH] fix --- adminwww/application/controllers/Bkoadmin.php | 93 ++----------------- .../application/core/MCORE_Controller.php | 87 +++++++++-------- .../libraries/Admin_Controller.php | 31 +++++-- .../views/template/secure_header.php | 4 +- 4 files changed, 77 insertions(+), 138 deletions(-) diff --git a/adminwww/application/controllers/Bkoadmin.php b/adminwww/application/controllers/Bkoadmin.php index 4a42d10..37a16cf 100644 --- a/adminwww/application/controllers/Bkoadmin.php +++ b/adminwww/application/controllers/Bkoadmin.php @@ -4,100 +4,25 @@ defined('BASEPATH') OR exit('No direct script access allowed'); class Bkoadmin extends Admin_Controller { - public $template = array( - 'table_open' => "", - 'thead_open' => '', - 'thead_close' => '', - 'heading_row_start' => '', - 'heading_row_end' => '', - 'heading_cell_start' => '', - 'tbody_open' => '', - 'tbody_close' => '', - 'row_start' => '', - 'row_end' => '', - 'cell_start' => '', - 'row_alt_start' => '', - 'row_alt_end' => '', - 'cell_alt_start' => '', - 'table_close' => '
', - 'heading_cell_end' => '
', - 'cell_end' => '
', - 'cell_alt_end' => '
', - ); - public function index() { $this->load->helper('url'); $data = array(); - $this->load->library('table'); - $this->table->set_template($this->template); - - $data['recent_members'] = ""; - $mysql = "SELECT id,username,firstname,lastname,added::date,loc,last_login,acc_link FROM members ORDER by id DESC LIMIT 15"; - $query = $this->db->query($mysql); - //$this->table->set_heading( array('data' => 'ID', 'style' => 'width:50px'),'Email', 'Firstname', 'Lastname','Last Login','Location', array('data' => 'ACTION', 'style' => 'width:40px'), array('data' => 'Select', 'style' => 'width:40px')); - $data['recent_members'] = $this->table->generate($query); - - - $mysql="SELECT '' AS View,name,username,email,added,last_login from practice ORDER BY id DESC LIMIT 7"; - $data['recent_practice'] = ""; - $query = $this->db->query($mysql); - //$this->table->set_heading( array('data' => 'ID', 'style' => 'width:50px'),'Email', 'Firstname', 'Lastname','Last Login','Location', array('data' => 'ACTION', 'style' => 'width:40px'), array('data' => 'Select', 'style' => 'width:40px')); - $data['recent_practice'] = $this->table->generate($query); - - $mysql="SELECT '' AS process, - '' AS semail, - status, - practice_name,username,email,added::date from practice_pending ORDER BY id DESC LIMIT 7"; - $data['pending_practice'] = ""; - $query = $this->db->query($mysql); - //$this->table->set_heading( array('data' => 'ID', 'style' => 'width:50px'),'Email', 'Firstname', 'Lastname','Last Login','Location', array('data' => 'ACTION', 'style' => 'width:40px'), array('data' => 'Select', 'style' => 'width:40px')); - $data['pending_practice'] = $this->table->generate($query); - - - $this->renderAdminPage('view_dash', $data); - - } - - - public function pendingpractice(){ - - $data = array(); - $data["page_title"] = "Pending Practice"; - $this->load->library('table'); $this->table->set_template($this->template); - $mysql="SELECT '' AS process, - '' AS semail, - status, - practice_name,username,email,added::date from practice_pending ORDER BY id DESC LIMIT 20"; - $data['pending_practice'] = ""; + + $mysql = "SELECT '' AS View" + . ",username,firstname, lastname,email,status,added FROM bko_users ORDER BY username LIMIT 15"; + + $data['users_list'] = ""; $query = $this->db->query($mysql); - //$this->table->set_heading( array('data' => 'ID', 'style' => 'width:50px'),'Email', 'Firstname', 'Lastname','Last Login','Location', array('data' => 'ACTION', 'style' => 'width:40px'), array('data' => 'Select', 'style' => 'width:40px')); - $data['pending_practice'] = $this->table->generate($query); - $this->renderAdminPage('view_pendingpractice', $data); - } + $this->table->set_heading(array('data' => 'View', 'style' => 'width:50px'), 'Username', 'Firstname', 'Lastname', 'Email', 'Status', 'Added'); + $data['users_list'] = $this->table->generate($query); - public function pendingusers(){ - $data = array(); - $data["page_title"] = "Pending Members"; - $this->load->library('table'); - $this->table->set_template($this->template); - $data['recent_members'] = ""; - $mysql = "SELECT id,username,firstname,lastname,added::date,loc,last_login,acc_link FROM members ORDER by id DESC LIMIT 15"; - $query = $this->db->query($mysql); - //$this->table->set_heading( array('data' => 'ID', 'style' => 'width:50px'),'Email', 'Firstname', 'Lastname','Last Login','Location', array('data' => 'ACTION', 'style' => 'width:40px'), array('data' => 'Select', 'style' => 'width:40px')); - $data['recent_members'] = $this->table->generate($query); - $this->renderAdminPage('view_pendingusers', $data); + $data['page_title'] = "Back Offfice Users"; - } - - - protected function renderAdminPage($page_name, $data) { - $this->load->view('template/secure_header', $data); - $this->load->view('admin/' . $page_name, $data); - $this->load->view('template/secure_footer', $data); + $this->renderBkoadminPage('view_users', $data); } } diff --git a/adminwww/application/core/MCORE_Controller.php b/adminwww/application/core/MCORE_Controller.php index 55cdb72..2ad60cb 100644 --- a/adminwww/application/core/MCORE_Controller.php +++ b/adminwww/application/core/MCORE_Controller.php @@ -64,46 +64,45 @@ class MCORE_Controller extends CI_Controller { /* RET: added=2019-10-01 22:11:40.050111 -- 20:00:59.180 INFO [11950]: RET: backoffice_id=1 -- 20:00:59.180 INFO [11950]: RET: email=ses66181@gmail.com -- 20:00:59.180 INFO [11950]: RET: firstname=Olusesan -- 20:00:59.180 INFO [11950]: RET: id=1 -- 20:00:59.180 INFO [11950]: RET: lastname=Ameye -- 20:00:59.180 INFO [11950]: RET: pass=d0fbea2563b377ea7074bced45c88dcb -- 20:00:59.180 INFO [11950]: RET: result=YES I GET TO BACK END -- 20:00:59.180 INFO [11950]: RET: sessionid=acabab4686eec2d683d9f7595d4880ba -- 20:00:59.180 INFO [11950]: RET: status=1 -- 20:00:59.180 INFO [11950]: RET: stauts=OK -- 20:00:59.180 INFO [11950]: RET: username=oameye - */ - + - 20:00:59.180 INFO [11950]: RET: backoffice_id=1 + - 20:00:59.180 INFO [11950]: RET: email=ses66181@gmail.com + - 20:00:59.180 INFO [11950]: RET: firstname=Olusesan + - 20:00:59.180 INFO [11950]: RET: id=1 + - 20:00:59.180 INFO [11950]: RET: lastname=Ameye + - 20:00:59.180 INFO [11950]: RET: pass=d0fbea2563b377ea7074bced45c88dcb + - 20:00:59.180 INFO [11950]: RET: result=YES I GET TO BACK END + - 20:00:59.180 INFO [11950]: RET: sessionid=acabab4686eec2d683d9f7595d4880ba + - 20:00:59.180 INFO [11950]: RET: status=1 + - 20:00:59.180 INFO [11950]: RET: stauts=OK + - 20:00:59.180 INFO [11950]: RET: username=oameye + */ + protected function loginAdminUser($data, $out) { - - $data['action'] = MERMSEMR_BKO_LOGIN; - // $data['mlog'] = $mlog; - // $data['member_id'] = $_SESSION['member_id']; - $this->load->model('backend_model'); - $out = array(); - $res = $this->backend_model->mermsemr_api($data, $out); + + $data['action'] = MERMSEMR_BKO_LOGIN; + // $data['mlog'] = $mlog; + // $data['member_id'] = $_SESSION['member_id']; + $this->load->model('backend_model'); + $out = array(); + $res = $this->backend_model->mermsemr_api($data, $out); //echo $res." -------------------------------------++"; - $loginReturn = false; + $loginReturn = false; + + if ($res == PHP_API_OK && isset($out["sessionid"]) && $out["backoffice_id"] > 0) { + $_SESSION['session_id'] = $out['sessionid']; // ""; + $_SESSION['username'] = $out['username']; // ""; + $_SESSION['backoffice_id'] = $out['backoffice_id']; + $_SESSION['user_firstname'] = $out['firstname']; + $_SESSION['user_lastname'] = $out['lastname']; + $_SESSION['user_email'] = $out['email']; + $_SESSION['user_id'] = $out['backoffice_id']; + $_SESSION['current_user'] = $out['firstname'] . " " . $out['lastname']; + $loginReturn = true; + } else { + $data['error_message'] = "Invalid Username or Password"; + } - if ( $res==PHP_API_OK && isset($out["sessionid"]) && $out["backoffice_id"] > 0 ){ - $_SESSION['session_id'] =$out['sessionid']; // ""; - $_SESSION['username'] = $out['username']; // ""; - $_SESSION['backoffice_id'] = $out['backoffice_id']; - $_SESSION['user_firstname'] = $out['firstname']; - $_SESSION['user_lastname'] = $out['lastname']; - $_SESSION['user_email'] = $out['email']; - $_SESSION['user_id'] = $out['backoffice_id']; - $_SESSION['current_user'] = $out['firstname']." " . $out['lastname']; - $loginReturn = true; - } - else { - $data['error_message']="Invalid Username or Password"; - } - return $loginReturn; } @@ -164,7 +163,6 @@ class MCORE_Controller extends CI_Controller { return $str; - } protected function sql_escape_func($inp) { @@ -202,8 +200,6 @@ class MCORE_Controller extends CI_Controller { //$this->load->view('users/view_external_footer'); } - - protected function readFixedText($text_key) { $page_key = trim($text_key); @@ -256,19 +252,22 @@ class MCORE_Controller extends CI_Controller { return $query->result(); } - - protected function renderProviderSecurePage($page_name, $data) { - - // you dont have bussines here if you are not in session + + // you dont have bussines here if you are not in session if (!isset($_SESSION['session_id']) or ! isset($_SESSION['username']) or $_SESSION['username'] == '') { redirect(logout); } - + $this->load->view('template/provider_header', $data); $this->load->view('provider/' . $page_name, $data); $this->load->view('template/provider_footer', $data); } + protected function renderBkoadminPage($page_name, $data) { + $this->load->view('template/secure_header', $data); + $this->load->view('bkoadmin/' . $page_name, $data); + $this->load->view('template/secure_footer', $data); + } } diff --git a/adminwww/application/libraries/Admin_Controller.php b/adminwww/application/libraries/Admin_Controller.php index b7a20c2..91b9280 100644 --- a/adminwww/application/libraries/Admin_Controller.php +++ b/adminwww/application/libraries/Admin_Controller.php @@ -2,7 +2,26 @@ class Admin_Controller extends MCORE_Controller { - + public $template = array( + 'table_open' => "", + 'thead_open' => '', + 'thead_close' => '', + 'heading_row_start' => '', + 'heading_row_end' => '', + 'heading_cell_start' => '', + 'tbody_open' => '', + 'tbody_close' => '', + 'row_start' => '', + 'row_end' => '', + 'cell_start' => '', + 'row_alt_start' => '', + 'row_alt_end' => '', + 'cell_alt_start' => '', + 'table_close' => '
', + 'heading_cell_end' => '
', + 'cell_end' => '
', + 'cell_alt_end' => '
', + ); public $data = array(); function __construct() { @@ -12,23 +31,19 @@ class Admin_Controller extends MCORE_Controller { $this->load->helper('url'); // you dont have bussines here if you are not in session - if (!isset($_SESSION['session_id']) or ! isset($_SESSION['backoffice_id']) ) { + if (!isset($_SESSION['session_id']) or ! isset($_SESSION['backoffice_id'])) { redirect('/logout'); } - - } public function getSessionArray() { $data["current_date"] = date('l jS \of F Y h:i:s A'); - + return $data; } private function refreshAccountDetail($member_id) { - + } - - } diff --git a/adminwww/application/views/template/secure_header.php b/adminwww/application/views/template/secure_header.php index 4fc7741..53ec407 100644 --- a/adminwww/application/views/template/secure_header.php +++ b/adminwww/application/views/template/secure_header.php @@ -284,13 +284,13 @@ - +