<?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";
////$web = str_replace("_",".",$_GET["web"]);
////$rs_searchengines = mysql_query("select count(id) as ct, searchengine, keyword from ".$tablename." where keyword<>'' group by searchengine, keyword", $link);
// init
$rs_searchengines["x".SE_GOOGLE] = array();
$rs_searchengines["x".SE_YAHOO] = array();
$rs_searchengines["x".SE_MSN] = array();
if (file_exists(DATABASE_PATH.$tablename))
{
$fp = fopen (DATABASE_PATH.$tablename,"r");
while ($data = fgetcsv ($fp, 1000, ","))
$rs_searchengines["x".$data[8]]["x".$data[7]]++; // search engine + keyword
fclose ($fp);
}
$total = array();
$month = array();
$countk["day"]["x".SE_GOOGLE] = 0;
$countk["month"]["x".SE_GOOGLE] = 0;
$countk["total"]["x".SE_GOOGLE] = 0;
$countk["day"]["x".SE_YAHOO] = 0;
$countk["month"]["x".SE_YAHOO] = 0;
$countk["total"]["x".SE_YAHOO] = 0;
$countk["day"]["x".SE_MSN] = 0;
$countk["month"]["x".SE_MSN] = 0;
$countk["total"]["x".SE_MSN] = 0;
$day = array();
$day["x".SE_GOOGLE] = array();
$day["x".SE_YAHOO] = array();
$day["x".SE_MSN] = array();
// init
if (!isset($total["x".SE_GOOGLE])) $total["x".SE_GOOGLE] = array();
if (!isset($total["x".SE_YAHOO])) $total["x".SE_YAHOO] = array();
if (!isset($total["x".SE_MSN])) $total["x".SE_MSN] = array();
if (!isset($month["x".SE_GOOGLE])) $month["x".SE_GOOGLE] = array();
if (!isset($month["x".SE_YAHOO])) $month["x".SE_YAHOO] = array();
if (!isset($month["x".SE_MSN])) $month["x".SE_MSN] = array();
// update
foreach ($rs_searchengines["x".SE_GOOGLE] as $item => $value)
{
$total["x".SE_GOOGLE][$item] += $value;
$month["x".SE_GOOGLE][$item] += $value;
$day["x".SE_GOOGLE][$item] += $value;
}
foreach ($rs_searchengines["x".SE_YAHOO] as $item => $value)
{
$total["x".SE_YAHOO][$item] += $value;
$month["x".SE_YAHOO][$item] += $value;
$day["x".SE_YAHOO][$item] += $value;
}
foreach ($rs_searchengines["x".SE_MSN] as $item => $value)
{
$total["x".SE_MSN][$item] += $value;
$month["x".SE_MSN][$item] += $value;
$day["x".SE_MSN][$item] += $value;
}
define('MAX_SHOW_KEYWORDS_TOTAL', 50);
define('MAX_SHOW_KEYWORDS_MONTH', 50);
define('MAX_SHOW_KEYWORDS_DAY', 40);
// save database
asort($total["x".SE_GOOGLE]);
if (count($total["x".SE_GOOGLE]) > MAX_SHOW_KEYWORDS_TOTAL)
$total["x".SE_GOOGLE] = array_slice($total["x".SE_GOOGLE], count($total["x".SE_GOOGLE])-MAX_SHOW_KEYWORDS_TOTAL);
asort($month["x".SE_GOOGLE]);
if (count($month["x".SE_GOOGLE]) > MAX_SHOW_KEYWORDS_MONTH)
$month["x".SE_GOOGLE] = array_slice($month["x".SE_GOOGLE], count($month["x".SE_GOOGLE])-MAX_SHOW_KEYWORDS_MONTH);
asort($day["x".SE_GOOGLE]);
if (count($day["x".SE_GOOGLE]) > MAX_SHOW_KEYWORDS_DAY)
$day["x".SE_GOOGLE] = array_slice($day["x".SE_GOOGLE], count($day["x".SE_GOOGLE])-MAX_SHOW_KEYWORDS_DAY);
asort($total["x".SE_YAHOO]);
if (count($total["x".SE_YAHOO]) > MAX_SHOW_KEYWORDS_TOTAL)
$total["x".SE_YAHOO] = array_slice($total["x".SE_YAHOO], count($total["x".SE_YAHOO])-MAX_SHOW_KEYWORDS_TOTAL);
asort($month["x".SE_YAHOO]);
if (count($month["x".SE_YAHOO]) > MAX_SHOW_KEYWORDS_MONTH)
$month["x".SE_YAHOO] = array_slice($month["x".SE_YAHOO], count($month["x".SE_YAHOO])-MAX_SHOW_KEYWORDS_MONTH);
asort($day["x".SE_YAHOO]);
if (count($day["x".SE_YAHOO]) > MAX_SHOW_KEYWORDS_DAY)
$day["x".SE_YAHOO] = array_slice($day["x".SE_YAHOO], count($day["x".SE_YAHOO])-MAX_SHOW_KEYWORDS_DAY);
asort($total["x".SE_MSN]);
if (count($total["x".SE_MSN]) > MAX_SHOW_KEYWORDS_TOTAL)
$total["x".SE_MSN] = array_slice($total["x".SE_MSN], count($total["x".SE_MSN])-MAX_SHOW_KEYWORDS_TOTAL);
asort($month["x".SE_MSN]);
if (count($month["x".SE_MSN]) > MAX_SHOW_KEYWORDS_MONTH)
$month["x".SE_MSN] = array_slice($month["x".SE_MSN], count($month["x".SE_MSN])-MAX_SHOW_KEYWORDS_MONTH);
asort($day["x".SE_MSN]);
if (count($day["x".SE_MSN]) > MAX_SHOW_KEYWORDS_DAY)
$day["x".SE_MSN] = array_slice($day["x".SE_MSN], count($day["x".SE_MSN])-MAX_SHOW_KEYWORDS_DAY);
foreach($day["x".SE_MSN] as $item => $value)
$countk["day"]["x".SE_MSN] += $value;
foreach($month["x".SE_MSN] as $item => $value)
$countk["month"]["x".SE_MSN] += $value;
foreach($total["x".SE_MSN] as $item => $value)
$countk["total"]["x".SE_MSN] += $value;
foreach($day["x".SE_YAHOO] as $item => $value)
$countk["day"]["x".SE_YAHOO] += $value;
foreach($month["x".SE_YAHOO] as $item => $value)
$countk["month"]["x".SE_YAHOO] += $value;
foreach($total["x".SE_YAHOO] as $item => $value)
$countk["total"]["x".SE_YAHOO] += $value;
foreach($day["x".SE_GOOGLE] as $item => $value)
$countk["day"]["x".SE_GOOGLE] += $value;
foreach($month["x".SE_GOOGLE] as $item => $value)
$countk["month"]["x".SE_GOOGLE] += $value;
foreach($total["x".SE_GOOGLE] as $item => $value)
$countk["total"]["x".SE_GOOGLE] += $value;
$arr["total"] = $total;
$arr["month"] = $month;
$arr["day"] = $day;
$arr["count"] = $countk;
$str = serialize($arr);
?>