$T->set_block('page', 'COLUMN', 'CBlock'); $T->set_block('page', 'ROW', 'BBlock'); $T->set_block('page', 'TABLE', 'ABlock'); $T->set_var(array('colclass' => 'col_left', 'data' => $LANG_GUS00['browser'])); $T->parse('CBlock', 'COLUMN', FALSE); $T->set_var('data', $LANG_GUS00['version']); $T->parse('CBlock', 'COLUMN', TRUE); $T->set_var(array('colclass' => 'col_right', 'data' => $LANG_GUS00['page_views'])); $T->parse('CBlock', 'COLUMN', TRUE); $T->set_var(array('colclass' => 'col_right', 'data' => '%')); $T->parse('CBlock', 'COLUMN', TRUE); $T->set_var('rowclass', 'header'); $T->parse('BBlock', 'ROW', TRUE); $date_compare = GUS_get_date_comparison('date', $year, $month); $tmp_name = $_GUS_table_prefix . 'tempBrowser_' . $year . $month; $temp_table = GUS_create_temp_table($tmp_name, "SELECT COUNT( browser ) AS count, browser, version\n\t\tFROM {$_TABLES['gus_userstats']}, {$_TABLES['gus_user_agents']}\n\t\tWHERE {$_TABLES['gus_userstats']}.ua_id = {$_TABLES['gus_user_agents']}.ua_id AND {$date_compare}\n\t\tGROUP BY browser, version ORDER BY count DESC"); DB_query("SET @totalHits=0"); DB_query("SELECT @totalHits := SUM(count) FROM {$temp_table['name']}"); $sql = "SELECT SUM( count ) AS subtotal, FORMAT( (SUM( count ) / @totalHits) * 100.0, 2 ) as percent, browser\n\t\tFROM {$temp_table['name']}\n\t\tGROUP BY browser ORDER BY subtotal DESC"; $result = DB_query($sql); while ($row = DB_fetchArray($result)) { $T->set_var(array('rowclass' => 'row2', 'colclass' => 'col_left')); $browser = $row['browser']; $T->set_var('data', $row['browser']); $T->parse('CBlock', 'COLUMN', FALSE); $T->set_var('data', ' '); $T->parse('CBlock', 'COLUMN', TRUE); $T->set_var(array('colclass' => 'col_right', 'data' => $row['subtotal'])); $T->parse('CBlock', 'COLUMN', TRUE); $T->set_var('data', $row['percent']); $T->parse('CBlock', 'COLUMN', TRUE);
function GUS_get_ua_counts() { global $_TABLES, $_GUS_UA_IGNORE, $_GUS_table_prefix; if (count($_GUS_UA_IGNORE) === 0) { return array('list' => array(), 'list_len' => 0, 'entry_count' => 0); } $tmp_name = $_GUS_table_prefix . 'temp_ua_table'; $temp_table = GUS_create_temp_table($tmp_name, "SELECT DISTINCT ua_id, user_agent\n\t\t\t\tFROM {$_TABLES['gus_user_agents']} ua, {$_TABLES['gus_ignore_ua']} iua \n\t\t\t\tWHERE ua.user_agent LIKE iua.ua"); $result = DB_query("SELECT DISTINCT( user_agent ), COUNT( * ) AS entries\n\t\t\t\t\t\tFROM {$_TABLES['gus_userstats']} ua JOIN {$temp_table['name']} tmp ON ua.ua_id = tmp.ua_id\n\t\t\t\t\t\tGROUP BY user_agent"); $id_list = GUS_create_item_list_for_count($result, 'user_agent'); GUS_remove_temp_table($temp_table); return $id_list; }