3
3
* This file implements the UI view for the robot 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;
35
echo '<h2>'.get_manual_link( 'robot-hits-summary' ).T_('Robot hits summary').'</h2>';
24
echo '<h2>'.T_('Robot hits summary').'</h2>';
36
25
echo '<p class="notes">'.sprintf( T_('This page only includes hits identified as made by <a %s>indexing robots</a> a.k.a. web crawlers.'), ' href="?ctrl=stats&tab=useragents&agnt_robot=1&blog='.$blog.'"' ).'</p>';
37
26
echo '<p class="notes">'.T_('In order to be detected, robots must be listed in /qp_config/_stats.php.').'</p>';
40
SELECT COUNT(*) AS hits, EXTRACT(YEAR FROM hit_datetime) AS year,
41
EXTRACT(MONTH FROM hit_datetime) AS month, EXTRACT(DAY FROM hit_datetime) AS day
43
WHERE hit_agnt_type = 'robot'";
28
$sql = "SELECT COUNT(*) AS hits, EXTRACT(YEAR FROM hit_datetime) AS year,
29
EXTRACT(MONTH FROM hit_datetime) AS month, EXTRACT(DAY FROM hit_datetime) AS day
30
FROM T_hitlog WHERE hit_agnt_type = 'robot'";
46
33
$sql .= ' AND hit_blog_ID = '.$blog;
48
$sql .= ' GROUP BY year, month, day
49
ORDER BY year DESC, month DESC, day DESC';
35
$sql .= ' GROUP BY year, month, day ORDER BY year DESC, month DESC, day DESC';
50
37
$res_hits = $DB->get_results( $sql, ARRAY_A, 'Get robot summary' );
56
if( count($res_hits) )
40
if( count( $res_hits ) )
60
$chart[ 'chart_data' ][ 0 ] = array();
61
$chart[ 'chart_data' ][ 1 ] = array();
44
$chart['chart_data'][0] = array();
45
$chart['chart_data'][1] = array();
64
48
foreach( $res_hits as $row_stats )
66
50
$this_date = mktime( 0, 0, 0, $row_stats['month'], $row_stats['day'], $row_stats['year'] );
67
51
if( $last_date != $this_date )
68
{ // We just hit a new day, let's display the previous one:
69
$last_date = $this_date; // that'll be the next one
71
array_unshift( $chart[ 'chart_data' ][ 0 ], date( locale_datefmt(), $last_date ) );
72
array_unshift( $chart[ 'chart_data' ][ 1 ], 0 );
53
// We just hit a new day, let's display the previous one
54
$last_date = $this_date; // that'll be the next one
56
array_unshift( $chart['chart_data'][0], date( locale_datefmt(), $last_date ) );
57
array_unshift( $chart['chart_data'][1], 0 );
74
$chart [ 'chart_data' ][1][0] = $row_stats['hits'];
59
$chart ['chart_data'][1][0] = $row_stats['hits'];
77
array_unshift( $chart[ 'chart_data' ][ 0 ], '' );
78
array_unshift( $chart[ 'chart_data' ][ 1 ], 'Robot hits' ); // Translations need to be UTF-8
62
array_unshift( $chart['chart_data'][0], '' );
63
array_unshift( $chart['chart_data'][1], 'Robot hits' ); // Translations need to be UTF-8
80
// Include common chart properties:
66
* Include common chart properties
81
68
require dirname(__FILE__).'/inc/_bar_chart.inc.php';
83
$chart[ 'series_color' ] = array (
70
$chart['series_color'] = array (
88
74
echo '<div class="center">';
89
load_funcs('_ext/_swfcharts.php');
75
load_funcs( '_ext/_swfcharts.php' );
90
76
DrawChart( $chart );
97
81
// TOP INDEXING ROBOTS
100
$sql = "SELECT COUNT(*) AS hit_count, hit_agnt_signature
102
WHERE hit_agnt_type = 'robot' "
103
.( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog ).'
104
GROUP BY hit_agnt_signature';
83
$sql = "SELECT COUNT(*) AS hit_count, hit_agnt_signature FROM T_hitlog WHERE hit_agnt_type = 'robot' "
84
.( empty( $blog ) ? '' : 'AND hit_blog_ID = '.$blog ).' GROUP BY hit_agnt_signature';
106
86
$count_sql = "SELECT COUNT( DISTINCT hit_agnt_signature )
108
WHERE hit_agnt_type = 'robot' "
109
.( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog );
88
WHERE hit_agnt_type = 'robot' "
89
.( empty( $blog ) ? '' : 'AND hit_blog_ID = '.$blog );
111
91
$Results = new Results( $sql, 'topidx', '-D', 20, $count_sql );
113
$total_hit_count = $DB->get_var( "
116
WHERE hit_agnt_type = 'robot' "
117
.( empty($blog) ? '' : 'AND hit_blog_ID = '.$blog ) );
93
$total_hit_count = $DB->get_var( "SELECT COUNT(*)
95
WHERE hit_agnt_type = 'robot' "
96
.( empty( $blog ) ? '' : 'AND hit_blog_ID = '.$blog ) );
119
98
$Results->title = T_('Top Indexing Robots');
101
$Results->cols[] = array(
103
'order' => 'hit_agnt_signature',
104
'td' => '%translate_user_agent(\'$hit_agnt_signature$\')%',
108
$Results->cols[] = array(
109
'th' => T_('Hit count'),
110
'order' => 'hit_count',
111
'td_class' => 'right',
112
'td' => '$hit_count$',
116
$Results->cols[] = array(
118
'order' => 'hit_count',
119
'td_class' => 'right',
120
'td' => '%percentage( #hit_count#, '.$total_hit_count.' )%',
122
* Helper function to translate agnt_signature to a "human-friendly" version from {@link $user_agents}.
127
* translate agnt_signature to a "human-friendly" version from {@link $user_agents}
125
131
function translate_user_agent( $agnt_signature )
127
133
global $user_agents;
129
foreach ($user_agents as $curr_user_agent)
135
foreach( $user_agents as $curr_user_agent )
131
if (stristr($agnt_signature, $curr_user_agent[1]))
137
if( stristr( $agnt_signature, $curr_user_agent[1] ) )
133
return '<span title="'.htmlspecialchars($agnt_signature).'">'.htmlspecialchars($curr_user_agent[2]).'</span>';
139
return '<span title="'.htmlspecialchars( $agnt_signature ).'">'.htmlspecialchars( $curr_user_agent[2] ).'</span>';
137
return htmlspecialchars($agnt_signature);
143
return htmlspecialchars( $agnt_signature );
141
$Results->cols[] = array(
143
'order' => 'hit_agnt_signature',
144
'td' => '%translate_user_agent(\'$hit_agnt_signature$\')%',
148
$Results->cols[] = array(
149
'th' => T_('Hit count'),
150
'order' => 'hit_count',
151
'td_class' => 'right',
152
'td' => '$hit_count$',
156
$Results->cols[] = array(
158
'order' => 'hit_count',
159
'td_class' => 'right',
160
'td' => '%percentage( #hit_count#, '.$total_hit_count.' )%',
b'\\ No newline at end of file'