<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied live members MAXIMUS directly...');

include_once ('mainfile.php');
include_once ('kernel/nukesentinel.php');
include_once ('kernel/langues.php');
include_once ('includes/counter.php');
if (is_file("".$cache."/Configuration/".$cache_prefix."_cache_main.php")) {
include_once("".$cache."/Configuration/".$cache_prefix."_cache_main.php");}
$block_name = "Livemembers";
get_blang("$block_name");

$sql = "SELECT `uname`, `Wname` FROM `".TABLE_SESSION."` WHERE `guest`='0'";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(MODULE_ERROR, 'Could not obtain _session', '', __LINE__, __FILE__, $sql);}

$sql1 = "SELECT `uname`, `Wname` FROM `".TABLE_SESSION."` WHERE `guest`='1'";
if ( !($result1 = $GLOBALS['db']->sql_query($sql1)) )
{ query_die(MODULE_ERROR, 'Could not obtain _session', '', __LINE__, __FILE__, $sql1);}

        echo "<html>\n";
        echo "<head><title>"._LM_PUBLIC."</title></head>\n";
        echo "<body background='images/bg.png' link='#000000' alink='#000000' vlink='#000000'>\n";

echo "<table width='85%' valign='top'><tr><td width='40%' align='left' valign='top'>";
echo ""._LM_MEMBERS.":<br />";
while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
$uname = stripslashes($row['uname']);
$Wname = stripslashes($row['Wname']);
if ( $Wname == $GLOBALS['main_module'] ) { $Wname = "<em>"._LM_HOME."</em>"; }
echo "<big>.</big>&nbsp;$uname -> $Wname<br />";

}

echo "</td><td width='40%' align='left' valign='top'>";

echo ""._LM_VISITORS.":<br />";
while ($row1 = $GLOBALS['db']->sql_fetchrow($result1)) {
$unameip = stripslashes($row1['uname']);
$Wname   = stripslashes($row1['Wname']);
if ( $Wname == $GLOBALS['main_module'] ) { $Wname = "<em>"._LM_HOME."</em>"; }
echo "<big>.</big>&nbsp;"._LM_ANONYMOUS."-> $Wname<br />";

}
echo "</td></tr></table></tr></table>";

// stats
$Today = getdate();
//Formatting Current Date
$month = $Today['month'];
$mday  = $Today['mday'];
$year  = $Today['year'];
//Formatting Previous Date
$pmonth = $Today['month'];
$pmday  = $Today['mday'];
$pmday  = $mday-1;
$pyear  = $Today['year'];
//Month conversion into numeric mode
if ($pmonth=="January") { $pmonth=1; } else
if ($pmonth=="February") { $pmonth=2; } else
if ($pmonth=="March") { $pmonth=3; } else
if ($pmonth=="April") { $pmonth=4; } else
if ($pmonth=="May") { $pmonth=5; } else
if ($pmonth=="June") { $pmonth=6; } else
if ($pmonth=="July") { $pmonth=7; } else
if ($pmonth=="August") { $pmonth=8; } else
if ($pmonth=="September") { $pmonth=9; } else
if ($pmonth=="October") { $pmonth=10; } else
if ($pmonth=="November") { $pmonth=11; } else
if ($pmonth=="December") { $pmonth=12; };
$test = mktime (0,0,0,$pmonth,$pmday,$pyear,1);

//Creating SQL parameter
$curDate2 = "%".$month[0].$month[1].$month[2]."%".$mday."%".$year."%";
$preday   = strftime ("%d",$test);
$premonth = strftime ("%B",$test);
$preyear  = strftime ("%Y",$test);
$curDateP = "%".$premonth[0].$premonth[1].$premonth[2]."%".$preday."%".$preyear."%";
//////////////////////////
$resultat1 = $GLOBALS['db']->sql_query("SELECT `user_id` FROM `".TABLE_USERS."`");
$numrows   = $GLOBALS['db']->sql_numrows($resultat1);

