<?php
// +---------------------------------------------+
// |     Copyright 2003 - 2005 weenCompany       |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

if(!defined('IN_WEENCOMPANY'))
{
  die('File not found!');
}


global $hits, $DB;

if($sitedefaultlang == 'en') 
{
	$forelang='en';
}
else
{
	$forelang='cn';
}

if(phpversion()<'4.1.0'){  
	$count_info = $HTTP_COOKIE_VARS[$forelang . "count_info"];
}else{
	$count_info = $_COOKIE[$forelang . "count_info"];
}

$time = time();
if (!isset($count_info)){
    $counttime = $DB->query_first("SELECT cookietimeout FROM " . TABLE_PREFIX . "m18_hitcounter");

	if (time($count_info)+$counttime['cookietimeout'] >= time()){

        $resultconf = $DB->query("SELECT hits FROM " . TABLE_PREFIX . "m18_hitcounter");
		list($hits) = mysql_fetch_row($resultconf);

		$hits++;
		$DB->query("UPDATE " . TABLE_PREFIX . "m18_hitcounter SET hits=".$hits);

   		$cookie_string = $time;
   		setcookie ($forelang . "count_info",$cookie_string, $time+$counttime['cookietimeout']);

    }
}

?>