Exemplo n.º 1
0
 public function save()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     /*$this->data['buckets'] = array();
     		foreach($this->buckets as $bucketId => $bucket){
     			$this->data['buckets'][$bucketId] = array(
     				'path' => $bucket->getFilePath(),
     			);
     			
     			$bucket->save();
     		}*/
     /*$this->data['childBucketUpper'] = null;
     		if($this->childBucketUpper){
     			$this->data['childBucketUpper'] = $this->childBucketUpper->getFilePath();
     			$this->childBucketUpper->save();
     		}
     		
     		$this->data['childBucketLower'] = null;
     		if($this->childBucketLower){
     			$this->data['childBucketLower'] = $this->childBucketLower->getFilePath();
     			$this->childBucketLower->save();
     		}*/
     $this->data['rootBucket'] = null;
     if ($this->rootBucket) {
         $this->data['rootBucket'] = $this->rootBucket->getFilePath();
         $this->rootBucket->save();
     }
     $rv = parent::save();
     #unset($this->data['buckets']);
     #unset($this->data['childBucketUpper']);
     #unset($this->data['childBucketLower']);
     unset($this->data['rootBucket']);
     return $rv;
 }
Exemplo n.º 2
0
 public function save()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     #$this->data['prefixName'] = intToBin($this->getPrefix());
     $this->data['distanceName'] = intToBin($this->getDistance());
     $this->data['maskBitName'] = intToBin($this->getMaskByte());
     $this->data['maskBitName'] = intToBin($this->getMaskBit());
     $this->data['nodes'] = array();
     foreach ($this->nodes as $nodeId => $node) {
         #print __CLASS__.'->'.__FUNCTION__.': '.$nodeId.', '.(int)$node->getDataChanged()."\n";
         $this->data['nodes'][$nodeId] = array('path' => $node->getFilePath());
         $node->save();
     }
     $this->data['childBucketUpper'] = null;
     if ($this->childBucketUpper) {
         $this->data['childBucketUpper'] = $this->childBucketUpper->getFilePath();
         $this->childBucketUpper->save();
     }
     $this->data['childBucketLower'] = null;
     if ($this->childBucketLower) {
         $this->data['childBucketLower'] = $this->childBucketLower->getFilePath();
         $this->childBucketLower->save();
     }
     $rv = parent::save();
     unset($this->data['nodes']);
     unset($this->data['childBucketUpper']);
     unset($this->data['childBucketLower']);
     return $rv;
 }
Exemplo n.º 3
0
 public function save()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     $this->data['uri'] = (string) $this->uri;
     $this->data['sslKeyPub'] = base64_encode($this->sslKeyPub);
     return parent::save();
 }
Exemplo n.º 4
0
 public function testLoad1()
 {
     $storage = new YamlStorage('test_data/test1.yml');
     $storage->setDataChanged();
     $storage->save();
     $storage = new YamlStorage('test_data/test1.yml');
     $storage->load();
     $this->assertTrue($storage->isLoaded());
 }
Exemplo n.º 5
0
 public function testLoad1()
 {
     $fileName = 'test1_' . date('Ymd_His') . '_' . uniqid('', true) . '.yml';
     $storage = new YamlStorage('test_data/' . $fileName);
     $storage->setDataChanged();
     $storage->save();
     $storage = new YamlStorage('test_data/' . $fileName);
     $storage->load();
     $this->assertTrue($storage->isLoaded());
 }
Exemplo n.º 6
0
 public function save()
 {
     $this->data['nodes'] = array();
     foreach ($this->nodes as $nodeId => $node) {
         $this->data['nodes'][$nodeId] = array('path' => $node->getFilePath());
         $node->save();
     }
     $rv = parent::save();
     unset($this->data['nodes']);
     return $rv;
 }
Exemplo n.º 7
0
 public function save()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     $this->data['msgs'] = array();
     foreach ($this->msgs as $msgId => $msg) {
         #print __CLASS__.'->'.__FUNCTION__.': '.$msgId."\n";
         $this->data['msgs'][$msgId] = array('path' => $msg->getFilePath());
         $msg->save();
     }
     $rv = parent::save();
     unset($this->data['msgs']);
     return $rv;
 }
Exemplo n.º 8
0
 public function save()
 {
     #print __CLASS__.'->'.__FUNCTION__.''."\n";
     $this->data['contacts'] = array();
     foreach ($this->contacts as $contactId => $contact) {
         $contactAr = array();
         $contactAr['nodeId'] = $contact->getNodeId();
         $contactAr['userNickname'] = $contact->getUserNickname();
         $contactAr['timeCreated'] = $contact->getTimeCreated();
         $this->data['contacts'][$contactId] = $contactAr;
     }
     $rv = parent::save();
     unset($this->data['contacts']);
     return $rv;
 }
Exemplo n.º 9
0
 public function save()
 {
     #fwrite(STDOUT, __CLASS__.'->'.__FUNCTION__.''."\n");
     $this->data['hashcashs'] = array();
     foreach ($this->hashcashs as $hashcashId => $hashcash) {
         #fwrite(STDOUT, __CLASS__.'->'.__FUNCTION__.': '.$hashcashId."\n");
         $hashcashAr = array();
         $hashcashAr['id'] = $hashcashId;
         $hashcashAr['stamp'] = $hashcash->getStamp();
         if ($hashcash->verify()) {
             $this->data['hashcashs'][$hashcashId] = $hashcashAr;
         }
     }
     $rv = parent::save();
     unset($this->data['hashcashs']);
     return $rv;
 }
Exemplo n.º 10
0
 public function shutdown()
 {
     #print __CLASS__.'->'.__FUNCTION__.': '.(int)$this->ipcKernelShutdown."\n";
     if (!TEST) {
         fwrite(STDOUT, PHP_EOL);
     }
     $this->getLog()->info('shutdown');
     #$this->msgAdd('Shutting down...', true, true);
     if ($this->getModeChannel()) {
         $this->talkCloseSend();
     }
     #if(!$this->ipcKernelShutdown){ $this->ipcKernelConnection->execSync('shutdown'); }
     if ($this->settings->data['console']['history']['enabled'] && $this->settings->data['console']['history']['saveToFile']) {
         $historyStoragePath = $this->settings->data['datadir'] . '/history.yml';
         $historyStorage = new YamlStorage($historyStoragePath);
         if ($this->settings->data['console']['history']['entriesMax']) {
             $historyStorage->data = array_slice($this->history, 0, $this->settings->data['console']['history']['entriesMax']);
         } else {
             $historyStorage->data = $this->history;
         }
         $historyStorage->setDataChanged(true);
         $historyStorage->save();
     }
     if (!TEST) {
         $this->sttyReset();
     }
 }