You are here

function boost_stats_init in Boost 6

1 call to boost_stats_init()
boost_stats.php in stats/boost_stats.php
Place in webroot, for faster stats if needed.

File

stats/boost_stats.php, line 84
Place in webroot, for faster stats if needed.

Code

function boost_stats_init() {
  global $nid, $title, $q, $referer, $session_id, $uid, $count_views, $access_log, $variables;

  // Connect to DB.
  include_once './includes/bootstrap.inc';
  include_once './includes/common.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);

  // Set variables passed via GET.
  $nid = isset($_GET['nid']) && is_numeric($_GET['nid']) ? $_GET['nid'] : NULL;
  $title = isset($_GET['title']) && $_GET['title'] != 'NULL' ? urldecode($_GET['title']) : NULL;
  $q = isset($_GET['qq']) && $_GET['qq'] != 'NULL' ? $_GET['qq'] : NULL;

  //$q = (isset($_GET['q']) && $_GET['q'] != 'NULL') ? $_GET['q'] : NULL;
  $referer = isset($_GET['referer']) ? $_GET['referer'] : NULL;

  // $session_id only goes in the access log; only used for stats, not creds.
  $session_id = session_id();
  if (empty($session_id)) {
    if (empty($_COOKIE[session_name()])) {
      if (empty($_SERVER['HTTP_USER_AGENT'])) {
        $session_id = md5(ip_address());
      }
      else {
        $session_id = md5($_SERVER['HTTP_USER_AGENT'] . ip_address());
      }
    }
    else {
      $session_id = $_COOKIE[session_name()];
    }
  }

  // Anonymous users always get a User ID of 0.
  $uid = 0;

  // load all boost, statistics & throttle variables; 1 transaction instead of multiple
  $result = db_query("\nSELECT * FROM {variable}\nWHERE name LIKE 'boost_%'\nOR name LIKE 'statistics_%'\nOR name LIKE 'throttle_%'\n");
  while ($variable = db_fetch_object($result)) {
    $variables[$variable->name] = unserialize($variable->value);
  }
}