b2evolution PHP Cross Reference Blogging Systems

Source: /inc/sessions/views/_stats_refdomains.view.php - 213 lines - 7427 bytes - Summary - Text - Print

Description: This file implements the UI view for the User Agents stats. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI view for the User Agents stats.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * }}
  21   *
  22   * @package admin
  23   *
  24   * @version $Id: _stats_refdomains.view.php 6136 2014-03-08 07:59:48Z manuel $
  25   */
  26  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  27  
  28  /**
  29   * View funcs
  30   */
  31  require_once dirname(__FILE__).'/_stats_view.funcs.php';
  32  
  33  
  34  global $blog, $admin_url, $rsc_url, $current_User, $UserSettings;
  35  
  36  global $dtyp_normal, $dtyp_searcheng, $dtyp_aggregator, $dtyp_email, $dtyp_unknown;
  37  
  38  // For the referring domains list:
  39  param( 'dtyp_normal', 'integer', 0, true );
  40  param( 'dtyp_searcheng', 'integer', 0, true );
  41  param( 'dtyp_aggregator', 'integer', 0, true );
  42  param( 'dtyp_email', 'integer', 0, true );
  43  param( 'dtyp_unknown', 'integer', 0, true );
  44  
  45  if( !$dtyp_normal && !$dtyp_searcheng && !$dtyp_aggregator && !$dtyp_email && !$dtyp_unknown )
  46  {    // Set default status filters:
  47      $dtyp_normal = 1;
  48      $dtyp_searcheng = 1;
  49      $dtyp_aggregator = 1;
  50      $dtyp_email = 1;
  51      $dtyp_unknown = 1;
  52  }
  53  
  54  
  55  echo '<h2>'.T_('Referring domains').'</h2>';
  56  
  57  $SQL = new SQL();
  58  
  59  $selected_agnt_types = array();
  60  if( $dtyp_normal ) $selected_agnt_types[] = "'normal'";
  61  if( $dtyp_searcheng ) $selected_agnt_types[] = "'searcheng'";
  62  if( $dtyp_aggregator ) $selected_agnt_types[] = "'aggregator'";
  63  if( $dtyp_email ) $selected_agnt_types[] = "'email'";
  64  if( $dtyp_unknown ) $selected_agnt_types[] = "'unknown'";
  65  $SQL->WHERE( 'dom_type IN ( ' . implode( ', ', $selected_agnt_types ) . ' )' );
  66  
  67  // Exclude hits of type "self" and "admin":
  68  // TODO: fp>implement filter checkboxes, not a hardwired filter
  69  //$where_clause .= ' AND hit_referer_type NOT IN ( "self", "admin" )';
  70  
  71  if( !empty($blog) )
  72  {
  73      $SQL->WHERE_and( 'hit_blog_ID = ' . $blog );
  74  }
  75  
  76  $SQL->SELECT( 'SQL_NO_CACHE COUNT( hit_ID ) AS hit_count' );
  77  $SQL->FROM( 'T_basedomains LEFT OUTER JOIN T_hitlog ON dom_ID = hit_referer_dom_ID' );
  78  
  79  $total_hit_count = $DB->get_var( $SQL->get(), 0, 0, 'Get total hit count - referred hits only' );
  80  
  81  
  82  // Create result set:
  83  $SQL->SELECT( 'SQL_NO_CACHE dom_name, dom_status, dom_type, COUNT( hit_ID ) AS hit_count' );
  84  $SQL->GROUP_BY( 'dom_ID' );
  85  
  86  $CountSQL = new SQL();
  87  $CountSQL->SELECT( 'SQL_NO_CACHE COUNT( DISTINCT dom_ID )' );
  88  $CountSQL->FROM( $SQL->get_from( '' ) );
  89  $CountSQL->WHERE( $SQL->get_where( '' ) );
  90  
  91  $Results = new Results( $SQL->get(), 'refdom_', '---D', $UserSettings->get( 'results_per_page' ), $CountSQL->get() );
  92  
  93  /**
  94   * Callback to add filters on top of the result set
  95   *
  96   * @param Form
  97   */
  98  function filter_basedomains( & $Form )
  99  {
 100      global $blog, $dtyp_normal, $dtyp_searcheng, $dtyp_aggregator, $dtyp_unknown;
 101  
 102      $Form->checkbox( 'dtyp_normal', $dtyp_normal, T_('Regular sites') );
 103      $Form->checkbox( 'dtyp_searcheng', $dtyp_searcheng, T_('Search engines') );
 104      $Form->checkbox( 'dtyp_aggregator', $dtyp_aggregator, T_('Feed aggregators') );
 105      $Form->checkbox( 'dtyp_email', $dtyp_aggregator, T_('Email domains') );
 106      $Form->checkbox( 'dtyp_unknown', $dtyp_unknown, T_('Unknown') );
 107  }
 108  $Results->filter_area = array(
 109      'callback' => 'filter_basedomains',
 110      'url_ignore' => 'results_refdom_page,dtyp_normal,dtyp_searcheng,dtyp_aggregator,dtyp_unknown',    // ignore page param and checkboxes
 111      'presets' => array(
 112              'browser' => array( T_('Regular'), '?ctrl=stats&amp;tab=domains&amp;dtyp_normal=1&amp;blog='.$blog ),
 113              'robot'   => array( T_('Search engines'), '?ctrl=stats&amp;tab=domains&amp;dtyp_searcheng=1&amp;blog='.$blog ),
 114              'rss'     => array( T_('Aggregators'), '?ctrl=stats&amp;tab=domains&amp;dtyp_aggregator=1&amp;blog='.$blog ),
 115              'email'   => array( T_('Email'), '?ctrl=stats&amp;tab=domains&amp;dtyp_email=1&amp;blog='.$blog ),
 116              'unknown' => array( T_('Unknown'), '?ctrl=stats&amp;tab=domains&amp;dtyp_unknown=1&amp;blog='.$blog ),
 117              'all'     => array( T_('All'), '?ctrl=stats&amp;tab=domains&amp;dtyp_normal=1&amp;dtyp_searcheng=1&amp;dtyp_aggregator=1&amp;dtyp_unknown=1&amp;blog='.$blog ),
 118          )
 119      );
 120  
 121  
 122  $Results->title = T_('Referring domains').get_manual_link('referring-domains-tab');
 123  
 124  $Results->cols[] = array(
 125                          'th' => T_('Domain name'),
 126                          'order' => 'dom_name',
 127                          'td' => '$dom_name$',
 128                          'total' => '<strong>'.T_('Global total').'</strong>',
 129                      );
 130  
 131  if( $current_User->check_perm( 'stats', 'edit' ) )
 132  {
 133      $Results->cols[] = array(
 134                              'th' => T_('Type'),
 135                              'order' => 'dom_type',
 136                              'td_class' => 'dom_type_edit',
 137                              'td' => '<a href="#" rel="$dom_type$">%stats_dom_type_title( #dom_type# )%</a>',
 138                              'total' => '',
 139                          );
 140  }
 141  else
 142  {
 143      $Results->cols[] = array(
 144                              'th' => T_('Type'),
 145                              'order' => 'dom_type',
 146                              'td_class' => 'dom_type_edit',
 147                              'td' => '%stats_dom_type_title( #dom_type# )%',
 148                              'total' => '',
 149                          );
 150  }
 151  $Results->cols[] = array(
 152                          'th' => T_('Status'),
 153                          'order' => 'dom_status',
 154                          'td' => '$dom_status$',
 155                          'total' => '',
 156                      );
 157  
 158  $Results->cols[] = array(
 159                          'th' => T_('Hit count'),
 160                          'order' => 'hit_count',
 161                          'td_class' => 'right',
 162                          'total_class' => 'right',
 163                          'td' => '$hit_count$',
 164                          'total' => $total_hit_count,
 165                      );
 166  
 167  $Results->cols[] = array(
 168                          'th' => T_('Hit %'),
 169                          'order' => 'hit_count',
 170                          'td_class' => 'right',
 171                          'total_class' => 'right',
 172                          'td' => '%percentage( #hit_count#, '.$total_hit_count.' )%',
 173                          'total' => '%percentage( 100, 100 )%',
 174                      );
 175  
 176  // Display results:
 177  $Results->display();
 178  
 179  if( $current_User->check_perm( 'stats', 'edit' ) )
 180  {
 181  ?>
 182  <script type="text/javascript">
 183      jQuery(document).ready(function(){
 184      jQuery('.dom_type_edit').editable( htsrv_url+'async.php?action=dom_type_edit&<?php echo url_crumb( 'domtype' )?>', {
 185      data    : function(value, settings){
 186              value = ajax_debug_clear( value );
 187              var re =  /rel="(.*)"/;
 188              var result = value.match(re);
 189              return {'unknown':'<?php echo stats_dom_type_title( 'unknown', true ) ?>','normal':'<?php echo stats_dom_type_title( 'normal', true ) ?>','searcheng':'<?php echo stats_dom_type_title( 'searcheng', true ) ?>', 'aggregator':'<?php echo stats_dom_type_title( 'aggregator', true ) ?>', 'email':'<?php echo stats_dom_type_title( 'email', true ) ?>', 'selected' : result[1]}
 190              },
 191      type     : 'select',
 192      name     : 'new_dom_type',
 193      tooltip  : 'Click to edit',
 194      event    : 'click',
 195      callback : function (settings, original){
 196              evoFadeSuccess(this);
 197          },
 198      onsubmit: function(settings, original) {},
 199      submitdata : function(value, settings) {
 200              var name =  jQuery(':first',jQuery(this).parent()).text();
 201              return {dom_name: name}
 202          },
 203      onerror : function(settings, original, xhr) {
 204              evoFadeFailure(original);
 205          }
 206      });
 207  
 208      });
 209  </script>
 210  <?php
 211  }
 212  
 213  ?>

title

Description

title

Description

title

Description

title

title

Body