Esempio n. 1
0
 /**
  * gets the name of the nearest celestial the kill happened
  * @return string the name of the nearest celestial the kill happened at, or an empty string if no coordinates are available
  */
 public function getNearestCelestialName()
 {
     if (!isset($this->nearestCelestial)) {
         $this->calculateNearestCelestial();
     }
     if (isset($this->nearestCelestial)) {
         return $this->nearestCelestial->getName();
     }
     return null;
 }
 public function automaticApprovalDuration()
 {
     $location = new Location($this->getLocationId());
     return $location->getName() == 'Yard' ? 7 : 2;
 }
require '../header.php';
ensureMember();
$projects = fRecordSet::build('Project', array('state_id!=' => array('6', '7')), array('location_id' => 'asc', 'name' => 'asc'));
?>

<h2>Storage Requests</h2>
<a href="/storage/edit.php" class="btn btn-primary"><span class="glyphicon glyphicon-add"></span> Start a storage request</a>
<br/><br/>

<?php 
$loc = '';
foreach ($projects as $project) {
    if ($project->getLocationId() != $loc) {
        $loc = $project->getLocationId();
        $location = new Location($project->getLocationId());
        echo "<h3>" . $location->getName() . "</h3>";
    }
    ?>
        <div class="status list small <?php 
    echo strtolower($project->getState());
    ?>
"><?php 
    echo $project->getState();
    ?>
 <?php 
    if ($project->getState() == 'Extended') {
        ?>
(<?php 
        echo $project->getExtensionDuration();
        ?>
 days)<?php 
Esempio n. 4
0
 private function history()
 {
     $current_location = new Location($this->getLocationId());
     $current_location->build();
     db_insert('location_history')->fields(array('locationid' => $current_location->getLocationId(), 'name' => $current_location->getName(), 'address' => $current_location->getAddress(), 'address2' => $current_location->getAddress2(), 'city' => $current_location->getCity(), 'state' => $current_location->getState(), 'zip' => $current_location->getZip(), 'saved_userid' => $current_location->getSavedUserID(), 'saved_datetime' => $current_location->getSavedDateTime(), 'history_userid' => $this->getSavedUserID(), 'history_datetime' => $this->getSavedDateTime()))->execute();
 }
Esempio n. 5
0
 protected function processEncryptedNode(ProtocolNode $node)
 {
     if ($this->parent->getAxolotlStore() == null) {
         return;
     }
     //is a chat encrypted message
     $from = $node->getAttribute('from');
     if (strpos($from, Constants::WHATSAPP_SERVER) !== false) {
         $author = ExtractNumber($node->getAttribute('from'));
         $version = $node->getChild(0)->getAttribute('v');
         $encType = $node->getChild(0)->getAttribute('type');
         $encMsg = $node->getChild('enc')->getData();
         if (!$this->parent->getAxolotlStore()->containsSession($author, 1)) {
             //we don't have the session to decrypt, save it in pending and process it later
             $this->parent->addPendingNode($node);
             $this->parent->logFile('info', 'Requesting cipher keys from {from}', ['from' => $author]);
             $this->parent->sendGetCipherKeysFromUser($author);
         } else {
             //decrypt the message with the session
             if ($node->getChild('enc')->getAttribute('count') == '') {
                 $this->parent->setRetryCounter($node->getAttribute('id'), 1);
             }
             if ($version == '2') {
                 if (!in_array($author, $this->parent->getv2Jids())) {
                     $this->parent->setv2Jids($author);
                 }
             }
             $plaintext = $this->decryptMessage($from, $encMsg, $encType, $node->getAttribute('id'), $node->getAttribute('t'));
             //$plaintext ="A";
             if ($plaintext === false) {
                 $this->parent->sendRetry($this->node, $from, $node->getAttribute('id'), $node->getAttribute('t'));
                 $this->parent->logFile('info', 'Couldn\'t decrypt message with {id} id from {from}. Retrying...', ['id' => $node->getAttribute('id'), 'from' => ExtractNumber($from)]);
                 return $node;
                 // could not decrypt
             }
             if (isset($this->parent->retryNodes[$node->getAttribute('id')])) {
                 unset($this->parent->retryNodes[$node->getAttribute('id')]);
             }
             if (isset($this->parent->retryCounters[$node->getAttribute('id')])) {
                 unset($this->parent->retryCounters[$node->getAttribute('id')]);
             }
             switch ($node->getAttribute('type')) {
                 case 'text':
                     $node->addChild(new ProtocolNode('body', null, null, $plaintext));
                     break;
                 case 'media':
                     switch ($node->getChild('enc')->getAttribute('mediatype')) {
                         case 'image':
                             $image = new ImageMessage();
                             $image->parseFromString($plaintext);
                             $keys = (new HKDFv3())->deriveSecrets($image->getRefKey(), hex2bin('576861747341707020496d616765204b657973'), 112);
                             $iv = substr($keys, 0, 16);
                             $keys = substr($keys, 16);
                             $parts = str_split($keys, 32);
                             $key = $parts[0];
                             $macKey = $parts[1];
                             $refKey = $parts[2];
                             //should be changed to nice curl, no extra headers :D
                             $file_enc = file_get_contents($image->getUrl());
                             //requires mac check , last 10 chars
                             $mac = substr($file_enc, -10);
                             $cipherImage = substr($file_enc, 0, strlen($file_enc) - 10);
                             $decrypted_image = pkcs5_unpad(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $cipherImage, MCRYPT_MODE_CBC, $iv));
                             //$save_file = tempnam(sys_get_temp_dir(),"WAIMG_");
                             //file_put_contents($save_file,$decrypted_image);
                             $child = new ProtocolNode('media', ['size' => $image->getLength(), 'caption' => $image->getCaption(), 'url' => $image->getUrl(), 'mimetype' => $image->getMimeType(), 'filehash' => bin2hex($image->getSha256()), 'width' => 0, 'height' => 0, 'file' => $decrypted_image ?: $file_enc, 'type' => 'image'], null, $image->getThumbnail());
                             $node->addChild($child);
                             break;
                         case 'location':
                             $location = new Location();
                             $data = $node->getChild('enc')->getData();
                             $location->parseFromString($plaintext);
                             $child = new ProtocolNode('media', ['type' => 'location', 'encoding' => 'raw', 'latitude' => $location->getLatitude(), 'longitude' => $location->getLongitude(), 'name' => $location->getName(), 'url' => $location->getUrl()], null, $location->getThumbnail());
                             $node->addChild($child);
                             break;
                     }
                     break;
             }
             $this->parent->logFile('info', 'Decrypted message with {id} from {from}', ['id' => $node->getAttribute('id'), 'from' => ExtractNumber($from)]);
             return $node;
         }
     } else {
         $author = ExtractNumber($node->getAttribute('participant'));
         $group_number = ExtractNumber($node->getAttribute('from'));
         $childs = $node->getChildren();
         foreach ($childs as $child) {
             if ($child->getAttribute('type') == 'pkmsg' || $child->getAttribute('type') == 'msg') {
                 if (!$this->parent->getAxolotlStore()->containsSession($author, 1)) {
                     $this->parent->addPendingNode($node);
                     $this->parent->sendGetCipherKeysFromUser($author);
                     break;
                 } else {
                     //decrypt senderKey and save it
                     $encType = $child->getAttribute('type');
                     $encMsg = $child->getData();
                     $from = $node->getAttribute('participant');
                     $version = $child->getAttribute('v');
                     if ($node->getChild('enc')->getAttribute('count') == '') {
                         $this->parent->setRetryCounter($node->getAttribute('id'), 1);
                     }
                     if ($version == '2') {
                         if (!in_array($author, $this->parent->getv2Jids())) {
                             $this->parent->setv2Jids($author);
                         }
                     }
                     $skip_unpad = $node->getChild('enc', ['type' => 'skmsg']) == null;
                     $senderKeyBytes = $this->decryptMessage($from, $encMsg, $encType, $node->getAttribute('id'), $node->getAttribute('t'), $node->getAttribute('from'), $skip_unpad);
                     if ($senderKeyBytes) {
                         if (!$skip_unpad) {
                             $senderKeyGroupMessage = new SenderKeyGroupMessage();
                             $senderKeyGroupMessage->parseFromString($senderKeyBytes);
                         } else {
                             $senderKeyGroupMessage = new SenderKeyGroupData();
                             try {
                                 $senderKeyGroupMessage->parseFromString($senderKeyBytes);
                             } catch (Exception $ex) {
                                 try {
                                     $senderKeyGroupMessage->parseFromString(substr($senderKeyBytes, 0, -1));
                                 } catch (Exception $ex) {
                                     return $node;
                                 }
                             }
                             $message = $senderKeyGroupMessage->getMessage();
                             $senderKeyGroupMessage = $senderKeyGroupMessage->getSenderKey();
                         }
                         $senderKey = new SenderKeyDistributionMessage(null, null, null, null, $senderKeyGroupMessage->getSenderKey());
                         $groupSessionBuilder = new GroupSessionBuilder($this->parent->axolotlStore);
                         $groupSessionBuilder->processSender($group_number . ':' . $author, $senderKey);
                         if (isset($message)) {
                             $this->parent->sendReceipt($node, 'receipt', $this->parent->getJID($this->phoneNumber));
                             $node->addChild(new ProtocolNode('body', null, null, $message));
                         }
                     }
                 }
             } elseif ($child->getAttribute('type') == 'skmsg') {
                 $version = $child->getAttribute('v');
                 if ($version == '2') {
                     if (!in_array($author, $this->parent->v2Jids)) {
                         $this->parent->setv2Jids($author);
                     }
                 }
                 $plaintext = $this->decryptMessage([$group_number, $author], $child->getData(), $child->getAttribute('type'), $node->getAttribute('id'), $node->getAttribute('t'));
                 if (!$plaintext) {
                     $this->parent->sendRetry($this->node, $from, $node->getAttribute('id'), $node->getAttribute('t'), $node->getAttribute('participant'));
                     $this->parent->logFile('info', 'Couldn\'t decrypt group message with {id} id from {from}. Retrying...', ['id' => $node->getAttribute('id'), 'from' => $from]);
                     return $node;
                     // could not decrypt
                 } else {
                     if (isset($this->parent->retryNodes[$node->getAttribute('id')])) {
                         unset($this->parent->retryNodes[$node->getAttribute('id')]);
                     }
                     if (isset($this->parent->retryCounters[$node->getAttribute('id')])) {
                         unset($this->parent->retryCounters[$node->getAttribute('id')]);
                     }
                     $this->parent->logFile('info', 'Decrypted group message with {id} from {from}', ['id' => $node->getAttribute('id'), 'from' => $from]);
                     $this->parent->sendReceipt($node, 'receipt', $this->parent->getJID($this->phoneNumber));
                     $node->addChild(new ProtocolNode('body', null, null, $plaintext));
                 }
             }
         }
     }
 }