public function setPhpCookieData()
 {
     if (!isset($_COOKIE['id_guest'])) {
         if (!isset($this->context->cookie->id_guest)) {
             Guest::setNewGuest($this->context->cookie);
         }
         setcookie('id_guest', $this->context->cookie->id_guest, time() + 86400, "/");
     } else {
         $this->context->cookie->id_guest = $_COOKIE['id_guest'];
         setcookie('id_guest', $this->context->cookie->id_guest, time() + 86400, "/");
     }
     $guest = new Guest($this->context->cookie->id_guest);
     if (!isset($_COOKIE['id_cart']) && !isset($this->context->cart->id)) {
         $cart = new Cart();
         $cart->recyclable = 0;
         $cart->gift = 0;
         $cart->id_shop = (int) $this->context->shop->id;
         $cart->id_lang = ($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
         $cart->id_currency = ($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT');
         $cart->id_address_delivery = 0;
         $cart->id_address_invoice = 0;
         $cart->id_currency = Configuration::get('PS_CURRENCY_DEFAULT');
         $cart->id_guest = (int) $this->context->cookie->id_guest;
         $cart->setNoMultishipping();
         $cart->save();
         $this->context->cart = $cart;
         $this->context->cookie->id_cart = $cart->id;
         setcookie('id_cart', $cart->id, time() + 86400, "/");
     } else {
         $cart = new Cart((int) $_COOKIE['id_cart']);
         $this->context->cart = $cart;
         $this->context->cookie->id_cart = $cart->id;
         setcookie('id_cart', $cart->id, time() + 86400, "/");
     }
     $customer = new Customer();
     $customer->id_gender = 0;
     $customer->id_default_group = 1;
     $customer->outstanding_allow_amount = 0;
     $customer->show_public_prices = 0;
     $customer->max_payment_days = 0;
     $customer->active = 1;
     $customer->is_guest = 0;
     $customer->deleted = 0;
     $customer->logged = 0;
     $customer->id_guest = $this->context->cookie->id_guest;
     $this->context->customer = $customer;
 }
Esempio n. 2
0
    public function hookFooter($params)
    {
        $html = '';
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);
            if (Configuration::get('PS_STATSDATA_PLUGINS')) {
                $this->context->controller->addJS($this->_path . 'js/plugindetect.js');
                $token = sha1($params['cookie']->id_guest . _COOKIE_KEY_);
                $html .= '
				<script type="text/javascript">
					$(document).ready(function() {
						plugins = new Object;
						plugins.adobe_director = (PluginDetect.getVersion("Shockwave") != null) ? 1 : 0;
						plugins.adobe_flash = (PluginDetect.getVersion("Flash") != null) ? 1 : 0;
						plugins.apple_quicktime = (PluginDetect.getVersion("QuickTime") != null) ? 1 : 0;
						plugins.windows_media = (PluginDetect.getVersion("WindowsMediaPlayer") != null) ? 1 : 0;
						plugins.sun_java = (PluginDetect.getVersion("java") != null) ? 1 : 0;
						plugins.real_player = (PluginDetect.getVersion("RealPlayer") != null) ? 1 : 0;

						navinfo = { screen_resolution_x: screen.width, screen_resolution_y: screen.height, screen_color:screen.colorDepth};
						for (var i in plugins)
							navinfo[i] = plugins[i];
						navinfo.type = "navinfo";
						navinfo.id_guest = "' . (int) $params['cookie']->id_guest . '";
						navinfo.token = "' . $token . '";
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", navinfo);
					});
				</script>';
            }
        }
        // Record the guest path then increment the visit counter of the page
        $token_array = Connection::setPageConnection($params['cookie']);
        ConnectionsSource::logHttpReferer();
        if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) {
            Page::setPageViewed($token_array['id_page']);
        }
        if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) {
            // Ajax request sending the time spend on the page
            $token = sha1($token_array['id_connections'] . $token_array['id_page'] . $token_array['time_start'] . _COOKIE_KEY_);
            $html .= '
			<script type="text/javascript">
				var time_start;
				$(window).load(
					function() {
						time_start = new Date();
					}
				);
				$(window).unload(
					function() {
						var time_end = new Date();
						var pagetime = new Object;
						pagetime.type = "pagetime";
						pagetime.id_connections = "' . (int) $token_array['id_connections'] . '";
						pagetime.id_page = "' . (int) $token_array['id_page'] . '";
						pagetime.time_start = "' . $token_array['time_start'] . '";
						pagetime.token = "' . $token . '";
						pagetime.time = time_end-time_start;
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", pagetime);
					}
				);
			</script>';
        }
        return $html;
    }
