require_once "../../../include/config.php"; require_once $basedir . "/admin/include/functions.php"; include $basedir . '/admin/include/isadmin.php'; $cats = getCategories(); $gamemenu = 'active'; $game_id = isset($_GET['game_id']) ? $_GET['game_id'] : ''; if (!$game_id) { header('Location: ' . $baseurl . '/admin/games?lang=' . $LANGUAGE); exit; } else { $game = getGame($game_id); //$game['g_categories'] = explode(",", $game['g_categories']); $bet_items = getBetItems($game_id); $reserve_time = getDateFormat($game['g_schedFrom']) . ' - ' . getDateFormat($game['g_schedTo']); } $total_placed_coins = getGameTotalPlacedCoins($game_id); $location = $_SERVER['PHP_SELF'] . '?lang=' . $LANGUAGE . '&game_id=' . $game_id; if (isset($_SESSION['error'])) { if ($_SESSION['error']['error'] == 0) { $alert_type = "alert-success"; } else { $alert_type = "alert-warning"; } $display = "block"; $alert_message = $_SESSION['error']['status']; unset($_SESSION['error']); } else { $display = "none"; $alert_message = ''; $alert_type = "alert-warning"; }
function allMyGameItems($user_id, $filter, $cat, $sort) { global $config, $LANGUAGE; $data = array(); $temp = array(); $file = $config['basedir'] . '/temp/all_games.txt'; if (file_exists($file)) { $temp = json_decode(file_get_contents($file), true); } else { $temp = getAllGames(); } foreach ($temp as $t) { $all_games[$t['g_id']] = $t; } $all_bets = getAllBetsByUserId($user_id); $haswon = array(); $temp = array(); $bets_per_category = array(); foreach ($all_bets as $ab) { if ($ab['ub_iswinner']) { $haswon[$ab['g_id']] = true; } } foreach ($all_bets as $ab) { $do_skip = false; $g_id = $ab['g_id']; $game = $all_games[$g_id]; $suffix = getSuffix($game); // make sure category is equal to $cat $category = $game['g_categories']; $bets_per_category[$game['g_categories' . $suffix]] += 1; if ($category != $cat and $cat != 'all') { continue; } switch ($filter) { case 'all': break; case 'won': if (!$ab['ub_iswinner'] and !isset($haswon[$g_id])) { $do_skip = true; } break; case 'lose': if (isset($haswon[$g_id])) { $do_skip = true; } else { if (!$game['g_isClosed']) { $do_skip = true; } } break; case 'judgement': $now = time(); $do_skip = true; if ($game['g_schedTo'] < $now and !$game['g_isClosed'] and !$game['g_isCancelled']) { $do_skip = false; } break; case 'cancelled': if (!$game['g_isCancelled']) { $do_skip = true; } break; default: $do_skip = true; break; } if ($do_skip) { continue; } if (!isset($temp[$g_id])) { $temp[$g_id] = getBetItems($g_id); foreach ($temp[$g_id] as $t) { $bet_items[$t['bi_id']] = $t; } if ($game['g_isClosed'] and !$game['g_isCancelled']) { $key = 0; } else { $key = 'current'; } $data[$g_id]['won'] = $key; $data[$g_id]['game_id'] = $g_id; $data[$g_id]['title'] = $game['g_title' . $suffix]; $data[$g_id]['image'] = $game['g_image']; $data[$g_id]['from'] = $game['g_schedFrom']; $data[$g_id]['to'] = $game['g_schedTo']; $data[$g_id]['your_placed'] = 0; $data[$g_id]['housecom'] = $game['g_houseCom']; $data[$g_id]['total_placed'] = getGameTotalPlacedCoins($g_id); } if ($ab['ub_iswinner']) { $data[$g_id]['won'] = 1; } if (!isset($data[$g_id]['your_items'][$ab['bi_id']]['placed_coins'])) { $data[$g_id]['your_items'][$ab['bi_id']]['placed_coins'] = 0; } $data[$g_id]['your_placed'] += $ab['ub_coins']; $data[$g_id]['your_items'][$ab['bi_id']]['placed_coins'] += $ab['ub_coins']; $data[$g_id]['your_items'][$ab['bi_id']]['name'] = $bet_items[$ab['bi_id']]['bi_description' . $suffix]; $data[$g_id]['your_items'][$ab['bi_id']]['winner'] = $ab['ub_iswinner']; } if ($bets_per_category) { arsort($bets_per_category); } $data = sortMyBets($data, $sort); return array('data' => $data, 'bets_per_category' => $bets_per_category); }