//Executing SQL Today
$resultat2 = $GLOBALS['db']->sql_query("SELECT COUNT(user_id) AS userCount FROM `".TABLE_USERS."` WHERE `user_regdate` LIKE '$curDate2'");
$row = $GLOBALS['db']->sql_fetchrow($resultat2);
$userCount = $GLOBALS['db']->XMFnum($row['userCount']);
//Executing SQL Today
$resultat3  = $GLOBALS['db']->sql_query("SELECT COUNT(user_id) AS userCount FROM `".TABLE_USERS."` WHERE `user_regdate` LIKE '$curDateP'");
$raaw3      = $GLOBALS['db']->sql_fetchrow($resultat3);
$userCount2 = $GLOBALS['db']->XMFnum($raaw3['userCount']);
// en attente
$resultat4 = $GLOBALS['db']->sql_query("SELECT `user_id` FROM `".TABLE_USERS_TEMP."`");
$numrows1  = $GLOBALS['db']->sql_numrows($resultat4);
// suspendu
$resultat5 = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_level`='0' AND `user_id`>'1'");
$sus       = $GLOBALS['db']->sql_numrows($resultat5);
// supprimé
$resultat6 = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `user_level`='-1' AND `user_id`>'1'");
$del       = $GLOBALS['db']->sql_numrows($resultat6);

echo "<table width='75%' align='center'><tr><td width='75%' align='left'>";

echo "<br />"._LM_STATS."<br />";
// nouveau compte
if ($userCount == 0) {
echo ""._LM_ACCOUNTS_NOTODAY."<br />";
} elseif ($userCount == 1) {
echo ""._LM_ACCOUNTS_ONETODAY."<br />";
} else {
echo "$userCount "._LM_ACCOUNTS_NEWTODAY."<br />";
}
// nouveau compte hier
if ($userCount2 == 0) {
echo ""._LM_ACCOUNTS_NOYESTERDAY."<br />";
} elseif ($userCount2 == 1) {
echo ""._LM_ACCOUNTS_ONEYESTERDAY."<br />";
} else {
echo "$userCount2 "._LM_ACCOUNTS_NEWYESTERDAY."<br />";
}

echo "$numrows "._LM_ACCOUNTS_ACTIVE."<br />";

if ( $numrows1 == 0 ) {
echo ""._LM_ACCOUNT_NOWAITING."<br />";
} elseif ( $numrows1 == 1 ) {
echo ""._LM_ACCOUNT_WAITING."<br />";
} else {
echo "$numrows1 "._LM_ACCOUNTS_WAITING."<br />";
}

if ( $sus == 0 ) {
echo ""._LM_ACCOUNT_NOSUSPEND."<br />";
} elseif ( $sus == 1 ) {
echo ""._LM_ACCOUNT_SUSPEND."<br />";
} else {
echo "$sus "._LM_ACCOUNTS_SUSPEND."<br />";
}

if ( $del == 0 ) {
echo ""._LM_ACCOUNT_NODEL."<br />";
} elseif ( $del == 1 ) {
echo ""._LM_ACCOUNT_DEL."<br />";
} else {
echo "$del "._LM_ACCOUNTS_DEL."<br />";
}

$GLOBALS['db']->sql_freeresult($result);
$GLOBALS['db']->sql_freeresult($result1);
$GLOBALS['db']->sql_freeresult($resultat1);
$GLOBALS['db']->sql_freeresult($resultat2);
$GLOBALS['db']->sql_freeresult($resultat3);
$GLOBALS['db']->sql_freeresult($resultat4);
$GLOBALS['db']->sql_freeresult($resultat5);
$GLOBALS['db']->sql_freeresult($resultat6);
echo "</td></tr></table><br />";
echo "<form action='?livemembers' method='post'>";
echo "<center><input type='submit' value='"._LM_REFRESH."' /></form><br />
<a href='javascript: self.close ()'>"._LM_CLOSE."</a></center>";
echo "</body>\n";
echo "</html>";