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 * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009) $ *
15 * $Tag:: 0.2.1-FINAL $ *
16 * $Author:: stelzi $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
48 // Is the 'url_id' set?
49 if (REQUEST_ISSET_GET(('url_id'))) {
50 // Generate general statistics
51 $result = SQL_QUERY_ESC("SELECT `userid`, `count` AS `total_visits`, UNIX_TIMESTAMP(`last_online`) AS `last_online`
52 FROM `{!_MYSQL_PREFIX!}_surfbar_stats`
54 ORDER BY `userid` ASC",
55 array(bigintval(REQUEST_GET('url_id'))), __FILE__, __LINE__);
58 if (SQL_NUMROWS($result) > 0) {
60 $OUT = ""; $SW = 2; $cnt = 0; $visits = 0;
61 while ($content = SQL_FETCHARRAY($result)) {
63 $visits += $content['total_visits'];
65 // "Translate" some data
66 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
67 $content['total_visits'] = TRANSLATE_COMMA($content['total_visits']);
68 $content['last_online'] = MAKE_DATETIME($content['last_online'], "2");
72 $OUT .= LOAD_TEMPLATE("admin_surfbar_url_stats_row", true, $content);
73 $cnt++; $SW = 3 - $SW;
85 LOAD_TEMPLATE("admin_surfbar_url_stats", false, $content);
87 // No statistics so far
88 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SURFBAR_NO_URL_STATS'));
91 // Generate general statistics
92 $result = SQL_QUERY("SELECT `userid`, COUNT(`url_id`) AS `visited_urls`, SUM(`count`) AS `total_visits`
93 FROM `{!_MYSQL_PREFIX!}_surfbar_stats`
95 ORDER BY `userid` ASC", __FILE__, __LINE__);
98 if (SQL_NUMROWS($result) > 0) {
100 $OUT = ""; $SW = 2; $urls = 0; $visits = 0;
101 while ($content = SQL_FETCHARRAY($result)) {
103 $urls += $content['visited_urls'];
104 $visits += $content['total_visits'];
106 // "Translate" some data
107 $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']);
108 $content['visited_urls'] = TRANSLATE_COMMA($content['visited_urls']);
109 $content['total_visits'] = TRANSLATE_COMMA($content['total_visits']);
110 $content['sw'] = $SW;
113 $OUT .= LOAD_TEMPLATE("admin_surfbar_stats_row", true, $content);
125 // Load main template
126 LOAD_TEMPLATE("admin_surfbar_stats", false, $content);
128 // No statistics so far
129 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SURFBAR_NO_STATS'));
134 SQL_FREERESULT($result);