function getActivities($user_id)
{
    global $config, $lang, $suffix;
    $basedir = $config['basedir'];
    $baseurl = $config['baseurl'];
    $data = array();
    $games = array();
    $users = array();
    $ret = array();
    $max_rec = 10;
    $limit = 1;
    $q = "SELECT * FROM user_activities WHERE user_id = '{$user_id}' AND ua_seen = 0 ORDER BY ua_id DESC limit 0, {$max_rec}";
    $result = mysql_query($q);
    $numrows = mysql_num_rows($result);
    if ($numrows) {
        while ($row = mysql_fetch_array($result)) {
            $data[] = $row;
        }
        if ($numrows < $max_rec) {
            $limit = $max_rec - $numrows;
        }
    } else {
        $limit = $max_rec;
    }
    $q = "SELECT * FROM user_activities WHERE user_id = '{$user_id}' AND ua_seen = 1 ORDER BY ua_id DESC limit 0, {$limit}";
    $result = mysql_query($q);
    $numrows = mysql_num_rows($result);
    if ($numrows) {
        while ($row = mysql_fetch_array($result)) {
            $data[] = $row;
        }
    }
    $i = 0;
    $unseen = 0;
    foreach ($data as $d) {
        // 'like','unlike','withdraw','deposit','userfollow','bookmark','unbookmark','won','joinedgame','gamecancelled','changepass'
        $activity = $d['ua_activity'];
        switch ($activity) {
            case 'like':
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[419]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'unlike':
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[427]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'deposit':
                break;
            case 'userfollow':
                if ($d['ua_seen'] == 0) {
                    $unseen++;
                }
                break;
            case 'bookmark':
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[428]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'unbookmark':
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[429]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'won':
                if ($d['ua_seen'] == 0) {
                    $unseen++;
                }
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[430]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'joinedgame':
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[431]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'gamecancelled':
                if ($d['ua_seen'] == 0) {
                    $unseen++;
                }
                $g_id = $d['ua_fieldvalue'];
                $games[$g_id] = !isset($games[$g_id]) ? getGameFromCache($g_id) : $games[$g_id];
                $game_title = $games[$g_id]['g_title' . $suffix];
                if (strlen($game_title) > 30) {
                    $game_title = substr($game_title, 0, 30) . '...';
                }
                $ret[$i]['message'] = str_replace('$GAME_TITLE', $game_title, $lang[432]);
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/game_pics/' . $games[$g_id]['g_image'];
                $ret[$i]['href'] = $baseurl . '/details.php?game=' . base64_encode($g_id);
                break;
            case 'changepass':
                $user_id = $d['user_id'];
                $users[$user_id] = !isset($users[$user_id]) ? getUserFromCache($user_id) : $users[$user_id];
                $ret[$i]['message'] = $lang[434];
                $ret[$i]['time'] = _timeSince($d['ua_date']);
                $ret[$i]['image'] = $baseurl . '/images/user_pics/' . $users[$user_id]['user_pic'];
                $ret[$i]['href'] = $baseurl . '/settings/password.php';
                break;
        }
        $i++;
    }
    if ($ret) {
        return array('ret' => $ret, 'unseen' => $unseen);
    } else {
        return false;
    }
    //return $ret;
}
// 8: OA==
$game_id = base64_decode($_GET['game']);
if (!$game_id) {
    echo 'no game id. refresh to main page';
    //header('Location: ' . $baseurl);
    exit;
}
if ($user_id) {
    $is_liked = checkIsLiked($user_id, $game_id);
    $is_bookmarked = checkIsBookmarked($user_id, $game_id);
} else {
    $is_liked = false;
    $is_bookmarked = false;
}
//$game = getGame($game_id);
$game = getGameFromCache($game_id);
if (!$game) {
    header('Location: ' . $baseurl);
    exit;
}
if ($user_coins < $game['g_coinPerBet'] and !$game['g_isTrial']) {
    $disable_betting = true;
    $notice .= $lang[226];
    // you have less than minimum coins...
    $notice_display = "block";
    $notice_class = 'needcoins';
}
$game_timer = $game['g_schedTo'];
$game_tags = $game['g_tags'];
$game_cat = $game['g_categories' . $suffix];
$game_cat_id = getCategoryId($game['g_categories']);