コード例 #1
0
ファイル: spawnables.php プロジェクト: spoymenov/arisgames
 public static function createSpawnableForObject($gameId, $type, $typeId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     switch ($type) {
         case 'Item':
             $query = "SELECT name as title FROM items WHERE game_id = {$gameId} AND item_id = {$typeId} LIMIT 1";
             break;
         case 'Node':
             $query = "SELECT title FROM nodes WHERE game_id = {$gameId} AND node_id = {$typeId} LIMIT 1";
             break;
         case 'Npc':
             $query = "SELECT name as title FROM npcs WHERE game_id = {$gameId} AND npc_id = {$typeId} LIMIT 1";
             break;
         case 'WebPage':
             $query = "SELECT name as title FROM web_pages WHERE web_page_id = {$typeId} LIMIT 1";
             break;
         case 'AugBubble':
             $query = "SELECT name as title FROM aug_bubbles WHERE aug_bubble_id = {$typeId} LIMIT 1";
             break;
     }
     $result = Module::query($query);
     $obj = mysql_fetch_object($result);
     $title = $obj->title;
     Spawnables::createSpawnable($gameId, $type, $typeId, $title, 5, 35, 50, 'PER_PLAYER', 'PLAYER', 0, 0, 50, 10, 0, 100, 15, 0, 0, 0, 1, 0);
     return Spawnables::getSpawnableForObject($gameId, $type, $typeId);
 }
コード例 #2
0
ファイル: webhooks.php プロジェクト: spoymenov/arisgames
 public function deleteWebHook($gameId, $intWebHookID, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "DELETE FROM web_hooks WHERE web_hook_id = {$intWebHookID}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     if (!mysql_affected_rows()) {
         return new returnData(2, NULL, 'invalid event id');
     }
     $query = "DELETE FROM requirements WHERE game_id = {$gameId} AND content_type = 'OutgoingWebHook' AND content_id = '{$intWebHookID}'";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "{$query} SQL Error");
     }
     $query = "DELETE FROM requirements WHERE game_id = {$gameId} AND requirement = 'PLAYER_HAS_RECEIVED_INCOMING_WEB_HOOK' AND requirement_detail_1 = '{$intWebHookID}'";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "{$query} SQL Error");
     }
     return new returnData(0, TRUE);
 }
コード例 #3
0
ファイル: overlays.php プロジェクト: kimblemj/server
 public function updateOverlay($overlayId, $gameId, $name, $mediaId, $topLeftLat, $topLeftLong, $topRightLat, $topRightLong, $bottomLeftLat, $bottomLeftLong, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $newName = addslashes($newName);
     Module::query("UPDATE overlays SET game_id = {$gameId}, name = '{$name}', media_id = {$mediaId}, top_left_latitude = {$topLeftLat}, top_left_longitude = {$topLeftLong}, top_right_latitude = {$topRightLat}, top_right_longitude = {$topRightLong}, bottom_left_latitude = {$bottomLeftLat}, bottom_left_longitude = {$bottomLeftLong} WHERE overlay_id = {$overlayId};");
     return new returnData(0);
 }
コード例 #4
0
ファイル: fountains.php プロジェクト: spoymenov/arisgames
 public static function deleteFountain($fountainId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "UPDATE fountains SET active = 0 WHERE fountain_id = {$fountainId}";
     Module::query($query);
     /*
             //This does a hard delete
             $query = "DELETE FROM fountains WHERE fountain_id = $fountainId";
             Module::query($query);
     */
     return new returnData(0);
 }
コード例 #5
0
ファイル: quests.php プロジェクト: kimblemj/server
 public function swapSortIndex($gameId, $a, $b, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $result = Module::query("SELECT * FROM quests WHERE game_id = {$gameId} AND (quest_id = '{$a}' OR quest_id = '{$b}')");
     $quests = array();
     while ($quest = mysql_fetch_object($result)) {
         $quests[$quest->quest_id] = $quest;
     }
     Module::query("UPDATE quests SET sort_index = '{$quests[$a]->sort_index}' WHERE game_id = {$gameId} AND quest_id = '{$b}'");
     Module::query("UPDATE quests SET sort_index = '{$quests[$b]->sort_index}' WHERE game_id = {$gameId} AND quest_id = '{$a}'");
     return new returnData(0);
 }
コード例 #6
0
ファイル: requirements.php プロジェクト: spoymenov/arisgames
 public function deleteRequirement($gameId, $requirementId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "DELETE FROM requirements WHERE game_id = {$gameId} AND requirement_id = {$requirementId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     if (mysql_affected_rows()) {
         return new returnData(0);
     } else {
         return new returnData(2, NULL, 'invalid requirement id');
     }
 }
