You are here

function counter_report in Counter 5

Same name and namespace in other branches
  1. 6 counter.module \counter_report()
1 string reference to 'counter_report'
counter_menu in ./counter.module
Menu callback. Prints a listing of active nodes on the site.

File

./counter.module, line 159
The counter module used for displaying Site Counter.

Code

function counter_report() {
  $items_per_page = variable_get('default_nodes_main', 10);
  $sql = "SELECT * FROM {counter} ORDER BY counter_id DESC";
  $sql_count = db_rewrite_sql('SELECT COUNT(*) FROM {counter}');
  $results = pager_query($sql, $items_per_page, 0, $sql_count);
  $rows = array();
  $page = isset($_GET['page']) ? $_GET['page'] : '';
  $i = 1 + $page * $items_per_page;
  $header = array(
    t('#'),
    t('ID'),
    t('IP Address'),
    t('Created Date'),
    t('Access page'),
  );
  while ($data = db_fetch_object($results)) {
    $rows[] = array(
      $i++,
      $data->counter_id,
      $data->counter_ip,
      $data->counter_date,
      $data->counter_page,
    );
  }
  $output = "";
  $output .= theme('table', $header, $rows);
  $output .= theme('pager', NULL, $items_per_page, 0);
  return $output;
}