Exemple #1
0
 public function getConversationsForPlayer($gameId, $intNpcId, $intPlayerId)
 {
     $conversationsReturnData = Npcs::getConversations($gameId, $intNpcId);
     $conversations = $conversationsReturnData->data;
     $conversationsWithRequirementsMet = array();
     while ($conversation = mysql_fetch_array($conversations)) {
         if (Module::objectMeetsRequirements($gameId, $intPlayerId, 'Node', $conversation['node_id'])) {
             $query = "SELECT * FROM player_log WHERE game_id = '{$gameId}' AND player_id = '{$intPlayerId}' AND event_type = '" . Module::kLOG_VIEW_NODE . "' AND event_detail_1 = '" . $conversation['node_id'] . "' AND deleted = '0'";
             $result = Module::query($query);
             if (mysql_num_rows($result) > 0) {
                 $conversation['has_viewed'] = true;
             } else {
                 $conversation['has_viewed'] = false;
             }
             $conversationsWithRequirementsMet[] = $conversation;
         }
     }
     return new returnData(0, $conversationsWithRequirementsMet);
 }
Exemple #2
0
 public function getQRCodePackageURL($gameId)
 {
     $query = "SELECT * FROM qrcodes WHERE game_id = {$gameId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     //Set up a tmp directory
     $relDir = "{$gameId}_qrcodes_" . date('Y_m_d_h_i_s');
     $tmpDir = Config::gamedataFSPath . "/backups/{$relDir}";
     $command = "mkdir {$tmpDir}";
     exec($command, $output, $return);
     if ($return) {
         return new returnData(4, NULL, "cannot create backup dir, check file permissions");
     }
     //Get all the images
     while ($qrCode = mysql_fetch_object($rsResult)) {
         //Look up the item to get a good file name
         $fileNameType = '';
         $fileNameId = '';
         $fileNameName = '';
         switch ($qrCode->link_type) {
             case 'Location':
                 $fileNameType = "Location";
                 $fileNameId = $qrCode->link_id;
                 $locationReturnData = Locations::getLocation($gameId, $qrCode->link_id);
                 $location = $locationReturnData->data;
                 switch ($location->type) {
                     case 'Npc':
                         $object = Npcs::getNpc($gameId, $location->type_id);
                         $fileNameName = $object->data->name;
                         break;
                     case 'Node':
                         $object = Nodes::getNode($gameId, $location->type_id);
                         $fileNameName = $object->data->title;
                         break;
                     case 'Item':
                         $object = Items::getItem($gameId, $location->type_id);
                         $fileNameName = $object->data->name;
                         break;
                 }
                 break;
             default:
                 $returnResult = new returnData(5, NULL, "Invalid QR Code Found.");
         }
         $fileName = "{$fileNameType}{$fileNameId}-{$fileNameName}.jpg";
         $command = "curl -s -o /{$tmpDir}/{$fileName} 'http://chart.apis.google.com/chart?chs=300x300&cht=qr&choe=UTF-8&chl={$qrCode->code}'";
         exec($command, $output, $return);
         if ($return) {
             return new returnData(4, NULL, "cannot download and save qr code image, check file permissions and url in console");
         }
     }
     //Zip up the whole directory
     $zipFileName = "aris_qr_codes.tar";
     $cwd = Config::gamedataFSPath . "/backups";
     chdir($cwd);
     $command = "tar -cf {$zipFileName} {$relDir}/";
     exec($command, $output, $return);
     if ($return) {
         return new returnData(5, NULL, "cannot compress backup dir, check that tar command is availabe.");
     }
     //Delete the Temp
     /*
       $rmCommand = "rm -rf {$tmpDir}";
       exec($rmCommand, $output, $return);
       if ($return) return new returnData(5, NULL, "cannot delete backup dir, check file permissions");
     */
     return new returnData(0, Config::gamedataWWWPath . "/backups/{$zipFileName}");
 }
 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');
     }
 }