Esempio n. 3
0
 public function makeNewLog()
 {
     unset($this->_content['id_customer']);
     unset($this->_content['id_guest']);
     Guest::setNewGuest($this);
     $this->_modified = true;
 }
Esempio n. 4
0
    function hookFooter($params)
    {
        global $protocol_content, $server_host;
        // Identification information are encrypted to prevent hacking attempts
        $blowfish = new Blowfish(_COOKIE_KEY_, _COOKIE_IV_);
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);
            // Ajax request sending browser information
            $token = $blowfish->encrypt($params['cookie']->id_guest);
            $this->_html = '
			<script type="text/javascript" src="' . $protocol_content . $server_host . __PS_BASE_URI__ . 'js/pluginDetect.js"></script>
			<script type="text/javascript">
				plugins = new Object;
				
				plugins.adobe_director = (PluginDetect.getVersion("Shockwave") != null) ? 1 : 0;
				plugins.adobe_flash = (PluginDetect.getVersion("Flash") != null) ? 1 : 0;
				plugins.apple_quicktime = (PluginDetect.getVersion("QuickTime") != null) ? 1 : 0;
				plugins.windows_media = (PluginDetect.getVersion("WindowsMediaPlayer") != null) ? 1 : 0;
				plugins.sun_java = (PluginDetect.getVersion("java") != null) ? 1 : 0;
				plugins.real_player = (PluginDetect.getVersion("RealPlayer") != null) ? 1 : 0;
				
				$(document).ready(
					function() {
						navinfo = new Object;
						navinfo = { screen_resolution_x: screen.width, screen_resolution_y: screen.height, screen_color:screen.colorDepth};
						for (var i in plugins)
							navinfo[i] = plugins[i];
						navinfo.type = "navinfo";
						navinfo.token = "' . $token . '";
						$.post("' . $protocol_content . $server_host . __PS_BASE_URI__ . 'statistics.php", navinfo);
					}
				);
			</script>';
        }
        // Record the guest path then increment the visit counter of the page
        $tokenArray = Connection::setPageConnection($params['cookie']);
        ConnectionsSource::logHttpReferer();
        Page::setPageViewed($tokenArray['id_page']);
        // Ajax request sending the time spend on the page
        $token = $blowfish->encrypt($tokenArray['id_connections'] . '|' . $tokenArray['id_page'] . '|' . $tokenArray['time_start']);
        $this->_html .= '
		<script type="text/javascript">
			var time_start;
			$(window).load(
				function() {
					time_start = new Date();
				}
			);
			$(window).unload(
				function() {
					var time_end = new Date();
					var pagetime = new Object;
					pagetime.type = "pagetime";
					pagetime.token = "' . $token . '";
					pagetime.time = time_end-time_start;
					$.post("' . $protocol_content . $server_host . __PS_BASE_URI__ . 'statistics.php", pagetime);
				}
			);
		</script>';
        return $this->_html;
    }
