You are here

function visitors_hit_details in Visitors 7.2

Same name and namespace in other branches
  1. 8 reports/hit_details.inc \visitors_hit_details()
  2. 7 reports/hit_details.inc \visitors_hit_details()
  3. 7.0 reports/hit_details.inc \visitors_hit_details()

Menu callback; Displays recent page accesses.

Parameters

visitors_id: int visitors id from visitors table

Return value

string hit details report or 404 error if visitors_id not found

1 string reference to 'visitors_hit_details'
visitors_menu in ./visitors.module
Menu callback. Prints a listing of active nodes on the site.

File

reports/hit_details.inc, line 17
Hit details report for the visitors module.

Code

function visitors_hit_details($visitors_id) {
  $hit_details = visitors_hit_details_get_data($visitors_id);
  if ($hit_details) {
    $url = urldecode($hit_details->visitors_url);
    $referer = $hit_details->visitors_referer;
    $date = format_date($hit_details->visitors_date_time, 'large', visitors_get_timezone());
    $whois_enable = module_exists('whois');
    $attr = array(
      'attributes' => array(
        'target' => '_blank',
        'title' => t('Whois lookup'),
      ),
    );
    $ip = long2ip($hit_details->visitors_ip);
    $array = array(
      'URL' => l($url, $url),
      'Title' => check_plain($hit_details->visitors_title),
      'Referer' => $referer ? l($referer, $referer) : '',
      'Date' => $date,
      'User' => theme('username', array(
        'account' => $hit_details,
      )),
      'IP' => $whois_enable ? l($ip, 'whois/' . $ip, $attr) : $ip,
      'User Agent' => check_plain($hit_details->visitors_user_agent),
    );
    if (module_exists('visitors_geoip')) {
      $geoip_data = visitors_hit_details_get_geoip_data($hit_details);
      $array = array_merge($array, $geoip_data);
    }
    if (module_exists('visitors_browscap')) {
      $user_agent = $hit_details->visitors_user_agent;
      $browscap_data = visitors_hit_details_get_browscap_data($user_agent);
      if ($browscap_data !== FALSE) {
        $array = array_merge($array, $browscap_data);
      }
    }
    $rows = array();
    foreach ($array as $key => $value) {
      $rows[] = array(
        array(
          'data' => t($key),
          'header' => TRUE,
        ),
        $value,
      );
    }
    drupal_set_title(t('Details'));
    return theme('table', array(
      'rows' => $rows,
    ));
  }
  drupal_not_found();
}