2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/09/2008 *
4 * ================ Last change: 09/09/2008 *
6 * -------------------------------------------------------------------- *
7 * File : what-surfbar_stats.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Surfbar URL statistics *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : URL-Statistiken fuer die Surfbar *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
43 // Is the 'url_id' set?
44 if (isset($_GET['url_id'])) {
45 // Generate general statistics
46 $result = SQL_QUERY_ESC("SELECT `userid`, `count` AS `total_visits`, UNIX_TIMESTAMP(`last_online`) AS `last_online`
47 FROM `"._MYSQL_PREFIX."_surfbar_stats`
49 ORDER BY `userid` ASC",
50 array(bigintval($_GET['url_id'])), __FILE__, __LINE__);
53 if (SQL_NUMROWS($result) > 0) {
55 $OUT = ""; $SW = 2; $cnt = 0; $visits = 0;
56 while ($content = SQL_FETCHARRAY($result)) {
58 $visits += $content['total_visits'];
60 // "Translate" some data
61 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
62 $content['total_visits'] = TRANSLATE_COMMA($content['total_visits']);
63 $content['last_online'] = MAKE_DATETIME($content['last_online'], "2");
67 $OUT .= LOAD_TEMPLATE("admin_surfbar_url_stats_row", true, $content);
68 $cnt++; $SW = 3 - $SW;
80 LOAD_TEMPLATE("admin_surfbar_url_stats", false, $content);
82 // No statistics so far
83 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_SURFBAR_NO_URL_STATS);
86 // Generate general statistics
87 $result = SQL_QUERY("SELECT `userid`, COUNT(`url_id`) AS `visited_urls`, SUM(`count`) AS `total_visits`
88 FROM `"._MYSQL_PREFIX."_surfbar_stats`
90 ORDER BY `userid` ASC", __FILE__, __LINE__);
93 if (SQL_NUMROWS($result) > 0) {
95 $OUT = ""; $SW = 2; $urls = 0; $visits = 0;
96 while ($content = SQL_FETCHARRAY($result)) {
98 $urls += $content['visited_urls'];
99 $visits += $content['total_visits'];
101 // "Translate" some data
102 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
103 $content['visited_urls'] = TRANSLATE_COMMA($content['visited_urls']);
104 $content['total_visits'] = TRANSLATE_COMMA($content['total_visits']);
105 $content['sw'] = $SW;
108 $OUT .= LOAD_TEMPLATE("admin_surfbar_stats_row", true, $content);
120 // Load main template
121 LOAD_TEMPLATE("admin_surfbar_stats", false, $content);
123 // No statistics so far
124 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_SURFBAR_NO_STATS);
129 SQL_FREERESULT($result);