コード例 #7
0
 public function deletePlayerStateChange($gameId, $intPlayerStateChangeId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "DELETE FROM player_state_changes WHERE game_id = {$gameId} AND id = {$intPlayerStateChangeId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     if (mysql_affected_rows()) {
         return new returnData(0);
     } else {
         return new returnData(2, NULL, 'invalid player state change id');
     }
 }
コード例 #8
0
ファイル: webpages.php プロジェクト: spoymenov/arisgames
 public static function updateWebPage($gameId, $webPageId, $name, $url, $iconMediaId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $name = addslashes($name);
     $query = "UPDATE web_pages \n            SET name = '{$name}', \n                url = '{$url}', \n                icon_media_id = '{$iconMediaId}' \n                    WHERE web_page_id = '{$webPageId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error() . "while running query:" . $query);
     }
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE, "Success Running:" . $query);
     } else {
         return new returnData(0, FALSE, "Success Running:" . $query);
     }
 }
コード例 #9
0
ファイル: nodes.php プロジェクト: spoymenov/arisgames
 public function updateNode($gameId, $intNodeID, $strTitle, $strText, $intMediaID, $intIconMediaID, $strOpt1Text, $intOpt1NodeID, $strOpt2Text, $intOpt2NodeID, $strOpt3Text, $intOpt3NodeID, $strQACorrectAnswer, $intQAIncorrectNodeID, $intQACorrectNodeID, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $strTitle = addslashes($strTitle);
     $strText = addslashes($strText);
     $strOpt1Text = addslashes($strOpt1Text);
     $strOpt2Text = addslashes($strOpt2Text);
     $strOpt3Text = addslashes($strOpt3Text);
     $strQACorrectAnswer = addslashes($strQACorrectAnswer);
     $query = "UPDATE nodes \n            SET title = '{$strTitle}', text = '{$strText}',\n                media_id = '{$intMediaID}', icon_media_id = '{$intIconMediaID}',\n                opt1_text = '{$strOpt1Text}', opt1_node_id = '{$intOpt1NodeID}',\n                opt2_text = '{$strOpt2Text}', opt2_node_id = '{$intOpt2NodeID}',\n                opt3_text = '{$strOpt3Text}', opt3_node_id = '{$intOpt3NodeID}',\n                require_answer_string = '{$strQACorrectAnswer}', \n                require_answer_incorrect_node_id = '{$intQAIncorrectNodeID}', \n                require_answer_correct_node_id = '{$intQACorrectNodeID}'\n                    WHERE game_id = {$gameId} AND node_id = '{$intNodeID}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error() . "while running query:" . $query);
     }
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE, "Success Running:" . $query);
     } else {
         return new returnData(0, FALSE, "Success Running:" . $query);
     }
 }
コード例 #10
0
ファイル: npcs.php プロジェクト: kimblemj/server
 public function updateNpc($gameId, $npcId, $name, $description, $greeting, $closing, $mediaId, $iconMediaId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $greeting = str_replace("“", "\"", $greeting);
     $greeting = str_replace("”", "\"", $greeting);
     $closing = str_replace("“", "\"", $closing);
     $closing = str_replace("”", "\"", $closing);
     $name = addslashes($name);
     $description = addslashes($description);
     $greeting = addslashes($greeting);
     $closing = addslashes($closing);
     $query = "UPDATE npcs \n            SET name = '{$name}', description = '{$description}',\n                text = '{$greeting}', closing = '{$closing}', \n                media_id = '{$mediaId}', icon_media_id = '{$iconMediaId}'\n                    WHERE npc_id = '{$npcId}' AND game_id = {$gameId}";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error());
     }
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE, "");
     } else {
         return new returnData(0, FALSE, "");
     }
 }
コード例 #11
0
ファイル: prune.php プロジェクト: kimblemj/server
 public function pruneNoteContentFromGame($gameId, $surrogate, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $unused_content = array();
     $noteContent = Module::queryArray("SELECT * FROM note_content WHERE game_id = '{$gameId}'");
     for ($i = 0; $i < count($noteContent); $i++) {
         if (!Module::queryObject("SELECT * FROM notes WHERE game_id = '{$gameId}' AND note_id = '{$noteContent[$i]->note_id}'")) {
             $unused_content[] = $noteContent[$i]->content_id;
         }
     }
     if ($surrogate) {
         for ($i = 0; $i < count($unused_content); $i++) {
             Module::query("UPDATE note_content SET game_id = '{$surrogate}' WHERE game_id = '{$gameId}' AND content_id = '{$unused_content[$i]}'");
         }
     } else {
         for ($i = 0; $i < count($unused_content); $i++) {
             Module::query("DELETE FROM note_content WHERE game_id = '{$gameId}' AND content_id = '{$unused_content[$i]}'");
         }
     }
     return $unused_content;
 }
