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);
 }
 function getList($params = NULL, $proyection = '*', $order = '1', $limit = '')
 {
     if ($this->db != NULL) {
         $this->db->read($this->table, $proyection, $params);
         $r = array();
         while ($param = $this->db->getRow()) {
             $picture = new Picture();
             $picture->set($param);
             $r[] = $picture;
         }
         return $r;
     }
     return NULL;
 }
Exemple #5
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 #6
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 #7
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();
     }
 }
Exemple #8
0
<?php

define('DOCUMENT_ROOT', dirname(__FILE__));
require_once DOCUMENT_ROOT . '/bootstrap.php';
$bootstrap = new Bootstrap();
$booted = $bootstrap->boot();
$sFileName = $_FILES['image_file']['name'];
$sFileType = $_FILES['image_file']['type'];
$error = $_FILES['image_file']['error'];
$user = new User();
if ($error == UPLOAD_ERR_OK && $user->dirSize() < $user->sizelimit) {
    $tmp_name = $_FILES["image_file"]["tmp_name"];
    if (getimagesize($tmp_name) != 0) {
        $name = stringToUri($_FILES["image_file"]["name"]);
        move_uploaded_file($tmp_name, $user->userdir . $name);
        $p = new \Picture();
        $p->fromPath($user->userdir . $name);
        $p->set($user->userdir . $name);
    } else {
        unlink($tmp_name);
        echo '<div class="message error">' . t('Not a picture') . '</div>';
    }
} else {
    echo '<div class="message error">' . t('Folder size limit exceeded') . '</div>';
}
Exemple #9
0
 public function setPicture()
 {
     $pd = new \Modl\PostnDAO();
     $item = $pd->getGroupPicture($this->server, $this->node);
     if ($item) {
         $item->getAttachments();
         $p = new \Picture();
         if ($item->getPublicUrl()) {
             try {
                 $embed = \Embed\Embed::create($item->getPublicUrl());
                 // We get the icon
                 $url = false;
                 foreach ($embed->providerIcons as $icon) {
                     if ($icon['mime'] != 'image/x-icon') {
                         $url = $icon['value'];
                     }
                 }
                 // If not we take the main picture
                 if (!$url) {
                     $url = (string) $embed->image;
                 }
                 // If not we take the post picture
                 if (!$url) {
                     $url = (string) $item->picture;
                 }
                 $p->fromURL($url);
                 if ($p->set($this->server . $this->node)) {
                     $this->logo = true;
                 }
             } catch (\Exception $e) {
                 error_log($e->getMessage());
             }
         }
     }
 }