Пример #1
0
 /** Receives the form submission from the new action and creates the new object. */
 public function actionCreate()
 {
     // create a new message
     $messages = new Messages();
     $name = $messages->generateNewName($this->request->getPost());
     if (empty($name)) {
         $this->flashFail = 'The message cannot be blank';
         $this->redirectTo('topics/new');
     }
     $stamp = date("Y-m-d H:i:s", mktime());
     $save['name'] = $this->userRow['name'];
     // create new topic
     $save['name'] = $this->request->getPost('name');
     $save['created_at'] = $save['updated_at'] = $stamp;
     $save['created_by'] = $this->userRow['name'];
     $save['is_archived'] = 0;
     $topicId = $this->topics->save($save);
     // create new message... read by us
     $newId = $messages->save(array('topics_id' => $topicId, 'created_at' => $stamp, 'name' => $name, 'user' => $this->userRow['name'], 'read_by' => "!{$this->userRow['id']}!"));
     // create new mailer
     //$mailer = new Mailer();
     // save the text
     $nodes = new Nodes();
     $nodes->saveMessage(0, $this->request->getPost(0), $topicId, $newId, $this->userRow['name'], $mailer);
     // send email to all recipients
     //$users = new Users();
     //foreach ($users->select('email')->findAll() as $user) $recipients[] = $user['email'];
     //$mailer->sendMessage($recipients, $newId, $topicId, $this->topics);
     // redirect to the new message
     $this->redirectTo("messages/show/{$topicId}/{$newId}");
 }
Пример #2
0
 public function getValue($key)
 {
     if ($this->storage !== null) {
         $this->storage->lock();
     }
     $root = $this->firstNode();
     if ($root === null) {
         return null;
     }
     $node = $this->search($root, $key);
     if ($node->valueType === 1) {
         $value = new Nodes();
         if ($this->storage !== null) {
             $value->setStorage($this->storage);
             $value->setHeadNodePointer($node->pointer);
         } else {
             $value->firstNode = $node->subNode;
         }
     } else {
         $value = $node->value;
     }
     if ($this->storage !== null) {
         $this->storage->unlock();
     }
     return $value;
 }
Пример #3
0
 public function each(Records $records, Nodes $nodes, callable $callback) : void
 {
     if (!$this->externalAddress->isEmpty()) {
         $record = $records->read($this->externalAddress);
         $node = $nodes->read($record->nodeAddress());
         $node->each($callback);
     }
 }
Пример #4
0
 public static function initialize($idN, $idS, $editor = false)
 {
     $ON = NodesPeer::retrieveByPK($idN);
     if (!$ON instanceof Nodes) {
         $ON = new Nodes();
         $ON->setSiteId($idS);
         $ON->setActiu(true);
     }
     if ($editor) {
         return new EditorHtmlForm($ON, array('IDS' => $idS));
     } else {
         return new NodesForm($ON, array('IDS' => $idS));
     }
 }
Пример #5
0
 public function getDevice()
 {
     $nodoObj = Nodes::select('Caption')->where('NodeId', '=', intval(Input::get('nodeId')))->first();
     $deviceObj = Equipos::with('Fabricante')->with('Ubicacion')->with('Tipo')->where('name', '=', $nodoObj->Caption)->first();
     $datos = json_encode($deviceObj->toArray());
     return $datos;
 }
Пример #6
0
 public function deleteNodesReferencedByObject($gameId, $type, $intNpcId)
 {
     $query = "SELECT node_id FROM npc_conversations WHERE game_id = {$gameId} AND npc_id = {$intNpcId}";
     $result = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     while ($nid = mysql_fetch_object($result)) {
         Nodes::deleteNode($gameId, $nid->node_id);
     }
     return new returnData(0);
 }
Пример #7
0
function utility($name)
{
    return Nodes::utility($name);
}
Пример #8
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}");
 }
Пример #9
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Nodes $value A Nodes object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Nodes $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getIdnodes();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Пример #10
0
 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');
     }
 }
Пример #11
0
	<input type="submit" name="submit" value="Submit" />
</form>

