Modules: XOOP-Stats - No Month Display in "Hit Details"

Posted by: seventhsealon 2005/2/1 15:44:34 5968 reads
Thanks to some quick reporting by artigas, it was noticed that "hit details" was not showing the months for a given year. After midnight Jan. 31 it only was displaying December 2005. A bit strange, but easily fixed.

A download version will be available later today, but the quick fix is as follows:

In the statistics/include directory is a file called statutils.php. Load it in your favorite editor. So we don't get confused on line numbers and different versions of editors, just replace the entire function declaration and code
getMonthlyStats

with
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'] = "<a href="statdetails.php?op=monthlystats&year=$year&month=$month">".$monthlist[$i]['month']."</a>";
    }
    else
    {
      
$monthlist[$i]['link'] = "";
    }
  
    
$midbarsize substr(100 $hits $hitsforyear05);
    
$monthlist[$i]['percent'] = $midbarsize."%";
    
$m_name getMonth($month);
    
$monthlist[$i]['graph'] = "<img src="images/leftbar.gif" height="$l_size[1]" width="$l_size[0]" Alt="$m_name $hits"><img src="images/mainbar.gif" Alt="$m_name $hits" height="$m_size[1]" width="$midbarsize"><img src="images/rightbar.gif" height="$r_size[1]" width="$r_size[0]" Alt="$m_name $hits">";
    
$i++;
  }
  
$xoopsTpl->assign('monthlist'$monthlist );
  
$xoopsDB->freeRecordSet($result);
}


This will fix it! :t-up:

Now, for those detail oriented folks, basically a counter was not getting incremented when creating the month list for details. The wierd thing is, I'm not entirely sure how it was working for December 2004 and January 2005. But, it was, and now it's fixed. This has already been fixed for v0.60 - coming soon!

Thanks for reporting, and thanks for using.