public static function updateGame($pack) { $pack->auth->game_id = $pack->game_id; $pack->auth->permission = "read_write"; if (!editors::authenticateGameEditor($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $url_result = games::isValidSiftrURL($pack); if ($url_result->returnCode != 0) { return $url_result; } // If the URL is an empty string (but NOT undefined or null), that means it is being explicitly set to NULL in db. $unset_url = isset($pack->siftr_url) && $pack->siftr_url == ''; if ($unset_url) { unset($pack->siftr_url); } //ensure requested scene_id exists, otherwise pick one from list of existing scenes //this is a hack, in case you were wondering... if (!dbconnection::queryObject("SELECT * FROM scenes WHERE scene_id = '{$pack->intro_scene_id}' AND game_id = '{$pack->game_id}'")) { $pack->intro_scene_id = 0; //fallback if we can't find a good one $scenes = dbconnection::queryArray("SELECT * FROM scenes WHERE game_id = '{$pack->game_id}'"); if (count($scenes) > 0) { $pack->intro_scene_id = $scenes[0]->scene_id; } } dbconnection::query("UPDATE games SET " . (isset($pack->name) ? "name = '" . addslashes($pack->name) . "', " : "") . (isset($pack->description) ? "description = '" . addslashes($pack->description) . "', " : "") . (isset($pack->icon_media_id) ? "icon_media_id = '" . addslashes($pack->icon_media_id) . "', " : "") . (isset($pack->media_id) ? "media_id = '" . addslashes($pack->media_id) . "', " : "") . (isset($pack->map_type) ? "map_type = '" . addslashes($pack->map_type) . "', " : "") . (isset($pack->map_focus) ? "map_focus = '" . addslashes($pack->map_focus) . "', " : "") . (isset($pack->map_latitude) ? "map_latitude = '" . addslashes($pack->map_latitude) . "', " : "") . (isset($pack->map_longitude) ? "map_longitude = '" . addslashes($pack->map_longitude) . "', " : "") . (isset($pack->map_zoom_level) ? "map_zoom_level = '" . addslashes($pack->map_zoom_level) . "', " : "") . (isset($pack->map_show_player) ? "map_show_player = '" . addslashes($pack->map_show_player) . "', " : "") . (isset($pack->map_show_players) ? "map_show_players = '" . addslashes($pack->map_show_players) . "', " : "") . (isset($pack->map_offsite_mode) ? "map_offsite_mode = '" . addslashes($pack->map_offsite_mode) . "', " : "") . (isset($pack->notebook_allow_comments) ? "notebook_allow_comments = '" . addslashes($pack->notebook_allow_comments) . "', " : "") . (isset($pack->notebook_allow_likes) ? "notebook_allow_likes = '" . addslashes($pack->notebook_allow_likes) . "', " : "") . (isset($pack->notebook_trigger_scene_id) ? "notebook_trigger_scene_id = '" . addslashes($pack->notebook_trigger_scene_id) . "', " : "") . (isset($pack->notebook_trigger_requirement_root_package_id) ? "notebook_trigger_requirement_root_package_id = '" . addslashes($pack->notebook_trigger_requirement_root_package_id) . "', " : "") . (isset($pack->notebook_trigger_title) ? "notebook_trigger_title = '" . addslashes($pack->notebook_trigger_title) . "', " : "") . (isset($pack->notebook_trigger_icon_media_id) ? "notebook_trigger_icon_media_id = '" . addslashes($pack->notebook_trigger_icon_media_id) . "', " : "") . (isset($pack->notebook_trigger_distance) ? "notebook_trigger_distance = '" . addslashes($pack->notebook_trigger_distance) . "', " : "") . (isset($pack->notebook_trigger_infinite_distance) ? "notebook_trigger_infinite_distance = '" . addslashes($pack->notebook_trigger_infinite_distance) . "', " : "") . (isset($pack->notebook_trigger_wiggle) ? "notebook_trigger_wiggle = '" . addslashes($pack->notebook_trigger_wiggle) . "', " : "") . (isset($pack->notebook_trigger_show_title) ? "notebook_trigger_show_title = '" . addslashes($pack->notebook_trigger_show_title) . "', " : "") . (isset($pack->notebook_trigger_hidden) ? "notebook_trigger_hidden = '" . addslashes($pack->notebook_trigger_hidden) . "', " : "") . (isset($pack->notebook_trigger_on_enter) ? "notebook_trigger_on_enter = '" . addslashes($pack->notebook_trigger_on_enter) . "', " : "") . (isset($pack->inventory_weight_cap) ? "inventory_weight_cap = '" . addslashes($pack->inventory_weight_cap) . "', " : "") . (isset($pack->is_siftr) ? "is_siftr = '" . addslashes($pack->is_siftr) . "', " : "") . (isset($pack->siftr_url) ? "siftr_url = '" . addslashes($pack->siftr_url) . "', " : "") . ($unset_url ? "siftr_url = NULL, " : "") . (isset($pack->published) ? "published = '" . addslashes($pack->published) . "', " : "") . (isset($pack->type) ? "type = '" . addslashes($pack->type) . "', " : "") . (isset($pack->intro_scene_id) ? "intro_scene_id = '" . addslashes($pack->intro_scene_id) . "', " : "") . (isset($pack->latitude) ? "latitude = '" . addslashes($pack->latitude) . "', " : "") . (isset($pack->longitude) ? "longitude = '" . addslashes($pack->longitude) . "', " : "") . (isset($pack->network_level) ? "network_level = '" . addslashes($pack->network_level) . "', " : "") . (isset($pack->allow_download) ? "allow_download = '" . addslashes($pack->allow_download) . "', " : "") . (isset($pack->preload_media) ? "preload_media = '" . addslashes($pack->preload_media) . "', " : "") . (isset($pack->moderated) ? "moderated = '" . addslashes($pack->moderated) . "', " : "") . (isset($pack->version) ? "version = '" . addslashes($pack->version) . "', " : "") . (isset($pack->colors_id) ? "colors_id = '" . addslashes($pack->colors_id) . "', " : "") . "last_active = CURRENT_TIMESTAMP " . "WHERE game_id = '{$pack->game_id}'"); games::bumpGameVersion($pack); return games::getGame($pack); }