home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / statistics / index.php
Encoding:
PHP Script  |  2002-09-16  |  29.5 KB  |  456 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* Enhanced with NukeStats Module Version 1.0                           */
  11. /* ==========================================                           */
  12. /* Copyright ⌐2002 by Harry Mangindaan (sens@indosat.net) and           */
  13. /*                    Sudirman (sudirman@akademika.net)                 */
  14. /* http://www.nuketest.com                                              */
  15. /*                                                                      */
  16. /* This program is free software. You can redistribute it and/or modify */
  17. /* it under the terms of the GNU General Public License as published by */
  18. /* the Free Software Foundation; either version 2 of the License.       */
  19. /************************************************************************/
  20.  
  21. if (!eregi("modules.php", $PHP_SELF)) {
  22.     die ("You can't access this file directly...");
  23. }
  24. require_once("mainfile.php");
  25. $module_name = basename(dirname(__FILE__));
  26. get_lang($module_name);
  27. $pagetitle = "- "._STATS."";
  28.  
  29. $ThemeSel = get_theme();
  30.  
  31. $now = date("d-m-Y");
  32. $dot = explode ("-",$now);
  33. $nowdate = $dot[0];
  34. $nowmonth = $dot[1];
  35. $nowyear = $dot[2];
  36.  
  37. function Stats_Main() {
  38.     global $prefix, $dbi, $startdate, $sitename, $ThemeSel, $user_prefix, $Version_Num, $module_name;
  39.     include("header.php");
  40.     $result = sql_query("select type, var, count from ".$prefix."_counter order by type desc", $dbi);
  41.     while(list($type, $var, $count) = sql_fetch_row($result, $dbi)) {
  42.     if(($type == "total") && ($var == "hits")) {
  43.         $total = $count;
  44.     } elseif($type == "browser") {
  45.         if($var == "Netscape") {
  46.             $netscape[] = $count;
  47.             $netscape[] =  substr(100 * $count / $total, 0, 5);
  48.         } elseif($var == "MSIE") {
  49.             $msie[] = $count;
  50.             $msie[] =  substr(100 * $count / $total, 0, 5);
  51.         } elseif($var == "Konqueror") {
  52.             $konqueror[] = $count;
  53.             $konqueror[] =  substr(100 * $count / $total, 0, 5);
  54.         } elseif($var == "Opera") {
  55.             $opera[] = $count;
  56.             $opera[] =  substr(100 * $count / $total, 0, 5);
  57.         } elseif($var == "Lynx") {
  58.             $lynx[] = $count;
  59.             $lynx[] =  substr(100 * $count / $total, 0, 5);
  60.         } elseif($var == "Bot") {
  61.             $bot[] = $count;
  62.             $bot[] =  substr(100 * $count / $total, 0, 5);
  63.         } elseif(($type == "browser") && ($var == "Other")) {
  64.             $b_other[] = $count;
  65.             $b_other[] =  substr(100 * $count / $total, 0, 5);
  66.         }
  67.     } elseif($type == "os") {
  68.         if($var == "Windows") {
  69.             $windows[] = $count;
  70.             $windows[] =  substr(100 * $count / $total, 0, 5);
  71.         } elseif($var == "Mac") {
  72.             $mac[] = $count;
  73.             $mac[] =  substr(100 * $count / $total, 0, 5);
  74.         } elseif($var == "Linux") {
  75.             $linux[] = $count;
  76.             $linux[] =  substr(100 * $count / $total, 0, 5);
  77.         } elseif($var == "FreeBSD") {
  78.             $freebsd[] = $count;
  79.             $freebsd[] =  substr(100 * $count / $total, 0, 5);
  80.         } elseif($var == "SunOS") {
  81.             $sunos[] = $count;
  82.             $sunos[] =  substr(100 * $count / $total, 0, 5);
  83.         } elseif($var == "IRIX") {
  84.             $irix[] = $count;
  85.             $irix[] =  substr(100 * $count / $total, 0, 5);
  86.         } elseif($var == "BeOS") {
  87.             $beos[] = $count;
  88.             $beos[] =  substr(100 * $count / $total, 0, 5);
  89.         } elseif($var == "OS/2") {
  90.             $os2[] = $count;
  91.             $os2[] =  substr(100 * $count / $total, 0, 5);
  92.         } elseif($var == "AIX") {
  93.             $aix[] = $count;
  94.             $aix[] =  substr(100 * $count / $total, 0, 5);
  95.         } elseif(($type == "os") && ($var == "Other")) {
  96.             $os_other[] = $count;
  97.             $os_other[] =  substr(100 * $count / $total, 0, 5);
  98.         }
  99.     }
  100.     }
  101.     title("$sitename "._STATS."");
  102.     OpenTable();
  103.     OpenTable();
  104.     echo "<center><font class=\"option\"><b>$sitename "._STATS."</b></font><br><br>"._WERECEIVED." <b>$total</b> "._PAGESVIEWS." $startdate<br><br>"
  105.     ."[ <a href=\"modules.php?name=$module_name&op=Stats\">"._VIEWDETAILED."</a> ]</center>";
  106.     CloseTable();
  107.     echo "<br><br>";
  108.     $l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
  109.     $m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
  110.     $r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
  111.     OpenTable2();
  112.     echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"2\">\n";
  113.     echo "<center><font color=\"$textcolor2\"><b>"._BROWSERS."</b></font></center><br></td></tr>\n";
  114.     echo "<tr><td><img src=\"modules/$module_name/images/explorer.gif\" border=\"0\" alt=\"\"> MSIE: </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Internet Explorer\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Internet Explorer\" height=\"$m_size[1]\" width=", $msie[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Internet Explorer\"> $msie[1] % ($msie[0])</td></tr>\n";
  115.     echo "<tr><td><img src=\"modules/$module_name/images/netscape.gif\" border=\"0\" alt=\"\"> Netscape: </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Netscape\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Netscape\" height=\"$m_size[1]\" width=", $netscape[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Netscape\"> $netscape[1] % ($netscape[0])</td></tr>\n";
  116.     echo "<tr><td><img src=\"modules/$module_name/images/opera.gif\" border=\"0\" alt=\"\"> Opera: </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Opera\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Opera\" height=\"$m_size[1]\" width=", $opera[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Opera\"> $opera[1] % ($opera[0])</td></tr>\n";
  117.     echo "<tr><td><img src=\"modules/$module_name/images/konqueror.gif\" border=\"0\" alt=\"\"> Konqueror: </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Konqueror\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Konqueror (KDE)\" height=\"$m_size[1]\" width=", $konqueror[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Konqueror\"> $konqueror[1] % ($konqueror[0])</td></tr>\n";
  118.     echo "<tr><td><img src=\"modules/$module_name/images/lynx.gif\" border=\"0\" alt=\"\"> Lynx: </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Lynx\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Lynx\" height=\"$m_size[1]\" width=", $lynx[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Lynx\"> $lynx[1] % ($lynx[0])</td></tr>\n";
  119.     echo "<tr><td><img src=\"modules/$module_name/images/altavista.gif\" border=\"0\" alt=\"\"> "._SEARCHENGINES.": </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Robots - Spiders - Buscadores\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Robots - Spiders - Buscadores\" height=\"$m_size[1]\" width=", $bot[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\""._BOTS."\"> $bot[1] % ($bot[0])</td></tr>\n";
  120.     echo "<tr><td><img src=\"modules/$module_name/images/question.gif\" border=\"0\" alt=\"\"> "._UNKNOWN.": </td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Otros - Desconocidos\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Otros - Desconocidos\" height=\"$m_size[1]\" width=", $b_other[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\""._OTHER."\"> $b_other[1] % ($b_other[0])\n";
  121.     echo "</td></tr></table>";
  122.     CloseTable2();
  123.     echo "<br><br>\n";
  124.     OpenTable2();
  125.     echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"2\">\n";
  126.     echo "<center><font color=\"$textcolor2\"><b>"._OPERATINGSYS."</b></font></center><br></td></tr>\n";
  127.     echo "<tr><td><img src=\"modules/$module_name/images/windows.gif\" border=\"0\" alt=\"\"> Windows:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Windows\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Windows\" height=\"$m_size[1]\" width=", $windows[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Windows\"> $windows[1] % ($windows[0])</td></tr>\n";
  128.     echo "<tr><td><img src=\"modules/$module_name/images/linux.gif\" border=\"0\" alt=\"\"> Linux:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Linux\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Linux\" height=\"$m_size[1]\" width=", $linux[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Linux\"> $linux[1] % ($linux[0])</td></tr>\n";
  129.     echo "<tr><td><img src=\"modules/$module_name/images/mac.gif\" border=\"0\" alt=\"\"> Mac/PPC:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Mac/PPC\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"Mac - PPC\" height=\"$m_size[1]\" width=", $mac[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"Mac/PPC\"> $mac[1] % ($mac[0])</td></tr>\n";
  130.     echo "<tr><td><img src=\"modules/$module_name/images/bsd.gif\" border=\"0\" alt=\"\"> FreeBSD:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"FreeBSD\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"FreeBSD\" height=\"$m_size[1]\" width=", $freebsd[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"FreeBSD\"> $freebsd[1] % ($freebsd[0])</td></tr>\n";
  131.     echo "<tr><td><img src=\"modules/$module_name/images/sun.gif\" border=\"0\" alt=\"\"> SunOS:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"SunOS\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"SunOS\" height=\"$m_size[1]\" width=", $sunos[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"SunOS\"> $sunos[1] % ($sunos[0])</td></tr>\n";
  132.     echo "<tr><td><img src=\"modules/$module_name/images/irix.gif\" border=\"0\" alt=\"\"> IRIX:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"SGI Irix\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"SGI Irix\" height=\"$m_size[1]\" width=", $irix[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"SGI Irix\"> $irix[1] % ($irix[0])</td></tr>\n";
  133.     echo "<tr><td><img src=\"modules/$module_name/images/be.gif\" border=\"0\" alt=\"\"> BeOS:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"BeOS\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"BeOS\" height=\"$m_size[1]\" width=", $beos[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"BeOS\"> $beos[1] % ($beos[0])</td></tr>\n";
  134.     echo "<tr><td><img src=\"modules/$module_name/images/os2.gif\" border=\"0\" alt=\"\"> OS/2:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"OS/2\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"OS/2\" height=\"$m_size[1]\" width=", $os2[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"OS/2\"> $os2[1] % ($os2[0])</td></tr>\n";
  135.     echo "<tr><td><img src=\"modules/$module_name/images/aix.gif\" border=\"0\" alt=\"\"> AIX:</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"AIX\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" Alt=\"AIX\" height=\"$m_size[1]\" width=", $aix[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"AIX\"> $aix[1] % ($aix[0])</td></tr>\n";
  136.     echo "<tr><td><img src=\"modules/$module_name/images/question.gif\" border=\"0\" alt=\"\"> "._UNKNOWN.":</td><td><img src=\"themes/$ThemeSel/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"Otros - Desconocidos\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" ALt=\"Otros - Desconocidos\" height=\"$m_size[1]\" width=", $os_other[1] * 2, "><img src=\"themes/$ThemeSel/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\""._OTHER."\"> $os_other[1] % ($os_other[0])\n";
  137.     echo "</td></tr></table>\n";
  138.     CloseTable2();
  139.     echo "<br><br>\n";
  140.  
  141.     $unum = sql_num_rows(sql_query("select * from ".$user_prefix."_users", $dbi));
  142.     $anum = sql_num_rows(sql_query("select * from ".$prefix."_authors", $dbi));
  143.     $snum = sql_num_rows(sql_query("select * from ".$prefix."_stories", $dbi));
  144.     $cnum = sql_num_rows(sql_query("select * from ".$prefix."_comments", $dbi));
  145.     if (is_active("Sections")) {
  146.     $secnum = sql_num_rows(sql_query("select * from ".$prefix."_sections", $dbi));
  147.     $secanum = sql_num_rows(sql_query("select * from ".$prefix."_seccont", $dbi));
  148.     }
  149.     $subnum = sql_num_rows(sql_query("select * from ".$prefix."_queue", $dbi));
  150.     if (is_active("Topics")) {
  151.     $tnum = sql_num_rows(sql_query("select * from ".$prefix."_topics", $dbi));
  152.     }
  153.     if (is_active("Web_Links")) {
  154.     $links = sql_num_rows(sql_query("select * from ".$prefix."_links_links", $dbi));
  155.     $cat = sql_num_rows(sql_query("select * from ".$prefix."_links_categories", $dbi));
  156.     }
  157.     OpenTable2();
  158.     echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"2\">\n";
  159.     echo "<center><font color=\"$textcolor2\"><b>"._MISCSTATS."</b></font></center><br></td></tr>\n";
  160.     echo "<tr><td><img src=\"modules/$module_name/images/users.gif\" border=\"0\" alt=\"\"> "._REGUSERS."</td><td><b>$unum</b></td></tr>\n";
  161.     echo "<tr><td><img src=\"modules/$module_name/images/authors.gif\" border=\"0\" alt=\"\"> "._ACTIVEAUTHORS."</td><td><b>$anum</b></td></tr>\n";
  162.     echo "<tr><td><img src=\"modules/$module_name/images/news.gif\" border=\"0\" alt=\"\"> "._STORIESPUBLISHED."</td><td><b>$snum</b></td></tr>\n";
  163.     if (is_active("Topics")) {
  164.     echo "<tr><td><img src=\"modules/$module_name/images/topics.gif\" border=\"0\" alt=\"\"> "._SACTIVETOPICS."</td><td><b>$tnum</b></td></tr>\n";
  165.     }
  166.     echo "<tr><td><img src=\"modules/$module_name/images/comments.gif\" border=\"0\" alt=\"\"> "._COMMENTSPOSTED."</td><td><b>$cnum</b></td></tr>\n";
  167.     if (is_active("Sections")) {
  168.     echo "<tr><td><img src=\"modules/$module_name/images/sections.gif\" border=\"0\" alt=\"\"> "._SSPECIALSECT."</td><td><b>$secnum</b></td></tr>\n";
  169.     echo "<tr><td><img src=\"modules/$module_name/images/articles.gif\" border=\"0\" alt=\"\"> "._ARTICLESSEC."</td><td><b>$secanum</b></td></tr>\n";
  170.     }
  171.     if (is_active("Web_Links")) {
  172.     echo "<tr><td><img src=\"modules/$module_name/images/topics.gif\" border=\"0\" alt=\"\"> "._LINKSINLINKS."</td><td><b>$links</b></td></tr>\n";
  173.     echo "<tr><td><img src=\"modules/$module_name/images/sections.gif\" border=\"0\" alt=\"\"> "._LINKSCAT."</td><td><b>$cat</b></td></tr>\n";
  174.     }
  175.     echo "<tr><td><img src=\"modules/$module_name/images/waiting.gif\" border=\"0\" alt=\"\"> "._NEWSWAITING."</td><td><b>$subnum</b></td></tr>\n";
  176.  
  177.     /* Do not Remove the following line! */
  178.     echo "<tr><td><img src=\"modules/$module_name/images/sections.gif\" border=\"0\" alt=\"\"> "._NUKEVERSION."</td><td><b>$Version_Num</b>\n";
  179.  
  180.     echo "</td></tr></table>\n";
  181.     CloseTable2();
  182.     CloseTable();
  183.     include("footer.php");
  184. }
  185.  
  186. function Stats($total) {
  187.     global $hlpfile,$nowyear,$nowmonth,$nowdate,$nowhour, $sitename, $startdate, $prefix, $dbi, $now, $module_name;
  188.     $result = sql_query("select count from ".$prefix."_counter order by type desc", $dbi);
  189.     list($total) = sql_fetch_row($result, $dbi);
  190.     include ("header.php");
  191.     title("$sitename "._STATS."");
  192.     $total++;
  193.     OpenTable();
  194.     OpenTable();
  195.     echo "<center><font class=\"option\"><b>$sitename "._STATS."</b></font><br><br>"._WERECEIVED." <b>$total</b> "._PAGESVIEWS." $startdate<br>"._TODAYIS.": $now[0]/$now[1]/$now[2]<br><br>";
  196.  
  197.     $result = sql_query("select year, month, hits from ".$prefix."_stats_month order by hits DESC limit 0,1", $dbi);
  198.     list($year, $month, $hits) = sql_fetch_row($result, $dbi);
  199.     if ($month == 1) {$month = _JANUARY;} elseif ($month == 2) {$month = _FEBRUARY;} elseif ($month == 3) {$month = _MARCH;} elseif ($month == 4) {$month = _APRIL;} elseif ($month == 5) {$month = _MAY;} elseif ($month == 6) {$month = _JUNE;} elseif ($month == 7) {$month = _JULY;} elseif ($month == 8) {$month = _AUGUST;} elseif ($month == 9) {$month = _SEPTEMBER;} elseif ($month == 10) {$month = _OCTOBER;} elseif ($month == 11) {$month = _NOVEMBER;} elseif ($month == 12) {$month = _DECEMBER;}
  200.     echo ""._MOSTMONTH.": $month $year ($hits "._HITS.")<br>";
  201.  
  202.     $result = sql_query("select year, month, date, hits from ".$prefix."_stats_date order by hits DESC limit 0,1", $dbi);
  203.     list($year, $month, $date, $hits) = sql_fetch_row($result, $dbi);
  204.     if ($month == 1) {$month = _JANUARY;} elseif ($month == 2) {$month = _FEBRUARY;} elseif ($month == 3) {$month = _MARCH;} elseif ($month == 4) {$month = _APRIL;} elseif ($month == 5) {$month = _MAY;} elseif ($month == 6) {$month = _JUNE;} elseif ($month == 7) {$month = _JULY;} elseif ($month == 8) {$month = _AUGUST;} elseif ($month == 9) {$month = _SEPTEMBER;} elseif ($month == 10) {$month = _OCTOBER;} elseif ($month == 11) {$month = _NOVEMBER;} elseif ($month == 12) {$month = _DECEMBER;}
  205.     echo ""._MOSTDAY.": $date $month $year ($hits "._HITS.")<br>";
  206.  
  207.     $result = sql_query("select year, month, date, hour, hits from ".$prefix."_stats_hour order by hits DESC limit 0,1", $dbi);
  208.     list($year, $month, $date, $hour, $hits) = sql_fetch_row($result, $dbi);
  209.     if ($month == 1) {$month = _JANUARY;} elseif ($month == 2) {$month = _FEBRUARY;} elseif ($month == 3) {$month = _MARCH;} elseif ($month == 4) {$month = _APRIL;} elseif ($month == 5) {$month = _MAY;} elseif ($month == 6) {$month = _JUNE;} elseif ($month == 7) {$month = _JULY;} elseif ($month == 8) {$month = _AUGUST;} elseif ($month == 9) {$month = _SEPTEMBER;} elseif ($month == 10) {$month = _OCTOBER;} elseif ($month == 11) {$month = _NOVEMBER;} elseif ($month == 12) {$month = _DECEMBER;}
  210.     if ($hour < 10) {
  211.     $hour = "0$hour:00 - 0$hour:59";
  212.     } else {
  213.     $hour = "$hour:00 - $hour:59";
  214.     }
  215.     echo ""._MOSTHOUR.": $hour "._ON." $month $date, $year ($hits "._HITS.")<br><br>"
  216.     ."[ <a href=\"modules.php?name=$module_name\">"._RETURNBASICSTATS."</a> ]</center>";
  217.  
  218.     CloseTable();
  219.     echo "<br><br>";
  220.     showYearStats($nowyear);
  221.     echo "<BR><BR>";
  222.     showMonthStats($nowyear,$nowmonth);
  223.     echo "<BR><BR>";
  224.     showDailyStats($nowyear,$nowmonth,$nowdate);
  225.     echo "<BR><BR>";
  226.     showHourlyStats($nowyear,$nowmonth,$nowdate);
  227.     echo "<br><br><center>"._GOBACK."</center><br><br>";
  228.     CloseTable();
  229.     include ("footer.php");
  230. }
  231.  
  232. function YearlyStats($year){
  233.     global $hlpfile,$nowyear,$nowmonth,$nowdate, $sitename, $module_name;
  234.     include ("header.php");
  235.     title("$sitename "._STATS."");
  236.     opentable();
  237.     showMonthStats($year,$nowmonth);
  238.     echo "<BR>";
  239.     echo "<center>[ <a href=\"modules.php?name=$module_name\">"._BACKTOMAIN."</a> | <a href=\"modules.php?name=$module_name&op=Stats\">"._BACKTODETSTATS."</a> ]</center>";
  240.     closetable();
  241.     include ("footer.php");
  242. }
  243.  
  244. function MonthlyStats($year,$month){
  245.     global $sitename, $module_name;
  246.     include ("header.php");
  247.     title("$sitename "._STATS."");    
  248.     opentable();
  249.     showDailyStats($year,$month,$nowdate);
  250.     echo "<BR>";
  251.     echo "<center>[ <a href=\"modules.php?name=$module_name\">"._BACKTOMAIN."</a> | <a href=\"modules.php?name=$module_name&op=Stats\">"._BACKTODETSTATS."</a> ]</center>";
  252.     closetable();
  253.     include ("footer.php");
  254. }
  255.  
  256. function DailyStats($year,$month,$date){
  257.     global $sitename, $module_name;
  258.     include ("header.php");
  259.     title("$sitename "._STATS."");
  260.     opentable();
  261.     showHourlyStats($year,$month,$date);
  262.     echo "<BR>";
  263.     echo "<center>[ <a href=\"modules.php?name=$module_name\">"._BACKTOMAIN."</a> | <a href=\"modules.php?name=$module_name&op=Stats\">"._BACKTODETSTATS."</a> ]</center>";
  264.     closetable();
  265.     include ("footer.php");
  266. }
  267.  
  268.  
  269. function showYearStats($nowyear){
  270.     global $dbi,$prefix,$bgcolor1,$bgcolor2,$bgcolor2, $ThemeSel, $module_name;
  271.     $l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
  272.     $m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
  273.     $r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
  274.     $resulttotal = sql_query("select sum(hits) as TotalHitsYear from ".$prefix."_stats_year",$dbi);
  275.     list($TotalHitsYear) = sql_fetch_row($resulttotal,$dbi);
  276.     sql_free_result($resulttotal, $dbi);
  277.     $result = sql_query("select year,hits from ".$prefix."_stats_year order by year",$dbi);
  278.     echo "<center><b>"._YEARLYSTATS."</b></center><br>";
  279.     echo "<table align=\"center\" bgcolor=\"#000000\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
  280.     echo "<tr><td width=\"25%\" bgcolor=\"$bgcolor2\">"._YEAR."</td><td bgcolor=\"$bgcolor2\">"._SPAGESVIEWS."</td></tr>";
  281.     while (list($year,$hits) = sql_fetch_row($result,$dbi)){
  282.     echo "<tr bgcolor=\"$bgcolor1\"><td>";
  283.     if ($year != $nowyear) {
  284.         echo "<a href=\"modules.php?name=$module_name&op=YearlyStats&year=$year\">$year</a>";
  285.     } else {
  286.         echo "$year";
  287.     }
  288.     echo "</td><td>";
  289.     $WidthIMG = round(100 * $hits/$TotalHitsYear,0);
  290.     echo "<img src=\"themes/$ThemeSel/images/leftbar.gif\" Alt=\"\" width=\"$l_size[0]\" height=\"$l_size[1]\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" height=\"$m_size[1]\" width=",$WidthIMG * 2," Alt=\"\">"
  291.         ."<img src=\"themes/$ThemeSel/images/rightbar.gif\" Alt=\"\" width=\"$r_size[0]\" height=\"$r_size[1]\"> ($hits)</td></tr>";
  292.     }
  293.     sql_free_result($result,$dbi);
  294.     echo "</table>";
  295. }
  296.  
  297. function showMonthStats($nowyear,$nowmonth){
  298.     global $prefix,$bgcolor1,$bgcolor2,$dbi, $ThemeSel, $module_name;
  299.     $l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
  300.     $m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
  301.     $r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
  302.     $resultmonth = sql_query("select sum(hits) as TotalHitsMonth from ".$prefix."_stats_month where year='$nowyear'",$dbi);
  303.     list($TotalHitsMonth) = sql_fetch_row($resultmonth,$dbi);
  304.     sql_free_result($resultmonth, $dbi);
  305.     $result = sql_query("select month,hits from ".$prefix."_stats_month where year='$nowyear'",$dbi);
  306.     echo "<center><b>"._MONTLYSTATS." $nowyear</b></center><br>";
  307.     echo "<table align=\"center\" bgcolor=\"#000000\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
  308.     echo "<tr><td width=\"25%\" bgcolor=\"$bgcolor2\">"._UMONTH."</td><td bgcolor=\"$bgcolor2\">"._SPAGESVIEWS."</td></tr>";
  309.     while (list($month,$hits) = sql_fetch_row($result,$dbi)){
  310.     echo "<tr bgcolor=\"$bgcolor1\"><td>";
  311.     if ($month != $nowmonth) {
  312.         echo "<a href=\"modules.php?name=$module_name&op=MonthlyStats&year=$nowyear&month=$month\" class=\"hover_orange\">";
  313.         getmonth($month);
  314.         echo "</a>";
  315.     } else {
  316.         getmonth($month);
  317.     }
  318.     echo "</td><td>";
  319.     $WidthIMG = round(100 * $hits/$TotalHitsMonth,0);
  320.     echo "<img src=\"themes/$ThemeSel/images/leftbar.gif\" Alt=\"\" width=\"$l_size[0]\" height=\"$l_size[1]\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" height=\"$m_size[1]\" width=",$WidthIMG * 2," Alt=\"\">";
  321.     echo "<img src=\"themes/$ThemeSel/images/rightbar.gif\" Alt=\"\" width=\"$r_size[0]\" height=\"$r_size[1]\"> ($hits)</td></tr>";
  322.     echo "</td></tr>";
  323.     }
  324.     sql_free_result($result);
  325.     echo "</table>";
  326. }
  327.  
  328. function showDailyStats($year,$month,$nowdate){
  329.     global $prefix,$bgcolor1,$bgcolor2,$dbi, $ThemeSel, $module_name;
  330.     $l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
  331.     $m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
  332.     $r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
  333.     $resulttotal = sql_query("select sum(hits) as TotalHitsDate from ".$prefix."_stats_date where year='$year' and month='$month'",$dbi);
  334.     list($TotalHitsDate) = sql_fetch_row($resulttotal,$dbi);
  335.     mysql_free_result($resulttotal);
  336.     $result = sql_query("select year,month,date,hits from ".$prefix."_stats_date where year='$year' and month='$month' order by date",$dbi);
  337.     $total = sql_num_rows($result, $dbi);
  338.     echo "<center><b>"._DAILYSTATS." ";
  339.     getmonth($month);
  340.     echo ", $year</b></center><br>";
  341.     echo "<table align=\"center\" bgcolor=\"#000000\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
  342.     echo "<tr><td width=\"25%\" bgcolor=\"$bgcolor2\">"._DATE."</td><td bgcolor=\"$bgcolor2\">"._SPAGESVIEWS."</td></tr>";
  343.     while (list($year,$month,$date,$hits) = sql_fetch_row($result,$dbi)){
  344.     echo "<tr bgcolor=\"$bgcolor1\"><td>";
  345.     if ($date != $nowdate) {
  346.         echo "<a href=\"modules.php?name=$module_name&op=DailyStats&year=$year&month=$month&date=$date\" class=\"hover_orange\">";
  347.         echo $date;
  348.         echo "</a>";
  349.     } else {
  350.         echo $date;
  351.     }
  352.     echo "</td><td>";
  353.     if ($hits == 0) {
  354.         $WidthIMG = 0;
  355.         $d_percent = 0;
  356.     } else {
  357.         $WidthIMG = round(100 * $hits/$TotalHitsDate,0);
  358.         $d_percent = substr(100 * $hits / $TotalHitsDate, 0, 5);
  359.     }
  360.     echo "<img src=\"themes/$ThemeSel/images/leftbar.gif\" Alt=\"\" width=\"$l_size[0]\" height=\"$l_size[1]\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" height=\"$m_size[1]\" width=",$WidthIMG * 2," Alt=\"\">"
  361.         ."<img src=\"themes/$ThemeSel/images/rightbar.gif\" Alt=\"\" width=\"$r_size[0]\" height=\"$r_size[1]\"> $d_percent% ($hits)</td></tr>"
  362.         ."</td></tr>";
  363.     }
  364.     sql_free_result($result, $dbi);
  365.     echo "</table>";
  366. }
  367.  
  368. function showHourlyStats($year,$month,$date){
  369.     global $prefix,$bgcolor1,$bgcolor2,$dbi, $ThemeSel;
  370.     $l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
  371.     $m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
  372.     $r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
  373.     $resulttotal = sql_query("select sum(hits) as TotalHitsHour from ".$prefix."_stats_hour where year='$year' and month='$month' and date='$date'",$dbi);
  374.     list ($TotalHitsHour) = sql_fetch_row($resulttotal,$dbi);
  375.     sql_free_result($resulttotal,$dbi);
  376.     $nowdate = date("d-m-Y");
  377.     $nowdate_arr = explode("-",$nowdate);
  378.     echo "<center><b>"._HOURLYSTATS." ";
  379.     echo getmonth($month)." ".$date.", " .$year."</b></center><br>";
  380.     echo "<table align=\"center\" bgcolor=\"#000000\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
  381.     echo "<tr><td width=\"25%\" bgcolor=\"$bgcolor2\">"._HOUR."</td><td bgcolor=\"$bgcolor2\" width=\"70%\">"._SPAGESVIEWS."</td></tr>";
  382.     for ($k = 0;$k<=23;$k++) {
  383.     $result = sql_query("select hour,hits from ".$prefix."_stats_hour where year='$year' and month='$month' and date='$date' and hour='$k'",$dbi);
  384.     if (sql_num_rows($result,$dbi) == 0){
  385.         $hits=0;
  386.     } else {
  387.         list($hour,$hits) = sql_fetch_row($result,$dbi);
  388.     }
  389.     echo "<tr><td bgcolor=\"$bgcolor1\">";
  390.     if ($k < 10) {
  391.         $a = "0$k";
  392.     } else {
  393.         $a = $k;
  394.     }
  395.     echo "$a:00 - $a:59";
  396.     $a = "";
  397.     echo "</td><td bgcolor=\"$bgcolor1\">";
  398.     if ($hits == 0) {
  399.         $WidthIMG = 0;
  400.         $d_percent = 0;
  401.     } else {
  402.         $WidthIMG = round(100 * $hits/$TotalHitsHour,0);
  403.         $d_percent = substr(100 * $hits / $TotalHitsHour, 0, 5);
  404.     }
  405.     echo "<img src=\"themes/$ThemeSel/images/leftbar.gif\" Alt=\"\" width=\"$l_size[0]\" height=\"$l_size[1]\"><img src=\"themes/$ThemeSel/images/mainbar.gif\" height=\"$m_size[1]\" width=",$WidthIMG * 2," Alt=\"\">"
  406.         ."<img src=\"themes/$ThemeSel/images/rightbar.gif\" Alt=\"\" width=\"$r_size[0]\" height=\"$r_size[1]\"> $d_percent% ($hits)</td></tr>"
  407.         ."</td></tr>";
  408.     }
  409.     sql_free_result($result, $dbi);
  410.     echo "</table>";
  411. }
  412.  
  413. function getmonth($month){
  414.     if ($month == 1) echo ""._JANUARY."";
  415.     if ($month == 2) echo ""._FEBRUARY."";
  416.     if ($month == 3) echo ""._MARCH."";
  417.     if ($month == 4) echo ""._APRIL."";
  418.     if ($month == 5) echo ""._MAY."";
  419.     if ($month == 6) echo ""._JUNE."";
  420.     if ($month == 7) echo ""._JULY."";
  421.     if ($month == 8) echo ""._AUGUST."";
  422.     if ($month == 9) echo ""._SEPTEMBER."";
  423.     if ($month == 10) echo ""._OCTOBER."";
  424.     if ($month == 11) echo ""._NOVEMBER."";
  425.     if ($month == 12) echo ""._DECEMBER."";
  426. }
  427.  
  428. switch($op) {
  429.  
  430.     default:
  431.     Stats_Main();
  432.     break;
  433.     
  434.     case "Stats":
  435.     Stats($total);
  436.     break;
  437.     
  438.     case "YearlyStats":
  439.     YearlyStats($year);
  440.     break;
  441.     
  442.     case "MonthlyStats":
  443.     MonthlyStats($year,$month);
  444.     break;
  445.     
  446.     case "DailyStats":
  447.     DailyStats($year,$month,$date);
  448.     break;
  449.  
  450.     case "convert_month":
  451.     convert_month($month);
  452.     break;
  453.  
  454. }
  455.  
  456. ?>