require_once 'include/config.php';
require_once $basedir . "/include/functions.php";
require_once $basedir . "/include/user_functions.php";
if (!$user_id) {
    header('Location: ' . $baseurl . '#login');
    exit;
}
$joinedgamemenu = 'active';
$categories = getCategories();
// get all data for pie graph
if (checkCacheExists('all_coin_deals.txt')) {
    $all_coin_deals = getCoinDealsFromCache();
} else {
    $all_coin_deals = getCoinDeals();
}
$coin_deals = getUserCoinDeals($user_id, $all_coin_deals);
$fromto = getAllRange($coin_deals);
$from = $fromto['from'];
$to = $fromto['to'];
$ret = winLoseRatio($user_id, $from, $to, $coin_deals);
$pie = $ret['pie'];
$win_lose = $ret['data'];
$filter = isset($_GET['f']) ? $_GET['f'] : 'all';
// default to all
$cat = isset($_GET['c']) ? $_GET['c'] : 'all';
// default to all
$sort = isset($_GET['s']) ? $_GET['s'] : 'latest';
// default to newest
$temp = allMyGameItems($user_id, $filter, $cat, $sort);
$my_bets = $temp['data'];
$bets_per_category = $temp['bets_per_category'];
$admins = getAdmins();
$now_betting = false;
$closed_bets = false;
$total_closed_bets = 0;
$usermenu = 'active';
$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : '';
$activ = isset($_GET['active']) ? $_GET['active'] : 'bet';
if (!$user_id) {
    $redir = $baseurl . "/admin/users?lang={$LANGUAGE}";
    header('Location: ' . $redir);
    exit;
}
$user_likes = getUserLikes($user_id);
$user_bookmarks = getUserBookmarks($user_id);
$user_bets = getUserBetsByUserId($user_id);
$user_coin_deals = getUserCoinDeals($user_id);
$user_info = getUserInfo($user_id);
if ($user_bets) {
    $now_betting = getUserNowBetting($user_bets);
    $closed_bets = getUserClosedBetting($user_bets);
    $total_closed_bets = count($closed_bets['win']) + count($closed_bets['lose']);
}
?>
<!DOCTYPE html>
<html>
	<head>
		<?php 
include $basedir . '/admin/include/header.php';
?>
	</head>