getMonthlyStats
function getMonthlyStats( $year )
{
global $xoopsDB, $xoopsTpl;
$now = date("d-m-Y");
$dot = explode ("-",$now);
$nowmonth = $dot[1];
$l_size = getimagesize("images/leftbar.gif");
$m_size = getimagesize("images/mainbar.gif");
$r_size = getimagesize("images/rightbar.gif");
// get monthly stats and display
$resultmonth = $xoopsDB->queryF("select sum(hits) as totalhitsmonth from ".$xoopsDB->prefix("stats_month")." where year='$year'");
list($totalhitsmonth) = $xoopsDB->fetchRow($resultmonth);
$xoopsDB->freeRecordSet($resultmonth);
$xoopsTpl->assign('lang_stat_monthlystats', STATS_MONTHLYSTATS." - ".$year );
$xoopsTpl->assign('lang_stat_monthhead', STATS_MONTH );
$resulttotal = $xoopsDB->queryF("select hits from ".$xoopsDB->prefix("stats_year")." where year='$year'");
list($hitsforyear) = $xoopsDB->fetchRow($resulttotal);
$xoopsDB->freeRecordSet($resulttotal);
$monthlist = array();
$result = $xoopsDB->queryF("select month,hits from ".$xoopsDB->prefix("stats_month")." where year='$year'");
$i = 0;
while (list($month,$hits) = $xoopsDB->fetchRow($result))
{
$monthlist[$i]['month'] = getMonth( $month );
$monthlist[$i]['hits'] = $hits;
if ($month != $nowmonth)
{
$monthlist[$i]['link'] = "statdetails.php?op=monthlystats&year=$year&month=$month">".$monthlist[$i]['month']."";
}
else
{
$monthlist[$i]['link'] = "";
}
$midbarsize = substr(100 * $hits / $hitsforyear, 0, 5);
$monthlist[$i]['percent'] = $midbarsize."%";
$m_name = getMonth($month);
$monthlist[$i]['graph'] = "images/leftbar.gif" height="$l_size[1]" width="$l_size[0]" Alt="$m_name - $hits">images/mainbar.gif" Alt="$m_name - $hits" height="$m_size[1]" width="$midbarsize">images/rightbar.gif" height="$r_size[1]" width="$r_size[0]" Alt="$m_name - $hits">";
$i++;
}
$xoopsTpl->assign('monthlist', $monthlist );
$xoopsDB->freeRecordSet($result);
}
|