[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/ -> yourls-infos.php (source)

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


Generated: Wed Nov 5 05:10:36 2025 Cross-referenced by PHPXref 0.7.1