$day = date('j'); $sort_sep = '?'; } else { $sort_sep = '&'; } $sort = isset($_GET['sort']) ? $_GET['sort'] : ''; $anon = isset($_GET['anon']) ? $_GET['anon'] : ''; // check for cached file if (file_exists(GUS_cachefile()) and date('dMY') !== $day . $month . $year) { $display = GUS_getcache(); } else { // no cached version //main sql option $date_compare = GUS_get_date_comparison('date', $year, $month, $day); $date_format = $day == 0 ? 'CONCAT( DATE_FORMAT( date, \'%d %b - \' ), TIME_FORMAT( time, \'%H:%i\' ) )' : 'TIME_FORMAT( time, \'%H:%i\' )'; $order_by = GUS_get_order_by($sort); $sql = "SELECT COUNT(*) AS views, uid, username, ip, host, referer, date, time, \n\t\t\t{$date_format} AS date_formatted \n\t\t\tFROM {$_TABLES['gus_userstats']}\n\t\t\tWHERE {$date_compare} "; // anon or uid if ($anon == '1') { $sql .= " AND uid = '1'"; } else { if ($anon == '2') { $sql .= " AND uid > '1'"; } } // main sql grouping $sql .= " GROUP BY date, uid, ip {$order_by}"; // create navlinks AND set urls $totalrec = DB_query($sql); $totalrows = DB_numRows($totalrec); $num_pages = ceil($totalrows / $_GUS_limit);
} if ($uid > 1) { $sql .= " AND uid='{$uid}' "; } if ($visited_page != '') { $sql .= " AND page='{$visited_page}'"; } //anonymous or logged in if ($anon == '1') { $sql .= " AND uid='1'"; } else { if ($anon == '2') { $sql .= " AND uid>'1'"; } } $sql .= GUS_get_order_by($sort); // create navlinks AND set urls $totalrec = DB_query($sql); $totalrows = DB_numRows($totalrec); $num_pages = ceil($totalrows / $_GUS_limit); if (!isset($_GET['page']) or empty($_GET['page'])) { $curpage = 1; } else { $curpage = (int) $_GET['page']; } $header_url = GUS_create_url('sort'); $base_url = GUS_create_url(''); $navlinks = COM_printPageNavigation($base_url, $curpage, $num_pages); // limit to the sql $offset = ($curpage - 1) * $_GUS_limit; $sql .= " LIMIT " . $offset . ', ' . $_GUS_limit;