<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: stats.php,v 1.7.2.5 2004/08/01 17:04:19 kirilt Exp $




/************************************************************************/
/* 4nStats Addon Version 1.0                                            */
/* for phpNUKE (http://phpnuke.org) Version 5.x                         */
/* ==================================================================== */
/* Based on phpNUKE Stats Version 0.5.1 by PSIplus <psiplus@gmx.net>    */
/* ==================================================================== */
/* Modified by Warp_Speed (warp_speed@gmx.net) in o8/2oo1               */
/* http://www.warp-speed.de @ 4thDimension.de Networking                */
/* ==================================================================== */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 or a newer version.   */
/************************************************************************/
global $bgcolor1;

function getprivs()
{
    if ( _MPN_ADMIN )
    {
        $right = 2;
    }
    else
    {
        if ( _MPN_USER )
        {
            $right = 1;
        }
        else
        {
            $right = 0;
        }
    }

    return $right;
}

function mk_percbar($pperc, $width=100, $height=10, $color="#000000", $bordercolor="#000000", $bgcolor="#ffffff", $xecho=true )
{
  $pperc=round($pperc,0);
  $ipperc=100-$pperc;

  if($pperc==100)
  {
    $what="<table width=$width height=$height border=1 cellspacing=0 cellpadding=0 style=\"border-width:1px;border-style:solid;border-color:$bordercolor\"><tr><td width=\"100%\" style=\"background-color:$color;border-style:solid;border-width:1px;border-color:$bgcolor\"></td></tr></table>";
  }
  elseif($pperc==0)
  {
    $what="<table width=$width height=$height border=1 cellspacing=0 cellpadding=0 style=\"border-width:1px;border-style:solid;border-color:$bordercolor\"><tr><td width=\"100%\" style=\"background-color:$bgcolor;border-style:solid;border-width:1px;border-color:$bgcolor\"></td></tr></table>";
  }
  else
  {
    $what="<table width=$width height=$height border=1 cellspacing=0 cellpadding=0 style=\"border-width:1px;border-style:solid;border-color:$bordercolor\"><tr><td width=\"$pperc%\" style=\"background-color:$color;border-style:solid;border-width:1px;border-color:$bgcolor\"></td><td width=\"$ipperc%\" style=\"background-color:$bgcolor;border-style:solid;border-width:1px;border-color:$bgcolor\"></td></tr></table>";
  }
  if($xecho==true) echo $what; else return $what;
}

//if (!isset($mainfile)) { include("mainfile.php"); }

include("header.php");

/* 4nStats Hour / Day Stats */

$waxix=array( translate('Sunday'), translate('Monday'), translate('Tuesday'), translate('Wednesday'), translate('Thursday'), translate('Friday'), translate('Saturday') );

$toddate=date('dmY');
/*
if(date('d')==1)
{
  if(date('d')==31)
  {
    $xyd=30;
  }
  if(date('d')==30||date('m')==08||date('m')==1)
  {
    $xyd=31;
  }
  if(date('m')==03)
  {
    if(date('L')==true)
    {  $xyd=29;}
    else
    {  $xyd=28;}
  }
 $mtd=date('m')-1;
}
else
{
  $xyd=date('d')-1;
  $mtd=date('m');
}
if(date('m')==1&&date('d')==1)
{
  $yed=date('Y')-1;
  $mtd='12';
}
else
{
  $yed=date('Y');
}
if(strlen($xyd)==1){$xyd='0'.$xyd;}
if(strlen($mtd)==1){$mtd='0'.$mtd;}
$yesdate=$xyd.$mtd.$yed;
*/
// 20040501 - AvW: replaced non functional code for determinating yesterdays date with this new line.
$yesdate = date('dmY',mktime(0, 0, 0, date("m"), date("d")-1,  date("Y")));

$toddb=mysql_query("SELECT * FROM ".$mpnTables['4nstats_datecnt']." WHERE date='$toddate'");

