Re-added, now the right ones
[mailer.git] / 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  * $Revision:: 856                                                    $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
47
48 // Online stats are only working if extension ext-online is installed
49 if (EXT_IS_ACTIVE("online")) {
50         // Count guests, members and admins
51         // @TODO Rewrite these constants
52         // @TODO Add a filter for sponsor
53         define('_GUESTS_ONLINE' , GET_TOTAL_DATA("N", "online", "id", "is_admin", true, " AND is_member='N'"));
54         define('_ADMINS_ONLINE' , GET_TOTAL_DATA("N", "online", "id", "is_admin", true, " AND is_member='Y'"));
55         define('_MEMBERS_ONLINE', GET_TOTAL_DATA("N", "online", "id", "is_admin", true));
56
57         // Load template
58         LOAD_TEMPLATE("admin_mini_online");
59
60         // Check for online users
61         $result = SQL_QUERY("SELECT id, ip, userid, refid, module, action, what, is_member, is_admin, timestamp FROM `{!_MYSQL_PREFIX!}_online` ORDER by timestamp DESC",
62                 __FILE__, __LINE__);
63         if (SQL_NUMROWS($result) > 0) {
64                 // Load header template
65                 LOAD_TEMPLATE("admin_online_header");
66
67                 // List all online users
68                 $SW = 2;
69                 while ($content = SQL_FETCHARRAY($result)) {
70                         // Fix empty action/what
71                         if (empty($content['action'])) $content['action'] = "---";
72                         if (empty($content['what']))   $content['what']   = "---";
73
74                         if ($content['is_admin'] == "Y") {
75                                 // Is an administrator
76                                 $content['userid'] = getMessage('_IS_ADMIN');
77                         } elseif (($content['is_member'] == "N") && ($content['is_admin'] == "N")) {
78                                 // Is a guest
79                                 $content['userid'] = getMessage('_IS_GUEST');
80                         } elseif ($content['userid'] > 0) {
81                                 // Add profile link to userid
82                                 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
83                         } // END - if
84
85                         // Is the refid set?
86                         if ($content['refid'] > 0) {
87                                 // Add profile link to referer id
88                                 $content['refid'] = ADMIN_USER_PROFILE_LINK($content['refid']);
89                         } // END - if
90
91                         OUTPUT_HTML("<tr>
92   <td align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$content['id']."</td>
93   <td align=\"center\" width=\"15%\" class=\"switch_sw".$SW." bottom right\">".$content['userid']."</td>
94   <td align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$content['ip']."</td>
95   <td align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$content['refid']."</td>
96   <td align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$content['module']."</td>
97   <td align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom right\">".$content['action']."</td>
98   <td align=\"center\" width=\"5%\" class=\"switch_sw".$SW." bottom right\">".$content['what']."</td>
99   <td align=\"center\" width=\"10%\" class=\"switch_sw".$SW." bottom\">".MAKE_DATETIME($content['timestamp'], "2")."</td>
100 </tr>");
101                         $SW = 3 - $SW;
102                 } // END - while
103
104                 // Free memory
105                 SQL_FREERESULT($result);
106
107                 // @TODO Rewrite this constant
108                 define('__FANCY_ONLINE_TIMEOUT', CREATE_FANCY_TIME(getConfig('online_timeout')));
109
110                 // Load footer template
111                 LOAD_TEMPLATE("admin_online_footer");
112         } // END - if
113 } else {
114         // Online statistics deactivated!
115         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ONLINE_STATISTICS_DEACTIVATED'));
116 }
117
118 //
119 ?>