- Login failtures now counted and displayed after login in admin/member area
[mailer.git] / inc / modules / admin / what-user_online.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/02/2004 *
4  * ================                             Last change: 07/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : action-online.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Who is where? (DO NOT add sub menus!)            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Wer ist wo? (KEINE Untermenues anhaengen!)       *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Add description as navigation point
42 ADD_DESCR("admin", basename(__FILE__));
43
44 // Count guests, members and admins
45 $result_guests  = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='N' AND is_member='N'", __FILE__, __LINE__);
46 $result_members = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='N' AND is_member='Y'", __FILE__, __LINE__);
47 $result_admins  = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='Y'", __FILE__, __LINE__);
48
49 OUTPUT_HTML("<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" width=\"170\" class=\"admin_table dashed\">
50 <TR><TD colspan=\"5\" height=\"7\" class=\"seperator admin_title\">&nbsp;</TD></TR>
51 <TR>
52   <TD colspan=\"3\" class=\"admin_title\" align=\"center\">
53     <STRONG>".USER_NOW_ONLINE."</STRONG>
54   </TD>
55 </TR>
56 <TR><TD colspan=\"5\" height=\"7\" class=\"seperator admin_title\">&nbsp;</TD></TR>
57 <TR>
58   <TD width=\"85%\" class=\"top2 bottom2\" align=\"right\"><FONT class=\"medium\">".GUESTS_ONLINE.":</FONT></TD>
59   <TD width=\"5%\" class=\"top2 bottom2\">&nbsp;</TD>
60   <TD width=\"10%\" class=\"top2 bottom2\"><B>".SQL_NUMROWS($result_guests)."</B></TD>
61 </TR>
62 <TR>
63   <TD width=\"85%\" class=\"bottom2\" align=\"right\"><FONT class=\"medium\">".MEMBERS_ONLINE.":</FONT></TD>
64   <TD width=\"5%\" class=\"bottom2\">&nbsp;</TD>
65   <TD width=\"10%\" class=\"bottom2\"><B>".SQL_NUMROWS($result_members)."</B></TD>
66 </TR>
67 <TR>
68   <TD width=\"85%\" align=\"right\"><FONT class=\"medium\">".ADMINS_ONLINE.":</FONT></TD>
69   <TD width=\"5%\">&nbsp;</TD>
70   <TD width=\"10%\"><B>".SQL_NUMROWS($result_admins)."</B></TD>
71 </TR>
72 </TABLE><br />");
73
74 $result = SQL_QUERY("SELECT id, ip, userid, refid, module, action, what, is_member, is_admin, timestamp FROM "._MYSQL_PREFIX."_online ORDER by timestamp DESC", __FILE__, __LINE__);
75 if (SQL_NUMROWS($result) > 0)
76 {
77         // Load header template
78         LOAD_TEMPLATE("admin_online_header");
79
80         // List all online users
81         $SW = 2;
82         while (list($id, $ip, $userid, $refid, $module, $action, $what, $mem, $admin, $time) = SQL_FETCHROW($result))
83         {
84                 if ($action == "") $action = "---";
85                 if ($what   == "")   $what = "---";
86
87                 if ($admin == "Y")
88                 {
89                         // Is an administrator
90                         $userid = _IS_ADMIN;
91                 }
92                 elseif (($mem == "N") && ($admin == "N"))
93                 {
94                         // Is a guest
95                         $userid = _IS_GUEST;
96                 }
97                 OUTPUT_HTML("<TR>
98   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$id."</TD>
99   <TD align=\"center\" width=\"15%\" class=\"switch_sw".$SW." bottom right\">");
100                 if ($userid > 0)
101                 {
102                         OUTPUT_HTML("<A href=\"".URL."/modules.php?module=admin&amp;what=list_user&amp;u_id=".$userid."\">".$userid."</A>");
103                 }
104                 else
105                 {
106                         OUTPUT_HTML($userid);
107                 }
108                 if ($refid > 0)
109                 {
110                         $refid = "<A href=\"".URL."/modules.php?module=admin&amp;what=list_user&amp;u_id=".$refid."\">".$refid."</A>";
111                 }
112                 OUTPUT_HTML("</TD>
113   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$ip."</TD>
114   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$refid."</TD>
115   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$module."</TD>
116   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$action."</TD>
117   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$what."</TD>
118   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom\">".MAKE_DATETIME($time, "2")."</TD>
119 </TR>");
120                 $SW = 3 - $SW;
121         }
122         OUTPUT_HTML("<TR>
123   <TD colspan=\"8\" align=\"center\" class=\"admin_footer\">
124     ".ONLINE_TIMEOUT_IS_1.CREATE_FANCY_TIME($_CONFIG['online_timeout']).ONLINE_TIMEOUT_IS_2."
125   </TD>
126 </TR>
127 </TABLE>");
128 }
129 //
130 ?>