function add_txt($file, $name, $uid, $textassoc = null, $start = 0, $end = 0) { // open the file $filestr = open_file($file); // =========== GENERALIZE THIS PLZ ======================================= // arrayify the text into canonical array form $acanon = str_to_array($filestr, "[^a-zA-Z0-9_\\s]"); // get the hash of the text $hash = count_words($acanon); // get counts of uniques, hapax, ... $counts = get_counts($hash); // get a unique text hash to be used as location data $thash = file_id($uid, $name, $filestr); // must build aarray to send to db add function $data['name'] = $name; $data['words'] = $hash; $data['user'] = $uid; $data['counts'] = $counts; $data['start'] = $start; $data['end'] = $end ? $end : $counts['total'] - 1; $data['assoc'] = $textassoc; $data['canon'] = $filestr; $data['hash'] = $thash; // call the add function in MODQUERY and retrive the text_id $tid = add_text_to_db($data); return $tid; }
function insert_rightscale_data($server_cfg, $game_cfg, $time_slots = '*') { // TODO take the names from config and expand table as and when new machine class is added to config $machine_class_default = array('web_count' => 0, 'mb_count' => 0, 'mc_count' => 0, 'db_count' => 0, 'queue_count' => 0, 'proxy_count' => 0, 'admin_count' => 0); $game_name = $game_cfg["name"]; $table = $game_cfg['db_stats_table']; $gid = $game_cfg['gameid']; // to query for the dau_5min table and to insert into stats_30min; $snid = $game_cfg['snid'] ? $game_cfg['snid'] : null; $cid = $game_cfg['cid'] ? $game_cfg['cid'] : null; $deploy_array = $game_cfg['deployIDs']; $deploy_id = $deploy_array[0]; // // get the max value of the supplied timeslots // expects that time_slots are given as follows // {ts1,ts2} // preg_match("/\\{(.*)\\}/", $time_slots, $m); $timeslot = max(explode(",", $m[1])); if (empty($timeslot)) { $game_cfg['logger']->log("insert_bd_metric", "null is given as timeslot", Logger::ERR); error_log("null is given as timeslots", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); return; } $timestamp = $timeslot * 1800; $dauObj = new DAUAdapter(); $dau = $dauObj->get_timed_dau($timestamp, $gid, $snid, $cid); $rsObj = new RightScale($server_cfg, $game_cfg); $web_count = null; if (isset($game_cfg['id'])) { $web_count = $rsObj->get_host_count_per_pool($game_cfg['id'], $deploy_id); $game_name = $game_cfg['parent']; // to query other machine counts } $machine_counts = $rsObj->get_host_count_per_class($deploy_id, $game_name); $counts_array = get_counts($machine_class_default, $machine_counts, $web_count); $query = create_query($table, $timestamp, $dau, $counts_array, $gid); $queries = array($query); $query_res = execute_queries($server_cfg, $game_cfg, $queries); if ($query_res == 0) { $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " successfully inserted", Logger::INFO); error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } else { $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " not inserted", Logger::ERR); error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name'])); } }
function get_os_unq() { $result = mysql_query("SELECT b.osName\n\t\t\t FROM wp_3xvgq6_Counterize a, wp_3xvgq6_Counterize_UserAgents b\n\t\t\t WHERE a.agentID = b.agentID\n\t\t\t GROUP BY a.IP;"); $arr = get_counts($result, "osName"); return $arr; }
function count_show() { $counts = get_counts(); $r = $counts['tweets_thisweek'] . ',' . $counts['tweets_today']; echo $r; }