~quam-plures-core/quam-plures/file_manager_limits

« back to all changes in this revision

Viewing changes to qp_inc/sessions/views/_stats_referers.view.php

  • Committer: EdB
  • Date: 2013-03-04 07:15:41 UTC
  • mfrom: (7655.1.3 qp5_antispam)
  • Revision ID: 1912webworks@gmail.com-20130304071541-x462crs4d531rh69
http://forums.quamplures.net/viewtopic.php?f=6&t=1887

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
/**
3
3
 * This file implements the UI view for the referer stats.
4
4
 *
5
 
 * This file is part of Quam Plures - {@link http://quamplures.net/}
6
 
 * See also {@link https://launchpad.net/quam-plures}.
7
 
 *
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/}
10
 
 *
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
18
 
 * }}
19
 
 *
20
 
 * {@internal Open Source relicensing agreement:
21
 
 * }}
22
 
 *
 
5
 * @uses PHP_SWF_Charts
 
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
24
11
 */
25
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
 
12
if(!defined('QP_MAIN_INIT')) die('fail');
26
13
 
27
14
/**
28
15
 * View funcs
29
16
 */
30
17
require_once dirname(__FILE__).'/_stats_view.funcs.php';
31
18
 
32
 
 
33
 
global $blog, $admin_url, $rsc_url, $AdminUI;
 
19
global $AdminUI;
 
20
global $admin_url;
 
21
global $blog;
 
22
global $rsc_url;
34
23
 
35
24
?>
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>
38
27
<?php
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' );
48
 
 
49
 
$Results->title = get_manual_link( 'refered-browser-hits' ).T_('Refered browser hits');
50
 
 
51
 
// datetime:
 
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' );
 
37
 
 
38
$Results->title = T_('Refered browser hits');
 
39
 
 
40
// datetime
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$\' )%',
57
 
        );
 
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$\' )%',
 
46
);
58
47
 
59
 
// Referer:
 
48
// Referer
60
49
$Results->cols[1] = array(
61
 
                'th' => T_('Referer'),
62
 
                'order' => 'dom_name',
63
 
        );
 
50
        'th' => T_('Referer'),
 
51
        'order' => 'dom_name',
 
52
);
 
53
 
64
54
if( $current_User->check_perm( 'stats', 'edit' ) )
65
55
{
66
56
        $Results->cols[1]['td'] = '<a href="%regenerate_url( \'action\', \'action=delete&amp;hit_ID=$hit_ID$\')%" title="'
67
 
                        .T_('Delete this hit!').'">'.get_icon( 'delete' ).'</a> '
68
 
 
69
 
                        .'<a href="%regenerate_url( \'action\', \'action=changetype&amp;new_hit_type=search&amp;hit_ID=$hit_ID$\')%" title="'
70
 
                        .T_('Log as a search instead').'">'.get_icon( 'search' ).'</a> '
71
 
 
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&amp;new_hit_type=search&amp;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>';
73
61
}
74
62
else
75
63
{
76
64
        $Results->cols[1]['td'] = '<a href="$hit_referer$">$dom_name$</a>';
77
65
}
78
66
 
79
 
// Antispam:
 
