[ 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  yourls_html_head( 'infos', yourls_s( 'Statistics for %s', YOURLS_SITE.'/'.$keyword ) );
 213  yourls_html_logo();
 214  yourls_html_menu();
 215  ?>
 216  
 217  <h2 id="informations"><?php echo yourls_esc_html( $title ); ?></h2>
 218  
 219  <h3><span class="label"><?php yourls_e( 'Short URL'); ?>:</span> <img src="<?php yourls_get_yourls_favicon_url() ?>"/>
 220  <?php if( $aggregate ) {
 221      $i = 0;
 222      foreach( $keyword_list as $k ) {
 223          $i++;
 224          if ( $i == 1 ) {
 225              yourls_html_link( yourls_link($k) );
 226          } else {
 227              yourls_html_link( yourls_link($k), "/$k" );
 228          }
 229          if ( $i < count( $keyword_list ) )
 230              echo ' + ';
 231      }
 232  } else {
 233      yourls_html_link( yourls_link($keyword) );
 234      if( isset( $keyword_list ) && count( $keyword_list ) > 1 )
 235          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>';
 236  } ?></h3>
 237  <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>
 238  
 239  <div id="tabs">
 240      <div class="wrap_unfloat">
 241      <ul id="headers" class="toggle_display stat_tab">
 242          <?php if( yourls_do_log_redirect() ) { ?>
 243          <li class="selected"><a href="#stat_tab_stats"><h2><?php yourls_e( 'Traffic statistics'); ?></h2></a></li>
 244          <li><a href="#stat_tab_location"><h2><?php yourls_e( 'Traffic location'); ?></h2></a></li>
 245          <li><a href="#stat_tab_sources"><h2><?php yourls_e( 'Traffic sources'); ?></h2></a></li>
 246          <?php } ?>
 247          <li><a href="#stat_tab_share"><h2><?php yourls_e( 'Share'); ?></h2></a></li>
 248      </ul>
 249      </div>
 250  
 251  
 252  <?php if( yourls_do_log_redirect() ) { ?>
 253      <div id="stat_tab_stats" class="tab">
 254          <h2><?php yourls_e( 'Traffic statistics'); ?></h2>
 255  
 256          <?php yourls_do_action( 'pre_yourls_info_stats', $keyword ); ?>
 257  
 258          <?php if ( $list_of_days ) { ?>
 259  
 260              <?php
 261              $graphs = array(
 262                  '24' => yourls__( 'Last 24 hours' ),
 263                  '7'  => yourls__( 'Last 7 days' ),
 264                  '30' => yourls__( 'Last 30 days' ),
 265                  'all'=> yourls__( 'All time' ),
 266              );
 267  
 268              // Which graph to generate ?
 269              $do_all = $do_30 = $do_7 = $do_24 = false;
 270              $hits_all = array_sum( $list_of_days );
 271              $hits_30  = array_sum( array_slice( $list_of_days, -30 ) );
 272              $hits_7   = array_sum( array_slice( $list_of_days, -7 ) );
 273              $hits_24  = array_sum( $last_24h );
 274              if( $hits_all > 0 )
 275                  $do_all = true; // graph for all days range
 276              if( $hits_30 > 0 && count( array_slice( $list_of_days, -30 ) ) == 30 )
 277                  $do_30 = true; // graph for last 30 days
 278              if( $hits_7 > 0 && count( array_slice( $list_of_days, -7 ) ) == 7 )
 279                  $do_7 = true; // graph for last 7 days
 280              if( $hits_24 > 0 )
 281                  $do_24 = true; // graph for last 24 hours
 282  
 283              // Which graph to display ?
 284              $display_all = $display_30 = $display_7 = $display_24 = false;
 285              if( $do_24 ) {
 286                  $display_24 = true;
 287              } elseif ( $do_7 ) {
 288                  $display_7 = true;
 289              } elseif ( $do_30 ) {
 290                  $display_30 = true;
 291              } elseif ( $do_all ) {
 292                  $display_all = true;
 293              }
 294              ?>
 295  
 296              <table border="0" cellspacing="2">
 297              <tr>
 298                  <td valign="top">
 299                  <ul id="stats_lines" class="toggle_display stat_line">
 300                  <?php
 301                  if( $do_24 == true )
 302                      echo '<li><a href="#stat_line_24">' . yourls__( 'Last 24 hours' ) . '</a>';
 303                  if( $do_7 == true )
 304                      echo '<li><a href="#stat_line_7">' . yourls__( 'Last 7 days' ) . '</a>';
 305                  if( $do_30 == true )
 306                      echo '<li><a href="#stat_line_30">' . yourls__( 'Last 30 days' ) . '</a>';
 307                  if( $do_all == true )
 308                      echo '<li><a href="#stat_line_all">' . yourls__( 'All time' ) . '</a>';
 309                  ?>
 310                  </ul>
 311                  <?php
 312                  // Generate, and display if applicable, each needed graph
 313                  foreach( $graphs as $graph => $graphtitle ) {
 314                      if( ${'do_'.$graph} == true ) {
 315                          $display = ( ${'display_'.$graph} === true ? 'display:block' : 'display:none' );
 316                          echo "<div id='stat_line_$graph' class='stats_line line' style='$display'>";
 317                          echo '<h3>' . yourls_s( 'Number of hits : %s' , $graphtitle ) . '</h3>';
 318                          switch( $graph ) {
 319                              case '24':
 320                                  yourls_stats_line( $last_24h, "stat_line_$graph" );
 321                                  break;
 322  
 323                              case '7':
 324                              case '30':
 325                                  $slice = array_slice( $list_of_days, intval( $graph ) * -1 );
 326                                  yourls_stats_line( $slice, "stat_line_$graph" );
 327                                  unset( $slice );
 328                                  break;
 329  
 330                              case 'all':
 331                                  yourls_stats_line( $list_of_days, "stat_line_$graph" );
 332                                  break;
 333                          }
 334                          echo "</div>\n";
 335                      }
 336                  } ?>
 337  
 338                  </td>
 339                  <td valign="top">
 340                  <h3><?php yourls_e( 'Historical click count' ); ?></h3>
 341                  <?php
 342                  $timestamp = strtotime( $timestamp );
 343                  $ago = round( (date('U') - $timestamp) / (24* 60 * 60 ) );
 344                  if( $ago <= 1 ) {
 345                      $daysago = '';
 346                  } else {
 347                      $daysago = ' (' . sprintf( yourls_n( 'about 1 day ago', 'about %s days ago', $ago ), $ago ) . ')';
 348                  }
 349                  ?>
 350                  <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>
 351                  <div class="wrap_unfloat">
 352                      <ul class="no_bullet toggle_display stat_line" id="historical_clicks">
 353                      <?php
 354                      foreach( $graphs as $graph => $graphtitle ) {
 355                          if ( ${'do_'.$graph} ) {
 356                              $link = "<a href='#stat_line_$graph'>$graphtitle</a>";
 357                          } else {
 358                              $link = $graphtitle;
 359                          }
 360                          $stat = '';
 361                          if( ${'do_'.$graph} ) {
 362                              switch( $graph ) {
 363                                  case '7':
 364                                  case '30':
 365                                      $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / intval( $graph ) ) * 100 ) / 100 );
 366                                      break;
 367                                  case '24':
 368                                      $stat = yourls_s( '%s per hour', round( ( ${'hits_'.$graph} / 24 ) * 100 ) / 100 );
 369                                      break;
 370                                  case 'all':
 371                                      if( $ago > 0 )
 372                                          $stat = yourls_s( '%s per day', round( ( ${'hits_'.$graph} / $ago ) * 100 ) / 100 );
 373                              }
 374                          }
 375                          $hits = sprintf( yourls_n( '%s hit', '%s hits', ${'hits_'.$graph} ), ${'hits_'.$graph} );
 376                          echo "<li><span class='historical_link'>$link</span> <span class='historical_count'>$hits</span> $stat</li>\n";
 377                      }
 378                      ?>
 379                      </ul>
 380                  </div>
 381  
 382                  <h3><?php yourls_e( 'Best day' ); ?></h3>
 383                  <?php
 384                  $best = yourls_stats_get_best_day( $list_of_days );
 385                  $best_time['day']   = date( "d", strtotime( $best['day'] ) );
 386                  $best_time['month'] = date( "m", strtotime( $best['day'] ) );
 387                  $best_time['year']  = date( "Y", strtotime( $best['day'] ) );
 388                  ?>
 389                  <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'] ) ) ); ?>.
 390                  <a href="" class='details hide-if-no-js' id="more_clicks"><?php yourls_e( 'Click for more details' ); ?></a></p>
 391                  <ul id="details_clicks" style="display:none">
 392                      <?php
 393                      foreach( $dates as $year=>$months ) {
 394                          $css_year = ( $year == $best_time['year'] ? 'best_year' : '' );
 395                          if( count( $list_of_years ) > 1 ) {
 396                              $li = "<a href='' class='details' id='more_year$year'>" . yourls_s( 'Year %s', $year ) . '</a>';
 397                              $display = 'none';
 398                          } else {
 399                              $li = yourls_s( 'Year %s', $year );
 400                              $display = 'block';
 401                          }
 402                          echo "<li><span class='$css_year'>$li</span>";
 403                          echo "<ul style='display:$display' id='details_year$year'>";
 404                          foreach( $months as $month=>$days ) {
 405                              $css_month = ( ( $month == $best_time['month'] && ( $css_year == 'best_year' ) ) ? 'best_month' : '' );
 406                              $monthname = yourls_date_i18n( "F", mktime( 0, 0, 0, $month, 1 ) );
 407                              if( count( $list_of_months ) > 1 ) {
 408                                  $li = "<a href='' class='details' id='more_month$year$month'>$monthname</a>";
 409                                  $display = 'none';
 410                              } else {
 411                                  $li = "$monthname";
 412                                  $display = 'block';
 413                              }
 414                              echo "<li><span class='$css_month'>$li</span>";
 415                              echo "<ul style='display:$display' id='details_month$year$month'>";
 416                                  foreach( $days as $day=>$hits ) {
 417                                      $class = ( $hits == $best['max'] ? 'class="bestday"' : '' );
 418                                      echo "<li $class>$day: " . sprintf( yourls_n( '1 hit', '%s hits', $hits ), $hits ) ."</li>\n";
 419                                  }
 420                              echo "</ul>\n";
 421                          }
 422                          echo "</ul>\n";
 423                      }
 424                      ?>
 425                  </ul>
 426  
 427                  </td>
 428  
 429              </tr>
 430              </table>
 431  
 432          <?php yourls_do_action( 'post_yourls_info_stats', $keyword ); ?>
 433  
 434          <?php } else {
 435              echo '<p>' . yourls__( 'No traffic yet. Get some clicks first!' ) . '</p>';
 436          } ?>
 437      </div>
 438  
 439  
 440      <div id="stat_tab_location" class="tab">
 441          <h2><?php yourls_e( 'Traffic location' ); ?></h2>
 442  
 443          <?php yourls_do_action( 'pre_yourls_info_location', $keyword ); ?>
 444  
 445          <?php if ( $countries ) { ?>
 446  
 447              <table border="0" cellspacing="2">
 448              <tr>
 449                  <td valign="top">
 450                      <h3><?php yourls_e( 'Top 5 countries' ); ?></h3>
 451                      <?php yourls_stats_pie( $countries, 5, '340x220', 'stat_tab_location_pie' ); ?>
 452                      <p><a href="" class='details hide-if-no-js' id="more_countries"><?php yourls_e( 'Click for more details' ); ?></a></p>
 453                      <ul id="details_countries" style="display:none" class="no_bullet">
 454                      <?php
 455                      foreach( $countries as $code=>$count ) {
 456                          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";
 457                      }
 458                      ?>
 459                      </ul>
 460  
 461                  </td>
 462                  <td valign="top">
 463                      <h3><?php yourls_e( 'Overall traffic' ); ?></h3>
 464                      <?php yourls_stats_countries_map( $countries, 'stat_tab_location_map' ); ?>
 465                  </td>
 466              </tr>
 467              </table>
 468  
 469          <?php yourls_do_action( 'post_yourls_info_location', $keyword ); ?>
 470  
 471          <?php } else {
 472              echo '<p>' . yourls__( 'No country data.' ) . '</p>';
 473          } ?>
 474      </div>
 475  
 476  
 477      <div id="stat_tab_sources" class="tab">
 478          <h2><?php yourls_e( 'Traffic sources' ); ?></h2>
 479  
 480          <?php yourls_do_action( 'pre_yourls_info_sources', $keyword ); ?>
 481  
 482          <?php if ( $referrers ) { ?>
 483  
 484              <table border="0" cellspacing="2">
 485              <tr>
 486                  <td valign="top">
 487                      <h3><?php yourls_e( 'Referrer shares' ); ?></h3>
 488                      <?php
 489                      if ( $number_of_sites > 1 )
 490                          $referrer_sort[ yourls__( 'Others' ) ] = count( $referrers );
 491                      yourls_stats_pie( $referrer_sort, 5, '440x220', 'stat_tab_source_ref' );
 492                      unset( $referrer_sort[yourls__('Others')] );
 493                      ?>
 494                      <h3><?php yourls_e( 'Referrers' ); ?></h3>
 495                      <ul class="no_bullet">
 496                          <?php
 497                          $i = 0;
 498                          foreach( $referrer_sort as $site => $count ) {
 499                              $i++;
 500                              $favicon = yourls_get_favicon_url( $site );
 501                              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";
 502                              echo "<ul id='details_url$i' style='display:none'>";
 503                              foreach( $referrers[$site] as $url => $count ) {
 504                                  echo "<li>"; yourls_html_link($url); echo ": <strong>$count</strong></li>\n";
 505                              }
 506                              echo "</ul>\n";
 507                              unset( $referrers[$site] );
 508                          }
 509                          // Any referrer left? Group in "various"
 510                          if ( $referrers ) {
 511                              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";
 512                              echo "<ul id='details_various' style='display:none'>";
 513                              foreach( $referrers as $url ) {
 514                                  echo "<li>"; yourls_html_link(key($url)); echo ": 1</li>\n";
 515                              }
 516                              echo "</ul>\n";
 517                          }
 518                          ?>
 519  
 520                      </ul>
 521  
 522                  </td>
 523  
 524                  <td valign="top">
 525                      <h3><?php yourls_e( 'Direct vs Referrer Traffic' ); ?></h3>
 526                      <?php
 527                      yourls_stats_pie( array( yourls__( 'Direct' ) => $direct, yourls__( 'Referrers' ) => $notdirect ), 5, '440x220', 'stat_tab_source_direct' );
 528                      ?>
 529                      <p><?php yourls_e( 'Direct traffic:' ); echo ' ' . sprintf( yourls_n( '<strong>%s</strong> hit', '<strong>%s</strong> hits', $direct ), $direct ); ?> </p>
 530                      <p><?php yourls_e( 'Referrer traffic:' ); echo ' ' . sprintf( yourls_n( '<strong>%s</strong> hit', '<strong>%s</strong> hits', $notdirect ), $notdirect ); ?> </p>
 531  
 532                  </td>
 533              </tr>
 534              </table>
 535  
 536          <?php yourls_do_action( 'post_yourls_info_sources', $keyword ); ?>
 537  
 538          <?php } else {
 539              echo '<p>' . yourls__( 'No referrer data.' ) . '</p>';
 540          } ?>
 541  
 542      </div>
 543  
 544  <?php } // endif do log redirect ?>
 545  
 546  
 547      <div id="stat_tab_share" class="tab">
 548          <h2><?php yourls_e( 'Share' ); ?></h2>
 549  
 550          <?php yourls_share_box( $longurl, yourls_link($keyword), $title, '', '<h3>' . yourls__( 'Short link' ) . '</h3>', '<h3>' . yourls__( 'Quick Share' ) . '</h3>'); ?>
 551  
 552      </div>
 553  
 554  </div>
 555  
 556  
 557  <?php yourls_html_footer(); ?>


Generated: Sat Jul 2 05:10:01 2022 Cross-referenced by PHPXref 0.7.1