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