예제 #1
0
function GameData($raw_data, $type)
{
    global $setting, $template, $user;
    $game = array('id' => $raw_data['id'], 'instructions' => nl2br($raw_data['instructions']), 'plays' => $raw_data['hits'], 'highscores' => $raw_data['highscores'], 'seo_url' => $raw_data['seo_url'], 'category' => $raw_data['category_id'], 'submitter' => $raw_data['submitter']);
    if ($type != 'view_game') {
        $description_stripped = htmlspecialchars(strip_tags($raw_data['description']));
    }
    if (isset($template[$type . '_game_chars'])) {
        $game['name'] = shortenStr($raw_data['name'], $template[$type . '_game_chars']);
    } else {
        $game['name'] = $raw_data['name'];
    }
    if (isset($template[$type . '_game_desc_chars'])) {
        $game['description'] = shortenStr($description_stripped, $template[$type . '_game_desc_chars']);
    } else {
        $game['description'] = $raw_data['description'];
    }
    $game['url'] = GameUrl($raw_data['id'], $raw_data['seo_url'], $raw_data['category_id']);
    $game['image_url'] = GameImageUrl($raw_data['image'], $raw_data['import'], $raw_data['url']);
    if ($raw_data['highscores'] == 1) {
        $game['highscore_image'] = $template['highscore_image'];
    } else {
        $game['highscore_image'] = '';
    }
    if ($user['admin'] == 1) {
        $game['admin_edit'] = '<a href="' . $setting['site_url'] . '/admin/?task=manage_games#id=' . $raw_data['id'] . '">Edit</a>';
    } else {
        $game['admin_edit'] = '';
    }
    $game['date_added'] = FormatDate($raw_data['date_added'], 'date');
    // Define the overall rating for use in the template
    $game['rating'] = $game['rating_image'] = GenerateRating($raw_data['rating'], $type);
    $game['rating_value'] = $raw_data['rating'];
    // Get the submitter name and URL
    if ($raw_data['submitter'] != 0) {
        $submitter = mysql_fetch_array(mysql_query("SELECT * FROM ava_users WHERE id = {$raw_data['submitter']}"));
        $game['submitter_name'] = $submitter['username'];
        $game['submitter_url'] = ProfileUrl($submitter['id'], $submitter['seo_url']);
    }
    return $game;
}
예제 #2
0
        $game['fav_game'] = '<div class="normal_button" id="favbutton"><a href="#">' . GAME_FAVOURITE . '</a></div>';
    }
} else {
    $game['fav_game'] = '<div class="normal_button" id="favbutton"><a href="' . $user['login_link'] . '">' . LOGIN . '</a></div>';
}
// Report game button
if ($setting['report_permissions'] == "1" || $setting['report_permissions'] == "2" && $user['login_status'] == 1) {
    $game['report_game'] = '<div class="normal_button"><a href="#" onclick="ShowPopup(\'ava-popup\', \'' . $setting['site_url'] . '/includes/forms/game_report_form.php?id=' . $row2['id'] . '\', \'' . GAME_REPORT . '\'); return false">' . GAME_REPORT . '</a></div>';
}
// Define the 'new rating' section for the template
if (isset($_COOKIE["ava_username"])) {
    $user_rated_yet = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ava_ratings WHERE user_id='{$user['id']}' AND game_id='{$id}'"), 0);
    if ($user_rated_yet >= 1) {
        $ur = mysql_query("SELECT * FROM ava_ratings WHERE game_id={$id} AND user_id='{$user['id']}'");
        $user_rating = mysql_fetch_array($ur);
        $game['new_rating_form'] = GenerateRating($user_rating['rating'], 'view_game');
    } else {
        $game['new_rating_form'] = '<div id="rateMe" title="Rate Me...">
    	<a onclick="rateIt(this, ' . $id . ')" id="_1" title="1" onmouseover="rating(this)" onmouseout="off(this)"></a>
    	<a onclick="rateIt(this, ' . $id . ')" id="_2" title="2" onmouseover="rating(this)" onmouseout="off(this)"></a>
    	<a onclick="rateIt(this, ' . $id . ')" id="_3" title="3" onmouseover="rating(this)" onmouseout="off(this)"></a>
    	<a onclick="rateIt(this, ' . $id . ')" id="_4" title="4" onmouseover="rating(this)" onmouseout="off(this)"></a>
    	<a onclick="rateIt(this, ' . $id . ')" id="_5" title="5" onmouseover="rating(this)" onmouseout="off(this)"></a>
		</div>';
    }
} else {
    $game['new_rating_form'] = GAME_LOGIN_TO_RATE;
}
$game['tags'] = TagList($row2['id'], "&nbsp; ", 1);
if ($game['tags'] == '') {
    $game['tags'] = NO_TAGS;