Esempio n. 1
0
 public static function deleteScene($pack)
 {
     $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM scenes WHERE scene_id = '{$pack->scene_id}'")->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM scenes WHERE scene_id = '{$pack->scene_id}' LIMIT 1");
     //cleanup
     $s = dbconnection::queryObject("SELECT * FROM scenes WHERE game_id = '{$pack->game_id}' LIMIT 1");
     $s_id = $s ? $s->scene_id : 0;
     dbconnection::query("UPDATE games SET intro_scene_id = '{$s_id}' WHERE intro_scene_id = '{$pack->scene_id}'");
     $triggers = dbconnection::queryArray("SELECT * FROM triggers WHERE scene_id  = '{$pack->scene_id}'");
     for ($i = 0; $i < count($triggers); $i++) {
         $pack->trigger_id = $triggers[$i]->trigger_id;
         triggers::deleteTrigger($pack);
     }
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'SCENE' AND object_id = '{$pack->scene_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         instances::deleteInstance($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 2
0
 public static function createTriggerAndInstance($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");
     }
 }
Esempio n. 3
0
 public static function deleteItem($pack)
 {
     $item = dbconnection::queryObject("SELECT * FROM items WHERE item_id = '{$pack->item_id}'");
     $pack->auth->game_id = $item->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM items WHERE item_id = '{$pack->item_id}' LIMIT 1");
     //cleanup
     $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_ITEM' AND link_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($options); $i++) {
         $pack->dialog_option_id = $options[$i]->dialog_option_id;
         dialogs::deleteDialogOption($pack);
     }
     $tabs = dbconnection::queryArray("SELECT * FROM tabs WHERE type = 'ITEM' AND content_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($tabs); $i++) {
         $pack->tab_id = $tabs[$i]->tab_id;
         tabs::deleteTab($pack);
     }
     $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($tags); $i++) {
         $pack->object_tag_id = $tags[$i]->object_tag_id;
         tags::deleteObjectTag($pack);
     }
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         instances::deleteInstance($pack);
     }
     $factories = dbconnection::queryArray("SELECT * FROM factories WHERE object_type = 'ITEM' AND object_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($factories); $i++) {
         $pack->factory_id = $factories[$i]->factory_id;
         factories::deleteFactory($pack);
     }
     $events = dbconnection::queryArray("SELECT * FROM events WHERE (event = 'GIVE_ITEM_PLAYER' OR event = 'TAKE_ITEM_PLAYER' OR event = 'GIVE_ITEM_GAME' OR event = 'TAKE_ITEM_GAME') AND content_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($events); $i++) {
         $pack->event_id = $events[$i]->event_id;
         events::deleteEvent($pack);
     }
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_VIEWED_ITEM' AND content_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_ITEM' AND content_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'GAME_HAS_ITEM' AND content_id = '{$pack->item_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 4
0
 public static function removeEditorFromGame($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::query("DELETE FROM user_games WHERE user_id = '{$pack->user_id}' AND game_id = '{$pack->game_id}'");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 5
0
 public static function deletePlaque($pack)
 {
     $plaque = dbconnection::queryObject("SELECT * FROM plaques WHERE plaque_id = '{$pack->plaque_id}'");
     $pack->auth->game_id = $plaque->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM plaques WHERE plaque_id = '{$pack->plaque_id}' LIMIT 1");
     //cleanup
     /* Comment out until we've decided on desired behavior...
        $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$plaque->event_package_id}'");
        if($eventpack)
        {
            $pack->event_package_id = $eventpack->event_package_id;
            events::deleteEventPackage($pack);
        }
        */
     $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_PLAQUE' AND link_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($options); $i++) {
         $pack->dialog_option_id = $options[$i]->dialog_option_id;
         dialogs::deleteDialogOption($pack);
     }
     $tabs = dbconnection::queryArray("SELECT * FROM tabs WHERE type = 'PLAQUE' AND content_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($tabs); $i++) {
         $pack->tab_id = $tabs[$i]->tab_id;
         tabs::deleteTab($pack);
     }
     $tags = dbconnection::queryArray("SELECT * FROM object_tags WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($tags); $i++) {
         $pack->object_tag_id = $tags[$i]->object_tag_id;
         tags::deleteObjectTag($pack);
     }
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         instances::deleteInstance($pack);
     }
     $factories = dbconnection::queryArray("SELECT * FROM factories WHERE object_type = 'PLAQUE' AND object_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($factories); $i++) {
         $pack->factory_id = $factories[$i]->factory_id;
         factories::deleteFactory($pack);
     }
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_VIEWED_PLAQUE' AND content_id = '{$pack->plaque_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 6
0
 public static function deleteGroup($pack)
 {
     $group = dbconnection::queryObject("SELECT * FROM groups WHERE group_id = '{$pack->group_id}'");
     $pack->auth->game_id = $group->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM groups WHERE group_id = '{$pack->group_id}' LIMIT 1");
     //cleanup
     dbconnection::query("UPDATE game_user_groups SET group_id = 0 WHERE game_id = '{$group->game_id}' AND group_id = '{$group->group_id}';");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 7
0
 public static function deleteOverlay($pack)
 {
     $overlay = dbconnection::queryObject("SELECT * FROM overlays WHERE overlay_id = '{$pack->overlay_id}'");
     $pack->auth->game_id = $overlay->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM overlays WHERE overlay_id = '{$pack->overlay_id}' LIMIT 1");
     //cleanup
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$overlay->requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 8
0
 public static function deleteWebHook($pack)
 {
     $webhook = dbconnection::queryObject("SELECT * FROM web_hooks WHERE web_hook_id = '{$pack->web_hook_id}'");
     $pack->auth->game_id = $webhook->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM web_hooks WHERE web_hook_id = '{$pack->web_hook_id}' LIMIT 1");
     //cleanup
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$webhook->requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_RECEIVED_INCOMING_WEB_HOOK' AND content_id = '{$pack->web_hook_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 9
0
 public static function deleteTab($pack)
 {
     $tab = dbconnection::queryObject("SELECT * FROM tabs WHERE tab_id = '{$pack->tab_id}'");
     $pack->auth->game_id = $tab->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM tabs WHERE tab_id = '{$pack->tab_id}' LIMIT 1");
     //cleanup
     $options = dbconnection::queryArray("SELECT * FROM dialog_options WHERE link_type = 'EXIT_TO_TAB' AND link_id = '{$pack->tab_id}'");
     for ($i = 0; $i < count($options); $i++) {
         $pack->dialog_option_id = $options[$i]->dialog_option_id;
         dialogs::deleteDialogOption($pack);
     }
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$tab->requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 10
0
 public static function deleteEvent($pack)
 {
     $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM events WHERE event_id = '{$pack->event_id}'")->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM events WHERE event_id = '{$pack->event_id}' LIMIT 1");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 11
0
 public static function deleteQuest($pack)
 {
     $quest = dbconnection::queryObject("SELECT * FROM quests WHERE quest_id = '{$pack->quest_id}'");
     $pack->auth->game_id = $quest->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM quests WHERE quest_id = '{$pack->quest_id}' LIMIT 1");
     //cleanup
     $reqAtoms = dbconnection::queryArray("SELECT * FROM requirement_atoms WHERE requirement = 'PLAYER_HAS_COMPLETED_QUEST' AND content_id = '{$pack->quest_id}'");
     for ($i = 0; $i < count($reqAtoms); $i++) {
         $pack->requirement_atom_id = $reqAtoms[$i]->requirement_atom_id;
         requirements::deleteRequirementAtom($pack);
     }
     /* Comment out until we've decided on desired behavior...
        $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$quest->active_event_package_id}'");
        if($eventpack)
        {
            $pack->event_package_id = $eventpack->event_package_id;
            events::deleteEventPackage($pack);
        }
        $eventpack = dbconnection::queryObject("SELECT * FROM event_packages WHERE event_package_id = '{$quest->complete_event_package_id}'");
        if($eventpack)
        {
            $pack->event_package_id = $eventpack->event_package_id;
            events::deleteEventPackage($pack);
        }
        */
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$quest->active_requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$quest->complete_requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 12
0
 public static function deleteObjectTagsForObject($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");
     }
     dbconnection::query("DELETE FROM object_tags WHERE game_id = '{$pack->game_id}' AND object_type = '{$pack->object_type}' AND object_id = '{$pack->object_id}';");
     games::bumpGameVersion($pack);
 }
Esempio n. 13
0
 public static function deleteMedia($pack)
 {
     $media_sql = dbconnection::queryObject("SELECT * FROM media WHERE media_id = '{$pack->media_id}'");
     $pack->auth->game_id = $media_sql->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     if (!unlink(Config::v2_gamedata_folder . "/" . $media_sql->file_folder . "/" . $media_sql->file_name)) {
         return new return_package(1, "Could not delete file.");
     }
     dbconnection::query("DELETE FROM media WHERE media_id = '{$pack->media_id}' LIMIT 1");
     //cleanup
     dbconnection::query("UPDATE games SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE games SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE tabs SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE items SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE items SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE dialogs SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE dialog_characters SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE plaques SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE plaques SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE web_pages SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE tags SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE overlays SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE note_media SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE quests SET active_media_id = 0 WHERE active_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE quests SET active_icon_media_id = 0 WHERE active_icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE quests SET complete_media_id = 0 WHERE complete_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE quests SET complete_icon_media_id = 0 WHERE complete_icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE triggers SET icon_media_id = 0 WHERE icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE factories SET trigger_icon_media_id = 0 WHERE trigger_icon_media_id = '{$pack->media_id}'");
     dbconnection::query("UPDATE users SET media_id = 0 WHERE media_id = '{$pack->media_id}'");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 14
0
 public static function deleteGame($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 (!is_numeric($pack->game_id)) {
         return new return_package(1, NULL, "Invalid game ID format");
     }
     $tables = array();
     $tables[] = "dialog_characters";
     $tables[] = "dialog_options";
     $tables[] = "dialog_scripts";
     $tables[] = "dialogs";
     $tables[] = "event_packages";
     $tables[] = "events";
     $tables[] = "factories";
     $tables[] = "game_comments";
     $tables[] = "instances";
     $tables[] = "items";
     $tables[] = "media";
     $tables[] = "note_comments";
     $tables[] = "note_likes";
     $tables[] = "notes";
     $tables[] = "object_tags";
     $tables[] = "overlays";
     $tables[] = "plaques";
     $tables[] = "quests";
     $tables[] = "requirement_and_packages";
     $tables[] = "requirement_atoms";
     $tables[] = "requirement_root_packages";
     $tables[] = "scenes";
     $tables[] = "tabs";
     $tables[] = "tags";
     $tables[] = "triggers";
     $tables[] = "user_game_scenes";
     $tables[] = "user_games";
     $tables[] = "web_hooks";
     $tables[] = "web_pages";
     dbconnection::query("DELETE FROM games WHERE game_id = '{$pack->game_id}' LIMIT 1");
     for ($i = 0; $i < count($tables); $i++) {
         dbconnection::query("DELETE FROM {$tables[$i]} WHERE game_id = '{$pack->game_id}'");
     }
     $command = 'rm -rf ' . Config::v2_gamedata_folder . "/{$pack->game_id}";
     exec($command, $output, $return);
     if ($return) {
         return new return_package(4, NULL, "unable to delete game directory");
     }
     return new return_package(0);
 }
Esempio n. 15
0
 public static function deleteFactory($pack)
 {
     $factory = dbconnection::queryObject("SELECT * FROM factories WHERE factory_id = '{$pack->factory_id}'");
     $pack->auth->game_id = $factory->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM factories WHERE factory_id = '{$pack->factory_id}' LIMIT 1");
     //cleanup
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE factory_id = '{$pack->factory_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         instances::deleteInstance($pack);
     }
     $instances = dbconnection::queryArray("SELECT * FROM instances WHERE object_type = 'FACTORY' AND object_id = '{$pack->factory_id}'");
     for ($i = 0; $i < count($instances); $i++) {
         $pack->instance_id = $instances[$i]->instance_id;
         instances::deleteInstance($pack);
     }
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$factory->requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     $reqPack = dbconnection::queryObject("SELECT * FROM requirement_root_packages WHERE requirement_root_package_id = '{$factory->trigger_requirement_root_package_id}'");
     if ($reqPack) {
         $pack->requirement_root_package_id = $reqPack->requirement_root_package_id;
         requirements::deleteRequirementPackage($pack);
     }
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 16
0
 public static function exportNotes($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");
     }
     $export = notes::getNotesForGame($pack);
     $tmp_export_folder = $pack->game_id . "_notebook_export_" . date("mdY_Gis");
     $fs_tmp_export_folder = Config::v2_gamedata_folder . "/" . $tmp_export_folder;
     if (file_exists($fs_tmp_export_folder)) {
         util::rdel($fs_tmp_export_folder);
     }
     mkdir($fs_tmp_export_folder, 0777);
     $jsonfile = fopen($fs_tmp_export_folder . "/export.json", "w");
     fwrite($jsonfile, json_encode($export));
     fclose($jsonfile);
     util::rcopy(Config::v2_gamedata_folder . "/" . $pack->game_id, $fs_tmp_export_folder . "/gamedata");
     util::rzip($fs_tmp_export_folder, $fs_tmp_export_folder . ".zip");
     util::rdel($fs_tmp_export_folder);
     return new return_package(0, Config::v2_gamedata_www_path . "/" . $tmp_export_folder . ".zip");
 }
Esempio n. 17
0
 public static function deleteNoteComment($pack)
 {
     $note_comment = dbconnection::queryObject("SELECT * FROM note_comments WHERE note_comment_id = '{$pack->note_comment_id}'");
     $note = dbconnection::queryObject("SELECT * FROM notes WHERE note_id = '{$note_comment->note_id}'");
     $pack->auth->game_id = $note_comment->game_id;
     $pack->auth->permission = "read_write";
     //tl;dr: must be game owner, note owner, or comment owner to delete comment
     if (!(users::authenticateUser($pack->auth) && ($pack->auth->user_id == $note_comment->user_id || $pack->auth->user_id == $note->user_id)) && !editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     dbconnection::query("DELETE FROM note_comments WHERE note_comment_id = '{$pack->note_comment_id}' LIMIT 1");
     games::bumpGameVersion($pack);
     return new return_package(0);
 }
Esempio n. 18
0
 public static function deleteInstance($pack)
 {
     $pack->auth->game_id = dbconnection::queryObject("SELECT * FROM instances WHERE instance_id = '{$pack->instance_id}'")->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     games::bumpGameVersion($pack);
     return instances::noauth_deleteInstance($pack);
 }
Esempio n. 19
0
 public static function deleteRequirementAtom($pack)
 {
     $pack->auth->game_id = dbconnection::queryObject("SELECT game_id FROM requirement_atoms WHERE requirement_atom_id = '{$pack->requirement_atom_id}'")->game_id;
     $pack->auth->permission = "read_write";
     if (!editors::authenticateGameEditor($pack->auth)) {
         return new return_package(6, NULL, "Failed Authentication");
     }
     games::bumpGameVersion($pack);
     return requirements::noauth_deleteRequirementAtom($pack);
 }