]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-infos.php
Change in logic: now all request are handled by PHP in yourls-loader.php instead...
[Github/YOURLS.git] / yourls-infos.php
1 <?php\r
2 // TODO: make things cleaner. This file is an awful HTML/PHP soup.\r
3 \r
4 require_once( dirname(__FILE__).'/includes/load-yourls.php' );\r
5 require_once( YOURLS_INC.'/functions-infos.php' );\r
6 yourls_maybe_require_auth();\r
7 \r
8 // Variables should be defined in yourls-loader.php, if not try GET request (old behavior of yourls-infos.php)\r
9 if( !isset( $keyword ) && isset( $_GET['id'] ) )\r
10         $keyword = $_GET['id'];\r
11 if( !isset( $aggregate ) && isset( $_GET['all'] ) && $_GET['all'] == 1 && yourls_allow_duplicate_longurls() )\r
12         $aggregate = true;\r
13 \r
14 if ( !isset( $keyword ) )\r
15         yourls_redirect( YOURLS_SITE, 307 );\r
16         \r
17         var_dump( $aggregate );\r
18         \r
19 // Get basic infos for this shortened URL\r
20 $keyword = yourls_sanitize_string( $keyword );\r
21 $longurl = yourls_get_keyword_longurl( $keyword );\r
22 $clicks = yourls_get_keyword_clicks( $keyword );\r
23 $timestamp = yourls_get_keyword_timestamp( $keyword );\r
24 \r
25 if ( $longurl === false )\r
26         yourls_redirect( YOURLS_SITE, 307 );\r
27 \r
28 if( yourls_do_log_redirect() ) {\r
29 \r
30         // Duplicate keywords, if applicable\r
31         $keyword_list = yourls_get_duplicate_keywords( $longurl );\r
32                 \r
33         // Fetch all information from the table log\r
34         $table = YOURLS_DB_TABLE_LOG;\r
35 \r
36         if( $aggregate ) {\r
37                 $keywords = join( "', '", $keyword_list );\r
38                 // Fetch information for all keywords pointing to $longurl\r
39                 $hits = $ydb->get_results( "SELECT `shorturl`, `click_time`, `referrer`, `user_agent`, `country_code` FROM `$table` WHERE `shorturl` IN ( '$keywords' );" );\r
40         } else {\r
41                 // Fetch information for current keyword only\r
42                 $hits = $ydb->get_results( "SELECT `click_time`, `referrer`, `user_agent`, `country_code` FROM `$table` WHERE `shorturl` = '$keyword';" );\r
43         }\r
44         \r
45         $referrers = array();\r
46         $direct = $notdirect = 0;\r
47         $countries = array();\r
48         $dates = array();\r
49         $list_of_days = array();\r
50         $list_of_months = array();\r
51         $list_of_years = array();\r
52         $last_24h = array();\r
53 \r
54         // Loop through all results and build list of referrers, countries and hits per day\r
55         foreach( (array)$hits as $hit ) {\r
56                 extract( (array)$hit );\r
57 \r
58                 if ( isset( $country_code ) && $country_code ) {\r
59                         if( !array_key_exists( $country_code, $countries ) )\r
60                                 $countries[$country_code] = 0;\r
61                         $countries[$country_code]++;\r
62                 }\r
63                 \r
64                 if( isset( $referrer ) ) {\r
65                         if ( $referrer == 'direct' ) {\r
66                                 $direct++;\r
67                         } else {\r
68                                 $notdirect++;\r
69                                 $host = yourls_get_domain( $referrer );\r
70                                 if( !array_key_exists( $host, $referrers ) )\r
71                                         $referrers[$host] = array( );\r
72                                 if( !array_key_exists( $referrer, $referrers[$host] ) )\r
73                                         $referrers[$host][$referrer] = 0;\r
74                                 $referrers[$host][$referrer]++;\r
75                         }\r
76                 }\r
77                 \r
78                 if( isset( $click_time ) ) {\r
79                         $now = intval( date('U') );\r
80 \r
81                         preg_match('/(\d+)-(\d+)-(\d+)\s(\d+):(\d+):(\d+)/', $click_time, $matches);\r
82                         list( $temp, $year, $month, $day, $hour, $min, $sec ) = $matches;\r
83                         unset( $matches );\r
84                         \r
85                         // Build array of $dates[$year][$month][$day] = number of clicks\r
86                         if( !array_key_exists( $year, $dates ) )\r
87                                 $dates[$year] = array();\r
88                         if( !array_key_exists( $month, $dates[$year] ) )\r
89                                 $dates[$year][$month] = array();\r
90                         if( !array_key_exists( $day, $dates[$year][$month] ) )\r
91                                 $dates[$year][$month][$day] = 0;\r
92                         $dates[$year][$month][$day]++;\r
93                         \r
94                         // Build array of last 24 hours $last_24h[$hour] = number of click\r
95                         $then = strtotime( $click_time);\r
96                         if( ( $now >= $then ) && ( ( $now - $then ) < ( 24 * 60 * 60 ) ) ) {\r
97                                 $year = sprintf( "%02d", substr( $year, -1, 2 ) ); // 2009 -> 09\r
98                                 $diff = $now - strtotime( $click_time);\r
99                                 if( !array_key_exists( "$year-$month-$day-$hour", $last_24h ) )\r
100                                         $last_24h["$year-$month-$day-$hour"] = 0;\r
101                                 $last_24h["$year-$month-$day-$hour"]++;\r
102                         }\r
103                 }\r
104         }\r
105 \r
106 \r
107         // Sort dates, chronologically from [2007][12][24] to [2009][02][19]\r
108         ksort( $dates );\r
109         foreach( $dates as $year=>$months ) {\r
110                 ksort( $dates[$year] );\r
111                 foreach( $months as $month=>$day ) {\r
112                         ksort( $dates[$year][$month] );\r
113                 }\r
114         }\r
115 \r
116         // Get $list_of_days, $list_of_months, $list_of_years\r
117         if( $dates ) {\r
118                 extract( yourls_build_list_of_days( $dates ) );\r
119 \r
120                 // If the $last_24h doesn't have all the hours, insert missing hours with value 0\r
121                 for ($i = 23; $i >= 0; $i--) {\r
122                         $h = date('y-m-d-H', $now - ($i * 60 * 60) );\r
123                         if( !array_key_exists( $h, $last_24h ) ) {\r
124                                 $last_24h[$h] = 0;\r
125                         }\r
126                 }\r
127                 ksort( $last_24h );\r
128         }\r
129 \r
130         // Sort countries, most frequent first\r
131         if ( $countries )\r
132                 arsort( $countries );\r
133 \r
134         // Sort referrers. $referrer_sort is a array of most frequent domains\r
135         arsort( $referrers );\r
136         $referrer_sort = array();\r
137         $number_of_sites = count( array_keys( $referrers ) );\r
138         foreach( $referrers as $site => $urls ) {\r
139                 if( count($urls) > 1 || $number_of_sites == 1 )\r
140                         $referrer_sort[$site] = array_sum( $urls );\r
141         }\r
142         arsort($referrer_sort);\r
143 \r
144 \r
145         /**\r
146         echo "<pre>";\r
147         echo "referrers: "; print_r( $referrers );\r
148         echo "referrer sort: "; print_r( $referrer_sort );\r
149         echo "direct: $direct\n";\r
150         echo "notdirect: $notdirect\n";\r
151         echo "dates: "; print_r( $dates );\r
152         echo "list of days: "; print_r( $list_of_days );\r
153         echo "list_of_months: "; print_r( $list_of_months );\r
154         echo "list_of_years: "; print_r( $list_of_years );\r
155         echo "last_24h: "; print_r( $last_24h );\r
156         //echo "countries: "; print_r( $countries );\r
157 \r
158         die();\r
159         /**/\r
160 \r
161 }\r
162 \r
163 yourls_html_head( 'infos' );\r
164 yourls_html_logo();\r
165 yourls_html_menu();\r
166 ?>\r
167 \r
168 <h2 id="informations">Information</h2>\r
169 \r
170 <h3>Short URL: <img src="<?php echo YOURLS_SITE; ?>/images/favicon.gif"/>\r
171 <?php if( $aggregate ) {\r
172         $i = 0;\r
173         foreach( $keyword_list as $k ) {\r
174                 $i++;\r
175                 if ( $i == 1 ) {\r
176                         yourls_html_link( yourls_link($k) );\r
177                 } else {\r
178                         yourls_html_link( yourls_link($k), "/$k" );\r
179                 }\r
180                 if ( $i < count( $keyword_list ) )\r
181                         echo ' + ';\r
182         }\r
183 } else {\r
184         yourls_html_link( yourls_link($keyword) );\r
185         if( count( $keyword_list ) > 1 )\r
186                 echo ' <a href="'. yourls_link($keyword).'+all" title="Aggregate stats for duplicate short URLs"><img src="' . YOURLS_SITE . '/images/chart_bar_add.png" border="0" /></a>';\r
187 } ?></h3>\r
188 <h3 id="longurl">Long URL: <img class="fix_images" src="<?php echo yourls_get_domain( $longurl, true );?>/favicon.ico"/> <?php yourls_html_link( $longurl, '', 'longurl' ); ?></h3>\r
189 \r
190 <div id="tabs">\r
191         <div class="wrap_unfloat">\r
192         <ul id="headers" class="toggle_display stat_tab">\r
193                 <?php if( yourls_do_log_redirect() ) { ?>\r
194                 <li class="selected"><a href="#stat_tab_stats"><h2>Traffic statistics</h2></a></li>\r
195                 <li><a href="#stat_tab_location"><h2>Traffic location</h2></a></li>\r
196                 <li><a href="#stat_tab_sources"><h2>Traffic sources</h2></a></li>\r
197                 <?php } ?>\r
198                 <li><a href="#stat_tab_share"><h2>Share</h2></a></li>\r
199         </ul>\r
200         </div>\r
201 \r
202                         \r
203 <?php if( yourls_do_log_redirect() ) { ?>\r
204         <div id="stat_tab_stats" class="tab">\r
205                 <h2>Traffic statistics</h2>\r
206                 \r
207                 <?php if ( $list_of_days ) { ?>\r
208                 \r
209                         <?php\r
210                         $graphs = array(\r
211                                 '24' => 'Last 24 hours',\r
212                                 '7'  => 'Last 7 days',\r
213                                 '30' => 'Last 30 days',\r
214                                 'all'=> 'All time'\r
215                         );\r
216                         \r
217                         // Which graph to generate ?\r
218                         $do_all = $do_30 = $do_7 = $do_24 = false;\r
219                         $hits_all = array_sum( $list_of_days );\r
220                         $hits_30  = array_sum( array_slice( $list_of_days, -30 ) );\r
221                         $hits_7   = array_sum( array_slice( $list_of_days, -7 ) );\r
222                         $hits_24  = array_sum( $last_24h );\r
223                         if( $hits_all > 0 )\r
224                                 $do_all = true; // graph for all days range\r
225                         if( $hits_30 > 0 && count( array_slice( $list_of_days, -30 ) ) == 30 )\r
226                                 $do_30 = true; // graph for last 30 days\r
227                         if( $hits_7 > 0 && count( array_slice( $list_of_days, -7 ) ) == 7 )\r
228                                 $do_7 = true; // graph for last 7 days\r
229                         if( $hits_24 > 0 )\r
230                                 $do_24 = true; // graph for last 24 hours\r
231                         \r
232                         // Which graph to display ?\r
233                         $display_all = $display_30 = $display_7 = $display_24 = false;\r
234                         if( $do_24 ) {\r
235                                 $display_24 = true;\r
236                         } elseif ( $do_7 ) {\r
237                                 $display_7 = true;\r
238                         } elseif ( $do_30 ) {\r
239                                 $display_30 = true;\r
240                         } elseif ( $do_all ) {\r
241                                 $display_all = true;\r
242                         }                               \r
243                         ?>\r
244 \r
245                         <table border="0" cellspacing="2">\r
246                         <tr>\r
247                                 <td valign="top">\r
248                                 <ul id="stats_lines" class="toggle_display stat_line">\r
249                                 <?php\r
250                                 if( $do_24 == true )\r
251                                         echo "<li><a href='#stat_line_24'>Last 24 hours</a>";\r
252                                 if( $do_7 == true )\r
253                                         echo "<li><a href='#stat_line_7'>Last 7 days</a>";\r
254                                 if( $do_30 == true )\r
255                                         echo "<li><a href='#stat_line_30'>Last 30 days</a>";\r
256                                 if( $do_all == true )\r
257                                         echo "<li><a href='#stat_line_all'>All time</a>";\r
258                                 ?>                              \r
259                                 </ul>\r
260                                 <?php\r
261                                 // Generate, and display if applicable, each needed graph\r
262                                 foreach( $graphs as $graph => $title ) {\r
263                                         if( ${'do_'.$graph} == true ) {\r
264                                                 $display = ( ${'display_'.$graph} === true ? 'display:block' : 'display:none' );\r
265                                                 echo "<div id='stat_line_$graph' class='stats_line line' style='$display'>";\r
266                                                 $labels_1 = $labels_2 = array();\r
267                                                 switch( $graph ) {\r
268                                                         case '24':\r
269                                                                 // each key of $last_24h is of type "yy-mm-dd-hh"\r
270                                                                 $first_key = current( array_keys( $last_24h ) );\r
271                                                                 $last_key = end( array_keys( $last_24h ) );\r
272                                                                 // Get "dd/mm" of first and last key\r
273                                                                 $first_label = preg_replace( '/\d\d-(\d\d)-(\d\d)-\d\d/', '$2/$1', $first_key );\r
274                                                                 $last_label = preg_replace( '/\d\d-(\d\d)-(\d\d)-\d\d/', '$2/$1', $last_key );\r
275                                                                 $labels_2 = array( $first_label, $last_label);\r
276                                                                 // Get hh of each key\r
277                                                                 foreach( $last_24h as $k=>$v ) {\r
278                                                                         $labels_1[] = end( explode( '-', $k ) ); // 'hh'\r
279                                                                 }\r
280                                                                 \r
281                                                                 echo "<h3>Number of hits : $title</h3>";\r
282                                                                 yourls_stats_line( $last_24h, $labels_1, $labels_2 );\r
283                                                                 break;\r
284 \r
285                                                         case '7':\r
286                                                         case '30':\r
287                                                                 // each key of $list_of_days is of type "yyyy-mm-dd"\r
288                                                                 $slice = array_slice( $list_of_days, intval( $graph ) * -1 );\r
289                                                                 foreach( $slice as $k=>$v ) {\r
290                                                                         // get "dd"\r
291                                                                         $labels_1[] = preg_replace( '/\d\d\d\d-\d\d-(\d\d)/', '$1', $k );\r
292                                                                 }\r
293                                                                 $first_key = current( array_keys( $slice ) );\r
294                                                                 $last_key = end( array_keys( $slice ) );\r
295                                                                 // Get "dd/mm" of first and last key\r
296                                                                 $first_label = preg_replace( '/\d\d\d\d-(\d\d)-(\d\d)/', '$2/$1', $first_key );\r
297                                                                 $last_label = preg_replace( '/\d\d\d\d-(\d\d)-(\d\d)/', '$2/$1', $last_key );\r
298                                                                 $labels_2 = array( $first_label, $last_label);\r
299                                                                 \r
300                                                                 echo "<h3>Number of hits : $title</h3>";\r
301                                                                 yourls_stats_line( $slice, $labels_1, $labels_2 );\r
302                                                                 unset( $slice );\r
303                                                                 break;\r
304 \r
305                                                         case 'all':\r
306                                                                 // get "yy-mm"\r
307                                                                 foreach( $list_of_days as $k=>$v ) {\r
308                                                                         $labels_1[] = preg_replace( '/\d\d(\d\d)-(\d\d)-\d\d/', '$1-$2', $k );\r
309                                                                 }\r
310                                                                 // take out duplicates\r
311                                                                 $labels_1 = array_unique( $labels_1 );\r
312                                                                 // now get "mm" only so we have all different month\r
313                                                                 foreach( $labels_1 as $k=>$v ) {\r
314                                                                         $labels_1[$k] = preg_replace( '/\d\d-(\d\d)/', '$1', $v );\r
315                                                                 }\r
316                                                                 \r
317                                                                 echo "<h3>Number of hits : $title</h3>";\r
318                                                                 $labels_1 = yourls_array_granularity( $labels_1, 30, false );\r
319                                                                 $labels_2 = yourls_array_granularity( $list_of_years, 30, false );\r
320                                                                 yourls_stats_line( $list_of_days, $labels_1, $labels_2 );\r
321                                                                 break;\r
322                                                 }\r
323                                                 echo "</div>\n";\r
324                                         }                       \r
325                                 } ?>\r
326                                 \r
327                                 </td>\r
328                                 <td valign="top">\r
329                                 <h3>Historical click count</h3>\r
330                                 <?php\r
331                                 $ago = round( (date('U') - strtotime($timestamp)) / (24* 60 * 60 ) );\r
332                                 if( $ago <= 1 ) {\r
333                                         $daysago = '';\r
334                                 } else {\r
335                                         $daysago = '(about '.$ago .' '.yourls_plural( ' day', $ago ).' ago)';\r
336                                 }\r
337                                 ?>\r
338                                 <p>Short URL created on <?php echo date("F j, Y @ g:i a", strtotime($timestamp)); ?> <?php echo $daysago; ?></p>\r
339                                 <div class="wrap_unfloat">\r
340                                         <ul class="no_bullet toggle_display stat_line" id="historical_clicks">\r
341                                         <?php\r
342                                         foreach( $graphs as $graph => $title ) {\r
343                                                 if ( ${'do_'.$graph} ) {\r
344                                                         $link = "<a href='#stat_line_$graph'>$title</a>";\r
345                                                 } else {\r
346                                                         $link = $title;\r
347                                                 }\r
348                                                 $stat = '';\r
349                                                 if( ${'do_'.$graph} ) {\r
350                                                         switch( $graph ) {\r
351                                                                 case '7':\r
352                                                                 case '30':\r
353                                                                         $stat = round( ( ${'hits_'.$graph} / intval( $graph ) ) * 100 ) / 100 . ' per day';\r
354                                                                         break;\r
355                                                                 case '24':\r
356                                                                         $stat = round( ( ${'hits_'.$graph} / 24 ) * 100 ) / 100 . ' per hour';\r
357                                                                         break;\r
358                                                                 case 'all':\r
359                                                                         if( $ago > 0 )\r
360                                                                                 $stat = round( ( ${'hits_'.$graph} / $ago ) * 100 ) / 100 . ' per day';\r
361                                                         }\r
362                                                 }\r
363                                                 $hits = yourls_plural( 'hit', ${'hits_'.$graph} );\r
364                                                 echo "<li><span class='historical_link'>$link</span> <span class='historical_count'>${'hits_'.$graph} $hits</span> $stat</li>\n";\r
365                                         }\r
366                                         ?>\r
367                                         </ul>\r
368                                 </div>\r
369                 \r
370                                 <h3>Best day</h3>\r
371                                 <?php $best = yourls_stats_get_best_day( $list_of_days ); ?>\r
372                                 <p><strong><?php echo $best['max'];?></strong> <?php echo yourls_plural( 'hit', $best['max'] ); ?> on <?php echo date("F j, Y", strtotime($best['day'])); ?>. \r
373                                 <a href="" class='details' id="more_clicks">Click for more details</a></p>\r
374                                 <ul id="details_clicks" style="display:none">\r
375                                         <?php\r
376                                         foreach( $dates as $year=>$months ) {\r
377                                                 if( count( $list_of_years ) > 1 ) {\r
378                                                         $li = "<a href='' class='details' id='more_year$year'>Year $year</a>";\r
379                                                         $display = 'none';\r
380                                                 } else {\r
381                                                         $li = "Year $year";\r
382                                                         $display = 'block';\r
383                                                 }\r
384                                                 echo "<li>$li";\r
385                                                 echo "<ul style='display:$display' id='details_year$year'>";\r
386                                                 foreach( $months as $month=>$days ) {\r
387                                                         $monthname = date("F", mktime(0, 0, 0, $month,1));\r
388                                                         if( count( $list_of_months ) > 1 ) {\r
389                                                                 $li = "<a href='' class='details' id='more_month$year$month'>$monthname</a>";\r
390                                                                 $display = 'none';\r
391                                                         } else {\r
392                                                                 $li = "$monthname";\r
393                                                                 $display = 'block';\r
394                                                         }\r
395                                                         echo "<li>$li";\r
396                                                         echo "<ul style='display:$display' id='details_month$year$month'>";\r
397                                                                 foreach( $days as $day=>$hits ) {\r
398                                                                         $class = ( $hits == $best['max'] ? 'class="bestday"' : '' );\r
399                                                                         echo "<li $class>$day: $hits". yourls_plural( ' hit', $hits) ."</li>\n";\r
400                                                                 }\r
401                                                         echo "</ul>\n";\r
402                                                 }\r
403                                                 echo "</ul>\n";\r
404                                         }\r
405                                         ?>\r
406                                 </ul>\r
407                                 \r
408                                 </td>\r
409                                 \r
410                         </tr>\r
411                         </table>\r
412 \r
413 \r
414                 \r
415                 <?php } else {\r
416                         echo "<p>No traffic yet. Get some clicks first!</p>";\r
417                 } ?>\r
418         </div>\r
419 \r
420 \r
421         <div id="stat_tab_location" class="tab">\r
422                 <h2>Traffic location</h2>\r
423                 \r
424                 <?php if ( $countries ) { ?>\r
425                         \r
426                         <table border="0" cellspacing="2">\r
427                         <tr>\r
428                                 <td valign="top">\r
429                                         <h3>Top 5 countries</h3>\r
430                                         <?php yourls_stats_pie( $countries, 5 ); ?>\r
431                                         <p><a href="" class='details' id="more_countries">Click for more details</a></p>\r
432                                         <ul id="details_countries" style="display:none" class="no_bullet">\r
433                                         <?php\r
434                                         foreach( $countries as $code=>$count ) {\r
435                                                 echo "<li><img src='".yourls_geo_get_flag( $code )."' /> $code (".yourls_geo_countrycode_to_countryname( $code ).") : $count ".yourls_plural('hit', $count)."</li>\n";\r
436                                         }               \r
437                                         ?>\r
438                                         </ul>\r
439 \r
440                                 </td>\r
441                                 <td valign="top">\r
442                                         <h3>Overall traffic</h3>\r
443                                         <?php yourls_stats_countries_map( $countries ); ?>\r
444                                 </td>\r
445                         </tr>\r
446                         </table>\r
447                 \r
448                 <?php } else {\r
449                         echo "<p>No country data.</p>";\r
450                 } ?>\r
451         </div>\r
452                                 \r
453                                 \r
454         <div id="stat_tab_sources" class="tab">\r
455                 <h2>Traffic Sources</h2>\r
456                 \r
457                 <?php if ( $referrers ) { ?>\r
458                         \r
459                         <table border="0" cellspacing="2">\r
460                         <tr>\r
461                                 <td valign="top">\r
462                                         <h3>Referrer shares</h3>\r
463                                         <?php\r
464                                         if ( $number_of_sites > 1 )\r
465                                                 $referrer_sort['Others'] = count( $referrers );\r
466                                         yourls_stats_pie( $referrer_sort, 5, '440x220', '902020,FF6060' );\r
467                                         unset( $referrer_sort['Others'] );\r
468                                         ?>\r
469                                         <h3>Referrers</h3>\r
470                                         <ul class="no_bullet">\r
471                                                 <?php\r
472                                                 $i = 0;\r
473                                                 foreach( $referrer_sort as $site => $count ) {\r
474                                                         $i++;\r
475                                                         echo "<li class='sites_list'><img src='http://$site/favicon.ico' class='fix_images'/> $site: <strong>$count</strong> <a href='' class='details' id='more_url$i'>(details)</a></li>\n";\r
476                                                         echo "<ul id='details_url$i' style='display:none'>";\r
477                                                         foreach( $referrers[$site] as $url => $count ) {\r
478                                                                 echo "<li>"; yourls_html_link($url); echo ": <strong>$count</strong></li>\n";\r
479                                                         }\r
480                                                         echo "</ul>\n";\r
481                                                         unset( $referrers[$site] );\r
482                                                 }\r
483                                                 // Any referrer left? Group in "various"\r
484                                                 if ( $referrers ) {\r
485                                                         echo "<li id='sites_various'>Various: <strong>". count( $referrers ). "</strong> <a href='' class='details' id='more_various'>(details)</a></li>\n";\r
486                                                         echo "<ul id='details_various' style='display:none'>";\r
487                                                         foreach( $referrers as $url ) {\r
488                                                                 echo "<li>"; yourls_html_link(key($url)); echo ": 1</li>\n";    \r
489                                                         }\r
490                                                         echo "</ul>\n";\r
491                                                 }\r
492                                                 ?>\r
493                                                 \r
494                                         </ul>\r
495                                 \r
496                                 </td>\r
497                                 \r
498                                 <td valign="top">\r
499                                         <h3>Direct vs Referrer Traffic</h3>\r
500                                         <?php\r
501                                         yourls_stats_pie( array('Direct'=>$direct, 'Referrers'=> $notdirect), 5, '440x220', '902020,FF6060' );\r
502                                         ?>\r
503                                         <p>Direct traffic: <strong><?php echo $direct; ?></strong> <?php echo yourls_plural( 'hit', $direct ); ?> </p>\r
504                                         <p>Referrer traffic: <strong><?php echo $notdirect; ?></strong> <?php echo yourls_plural( 'hit', $notdirect ); ?> </p>\r
505 \r
506                                 </td>\r
507                         </tr>\r
508                         </table>\r
509 \r
510                 <?php } else {\r
511                         echo "<p>No referrer data.</p>";\r
512                 } ?>\r
513                         \r
514         </div>\r
515 \r
516 <?php } // endif do log redirect ?>\r
517 \r
518 \r
519         <div id="stat_tab_share" class="tab">\r
520                 <h2>Share</h2>\r
521                 \r
522                 <?php yourls_share_box( $longurl, yourls_link($keyword), '', '', '<h3>Short link</h3>', '<h3>Quick Share</h3>'); ?>\r
523 \r
524         </div>\r
525         \r
526 </div>\r
527 \r
528 \r
529 <?php yourls_html_footer(); ?>\r