]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-surfbar_stats.php
- Rewrites to use more the userid than the actual email address when sending
[mailer.git] / inc / modules / admin / what-surfbar_stats.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Is the 'url_id' set?
47 if (isGetRequestParameterSet('url_id')) {
48         // Generate general statistics
49         $result = SQL_QUERY_ESC("SELECT
50         `stats_userid`,
51         `stats_count` AS `total_visits`,
52         UNIX_TIMESTAMP(`stats_last_surfed`) AS `last_surfed`
53 FROM
54         `{?_MYSQL_PREFIX?}_surfbar_stats`
55 WHERE
56         `stats_url_id`=%s
57 ORDER BY
58         `stats_userid` ASC",
59                 array(bigintval(getRequestParameter('url_id'))), __FILE__, __LINE__);
60
61         // Entries found?
62         if (!SQL_HASZERONUMS($result)) {
63                 // Get all rows
64                 $OUT = ''; $count = '0'; $visits = '0';
65                 while ($content = SQL_FETCHARRAY($result)) {
66                         // Count totals
67                         $visits += $content['total_visits'];
68
69                         // "Translate" some data
70                         $content['last_surfed']  = generateDateTime($content['last_surfed'], 2);
71
72                         // Load row template
73                         $OUT .= loadTemplate('admin_surfbar_url_stats_row', true, $content);
74                         $count++;;
75                 } // END - while
76
77                 // Prepare content
78                 $content = array(
79                         'rows'    => $OUT,
80                         'userids' => $count,
81                         'visits'  => $visits
82                 );
83
84
85                 // Load main template
86                 loadTemplate('admin_surfbar_url_stats', false, $content);
87         } else {
88                 // No statistics so far
89                 displayMessage('{--ADMIN_SURFBAR_NO_URL_STATS--}');
90         }
91 } else {
92         // Generate general statistics
93         $result = SQL_QUERY("SELECT
94         `stats_userid`,
95         COUNT(`stats_url_id`) AS `visited_urls`,
96         SUM(`stats_count`) AS `total_visits`
97 FROM
98         `{?_MYSQL_PREFIX?}_surfbar_stats`
99 GROUP BY
100         `stats_userid`
101 ORDER BY
102         `stats_userid` ASC", __FILE__, __LINE__);
103
104         // Entries found?
105         if (!SQL_HASZERONUMS($result)) {
106                 // Get all rows
107                 $OUT = ''; $urlArray = '0'; $visits = '0';
108                 while ($content = SQL_FETCHARRAY($result)) {
109                         // Count totals
110                         $urlArray += $content['visited_urls'];
111                         $visits   += $content['total_visits'];
112
113                         // Load row template
114                         $OUT .= loadTemplate('admin_surfbar_stats_row', true, $content);
115                 } // END - while
116
117                 // Prepare content
118                 $content = array(
119                         'rows'   => $OUT,
120                         'urls'   => $urlArray,
121                         'visits' => $visits
122                 );
123
124
125                 // Load main template
126                 loadTemplate('admin_surfbar_stats', false, $content);
127         } else {
128                 // No statistics so far
129                 displayMessage('{--ADMIN_SURFBAR_NO_STATS--}');
130         }
131 }
132
133 // Free result
134 SQL_FREERESULT($result);
135
136 // [EOF]
137 ?>