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