You are here

function adsense_click_log in Google AdSense integration 5.2

Same name and namespace in other branches
  1. 5.3 contrib/adsense_click/adsense_click.logs.inc \adsense_click_log()
  2. 5 adsense.module \adsense_click_log()
  3. 6 contrib/adsense_click/adsense_click.logs.inc \adsense_click_log()
  4. 7 contrib/adsense_click/adsense_click.logs.inc \adsense_click_log()

Menu callback; presents the "AdSense" log page.

1 string reference to 'adsense_click_log'
adsense_menu in ./adsense.module
Implementation of hook_menu().

File

./adsense.module, line 1538

Code

function adsense_click_log() {
  $header = array(
    array(
      'data' => t('Timestamp'),
      'field' => 'timestamp',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Path'),
      'field' => 'path',
    ),
    array(
      'data' => t('IP/host'),
      'field' => 'ip',
    ),
  );
  $name_resolve = variable_get(ADSENSE_CLICK_TRACKING_NAME_RESOLVE, 0);
  $sql = 'SELECT * FROM {adsense_clicks} ' . tablesort_sql($header);
  $result = pager_query($sql, 50);
  while ($log = db_fetch_object($result)) {
    if ($name_resolve) {
      $host = gethostbyaddr($log->ip);
    }
    else {
      $host = $log->ip;
    }
    $rows[] = array(
      array(
        'data' => format_date($log->timestamp, 'small'),
        'nowrap' => 'nowrap',
      ),
      _adsense_format_path($log->path),
      l($host, 'http://whois.domaintools.com/' . $log->ip),
    );
  }
  return theme('table', $header, $rows) . theme('pager', NULL, 50, 0);
}