function filterAllGames($all_games, $sort, $cat) { global $suffix; if (!$all_games) { return false; } $data = array(); $bet_items = array(); $bet_items2 = array(); $now = time(); $i = 0; $all_bets_from_db = false; $all_bet_items = false; foreach ($all_games as $a) { $all_bets = false; $g_id = $a['g_id']; if (!$all_bets_from_db) { $all_bets_from_db = getAllBets(); // query the DB } if (!$all_bet_items) { $all_bet_items = getAllBetItems(); // query the DB } $all_bets = getAllBetsFromCache($all_bets_from_db, $g_id); $bet_items = getBetItemsFromCache($all_bet_items, $g_id); if ($bet_items) { foreach ($bet_items as $bi) { $bet_items2[$bi['bi_id']] = $bi['bi_description' . $suffix]; // assign bi_id as key and bi_description as value } } // by category if ($cat == 'all') { $data[$i] = $a; foreach ($bet_items as $bi) { $data[$i]['bet_items'][] = $bet_items2[$bi['bi_id']]; } $data[$i]['total_bets'] = getGameCoins($all_bets); } else { $hit = false; $xs = explode(",", $a['g_categories']); foreach ($xs as $x) { if (strtolower($x) == strtolower($cat)) { $hit = true; break; } } if ($hit) { $data[$i] = $a; foreach ($bet_items as $bi) { $data[$i]['bet_items'][] = $bet_items2[$bi['bi_id']]; } $data[$i]['total_bets'] = getGameCoins($all_bets); } } $i++; } return $data; }
} $display_uri = $user_bettings ? "?q=yourgame&cat={$game_cat}&sort=time" : "?q=live&cat={$game_cat}&sort=time"; } // if game has not yet started if ($game['g_schedFrom'] > $time and $game['g_isCancelled'] == 0 and $game['g_isClosed'] == 0) { $is_future_game = true; $display_uri = $user_bettings ? "?q=yourgame&cat={$game_cat}&sort=time" : "?q=upcoming&cat={$game_cat}&sort=time"; $game_timer = $game['g_schedFrom']; $game_timer_id = ''; $temp = date('M d, Y h:i A', $game['g_schedFrom']); $notice .= str_replace('$DATE_VARIABLE', $temp, $lang[237]); $notice_display = "block"; $notice_class = "notstarted"; } $all_bets = getAllBets($game_id); $game_placed_coins = getGameCoins($all_bets); // get total placed coins for this game $total_joined = getTotalUsersJoined($all_bets); // count all users who played $bet_items = getBetItems($game_id); $disable_betting = time() > $game['g_schedTo'] ? true : false; // disabled betting when game ended foreach ($bet_items as $bi) { $bet_items2[$bi['bi_id']] = $bi['bi_description' . $suffix]; // assign bi_id as key and bi_description as value $bi_id_of_winner = $bi['bi_winner'] ? $bi['bi_id'] : $bi_id_of_winner; } $info_per_bet_item = getInfoPerBetItem($all_bets); // get placed coins, bet users, and ratio $user_may_earn = getUserMayEarn($info_per_bet_item, $game['g_houseCom']); // if game is already closed