template
[mailer.git] / 0.2.1 / inc / modules / admin / what-usr_online.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 01/14/2005 *
4  * ================                             Last change: 01/14/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-usr_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'])) || (!IS_ADMIN()))
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 if (EXT_IS_ACTIVE("online", true))
45 {
46         // Count guests, members and admins
47         $result_guests  = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='N' AND is_member='N'", __FILE__, __LINE__);
48         $result_members = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='N' AND is_member='Y'", __FILE__, __LINE__);
49         $result_admins  = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_online WHERE is_admin='Y'", __FILE__, __LINE__);
50
51         // Remember values for the template
52         define('_GUESTS_ONLINE' , SQL_NUMROWS($result_guests));
53         define('_ADMINS_ONLINE' , SQL_NUMROWS($result_admins));
54         define('_MEMBERS_ONLINE', SQL_NUMROWS($result_members));
55
56         // Free memory
57         SQL_FREERESULT($result_guests);
58         SQL_FREERESULT($result_admins);
59         SQL_FREERESULT($result_members);
60
61         // Load template
62         LOAD_TEMPLATE("admin_mini_online");
63
64         // Check for online users
65         $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__);
66         if (SQL_NUMROWS($result) > 0)
67         {
68                 // Load header template
69                 LOAD_TEMPLATE("admin_online_header");
70
71                 // List all online users
72                 $SW = 2;
73                 while (list($id, $ip, $uid, $ref, $mod, $act, $wht, $mem, $admin, $time) = SQL_FETCHROW($result))
74                 {
75                         if (empty($act)) $act = "---";
76                         if (empty($wht))   $wht = "---";
77
78                         if ($admin == "Y")
79                         {
80                                 // Is an administrator
81                                 $uid = _IS_ADMIN;
82                         }
83                          elseif (($mem == "N") && ($admin == "N"))
84                         {
85                                 // Is a guest
86                                 $uid = _IS_GUEST;
87                         }
88                         OUTPUT_HTML ("<TR>
89   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$id."</TD>
90   <TD align=\"center\" width=\"15%\" class=\"switch_sw".$SW." bottom right\">");
91                         if ($uid > 0)
92                         {
93                                 OUTPUT_HTML (ADMIN_USER_PROFILE_LINK($uid));
94                         }
95                          else
96                         {
97                                 OUTPUT_HTML ($uid);
98                         }
99                         if ($ref > 0)
100                         {
101                                 $ref = ADMIN_USER_PROFILE_LINK($ref);
102                         }
103                         OUTPUT_HTML ("</TD>
104   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$ip."</TD>
105   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$ref."</TD>
106   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$mod."</TD>
107   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$act."</TD>
108   <TD align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$wht."</TD>
109   <TD align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom\">".MAKE_DATETIME($time, "2")."</TD>
110 </TR>");
111                         $SW = 3 - $SW;
112                 }
113
114                 // Free memory
115                 SQL_FREERESULT($result);
116
117                 // Load footer template
118                 define('__FANCY_ONLINE_TIMEOUT', CREATE_FANCY_TIME($CONFIG['online_timeout']));
119                 LOAD_TEMPLATE("admin_online_footer");
120         }
121 }
122  else
123 {
124         // Online statistics deactivated!
125         LOAD_TEMPLATE("admin_settings_saved", false, ONLINE_STATISTICS_DEACTIVATED);
126 }
127 //
128 ?>