public static function createGame($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } if (isset($pack->siftr_url) && $pack->siftr_url == '') { // For creation, a siftr_url of undefined, null, or empty string are all the same. // They all become NULL in the db. $pack->siftr_url = null; } $url_result = games::isValidSiftrURL($pack); if ($url_result->returnCode != 0) { return $url_result; } $pack->game_id = dbconnection::queryInsert("INSERT INTO games (" . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->media_id) ? "media_id," : "") . (isset($pack->map_type) ? "map_type," : "") . (isset($pack->map_focus) ? "map_focus," : "") . (isset($pack->map_latitude) ? "map_latitude," : "") . (isset($pack->map_longitude) ? "map_longitude," : "") . (isset($pack->map_zoom_level) ? "map_zoom_level," : "") . (isset($pack->map_show_player) ? "map_show_player," : "") . (isset($pack->map_show_players) ? "map_show_players," : "") . (isset($pack->map_offsite_mode) ? "map_offsite_mode," : "") . (isset($pack->notebook_allow_comments) ? "notebook_allow_comments," : "") . (isset($pack->notebook_allow_likes) ? "notebook_allow_likes," : "") . (isset($pack->notebook_trigger_scene_id) ? "notebook_trigger_scene_id," : "") . (isset($pack->notebook_trigger_requirement_root_package_id) ? "notebook_trigger_requirement_root_package_id," : "") . (isset($pack->notebook_trigger_title) ? "notebook_trigger_title," : "") . (isset($pack->notebook_trigger_icon_media_id) ? "notebook_trigger_icon_media_id," : "") . (isset($pack->notebook_trigger_distance) ? "notebook_trigger_distance," : "") . (isset($pack->notebook_trigger_infinite_distance) ? "notebook_trigger_infinite_distance," : "") . (isset($pack->notebook_trigger_wiggle) ? "notebook_trigger_wiggle," : "") . (isset($pack->notebook_trigger_show_title) ? "notebook_trigger_show_title," : "") . (isset($pack->notebook_trigger_hidden) ? "notebook_trigger_hidden," : "") . (isset($pack->notebook_trigger_on_enter) ? "notebook_trigger_on_enter," : "") . (isset($pack->inventory_weight_cap) ? "inventory_weight_cap," : "") . (isset($pack->is_siftr) ? "is_siftr," : "") . (isset($pack->siftr_url) ? "siftr_url," : "") . (isset($pack->published) ? "published," : "") . (isset($pack->type) ? "type," : "") . (isset($pack->intro_scene_id) ? "intro_scene_id," : "") . (isset($pack->latitude) ? "latitude," : "") . (isset($pack->longitude) ? "longitude," : "") . (isset($pack->network_level) ? "network_level," : "") . (isset($pack->allow_download) ? "allow_download," : "") . (isset($pack->preload_media) ? "preload_media," : "") . (isset($pack->moderated) ? "moderated," : "") . (isset($pack->version) ? "version," : "") . (isset($pack->colors_id) ? "colors_id," : "") . "created" . ") VALUES (" . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . (isset($pack->map_type) ? "'" . addslashes($pack->map_type) . "'," : "") . (isset($pack->map_focus) ? "'" . addslashes($pack->map_focus) . "'," : "") . (isset($pack->map_latitude) ? "'" . addslashes($pack->map_latitude) . "'," : "") . (isset($pack->map_longitude) ? "'" . addslashes($pack->map_longitude) . "'," : "") . (isset($pack->map_zoom_level) ? "'" . addslashes($pack->map_zoom_level) . "'," : "") . (isset($pack->map_show_player) ? "'" . addslashes($pack->map_show_player) . "'," : "") . (isset($pack->map_show_players) ? "'" . addslashes($pack->map_show_players) . "'," : "") . (isset($pack->map_offsite_mode) ? "'" . addslashes($pack->map_offsite_mode) . "'," : "") . (isset($pack->notebook_allow_comments) ? "'" . addslashes($pack->notebook_allow_comments) . "'," : "") . (isset($pack->notebook_allow_likes) ? "'" . addslashes($pack->notebook_allow_likes) . "'," : "") . (isset($pack->notebook_trigger_scene_id) ? "'" . addslashes($pack->notebook_trigger_scene_id) . "'," : "") . (isset($pack->notebook_trigger_requirement_root_package_id) ? "'" . addslashes($pack->notebook_trigger_requirement_root_package_id) . "'," : "") . (isset($pack->notebook_trigger_title) ? "'" . addslashes($pack->notebook_trigger_title) . "'," : "") . (isset($pack->notebook_trigger_icon_media_id) ? "'" . addslashes($pack->notebook_trigger_icon_media_id) . "'," : "") . (isset($pack->notebook_trigger_distance) ? "'" . addslashes($pack->notebook_trigger_distance) . "'," : "") . (isset($pack->notebook_trigger_infinite_distance) ? "'" . addslashes($pack->notebook_trigger_infinite_distance) . "'," : "") . (isset($pack->notebook_trigger_wiggle) ? "'" . addslashes($pack->notebook_trigger_wiggle) . "'," : "") . (isset($pack->notebook_trigger_show_title) ? "'" . addslashes($pack->notebook_trigger_show_title) . "'," : "") . (isset($pack->notebook_trigger_hidden) ? "'" . addslashes($pack->notebook_trigger_hidden) . "'," : "") . (isset($pack->notebook_trigger_on_enter) ? "'" . addslashes($pack->notebook_trigger_on_enter) . "'," : "") . (isset($pack->inventory_weight_cap) ? "'" . addslashes($pack->inventory_weight_cap) . "'," : "") . (isset($pack->is_siftr) ? "'" . addslashes($pack->is_siftr) . "'," : "") . (isset($pack->siftr_url) ? "'" . addslashes($pack->siftr_url) . "'," : "") . (isset($pack->published) ? "'" . addslashes($pack->published) . "'," : "") . (isset($pack->type) ? "'" . addslashes($pack->type) . "'," : "") . (isset($pack->intro_scene_id) ? "'" . addslashes($pack->intro_scene_id) . "'," : "") . (isset($pack->latitude) ? "'" . addslashes($pack->latitude) . "'," : "") . (isset($pack->longitude) ? "'" . addslashes($pack->longitude) . "'," : "") . (isset($pack->network_level) ? "'" . addslashes($pack->network_level) . "'," : "") . (isset($pack->allow_download) ? "'" . addslashes($pack->allow_download) . "'," : "") . (isset($pack->preload_media) ? "'" . addslashes($pack->preload_media) . "'," : "") . (isset($pack->moderated) ? "'" . addslashes($pack->moderated) . "'," : "") . (isset($pack->version) ? "'" . addslashes($pack->version) . "'," : "") . (isset($pack->colors_id) ? "'" . addslashes($pack->colors_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); dbconnection::queryInsert("INSERT INTO user_games (game_id, user_id, created) VALUES ('{$pack->game_id}','{$pack->auth->user_id}',CURRENT_TIMESTAMP)"); // game_id, type, name, icon, sort, created dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'QUESTS', '', '0', '1', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'MAP', '', '0', '2', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'INVENTORY', '', '0', '3', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'SCANNER', '', '0', '4', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'DECODER', '', '0', '5', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'PLAYER', '', '0', '6', CURRENT_TIMESTAMP)"); dbconnection::query("INSERT INTO tabs (game_id, type, name, icon_media_id, sort_index, created) VALUES ('{$pack->game_id}', 'NOTEBOOK', '', '0', '7', CURRENT_TIMESTAMP)"); mkdir(Config::v2_gamedata_folder . "/{$pack->game_id}", 0777); $pack->name = "Starting Scene"; $pack->description = ""; scenes::createScene($pack); return games::getGame($pack); }
public static function createWebHook($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"); } $pack->web_hook_id = dbconnection::queryInsert("INSERT INTO web_hooks (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->url) ? "url," : "") . (isset($pack->incoming) ? "incoming," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->url) ? "'" . addslashes($pack->url) . "'," : "") . (isset($pack->incoming) ? "'" . addslashes($pack->incoming) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return web_hooks::getWebHook($pack); }
public static function createOverlay($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"); } $pack->overlay_id = dbconnection::queryInsert("INSERT INTO overlays (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->media_id) ? "media_id," : "") . (isset($pack->top_left_latitude) ? "top_left_latitude," : "") . (isset($pack->top_left_longitude) ? "top_left_longitude," : "") . (isset($pack->top_right_latitude) ? "top_right_latitude," : "") . (isset($pack->top_right_longitude) ? "top_right_longitude," : "") . (isset($pack->bottom_left_latitude) ? "bottom_left_latitude," : "") . (isset($pack->bottom_left_longitude) ? "bottom_left_longitude," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . (isset($pack->top_left_latitude) ? "'" . addslashes($pack->top_left_latitude) . "'," : "") . (isset($pack->top_left_longitude) ? "'" . addslashes($pack->top_left_longitude) . "'," : "") . (isset($pack->top_right_latitude) ? "'" . addslashes($pack->top_right_latitude) . "'," : "") . (isset($pack->top_right_longitude) ? "'" . addslashes($pack->top_right_longitude) . "'," : "") . (isset($pack->bottom_left_latitude) ? "'" . addslashes($pack->bottom_left_latitude) . "'," : "") . (isset($pack->bottom_left_longitude) ? "'" . addslashes($pack->bottom_left_longitude) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return overlays::getOverlay($pack); }
public static function createTrigger($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"); } $pack->trigger_id = dbconnection::queryInsert("INSERT INTO triggers (" . "game_id," . (isset($pack->instance_id) ? "instance_id," : "") . (isset($pack->scene_id) ? "scene_id," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . (isset($pack->type) ? "type," : "") . (isset($pack->name) ? "name," : "") . (isset($pack->title) ? "title," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->latitude) ? "latitude," : "") . (isset($pack->longitude) ? "longitude," : "") . (isset($pack->distance) ? "distance," : "") . (isset($pack->infinite_distance) ? "infinite_distance," : "") . (isset($pack->wiggle) ? "wiggle," : "") . (isset($pack->show_title) ? "show_title," : "") . (isset($pack->hidden) ? "hidden," : "") . (isset($pack->trigger_on_enter) ? "trigger_on_enter," : "") . (isset($pack->qr_code) ? "qr_code," : "") . (isset($pack->seconds) ? "seconds," : "") . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . (isset($pack->instance_id) ? "'" . addslashes($pack->instance_id) . "'," : "") . (isset($pack->scene_id) ? "'" . addslashes($pack->scene_id) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . (isset($pack->type) ? "'" . addslashes($pack->type) . "'," : "") . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->title) ? "'" . addslashes($pack->title) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->latitude) ? "'" . addslashes($pack->latitude) . "'," : "") . (isset($pack->longitude) ? "'" . addslashes($pack->longitude) . "'," : "") . (isset($pack->distance) ? "'" . addslashes($pack->distance) . "'," : "") . (isset($pack->infinite_distance) ? "'" . addslashes($pack->infinite_distance) . "'," : "") . (isset($pack->wiggle) ? "'" . addslashes($pack->wiggle) . "'," : "") . (isset($pack->show_title) ? "'" . addslashes($pack->show_title) . "'," : "") . (isset($pack->hidden) ? "'" . addslashes($pack->hidden) . "'," : "") . (isset($pack->trigger_on_enter) ? "'" . addslashes($pack->trigger_on_enter) . "'," : "") . (isset($pack->qr_code) ? "'" . addslashes($pack->qr_code) . "'," : "") . (isset($pack->seconds) ? "'" . addslashes($pack->seconds) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return triggers::getTrigger($pack); }
public static function createItem($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"); } $pack->item_id = dbconnection::queryInsert("INSERT INTO items (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->media_id) ? "media_id," : "") . (isset($pack->droppable) ? "droppable," : "") . (isset($pack->destroyable) ? "destroyable," : "") . (isset($pack->max_qty_in_inventory) ? "max_qty_in_inventory," : "") . (isset($pack->weight) ? "weight," : "") . (isset($pack->url) ? "url," : "") . (isset($pack->type) ? "type," : "") . (isset($pack->delta_notification) ? "delta_notification," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . (isset($pack->droppable) ? "'" . addslashes($pack->droppable) . "'," : "") . (isset($pack->destroyable) ? "'" . addslashes($pack->destroyable) . "'," : "") . (isset($pack->max_qty_in_inventory) ? "'" . addslashes($pack->max_qty_in_inventory) . "'," : "") . (isset($pack->weight) ? "'" . addslashes($pack->weight) . "'," : "") . (isset($pack->url) ? "'" . addslashes($pack->url) . "'," : "") . (isset($pack->type) ? "'" . addslashes($pack->type) . "'," : "") . (isset($pack->delta_notification) ? "'" . addslashes($pack->delta_notification) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return items::getItem($pack); }
public static function createTab($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"); } $pack->tab_id = dbconnection::queryInsert("INSERT INTO tabs (" . "game_id," . (isset($pack->type) ? "type," : "") . (isset($pack->name) ? "name," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->content_id) ? "content_id," : "") . (isset($pack->info) ? "info," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . (isset($pack->sort_index) ? "sort_index," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->type) ? "'" . addslashes($pack->type) . "'," : "") . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->content_id) ? "'" . addslashes($pack->content_id) . "'," : "") . (isset($pack->info) ? "'" . addslashes($pack->info) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . (isset($pack->sort_index) ? "'" . addslashes($pack->sort_index) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return tabs::getTab($pack); }
public static function createQuest($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"); } $pack->quest_id = dbconnection::queryInsert("INSERT INTO quests (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->active_icon_media_id) ? "active_icon_media_id," : "") . (isset($pack->active_media_id) ? "active_media_id," : "") . (isset($pack->active_description) ? "active_description," : "") . (isset($pack->active_notification_type) ? "active_notification_type," : "") . (isset($pack->active_function) ? "active_function," : "") . (isset($pack->active_requirement_root_package_id) ? "active_requirement_root_package_id," : "") . (isset($pack->active_event_package_id) ? "active_event_package_id," : "") . (isset($pack->complete_icon_media_id) ? "complete_icon_media_id," : "") . (isset($pack->complete_media_id) ? "complete_media_id," : "") . (isset($pack->complete_description) ? "complete_description," : "") . (isset($pack->complete_notification_type) ? "complete_notification_type," : "") . (isset($pack->complete_function) ? "complete_function," : "") . (isset($pack->complete_requirement_root_package_id) ? "complete_requirement_root_package_id," : "") . (isset($pack->complete_event_package_id) ? "complete_event_package_id," : "") . (isset($pack->sort_index) ? "sort_index," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->active_icon_media_id) ? "'" . addslashes($pack->active_icon_media_id) . "'," : "") . (isset($pack->active_media_id) ? "'" . addslashes($pack->active_media_id) . "'," : "") . (isset($pack->active_description) ? "'" . addslashes($pack->active_description) . "'," : "") . (isset($pack->active_notification_type) ? "'" . addslashes($pack->active_notification_type) . "'," : "") . (isset($pack->active_function) ? "'" . addslashes($pack->active_function) . "'," : "") . (isset($pack->active_requirement_root_package_id) ? "'" . addslashes($pack->active_requirement_root_package_id) . "'," : "") . (isset($pack->active_event_package_id) ? "'" . addslashes($pack->active_event_package_id) . "'," : "") . (isset($pack->complete_icon_media_id) ? "'" . addslashes($pack->complete_icon_media_id) . "'," : "") . (isset($pack->complete_media_id) ? "'" . addslashes($pack->complete_media_id) . "'," : "") . (isset($pack->complete_description) ? "'" . addslashes($pack->complete_description) . "'," : "") . (isset($pack->complete_notification_type) ? "'" . addslashes($pack->complete_notification_type) . "'," : "") . (isset($pack->complete_function) ? "'" . addslashes($pack->complete_function) . "'," : "") . (isset($pack->complete_requirement_root_package_id) ? "'" . addslashes($pack->complete_requirement_root_package_id) . "'," : "") . (isset($pack->complete_event_package_id) ? "'" . addslashes($pack->complete_event_package_id) . "'," : "") . (isset($pack->sort_index) ? "'" . addslashes($pack->sort_index) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return quests::getQuest($pack); }
public static function createInstance($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"); } $pack->instance_id = dbconnection::queryInsert("INSERT INTO instances (" . "game_id," . (isset($pack->object_type) ? "object_type," : "") . (isset($pack->object_id) ? "object_id," : "") . (isset($pack->qty) ? "qty," : "") . (isset($pack->infinite_qty) ? "infinite_qty," : "") . (isset($pack->factory_id) ? "factory_id," : "") . (isset($pack->owner_type) ? "owner_type," : "") . (isset($pack->owner_id) ? "owner_id," : "") . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . (isset($pack->object_type) ? "'" . addslashes($pack->object_type) . "'," : "") . (isset($pack->object_id) ? "'" . addslashes($pack->object_id) . "'," : "") . (isset($pack->qty) ? "'" . addslashes($pack->qty) . "'," : "") . (isset($pack->infinite_qty) ? "'" . addslashes($pack->infinite_qty) . "'," : "") . (isset($pack->factory_id) ? "'" . addslashes($pack->factory_id) . "'," : "") . (isset($pack->owner_type) ? "'" . addslashes($pack->owner_type) . "'," : "") . (isset($pack->owner_id) ? "'" . addslashes($pack->owner_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return instances::getInstance($pack); }
public static function createGroup($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"); } $pack->group_id = dbconnection::queryInsert("INSERT INTO groups (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return groups::getGroup($pack); }
public static function createObjectTag($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"); } $pack->object_tag_id = dbconnection::queryInsert("INSERT INTO object_tags (" . "game_id," . (isset($pack->object_type) ? "object_type," : "") . (isset($pack->object_id) ? "object_id," : "") . (isset($pack->tag_id) ? "tag_id," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->object_type) ? "'" . addslashes($pack->object_type) . "'," : "") . (isset($pack->object_id) ? "'" . addslashes($pack->object_id) . "'," : "") . (isset($pack->tag_id) ? "'" . addslashes($pack->tag_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return tags::getObjectTag($pack); }
public static function createWebPage($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"); } $pack->web_page_id = dbconnection::queryInsert("INSERT INTO web_pages (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->url) ? "url," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->back_button_enabled) ? "back_button_enabled," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->url) ? "'" . addslashes($pack->url) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->back_button_enabled) ? "'" . addslashes($pack->back_button_enabled) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return web_pages::getWebPage($pack); }
public static function createNoteComment($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $pack->note_comment_id = dbconnection::queryInsert("INSERT INTO note_comments (" . "game_id," . "note_id," . "user_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . "'" . $pack->note_id . "'," . "'" . $pack->auth->user_id . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); client::logPlayerCreatedComment($pack); games::bumpGameVersion($pack); return note_comments::getNoteComment($pack); }
public static function createFactory($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"); } $pack->factory_id = dbconnection::queryInsert("INSERT INTO factories (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->object_type) ? "object_type," : "") . (isset($pack->object_id) ? "object_id," : "") . (isset($pack->seconds_per_production) ? "seconds_per_production," : "") . (isset($pack->production_probability) ? "production_probability," : "") . (isset($pack->max_production) ? "max_production," : "") . (isset($pack->produce_expiration_time) ? "produce_expiration_time," : "") . (isset($pack->produce_expire_on_view) ? "produce_expire_on_view," : "") . (isset($pack->production_bound_type) ? "production_bound_type," : "") . (isset($pack->location_bound_type) ? "location_bound_type," : "") . (isset($pack->min_production_distance) ? "min_production_distance," : "") . (isset($pack->max_production_distance) ? "max_production_distance," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . (isset($pack->trigger_latitude) ? "trigger_latitude," : "") . (isset($pack->trigger_longitude) ? "trigger_longitude," : "") . (isset($pack->trigger_distance) ? "trigger_distance," : "") . (isset($pack->trigger_infinite_distance) ? "trigger_infinite_distance," : "") . (isset($pack->trigger_on_enter) ? "trigger_on_enter," : "") . (isset($pack->trigger_hidden) ? "trigger_hidden," : "") . (isset($pack->trigger_wiggle) ? "trigger_wiggle," : "") . (isset($pack->trigger_title) ? "trigger_title," : "") . (isset($pack->trigger_icon_media_id) ? "trigger_icon_media_id," : "") . (isset($pack->trigger_show_title) ? "trigger_show_title," : "") . (isset($pack->trigger_requirement_root_package_id) ? "trigger_requirement_root_package_id," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->object_type) ? "'" . addslashes($pack->object_type) . "'," : "") . (isset($pack->object_id) ? "'" . addslashes($pack->object_id) . "'," : "") . (isset($pack->seconds_per_production) ? "'" . addslashes($pack->seconds_per_production) . "'," : "") . (isset($pack->production_probability) ? "'" . addslashes($pack->production_probability) . "'," : "") . (isset($pack->max_production) ? "'" . addslashes($pack->max_production) . "'," : "") . (isset($pack->produce_expiration_time) ? "'" . addslashes($pack->produce_expiration_time) . "'," : "") . (isset($pack->produce_expire_on_view) ? "'" . addslashes($pack->produce_expire_on_view) . "'," : "") . (isset($pack->production_bound_type) ? "'" . addslashes($pack->production_bound_type) . "'," : "") . (isset($pack->location_bound_type) ? "'" . addslashes($pack->location_bound_type) . "'," : "") . (isset($pack->min_production_distance) ? "'" . addslashes($pack->min_production_distance) . "'," : "") . (isset($pack->max_production_distance) ? "'" . addslashes($pack->max_production_distance) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . (isset($pack->trigger_latitude) ? "'" . addslashes($pack->trigger_latitude) . "'," : "") . (isset($pack->trigger_longitude) ? "'" . addslashes($pack->trigger_longitude) . "'," : "") . (isset($pack->trigger_distance) ? "'" . addslashes($pack->trigger_distance) . "'," : "") . (isset($pack->trigger_infinite_distance) ? "'" . addslashes($pack->trigger_infinite_distance) . "'," : "") . (isset($pack->trigger_on_enter) ? "'" . addslashes($pack->trigger_on_enter) . "'," : "") . (isset($pack->trigger_hidden) ? "'" . addslashes($pack->trigger_hidden) . "'," : "") . (isset($pack->trigger_wiggle) ? "'" . addslashes($pack->trigger_wiggle) . "'," : "") . (isset($pack->trigger_title) ? "'" . addslashes($pack->trigger_title) . "'," : "") . (isset($pack->trigger_icon_media_id) ? "'" . addslashes($pack->trigger_icon_media_id) . "'," : "") . (isset($pack->trigger_show_title) ? "'" . addslashes($pack->trigger_show_title) . "'," : "") . (isset($pack->trigger_requirement_root_package_id) ? "'" . addslashes($pack->trigger_requirement_root_package_id) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return factories::getFactory($pack); }
public static function createPlaque($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"); } $pack->plaque_id = dbconnection::queryInsert("INSERT INTO plaques (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->icon_media_id) ? "icon_media_id," : "") . (isset($pack->media_id) ? "media_id," : "") . (isset($pack->event_package_id) ? "event_package_id," : "") . (isset($pack->back_button_enabled) ? "back_button_enabled," : "") . (isset($pack->continue_function) ? "continue_function," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->icon_media_id) ? "'" . addslashes($pack->icon_media_id) . "'," : "") . (isset($pack->media_id) ? "'" . addslashes($pack->media_id) . "'," : "") . (isset($pack->event_package_id) ? "'" . addslashes($pack->event_package_id) . "'," : "") . (isset($pack->back_button_enabled) ? "'" . addslashes($pack->back_button_enabled) . "'," : "") . (isset($pack->continue_function) ? "'" . addslashes($pack->continue_function) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return plaques::getPlaque($pack); }
public static function addEditorToGame($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"); } //note $pack->user_id is DIFFERENT than $pack->auth->user_id dbconnection::queryInsert("INSERT INTO user_games (game_id, user_id, created) VALUES ('{$pack->game_id}','{$pack->user_id}',CURRENT_TIMESTAMP)"); games::bumpGameVersion($pack); return new return_package(0); }
private static function applyUpgrade($user_id, $maj, $min) { $file = "db/upgrades/" . $maj . "." . $min . ".sql"; $upgrade = fopen($file, "r"); while (!feof($upgrade)) { $query = fgets($upgrade); if (preg_match("@^\\s*\$@is", $query)) { continue; } //ignore whitespace dbconnection::query($query); } fclose($upgrade); dbconnection::queryInsert("INSERT INTO db_upgrades (user_id, version_major, version_minor, timestamp) VALUES ('{$user_id}', '{$maj}', '{$min}', CURRENT_TIMESTAMP)"); }
public static function createScene($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"); } $pack->scene_id = dbconnection::queryInsert("INSERT INTO scenes (" . "game_id," . (isset($pack->name) ? "name," : "") . (isset($pack->description) ? "description," : "") . (isset($pack->editor_x) ? "editor_x," : "") . (isset($pack->editor_y) ? "editor_y," : "") . "created" . ") VALUES (" . "'" . $pack->game_id . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . (isset($pack->description) ? "'" . addslashes($pack->description) . "'," : "") . (isset($pack->editor_x) ? "'" . addslashes($pack->editor_x) . "'," : "") . (isset($pack->editor_y) ? "'" . addslashes($pack->editor_y) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); //Update game's intro scene if it doesn't yet exist $game = dbconnection::queryObject("SELECT * FROM games WHERE game_id = '{$pack->game_id}'"); if (!dbconnection::queryObject("SELECT * FROM scenes WHERE scene_id = '{$game->intro_scene_id}' AND game_id = '{$game->game_id}'")) { dbconnection::query("UPDATE games SET intro_scene_id = '{$pack->scene_id}' WHERE game_id = '{$pack->game_id}'"); } games::bumpGameVersion($pack); return scenes::getScene($pack); }
public static function createEvent($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"); } if (isset($pack->event) && $pack->event == 'GIVE_ITEM') { $pack->event = 'GIVE_ITEM_PLAYER'; } if (isset($pack->event) && $pack->event == 'TAKE_ITEM') { $pack->event = 'TAKE_ITEM_PLAYER'; } $pack->event_id = dbconnection::queryInsert("INSERT INTO events (" . "game_id," . "event_package_id," . (isset($pack->event) ? "event," : "") . (isset($pack->qty) ? "qty," : "") . (isset($pack->content_id) ? "content_id," : "") . (isset($pack->script) ? "script," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . "'" . addslashes($pack->event_package_id) . "'," . (isset($pack->event) ? "'" . addslashes($pack->event) . "'," : "") . (isset($pack->qty) ? "'" . addslashes($pack->qty) . "'," : "") . (isset($pack->content_id) ? "'" . addslashes($pack->content_id) . "'," : "") . (isset($pack->script) ? "'" . addslashes($pack->script) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return events::getEvent($pack); }
public static function createRequirementAndPackage($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"); } if (!$pack->requirement_root_package_id) { return; } $requirementAndPackageId = dbconnection::queryInsert("INSERT INTO requirement_and_packages (" . "game_id," . "requirement_root_package_id," . (isset($pack->name) ? "name," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . "'" . addslashes($pack->requirement_root_package_id) . "'," . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); for ($i = 0; $pack->atoms && $i < count($pack->atoms); $i++) { $pack->atoms[$i]->requirement_and_package_id = $requirementAndPackageId; $pack->atoms[$i]->game_id = $pack->game_id; $pack->atoms[$i]->auth = $pack->auth; requirements::createRequirementAtom($pack->atoms[$i]); } games::bumpGameVersion($pack); }
private static function importGameData($pack) { $tables = array(); //not actually used $columns = array(); //not actually used $coltablemap = array(); duplicate::getSchema($tables, $columns, $coltablemap); $maps = array(); $import = $pack->import; $game_id = $import->game_id; $table_data = $import->table_data; for ($i = 0; $i < count($table_data); $i++) { $table = $table_data[$i]->table; $cols = $table_data[$i]->columns; $old_data = $table_data[$i]->data; $maps[$table] = array(); $maps[$table][0] = 0; for ($j = 0; $j < count($old_data); $j++) { $old_datum = $old_data[$j]; $col_query = ""; $val_query = ""; $old_id = 0; for ($k = 0; $k < count($cols); $k++) { $col = $cols[$k]; $old_datum[$col->name] = addslashes($old_datum[$col->name]); //best thing I can think of for sanitation... if ($col->meta == 'id') { $old_id = $old_datum[$col->name]; //just store old id } else { if ($col->meta == 'timestamp') { if ($col_query != "") { $col_query .= ', '; $val_query .= ', '; } $col_query .= "{$col->name}"; $val_query .= "CURRENT_TIMESTAMP"; } else { if ($col_query != "") { $col_query .= ', '; $val_query .= ', '; } $col_query .= "{$col->name}"; if ($col->meta == 'special') { if ($col->name == 'siftr_url') { $val_query .= "NULL"; } else { $val_query .= "'0'"; } } else { if ($col->meta == 'map') { $val_query .= "'0'"; } else { $val_query .= "'{$old_datum[$col->name]}'"; } } } } } if ($pack->verbose) { echo "INSERT INTO {$table} ({$col_query}) VALUES ({$val_query});"; } $maps[$table][$old_id] = dbconnection::queryInsert("INSERT INTO {$table} ({$col_query}) VALUES ({$val_query});"); if ($pack->verbose) { echo " (id: {$maps[$table][$old_id]})\n"; } } } //NOTE- must do setup normally handled by games::createGame mkdir(Config::v2_gamedata_folder . "/{$maps['games'][$game_id]}", 0777); //second pass- fill in bogus mappings with known maps for ($i = 0; $i < count($table_data); $i++) { $table = $table_data[$i]->table; $cols = $table_data[$i]->columns; $old_data = $table_data[$i]->data; for ($j = 0; $j < count($old_data); $j++) { $old_datum = $old_data[$j]; $update_query = ""; $id_col = ""; $old_id = 0; for ($k = 0; $k < count($cols); $k++) { $col = $cols[$k]; $old_datum[$col->name] = addslashes($old_datum[$col->name]); //best thing I can think of for sanitation... if ($col->meta == 'id') { $id_col = $col->name; $old_id = $old_datum[$col->name]; //just store old id to find new id to update } else { if ($col->meta == '') { } else { if ($col->meta == 'map') { if ($update_query != '') { $update_query .= ', '; } $update_query .= "{$col->name} = '{$maps[$coltablemap[$col->name]][$old_datum[$col->name]]}'"; } else { if ($col->meta == 'special') { if ($update_query != '') { $update_query .= ', '; } if ($col->name == 'siftr_url') { $update_query .= "siftr_url = NULL"; } else { if ($col->name == 'file_folder') { //copy media to new folder $filenametitle = substr($old_datum['file_name'], 0, strrpos($old_datum['file_name'], '.')); $filenameext = substr($old_datum['file_name'], strrpos($old_datum['file_name'], '.')); $old_file_path = Config::v2_gamedata_folder . "/" . $old_datum['file_folder'] . "/" . $old_datum['file_name']; $new_file_path = Config::v2_gamedata_folder . "/" . $maps['games'][$game_id] . "/" . $old_datum['file_name']; $new_file_path_128 = Config::v2_gamedata_folder . "/" . $maps['games'][$game_id] . "/" . $filenametitle . "_128" . $filenameext; if (file_exists($old_file_path)) { copy($old_file_path, $new_file_path); if ($filenameext == ".jpg" || $filenameext == ".png" || $filenameext == ".gif") { try { if (exif_imagetype($new_file_path)) { $image = new Imagick($new_file_path); //aspect fill to 128x128 $w = $image->getImageWidth(); $h = $image->getImageHeight(); if ($w < $h) { $image->thumbnailImage(128, 128 / $w * $h, 1, 1); } else { $image->thumbnailImage(128 / $h * $w, 128, 1, 1); } //crop around center $w = $image->getImageWidth(); $h = $image->getImageHeight(); $image->cropImage(128, 128, ($w - 128) / 2, ($h - 128) / 2); $image->writeImage($new_file_path_128); } } catch (ImagickException $e) { //do nothing } } } $update_query .= "file_folder = '{$maps['games'][$game_id]}'"; } else { if ($col->name == 'content_id') { if ($table == 'events') { $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; } else { if ($table == 'requirement_atoms') { switch ($old_datum['requirement']) { case 'PLAYER_HAS_ITEM': case 'PLAYER_HAS_TAGGED_ITEM': case 'GAME_HAS_ITEM': case 'GAME_HAS_TAGGED_ITEM': case 'PLAYER_VIEWED_ITEM': $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_PLAQUE': $update_query .= "content_id = '{$maps['plaques'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_DIALOG': $update_query .= "content_id = '{$maps['dialogs'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_DIALOG_SCRIPT': $update_query .= "content_id = '{$maps['dialog_scripts'][$old_datum['content_id']]}'"; break; case 'PLAYER_VIEWED_WEB_PAGE': $update_query .= "content_id = '{$maps['web_pages'][$old_datum['content_id']]}'"; break; case 'PLAYER_HAS_COMPLETED_QUEST': $update_query .= "content_id = '{$maps['quests'][$old_datum['content_id']]}'"; break; case 'PLAYER_HAS_RECEIVED_INCOMING_WEB_HOOK': $update_query .= "content_id = '{$maps['web_hooks'][$old_datum['content_id']]}'"; break; case 'ALWAYS_TRUE': case 'ALWAYS_FALSE': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_IMAGE': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_AUDIO': case 'PLAYER_HAS_UPLOADED_MEDIA_ITEM_VIDEO': case 'PLAYER_HAS_NOTE': case 'PLAYER_HAS_NOTE_WITH_TAG': case 'PLAYER_HAS_NOTE_WITH_LIKES': case 'PLAYER_HAS_NOTE_WITH_COMMENTS': case 'PLAYER_HAS_GIVEN_NOTE_COMMENTS': default: $update_query .= "content_id = '{$old_datum['content_id']}'"; break; } } else { if ($table == 'tabs') { switch ($old_datum['type']) { case 'NOTE': $update_query .= "content_id = '{$maps['notes'][$old_datum['content_id']]}'"; break; case 'DIALOG': $update_query .= "content_id = '{$maps['dialogs'][$old_datum['content_id']]}'"; break; case 'ITEM': $update_query .= "content_id = '{$maps['items'][$old_datum['content_id']]}'"; break; case 'PLAQUE': $update_query .= "content_id = '{$maps['plaques'][$old_datum['content_id']]}'"; break; case 'WEB_PAGE': $update_query .= "content_id = '{$maps['web_pages'][$old_datum['content_id']]}'"; break; case 'MAP': case 'DECODER': case 'SCANNER': case 'QUESTS': case 'INVENTORY': case 'PLAYER': case 'NOTEBOOK': default: $update_query .= "content_id = '{$old_datum['content_id']}'"; break; } } } } } else { if ($col->name == 'object_id') { switch ($old_datum['object_type']) { case 'PLAQUE': $update_query .= "object_id = '{$maps['plaques'][$old_datum['object_id']]}'"; break; case 'ITEM': $update_query .= "object_id = '{$maps['items'][$old_datum['object_id']]}'"; break; case 'DIALOG': $update_query .= "object_id = '{$maps['dialogs'][$old_datum['object_id']]}'"; break; case 'WEB_PAGE': $update_query .= "object_id = '{$maps['web_pages'][$old_datum['object_id']]}'"; break; case 'NOTE': $update_query .= "object_id = '{$maps['notes'][$old_datum['object_id']]}'"; break; case 'FACTORY': $update_query .= "object_id = '{$maps['factories'][$old_datum['object_id']]}'"; break; case 'SCENE': $update_query .= "object_id = '{$maps['scenes'][$old_datum['object_id']]}'"; break; default: $update_query .= "object_id = '{$old_datum['object_id']}'"; break; } } else { if ($col->name == 'link_id') { switch ($old_datum['link_type']) { case 'EXIT_TO_PLAQUE': $update_query .= "link_id = '{$maps['plaques'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_ITEM': $update_query .= "link_id = '{$maps['items'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_WEB_PAGE': $update_query .= "link_id = '{$maps['web_pages'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_DIALOG': $update_query .= "link_id = '{$maps['dialogs'][$old_datum['link_id']]}'"; break; case 'EXIT_TO_TAB': $update_query .= "link_id = '{$maps['tabs'][$old_datum['link_id']]}'"; break; case 'DIALOG_SCRIPT': $update_query .= "link_id = '{$maps['dialog_scripts'][$old_datum['link_id']]}'"; break; case 'EXIT': default: $update_query .= "link_id = '{$old_datum['link_id']}'"; break; } } } } } } } } } } } if ($update_query != "") { if ($pack->verbose) { echo "UPDATE {$table} SET {$update_query} WHERE {$id_col} = '{$maps[$table][$old_id]}';"; } dbconnection::query("UPDATE {$table} SET {$update_query} WHERE {$id_col} = '{$maps[$table][$old_id]}';"); if ($pack->verbose) { echo " (id: {$maps[$table][$old_id]})\n"; } } } } // Now make the game visible to the user, so they don't see a half-imported game dbconnection::query("INSERT INTO user_games (game_id, user_id, created) VALUES ('{$maps['games'][$game_id]}','{$pack->auth->user_id}',CURRENT_TIMESTAMP);"); $pack->game_id = $maps['games'][$game_id]; return games::getGame($pack); }
public static function logIn($pack) { if ($pack->auth && $pack->auth->user_id) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $user = dbconnection::queryObject("SELECT * FROM users WHERE user_id = '{$pack->auth->user_id}'"); } else { if (!($user = dbconnection::queryObject("SELECT * FROM users WHERE user_name = '{$pack->user_name}'")) || hash("sha256", $user->salt . $pack->password) != $user->hash) { /* * BEGIN MIGRATION INJECTION */ //Login Failed. If username/password doesn't exist, check if we can re-route this to a migrate. if (!$user && !$pack->no_auto_migrate) { //miguser api for reference //public static function migrateUser($playerName, $playerPass, $editorName, $editorPass, $newName, $newPass, $newDisplay, $newEmail) //first try to migrate full editor & player $migArgs = $pack->user_name . "/" . $pack->password . "/" . $pack->user_name . "/" . $pack->password . "/" . $pack->user_name . "/" . $pack->password . "/0/0"; $mig = bridgeService("migration", "migration", "migrateUser", $migArgs, false); if ($mig->returnCode !== 0) { //if that doesn't work, just try editor $migArgs = "0/0/" . $pack->user_name . "/" . $pack->password . "/" . $pack->user_name . "/" . $pack->password . "/0/0"; $mig = bridgeService("migration", "migration", "migrateUser", $migArgs, false); } //if THAT doesn't work, bad login if ($mig->returnCode !== 0) { return new return_package(1, NULL, "Incorrect username/password"); } else { //pretend the user was correctly recieved $user = dbconnection::queryObject("SELECT * FROM users WHERE user_name = '{$pack->user_name}'"); } } else { //there already exists a user but they have an invalid password (so drop out of migration injection flow) /* * END MIGRATION INJECTION */ return new return_package(1, NULL, "Incorrect username/password"); } } } $ret = new stdClass(); $ret->user_id = $user->user_id; $ret->user_name = $user->user_name; $ret->display_name = $user->display_name; $ret->media_id = $user->media_id; if ($pack->permission == "read" || $pack->auth->permission == "read") { $ret->read_key = $user->read_key; } if ($pack->permission == "write" || $pack->auth->permission == "write") { $ret->write_key = $user->write_key; } if ($pack->permission == "read_write" || $pack->auth->permission == "read_write") { $ret->read_write_key = $user->read_write_key; } dbconnection::queryInsert("INSERT INTO user_log (user_id, event_type, created) VALUES ('{$ret->user_id}', 'LOG_IN', CURRENT_TIMESTAMP);"); return new return_package(0, $ret); }
public static function createDialogOption($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"); } $pack->dialog_option_id = dbconnection::queryInsert("INSERT INTO dialog_options (" . "game_id," . (isset($pack->dialog_id) ? "dialog_id," : "") . (isset($pack->parent_dialog_script_id) ? "parent_dialog_script_id," : "") . (isset($pack->prompt) ? "prompt," : "") . (isset($pack->link_type) ? "link_type," : "") . (isset($pack->link_id) ? "link_id," : "") . (isset($pack->link_info) ? "link_info," : "") . (isset($pack->requirement_root_package_id) ? "requirement_root_package_id," : "") . (isset($pack->sort_index) ? "sort_index," : "") . "created" . ") VALUES (" . "'" . addslashes($pack->game_id) . "'," . (isset($pack->dialog_id) ? "'" . addslashes($pack->dialog_id) . "'," : "") . (isset($pack->parent_dialog_script_id) ? "'" . addslashes($pack->parent_dialog_script_id) . "'," : "") . (isset($pack->prompt) ? "'" . addslashes($pack->prompt) . "'," : "") . (isset($pack->link_type) ? "'" . addslashes($pack->link_type) . "'," : "") . (isset($pack->link_id) ? "'" . addslashes($pack->link_id) . "'," : "") . (isset($pack->link_info) ? "'" . addslashes($pack->link_info) . "'," : "") . (isset($pack->requirement_root_package_id) ? "'" . addslashes($pack->requirement_root_package_id) . "'," : "") . (isset($pack->sort_index) ? "'" . addslashes($pack->sort_index) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return dialogs::getDialogOption($pack); }
public static function createMedia($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $filenameext = strtolower(substr($pack->file_name, strrpos($pack->file_name, '.') + 1)); if ($filenameext == "jpeg") { $filenameext = "jpg"; } //sanity $filename = md5((string) microtime() . $pack->file_name); $newfilename = 'aris' . $filename . '.' . $filenameext; $resizedfilename = 'aris' . $filename . '_resized.' . $filenameext; $newthumbfilename = 'aris' . $filename . '_128.' . $filenameext; // Make sure playerUploaded requirements keep in sync with this list if ($filenameext != "jpg" && $filenameext != "png" && $filenameext != "gif" && $filenameext != "mp4" && $filenameext != "mov" && $filenameext != "m4v" && $filenameext != "3gp" && $filenameext != "caf" && $filenameext != "mp3" && $filenameext != "aac" && $filenameext != "m4a") { return new return_package(1, NULL, "Invalid filetype: '{$filenameext}'"); } $filefolder = ""; if ($pack->game_id) { $filefolder = $pack->game_id; } else { $filefolder = "players"; } $fspath = Config::v2_gamedata_folder . "/" . $filefolder . "/" . $newfilename; $resizedpath = Config::v2_gamedata_folder . "/" . $filefolder . "/" . $resizedfilename; $fsthumbpath = Config::v2_gamedata_folder . "/" . $filefolder . "/" . $newthumbfilename; $fp = fopen($fspath, 'w'); if (!$fp) { return new return_package(1, NULL, "Couldn't open file:{$fspath}"); } fwrite($fp, base64_decode($pack->data)); fclose($fp); $did_resize = false; if ($filenameext == "jpg" || $filenameext == "png" || $filenameext == "gif") { if (isset($pack->resize)) { $image = new Imagick($fspath); // Reorient based on EXIF tag switch ($image->getImageOrientation()) { case Imagick::ORIENTATION_UNDEFINED: // We assume normal orientation break; case Imagick::ORIENTATION_TOPLEFT: // All good break; case Imagick::ORIENTATION_TOPRIGHT: $image->flopImage(); break; case Imagick::ORIENTATION_BOTTOMRIGHT: $image->rotateImage('#000', 180); break; case Imagick::ORIENTATION_BOTTOMLEFT: $image->rotateImage('#000', 180); $image->flopImage(); break; case Imagick::ORIENTATION_LEFTTOP: $image->rotateImage('#000', 90); $image->flopImage(); break; case Imagick::ORIENTATION_RIGHTTOP: $image->rotateImage('#000', 90); break; case Imagick::ORIENTATION_RIGHTBOTTOM: $image->rotateImage('#000', -90); $image->flopImage(); break; case Imagick::ORIENTATION_LEFTBOTTOM: $image->rotateImage('#000', -90); break; } $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT); // Resize image proportionally so min(width, height) == $pack->resize $w = $image->getImageWidth(); $h = $image->getImageHeight(); if ($w < $h) { $image->resizeImage($pack->resize, $pack->resize / $w * $h, Imagick::FILTER_LANCZOS, 1); } else { $image->resizeImage($pack->resize / $h * $w, $pack->resize, Imagick::FILTER_LANCZOS, 1); } $image->setImageCompression(Imagick::COMPRESSION_JPEG); $image->setImageCompressionQuality(40); $image->writeImage($resizedpath); $did_resize = true; } $image = new Imagick(isset($pack->resize) ? $resizedpath : $fspath); //aspect fill to 128x128 $w = $image->getImageWidth(); $h = $image->getImageHeight(); if ($w < $h) { $image->thumbnailImage(128, 128 / $w * $h, 1, 1); } else { $image->thumbnailImage(128 / $h * $w, 128, 1, 1); } //crop around center $w = $image->getImageWidth(); $h = $image->getImageHeight(); $image->cropImage(128, 128, ($w - 128) / 2, ($h - 128) / 2); $image->writeImage($fsthumbpath); } if ($did_resize) { unlink($fspath); } // after making the 128 thumbnail $pack->media_id = dbconnection::queryInsert("INSERT INTO media (" . "file_folder," . "file_name," . (isset($pack->game_id) ? "game_id," : "") . (isset($pack->auth->user_id) ? "user_id," : "") . (isset($pack->name) ? "name," : "") . "created" . ") VALUES (" . "'" . $filefolder . "'," . "'" . ($did_resize ? $resizedfilename : $newfilename) . "'," . (isset($pack->game_id) ? "'" . addslashes($pack->game_id) . "'," : "") . (isset($pack->auth->user_id) ? "'" . addslashes($pack->auth->user_id) . "'," : "") . (isset($pack->name) ? "'" . addslashes($pack->name) . "'," : "") . "CURRENT_TIMESTAMP" . ")"); games::bumpGameVersion($pack); return media::getMedia($pack); }
public static function logPlayerCreatedComment($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } dbconnection::queryInsert("INSERT INTO user_log (user_id, game_id, event_type, content_id, created) VALUES ('{$pack->auth->user_id}', '{$pack->game_id}', 'GIVE_NOTE_COMMENT', '{$pack->note_comment_id}', CURRENT_TIMESTAMP);"); return new return_package(0); }
public static function likeNote($pack) { $pack->auth->permission = "read_write"; if (!users::authenticateUser($pack->auth)) { return new return_package(6, NULL, "Failed Authentication"); } $existing = dbconnection::queryObject("SELECT * FROM note_likes" . " WHERE game_id = '" . intval($pack->game_id) . "'" . " AND note_id = '" . intval($pack->note_id) . "'" . " AND user_id = '" . intval($pack->auth->user_id) . "'"); if ($existing) { return new return_package(0); } dbconnection::queryInsert("INSERT INTO note_likes" . " (game_id, note_id, user_id, created)" . " VALUES" . " ( '" . intval($pack->game_id) . "'" . " , '" . intval($pack->note_id) . "'" . " , '" . intval($pack->auth->user_id) . "'" . " , CURRENT_TIMESTAMP" . " )"); return new return_package(0); }