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