Beispiel #1
0
 public function handle($stanza, $parent = false)
 {
     $evt = new \Event();
     $pd = new \modl\PostnDAO();
     $get = false;
     foreach ($stanza->query->item as $item) {
         $id = (string) $item->attributes()->name;
         if (!$pd->exist($id)) {
             $get = true;
             $gi = new GetItem();
             $gi->setTo($this->_to)->setNode($this->_node)->setId($id)->request();
         }
     }
     if ($get == false) {
         $this->pack(array('server' => $this->_to, 'node' => $this->_node));
         $this->deliver();
     }
 }
Beispiel #2
0
 public function handle($stanza, $parent = false)
 {
     $from = (string) $parent->attributes()->from;
     if ($stanza->items->item && isset($stanza->items->item->entry) && (string) $stanza->items->item->entry->attributes()->xmlns == 'http://www.w3.org/2005/Atom') {
         if ($parent->delay) {
             $delay = gmdate('Y-m-d H:i:s', strtotime((string) $parent->delay->attributes()->stamp));
         } else {
             $delay = false;
         }
         $p = new \modl\Postn();
         $p->set($stanza->items, $from, $delay);
         // We limit the very old posts (2 months old)
         if (strtotime($p->published) > mktime(0, 0, 0, gmdate("m") - 2, gmdate("d"), gmdate("Y")) && $p->nodeid != $this->testid) {
             $pd = new \modl\PostnDAO();
             $pd->set($p, $from);
             $this->pack($p);
             $this->deliver();
         }
     } elseif ($stanza->items->retract) {
         $pd = new \modl\PostnDAO();
         $pd->delete($stanza->items->retract->attributes()->id);
         $this->method('retract');
         $this->pack(array('server' => $from, 'node' => $stanza->attributes()->node));
         $this->deliver();
     } elseif (isset($stanza->items->item->realtime)) {
         $this->method('ticker');
         $this->pack(array('server' => $from, 'node' => $stanza->items->attributes()->node, 'ticker' => $stanza->items->item->realtime));
         $this->deliver();
     } elseif ($stanza->items->item && isset($stanza->items->item->attributes()->id) && !filter_var($from, FILTER_VALIDATE_EMAIL)) {
         // In this case we only get the header, so we request the full content
         $p = new \modl\PostnDAO();
         $id = (string) $stanza->items->item->attributes()->id;
         $here = $p->exist($id);
         if (!$here && $id != $this->testid) {
             $d = new GetItem();
             $d->setTo($from)->setNode((string) $stanza->items->attributes()->node)->setId($id)->request();
         }
     }
 }