Esempio n. 5
0
 /**
  * Hook Header : Add Media CSS & JS
  *
  * @param array $params list of specific data
  */
 public function hookHeader($params)
 {
     if (!isset($params['cookie']->id_guest)) {
         Guest::setNewGuest($params['cookie']);
     }
     // Check if prediggo module can be executed in this page
     if ($this->oPrediggoCallController->isPageAccessible() || $this->oPrediggoCallController->getPageName() == 'prediggo_search' || $this->oPrediggoSearchConfig->search_active) {
         Tools::addCSS($this->_path . 'css/' . $this->name . '.css', 'all');
         Tools::addJS(array($this->_path . 'js/prediggo_autocomplete.js', $this->_path . 'js/' . $this->name . '.js'));
     }
 }
Esempio n. 6
0
 /**
  * Hook Header : Add Media CSS & JS
  *
  * @param array $params list of specific data
  */
 public function hookDisplayHeader($params)
 {
     if (!isset($params['cookie']->id_guest)) {
         Guest::setNewGuest($params['cookie']);
     }
     if (!$this->oPrediggoConfig->web_site_id_checked) {
         return false;
     }
     // Check if prediggo module can be executed in this page
     if ($this->oPrediggoCallController->isPageAccessible() || $this->oPrediggoCallController->getPageName() == 'prediggo_search' || $this->oPrediggoConfig->search_active) {
         $this->context->controller->addCSS($this->_path . 'css/front/' . $this->name . '.css', 'all');
         $this->context->controller->addJS(array($this->_path . 'js/front/prediggo_autocomplete.js', $this->_path . 'js/front/' . $this->name . '.js'));
     }
 }
Esempio n. 7
0
 function makeNewLog()
 {
     unset($this->_content['id_customer']);
     unset($this->_content['id_guest']);
     Guest::setNewGuest($this);
 }
 private function _frontOfficePostProcess()
 {
     global $smarty, $cookie, $errors;
     require_once dirname(__FILE__) . '/ProductComment.php';
     require_once dirname(__FILE__) . '/ProductCommentCriterion.php';
     if (empty($cookie->id_customer) && !isset($cookie->id_guest)) {
         Guest::setNewGuest($cookie);
     }
     $allow_guests = (int) Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS');
     if (Tools::isSubmit('submitMessage') && (!empty($cookie->id_customer) || $cookie->id_guest && $allow_guests)) {
         $id_guest = !($id_customer = (int) $cookie->id_customer) ? (int) $cookie->id_guest : false;
         $customerComment = ProductComment::getByCustomer((int) Tools::getValue('id_product'), (int) $cookie->id_customer, true, (int) $id_guest);
         if (!$customerComment || $customerComment && strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME') < time()) {
             $customer_name = false;
             if ($id_guest && !($customer_name = Tools::getValue('customer_name'))) {
                 $errors[] = $this->l('Please fill your name');
             }
             if (!count($errors) && Tools::getValue('content')) {
                 $comment = new ProductComment();
                 $comment->content = strip_tags(Tools::getValue('content'));
                 $comment->id_product = (int) $_GET['id_product'];
                 $comment->id_customer = (int) $cookie->id_customer;
                 $comment->id_guest = (int) $id_guest;
                 $comment->customer_name = pSQL($customer_name);
                 $comment->title = pSQL(Tools::getValue('title'));
                 $comment->grade = 0;
                 $comment->validate = 0;
                 if (!$comment->content) {
                     $errors[] = $this->l('Invalid comment text posted.');
                 } else {
                     $comment->save();
                     for ($i = 1, $grade = 0; isset($_POST[$i . '_grade']) === true; ++$i) {
                         $cgrade = (int) Tools::getValue($i . '_grade');
                         $grade += $cgrade;
                         $productCommentCriterion = new ProductCommentCriterion((int) Tools::getValue('id_product_comment_criterion_' . $i));
                         if ($productCommentCriterion->id) {
                             $productCommentCriterion->addGrade($comment->id, $cgrade);
                         }
                     }
                     if ($i - 1 > 0) {
                         $comment->grade = $grade / ($i - 1);
                     }
                     if (!$comment->save()) {
                         $errors[] = $this->l('An error occurred while saving your comment.');
                     } else {
                         $smarty->assign('confirmation', $this->l('Comment posted.') . ((int) Configuration::get('PRODUCT_COMMENTS_MODERATE') ? ' ' . $this->l('Awaiting moderator validation.') : ''));
                     }
                 }
             } else {
                 $errors[] = $this->l('Comment text is required.');
             }
         } else {
             $errors[] = $this->l('You should wait') . ' ' . Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME') . ' ' . $this->l('seconds before posting a new comment');
         }
     }
 }
