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/controllers/ |
Upload File : |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Preview extends Customer_Controller { public function __construct() { parent::__construct(); $this->load->model('comment_m'); $this->load->library(['session', 'form_validation']); $this->load->helper('url'); $this->load->model('customer_m'); $this->load->model('Top_banner_m'); $this->load->library('GoogleClient'); $this->load->library('VisitorTracking'); $this->load->helper('cart'); if ($this->session->userdata('site_lang') == 'english') { $this->lang->load('register_login', 'english'); $this->lang->load('homepage', 'english'); } else { $this->lang->load('register_login', 'indonesian'); $this->lang->load('homepage', 'indonesian'); } $this->data['comments'] = $this->comment_m->get_comments(); $loginUrl = $this->googleclient->getLoginUrl(); $this->data_footer['googleUrl'] = $loginUrl; } public function index() { $this->track_visitor(); if ($this->session->userdata('customer')) { $id_customer = (int) $this->session->userdata('customer')['customer_id']; $this->data['customer'] = $this->customer_m->get_customer($id_customer); } $this->data['comments'] = $this->comment_m->get_comments(); $this->data_header = [ 'browser_title' => ucwords($this->data_header['website_name']) . ' - Preview', 'meta_description' => ucwords('Discover a world of passion at Laci Asmara. Premium adult products crafted to elevate intimate moments with fun, safety and privacy as priorities. Exclusive offers available—explore now and feel the difference!'), 'banner_image' => 'https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/152%20(1).webp?authuser=2', 'cta_text' => 'Get A Grip, Glide With Ease!', 'cta_button_text' => 'Fun Begin!', 'cta_button_link' => 'http://localhost/laciasmara/product/tickler-kegel-double-trainer', 'logo_path' => 'https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/LaciAsmara-ID-V-Mono-White%20(1).png?authuser=2', ]; $this->load->view("themes/$this->theme_no/header_new", $this->data_header); $this->load->view('preview', $this->data); $this->load->view("themes/$this->theme_no/footer_new", $this->data_footer); } public function landing() { $this->load->view('landing_page'); } public function main() { $this->load->model('Top_banner_m'); $this->load->model('Carousel_banner_m'); $this->load->model('Review_m'); $this->load->model('Brand_m'); // Get active banners and carousels $carousels = $this->Carousel_banner_m->get_active_carousel(); $banners = $this->Top_banner_m->get_active_banners(); $brands = $this->Brand_m->get_all_brands(); // Get reviews $this->db->select('pr.id, p.title AS product_name, pr.display_name AS customer_name, pr.rating, pr.review AS testimonial_text, c.sex_type') ->from('product_review pr') ->join('products p', 'p.id_products = pr.product_id') ->join('customers c', 'c.id_customers = pr.customer_id'); $reviews = $this->db->get()->result(); $testimonials = []; foreach ($reviews as $review) { switch ($review->sex_type) { case 'male': $image = "https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/Laciasmara_testimonial/male.png?authuser=2"; break; case 'female': $image = "https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/Laciasmara_testimonial/female.png?authuser=2"; break; default: $image = "https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/Laciasmara_testimonial/others.png?authuser=2"; } $testimonials[] = [ 'customer_image' => $image, 'customer_name' => $review->customer_name, 'product_name' => $review->product_name, 'star_rating' => $review->rating, 'testimonial_text' => $review->testimonial_text, ]; } $this->db->select(' p.id_products, p.title, p.brand_id, pd.id AS id_detail, pd.price, pd.discounted_price, COALESCE(GROUP_CONCAT(DISTINCT CONCAT_WS(": ", pa.product_attribute, pad.attribute_detail) SEPARATOR "; "), "No variants available") AS variants, pi.image, s.stock, s.stock_keep, (s.stock - s.stock_keep) AS stock_sell, SUM(od.quantity) AS total_sales, COUNT(pr.id) AS total_reviews ') ->from('products p') ->join('product_details pd', 'p.id_products = pd.product_id', 'left') ->join('product_images pi', 'pd.id = pi.product_details_id', 'left') ->join('stock s', 'pd.id = s.id_product_detail AND s.warehouse_id = 1', 'left') ->join('orders_detail od', 'od.item_id = pd.id AND od.warehouse_id = 1', 'left') ->join('product_combination pc', 'pd.id = pc.product_details_id', 'left') ->join('product_attributes pa', 'pc.attribute_id = pa.id', 'left') ->join('product_attributes_detail pad', 'pc.attribute_detail_id = pad.id', 'left') ->join('product_review pr', 'pr.product_id = p.id_products', 'left') ->where('p.product_status', '1') ->where('s.stock > 1') ->where('(s.stock - s.stock_keep) > 0') ->group_by('pd.id') ->order_by('total_reviews', 'DESC'); $top_seller_products = $this->db->get()->result_array(); // Prepare and format product data $formatted_products = $this->prepare_top_seller_products($top_seller_products); // Get website configuration data $this->db->select('website_icon, browser_title, meta_description') ->from('configuration') ->where('id_configuration', 1); $website_data = $this->db->get()->row(); // Prepare header data $this->data_header = [ 'website_icon' => $website_data->website_icon, 'browser_title' => ucwords($this->data_header['website_name']) . ' - Main Page', 'meta_description' => $website_data->meta_description, 'banners' => $banners, 'carousels' => $carousels, 'top_seller_products' => $formatted_products, 'testimonials' => $testimonials, 'brands' => $brands, 'logo_path' => 'https://storage.cloud.google.com/laciasmara-photos/laciasmara_test/LaciAsmara-ID-V-Mono-White%20(1).png?authuser=2', ]; if ($this->session->userdata('site_lang') == 'english') { $this->lang->load('mainpage', 'english'); } else { $this->lang->load('mainpage', 'indonesian'); } // Load views $this->load->view("themes/$this->theme_no/header_new", $this->data_header); $this->load->view('main_page'); $this->load->view("themes/$this->theme_no/footer_new", $this->data_footer); } private function prepare_top_seller_products($top_seller_products) { $formatted_products = []; $displayed_brands = []; foreach ($top_seller_products as $product) { // Skip if brand already displayed if (in_array($product['brand_id'], $displayed_brands)) { continue; } // Add brand to displayed list $displayed_brands[] = $product['brand_id']; // Determine current and original prices $current_price = $product['discounted_price'] > 0 ? $product['discounted_price'] : $product['price']; $original_price = $product['discounted_price'] > 0 ? $product['price'] : null; // Get review data for product $review_data = $this->Review_m->get_product_reviews($product['id_products']); $average_rating = isset($review_data['average_rating']) ? round($review_data['average_rating'], 1) : 0; $total_reviews = isset($review_data['total_reviews']) ? $review_data['total_reviews'] : 0; // Parse product variants $variants = !empty($product['variants']) ? explode('; ', $product['variants']) : []; // Format product data $formatted_products[] = [ 'id' => $product['id_products'], 'title' => $product['title'], 'id_detail' => $product['id_detail'], 'product_attribute' => $product['product_attribute'], 'attribute_detail' => $product['attribute_detail'], 'current_price' => $current_price, 'original_price' => $original_price, 'image' => $product['image'], 'stock' => $product['stock'], 'stock_sell' => $product['stock_sell'], 'total_sales' => $product['total_sales'], 'average_rating' => $average_rating, 'total_reviews' => $total_reviews, 'variants' => $variants, ]; } return $formatted_products; } public function login() { if ($this->session->userdata('site_lang') == 'english') { $this->lang->load('mainpage', 'english'); } else { $this->lang->load('mainpage', 'indonesian'); } if ($this->customer_m->loggedin() == TRUE) { redirect(base_url()); } $utm_data = $this->input->get('utm_data'); if ($utm_data) { $utm_data = json_decode(base64_decode($utm_data), true); $this->session->set_userdata('utm_data', $utm_data); } $this->visitortracking->trackVisitor(); $activeBanners = $this->Top_banner_m->get_active_banners(); // Fetch website data for header and meta information $websiteData = $this->db->select('website_icon, browser_title, meta_description') ->from('configuration') ->where('id_configuration', 1) ->get() ->row(); // Prepare header data $this->data_header = [ 'website_icon' => $websiteData->website_icon, 'browser_title' => $websiteData->browser_title . ' - Register', 'meta_description' => $websiteData->meta_description, 'banners' => $activeBanners, 'logo_path' => 'https://storage.googleapis.com/laciasmara-photos/laciaasmara_assets/laciasmara_landing_page/laciasmara_landing_page_logo.webp', ]; // $data['form_data'] = $this->session->flashdata('form_data'); // $data['form_errors'] = $this->session->flashdata('form_errors'); $this->load->view("themes/3/header_new", $this->data_header); $this->load->view('login_new'); $this->load->view("themes/3/footer_new", $this->data_footer); } public function register() { $this->visitortracking->trackVisitor(); if ($this->session->userdata('site_lang') == 'english') { $this->lang->load('mainpage', 'english'); } else { $this->lang->load('mainpage', 'indonesian'); } //if customer is loggedin, then direct to welcome page if ($this->customer_m->loggedin() == TRUE) redirect('welcome'); // //get TOC // $data['toc'] = $this->db->select('toc')->from('toc')->where('id_toc', 1)->get()->row()->toc; // //get Privacy // $data['privacy'] = $this->db->select('toc')->from('toc')->where('id_toc', 2)->get()->row()->toc; //get page $activeBanners = $this->Top_banner_m->get_active_banners(); // Fetch website data for header and meta information $websiteData = $this->db->select('website_icon, browser_title, meta_description') ->from('configuration') ->where('id_configuration', 1) ->get() ->row(); // Prepare header data $this->data_header = [ 'website_icon' => $websiteData->website_icon, 'browser_title' => $websiteData->browser_title . ' - Register', 'meta_description' => $websiteData->meta_description, 'banners' => $activeBanners, 'logo_path' => 'https://storage.googleapis.com/laciasmara-photos/laciaasmara_assets/laciasmara_landing_page/laciasmara_landing_page_logo.webp', ]; $data['widget'] = $this->recaptcha->getWidget(); $data['script'] = $this->recaptcha->getScriptTag(); $data['form_data'] = $this->session->flashdata('form_data'); $data['form_errors'] = $this->session->flashdata('form_errors'); $this->load->view("themes/3/header_new", $this->data_header); $this->load->view('register_new', $data); $this->load->view("themes/3/footer_new", $this->data_footer); } public function search() { header('Content-Type: application/json'); $query = $this->input->get('query', TRUE); // Debug query if (!$query) { echo json_encode(['error' => 'No query provided']); return; } $this->load->model('product_m'); // Cek hasil query $results = $this->product_m->search_products($query); if (empty($results)) { echo json_encode(['results' => []]); return; } foreach ($results as &$result) { $result['url'] = base_url('product/' . $result['alias']); $result['image'] = base_url('uploads/product/' . $result['image']); } echo json_encode(['results' => $results]); } public function add_comment() { // Validate and process the comment submission if ($this->session->userdata('customer')) { $id_customer = (int) $this->session->userdata('customer')['customer_id']; $comment_data = [ 'customer_id' => $id_customer, 'content' => $this->input->post('comment', true), 'created_at' => date('Y-m-d H:i:s'), ]; $this->comment_m->add_comment($comment_data); redirect('preview'); } else { redirect('login'); } } public function add_reply_comment() { $comment_id = $this->input->post('comment_id'); if ($this->session->userdata('customer')) { $id_customer = (int) $this->session->userdata('customer')['customer_id']; $comment_data = [ 'customer_id' => $id_customer, 'content' => $this->input->post('reply_comment', true), 'created_at' => date('Y-m-d H:i:s'), 'parent_id' => $comment_id, ]; $this->comment_m->add_comment($comment_data); redirect('preview'); } else { redirect('login'); } } private function track_visitor() { // $session_tracking = $this->session->userdata('visitor_tracking'); $utm_data = $this->session->userdata('utm_data'); $source = $this->determine_traffic_source(); // Generate tracking ID only if there is no existing session data $tracking_id = uniqid('track_'); // Prepare tracking data $tracking_data = array( 'tracking_id' => $tracking_id, 'source' => $utm_data['utm_source'] ?? $source['utm_source'], 'medium' => $utm_data['utm_medium'] ?? $source['utm_medium'], 'campaign' => $utm_data['utm_campaign'] ?? $source['utm_campaign'], 'ip_address' => $this->input->ip_address(), 'full_url' => current_url() ); // Set the tracking data in session $this->session->set_userdata('visitor_tracking', $tracking_data); // Only insert to database if the tracking_id is newly created $track_data = array( 'id' => $tracking_id, 'link_url' => $tracking_data['full_url'], 'source' => $tracking_data['source'], 'ip_address' => $tracking_data['ip_address'], 'user_agent' => $this->input->user_agent(), 'referer' => $this->input->server('HTTP_REFERER'), 'utm_source' => $tracking_data['source'], 'utm_medium' => $tracking_data['medium'], 'utm_campaign' => $tracking_data['campaign'], ); $this->db->insert('link_tracks', $track_data); } private function determine_traffic_source() { // Check UTM Parameters first $utm_source = $this->input->get('utm_source'); $utm_medium = $this->input->get('utm_medium'); $utm_campaign = $this->input->get('utm_campaign'); // Check HTTP Referer if UTM is not present $referer = $this->input->server('HTTP_REFERER'); $parsed_referer = $referer ? parse_url($referer) : null; // Initialize with default values $source = [ 'utm_source' => 'direct', 'utm_medium' => 'organic', 'utm_campaign' => 'organic' ]; // If UTM parameters exist, use them if ($utm_source) { $source['utm_source'] = $utm_source; $source['utm_medium'] = $utm_medium ?: 'unknown'; $source['utm_campaign'] = $utm_campaign ?: 'none'; } // If no UTM but referer exists, try to determine source from referer elseif ($parsed_referer) { $host = strtolower($parsed_referer['host']); // Check for common sources if (strpos($host, 'google') !== false) { $source['utm_source'] = 'google'; $source['utm_medium'] = 'organic'; } elseif (strpos($host, 'facebook.com') !== false) { $source['utm_source'] = 'facebook'; $source['utm_medium'] = 'social'; } elseif (strpos($host, 'instagram.com') !== false) { $source['utm_source'] = 'instagram'; $source['utm_medium'] = 'social'; } elseif (strpos($host, 't.co') !== false || strpos($host, 'twitter.com') !== false) { $source['utm_source'] = 'twitter'; $source['utm_medium'] = 'social'; } elseif (strpos($host, 'linkedin.com') !== false) { $source['utm_source'] = 'linkedin'; $source['utm_medium'] = 'social'; } else { $source['utm_source'] = $host; $source['utm_medium'] = 'organic'; } $source['utm_campaign'] = 'none'; } // If neither UTM nor referer, it's direct traffic else { $source['utm_source'] = 'direct'; $source['utm_medium'] = 'organic'; $source['utm_campaign'] = 'organic'; } // Store raw referer for debugging $source['raw_referer'] = $referer; return $source; } public function product_new($alias = NULL) { $activeBanners = $this->Top_banner_m->get_active_banners(); $websiteData = $this->db->select('website_icon, browser_title, meta_description') ->from('configuration') ->where('id_configuration', 1) ->get() ->row(); $this->data_header = [ 'website_icon' => $websiteData->website_icon, 'browser_title' => $websiteData->browser_title . ' - All Products', 'meta_description' => $websiteData->meta_description, 'banners' => $activeBanners, 'logo_path' => 'https://storage.googleapis.com/laciasmara-photos/laciaasmara_assets/laciasmara_landing_page/laciasmara_landing_page_logo.webp', ]; $this->lang->load('mainpage', $this->session->userdata('site_lang') == 'english' ? 'english' : 'indonesian'); $product = $this->db->select('*') ->from('products') ->where(['alias' => $alias, 'product_status' => 1]) ->get() ->row(); if (!$product) { show_404(); } $product_details = $this->db->select('*') ->from('product_details') ->where('product_id', $product->id_products) ->get() ->result(); foreach ($product_details as &$detail) { $stock = $this->db->select('stock, stock_keep, stock_reject') ->from('stock') ->where('id_product_detail', $detail->id) ->limit(1) ->get() ->row(); if ($stock) { $detail->stock_available = $stock->stock - $stock->stock_keep; } else { $detail->stock_available = 0; } // Get product combinations $detail->variants = $this->db->select('pa.product_attribute, pad.attribute_detail, pad.color_hex, COALESCE(GROUP_CONCAT(DISTINCT CONCAT_WS(": ", pa.product_attribute, pad.attribute_detail) SEPARATOR "; "), "No variants available") AS variants') ->from('product_combination pc') ->join('product_attributes pa', 'pc.attribute_id = pa.id') ->join('product_attributes_detail pad', 'pc.attribute_detail_id = pad.id') ->where('pc.product_details_id', $detail->id) ->get() ->result_array(); } $initial_product_detail = $product_details[0]; $product_images = $this->db->select('*') ->from('product_images') ->where('product_id', $product->id_products) ->where('product_details_id', $initial_product_detail->id) ->order_by('priority', 'ASC') ->get() ->result(); $this->db->select(' p.id_products AS product_id, p.title AS product_name, p.alias AS product_alias, COUNT(pr.id) AS review_count, AVG(pr.rating) AS average_rating') ->from('product_review pr') ->join('products p', 'p.id_products = pr.product_id') ->where('p.product_status', 1) ->where('pr.product_id', $product->id_products) ->group_by('pr.product_id'); $reviews = $this->db->get()->row(); $data['product'] = $product; $data['product_details'] = $product_details; $data['initial_product_detail'] = $initial_product_detail; $data['product_images'] = $product_images; $data['reviews'] = $reviews; $this->session->set_userdata('productpage_to_cart', base_url() . 'product/' . $alias); $this->load->view("themes/3/header_new", $this->data_header); $this->load->view("themes/3/product_new", $data); $this->load->view("themes/3/footer_new", $this->data_footer); } }