Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/indolok.id/application/core/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends MX_Controller { protected $data = array(); protected $data_header = array(); protected $data_footer = array(); protected $theme_no; function __construct() { parent::__construct(); } protected function common_functions() { //check if website is active $this->db->select('website_active, website_ip')->from('configuration')->where('id_configuration', 1); $website_status = $this->db->get()->row(); if($website_status->website_active == 'no') { //WEBSITE IS NOT ACTIVE (MAINTENANCE MODE) //get current IP $current_ip = $this->input->ip_address(); //localhost ip is ::1 //check for allowed IP $allowed_ips = explode(',', $website_status->website_ip); if (in_array($current_ip, $allowed_ips) == 0) { redirect(base_url('maintenance')); } else { $this->website_active(); } } else { $this->website_active(); } } private function website_active() { $this->load->helper('form'); $this->load->helper('menu'); $this->load->helper('cart'); $this->load->library('cart'); $this->load->model('product_m'); //WEBSITE DETAILS $this->db->select('logo, website_name, facebook, twitter, instagram, youtube, google_analytic_id, tawkto_id, primary_color_theme, website_icon, from_email, phone')->from('configuration')->where('id_configuration', 1); $website_infos = $this->db->get()->row(); $this->data_header['logo'] = $website_infos->logo; $this->data_header['website_name'] = $website_infos->website_name; $this->data_header['google_analytic_id'] = $website_infos->google_analytic_id; $this->data_header['tawkto_id'] = $website_infos->tawkto_id; $this->data_header['email'] = $website_infos->from_email; $this->data_header['phone'] = $website_infos->phone; $this->data['facebook'] = $website_infos->facebook; $this->data['twitter'] = $website_infos->twitter; $this->data['instagram'] = $website_infos->instagram; $this->data['youtube'] = $website_infos->youtube; $this->data_header['primary_colortheme'] = $website_infos->primary_color_theme; $this->data_header['website_icon'] = $website_infos->website_icon; //MAIN MENUS if($this->session->userdata('site_lang') == 'english') { $this->db->select('id_menus, menu_en as menu, menu_link')->from('menus')->where('status', 1)->where('parent_id', NULL)->order_by('priority', 'ASC'); } else { $this->db->select('id_menus, menu, menu_link')->from('menus')->where('status', 1)->where('parent_id', NULL)->order_by('priority', 'ASC'); } $this->data_header['main_menus'] = $this->db->get()->result(); //FOOTERS if($this->session->userdata('site_lang') == 'english') { $this->db->select('title_en as title, description_en as description')->from('home_footer')->where('status', '1')->order_by('priority', 'ASC'); } else { $this->db->select('title, description')->from('home_footer')->where('status', '1')->order_by('priority', 'ASC'); } $this->data_footer['footers'] = $this->db->get()->result(); //FLASH SALE (MODULE) echo Modules::run('flashsale/initialize'); //THEME NUMBER INITIALIZE $this->theme_no = '2'; $this->data_header['theme'] = $this->theme_no; $this->data_footer['theme'] = $this->theme_no; } } class Public_controller extends MY_Controller { function __construct() { parent::__construct(); $this->common_functions(); } } class Customer_controller extends MY_Controller { function __construct() { parent::__construct(); $this->common_functions(); //special case to check if request is coming from shipping page.. if($this->uri->segment(1) == 'shipping') { $this->session->set_userdata('from_shipping_page', 'yes'); } elseif($this->uri->segment(1) == 'login') { /*--do nothing--*/ } elseif($this->uri->segment(1) == 'register') { /*--do nothing--*/ } else { $this->session->unset_userdata('from_shipping_page'); } //clear customer session if customer is guest and want to access login/register page.. if($this->uri->segment(1) == 'login' || $this->uri->segment(1) == 'register') { if(isset($this->session->userdata('customer')['customer_type'])) { if($this->session->userdata('customer')['customer_type'] == 'guest') { $this->session->unset_userdata('customer'); } } } //clear customer session if customer is guest and want to access login/register page.. if($this->uri->segment(1) == 'account' && $this->uri->segment(2) == 'profile') { if(isset($this->session->userdata('customer')['customer_type'])) { if($this->session->userdata('customer')['customer_type'] == 'guest') { $this->session->unset_userdata('customer'); } } } //special case to check if request is coming from register/guest_checkout if($this->uri->segment(2) == 'guest_checkout') { $customer_data = array( 'customer_name' => 'Guest', 'customer_email' => '', 'customer_id' => NULL, 'customer_loggedin' => TRUE, 'customer_type' => 'guest' ); $this->session->set_userdata(array('customer' => $customer_data)); } $this->load->model('customer_m'); //logged in check, if loggedin is false, then kickout //exclude some pages from the check $exception_uris = array( 'register', 'register/b2b', 'register/submit_sms_code', 'register/new_registration', 'register/new_registration_b2b', 'register/logout', 'register/guest_checkout', 'login', 'login/b2b', 'login/login_password', 'login/login_sms', 'login/lost_password', 'login/set_new_password', 'login/facebook_login', 'login/google_login', 'register/register_landing' ); if(in_array(uri_string(), $exception_uris) == FALSE) { if($this->customer_m->loggedin() == FALSE) { redirect('login'); } } } } class Admin_controller extends MY_Controller { function __construct() { parent::__construct(); $this->load->helper('cms_helper'); $this->load->model('user_m'); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled $this->load->helper('form'); //logged in check, if loggedin is false, then kickout //first exclude login and logout page from the check $exception_uris = array( 'admin/user/login', 'admin/user/logout' ); if(in_array(uri_string(), $exception_uris) == FALSE) { if($this->user_m->loggedin() == FALSE) { redirect('admin/user/login'); } } //user role checking $this->data['role'] = $this->session->userdata('admin')['role']; switch ($this->data['role']) { case 'requester po': $this->data['allowed_module'] = ['pembelian_request']; break; case 'purchasing': $this->data['allowed_module'] = ['pembelian_pemesanan', 'pembelian_request']; break; case 'finance': $this->data['allowed_module'] = ['pembelian_faktur']; break; case 'director': $this->data['allowed_module'] = ['pembelian_approval']; break; case 'marketing': $this->data['allowed_module'] = ['blog']; break; case 'admin': $this->data['allowed_module'] = ['flashsale', 'promo_banners', 'home_footer', 'blog', 'toc', 'point_rewards', 'vouchers', 'companies', 'customers', 'pages', 'home_slideshow', 'menus', 'warehouses', 'marketplace', 'brands', 'categories', 'products', 'pembelian_request', 'pembelian_pemesanan', 'pembelian_faktur', 'pembelian_approval', 'pembelian_penerimaan', 'orders', 'penawaran']; break; case 'super admin': $this->data['allowed_module'] = ['flashsale', 'promo_banners', 'home_footer', 'blog', 'toc', 'point_rewards', 'vouchers', 'companies', 'customers', 'pages', 'home_slideshow', 'menus', 'warehouses', 'marketplace', 'brands', 'categories', 'products', 'pembelian_request', 'pembelian_pemesanan', 'pembelian_faktur', 'pembelian_approval', 'pembelian_penerimaan', 'orders', 'penawaran']; break; } //get Website Name $this->db->select('website_name')->from('configuration')->where('id_configuration', 1); $this->data_header['website_name'] = $this->db->get()->row()->website_name; $this->data_header['meta_title'] = 'Administration Page'; } }