3
3
* This file implements the UI view for the referer stats.
5
* This file is part of Quam Plures - {@link http://quamplures.net/}
6
* See also {@link https://launchpad.net/quam-plures}.
8
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
9
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
11
* {@internal License choice
12
* - If you have received this file as part of a package, please find the license.txt file in
13
* the same folder or the closest folder above for complete license terms.
14
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
15
* then you must choose one of the following licenses before using the file:
16
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
17
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
20
* {@internal Open Source relicensing agreement:
6
* @author {@link http://wonderwinds.com/ Ed Bennett}
7
* @author {@link http://fplanque.net/ Francois PLANQUE}
8
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
9
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
23
10
* @package sessions
25
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
12
if(!defined('QP_MAIN_INIT')) die('fail');
30
17
require_once dirname(__FILE__).'/_stats_view.funcs.php';
33
global $blog, $admin_url, $rsc_url, $AdminUI;
36
25
<h2><?php echo T_('Refered browser hits') ?></h2>
37
26
<p class="notes"><?php echo T_('These are browser hits from external web pages refering to this blog') ?>.</p>
39
28
// Create result set:
40
$Results = new Results( "
41
SELECT hit_ID, hit_datetime, hit_referer, dom_name, hit_blog_ID, hit_uri, hit_remote_addr, blog_shortname
42
FROM T_hitlog INNER JOIN T_basedomains ON dom_ID = hit_referer_dom_ID
43
INNER JOIN T_sessions ON hit_sess_ID = sess_ID
44
LEFT JOIN T_blogs ON hit_blog_ID = blog_ID
45
WHERE hit_referer_type = 'referer'
46
AND hit_agnt_type = 'browser'"
47
.( empty($blog) ? '' : "AND hit_blog_ID = $blog "), 'lstref_', 'D' );
49
$Results->title = get_manual_link( 'refered-browser-hits' ).T_('Refered browser hits');
29
$Results = new Results( "SELECT hit_ID, hit_datetime, hit_referer, dom_name,
30
hit_blog_ID, hit_uri, hit_remote_addr, blog_shortname
31
FROM T_hitlog INNER JOIN T_basedomains ON dom_ID = hit_referer_dom_ID
32
INNER JOIN T_sessions ON hit_sess_ID = sess_ID
33
LEFT JOIN T_blogs ON hit_blog_ID = blog_ID
34
WHERE hit_referer_type = 'referer'
35
AND hit_agnt_type = 'browser'"
36
.( empty( $blog ) ? '' : "AND hit_blog_ID = $blog "), 'lstref_', 'D' );
38
$Results->title = T_('Refered browser hits');
52
41
$Results->cols[0] = array(
53
'th' => T_('Date Time'),
54
'order' => 'hit_ID', // This field is index, much faster than actually sorting on the datetime!
55
'td_class' => 'timestamp',
56
'td' => '%mysql2localedatetime_spans( \'$hit_datetime$\' )%',
42
'th' => T_('Date Time'),
43
'order' => 'hit_ID', // This field is index, much faster than actually sorting on the datetime!
44
'td_class' => 'timestamp',
45
'td' => '%mysql2localedatetime_spans( \'$hit_datetime$\' )%',
60
49
$Results->cols[1] = array(
61
'th' => T_('Referer'),
62
'order' => 'dom_name',
50
'th' => T_('Referer'),
51
'order' => 'dom_name',
64
54
if( $current_User->check_perm( 'stats', 'edit' ) )
66
56
$Results->cols[1]['td'] = '<a href="%regenerate_url( \'action\', \'action=delete&hit_ID=$hit_ID$\')%" title="'
67
.T_('Delete this hit!').'">'.get_icon( 'delete' ).'</a> '
69
.'<a href="%regenerate_url( \'action\', \'action=changetype&new_hit_type=search&hit_ID=$hit_ID$\')%" title="'
70
.T_('Log as a search instead').'">'.get_icon( 'search' ).'</a> '
72
.'<a href="$hit_referer$" target="_blank">$dom_name$</a>';
57
.T_('Delete this hit!').'">'.get_icon( 'delete' ).'</a> '
58
.'<a href="%regenerate_url( \'action\', \'action=changetype&new_hit_type=search&hit_ID=$hit_ID$\')%" title="'
59
.T_('Log as a search instead').'">'.get_icon( 'search' ).'</a> '
60
.'<a href="$hit_referer$" target="_blank">$dom_name$</a>';
76
64
$Results->cols[1]['td'] = '<a href="$hit_referer$">$dom_name$</a>';
80
68
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
87
75
function referer_ban_link( $uri )
89
77
return '<a href="?ctrl=antispam&action=ban&keyword='.rawurlencode( get_ban_domain( $uri ) )
90
.'" title="'.T_('Ban this domain!').'">'.get_icon('ban').'</a>';
78
.'" title="'.T_('Ban this domain!').'">'.get_icon('ban').'</a>';
92
81
$Results->cols[] = array(
93
'th' => /* TRANS: Abbrev. for Spam */ T_('S'),
94
'td_class' => 'center',
95
'td' => '%referer_ban_link( #hit_referer# )%', // we use hit_referer, because unlike dom_name it includes more subdomains, especially "www."
82
'th' => /* TRANS: Abbrev. for Spam */ T_('S'),
83
'td_class' => 'center',
84
'td' => '%referer_ban_link( #hit_referer# )%', // we use hit_referer, because unlike dom_name it includes more subdomains, especially "www."
102
92
$Results->cols[] = array(
103
'th' => T_('Target Blog'),
104
'order' => 'hit_blog_ID',
105
'td' => '$blog_shortname$',
93
'th' => T_('Target Blog'),
94
'order' => 'hit_blog_ID',
95
'td' => '$blog_shortname$',
109
// Requested URI (linked to blog's baseurlroot+URI):
110
$Results->cols[] = array(
111
'th' => T_('Requested URI'),
112
'order' => 'hit_uri',
113
'td' => '%stats_format_req_URI( #hit_blog_ID#, #hit_uri# )%',
116
// Remote address (IP):
117
$Results->cols[] = array(
118
'th' => T_('Remote IP'),
119
'order' => 'hit_remote_addr',
120
'td' => '% $GLOBALS[\'Plugins\']->get_trigger_event( \'FilterIpAddress\', $tmp_params = array(\'format\'=>\'htmlbody\', \'data\'=>\'$hit_remote_addr$\') ) %',
99
// Requested URI (linked to blog's baseurlroot+URI)
100
$Results->cols[] = array(
101
'th' => T_('Requested URI'),
102
'order' => 'hit_uri',
103
'td' => '%stats_format_req_URI( #hit_blog_ID#, #hit_uri# )%',
106
// Remote address (IP)
107
$Results->cols[] = array(
108
'th' => T_('Remote IP'),
109
'order' => 'hit_remote_addr',
110
'td' => '% $GLOBALS[\'Plugins\']->get_trigger_event( \'FilterIpAddress\', $tmp_params = array(\'format\' => \'htmlbody\', \'data\' => \'$hit_remote_addr$\') ) %',
125
114
$Results->display();
128
117
<h3><?php echo T_('Top referers') ?>:</h3>
131
// TODO: re-use $Results from above
132
120
global $res_stats, $row_stats;
133
121
refererList( 30, 'global', 0, 0, "'referer'", 'dom_name', $blog, true );
134
122
if( count( $res_stats ) )
136
$chart [ 'chart_data' ][ 0 ][ 0 ] = "";
137
$chart [ 'chart_data' ][ 1 ][ 0 ] = 'Top referers'; // Needs UTF-8
124
$chart['chart_data'][0][0] = "";
125
$chart['chart_data'][1][0] = 'Top referers'; // Needs UTF-8
140
128
foreach( $res_stats as $row_stats )
145
$chart [ 'chart_data' ][ 0 ][ $count ] = stats_basedomain( false );
133
$chart ['chart_data'][0][$count] = stats_basedomain( false );
149
$chart [ 'chart_data' ][ 0 ][ $count ] = 'Others'; // Needs UTF-8
137
$chart ['chart_data'][0][$count] = 'Others'; // Needs UTF-8
151
$chart [ 'chart_data' ][ 1 ][ $count ] = stats_hit_count( false );
139
$chart ['chart_data'][1][$count] = stats_hit_count( false );
152
140
} // End stat loop
154
// Include common chart properties:
143
* Include common chart properties
155
145
require dirname(__FILE__).'/inc/_pie_chart.inc.php';
157
147
echo '<div class="center">';
158
load_funcs('_ext/_swfcharts.php');
148
load_funcs( '_ext/_swfcharts.php' );
159
149
DrawChart( $chart );
163
<table class="grouped" cellspacing="0">
152
<table class="grouped" cellspacing="0">
165
<th class="firstcol"><?php echo T_('Referer') ?></th>
166
<th><?php echo T_('Spam') ?></th>
167
<th><?php echo T_('Hits') ?></th>
168
<th class="lastcol"><?php echo /* xgettext:no-php-format */ T_('% of total') ?></th>
154
<th class="firstcol"><?php echo T_('Referer') ?></th>
155
<th><?php echo T_('Spam') ?></th>
156
<th><?php echo T_('Hits') ?></th>
157
<th class="lastcol"><?php echo /* xgettext:no-php-format */ T_('% of total') ?></th>
175
164
<tr class="<?php echo( $count%2 ? 'odd' : 'even') ?>">
176
<td class="firstcol"><a href="<?php stats_referer() ?>" target="_blank"><?php stats_basedomain() ?></a></td>
178
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
180
echo '<td class="center">'.action_icon( T_('Ban this domain!'), 'ban', regenerate_url( 'ctrl,action,keyword', 'ctrl=antispam&action=ban&aspm_source=reported&keyword='.rawurlencode( get_ban_domain($row_stats['hit_referer']) ) ) ).'</td>'; // we use hit_referer, because unlike dom_name it includes subdomains (especially 'www.')
183
<td class="right"<?php
186
echo ' style="background-color: #'.$chart['series_color'][$count].'"';
188
?>><?php stats_hit_count() ?></td>
189
<td class="right"><?php stats_hit_percent() ?></td>
165
<td class="firstcol"><a href="<?php stats_referer() ?>" target="_blank"><?php stats_basedomain() ?></a></td>
167
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
170
echo '<td class="center">'.action_icon( T_('Ban this domain!'), 'ban',
171
regenerate_url( 'ctrl,action,keyword', 'ctrl=antispam&action=ban&aspm_source=referer&aspm_shortened=0&keyword='.rawurlencode( get_ban_domain( $row_stats['hit_referer'] ) ) ) )
172
.'</td>'; // we use hit_referer, because unlike dom_name it includes subdomains (especially 'www.')
175
<td class="right"<?php
178
echo ' style="background-color: #'.$chart['series_color'][$count].'"';
180
?>><?php stats_hit_count() ?></td>
181
<td class="right"><?php stats_hit_percent() ?></td>
195
187
<tr class="total">
196
<td><?php echo T_('Total referers') ?></td>
198
<td class="right"><?php stats_total_hit_count() ?></td>
188
<td><?php echo T_('Total referers') ?></td>
190
<td class="right"><?php stats_total_hit_count() ?></td>
b'\\ No newline at end of file'