Example #1
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;
    }
Example #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;
    }
Example #3
0
    private function getScriptCustomerPagesViews($params)
    {
        // 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_);
            return '<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 '';
    }