]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-surfbar_stats.php
589504fba425cc086ef3fd4aeddc83136e15c9c1
[mailer.git] / inc / modules / admin / what-surfbar_stats.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 09/09/2008 *
4  * ================                             Last change: 09/09/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-surfbar_stats.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Surfbar URL statistics                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : URL-Statistiken fuer die Surfbar                 *
12  * -------------------------------------------------------------------- *
13  * $Revision:: 856                                                    $ *
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                  *
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 // 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`
53 WHERE `url_id`=%s
54 ORDER BY `userid` ASC",
55                 array(bigintval(REQUEST_GET('url_id'))), __FILE__, __LINE__);
56
57         // Entries found?
58         if (SQL_NUMROWS($result) > 0) {
59                 // Get all rows
60                 $OUT = ""; $SW = 2; $cnt = 0; $visits = 0;
61                 while ($content = SQL_FETCHARRAY($result)) {
62                         // Count totals
63                         $visits += $content['total_visits'];
64
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");
69                         $content['sw']           = $SW;
70
71                         // Load row template
72                         $OUT .= LOAD_TEMPLATE("admin_surfbar_url_stats_row", true, $content);
73                         $cnt++; $SW = 3 - $SW;
74                 } // END - while
75
76                 // Prepare content
77                 $content = array(
78                         'rows'    => $OUT,
79                         'userids' => $cnt,
80                         'visits'  => $visits
81                 );
82
83
84                 // Load main template
85                 LOAD_TEMPLATE("admin_surfbar_url_stats", false, $content);
86         } else {
87                 // No statistics so far
88                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SURFBAR_NO_URL_STATS'));
89         }
90 } else {
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`
94 GROUP BY `userid`
95 ORDER BY `userid` ASC", __FILE__, __LINE__);
96
97         // Entries found?
98         if (SQL_NUMROWS($result) > 0) {
99                 // Get all rows
100                 $OUT = ""; $SW = 2; $urls = 0; $visits = 0;
101                 while ($content = SQL_FETCHARRAY($result)) {
102                         // Count totals
103                         $urls   += $content['visited_urls'];
104                         $visits += $content['total_visits'];
105
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;
111
112                         // Load row template
113                         $OUT .= LOAD_TEMPLATE("admin_surfbar_stats_row", true, $content);
114                         $SW = 3 - $SW;
115                 } // END - while
116
117                 // Prepare content
118                 $content = array(
119                         'rows'   => $OUT,
120                         'urls'   => $urls,
121                         'visits' => $visits
122                 );
123
124
125                 // Load main template
126                 LOAD_TEMPLATE("admin_surfbar_stats", false, $content);
127         } else {
128                 // No statistics so far
129                 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SURFBAR_NO_STATS'));
130         }
131 }
132
133 // Free result
134 SQL_FREERESULT($result);
135
136 //
137 ?>