<?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(phpversion()<'4.1.0'){  
	$count_info = $HTTP_COOKIE_VARS["count_info"];
}else{
	$count_info = $_COOKIE["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 ("count_info",$cookie_string, $time+$counttime['cookietimeout']);

    }
}

?>