Esempio n. 9
0
 public function hookRightColumn($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return;
     }
     if (!isset($this->context->cart->id)) {
         if (!isset($this->context->cookie->id_guest)) {
             Guest::setNewGuest($this->context->cookie);
         }
         $cart = new Cart();
         $cart->recyclable = 0;
         $cart->gift = 0;
         $cart->id_shop = (int) $this->context->shop->id;
         $cart->id_lang = $this->context->language->id;
         $cart->id_currency = ($id_currency = $this->context->currency->id) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT');
         $cart->id_address_delivery = 0;
         $cart->id_address_invoice = 0;
         $cart->id_guest = (int) $this->context->cookie->id_guest;
         $cart->id_customer = (int) $this->context->cookie->id_customer;
         $cart->setNoMultishipping();
         $cart->save();
         $this->context->cart = $cart;
         $this->context->cookie->id_cart = $cart->id;
     }
     $result = $this->getHotelCartBookingData();
     $cart_htl_data = $result['cart_htl_data'];
     $total_rooms = $result['total_rooms_in_cart'];
     $cart_context = array('id' => $this->context->cart->id, 'id_customer' => $this->context->cart->id_customer, 'id_guest' => $this->context->cart->id_guest);
     // @todo this variable seems not used
     $this->smarty->assign(array('cart_htl_data' => $cart_htl_data, 'total_rooms_in_cart' => $total_rooms, 'module_dir' => _MODULE_DIR_, 'cart_context' => Tools::jsonEncode($cart_context), 'order_page' => strpos($_SERVER['PHP_SELF'], 'order') !== false, 'blockcart_top' => isset($params['blockcart_top']) && $params['blockcart_top'] ? true : false));
     $this->assignContentVars($params);
     return $this->display(__FILE__, 'blockcart.tpl');
 }
Esempio n. 10
0
    private function getScriptPlugins($params)
    {
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);
            if (Configuration::get('PS_STATSDATA_PLUGINS')) {
                if (_PS_VERSION_ >= 1.7) {
                    $this->context->controller->registerJavascript('modules-plugindetect', 'modules/' . $this->name . '/js/plugindetect.js', array('position' => 'bottom', 'priority' => 150));
                } else {
                    $this->context->controller->addJS($this->_path . 'js/plugindetect.js');
                }
                $token = sha1($params['cookie']->id_guest . _COOKIE_KEY_);
                return '<script type="text/javascript">
					$(document).ready(function() {
						plugins = new Object;
						plugins.adobe_director = (PluginDetect.getVersion("Shockwave") != null) ? 1 : 0;
						plugins.adobe_flash = (PluginDetect.getVersion("Flash") != null) ? 1 : 0;
						plugins.apple_quicktime = (PluginDetect.getVersion("QuickTime") != null) ? 1 : 0;
						plugins.windows_media = (PluginDetect.getVersion("WindowsMediaPlayer") != null) ? 1 : 0;
						plugins.sun_java = (PluginDetect.getVersion("java") != null) ? 1 : 0;
						plugins.real_player = (PluginDetect.getVersion("RealPlayer") != null) ? 1 : 0;

						navinfo = { screen_resolution_x: screen.width, screen_resolution_y: screen.height, screen_color:screen.colorDepth};
						for (var i in plugins)
							navinfo[i] = plugins[i];
						navinfo.type = "navinfo";
						navinfo.id_guest = "' . (int) $params['cookie']->id_guest . '";
						navinfo.token = "' . $token . '";
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", navinfo);
					});
				</script>';
            }
        }
        return '';
    }