if($toddb)
{
  $valtodayX=mysql_fetch_array($toddb);
  $valtoday=$valtodayX['hits'];
}
else
{
    $valtoday=0;
}

$yesdb=mysql_query("SELECT * FROM ".$mpnTables['4nstats_datecnt']." WHERE date='$yesdate'");

if( $yesdb )
{
  $valyesdayX = mysql_fetch_array($yesdb);
  $valyesday = $valyesdayX['hits'];
}
else $valyesday=0;

$sumlex=0;
$hourbadhits = 1000000000000;

if ( ! isset( $hourbesthits ) )
{
    $hourbesthits = 0;
}

for($saxx=0;$saxx<=23;$saxx++)
{
    $htmpdb = mysql_query( "SELECT hits FROM " . $mpnTables['4nstats_hourcnt'] . " WHERE hour = '$saxx'" );

    $lexhr[ $saxx ] = mysql_result( $htmpdb, 0 );

    if ( $hourbesthits < $lexhr[ $saxx ] )
    {
        $hourbesthits = $lexhr[ $saxx ];
        $hourbest = $saxx;
    }

    if ( $hourbadhits > $lexhr[ $saxx ] )
    {
        $hourbadhits = $lexhr[ $saxx ];
        $hourbad = $saxx;
    }

    $sumlex = $sumlex + $lexhr[ $saxx ];
}


$sumlux = 0;
$weekdaybadhits = 1000000000000;

if ( ! isset( $weekdaybesthits ) )
{
    $weekdaybesthits = 0;
}

for( $sbxx=0; $sbxx<=6; $sbxx++ )
{
    $htmpdbx = mysql_query( "SELECT hits FROM ".$mpnTables['4nstats_weekcnt']." WHERE weekday='$sbxx'" );

    $luxhr[ $sbxx ] = mysql_result($htmpdbx, 0);

    if ( $weekdaybesthits < $luxhr[ $sbxx ] )
    {
        $weekdaybesthits = $luxhr[ $sbxx ];
        $weekdaybest = $sbxx;
    }

    if ( $weekdaybadhits > $luxhr[ $sbxx ] )
    {
        $weekdaybadhits = $luxhr[ $sbxx ];
        $weekdaybad = $sbxx;
    }

    $sumlux = $sumlux + $luxhr[ $sbxx ];
}

$summon=0;
for( $salmon = 1; $salmon <= 12; $salmon++ )
{
  $htmpdbs=mysql_query("SELECT hits FROM ".$mpnTables['4nstats_monthcnt']." WHERE month='$salmon'");
  $lexmon[$salmon]=mysql_result($htmpdbs, 0);
  $summon=$summon+$lexmon[$salmon];
}

$result = mysql_query("select type, var, count from ".$mpnTables['counter']." order by type desc");

if ( !$result )
{
    echo mysql_errno(). ": ".mysql_error(). "<br>";
    exit();
}

