Ejemplo n.º 1
0
 public function handle($stanza, $parent = false)
 {
     $evt = new Event();
     $pd = new \modl\PostnDAO();
     foreach (array_reverse($stanza->query->xpath('item')) as $item) {
         $id = (string) $item->attributes()->name;
         if (!$pd->exists($this->_to, $this->_node, $id)) {
             $gi = new GetItem();
             $gi->setTo($this->_to)->setNode($this->_node)->setId($id)->request();
         }
     }
     $this->pack(['server' => $this->_to, 'node' => $this->_node]);
     $this->deliver();
 }
Ejemplo n.º 2
0
Archivo: Post.php Proyecto: movim/moxl
 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();
         $promise = $p->set($stanza->items, $from, $delay);
         $promise->done(function () use($p, $from) {
             // 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(['server' => $from, 'node' => $stanza->attributes()->node]);
         $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();
         $node = (string) $stanza->items->attributes()->node;
         $id = (string) $stanza->items->item->attributes()->id;
         $here = $p->exists($from, $node, $id);
         if (!$here && $id != $this->testid) {
             $d = new GetItem();
             $d->setTo($from)->setNode($node)->setId($id)->request();
         }
     }
 }