<?php 
if ($_FILES["file"]["error"] > 0) {
    die("Filupload fejlede!");
} else {
    $data = file_get_contents($_FILES["file"]["tmp_name"]);
}
//Nodes and decisions
$nodes_outer = "/(node|decision)[\\s]*([^\\s]*)[\\s]*{[\\s]*((([^\\s]*) = ([^;]+);[\\s]*)*)}/i";
$nodes_inner = "/([^\\s]*) = [\"\\(]?([^;]*?)[\"\\)]?;[\\s]*/i";
$state_labels = "/\"([^\"]*)\"/i";
$potential_outer = "/potential[\\s]*\\(([^\\s]+)( \\| ([^\\)]+))?\\)[\\s]*{[\\s]*data[\\s]*=([\\s]*[^}]+)}/i";
$potential_inner = "/[\\(]+([^\\)]+)[\\)]+/i";
$nodes = new Nodes();
//Parse nodes & decisions
preg_match_all($nodes_outer, $data, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
    $node = new Node($match[1], $match[2]);
    $nodes->addNode($node);
    preg_match_all($nodes_inner, $match[3], $settings, PREG_SET_ORDER);
    foreach ($settings as $setting) {
        if ($setting[1] == 'states') {
            preg_match_all($state_labels, $setting[2], $states, PREG_SET_ORDER);
            foreach ($states as $state) {
                $node->addState($state[1]);
            }
            break;
        }
    }
Пример #12
0
 public function deleteNpc($gameId, $intNpcId)
 {
     Locations::deleteLocationsForObject($gameId, 'Npc', $intNpcId);
     Requirements::deleteRequirementsForRequirementObject($gameId, 'Npc', $intNpcId);
     PlayerStateChanges::deletePlayerStateChangesThatRefrenceObject($gameId, 'Npc', $intNpcId);
     Nodes::deleteNodesReferencedByObject($gameId, 'Npc', $intNpcId);
     $query = "DELETE FROM npcs WHERE npc_id = {$intNpcId} AND game_id = {$gameId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     $hasDeletedNPC = mysql_affected_rows();
     $query = "DELETE FROM npc_conversations WHERE npc_id = {$intNpcId} AND game_id = {$gameId}";
     $rsResult = Module::query($query);
     if (mysql_error()) {
         return new returnData(3, NULL, "SQL Error");
     }
     if ($hasDeletedNPC) {
         return new returnData(0);
     } else {
         return new returnData(2, 'invalid npc id');
     }
 }
 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
<?php

if (!file_exists($argv[1])) {
    die("net2dlib error:\nFirst argument needs to be location to hugin .net file!\nSecond argument needs to be code.h\nThird argument needs to be enums.h\n");
} else {
    $data = file_get_contents($argv[1]);
}
echo "net2dlib is writing magic files for dlib...\n";
//Nodes and decisions
$nodes_outer = "/(node|decision)[\\s]*([^\\s]*)[\\s]*{[\\s]*((([^\\s]*) = ([^;]+);[\\s]*)*)}/i";
$nodes_inner = "/([^\\s]*) = [\"\\(]?([^;]*?)[\"\\)]?;[\\s]*/i";
$state_labels = "/\"([^\"]*)\"/i";
$potential_outer = "/potential[\\s]*\\(([^\\s]+)( \\| ([^\\)]+))?\\)[\\s]*{[\\s]*data[\\s]*=([\\s]*[^}]+)}/i";
$potential_inner = "/[\\(]+([^\\)]+)[\\)]+/i";
$nodes = new Nodes();
//Parse nodes & decisions
preg_match_all($nodes_outer, $data, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
    $node = new Node($match[1], $match[2]);
    $nodes->addNode($node);
    preg_match_all($nodes_inner, $match[3], $settings, PREG_SET_ORDER);
    foreach ($settings as $setting) {
        if ($setting[1] == 'states') {
            preg_match_all($state_labels, $setting[2], $states, PREG_SET_ORDER);
            foreach ($states as $state) {
                $node->addState($state[1]);
            }
            break;
        }
    }
}