Beispiel #1
0
function MaintenanceFixScores()
{
    global $db_prefix, $modSettings, $smcFunc, $context;
    $request = $smcFunc['db_query']('', '
		SELECT id_game, score_type, game_settings
		FROM {db_prefix}arcade_games');
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        fixScores($row['id_game'], $row['score_type']);
    }
    $smcFunc['db_free_result']($request);
    if (isset($_REQUEST['back']) && $_REQUEST['back'] == 'score') {
        redirectexit('action=admin;area=arcademaintenance;sa=highscore');
    }
}
Beispiel #2
0
function updateGame($id_game, $gameOptions, $log = false)
{
    global $scripturl, $sourcedir, $db_prefix, $user_info, $smcFunc;
    if (empty($id_game)) {
        fatal_error('arcade_game_update_error', false);
    }
    $gameUpdates = array();
    $updateValues = array();
    if (isset($gameOptions['internal_name'])) {
        $gameUpdates[] = "internal_name = {string:internal_name}";
        $updateValues['internal_name'] = $gameOptions['internal_name'];
    }
    if (isset($gameOptions['name'])) {
        $gameUpdates[] = "game_name = {string:game_name}";
        $updateValues['game_name'] = $gameOptions['name'];
    }
    if (isset($gameOptions['description'])) {
        $gameUpdates[] = "description = {string:description}";
        $updateValues['description'] = $gameOptions['description'];
    }
    if (isset($gameOptions['help'])) {
        $gameUpdates[] = "help = {string:help}";
        $updateValues['help'] = $gameOptions['help'];
    }
    if (isset($gameOptions['thumbnail'])) {
        $gameUpdates[] = "thumbnail = {string:thumbnail}";
        $updateValues['thumbnail'] = $gameOptions['thumbnail'];
    }
    if (isset($gameOptions['thumbnail_small'])) {
        $gameUpdates[] = "thumbnail_small = {string:thumbnail_small}";
        $updateValues['thumbnail_small'] = $gameOptions['thumbnail_small'];
    }
    if (isset($gameOptions['game_file'])) {
        $gameUpdates[] = "game_file = {string:game_file}";
        $updateValues['game_file'] = $gameOptions['game_file'];
    }
    if (isset($gameOptions['game_directory'])) {
        $gameUpdates[] = "game_directory = {string:game_directory}";
        $updateValues['game_directory'] = $gameOptions['game_directory'];
    }
    if (isset($gameOptions['class'])) {
        $gameUpdates[] = "class = {string:class}";
        $updateValues['class'] = $gameOptions['class'];
    }
    if (isset($gameOptions['member_groups'])) {
        $gameUpdates[] = "member_groups = {string:member_groups}";
        $updateValues['member_groups'] = implode(',', $gameOptions['member_groups']);
    }
    if (isset($gameOptions['game_settings'])) {
        $gameUpdates[] = "game_settings = {string:game_settings}";
        $updateValues['game_settings'] = serialize($gameOptions['game_settings']);
    }
    if (isset($gameOptions['score_type'])) {
        $gameUpdates[] = "score_type = {int:score_type}";
        $updateValues['score_type'] = $gameOptions['score_type'];
        require_once $sourcedir . '/ArcadeMaintenance.php';
        fixScores($id_game, $gameOptions['score_type']);
    }
    if (isset($gameOptions['num_plays'])) {
        if ($gameOptions['num_plays'] == '+') {
            $gameUpdates[] = "num_plays = num_plays + 1";
        } else {
            $gameUpdates[] = "num_plays = {int:num_plays}";
            $updateValues['num_plays'] = $gameOptions['num_plays'];
        }
    }
    if (isset($gameOptions['num_rates'])) {
        if ($gameOptions['num_rates'] == '+') {
            $gameUpdates[] = "num_rates = num_rates + 1";
        } elseif ($gameOptions['num_rates'] == '-') {
            $gameUpdates[] = "num_rates = num_rates - 1";
        } else {
            $gameUpdates[] = "num_rates = {int:num_rates}";
            $updateValues['num_rates'] = $gameOptions['num_rates'];
        }
    }
    if (isset($gameOptions['num_favorites'])) {
        if ($gameOptions['num_favorites'] == '+') {
            $gameUpdates[] = "num_favorites = num_favorites + 1";
        } elseif ($gameOptions['num_favorites'] == '-') {
            $gameUpdates[] = "num_favorites = num_favorites - 1";
        } else {
            $gameUpdates[] = "num_favorites = {int:num_favorites}";
            $updateValues['num_favorites'] = $gameOptions['num_favorites'];
        }
    }
    if (isset($gameOptions['rating'])) {
        $gameUpdates[] = "game_rating = {float:rating}";
        $updateValues['rating'] = $gameOptions['rating'];
    }
    if (isset($gameOptions['category'])) {
        $gameUpdates[] = "id_cat = {int:category}";
        $updateValues['category'] = $gameOptions['category'];
        $updateCat = true;
    }
    if (isset($gameOptions['champion'])) {
        $gameUpdates[] = "id_champion = {int:champion}";
        $updateValues['champion'] = $gameOptions['champion'];
    }
    if (isset($gameOptions['champion_score'])) {
        $gameUpdates[] = "id_champion_score = {int:champion_score}";
        $updateValues['champion_score'] = $gameOptions['champion_score'];
    }
    if (isset($gameOptions['enabled'])) {
        $gameUpdates[] = "enabled = {int:enabled}";
        $updateValues['enabled'] = $gameOptions['enabled'] ? 1 : 0;
        $updateCat = true;
    }
    if (isset($gameOptions['local_permissions'])) {
        $gameUpdates[] = "local_permissions = {int:local_permissions}";
        $updateValues['local_permissions'] = $gameOptions['local_permissions'];
    }
    if (empty($gameUpdates)) {
        return;
    }
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}arcade_games
		SET ' . implode(', ', $gameUpdates) . '
		WHERE id_game = {int:game}', array_merge($updateValues, array('game' => $id_game)));
    if ($log) {
        logAction('arcade_update_game', array('game' => $id_game));
    }
    if (!empty($updateCat)) {
        updateCategoryStats();
    }
    return true;
}