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