コード例 #12
0
ファイル: playerlog.php プロジェクト: kimblemj/server
 public function getPlayerLogs($glob)
 {
     ini_set('display_errors', 1);
     error_reporting(E_ALL);
     //Grrr amfphp should take care of this...
     $data = file_get_contents("php://input");
     $glob = json_decode($data);
     $reqOutputFormat = $glob->output_format;
     $reqOutputToFile = $glob->output_to_file;
     $reqOutputFilename = $glob->output_filename;
     $reqGameId = $glob->game_id;
     $reqEditorId = $glob->editor_id;
     $reqEditorToken = $glob->editor_token;
     $reqGroup = $glob->groupname;
     $reqPlayers = $glob->players;
     $reqPlayer = $glob->player;
     $reqStartDate = $glob->start_date;
     $reqEndDate = $glob->end_date;
     $reqGetExpired = $glob->get_expired;
     $reqVerbose = $glob->verbose;
     $iknowwhatimdoing = $glob->i_know_what_im_doing == "yes";
     //minimal level of "security" to prevent massive data requests
     if ($iknowwhatimdoing) {
         set_time_limit(0);
         ignore_user_abort(1);
     }
     //validation
     $expectsNotice = 'Expects JSON argument of minimal form: {"output_format":"json","game_id":1,"editor_id":1,"editor_token":"abc123"}';
     if (!is_string($reqOutputFormat)) {
         $reqOutputFormat = "json";
     } else {
         $reqOutputFormat = strToLower($reqOutputFormat);
     }
     if ($reqOutputFormat != "json" && $reqOutputFormat != "csv" && $reqOutputFormat != "xml") {
         return new returnData(1, NULL, "Error- Invalid output format (" . $reqOutputFormat . ")\n" . $expectsNotice);
     }
     if (is_numeric($reqOutputToFile)) {
         $reqOutputToFile = intval($reqOutputToFile);
     } else {
         $reqOutputToFile = 0;
     }
     if (!is_string($reqOutputFilename)) {
         $reqOutputFilename = $reqOutputToFile ? "mostrecentlogrequest" : "tmpmostrecentlogrequest";
     }
     if (is_numeric($reqGameId)) {
         $reqGameId = intval($reqGameId);
     } else {
         return new returnData(1, NULL, "Error- Empty Game (" . $reqGameId . ")\n" . $expectsNotice);
     }
     if (is_numeric($reqEditorId)) {
         $reqEditorId = intval($reqEditorId);
     } else {
         return new returnData(1, NULL, "Error- Empty Editor (" . $reqEditorId . ")\n" . $expectsNotice);
     }
     if (!is_string($reqEditorToken)) {
         return new returnData(1, NULL, "Error- Invalid EditorToken (" . $reqEditorToken . ")\n" . $expectsNotice);
     }
     if (!Module::authenticateGameEditor($reqGameId, $reqEditorId, $reqEditorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $filterMode = "none";
     if (is_string($reqGroup)) {
         $filterMode = "group";
     }
     if (is_array($reqPlayers)) {
         $filterMode = "players";
     }
     if (is_numeric($reqPlayer)) {
         $filterMode = "player";
     }
     if (!preg_match("/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/", $reqStartDate)) {
         $reqStartDate = "0000-00-00 00:00:00";
     }
     if (!preg_match("/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/", $reqEndDate)) {
         $reqEndDate = "9999-00-00 00:00:00";
     }
     if (!$iknowwhatimdoing && floor(abs(strtotime($reqEndDate) - strtotime($reqStartDate)) / (60 * 60 * 24 * 31)) > 0) {
         return new returnData(1, NULL, "Please don't ask for more than a month of data at a time!");
     }
     if (!is_numeric($reqGetExpired)) {
         $reqGetExpired = 0;
     } else {
         if (intval($reqGetExpired) > 0) {
             $reqGetExpired = 1;
         }
     }
     if (!is_numeric($reqVerbose)) {
         $reqVerbose = 0;
     } else {
         if (intval($reqVerbose) > 0) {
             $reqVerbose = 1;
         }
     }
     $playerLogs = array();
     if ($filterMode == "group") {
         $p = Module::queryArray("SELECT player_id, display_name, media_id, group_name from players WHERE group_name = '{$reqGroup}'");
         for ($i = 0; $i < count($p); $i++) {
             $log = new stdClass();
             $log->player = $p[$i];
             if ($log->player->display_name == "") {
                 $log->player->display_name = $log->player->user_name;
             }
             $log->player->pic_url = Media::getMediaObject("player", $p[$i]->media_id)->data->url;
             $playerLogs[] = $log;
         }
     } else {
         if ($filterMode == "players") {
             for ($i = 0; $i < count($reqPlayers); $i++) {
                 $p = Module::queryObject("SELECT player_id, display_name, media_id, group_name from players WHERE player_id = '{$reqPlayers[$i]}'");
                 $log = new stdClass();
                 $log->player = $p;
                 if ($log->player->display_name == "") {
                     $log->player->display_name = $log->player->user_name;
                 }
                 $log->player->pic_url = Media::getMediaObject("player", $p->media_id)->data->url;
                 $playerLogs[] = $log;
             }
         } else {
             if ($filterMode == "player") {
                 $p = Module::queryObject("SELECT player_id, display_name, media_id, group_name from players WHERE player_id = '{$reqPlayer}'");
                 $log = new stdClass();
                 $log->player = $p;
                 if ($log->player->display_name == "") {
                     $log->player->display_name = $log->player->user_name;
                 }
                 $log->player->pic_url = Media::getMediaObject("player", $p->media_id)->data->url;
                 $playerLogs[] = $log;
             } else {
                 $r = Module::queryArray("SELECT player_id FROM player_log WHERE game_id = '{$reqGameId}' AND timestamp BETWEEN '{$reqStartDate}' AND '{$reqEndDate}' AND (deleted = 0 OR deleted = {$reqGetExpired}) GROUP BY player_id");
                 for ($i = 0; $i < count($r); $i++) {
                     $p = Module::queryObject("SELECT player_id, user_name, display_name, media_id, group_name from players WHERE player_id = '{$r[$i]->player_id}'");
                     if (!$p) {
                         continue;
                     }
                     $log = new stdClass();
                     $log->player = $p;
                     if ($log->player->display_name == "") {
                         $log->player->display_name = $log->player->user_name;
                     }
                     $log->player->pic_url = Media::getMediaObject("player", intval($p->media_id))->data->url;
                     $playerLogs[] = $log;
                 }
             }
         }
     }
     //caches for quick content construction
     $questsA = Module::queryArray("SELECT quest_id, name FROM quests WHERE game_id = '{$reqGameId}'");
     $questsH = array();
     for ($i = 0; $i < count($questsA); $i++) {
         $questsH[$questsA[$i]->quest_id] = $questsA[$i];
     }
     $itemsA = Module::queryArray("SELECT item_id, name FROM items WHERE game_id = '{$reqGameId}'");
     $itemsH = array();
     for ($i = 0; $i < count($itemsA); $i++) {
         $itemsH[$itemsA[$i]->item_id] = $itemsA[$i];
     }
     $nodesA = Module::queryArray("SELECT node_id, title FROM nodes WHERE game_id = '{$reqGameId}'");
     $nodesH = array();
     for ($i = 0; $i < count($nodesA); $i++) {
         $nodesH[$nodesA[$i]->node_id] = $nodesA[$i];
     }
     $npcsA = Module::queryArray("SELECT npc_id, name FROM npcs WHERE game_id = '{$reqGameId}'");
     $npcsH = array();
     for ($i = 0; $i < count($npcsA); $i++) {
         $npcsH[$npcsA[$i]->npc_id] = $npcsA[$i];
     }
     $webpagesA = Module::queryArray("SELECT web_page_id, name FROM web_pages WHERE game_id = '{$reqGameId}'");
     $webpagesH = array();
     for ($i = 0; $i < count($webpagesA); $i++) {
         $webpagesH[$webpagesA[$i]->web_page_id] = $webpagesA[$i];
     }
     $locationsA = Module::queryArray("SELECT location_id, name FROM locations WHERE game_id = '{$reqGameId}'");
     $locationsH = array();
     for ($i = 0; $i < count($locationsA); $i++) {
         $locationsH[$locationsA[$i]->location_id] = $locationsA[$i];
     }
     $qrcodesA = Module::queryArray("SELECT qrcode_id, link_id, code FROM qrcodes WHERE game_id = '{$reqGameId}'");
     $qrcodesH = array();
     for ($i = 0; $i < count($qrcodesA); $i++) {
         $qrcodesH[$qrcodesA[$i]->code] = $qrcodesA[$i];
     }
     $webhooksA = Module::queryArray("SELECT web_hook_id, name FROM web_hooks WHERE game_id = '{$reqGameId}'");
     $webhooksH = array();
     for ($i = 0; $i < count($webhooksA); $i++) {
         $webhooksH[$webhooksA[$i]->web_hook_id] = $webhooksA[$i];
     }
     //used to segment writes so not too much memory is used
     $pagesize = 1000;
     $i = 0;
     $output_filename = Config::gamedataFSPath . "/" . $reqGameId . "/" . addslashes($reqOutputFilename) . "." . $reqOutputFormat;
     $output_fileurl = Config::gamedataWWWPath . "/" . $reqGameId . "/" . addslashes($reqOutputFilename) . "." . $reqOutputFormat;
     file_put_contents($output_filename, "", 0);
     //clear output file
     while ($i < count($playerLogs)) {
         $playerLogs[$i]->log = array();
         $r = Module::queryArray("SELECT * FROM player_log WHERE player_id = '{$playerLogs[$i]->player->player_id}' AND game_id = '{$reqGameId}' AND timestamp BETWEEN '{$reqStartDate}' AND '{$reqEndDate}' AND (deleted = 0 OR deleted = {$reqGetExpired});");
         for ($j = 0; $j < count($r); $j++) {
             $row = new stdClass();
             switch ($r[$j]->event_type) {
                 case "PICKUP_ITEM":
                     $row->event = "Received Item";
                     $row->object = $itemsH[$r[$j]->event_detail_1]->name;
                     $row->qty = $r[$j]->event_detail_2;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " received " . $row->qty . " " . $row->object . " (Item).";
                     break;
                 case "DROP_ITEM":
                 case "DESTROY_ITEM":
                     $row->event = "Lost Item";
                     $row->object = $itemsH[$r[$j]->event_detail_1]->name;
                     $row->qty = $r[$j]->event_detail_2;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " lost " . $row->qty . " " . $row->object . " (Item).";
                     break;
                 case "VIEW_ITEM":
                     $row->event = "Viewed Item";
                     $row->object = $itemsH[$r[$j]->event_detail_1]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed " . $row->object . " (Item).";
                     break;
                 case "VIEW_NODE":
                     $row->event = "Viewed Node";
                     $row->object = $nodesH[$r[$j]->event_detail_1]->title;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed " . $row->object . " (Node).";
                     break;
                 case "VIEW_NPC":
                     $row->event = "Viewed NPC";
                     $row->object = $npcsH[$r[$j]->event_detail_1]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed " . $row->object . " (Npc).";
                     break;
                 case "VIEW_WEBPAGE":
                     $row->event = "Viewed Web Page";
                     $row->object = $webpagesH[$r[$j]->event_detail_1]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed " . $row->object . " (Web Page).";
                     break;
                 case "ENTER_QRCODE":
                     $row->event = "Entered QR";
                     $row->code = $r[$j]->event_detail_1;
                     $row->object = $locationsH[$qrcodesH[$r[$j]->event_detail_1]->link_id]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " scanned " . $row->object . ".";
                     break;
                 case "COMPLETE_QUEST":
                     $row->event = "Completed Quest";
                     $row->object = $questsH[$r[$j]->event_detail_1]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " completed quest '" . $row->object . "'.";
                     break;
                 case "VIEW_MAP":
                     $row->event = "Viewed Map";
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed the map.";
                     break;
                 case "VIEW_QUESTS":
                     $row->event = "Viewed Quests";
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed the quests.";
                     break;
                 case "VIEW_INVENTORY":
                     $row->event = "Viewed Inventory";
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " viewed the inventory.";
                     break;
                 case "MOVE":
                     $row->event = "Moved";
                     $row->lat = $r[$j]->event_detail_1;
                     $row->lon = $r[$j]->event_detail_2;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " moved to (" . $row->lat . ($reqOutputFormat == "csv" ? " " : ",") . $row->lon . ")";
                     break;
                 case "RECEIVE_WEBHOOK":
                     $row->event = "Received Hook";
                     $row->object = $webhooksH[$r[$j]->event_detail_1]->name;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " received hook '" . $row->object . "'";
                     break;
                 default:
                     $row->event = $r[$j]->event_type;
                     $row->timestamp = $r[$j]->timestamp;
                     $row->human = $playerLogs[$i]->player->display_name . " " . $row->event;
                     break;
             }
             if ($reqVerbose) {
                 $row->raw = new stdClass();
                 $row->raw->id = $r[$j]->id;
                 $row->raw->player_id = $r[$j]->player_id;
                 $row->raw->game_id = $r[$j]->game_id;
                 $row->raw->timestamp = $r[$j]->timestamp;
                 $row->raw->event_type = $r[$j]->event_type;
                 $row->raw->event_detail_1 = $r[$j]->event_detail_1;
                 $row->raw->event_detail_2 = $r[$j]->event_detail_2;
                 $row->raw->event_detail_3 = $r[$j]->event_detail_3;
                 $row->raw->deleted = $r[$j]->deleted;
             }
             $playerLogs[$i]->log[] = $row;
         }
         if ($reqOutputFormat == "json") {
             $json = "";
             if ($i == 0) {
                 $json .= "[";
             } else {
                 $json .= ",";
             }
             $json .= json_encode($playerLogs[$i]);
             file_put_contents($output_filename, $json, FILE_APPEND);
         }
         if ($reqOutputFormat == "csv") {
             $csv = "";
             if ($i == 0) {
                 $csv .= "group_name,";
                 $csv .= "player_id,";
                 $csv .= "display_name,";
                 $csv .= "timestamp,";
                 $csv .= "human" . ($reqVerbose ? "," : "\n");
                 if ($reqVerbose) {
                     $csv .= "player_log_id,";
                     $csv .= "player_id,";
                     $csv .= "game_id,";
                     $csv .= "timestamp,";
                     $csv .= "event_type,";
                     $csv .= "event_detail_1,";
                     $csv .= "event_detail_2,";
                     $csv .= "event_detail_3,";
                     $csv .= "deleted\n";
                 }
             }
             for ($j = 0; $j < count($playerLogs[$i]->log); $j++) {
                 $csv .= $playerLogs[$i]->player->group_name . ",";
                 $csv .= $playerLogs[$i]->player->player_id . ",";
                 $csv .= $playerLogs[$i]->player->display_name . ",";
                 $csv .= $playerLogs[$i]->log[$j]->timestamp . ",";
                 $csv .= $playerLogs[$i]->log[$j]->human . ($reqVerbose ? "," : "\n");
                 if ($reqVerbose) {
                     $csv .= $playerLogs[$i]->log[$j]->raw->id . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->player_id . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->game_id . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->timestamp . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->event_type . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->event_detail_1 . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->event_detail_2 . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->event_detail_3 . ",";
                     $csv .= $playerLogs[$i]->log[$j]->raw->deleted . "\n";
                 }
             }
             file_put_contents($output_filename, $csv, FILE_APPEND);
         }
         $playerLogs[$i]->log = array();
         //clear data to save memory
         $i++;
     }
     if ($reqOutputFormat == "json" && count($playerLogs) > 0) {
         //closing ]
         file_put_contents($output_filename, "]", FILE_APPEND);
     }
     if ($reqOutputToFile) {
         return new returnData(0, $output_fileurl);
     } else {
         //literally json decodes valid json data so the framework can re-encode it...
         return new returnData(0, json_decode(file_get_contents(Config::gamedataFSPath . "/" . $reqGameId . "/" . addslashes($reqOutputFilename) . "." . $reqOutputFormat)));
     }
 }
コード例 #13
0
 public static function deleteContent($gameId, $intContentID, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     //Lookup the object
     $query = "SELECT content_type,content_id FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}' LIMIT 1";
     $contentQueryResult = Module::query($query);
     $content = @mysql_fetch_object($contentQueryResult);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     Spawnables::deleteSpawnablesOfObject($gameId, $content->content_type, $content->content_id, $editorId, $editorToken);
     //Delete the content record
     $query = "DELETE FROM folder_contents WHERE object_content_id = {$intContentID} AND game_id = '{$gameId}'";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     //Delete the object
     if ($content->content_type == "Node") {
         Nodes::deleteNode($gameId, $content->content_id, $editorId, $editorToken);
     } else {
         if ($content->content_type == "Item") {
             Items::deleteItem($gameId, $content->content_id, $editorId, $editorToken);
         } else {
             if ($content->content_type == "Npc") {
                 Npcs::deleteNpc($gameId, $content->content_id, $editorId, $editorToken);
             } else {
                 if ($content->content_type == "WebPage") {
                     WebPages::deleteWebPage($gameId, $content->content_id, $editorId, $editorToken);
                 } else {
                     if ($content->content_type == "AugBubble") {
                         AugBubbles::deleteAugBubble($gameId, $content->content_id, $editorId, $editorToken);
                     } else {
                         if ($content->content_type == "PlayerNote") {
                             Notes::deleteNote($content->content_id, $editorId, $editorToken);
                         }
                     }
                 }
             }
         }
     }
     if (mysql_affected_rows()) {
         return new returnData(0);
     } else {
         return new returnData(2, 'invalid folder id');
     }
 }
コード例 #14
0
ファイル: notebook.php プロジェクト: kimblemj/server
 public function deleteTagFromGame($gameId, $tagId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $tag = Module::queryObject("SELECT * FROM game_tags WHERE tag_id = '{$tagId}'");
     if ($tag->player_created == 1) {
         Module::query("DELETE FROM game_tags WHERE tag_id = '{$tagId}'");
         Module::query("DELETE FROM note_tags WHERE tag_id = '{$tagId}'");
     } else {
         $notesTagged = Module::queryObject("SELECT note_id FROM note_tags WHERE tag_id = '{$tagId}'");
         if ($notesTagged) {
             Module::query("UPDATE game_tags SET player_created = 1 WHERE tag_id = '{$tagId}'");
         } else {
             Module::query("DELETE FROM game_tags WHERE tag_id = '{$tagId}'");
             Module::query("DELETE FROM note_tags WHERE tag_id = '{$tagId}'");
         }
     }
     return new returnData(0);
 }
コード例 #15
0
ファイル: items.php プロジェクト: kimblemj/server
 public static function untagItem($gameId, $itemId, $tagId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "DELETE FROM object_tags WHERE object_type = 'ITEM' AND object_id = '{$itemId}' AND tag_id = '{$tagId}';";
     Module::query($query);
     return new returnData(0);
 }
コード例 #16
0
ファイル: requirements.php プロジェクト: kimblemj/server
 public function deleteRequirement($gameId, $requirementId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     Module::query("DELETE FROM requirements WHERE game_id = {$gameId} AND requirement_id = {$requirementId}");
     return new returnData(0);
 }
コード例 #17
0
ファイル: augbubbles.php プロジェクト: spoymenov/arisgames
 public static function updateAugBubbleMediaIndex($intAugId, $intMediaId, $stringName, $intGameId, $intIndex, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     /* This will be for when index is implemented
                $query = "SELECT * FROM aug_bubble_media WHERE aug_bubble_id = '{$intAugId}' AND media_id = '{$intMediaId}'";
                $result = Module::query($query);
     
                if(mysql_num_rows($result)>0){
                $query = "UPDATE aug_bubble_media SET";
                }
              */
     $query = "INSERT INTO aug_bubble_media (aug_bubble_id, media_id, text, game_id) VALUES ('{$intAugId}', '{$intMediaId}', '{$stringName}', '{$intGameId}')";
     Module::query($query);
     if (mysql_error()) {
         return new returnData(1, NULL, mysql_error());
     }
     return new returnData(0);
 }
コード例 #18
0
ファイル: overlays.php プロジェクト: spoymenov/arisgames
 public function writeOverlayToDatabase($gameId, $overlayId, $folderName, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     // go to folder for game ID: /var/www/html/server/gamedata/{game_id}/
     $sGameDir = "/var/www/html/server/gamedata/" . $gameId . "/";
     $sOverlayDir = $sGameDir . $folderName;
     $diOverlay = new DirectoryIterator($sOverlayDir);
     $i = 0;
     $query = "DELETE FROM overlay_tiles WHERE overlay_id = {$overlayId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     foreach ($diOverlay as $dirMain1) {
         if ($dirMain1->isDir() && !$dirMain1->isDot() && $i != 0) {
             //&& !(strpos($dirMain1->getFilename(), "__") > 0)
             //echo "dirMain1:" . $dirMain1->getFilename() ."---- ";
             $diMain1 = new DirectoryIterator($dirMain1->getPath() . "/" . $dirMain1->getFilename());
             foreach ($diMain1 as $dirZoom) {
                 //go to last one
                 if ($dirZoom->isDir() && !$dirZoom->isDot()) {
                     //&& !(strpos($dirMain2->getFilename(), "__") > 0)
                     $diZoom = new DirectoryIterator($dirZoom->getPath() . "/" . $dirZoom->getFilename());
                     // step through zoom level folders
                     foreach ($diZoom as $dirX) {
                         if ($dirX->isDir() && !$dirX->isDot()) {
                             // step through y folders
                             $diX = new DirectoryIterator($dirX->getPath() . "/" . $dirX->getFilename());
                             foreach ($diX as $fileY) {
                                 if (strpos($fileY->getFilename(), ".png") > 0) {
                                     $fileYName = $fileY->getFilename();
                                     $fileYShortName = substr($fileYName, 0, -4);
                                     $dirMain1Name = $dirMain1->getFilename();
                                     $dirZoomName = $dirZoom->getFilename();
                                     $dirXName = $dirX->getFilename();
                                     $fullFileName = $overlayId . "_" . $dirZoomName . "_" . $dirXName . "_" . $fileYName;
                                     $fullNewDirAndFileName = $sGameDir . $fullFileName;
                                     $fullOldDirAndFileName = $sOverlayDir . "/" . $dirMain1Name . "/" . $dirZoomName . "/" . $dirXName . "/" . $fileYName;
                                     $filePath = $gameId . "/" . $fullFileName;
                                     $query3 = "INSERT INTO media SET game_id = {$gameId}, name = '{$fullFileName}', file_path = '{$filePath}'";
                                     $rsResult3 = Module::query($query3);
                                     if (mysql_error()) {
                                         return new returnData(3, NULL, "SQL Error inserting Media: " . $query3);
                                     }
                                     $media_id = mysql_insert_id();
                                     $query4 = "REPLACE INTO overlay_tiles SET overlay_id = {$overlayId}, media_id={$media_id}, zoom={$dirZoomName}, x={$dirXName}, y={$fileYShortName}";
                                     $rsResult4 = Module::query($query4);
                                     if (mysql_error()) {
                                         return new returnData(3, NULL, "SQL Error inserting tiles: " . $query4);
                                     }
                                     // copy file into root game directory
                                     copy($fullOldDirAndFileName, $fullNewDirAndFileName);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $i = $i + 1;
     }
     $query5 = "UPDATE overlays SET file_uploaded = 1 WHERE overlay_id = {$overlayId} and game_id = {$gameId}";
     $rsResult5 = Module::query($query5);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error setting zip file uploaded flag: " . $query5);
     }
     // delete overlay folder now that it is no longer needed
     $this->recursiveRemoveDirectory($sOverlayDir);
     return new returnData(0, $fullOldDirAndFileName . "->" . $fullNewDirAndFileName);
 }
コード例 #19
0
ファイル: notes.php プロジェクト: kimblemj/server
 function deleteTagFromGame($gameId, $tagId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "SELECT * FROM game_tags WHERE tag_id = '{$tagId}'";
     $result = Module::query($query);
     $tag = mysql_fetch_object($result);
     if ($tag->player_created == 1) {
         //Completely wipe from game
         $query = "DELETE FROM game_tags WHERE tag_id = '{$tagId}'";
         Module::query($query);
         $query = "DELETE FROM note_tags WHERE tag_id = '{$tagId}'";
         Module::query($query);
     } else {
         //Checks to see if instantiated at least once (a necessary property of player_created notes)
         $query = "SELECT note_id FROM note_tags WHERE tag_id = '{$tagId}'";
         $result = Module::query($query);
         if (mysql_num_rows($result) > 0) {
             $query = "UPDATE game_tags SET player_created = 1 WHERE tag_id = '{$tagId}'";
             $result = Module::query($query);
         } else {
             $query = "DELETE FROM game_tags WHERE tag_id = '{$tagId}'";
             Module::query($query);
             $query = "DELETE FROM note_tags WHERE tag_id = '{$tagId}'";
             Module::query($query);
         }
     }
     return new returnData(0);
 }
コード例 #20
0
ファイル: conversations.php プロジェクト: kimblemj/server
 public function deleteConversationWithNode($gameId, $conversationId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "SELECT node_id FROM npc_conversations WHERE game_id = '{$gameId}' AND conversation_id = {$conversationId} LIMIT 1";
     $nodeIdRs = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error() . "while running query:" . $query);
     }
     $nodeIdObject = @mysql_fetch_object($nodeIdRs);
     if (!$nodeIdObject) {
         return new returnData(2, NULL, "No such conversation");
     }
     $nodeId = $nodeIdObject->node_id;
     Nodes::deleteNode($gameId, $nodeId);
     $query = "DELETE FROM npc_conversations WHERE game_id = '{$gameId}' AND conversation_id = {$conversationId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     if (mysql_affected_rows()) {
         return new returnData(0);
     } else {
         return new returnData(2, NULL, 'invalid conversation id');
     }
 }
コード例 #21
0
ファイル: media.php プロジェクト: kimblemj/server
 public function deleteMedia($gameId, $mediaId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "SELECT * FROM media \n            WHERE media_id = {$mediaId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error());
     }
     $mediaRow = mysql_fetch_array($rsResult);
     if ($mediaRow === FALSE) {
         return new returnData(2, NULL, "Invalid Media Record");
     }
     //Delete the Record
     $query = "DELETE FROM media \n            WHERE media_id = {$mediaId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error:" . mysql_error());
     }
     //Delete the file
     $fileToDelete = Config::gamedataFSPath . "/" . $mediaRow['file_path'];
     if (!@unlink($fileToDelete)) {
         return new returnData(4, NULL, "Record Deleted but file was not: {$fileToDelete}");
     }
     //Done
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE);
     } else {
         return new returnData(0, FALSE);
     }
 }
コード例 #22
0
ファイル: games.php プロジェクト: spoymenov/arisgames
 public function removeEditorFromGame($newEditorId, $gameId, $editorId, $editorToken)
 {
     if (!Module::authenticateGameEditor($gameId, $editorId, $editorToken, "read_write")) {
         return new returnData(6, NULL, "Failed Authentication");
     }
     $query = "DELETE FROM game_editors WHERE editor_id = '{$newEditorId}' AND game_id = '{$gameId}'";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, 'SQL Error');
     }
     if (mysql_affected_rows()) {
         return new returnData(0, TRUE);
     } else {
         return new returnData(0, FALSE);
     }
 }