|
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/serbaantik.com/public_html/application/core/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller
{
protected $data = array();
protected $data_header = array();
protected $data_footer = array();
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
{
//WEBSITE IS ACTIVE
$this->website_active();
}
}
else
{
//WEBSITE IS ACTIVE
$this->website_active();
}
}
private function website_active()
{
$this->load->helper('form');
//GET WEBSITE SETTING
$this->db->select('logo, dna_logo, website_name, facebook, tiktok, instagram, youtube, website_icon, from_email, phone, address, linkedin, tokopedia, dna_logo')->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['phone'] = $website_infos->phone;
$this->data_header['address'] = $website_infos->address;
$this->data_footer['email'] = $website_infos->from_email;
$this->data_footer['facebook'] = $website_infos->facebook;
$this->data_footer['tiktok'] = $website_infos->tiktok;
$this->data_footer['instagram'] = $website_infos->instagram;
$this->data_footer['youtube'] = $website_infos->youtube;
$this->data_header['website_icon'] = $website_infos->website_icon;
$this->data_footer['linkedin'] = $website_infos->linkedin;
$this->data_footer['tokopedia'] = $website_infos->tokopedia;
$this->data_footer['dna_logo'] = $website_infos->dna_logo;
//main navigation
if($this->session->userdata('site_lang') == 'english')
{
$this->db->select('id_menus, menu_en as menu, alias_en as alias, menu_type')->from('menus')->where('status', 1)->where('parent_id', NULL)->order_by('priority', 'ASC');
}
else
{
$this->db->select('id_menus, menu, alias, menu_type')->from('menus')->where('status', 1)->where('parent_id', null)->order_by('priority', 'ASC');
}
$this->data_header['top_menus'] = $this->db->get()->result_array();
//LOAD TOP MENU HELPER
$this->load->helper('menu');
}
}
class Public_controller extends MY_Controller
{
function __construct()
{
parent::__construct();
$this->common_functions();
$this->load->library('cart');
}
}
class Admin_controller extends MY_Controller
{
protected $allowed_sections = array();
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>');
$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');
}
}
//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';
//get user allowed sections
$allowed_sections = $this->db->select('section')->from('admin_sections_users')->join('admin_sections', 'admin_sections.id = admin_sections_users.admin_section_id')->where('user_id', (int) $this->session->userdata('admin')['id'])->get()->result_array();
foreach($allowed_sections as $section)
{
array_push($this->allowed_sections, $section['section']);
}
}
}