while(list($type, $var, $count) = mysql_fetch_row($result))
{
        if(($type == "total") && ($var == "hits")) {
                $total = $count;
        } elseif($type == "browser") {
                if($var == "Netscape") {
                        $netscape[] = $count;
                        $netscape[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "MSIE") {
                        $msie[] = $count;
                        $msie[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Konqueror") {
                        $konqueror[] = $count;
                        $konqueror[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Opera") {
                        $opera[] = $count;
                        $opera[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Lynx") {
                        $lynx[] = $count;
                        $lynx[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Bot") {
                        $bot[] = $count;
                        $bot[] =  substr(100 * $count / $total, 0, 5);
                } elseif(($type == "browser") && ($var == "Other")) {
                        $b_other[] = $count;
                        $b_other[] =  substr(100 * $count / $total, 0, 5);
                }
        } elseif($type == "os") {
                if($var == "Windows") {
                        $windows[] = $count;
                        $windows[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Mac") {
                        $mac[] = $count;
                        $mac[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "Linux") {
                        $linux[] = $count;
                        $linux[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "FreeBSD") {
                        $freebsd[] = $count;
                        $freebsd[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "SunOS") {
                        $sunos[] = $count;
                        $sunos[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "IRIX") {
                        $irix[] = $count;
                        $irix[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "BeOS") {
                        $beos[] = $count;
                        $beos[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "OS/2") {
                        $os2[] = $count;
                        $os2[] =  substr(100 * $count / $total, 0, 5);
                } elseif($var == "AIX") {
                        $aix[] = $count;
                        $aix[] =  substr(100 * $count / $total, 0, 5);
                } elseif(($type == "os") && ($var == "Other")) {
                        $os_other[] = $count;
                        $os_other[] =  substr(100 * $count / $total, 0, 5);
                }
        }
}

$clock_array = array("12 am", "1 am", "2 am", "3 am", "4 am", "5 am", "6 am", "7 am", "8 am", "9 am", "10 am", "11 am", "12 pm", "1 pm", "2 pm", "3 pm", "4 pm", "5 pm", "6 pm", "7 pm", "8 pm", "9 pm", "10 pm", "11 pm");

echo "<h1>$sitename " . translate ( 'Stats' ) . "</h1>\n";
echo "<br />\n";

OpenTable();

echo '<p class="tabletitles">' . translate ( 'Summary' ) . "</p>\n";

echo "<div class='indent15'>\n";

    echo translate( 'Total Page Hits Since' ) . ' ' . $startdate . ': <span class="label">' . $total . '</span>' . "\n";
    echo "<br /><br />\n";

    if ( ! isset( $valtoday ) || $valtoday == '' ) { $valtoday = 0; }

    echo translate( 'Page Hits Today' ) . ': <span class="label">' . $valtoday . '</span>' . "\n";
    echo "<br /><br />\n";

    if ( ! isset( $valyesday ) || $valyesday == '' ) { $valyesday = 0; }

    echo translate( 'Page Hits Yesterday' ) . ': <span class="label">' . $valyesday . '</span>' . "\n";

    echo "<br /><br /><br />\n";

    echo '<p class="subtitle1">' . translate( 'Highest Overall Day And Hour Totals' ) . '</p>' . "\n";

    echo "<br /><br />\n";

    echo "<div class='indent15'>\n";

        echo '<span class="label">' . $waxix[ $weekdaybest ] . '</span> ' . translate( 'Gets The Most Traffic With' ) . ' <span class="label">' . $weekdaybesthits . '</span> ' . translate( 'Total Hits' ) . "\n";
        echo "<br /><br />\n";

        echo translate( 'Heaviest Traffic Is Observed At' ) . ' <span class="label">' . $clock_array[ $hourbest ] . '</span> ' . translate( 'With' ) . ' <span class="label">' . $hourbesthits . '</span> ' . translate( 'Total Hits' ) . "\n";

    echo "</div>\n";

    echo "<br /><br />\n";

    echo '<p class="subtitle1">' . translate( 'Lowest Overall Day And Hour Totals' ) . '</p>' . "\n";

    echo "<br /><br />\n";

    echo "<div class='indent15'>\n";

        echo '<span class="label">' . $waxix[ $weekdaybad ] . '</span> ' . translate( 'Gets The Most Traffic With' ) . ' <span class="label">' . $weekdaybadhits . '</span> ' . translate( 'Total Hits' ) . "\n";

        echo "<br /><br />\n";

        echo translate( 'Lightest Traffic Is Observed At' ) . ' <span class="label">' . $clock_array[ $hourbad ] . '</span> ' . translate( 'With' ) . ' <span class="label">' . $hourbadhits . '</span> ' . translate( 'Total Hits' ) . "\n";

    echo "</div>\n";

echo "</div>\n";

CloseTable();

/*echo "<center><font class=\"option\"><br>".translate("There were")." <b>$total</b> ".translate("page views since")." $startdate, \n";
echo "".translate("of which there were")." <b></b> ".translate("page views today")."";
if (isset($valyesday)) echo " ".translate("and")." <b>$valyesday</b> ".translate("page views yesterday")."";
echo ".<br><b>".$waxix[$weekdaybest]."</b> ".translate("is this weeks highest hit day with")." <b>".."</b> ".translate("hits altogether, and ")."";
echo " <b>".$waxix[$weekdaybad]."</b> ".translate("with")." <b>".."</b> ".translate("hits is the lowest hit day.")."";

echo "<br>".translate("At")." <b>$clock_array[$hourbest]</b> ".translate("with")." <b>$hourbesthits</b> ".translate("hits has the most visitors online, at")." <b>$clock_array[$hourbad]</b> ".translate("with (only)")." <b>$hourbadhits</b> ".translate("hits the fewest.")."</font></center>";*/



echo "<br><br>";

$bigxy=0;
if($bigxy<$konqueror[1])$bigxy=$konqueror[1];
if($bigxy<$msie[1])$bigxy=$msie[1];
if($bigxy<$opera[1])$bigxy=$opera[1];
if($bigxy<$netscape[1])$bigxy=$netscape[1];
//if($bigxy<$webtv[1])$bigxy=$webtv[1];
if($bigxy<$lynx[1])$bigxy=$lynx[1];
if($bigxy<$bot[1])$bigxy=$bot[1];
if($bigxy<$b_other[1])$bigxy=$b_other[1];

OpenTable();
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"3\">\n";
echo "<center><font color=\"$textcolor2\"><b>".translate("Browser")."</b></font></center><br></td></tr>\n";
if($konqueror[0]>0) echo "<tr><td><img src=images/stats/konqueror.gif border=0>&nbsp;Konqueror: </td><td>".mk_percbar(round((100*$konqueror[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $konqueror[1] % ($konqueror[0])</td></tr>\n";
if($msie[0]>0) echo "<tr><td><img src=images/stats/explorer.gif border=0>&nbsp;MSIE: </td><td>".mk_percbar(round((100*$msie[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $msie[1] % ($msie[0])</td></tr>\n";
if($opera[0]>0) echo "<tr><td><img src=images/stats/opera.gif border=0>&nbsp;Opera: </td><td>".mk_percbar(round((100*$opera[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $opera[1] % ($opera[0])</td></tr>\n";
if($netscape[0]>0) echo "<tr><td><img src=images/stats/netscape.gif border=0>&nbsp;Netscape: </td><td>".mk_percbar(round((100*$netscape[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $netscape[1] % ($netscape[0])</td></tr>\n";
//if($webtv[0]>0) echo "<tr><td><img src=images/stats/webtv.gif border=0>&nbsp;WebTV: </td><td>".mk_percbar(round((100*$webtv[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $webtv[1] % ($webtv[0])</td></tr>\n";
if($lynx[0]>0) echo "<tr><td><img src=images/stats/lynx.gif border=0>&nbsp;Lynx: </td><td>".mk_percbar(round((100*$lynx[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $lynx[1] % ($lynx[0])</td></tr>\n";
if($bot[0]>0) echo "<tr><td><img src=images/stats/altavista.gif border=0>&nbsp;".translate("Search Engines").": </td><td>".mk_percbar(round((100*$bot[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $bot[1] % ($bot[0])</td></tr>\n";
if($b_other[0]>0) echo "<tr><td><img src=images/stats/question.gif border=0>&nbsp;".translate("Unknown").": </td><td>".mk_percbar(round((100*$b_other[1])/$bigxy,0),200,10,"#000000","#000000","$bgcolor1",false)."</td><td> $b_other[1] % ($b_other[0])</td></tr>\n";
echo "</table>";
CloseTable();
echo "<br><br>\n";

$bigxy=0;
if($bigxy<$linux[1])$bigxy=$linux[1];
if($bigxy<$windows[1])$bigxy=$windows[1];
if($bigxy<$mac[1])$bigxy=$mac[1];
if($bigxy<$freebsd[1])$bigxy=$freebsd[1];
if($bigxy<$sunos[1])$bigxy=$sunos[1];
if($bigxy<$irix[1])$bigxy=$irix[1];
if($bigxy<$beos[1])$bigxy=$beos[1];
if($bigxy<$os2[1])$bigxy=$os2[1];
if($bigxy<$aix[1])$bigxy=$aix[1];
if($bigxy<$os_other[1])$bigxy=$os_other[1];

OpenTable();
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"3\">\n";
echo "<center><font color=\"$textcolor2\"><b>".translate("Operating Systems")."</b></font></center><br></td></tr>\n";
if($linux[0]>0) echo "<tr><td><img src=images/stats/linux.gif border=0>&nbsp;Linux:</td><td>".mk_percbar(round((100*$linux[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $linux[1] % ($linux[0])</td></tr>\n";
if($windows[0]>0) echo "<tr><td><img src=images/stats/windows.gif border=0>&nbsp;Windows:</td><td>".mk_percbar(round((100*$windows[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $windows[1] % ($windows[0])</td></tr>\n";
if($mac[0]>0) echo "<tr><td><img src=images/stats/mac.gif border=0>&nbsp;Mac/PPC:</td><td>".mk_percbar(round((100*$mac[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $mac[1] % ($mac[0])</td></tr>\n";
if($freebsd[0]>0) echo "<tr><td><img src=images/stats/bsd.gif border=0>&nbsp;FreeBSD:</td><td>".mk_percbar(round((100*$freebsd[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $freebsd[1] % ($freebsd[0])</td></tr>\n";
if($sunos[0]>0) echo "<tr><td><img src=images/stats/sun.gif border=0>&nbsp;SunOS:</td><td>".mk_percbar(round((100*$sunos[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $sunos[1] % ($sunos[0])</td></tr>\n";
if($irix[0]>0) echo "<tr><td><img src=images/stats/irix.gif border=0>&nbsp;IRIX:</td><td>".mk_percbar(round((100*$irix[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $irix[1] % ($irix[0])</td></tr>\n";
if($beos[0]>0) echo "<tr><td><img src=images/stats/be.gif border=0>&nbsp;BeOS:</td><td>".mk_percbar(round((100*$beos[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $beos[1] % ($beos[0])</td></tr>\n";
if($os2[0]>0) echo "<tr><td><img src=images/stats/os2.gif border=0>&nbsp;OS/2:</td><td>".mk_percbar(round((100*$os2[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $os2[1] % ($os2[0])</td></tr>\n";
if($aix[0]>0) echo "<tr><td><img src=images/stats/aix.gif border=0>&nbsp;AIX:</td><td>".mk_percbar(round((100*$aix[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $aix[1] % ($aix[0])</td></tr>\n";
if($os_other[0]>1) echo "<tr><td><img src=images/stats/question.gif border=0>&nbsp;".translate("Unknown").":</td><td>".mk_percbar(round((100*$os_other[1])/$bigxy,0),200,10,"#0A5F89","#0A5F89","$bgcolor1",false)."</td><td> $os_other[1] % ($os_other[0])</td></tr>\n";
echo "</table>\n";
CloseTable();
if(_MPN_ADMIN) {
echo "<br><br>\n";
OpenTable();
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"3\">\n";
echo "<center><font color=\"$textcolor2\"><b>".translate("Stat by hours")."</b></font><br></td></tr>\n";
 $telixbiggest=0;
for($telix=0;$telix<=23;$telix++)if($telixbiggest<$lexhr[$telix])$telixbiggest=$lexhr[$telix];


echo "<table cellspacing=0 cellpadding=3 border=0 align=\"center\">";
for($telix=5;$telix<=23;$telix++)
{
  echo "<tr><td align=right>$telix ".translate("Hours").":</td><td>".mk_percbar(round((100*$lexhr[$telix])/$telixbiggest,0),200,10,"#0000ff","#0000ff","$bgcolor1",false)."</td><td>".round((100*$lexhr[$telix])/$sumlex,2)."% ($lexhr[$telix])</td></tr>\n";
}
for($telix=0;$telix<=4;$telix++)
{
  echo "<tr><td align=right>$telix ".translate("Hours").": </td><td>".mk_percbar(round((100*$lexhr[$telix])/$telixbiggest,0),200,10,"#0000ff","#0000ff","$bgcolor1",false)."</td><td>".round((100*$lexhr[$telix])/$sumlex,2)."% ($lexhr[$telix])</td></tr>\n";
}
echo "</table>\n";
CloseTable();
echo "<br><br>\n";
$telixbiggest=0;
for($telix=0;$telix<=6;$telix++)if($telixbiggest<$luxhr[$telix])$telixbiggest=$luxhr[$telix];
OpenTable();
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"3\">\n";
echo "<center><font color=\"$textcolor2\"><b>".translate("Stat by week")."</b></font></center><br></td></tr>\n";
for($telix2=1;$telix2<=6;$telix2++)
{
  echo "<tr><td>$waxix[$telix2]:</td><td>".mk_percbar(round((100*$luxhr[$telix2])/$telixbiggest,0),200,10,"#008000","#008000","$bgcolor1",false)."</td><td>".round((100*$luxhr[$telix2])/$sumlux,2),"% ($luxhr[$telix2])</td></tr>\n";
}
$telix2=0;
echo "<tr><td>$waxix[$telix2]:</td><td>".mk_percbar(round((100*$luxhr[$telix2])/$telixbiggest,0),200,10,"#008000","#008000","$bgcolor1",false)."</td><td>".round((100*$luxhr[$telix2])/$sumlux,2),"% ($luxhr[$telix2])</td></tr>\n";
echo "</table>\n";
CloseTable();
echo "<br><br>\n";
$telixbiggest=0;
for($telix=1;$telix<=12;$telix++)if($telixbiggest<$lexmon[$telix])$telixbiggest=$lexmon[$telix];
$waxixy=array("","".translate("January")."","".translate("February")."","".translate("March")."","".translate("April")."","".translate("May")."","".translate("June")."","".translate("July")."","".translate("August")."","".translate("September")."","".translate("October")."","".translate("November")."","".translate("December")."");
OpenTable();
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" align=\"center\"><tr><td colspan=\"3\">\n";
echo "<center><font color=\"$textcolor2\"><b>".translate("Stat by month")."</b></font></center><br></td></tr>\n";
for($telix4=1;$telix4<=12;$telix4++)
{
  echo "<tr><td>$waxixy[$telix4]:</td><td>".mk_percbar(round((100*$lexmon[$telix4])/$telixbiggest,0),200,10,"#FF7D00","#FF7D00","$bgcolor1",false)."</td><td>".round((100*$lexmon[$telix4])/$summon,2),"% ($lexmon[$telix4])</td></tr>\n";
}
echo "</table>\n";
CloseTable();

echo "<br>";

$req=mysql_query("select * from ".$mpnTables['visits_counter']."");
$rows=MYSQL_NUM_ROWS($req);
$c=0;
OpenTable();
echo "<center><font color=\"$textcolor2\"><b>".translate("Stats this month")."</b></font></center><br>";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\" align=\"center\" width=\"300\">";
echo "<tr>";
echo "<td align=\"center\">".translate("Date")."</td>";
echo "<td align=\"center\">".translate("Unique visitors")."</td>";
echo "</tr>";
while($c!=$rows)
{
$date=mysql_result($req,$c,"date");
$count=mysql_result($req,$c,"count");
echo "<tr>";
echo "<td align=\"center\">$date</td>";
echo "<td align=\"center\">$count</td>";
echo "</tr>";
$c++;
}
echo "</table>";
CloseTable();
}
echo "<br><br>\n";

$result = mysql_query("select count(uid) from ".$mpnTables['users']." WHERE uid > 1");
$unum = mysql_result($result, 0);
$result = mysql_query("select count(aid) from ".$mpnTables['authors']);
$anum = mysql_result($result, 0);
$result = mysql_query("select count(sid) from ".$mpnTables['stories']);
$snum = mysql_result($result, 0);
$result = mysql_query("select count(tid) from ".$mpnTables['comments']);
$cnum = mysql_result($result, 0);
$result = mysql_query("select count(lid) from ".$mpnTables['downloads_downloads']."");
$dnum = mysql_result($result, 0);
$result = mysql_query("select count(secid) from ".$mpnTables['sections']);
$secnum = mysql_result($result, 0);
$result = mysql_query("select count(artid) from ".$mpnTables['seccont']);
$secanum = mysql_result($result, 0);
$result = mysql_query("select count(qid) from ".$mpnTables['queue']);
$subnum = mysql_result($result, 0);
$result = mysql_query("select count(topicid) from ".$mpnTables['topics']);
$tnum = mysql_result($result, 0);
$result = mysql_query("select count(lid) from ".$mpnTables['links_links']);
$links = mysql_result($result, 0);
$result = mysql_query("select count(cid) from ".$mpnTables['links_categories']);
$cat1 = mysql_result($result, 0);
$result = mysql_query("select count(sid) from ".$mpnTables['links_subcategories']);
$cat2 = mysql_result($result, 0);

$cat = $cat1+$cat2;

OpenTable();
echo "<TABLE CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=$bgcolor2 align=\"center\"><TR><TD>";
echo "<TABLE CELLSPACING=0 CELLPADDING=3 BORDER=0 BGCOLOR=$bgcolor3><tr><td colspan=2 bgcolor=$bgcolor1>";
echo "<font color=$textcolor2><center><b>".translate("Miscelaneous Stats")."</b></center></font>";
echo "<tr><td><img src=images/stats/users.gif border=0>&nbsp;".translate("Registered Users: ")."</td><td><b>$unum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/authors.gif border=0>&nbsp;".translate("Active Authors: ")."</td><td><b>$anum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/news.gif border=0>&nbsp;".translate("Stories Published: ")."</td><td><b>$snum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/topics.gif border=0>&nbsp;".translate("Active Topics: ")."</td><td><b>$tnum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/comments.gif border=0>&nbsp;".translate("Comments Posted: ")."</td><td><b>$cnum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/topics.gif border=0 width=15 height=15>&nbsp;".translate("Downloads Posted: ")."</td><td><b>$dnum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/sections.gif border=0>&nbsp;".translate("Special Sections: ")."</td><td><b>$secnum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/articles.gif border=0>&nbsp;".translate("Articles in Sections: ")."</td><td><b>$secanum</b></td></tr>\n";
echo "<tr><td><img src=images/stats/topics.gif border=0>&nbsp;".translate("Links in Web Links: ")."</td><td><b>$links</b></td></tr>\n";
echo "<tr><td><img src=images/stats/sections.gif border=0>&nbsp;".translate("Categories in Web Links: ")."</td><td><b>$cat</b></td></tr>\n";
echo "<tr><td><img src=images/stats/waiting.gif border=0>&nbsp;".translate("News Waiting to be Published: ")."</td><td><b>$subnum</b></td></tr>\n";

if (isset($mpn_version)) {
    echo "<tr><td><img src=images/stats/sections.gif border=0>&nbsp;".translate("myPHPNuke version: ")."</td><td><b>$mpn_version</b></td></tr>\n";
}
echo "<tr><td><img src=\"images/stats/sections.gif\" border=\"0\" alt=\"\">&nbsp;<a href=\"http://www.warp-speed.de\" target=\"_blank\">4nStats</a> ".translate("version").":</td><td><b>1.0</b>\n";
echo "</TD></TR></TABLE>";
echo "</td></tr></table>\n";
CloseTable();
echo "<br>";
include("footer.php");

?>
