<?php
/*
+--------------------------------------------------------------------------
| D4WStatsLittle v1.1.2 - Developers4Web Web Stats Software
| ==========================================================
| by Developers4Web.com
| D4WStatsLittle is a Trade Mark of Developers4Web
| Copyright Developers4Web 2005 - 2006. All rights reserved.
| English:
| http://stats-service.developers4web.com
| Español:
| http://www.developers4web.com
| ========================================
| optimized by Trio Solutions
| Dreamweaver Extensions and Web Development Components
| English:
| http://components.developers4web.com
| Español:
| http://componentes.developers4web.com
| ========================================
| Web: http://www.d4wstats.com
| Date: Tuesday, February 20, 2006
| Email: info (at) developers4web (dot) com
| License Type: D4WSTATSLITTLE is NOT Open Source Software and Limitations Apply
| Licence Info: /d4wstatslittle/license.txt
+--------------------------------------------------------------------------
*/
?>
<?php
require "_dbconn.inc.php";
require "common.inc.php";
////$rs_countries_vr = mysql_query("select count(distinct (ip_converted) ) as ct,country from ".$tablename." group by country", $link);
////$rs_countries_vs = mysql_query("select count(distinct (ip_converted) ) as ct,country,hora from ".$tablename." group by country, hora", $link);
////$rs_countries_h = mysql_query("select count(id) as ct,country from ".$tablename." group by country", $link);
////$web = str_replace("_",".",$_GET["web"]);
////$rs_referers = mysql_query("select count(id) as ct, (concat(domain,'/',path)) as referer from ".$tablename." WHERE domain<>'http://".$web."' AND domain<>'' group by domain,path", $link);
// init
$ip_converted = array();
for ($i=0;$i<24;$i++)
$ip_converted_hours[$i] = array();
$rs_referers = array();
$rs_countries_vr = array();
$rs_countries_vs = array();
$rs_countries_h = array();
if (file_exists(DATABASE_PATH.$tablename))
{
$fp = fopen (DATABASE_PATH.$tablename,"r");
while ($data = fgetcsv ($fp, 1000, ","))
{
if (!$ip_converted[$data[3]])
{
$ip_converted[$data[3]] = 1;
$rs_countries_vr["x".$data[4]]++;
}
if ($data[5].$data[6] != '')
$rs_referers [$data[5].$data[6]]++; // full referer entries
$rs_countries_h["x".$data[4]]++;
if (!$ip_converted_hours[$data[0]][$data[3]])
{
$ip_converted_hours[$data[0]][$data[3]]++;
$rs_countries_vs["x".$data[4]]++;
}
}
fclose ($fp);
}
// countries
$day = array();
$visitors = 0;
$visits = 0;
$hits = 0;
foreach ($rs_countries_h as $item =>$value)
{
$day[$item]["h"] += $value;
$hits += $value;
}
foreach ($rs_countries_vs as $item =>$value)
{
$day[$item]["vs"] += $value;
$visits += $value;
}
foreach ($rs_countries_vr as $item =>$value)
{
$day[$item]["vr"] += $value;
$visitors += $value;
}
$arr["countries"] = $day;
// referers
$day = array();
// update
foreach ($rs_referers as $item =>$value)
$day[$item] += $value;
asort($day);
if (count($day) > 30)
$day = array_slice($day, count($day)-30);
$arr["referers"] = $day;
$arr["visitors"] = $visitors;
$arr["visits"] = $visits;
$arr["hits"] = $hits;
$str = serialize($arr);
?>