Exemple #1
0
 function ajaxSubmit($avatar)
 {
     $p = new \Picture();
     $p->fromBase((string) $avatar->photobin->value);
     $p->set($this->user->getLogin());
     $r = new Set();
     $r->setData($avatar->photobin->value)->request();
 }
Exemple #2
0
 function ajaxSubmit($avatar)
 {
     $p = new \Picture();
     $p->fromBase($avatar->photobin->value);
     $p->set('temp', 'jpeg', 60);
     $p = new \Picture();
     $p->get('temp');
     $r = new Set();
     $r->setData($p->toBase())->request();
 }
Exemple #3
0
 public function handle($stanza, $parent = false)
 {
     $jid = current(explode('/', (string) $parent->attributes()->from));
     $evt = new \Event();
     $cd = new \modl\ContactDAO();
     $c = $cd->get($jid);
     if ($c == null) {
         $c = new \modl\Contact();
     }
     $p = new \Picture();
     $p->fromBase((string) $stanza->items->item->data);
     $p->set($jid);
     $evt->runEvent('vcard', $c);
 }
Exemple #4
0
 function ajaxSend($to, $pack, $file)
 {
     if (!$this->validateJid($to)) {
         return;
     }
     list($key, $ext) = explode('.', $file);
     $filepath = dirname(__FILE__) . '/stickers/' . $pack . '/' . $key . '.png';
     if (!file_exists($filepath)) {
         return;
     }
     // We get the base64
     $base64 = base64_encode(file_get_contents($filepath));
     // Caching the picture
     if (!file_exists(CACHE_PATH . md5($key) . '.png')) {
         $p = new Picture();
         $p->fromBase($base64);
         $p->set($key, 'png');
     }
     // Creating a message
     $m = new \Modl\Message();
     $m->session = $this->user->getLogin();
     $m->jidto = echapJid($to);
     $m->jidfrom = $this->user->getLogin();
     $m->sticker = $key;
     $m->body = $this->__('sticker.sent');
     $m->published = gmdate('Y-m-d H:i:s');
     $session = \Session::start();
     $m->id = Uuid::uuid4();
     $m->type = 'chat';
     $m->resource = $session->get('resource');
     // Sending the sticker
     $html = "<p><img alt='Sticker' src='cid:sha1+" . $key . "@bob.xmpp.org'/></p>";
     $p = new Publish();
     $p->setTo($m->jidto)->setContent($m->body)->setHTML($html)->setId($m->id)->request();
     $md = new \Modl\MessageDAO();
     $md->set($m);
     // Sending it to Chat
     $packet = new Moxl\Xec\Payload\Packet();
     $packet->content = $m;
     $c = new Chat();
     $c->onMessage($packet);
 }
Exemple #5
0
 public function createThumbnails()
 {
     $p = new \Picture();
     $p->fromBase($this->photobin);
     $p->set($this->jid);
     if (isset($this->email)) {
         \createEmailPic(strtolower($this->jid), $this->email);
     }
 }
Exemple #6
0
 public function set($stanza, $parent = false)
 {
     if ($stanza->body || $stanza->subject) {
         $jid = explode('/', (string) $stanza->attributes()->from);
         $to = current(explode('/', (string) $stanza->attributes()->to));
         if (isset($stanza->attributes()->id)) {
             $this->id = (string) $stanza->attributes()->id;
         }
         // This is not very beautiful
         $user = new \User();
         $this->session = $user->getLogin();
         $this->jidto = $to;
         $this->jidfrom = $jid[0];
         if (isset($jid[1])) {
             $this->__set('resource', $jid[1]);
         }
         $this->type = 'chat';
         if ($stanza->attributes()->type) {
             $this->type = (string) $stanza->attributes()->type;
         }
         if ($stanza->body) {
             $this->__set('body', (string) $stanza->body);
         }
         if ($stanza->subject) {
             $this->__set('subject', (string) $stanza->subject);
         }
         if ($stanza->html) {
             $xml = \simplexml_load_string((string) $stanza->html->body);
             if ($xml) {
                 $results = $xml->xpath('//img/@src');
                 if (is_array($results) && !empty($results)) {
                     if (substr((string) $results[0], 0, 10) == 'data:image') {
                         $str = explode('base64,', $results[0]);
                         if (isset($str[1])) {
                             $p = new \Picture();
                             $p->fromBase(urldecode($str[1]));
                             $key = sha1(urldecode($str[1]));
                             $p->set($key, 'png');
                             $this->sticker = $key;
                         }
                     } else {
                         $this->sticker = getCid((string) $results[0]);
                     }
                 }
             }
         }
         if ($stanza->replace) {
             $this->newid = $this->id;
             $this->id = (string) $stanza->replace->attributes()->id;
             $this->edited = true;
         }
         if ($stanza->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
         } elseif ($parent && $parent->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
         } else {
             $this->published = gmdate('Y-m-d H:i:s');
         }
         $this->checkPicture();
     }
 }