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/rabbithabit.com/public_html/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['configs'] = $website_infos; $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_type, img_name, menu_en as menu, menu_link_en as menu_link')->from('menus')->where('status', 1)->where('parent_id', NULL)->order_by('priority', 'ASC'); } else { $this->db->select('id_menus,menu_type, img_name, 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'); $this->theme_no = '3'; if($this->theme_no == '3'){ $p_color = "#2B286E"; $p_rgbcolor= "rgb(43, 40, 110)"; $this->session->set_userdata('p_color', $p_color); $this->session->set_userdata('p_rgbcolor', $p_rgbcolor); $this->session->set_userdata('footers', $this->data_footer['footers']); } //$this->theme_no = '1'; $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']); if (is_array($email_data['email']) && count($email_data['email'])>1) { $this->email->to(implode(', ', $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(); //special case to check if request is coming from shipping guest page.. if($this->uri->segment(1) == 'shipping') { $this->session->set_userdata('from_shipping_page', 'yes'); } $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(); $this->data_header['bg_section_color'] = 'background:#FFFAFA;'; } protected function calculate_total_shipping_fee($shipping_id_subdistrict,$using_ajax = false) { //calculate initial total shipping fee //if 2 product has the same shipping method, then use 1 shipping fee only.. $shipping_fee_array = array(); foreach ($this->session->userdata('shipping_cart') as $item) { $shipping_fee_array[$item['chosen_shipping_id']][$item['warehouse_id']][] = $item; } // echo "<pre>"; // var_dump($shipping_fee_array); exit(); $final_total_shipping_fee = 0; //harga akhir $shipping_session = null; $shipping_session_index = 0; foreach ($shipping_fee_array as $warehouse_sid) { $total_fee_shipping = 0; foreach ($warehouse_sid as $item1) { $total_fee_warehouse = 0; $total_weight_wids = 0; $count_wsid = count($item1); for($a = 0; $a < $count_wsid; $a++) { $this->db ->select('weight, length, width, height') ->from('product_details') ->where('product_id', $item1[$a]['product_id']) ->where('id', $item1[$a]['id']); $product_dimension = $this->db->get()->row(); $product_weight = $product_dimension->weight; //gram $product_length = $product_dimension->length; //cm $product_width = $product_dimension->width; //cm $product_height = $product_dimension->height; //cm //check if volume is bigger than weight $volume_weight = $product_length * $product_width * $product_height / 6000; //kg if(($volume_weight * 1000) >= $product_weight) { $weight = $volume_weight * 1000; } else { $weight = $product_weight; } $total_weight_gram = ceil($weight * $item1[$a]['qty']); //gram $total_weight_wids = $total_weight_wids + $total_weight_gram; } $shipping_session[$shipping_session_index]['warehouse_id'] = $item1[0]['warehouse_id']; //get shipping method name $shipping_method = $this->db->select('name, shipper, carrier, service_code1, service_code2')->from('shipment_method')->where('id', $item1[0]['chosen_shipping_id'])->get()->row(); $shipping_name = $shipping_method->name; $shipping_carrier = $shipping_method->carrier; $shipping_shipper = $shipping_method->shipper; $service_code1 = $shipping_method->service_code1; $service_code2 = $shipping_method->service_code2; //get warehose sub district id $warehouse_subdistrict_id = $this->db->select('id_subdistrict')->from('warehouse')->where('id', $item1[0]['warehouse_id'])->get()->row()->id_subdistrict; $rajaongkir_cost = get_rajaongkir_ongkos($warehouse_subdistrict_id, $shipping_id_subdistrict, $total_weight_wids, $shipping_carrier); //check if weight is zero. If zero, then rajaongkir cannot proceed.. if($total_weight_wids > 0) { //check which key has carrier name if($service_code2 != NULL) { if(count($rajaongkir_cost['rajaongkir']['results'][0]['costs']) != 0) { foreach($rajaongkir_cost['rajaongkir']['results'][0]['costs'] as $key => $result) { if($result['service'] == $service_code1 || $result['service'] == $service_code2) { $total_shipping_fee = $result['cost'][0]['value']; break; } else { $total_shipping_fee = 0; //service is not available } } } else { // echo $item1[0]['chosen_shipping_id']; exit(); $total_shipping_fee = 0; //service is not available } } else { if(count($rajaongkir_cost['rajaongkir']['results'][0]['costs']) != 0) { foreach($rajaongkir_cost['rajaongkir']['results'][0]['costs'] as $key => $result) { if($result['service'] == $service_code1) { $total_shipping_fee = $result['cost'][0]['value']; break; } else { $total_shipping_fee = 0; //service is not available } } } else { $total_shipping_fee = 0; //service is not available } } } else { //total weight gram is zero $total_shipping_fee = 0; //service is not available } //total fee dari banyak produk dalam 1 warehouse dan 1 shipping fee $total_fee_warehouse = $total_fee_warehouse + $total_shipping_fee; //total fee dari banyak warehouse dalam 1 shipping fee $total_fee_shipping = $total_fee_shipping + $total_fee_warehouse; $shipping_session[$shipping_session_index]['shipping_fee'] = $total_fee_warehouse; if($item1[0]['chosen_shipping_id'] == 5){ $is_indent = "yes"; } else{ $is_indent = "no"; } $shipping_session[$shipping_session_index]['is_indent'] = $is_indent; $shipping_session_index++; } if($using_ajax == false){ $final_total_shipping_fee = $final_total_shipping_fee + $total_fee_shipping; }else{ if($item1[0]['chosen_shipping_id'] != 5){ // $total_fee_shipping2 += $total_fee_shipping; $final_total_shipping_fee += $total_fee_shipping; } } if ($item1[0]['chosen_shipping_id'] == 2) { $this->db->select('shopdelivery_fee')->from('configuration')->where('id_configuration', 1); $shopdelivery_fee = $this->db->get()->row()->shopdelivery_fee; $final_total_shipping_fee = $shopdelivery_fee; } // $final_total_shipping_fee = $final_total_shipping_fee + $total_fee_shipping; // echo $final_total_shipping_fee." ID: ".$item1[0]['chosen_shipping_id']."<br>"; //penjumlahan ke harga akhir // $total_fee_shipping2 += $total_fee_shipping; } // echo $total_fee_shipping2; // $final_total_shipping_fee = $total_fee_shipping2; // exit(); $get_grand_total = 0; foreach ($this->session->userdata('shipping_cart') as $item){ $get_grand_total += $item['subtotal']; } $q_config_cond = $this->db->select('type_cond_prov_free_shipping, cond_more_prov_free_shipping, cond_less_prov_free_shipping')->from('configuration')->where('id_configuration',1)->get()->row(); if($this->session->userdata('customer') && $this->session->userdata('customer')['customer_type'] == 'regular') { //check if there is regional free shipping, if 0, then final_total_shipping_fee is 0 $free_shipping_price = $this->db->select('free_shipping_type_subsidi')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type_subsidi; $free_shipping_type = $this->db->select('free_shipping_type')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type; if($free_shipping_type == 'region') { $selected_region_province = $this->db->select('province_id')->from('free_shipping_region')->where('configuration_id',1)->get()->result(); //get destination province_id $shipping_id_district = $this->db->select('indonesia_id_district')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', $shipping_id_subdistrict)->get()->row()->indonesia_id_district; $shipping_id_province = $this->db->select('indonesia_id_province')->from('indonesia_districts')->where('rajaongkir_id_district', $shipping_id_district)->get()->row()->indonesia_id_province; $act_cond_free_shipping = false; switch ($q_config_cond->type_cond_prov_free_shipping) { case 'more_than': if ($get_grand_total >= $q_config_cond->cond_more_prov_free_shipping) { $act_cond_free_shipping = true; } break; case 'less_than': if ($get_grand_total <= $q_config_cond->cond_less_prov_free_shipping) { $act_cond_free_shipping = true; } break; default: $act_cond_free_shipping = true; break; } if ($act_cond_free_shipping == true) { foreach ($selected_region_province as $region_province) { if($region_province->province_id == $shipping_id_province) { if($free_shipping_price == 0){ $final_total_shipping_fee = 0; break; } } } } } } $free_shipping_type = $this->db->select('free_shipping_type')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type; if($free_shipping_type == 'region') { $shipping_id_district = $this->db->select('indonesia_id_district')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', $shipping_id_subdistrict)->get()->row()->indonesia_id_district; $shipping_id_province = $this->db->select('indonesia_id_province')->from('indonesia_districts')->where('rajaongkir_id_district', $shipping_id_district)->get()->row()->indonesia_id_province; $selected_region_province = $this->db->select('province_id')->from('free_shipping_region')->where('configuration_id',1)->get()->result(); $act_cond_free_shipping = false; foreach ($selected_region_province as $region_province) { if($region_province->province_id == $shipping_id_province) { $act_cond_free_shipping = true; break; } } if ($act_cond_free_shipping == true) { switch ($q_config_cond->type_cond_prov_free_shipping) { case 'more_than': if ($get_grand_total >= $q_config_cond->cond_more_prov_free_shipping) { $shipping_session = 0; $final_total_shipping_fee = 0; } break; case 'less_than': if ($get_grand_total <= $q_config_cond->cond_less_prov_free_shipping) { $shipping_session = 0; $final_total_shipping_fee = 0; } break; default: // if no break; } } } // echo "<pre>"; // // var_dump($this->session->userdata('shipping_cart')); // echo $final_total_shipping_fee; // exit(); $this->session->set_userdata('shipping_session', $shipping_session); $this->session->set_userdata('total_shipping_fee', $final_total_shipping_fee); return $final_total_shipping_fee; } protected function calculate_free_shipping_fee($province_id, $final_total_shipping_fee) { $get_grand_total = 0; foreach ($this->session->userdata('shipping_cart') as $item){ $get_grand_total += $item['subtotal']; } $q_config_cond = $this->db->select('type_cond_prov_free_shipping, cond_more_prov_free_shipping, cond_less_prov_free_shipping')->from('configuration')->where('id_configuration',1)->get()->row(); if($this->session->userdata('customer') && $this->session->userdata('customer')['customer_type'] == 'regular') { /*new get free fee shipping*/ $this->load->helper('shipping'); $free_shipping_fee = 0; $free_shipping_price = $this->db->select('free_shipping_type_subsidi')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type_subsidi; $free_shipping_type = $this->db->select('free_shipping_type')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type; if($free_shipping_type == 'region') { $selected_region_province = $this->db->select('province_id')->from('free_shipping_region')->where('configuration_id',1)->get()->result(); $act_cond_free_shipping = false; switch ($q_config_cond->type_cond_prov_free_shipping) { case 'more_than': if ($get_grand_total >= $q_config_cond->cond_more_prov_free_shipping) { $act_cond_free_shipping = true; } break; case 'less_than': if ($get_grand_total <= $q_config_cond->cond_less_prov_free_shipping) { $act_cond_free_shipping = true; } break; default: $act_cond_free_shipping = true; break; } if ($act_cond_free_shipping == true) { foreach ($selected_region_province as $region_province) { if($region_province->province_id == $province_id) { if($free_shipping_price == 0){ $free_shipping_fee = $final_total_shipping_fee; } else{ $free_shipping_fee = $free_shipping_price; } break; } } } } elseif($free_shipping_type == 'global') { $min_transaction = $this->db->select('min_transaction')->from('free_shipping_global')->where('configuration_id',1)->get()->row()->min_transaction; if($total_item_amount >= $min_transaction){ if($free_shipping_price == 0){ $free_shipping_fee = $final_total_shipping_fee; } else{ $free_shipping_fee = $free_shipping_price; } } else{ $free_shipping_fee = 0; } } } $free_shipping_type = $this->db->select('free_shipping_type')->from('configuration')->where('id_configuration',1)->get()->row()->free_shipping_type; if($free_shipping_type == 'region') { $selected_region_province = $this->db->select('province_id')->from('free_shipping_region')->where('configuration_id',1)->get()->result(); $act_cond_free_shipping = false; foreach ($selected_region_province as $region_province) { if($region_province->province_id == $province_id) { $act_cond_free_shipping = true; break; } } if ($act_cond_free_shipping == true) { switch ($q_config_cond->type_cond_prov_free_shipping) { case 'more_than': if ($get_grand_total >= $q_config_cond->cond_more_prov_free_shipping) { $free_shipping_fee = 0; } break; case 'less_than': if ($get_grand_total <= $q_config_cond->cond_less_prov_free_shipping) { $free_shipping_fee = 0; } break; default: // if no break; } } } // echo "<pre>"; // // var_dump($this->session->userdata('shipping_cart')); // echo $free_shipping_fee; // exit(); $this->session->set_userdata('free_shipping', $free_shipping_fee); return $free_shipping_fee; } } 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(); $this->data_header['bg_section_color'] = 'background:#FFFAFA;'; //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 = 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/submit_sms_code', 'register/new_registration', 'register/logout', 'register/guest_checkout', 'login', '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', 'payment/post_payment', 'payment/process_payment', 'payment/bank_transfer_processing', 'forgot_password', 'forgot_password/lost_password', ); 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'); } } //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(); //check for allowed modules.. $allowed_modules = $this->db->select('role_item_name')->from('role_item')->where('role_id', $this->session->userdata('admin')['role_id'])->get()->result(); $this->data['admin_allowed_modules'] = array(); foreach ($allowed_modules as $index => $module) { $this->data['admin_allowed_modules'][] = $module->role_item_name; } $this->data_header['admin_allowed_modules'] = $this->data['admin_allowed_modules']; } }