1 | <?php |
||||
2 | // TODO: make things cleaner. This file is an awful HTML/PHP soup. |
||||
3 | define( 'YOURLS_INFOS', true ); |
||||
4 | require_once( dirname( __FILE__ ).'/includes/load-yourls.php' ); |
||||
5 | yourls_maybe_require_auth(); |
||||
6 | |||||
7 | // Variables should be defined in yourls-loader.php |
||||
8 | if ( !isset( $keyword ) ) { |
||||
9 | yourls_do_action( 'infos_no_keyword' ); |
||||
10 | yourls_redirect( YOURLS_SITE, 302 ); |
||||
11 | } |
||||
12 | |||||
13 | // Get basic infos for this shortened URL |
||||
14 | $keyword = yourls_sanitize_keyword( $keyword ); |
||||
15 | $longurl = yourls_get_keyword_longurl( $keyword ); |
||||
16 | $clicks = yourls_get_keyword_clicks( $keyword ); |
||||
17 | $timestamp = yourls_get_keyword_timestamp( $keyword ); |
||||
18 | $title = yourls_get_keyword_title( $keyword ); |
||||
19 | |||||
20 | // Update title if it hasn't been stored yet |
||||
21 | if( $title == '' ) { |
||||
22 | $title = yourls_get_remote_title( $longurl ); |
||||
23 | yourls_edit_link_title( $keyword, $title ); |
||||
24 | } |
||||
25 | |||||
26 | if ( $longurl === false ) { |
||||
27 | yourls_do_action( 'infos_keyword_not_found' ); |
||||
28 | yourls_redirect( YOURLS_SITE, 302 ); |
||||
29 | } |
||||
30 | |||||
31 | yourls_do_action( 'pre_yourls_infos', $keyword ); |
||||
32 | |||||
33 | |||||
34 | if( yourls_do_log_redirect() ) { |
||||
35 | |||||
36 | $table = YOURLS_DB_TABLE_LOG; |
||||
37 | $referrers = array(); |
||||
38 | $direct = $notdirect = 0; |
||||
39 | $countries = array(); |
||||
40 | $dates = array(); |
||||
41 | $list_of_days = array(); |
||||
42 | $list_of_months = array(); |
||||
43 | $list_of_years = array(); |
||||
44 | $last_24h = array(); |
||||
45 | |||||
46 | if( yourls_allow_duplicate_longurls() ) |
||||
47 | $keyword_list = yourls_get_longurl_keywords( $longurl ); |
||||
48 | // Define keyword query range : either a single keyword or a list of keywords |
||||
49 | if( $aggregate ) { |
||||
50 | $keyword_range = 'IN ( :list )'; |
||||
51 | $keyword_binds = array('list' => $keyword_list); |
||||
52 | } else { |
||||
53 | $keyword_range = '= :keyword'; |
||||
54 | $keyword_binds = array('keyword' => $keyword); |
||||
55 | } |
||||
56 | |||||
57 | |||||
58 | // *** Referrers *** |
||||
59 | $sql = "SELECT `referrer`, COUNT(*) AS `count` FROM `$table` WHERE `shorturl` $keyword_range GROUP BY `referrer`;"; |
||||
60 | $sql = yourls_apply_filter('stat_query_referrer', $sql); |
||||
61 | $rows = $ydb->fetchObjects($sql, $keyword_binds); |
||||
62 | |||||
63 | // Loop through all results and build list of referrers, countries and hits per day |
||||
64 | foreach( (array)$rows as $row ) { |
||||
65 | if ( $row->referrer == 'direct' ) { |
||||
66 | $direct = $row->count; |
||||
67 | continue; |
||||
68 | } |
||||
69 | |||||
70 | $host = yourls_get_domain( $row->referrer ); |
||||
71 | if( !array_key_exists( $host, $referrers ) ) |
||||
72 | $referrers[$host] = array( ); |
||||
73 | if( !array_key_exists( $row->referrer, $referrers[$host] ) ) { |
||||
74 | $referrers[$host][$row->referrer] = $row->count; |
||||
75 | $notdirect += $row->count; |
||||
76 | } else { |
||||
77 | $referrers[$host][$row->referrer] += $row->count; |
||||
78 | $notdirect += $row->count; |
||||
79 | } |
||||
80 | } |
||||
81 | |||||
82 | // Sort referrers. $referrer_sort is a array of most frequent domains |
||||
83 | arsort( $referrers ); |
||||
84 | $referrer_sort = array(); |
||||
85 | $number_of_sites = count( array_keys( $referrers ) ); |
||||
86 | foreach( $referrers as $site => $urls ) { |
||||
87 | if( count($urls) > 1 || $number_of_sites == 1 ) |
||||
88 | $referrer_sort[$site] = array_sum( $urls ); |
||||
89 | } |
||||
90 | arsort($referrer_sort); |
||||
91 | |||||
92 | |||||
93 | // *** Countries *** |
||||
94 | $sql = "SELECT `country_code`, COUNT(*) AS `count` FROM `$table` WHERE `shorturl` $keyword_range GROUP BY `country_code`;"; |
||||
95 | $sql = yourls_apply_filter('stat_query_country', $sql); |
||||
96 | $rows = $ydb->fetchObjects($sql, $keyword_binds); |
||||
97 | |||||
98 | // Loop through all results and build list of countries and hits |
||||
99 | foreach( (array)$rows as $row ) { |
||||
100 | if ("$row->country_code") |
||||
101 | $countries["$row->country_code"] = $row->count; |
||||
102 | } |
||||
103 | |||||
104 | // Sort countries, most frequent first |
||||
105 | if ( $countries ) |
||||
106 | arsort( $countries ); |
||||
107 | |||||
108 | |||||
109 | // *** Dates : array of $dates[$year][$month][$day] = number of clicks *** |
||||
110 | $sql = "SELECT |
||||
111 | DATE_FORMAT(`click_time`, '%Y') AS `year`, |
||||
112 | DATE_FORMAT(`click_time`, '%m') AS `month`, |
||||
113 | DATE_FORMAT(`click_time`, '%d') AS `day`, |
||||
114 | COUNT(*) AS `count` |
||||
115 | FROM `$table` |
||||
116 | WHERE `shorturl` $keyword_range |
||||
117 | GROUP BY `year`, `month`, `day`;"; |
||||
118 | $sql = yourls_apply_filter('stat_query_dates', $sql); |
||||
119 | $rows = $ydb->fetchObjects($sql, $keyword_binds); |
||||
120 | |||||
121 | // Loop through all results and fill blanks |
||||
122 | foreach( (array)$rows as $row ) { |
||||
123 | if( !array_key_exists($row->year, $dates ) ) |
||||
124 | $dates[$row->year] = array(); |
||||
125 | if( !array_key_exists( $row->month, $dates[$row->year] ) ) |
||||
126 | $dates[$row->year][$row->month] = array(); |
||||
127 | if( !array_key_exists( $row->day, $dates[$row->year][$row->month] ) ) |
||||
128 | $dates[$row->year][$row->month][$row->day] = $row->count; |
||||
129 | else |
||||
130 | $dates[$row->year][$row->month][$row->day] += $row->count; |
||||
131 | } |
||||
132 | |||||
133 | // Sort dates, chronologically from [2007][12][24] to [2009][02][19] |
||||
134 | ksort( $dates ); |
||||
135 | foreach( $dates as $year=>$months ) { |
||||
136 | ksort( $dates[$year] ); |
||||
137 | foreach( $months as $month=>$day ) { |
||||
138 | ksort( $dates[$year][$month] ); |
||||
139 | } |
||||
140 | } |
||||
141 | |||||
142 | // Get $list_of_days, $list_of_months, $list_of_years |
||||
143 | reset( $dates ); |
||||
144 | if( $dates ) { |
||||
145 | $_lists = yourls_build_list_of_days( $dates ); |
||||
146 | $list_of_days = $_lists['list_of_days']; |
||||
147 | $list_of_months = $_lists['list_of_months']; |
||||
148 | $list_of_years = $_lists['list_of_years']; |
||||
149 | unset($_lists); |
||||
150 | } |
||||
151 | |||||
152 | $offset = yourls_get_time_offset(); |
||||
153 | |||||
154 | // *** Last 24 hours : array of $last_24h[ $hour ] = number of click *** |
||||
155 | $sql = "SELECT |
||||
156 | DATE_FORMAT(DATE_ADD(`click_time`, INTERVAL " . $offset . " HOUR), '%H %p') AS `time`, |
||||
157 | COUNT(*) AS `count` |
||||
158 | FROM `$table` |
||||
159 | WHERE `shorturl` $keyword_range AND DATE_ADD(`click_time`, INTERVAL " . $offset . " HOUR) > (DATE_ADD(CURRENT_TIMESTAMP, INTERVAL " . $offset . " HOUR) - INTERVAL 1 DAY) |
||||
160 | GROUP BY `time`;"; |
||||
161 | $sql = yourls_apply_filter('stat_query_last24h', $sql); |
||||
162 | $rows = $ydb->fetchObjects($sql, $keyword_binds); |
||||
163 | |||||
164 | $_last_24h = array(); |
||||
165 | foreach( (array)$rows as $row ) { |
||||
166 | if ( isset( $row->time ) ) |
||||
167 | $_last_24h[ "$row->time" ] = $row->count; |
||||
168 | } |
||||
169 | |||||
170 | $now = intval( date('U') ); |
||||
171 | for ($i = 23; $i >= 0; $i--) { |
||||
172 | $h = date('H A', ($now - ($i * 60 * 60) + ($offset * 60 * 60)) ); |
||||
173 | // If the $last_24h doesn't have all the hours, insert missing hours with value 0 |
||||
174 | $last_24h[ $h ] = array_key_exists( $h, $_last_24h ) ? $_last_24h[ $h ] : 0 ; |
||||
175 | } |
||||
176 | unset( $_last_24h ); |
||||
177 | |||||
178 | // *** Queries all done, phew *** |
||||
179 | |||||
180 | // Filter all this junk if applicable. Be warned, some are possibly huge datasets. |
||||
181 | $referrers = yourls_apply_filter( 'pre_yourls_info_referrers', $referrers ); |
||||
182 | $referrer_sort = yourls_apply_filter( 'pre_yourls_info_referrer_sort', $referrer_sort ); |
||||
183 | $direct = yourls_apply_filter( 'pre_yourls_info_direct', $direct ); |
||||
184 | $notdirect = yourls_apply_filter( 'pre_yourls_info_notdirect', $notdirect ); |
||||
185 | $dates = yourls_apply_filter( 'pre_yourls_info_dates', $dates ); |
||||
186 | $list_of_days = yourls_apply_filter( 'pre_yourls_info_list_of_days', $list_of_days ); |
||||
187 | $list_of_months = yourls_apply_filter( 'pre_yourls_info_list_of_months', $list_of_months ); |
||||
188 | $list_of_years = yourls_apply_filter( 'pre_yourls_info_list_of_years', $list_of_years ); |
||||
189 | $last_24h = yourls_apply_filter( 'pre_yourls_info_last_24h', $last_24h ); |
||||
190 | $countries = yourls_apply_filter( 'pre_yourls_info_countries', $countries ); |
||||
191 | |||||
192 | // I can haz debug data |
||||
193 | /** |
||||
194 | echo "<pre>"; |
||||
195 | echo "referrers: "; print_r( $referrers ); |
||||
196 | echo "referrer sort: "; print_r( $referrer_sort ); |
||||
197 | echo "direct: $direct\n"; |
||||
198 | echo "notdirect: $notdirect\n"; |
||||
199 | echo "dates: "; print_r( $dates ); |
||||
200 | echo "list of days: "; print_r( $list_of_days ); |
||||
201 | echo "list_of_months: "; print_r( $list_of_months ); |
||||
202 | echo "list_of_years: "; print_r( $list_of_years ); |
||||
203 | echo "last_24h: "; print_r( $last_24h ); |
||||
204 | echo "countries: "; print_r( $countries ); |
||||
205 | die(); |
||||
206 | **/ |
||||
207 | |||||
208 | } |
||||
209 | |||||
210 | yourls_html_head( 'infos', yourls_s( 'Statistics for %s', YOURLS_SITE.'/'.$keyword ) ); |
||||
211 | yourls_html_logo(); |
||||
212 | yourls_html_menu(); |
||||
213 | ?> |
||||
214 | |||||
215 | <h2 id="informations"><?php echo yourls_esc_html( $title ); ?></h2> |
||||
216 | |||||
217 | <h3><span class="label"><?php yourls_e( 'Short URL'); ?>:</span> <img src="<?php yourls_get_yourls_favicon_url() ?>"/> |
||||
218 | <?php if( $aggregate ) { |
||||
219 | $i = 0; |
||||
220 | foreach( $keyword_list as $k ) { |
||||
221 | $i++; |
||||
222 | if ( $i == 1 ) { |
||||
223 | yourls_html_link( yourls_link($k) ); |
||||
224 | } else { |
||||
225 | yourls_html_link( yourls_link($k), "/$k" ); |
||||
226 | } |
||||
227 | if ( $i < count( $keyword_list ) ) |
||||
228 | echo ' + '; |
||||
229 | } |
||||
230 | } else { |
||||
231 | yourls_html_link( yourls_link($keyword) ); |
||||
232 | if( isset( $keyword_list ) && count( $keyword_list ) > 1 ) |
||||
233 | echo ' <a href="'. yourls_link($keyword).'+all" title="' . yourls_esc_attr__( 'Aggregate stats for duplicate short URLs' ) . '"><img src="' . yourls_match_current_protocol( YOURLS_SITE ) . '/images/chart_bar_add.png" border="0" /></a>'; |
||||
234 | } ?></h3> |
||||
235 | <h3 id="longurl"><span class="label"><?php yourls_e( 'Long URL'); ?>:</span> <img class="fix_images" src="<?php echo yourls_get_favicon_url( $longurl );?>" /> <?php yourls_html_link( $longurl, yourls_trim_long_string( $longurl ), 'longurl' ); ?></h3> |
||||
236 | |||||
237 | <div id="tabs"> |
||||
238 | <div class="wrap_unfloat"> |
||||
239 | <ul id="headers" class="toggle_display stat_tab"> |
||||
240 | <?php if( yourls_do_log_redirect() ) { ?> |
||||
241 | <li class="selected"><a href="#stat_tab_stats"><h2><?php yourls_e( 'Traffic statistics'); ?></h2></a></li> |
||||
242 | <li><a href="#stat_tab_location"><h2><?php yourls_e( 'Traffic location'); ?></h2></a></li> |
||||
243 | <li><a href="#stat_tab_sources"><h2><?php yourls_e( 'Traffic sources'); ?></h2></a></li> |
||||
244 | <?php } ?> |
||||
245 | <li><a href="#stat_tab_share"><h2><?php yourls_e( 'Share'); ?></h2></a></li> |
||||
246 | </ul> |
||||
247 | </div> |
||||
248 | |||||
249 | |||||
250 | <?php if( yourls_do_log_redirect() ) { ?> |
||||
251 | <div id="stat_tab_stats" class="tab"> |
||||
252 | <h2><?php yourls_e( 'Traffic statistics'); ?></h2> |
||||
253 | |||||
254 | <?php yourls_do_action( 'pre_yourls_info_stats', $keyword ); ?> |
||||
255 | |||||
256 | <?php if ( $list_of_days ) { ?> |
||||
257 | |||||
258 | <?php |
||||
259 | $graphs = array( |
||||
260 | '24' => yourls__( 'Last 24 hours' ), |
||||
261 | '7' => yourls__( 'Last 7 days' ), |
||||
262 | '30' => yourls__( 'Last 30 days' ), |
||||
263 | 'all'=> yourls__( 'All time' ), |
||||
264 | ); |
||||
265 | |||||
266 | // Which graph to generate ? |
||||
267 | $do_all = $do_30 = $do_7 = $do_24 = false; |
||||
268 | $hits_all = array_sum( $list_of_days ); |
||||
269 | $hits_30 = array_sum( array_slice( $list_of_days, -30 ) ); |
||||
270 | $hits_7 = array_sum( array_slice( $list_of_days, -7 ) ); |
||||
271 | $hits_24 = array_sum( $last_24h ); |
||||
272 | if( $hits_all > 0 ) |
||||
273 | $do_all = true; // graph for all days range |
||||
274 | if( $hits_30 > 0 && count( array_slice( $list_of_days, -30 ) ) == 30 ) |
||||
275 | $do_30 = true; // graph for last 30 days |
||||
276 | if( $hits_7 > 0 && count( array_slice( $list_of_days, -7 ) ) == 7 ) |
||||
277 | $do_7 = true; // graph for last 7 days |
||||
278 | if( $hits_24 > 0 ) |
||||
279 | $do_24 = true; // graph for last 24 hours |
||||
280 | |||||
281 | // Which graph to display ? |
||||
282 | $display_all = $display_30 = $display_7 = $display_24 = false; |
||||
283 | if( $do_24 ) { |
||||
284 | $display_24 = true; |
||||
285 | } elseif ( $do_7 ) { |
||||
286 | $display_7 = true; |
||||
287 | } elseif ( $do_30 ) { |
||||
288 | $display_30 = true; |
||||
289 | } elseif ( $do_all ) { |
||||
290 | $display_all = true; |
||||
291 | } |
||||
292 | ?> |
||||
293 | |||||
294 | <table border="0" cellspacing="2"> |
||||
295 | <tr> |
||||
296 | <td valign="top"> |
||||
297 | <ul id="stats_lines" class="toggle_display stat_line"> |
||||
298 | <?php |
||||
299 | if( $do_24 == true ) |
||||
0 ignored issues
–
show
|
|||||
300 | echo '<li><a href="#stat_line_24">' . yourls__( 'Last 24 hours' ) . '</a>'; |
||||
301 | if( $do_7 == true ) |
||||
0 ignored issues
–
show
|
|||||
302 | echo '<li><a href="#stat_line_7">' . yourls__( 'Last 7 days' ) . '</a>'; |
||||
303 | if( $do_30 == true ) |
||||
0 ignored issues
–
show
|
|||||
304 | echo '<li><a href="#stat_line_30">' . yourls__( 'Last 30 days' ) . '</a>'; |
||||
305 | if( $do_all == true ) |
||||
0 ignored issues
–
show
|
|||||
306 | echo '<li><a href="#stat_line_all">' . yourls__( 'All time' ) . '</a>'; |
||||
307 | ?> |
||||
308 | </ul> |
||||
309 | <?php |
||||
310 | // Generate, and display if applicable, each needed graph |
||||
311 | foreach( $graphs as $graph => $graphtitle ) { |
||||
312 | if( ${'do_'.$graph} == true ) { |
||||
313 | $display = ( ${'display_'.$graph} === true ? 'display:block' : 'display:none' ); |
||||
314 | echo "<div id='stat_line_$graph' class='stats_line line' style='$display'>"; |
||||
315 | echo '<h3>' . yourls_s( 'Number of hits : %s' , $graphtitle ) . '</h3>'; |
||||
316 | switch( $graph ) { |
||||
317 | case '24': |
||||
318 | yourls_stats_line( $last_24h, "stat_line_$graph" ); |
||||
319 | break; |
||||
320 | |||||
321 | case '7': |
||||
322 | case '30': |
||||
323 | $slice = array_slice( $list_of_days, intval( $graph ) * -1 ); |
||||
324 | yourls_stats_line( $slice, "stat_line_$graph" ); |
||||
325 | unset( $slice ); |
||||
326 | break; |
||||
327 | |||||
328 | case 'all': |
||||
329 | yourls_stats_line( $list_of_days, "stat_line_$graph" ); |
||||
330 | break; |
||||
331 | } |
||||
332 | echo "</div>\n"; |
||||
333 | } |
||||
334 | } ?> |
||||
335 | |||||
336 | </td> |
||||
337 | <td valign="top"> |
||||
338 | <h3><?php yourls_e( 'Historical click count' ); ?></h3> |
||||
339 | <?php |
||||
340 | $timestamp = strtotime( $timestamp ); |
||||
341 | $ago = round( (date('U') - $timestamp) / (24* 60 * 60 ) ); |
||||
342 | if( $ago <= 1 ) { |
||||
343 | $daysago = ''; |
||||
344 | } else { |
||||
345 | $daysago = ' (' . sprintf( yourls_n( 'about 1 day ago', 'about %s days ago', $ago ), $ago ) . ')'; |
||||
0 ignored issues
–
show
$ago of type double is incompatible with the type integer expected by parameter $number of yourls_n() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
346 | } |
||||
347 | ?> |
||||
348 | <p><?php echo /* //translators: eg Short URL created on March 23rd 1972 */ yourls_s( 'Short URL created on %s', yourls_date_i18n( yourls_get_datetime_format("F j, Y @ g:i a"), yourls_get_timestamp( $timestamp ) ) ) . $daysago; ?></p> |
||||
349 | <div class="wrap_unfloat"> |
||||
350 | <ul class="no_bullet toggle_display stat_line" id="historical_clicks"> |
||||
351 | <?php |
||||
352 | foreach( $graphs as $graph => $graphtitle ) { |
||||
353 | if ( ${'do_'.$graph} ) { |
||||
354 | $link = "<a href='#stat_line_$graph'>$graphtitle</a>"; |
||||
355 | } else { |
||||
356 | $link = $graphtitle; |
||||
357 | } |
||||
358 | $stat = ''; |
||||
359 | if( ${'do_'.$graph} ) { |
||||
360 | switch( $graph ) { |
||||
361 | case '7': |
||||
362 | case '30': |
||||
363 | $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / intval( $graph ) ) * 100 ) / 100 ); |
||||
364 | break; |
||||
365 | case '24': |
||||
366 | $stat = yourls_s( '%s per hour', round( ( ${'hits_'.$graph} / 24 ) * 100 ) / 100 ); |
||||
367 | break; |
||||
368 | case 'all': |
||||
369 | if( $ago > 0 ) |
||||
370 | $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / $ago ) * 100 ) / 100 ); |
||||
371 | } |
||||
372 | } |
||||
373 | $hits = sprintf( yourls_n( '%s hit', '%s hits', ${'hits_'.$graph} ), ${'hits_'.$graph} ); |
||||
374 | echo "<li><span class='historical_link'>$link</span> <span class='historical_count'>$hits</span> $stat</li>\n"; |
||||
375 | } |
||||
376 | ?> |
||||
377 | </ul> |
||||
378 | </div> |
||||
379 | |||||
380 | <h3><?php yourls_e( 'Best day' ); ?></h3> |
||||
381 | <?php |
||||
382 | $best = yourls_stats_get_best_day( $list_of_days ); |
||||
383 | $best_time['day'] = date( "d", strtotime( $best['day'] ) ); |
||||
384 | $best_time['month'] = date( "m", strtotime( $best['day'] ) ); |
||||
385 | $best_time['year'] = date( "Y", strtotime( $best['day'] ) ); |
||||
386 | ?> |
||||
387 | <p><?php echo sprintf( /* //translators: eg. 43 hits on January 1, 1970 */ yourls_n( '<strong>%1$s</strong> hit on %2$s', '<strong>%1$s</strong> hits on %2$s', $best['max'] ), $best['max'], yourls_date_i18n( yourls_get_date_format("F j, Y"), strtotime( $best['day'] ) ) ); ?>. |
||||
388 | <a href="" class='details hide-if-no-js' id="more_clicks"><?php yourls_e( 'Click for more details' ); ?></a></p> |
||||
389 | <ul id="details_clicks" style="display:none"> |
||||
390 | <?php |
||||
391 | foreach( $dates as $year=>$months ) { |
||||
392 | $css_year = ( $year == $best_time['year'] ? 'best_year' : '' ); |
||||
393 | if( count( $list_of_years ) > 1 ) { |
||||
394 | $li = "<a href='' class='details' id='more_year$year'>" . yourls_s( 'Year %s', $year ) . '</a>'; |
||||
395 | $display = 'none'; |
||||
396 | } else { |
||||
397 | $li = yourls_s( 'Year %s', $year ); |
||||
398 | $display = 'block'; |
||||
399 | } |
||||
400 | echo "<li><span class='$css_year'>$li</span>"; |
||||
401 | echo "<ul style='display:$display' id='details_year$year'>"; |
||||
402 | foreach( $months as $month=>$days ) { |
||||
403 | $css_month = ( ( $month == $best_time['month'] && ( $css_year == 'best_year' ) ) ? 'best_month' : '' ); |
||||
404 | $monthname = yourls_date_i18n( "F", mktime( 0, 0, 0, $month, 1 ) ); |
||||
405 | if( count( $list_of_months ) > 1 ) { |
||||
406 | $li = "<a href='' class='details' id='more_month$year$month'>$monthname</a>"; |
||||
407 | $display = 'none'; |
||||
408 | } else { |
||||
409 | $li = "$monthname"; |
||||
410 | $display = 'block'; |
||||
411 | } |
||||
412 | echo "<li><span class='$css_month'>$li</span>"; |
||||
413 | echo "<ul style='display:$display' id='details_month$year$month'>"; |
||||
414 | foreach( $days as $day=>$hits ) { |
||||
415 | $class = ( $hits == $best['max'] ? 'class="bestday"' : '' ); |
||||
416 | echo "<li $class>$day: " . sprintf( yourls_n( '1 hit', '%s hits', $hits ), $hits ) ."</li>\n"; |
||||
417 | } |
||||
418 | echo "</ul>\n"; |
||||
419 | } |
||||
420 | echo "</ul>\n"; |
||||
421 | } |
||||
422 | ?> |
||||
423 | </ul> |
||||
424 | |||||
425 | </td> |
||||
426 | |||||
427 | </tr> |
||||
428 | </table> |
||||
429 | |||||
430 | <?php yourls_do_action( 'post_yourls_info_stats', $keyword ); ?> |
||||
431 | |||||
432 | <?php } else { |
||||
433 | echo '<p>' . yourls__( 'No traffic yet. Get some clicks first!' ) . '</p>'; |
||||
434 | } ?> |
||||
435 | </div> |
||||
436 | |||||
437 | |||||
438 | <div id="stat_tab_location" class="tab"> |
||||
439 | <h2><?php yourls_e( 'Traffic location' ); ?></h2> |
||||
440 | |||||
441 | <?php yourls_do_action( 'pre_yourls_info_location', $keyword ); ?> |
||||
442 | |||||
443 | <?php if ( $countries ) { ?> |
||||
444 | |||||
445 | <table border="0" cellspacing="2"> |
||||
446 | <tr> |
||||
447 | <td valign="top"> |
||||
448 | <h3><?php yourls_e( 'Top 5 countries' ); ?></h3> |
||||
449 | <?php yourls_stats_pie( $countries, 5, '340x220', 'stat_tab_location_pie' ); ?> |
||||
450 | <p><a href="" class='details hide-if-no-js' id="more_countries"><?php yourls_e( 'Click for more details' ); ?></a></p> |
||||
451 | <ul id="details_countries" style="display:none" class="no_bullet"> |
||||
452 | <?php |
||||
453 | foreach( $countries as $code=>$count ) { |
||||
454 | echo "<li><img src='".yourls_geo_get_flag( $code )."' /> $code (".yourls_geo_countrycode_to_countryname( $code ) . ') : ' . sprintf( yourls_n( '1 hit', '%s hits', $count ), $count ) . "</li>\n"; |
||||
455 | } |
||||
456 | ?> |
||||
457 | </ul> |
||||
458 | |||||
459 | </td> |
||||
460 | <td valign="top"> |
||||
461 | <h3><?php yourls_e( 'Overall traffic' ); ?></h3> |
||||
462 | <?php yourls_stats_countries_map( $countries, 'stat_tab_location_map' ); ?> |
||||
463 | </td> |
||||
464 | </tr> |
||||
465 | </table> |
||||
466 | |||||
467 | <?php yourls_do_action( 'post_yourls_info_location', $keyword ); ?> |
||||
468 | |||||
469 | <?php } else { |
||||
470 | echo '<p>' . yourls__( 'No country data.' ) . '</p>'; |
||||
471 | } ?> |
||||
472 | </div> |
||||
473 | |||||
474 | |||||
475 | <div id="stat_tab_sources" class="tab"> |
||||
476 | <h2><?php yourls_e( 'Traffic sources' ); ?></h2> |
||||
477 | |||||
478 | <?php yourls_do_action( 'pre_yourls_info_sources', $keyword ); ?> |
||||
479 | |||||
480 | <?php if ( $referrers ) { ?> |
||||
481 | |||||
482 | <table border="0" cellspacing="2"> |
||||
483 | <tr> |
||||
484 | <td valign="top"> |
||||
485 | <h3><?php yourls_e( 'Referrer shares' ); ?></h3> |
||||
486 | <?php |
||||
487 | if ( $number_of_sites > 1 ) |
||||
488 | $referrer_sort[ yourls__( 'Others' ) ] = count( $referrers ); |
||||
489 | yourls_stats_pie( $referrer_sort, 5, '440x220', 'stat_tab_source_ref' ); |
||||
490 | unset( $referrer_sort[yourls__('Others')] ); |
||||
491 | ?> |
||||
492 | <h3><?php yourls_e( 'Referrers' ); ?></h3> |
||||
493 | <ul class="no_bullet"> |
||||
494 | <?php |
||||
495 | $i = 0; |
||||
496 | foreach( $referrer_sort as $site => $count ) { |
||||
497 | $i++; |
||||
498 | $favicon = yourls_get_favicon_url( $site ); |
||||
499 | echo "<li class='sites_list'><img src='$favicon' class='fix_images'/> $site: <strong>$count</strong> <a href='' class='details hide-if-no-js' id='more_url$i'>" . yourls__( '(details)' ) . "</a></li>\n"; |
||||
500 | echo "<ul id='details_url$i' style='display:none'>"; |
||||
501 | foreach( $referrers[$site] as $url => $count ) { |
||||
0 ignored issues
–
show
|
|||||
502 | echo "<li>"; yourls_html_link($url); echo ": <strong>$count</strong></li>\n"; |
||||
503 | } |
||||
504 | echo "</ul>\n"; |
||||
505 | unset( $referrers[$site] ); |
||||
506 | } |
||||
507 | // Any referrer left? Group in "various" |
||||
508 | if ( $referrers ) { |
||||
509 | echo "<li id='sites_various'>" . yourls__( 'Various:' ) . " <strong>". count( $referrers ). "</strong> <a href='' class='details hide-if-no-js' id='more_various'>" . yourls__( '(details)' ) . "</a></li>\n"; |
||||
510 | echo "<ul id='details_various' style='display:none'>"; |
||||
511 | foreach( $referrers as $url ) { |
||||
512 | echo "<li>"; yourls_html_link(key($url)); echo ": 1</li>\n"; |
||||
513 | } |
||||
514 | echo "</ul>\n"; |
||||
515 | } |
||||
516 | ?> |
||||
517 | |||||
518 | </ul> |
||||
519 | |||||
520 | </td> |
||||
521 | |||||
522 | <td valign="top"> |
||||
523 | <h3><?php yourls_e( 'Direct vs Referrer Traffic' ); ?></h3> |
||||
524 | <?php |
||||
525 | yourls_stats_pie( array( yourls__( 'Direct' ) => $direct, yourls__( 'Referrers' ) => $notdirect ), 5, '440x220', 'stat_tab_source_direct' ); |
||||
526 | ?> |
||||
527 | <p><?php yourls_e( 'Direct traffic:' ); echo ' ' . sprintf( yourls_n( '<strong>%s</strong> hit', '<strong>%s</strong> hits', $direct ), $direct ); ?> </p> |
||||
528 | <p><?php yourls_e( 'Referrer traffic:' ); echo ' ' . sprintf( yourls_n( '<strong>%s</strong> hit', '<strong>%s</strong> hits', $notdirect ), $notdirect ); ?> </p> |
||||
529 | |||||
530 | </td> |
||||
531 | </tr> |
||||
532 | </table> |
||||
533 | |||||
534 | <?php yourls_do_action( 'post_yourls_info_sources', $keyword ); ?> |
||||
535 | |||||
536 | <?php } else { |
||||
537 | echo '<p>' . yourls__( 'No referrer data.' ) . '</p>'; |
||||
538 | } ?> |
||||
539 | |||||
540 | </div> |
||||
541 | |||||
542 | <?php } // endif do log redirect ?> |
||||
543 | |||||
544 | |||||
545 | <div id="stat_tab_share" class="tab"> |
||||
546 | <h2><?php yourls_e( 'Share' ); ?></h2> |
||||
547 | |||||
548 | <?php yourls_share_box( $longurl, yourls_link($keyword), $title, '', '<h3>' . yourls__( 'Short link' ) . '</h3>', '<h3>' . yourls__( 'Quick Share' ) . '</h3>'); ?> |
||||
549 | |||||
550 | </div> |
||||
551 | |||||
552 | </div> |
||||
553 | |||||
554 | |||||
555 | <?php yourls_html_footer(); ?> |
||||
556 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.