67
// Antispam
80
68
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
81
69
{
82
70
        /**
87
75
        function referer_ban_link( $uri )
88
76
        {
89
77
                return '<a href="?ctrl=antispam&amp;action=ban&amp;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>';
91
79
        }
 
80
 
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."
96
 
                );
 
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."
 
85
        );
 
86
 
97
87
}
98
88
 
99
 
// Target Blog:
100
 
if( empty($blog) )
 
89
// Target Blog
 
90
if( empty( $blog ) )
101
91
{
102
92
        $Results->cols[] = array(
103
 
                        'th' => T_('Target Blog'),
104
 
                        'order' => 'hit_blog_ID',
105
 
                        'td' => '$blog_shortname$',
106
 
                );
 
93
                'th' => T_('Target Blog'),
 
94
                'order' => 'hit_blog_ID',
 
95
                'td' => '$blog_shortname$',
 
96
        );
107
97
}
108
98
 
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# )%',
114
 
        );
115
 
 
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$\') ) %',
121
 
        );
122
 
 
123
 
 
124
 
// Display results:
 
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# )%',
 
104
);
 
105
 
 
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$\') ) %',
 
111
);
 
112
 
 
113
// Display results
125
114
$Results->display();
126
115
 
127
116
?>
128
117
<h3><?php echo T_('Top referers') ?>:</h3>
129
118
 
130
119
<?php
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 ) )
135
123
{
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
138
126
 
139
127
        $count = 0;
140
128
        foreach( $res_stats as $row_stats )
142
130
                if( $count < 8 )
143
131
                {
144
132
                        $count++;
145
 
                        $chart [ 'chart_data' ][ 0 ][ $count ] = stats_basedomain( false );
 
133
                        $chart ['chart_data'][0][$count] = stats_basedomain( false );
146
134
                }
147
135
                else
148
136
                {
149
 
                        $chart [ 'chart_data' ][ 0 ][ $count ] = 'Others'; // Needs UTF-8
 
137
                        $chart ['chart_data'][0][$count] = 'Others'; // Needs UTF-8
150
138
                }
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
153
141
 
154
 
        // Include common chart properties:
 
142
        /**
 
143
         * Include common chart properties
 
144
         */
155
145
        require dirname(__FILE__).'/inc/_pie_chart.inc.php';
156
146
 
157
147
        echo '<div class="center">';
158
 
        load_funcs('_ext/_swfcharts.php');
 
148
        load_funcs( '_ext/_swfcharts.php' );
159
149
        DrawChart( $chart );
160
150
        echo '</div>';
161
 
 
162
 
?>
163
 
<table class="grouped" cellspacing="0">
 
151
        ?>
 
152
        <table class="grouped" cellspacing="0">
164
153
        <tr>
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>
169
158
        </tr>
170
159
        <?php
171
160
        $count = 0;
173
162
        {
174
163
                ?>
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>
177
 
                        <?php
178
 
                        if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
179
 
                        { // user can ban:
180
 
                                echo '<td class="center">'.action_icon( T_('Ban this domain!'), 'ban', regenerate_url( 'ctrl,action,keyword', 'ctrl=antispam&amp;action=ban&amp;aspm_source=reported&amp;keyword='.rawurlencode( get_ban_domain($row_stats['hit_referer']) ) ) ).'</td>'; // we use hit_referer, because unlike dom_name it includes subdomains (especially 'www.')
181
 
                        }
182
 
                        ?>
183
 
                        <td class="right"<?php
184
 
                                if( $count < 8 )
185
 
                                {
186
 
                                        echo ' style="background-color: #'.$chart['series_color'][$count].'"';
187
 
                                }
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>
 
166
                <?php
 
167
                if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
 
168
                {
 
169
                        // user can ban
 
170
                        echo '<td class="center">'.action_icon( T_('Ban this domain!'), 'ban',
 
171
                                regenerate_url( 'ctrl,action,keyword', 'ctrl=antispam&amp;action=ban&amp;aspm_source=referer&amp;aspm_shortened=0&amp;keyword='.rawurlencode( get_ban_domain( $row_stats['hit_referer'] ) ) ) )
 
172
                                .'</td>'; // we use hit_referer, because unlike dom_name it includes subdomains (especially 'www.')
 
173
                }
 
174
                ?>
 
175
                <td class="right"<?php
 
176
                if( $count < 8 )
 
177
                {
 
178
                        echo ' style="background-color: #'.$chart['series_color'][$count].'"';
 
179
                }
 
180
                ?>><?php stats_hit_count() ?></td>
 
181
                <td class="right"><?php stats_hit_percent() ?></td>
190
182
                </tr>
191
183
                <?php
192
184
                $count++;
193
185
        }
194
186
        ?>
195
187
        <tr class="total">
196
 
                <td><?php echo T_('Total referers') ?></td>
197
 
                <td>&nbsp;</td>
198
 
                <td class="right"><?php stats_total_hit_count() ?></td>
199
 
                <td>&nbsp;</td>
 
188
        <td><?php echo T_('Total referers') ?></td>
 
189
        <td>&nbsp;</td>
 
190
        <td class="right"><?php stats_total_hit_count() ?></td>
 
191
        <td>&nbsp;</td>
200
192
        </tr>
201
 
</table>
202
 
<?php }
203
 
 
204
 
 
205
 
?>
 
 
b'\\ No newline at end of file'
 
193
        </table>
 
194
        <?php
 
195
}
 
196
 
 
197
?>