|
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/laciasmara.com/public_html/shop/application/core/ |
Upload File : |
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class MY_Controller extends MX_Controller
{
protected $data = [];
protected $data_header = [];
protected $data_footer = [];
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');
$this->load->model('Footer_m');
$this->load->model('Top_banner_m');
$this->load->library('CampaignManager');
//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, browser_title, meta_description'
)
->from('configuration')
->where('id_configuration', 1);
$website_infos = $this->db->get()->row();
$this->data_header = [
'website_icon' => $website_infos->website_icon,
'browser_title' => ucwords($website_infos->browser_title),
'meta_description' => '',
'banners' => $this->Top_banner_m->get_active_banners(),
'logo_path' => 'https://storage.googleapis.com/laciasmara-photos/laciaasmara_assets/laciasmara_landing_page/laciasmara_landing_page_logo.webp',
'footer_categories' => $this->Footer_m->get_all_categories(),
'footer_social_media' => $this->Footer_m->get_social_media(),
'footer_payment_methods' => $this->Footer_m->get_payment_methods(),
'footer_asmaradoor' => $this->Footer_m->get_asmaradoor(),
'footer_bottom' => $this->Footer_m->get_footer_bottom(),
'logo' => $website_infos->logo,
'website_name' => $website_infos->website_name,
'google_analytic_id' => $website_infos->google_analytic_id,
'tawkto_id' => $website_infos->tawkto_id,
'email' => $website_infos->from_email,
'phone' => $website_infos->phone,
'primary_colortheme' => $website_infos->primary_color_theme
];
//FLASH SALE (MODULE)
echo Modules::run('flashsale/initialize');
$this->theme_no = '3';
if ($this->theme_no == '3') {
$p_color = "#7a4397";
$p_rgbcolor = "rgb(122, 67, 151, 0.7)";
$this->session->set_userdata('p_color', $p_color);
$this->session->set_userdata('p_rgbcolor', $p_rgbcolor);
}
$this->data_header['theme'] = $this->theme_no;
}
protected function send_email($view_file, $email_data, $e_msg = false)
{
//get website data
$website_data = $this->db
->select(
'logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp'
)
->from('configuration')
->where('id_configuration', 1)
->get()
->row();
$email_data['website_name'] = $website_data->website_name;
$email_data['logo'] = $website_data->logo;
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = $website_data->email_smtp_host;
$config['smtp_port'] = $website_data->email_smtp_port;
$config['smtp_user'] = $website_data->email_smtp;
$config['smtp_pass'] = $website_data->email_smtp_password;
$config['mailtype'] = 'html';
$config['smtp_crypto'] = 'ssl';
$config['charset'] = 'iso-8859-1';
//$config['charset'] = 'UTF-8';
$config['wordwrap'] = true;
$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard
$this->email->set_crlf("\r\n"); //must add this for hotmail
$this->email->initialize($config);
$this->email->from($website_data->from_email, $website_data->website_name);
$this->email->to($email_data['email']);
$this->email->subject($email_data['subject']);
if ($e_msg === false) {
$email = $this->load->view($view_file, $email_data, true);
$this->email->message($email);
} else {
$this->email->message($view_file);
}
$respon_email = $this->email->send();
if (!$respon_email) {
var_dump($this->email->print_debugger());
exit();
}
}
}
class Public_controller extends MY_Controller
{
function __construct()
{
parent::__construct();
$this->common_functions();
$this->load->helper('visits');
if ($this->should_track_visit()) {
track_visit();
}
if ($this->uri->segment(1) == 'shipping') {
$this->session->set_userdata('from_shipping_page', 'yes');
}
}
/**
* Determine apakah request ini harus di-track sebagai visit
* AJAX calls dan internal API calls tidak di-track
*
* @return bool
*/
private function should_track_visit()
{
// List controller/method yang TIDAK di-track
$excluded_paths = [
'cart/get_cart_items',
'cart/update_cart',
'cart/remove_item',
'welcome/track_impression',
'product/get_product_info',
'api/',
'ajax/',
];
// Get current path
$current_path = $this->uri->segment(1) . '/' . $this->uri->segment(2);
// Check if path in excluded list
foreach ($excluded_paths as $excluded) {
if (strpos($current_path, $excluded) === 0) {
return false;
}
}
// Check if AJAX request via HTTP header
if ($this->input->is_ajax_request()) {
return false;
}
// Check if API request based on Accept header
$accept = $this->input->get_request_header('Accept');
if ($accept && strpos($accept, 'application/json') !== false) {
return false;
}
// Check HTTP method - hanya track GET requests
if ($this->input->method() !== 'get') {
return false;
}
return true;
}
}
class Customer_controller extends MY_Controller
{
function __construct()
{
parent::__construct();
$this->common_functions();
$this->data['modules_setting'] = $this->db
->select('*')
->from('modules')
->where('id', 1)
->get()
->row();
$this->data_header['modules_setting'] = $this->db
->select('*')
->from('modules')
->where('id', 1)
->get()
->row();
$this->data_footer['modules_setting'] = $this->db
->select('*')
->from('modules')
->where('id', 1)
->get()
->row();
//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 account/profile 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 = [
'customer_name' => 'Guest',
'customer_email' => '',
'customer_id' => null,
'customer_loggedin' => true,
'customer_type' => 'guest',
];
$this->session->set_userdata(['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 = [
'register',
'register/submit_sms_code',
'register/new_registration',
'register/logout',
'register/create_new',
'register/guest_checkout',
'register/punchline',
'login',
'login/reset_lost_password',
'login/login_password',
'login/login_sms',
'login/lost_password',
'login/set_new_password',
'login/set_new_password_first_migration',
'login/facebook_login',
'login/google_login',
'account/affiliator',
'payment/post_payment',
'payment/process_payment',
'payment/retailer_approval_process',
'payment/bank_transfer_processing',
'forgot_password',
'forgot_password/lost_password',
'preview',
'preview/main',
'preview/register',
'preview/login',
'preview/search',
'login/redirect_google',
];
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->helper('visits');
$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 = ['admin/user/login', 'admin/user/logout', 'admin/auth/login', 'admin/auth/logout', 'admin/auth/login_process'];
if (in_array(uri_string(), $exception_uris) == false) {
if ($this->user_m->loggedin() == false) {
redirect('admin/auth/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 membership type
// $this->db
// ->select('membership_type')
// ->from('configuration')
// ->where('id_configuration', 1);
// $this->data_header['membership_type'] = $this->db->get()->row()->membership_type;
// //get membership type
// $this->db
// ->select('membership_type')
// ->from('configuration')
// ->where('id_configuration', 1);
// $this->data['membership_type'] = $this->db->get()->row()->membership_type;
// //count products
// $this->db->select('*')->from('products');
// $this->data['jml_produk'] = $this->db->get()->num_rows();
// //count users
// $this->db->select('*')->from('users');
// $this->data['jml_user'] = $this->db->get()->num_rows();
// //count users
// $this->db->select('*')->from('warehouse');
// $this->data['jml_gudang'] = $this->db->get()->num_rows();
}
}