1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

update to movim 0.9 2015-08-27

This commit is contained in:
src386 2015-08-27 07:26:21 +02:00
parent 449c5f7fe6
commit 7acf104028
16 changed files with 234 additions and 223 deletions

View file

@ -5,10 +5,13 @@ Movim is a decentralized social network, written in PHP and HTML5 and based on t
Warning: BETA. Warning: BETA.
Current Movim version : 20150824. Current Movim version : 0.9 git2015-08-27
**Changelog** **Changelog**
0.9b 2015-08-27
- Update to Movim 0.9 git2015-08-27
0.8b 2015-08-24 0.8b 2015-08-24
- Added language selection : ar, de, es, it, ja, nl, ru - Added language selection : ar, de, es, it, ja, nl, ru
- Fix URL in manifest.json (was https://https://...) - Fix URL in manifest.json (was https://https://...)

View file

@ -4,9 +4,9 @@ namespace modl;
class Conference extends Model { class Conference extends Model {
public $jid; public $jid;
public $conference; protected $conference;
public $name; protected $name;
public $nick; protected $nick;
public $autojoin; public $autojoin;
public $status; public $status;

View file

@ -158,37 +158,37 @@ class Contact extends Model {
} }
public function set($vcard, $jid) { public function set($vcard, $jid) {
$this->jid = \echapJid($jid); $this->__set('jid', \echapJid($jid));
if(isset($vcard->vCard->BDAY) if(isset($vcard->vCard->BDAY)
&& (string)$vcard->vCard->BDAY != '') && (string)$vcard->vCard->BDAY != '')
$this->date = (string)$vcard->vCard->BDAY; $this->__set('date', (string)$vcard->vCard->BDAY);
else else
$this->date = null; $this->__set('date', null);
$this->date = date(DATE_ISO8601, strtotime($this->date)); $this->__set('date', date(DATE_ISO8601, strtotime($this->date)));
$this->name = (string)$vcard->vCard->NICKNAME; $this->__set('name', (string)$vcard->vCard->NICKNAME);
$this->fn = (string)$vcard->vCard->FN; $this->__set('fn', (string)$vcard->vCard->FN);
$this->url = (string)$vcard->vCard->URL; $this->__set('url', (string)$vcard->vCard->URL);
$this->gender = (string)$vcard->vCard->{'X-GENDER'}; $this->__set('gender', (string)$vcard->vCard->{'X-GENDER'});
$this->marital = (string)$vcard->vCard->MARITAL->STATUS; $this->__set('marital', (string)$vcard->vCard->MARITAL->STATUS);
$this->email = (string)$vcard->vCard->EMAIL->USERID; $this->__set('email', (string)$vcard->vCard->EMAIL->USERID);
$this->adrlocality = (string)$vcard->vCard->ADR->LOCALITY; $this->__set('adrlocality', (string)$vcard->vCard->ADR->LOCALITY);
$this->adrpostalcode = (string)$vcard->vCard->ADR->PCODE; $this->__set('adrpostalcode', (string)$vcard->vCard->ADR->PCODE);
$this->adrcountry = (string)$vcard->vCard->ADR->CTRY; $this->__set('adrcountry', (string)$vcard->vCard->ADR->CTRY);
if(filter_var((string)$vcard->vCard->PHOTO, FILTER_VALIDATE_URL)) { if(filter_var((string)$vcard->vCard->PHOTO, FILTER_VALIDATE_URL)) {
$this->photobin = base64_encode( $this->__set('photobin', base64_encode(
requestUrl((string)$vcard->vCard->PHOTO, 1)); requestUrl((string)$vcard->vCard->PHOTO, 1)));
} else { } else {
$this->photobin = (string)$vcard->vCard->PHOTO->BINVAL; $this->__set('photobin', (string)$vcard->vCard->PHOTO->BINVAL);
} }
$this->description = (string)$vcard->vCard->DESC; $this->__set('description', (string)$vcard->vCard->DESC);
} }
public function createThumbnails() { public function createThumbnails() {
@ -250,32 +250,32 @@ class Contact extends Model {
} }
public function setTune($stanza) { public function setTune($stanza) {
$this->tuneartist = (string)$stanza->items->item->tune->artist; $this->__set('tuneartist', (string)$stanza->items->item->tune->artist);
$this->tunelenght = (int)$stanza->items->item->tune->lenght; $this->__set('tunelenght', (int)$stanza->items->item->tune->lenght);
$this->tunerating = (int)$stanza->items->item->tune->rating; $this->__set('tunerating', (int)$stanza->items->item->tune->rating);
$this->tunesource = (string)$stanza->items->item->tune->source; $this->__set('tunesource', (string)$stanza->items->item->tune->source);
$this->tunetitle = (string)$stanza->items->item->tune->title; $this->__set('tunetitle', (string)$stanza->items->item->tune->title);
$this->tunetrack = (string)$stanza->items->item->tune->track; $this->__set('tunetrack', (string)$stanza->items->item->tune->track);
} }
public function setVcard4($vcard) { public function setVcard4($vcard) {
if(isset($vcard->bday->date)) /*if(isset($vcard->bday->date))
$this->date = (string)$vcard->bday->date; $this->__set('date', (string)$vcard->bday->date);
if(empty($this->date)) if(empty($this->date))
$this->date = null; $this->__set('date', null);
*/
$this->name = (string)$vcard->nickname->text; $this->__set('name', (string)$vcard->nickname->text);
$this->fn = (string)$vcard->fn->text; $this->__set('fn', (string)$vcard->fn->text);
$this->url = (string)$vcard->url->uri; $this->__set('url', (string)$vcard->url->uri);
if(isset($vcard->gender)) if(isset($vcard->gender))
$this->gender = (string)$vcard->gender->sex->text; $this->__set('gender ', (string)$vcard->gender->sex->text);
if(isset($vcard->marital)) if(isset($vcard->marital))
$this->marital = (string)$vcard->marital->status->text; $this->__set('marital', (string)$vcard->marital->status->text);
$this->adrlocality = (string)$vcard->adr->locality; $this->__set('adrlocality', (string)$vcard->adr->locality);
$this->adrcountry = (string)$vcard->adr->country; $this->__set('adrcountry', (string)$vcard->adr->country);
$this->adrpostalcode = (string)$vcard->adr->code; $this->__set('adrpostalcode', (string)$vcard->adr->code);
if(isset($vcard->impp)) { if(isset($vcard->impp)) {
foreach($vcard->impp->children() as $c) { foreach($vcard->impp->children() as $c) {
@ -283,21 +283,20 @@ class Contact extends Model {
switch($key) { switch($key) {
case 'twitter' : case 'twitter' :
$this->twitter = str_replace('@', '', $value); $this->__set('twitter', str_replace('@', '', $value));
break; break;
case 'skype' : case 'skype' :
$this->skype = (string)$value; $this->__set('skype', (string)$value);
break; break;
case 'ymsgr' : case 'ymsgr' :
$this->yahoo = (string)$value; $this->__set('yahoo', (string)$value);
break; break;
} }
} }
} }
$this->email = (string)$vcard->email->text; $this->__set('email', (string)$vcard->email->text);
$this->__set('description', trim((string)$vcard->note->text));
$this->description = trim((string)$vcard->note->text);
} }
public function getPlace() { public function getPlace() {

View file

@ -7,14 +7,14 @@ class Message extends Model {
public $jidto; public $jidto;
public $jidfrom; public $jidfrom;
public $resource; protected $resource;
public $type; public $type;
public $subject; protected $subject;
public $thread; protected $thread;
public $body; protected $body;
public $html; protected $html;
public $published; public $published;
public $delivered; public $delivered;
@ -66,15 +66,15 @@ class Message extends Model {
$this->jidfrom = $jid[0]; $this->jidfrom = $jid[0];
if(isset($jid[1])) if(isset($jid[1]))
$this->resource = $jid[1]; $this->__set('resource', $jid[1]);
$this->type = 'chat'; $this->type = 'chat';
if($stanza->attributes()->type) { if($stanza->attributes()->type) {
$this->type = (string)$stanza->attributes()->type; $this->type = (string)$stanza->attributes()->type;
} }
$this->body = (string)$stanza->body; $this->__set('body', (string)$stanza->body);
$this->subject = (string)$stanza->subject; $this->__set('subject', (string)$stanza->subject);
$images = (bool)($this->type == 'chat'); $images = (bool)($this->type == 'chat');
@ -83,7 +83,7 @@ class Message extends Model {
$this->html = \fixSelfClosing($this->html); $this->html = \fixSelfClosing($this->html);
$this->html = \prepareString($this->html, false, $images); $this->html = \prepareString($this->html, false, $images);
} else {*/ } else {*/
$this->html = \prepareString($this->body, false, $images); // $this->html = \prepareString($this->body, false, $images);
//} //}
if($stanza->delay) if($stanza->delay)

View file

@ -109,33 +109,33 @@ class Postn extends Model {
else else
$entry = $item; $entry = $item;
$this->origin = $from; $this->__set('origin', $from);
if($node) if($node)
$this->node = $node; $this->__set('node', $node);
else else
$this->node = (string)$item->attributes()->node; $this->__set('node', (string)$item->attributes()->node);
$this->nodeid = (string)$entry->attributes()->id; $this->__set('nodeid', (string)$entry->attributes()->id);
if($entry->entry->id) if($entry->entry->id)
$this->nodeid = (string)$entry->entry->id; $this->__set('nodeid', (string)$entry->entry->id);
// Get some informations on the author // Get some informations on the author
if($entry->entry->author->name) if($entry->entry->author->name)
$this->aname = (string)$entry->entry->author->name; $this->__set('aname', (string)$entry->entry->author->name);
if($entry->entry->author->uri) if($entry->entry->author->uri)
$this->aid = substr((string)$entry->entry->author->uri, 5); $this->__set('aid', substr((string)$entry->entry->author->uri, 5));
if($entry->entry->author->email) if($entry->entry->author->email)
$this->aemail = (string)$entry->entry->author->email; $this->__set('aemail', (string)$entry->entry->author->email);
// Non standard support // Non standard support
if($entry->entry->source && $entry->entry->source->author->name) if($entry->entry->source && $entry->entry->source->author->name)
$this->aname = (string)$entry->entry->source->author->name; $this->__set('aname', (string)$entry->entry->source->author->name);
if($entry->entry->source && $entry->entry->source->author->uri) if($entry->entry->source && $entry->entry->source->author->uri)
$this->aid = substr((string)$entry->entry->source->author->uri, 5); $this->__set('aid', substr((string)$entry->entry->source->author->uri, 5));
$this->title = (string)$entry->entry->title; $this->__set('title', (string)$entry->entry->title);
// Content // Content
if($entry->entry->summary && (string)$entry->entry->summary != '') if($entry->entry->summary && (string)$entry->entry->summary != '')
@ -153,23 +153,22 @@ class Postn extends Model {
$content = $summary.$content; $content = $summary.$content;
if($entry->entry->updated) if($entry->entry->updated)
$this->updated = (string)$entry->entry->updated; $this->__set('updated', (string)$entry->entry->updated);
else else
$this->updated = gmdate(DATE_ISO8601); $this->__set('updated', gmdate(DATE_ISO8601));
if($entry->entry->published) if($entry->entry->published)
$this->published = (string)$entry->entry->published; $this->__set('published', (string)$entry->entry->published);
elseif($entry->entry->updated) elseif($entry->entry->updated)
$this->published = (string)$entry->entry->updated; $this->__set('published', (string)$entry->entry->updated);
else else
$this->published = gmdate(DATE_ISO8601); $this->__set('published', gmdate(DATE_ISO8601));
if($delay) if($delay)
$this->delay = $delay; $this->__set('delay', $delay);
$contentimg = $this->setAttachements($entry->entry->link); $contentimg = $this->setAttachements($entry->entry->link);
// Tags parsing // Tags parsing
if($entry->entry->category) { if($entry->entry->category) {
$this->tags = array(); $this->tags = array();
@ -183,22 +182,24 @@ class Postn extends Model {
} }
if(!empty($this->tags)) if(!empty($this->tags))
$this->tags = serialize($this->tags); $this->__set('tags', serialize($this->tags));
if($contentimg != '') if($contentimg != '')
$content .= '<br />'.$contentimg; $content .= '<br />'.$contentimg;
if(!isset($this->commentplace)) if(!isset($this->commentplace))
$this->commentplace = $this->origin; $this->__set('commentplace', $this->origin);
$this->content = trim($content); $this->__set('content', trim($content));
$this->contentcleaned = prepareString(html_entity_decode($this->content)); //$this->__set('contentcleaned', prepareString(html_entity_decode($this->content)));
$purifier = new \HTMLPurifier();
$this->contentcleaned = $purifier->purify(html_entity_decode($this->content));
if($entry->entry->geoloc) { if($entry->entry->geoloc) {
if($entry->entry->geoloc->lat != 0) if($entry->entry->geoloc->lat != 0)
$this->lat = (string)$entry->entry->geoloc->lat; $this->__set('lat', (string)$entry->entry->geoloc->lat);
if($entry->entry->geoloc->lon != 0) if($entry->entry->geoloc->lon != 0)
$this->lon = (string)$entry->entry->geoloc->lon; $this->__set('lon', (string)$entry->entry->geoloc->lon);
} }
} }

View file

@ -82,35 +82,35 @@ class Presence extends Model {
else else
$to = $jid[0]; $to = $jid[0];
$this->session = $to; $this->__set('session', $to);
$this->jid = $jid[0]; $this->__set('jid', $jid[0]);
if(isset($jid[1])) if(isset($jid[1]))
$this->resource = $jid[1]; $this->__set('resource', $jid[1]);
else else
$this->resource = 'default'; $this->__set('resource', 'default');
$this->status = (string)$stanza->status; $this->__set('status', (string)$stanza->status);
if($stanza->c) { if($stanza->c) {
$this->node = (string)$stanza->c->attributes()->node; $this->__set('node', (string)$stanza->c->attributes()->node);
$this->ver = (string)$stanza->c->attributes()->ver; $this->__set('ver', (string)$stanza->c->attributes()->ver);
} }
if($stanza->priority) if($stanza->priority)
$this->priority = (string)$stanza->priority; $this->__set('priority', (string)$stanza->priority);
if((string)$stanza->attributes()->type == 'error') { if((string)$stanza->attributes()->type == 'error') {
$this->value = 6; $this->__set('value', 6);
} elseif((string)$stanza->attributes()->type == 'unavailable') { } elseif((string)$stanza->attributes()->type == 'unavailable') {
$this->value = 5; $this->__set('value', 5);
} elseif((string)$stanza->show == 'away') { } elseif((string)$stanza->show == 'away') {
$this->value = 2; $this->__set('value', 2);
} elseif((string)$stanza->show == 'dnd') { } elseif((string)$stanza->show == 'dnd') {
$this->value = 3; $this->__set('value', 3);
} elseif((string)$stanza->show == 'xa') { } elseif((string)$stanza->show == 'xa') {
$this->value = 4; $this->__set('value', 4);
} else { } else {
$this->value = 1; $this->__set('value', 1);
} }
// Specific XEP // Specific XEP
@ -118,38 +118,38 @@ class Presence extends Model {
foreach($stanza->children() as $name => $c) { foreach($stanza->children() as $name => $c) {
switch($c->attributes()->xmlns) { switch($c->attributes()->xmlns) {
case 'jabber:x:signed' : case 'jabber:x:signed' :
$this->publickey = (string)$c; $this->__set('publickey', (string)$c);
break; break;
case 'http://jabber.org/protocol/muc#user' : case 'http://jabber.org/protocol/muc#user' :
$this->muc = true; $this->__set('muc ', true);
if($c->item->attributes()->jid) if($c->item->attributes()->jid)
$this->mucjid = cleanJid((string)$c->item->attributes()->jid); $this->__set('mucjid', cleanJid((string)$c->item->attributes()->jid));
else else
$this->mucjid = (string)$stanza->attributes()->from; $this->__set('mucjid', (string)$stanza->attributes()->from);
$this->mucrole = (string)$c->item->attributes()->role; $this->__set('mucrole', (string)$c->item->attributes()->role);
$this->mucaffiliation = (string)$c->item->attributes()->affiliation; $this->__set('mucaffiliation', (string)$c->item->attributes()->affiliation);
break; break;
case 'vcard-temp:x:update' : case 'vcard-temp:x:update' :
$this->photo = true; $this->__set('photo', true);
break; break;
} }
} }
} }
if($stanza->delay) { if($stanza->delay) {
$this->delay = $this->__set('delay',
gmdate( gmdate(
'Y-m-d H:i:s', 'Y-m-d H:i:s',
strtotime( strtotime(
(string)$stanza->delay->attributes()->stamp (string)$stanza->delay->attributes()->stamp
) )
) )
; );
} }
if($stanza->query) { if($stanza->query) {
$this->last = (int)$stanza->query->attributes()->seconds; $this->__set('last', (int)$stanza->query->attributes()->seconds);
} }
} }

View file

@ -6,13 +6,13 @@ class RosterLink extends Model {
public $session; public $session;
public $jid; public $jid;
public $rostername; protected $rostername;
public $rosterask; public $rosterask;
public $rostersubscription; public $rostersubscription;
public $realname; protected $realname;
public $groupname; protected $groupname;
public $chaton; public $chaton;
@ -46,12 +46,13 @@ class RosterLink extends Model {
function set($stanza) { function set($stanza) {
$this->jid = (string)$stanza->attributes()->jid; $this->jid = (string)$stanza->attributes()->jid;
if(isset($stanza->attributes()->name) && (string)$stanza->attributes()->name != '') if(isset($stanza->attributes()->name)
$this->rostername = (string)$stanza->attributes()->name; && (string)$stanza->attributes()->name != '')
$this->__set('rostername', (string)$stanza->attributes()->name);
else else
$this->rostername = (string)$stanza->attributes()->jid; $this->__set('rostername', (string)$stanza->attributes()->jid);
$this->rosterask = (string)$stanza->attributes()->ask; $this->__set('rosterask', (string)$stanza->attributes()->ask);
$this->rostersubscription = (string)$stanza->attributes()->subscription; $this->__set('rostersubscription', (string)$stanza->attributes()->subscription);
$this->groupname = (string)$stanza->group; $this->__set('groupname', (string)$stanza->group);
} }
} }

View file

@ -4,11 +4,11 @@ namespace modl;
class Subscription extends Model { class Subscription extends Model {
public $jid; public $jid;
public $server; protected $server;
public $node; protected $node;
public $subscription; protected $subscription;
public $subid; protected $subid;
public $title; protected $title;
public $description; public $description;
public $tags; public $tags;
public $timestamp; public $timestamp;
@ -40,13 +40,13 @@ class Subscription extends Model {
} }
function set($jid, $server, $node, $s) { function set($jid, $server, $node, $s) {
$this->jid = $jid; $this->__set('jid', $jid);
$this->server = $server; $this->__set('server', $server);
$this->node = $node; $this->__set('node', $node);
$this->jid = (string)$s->attributes()->jid; $this->__set('jid', (string)$s->attributes()->jid);
$this->subscription = (string)$s->attributes()->subscription; $this->__set('subscription', (string)$s->attributes()->subscription);
$this->subid = (string)$s->attributes()->subid; $this->__set('subid', (string)$s->attributes()->subid);
$this->tags = serialize(array()); $this->__set('tags', serialize(array()));
if($this->subid = '') if($this->subid = '')
$this->subid = 'default'; $this->subid = 'default';

View file

@ -13,7 +13,7 @@ class Account extends WidgetBase
$this->addjs('account.js'); $this->addjs('account.js');
$this->registerEvent('register_changepassword_handle', 'onPasswordChanged'); $this->registerEvent('register_changepassword_handle', 'onPasswordChanged');
$this->registerEvent('register_remove_handle', 'onRemoved'); $this->registerEvent('register_remove_handle', 'onRemoved');
$this->registerEvent('register_get_handle', 'onRegister'); $this->registerEvent('register_get_handle', 'onRegister', 'account');
} }
function onPasswordChanged() function onPasswordChanged()

View file

@ -10,3 +10,7 @@ var Account = {
Presence_ajaxLogout(); Presence_ajaxLogout();
} }
} }
MovimWebsocket.attach(function() {
Notification.current('account');
});

View file

@ -12,9 +12,9 @@ class AccountNext extends WidgetBase {
$this->registerEvent('register_get_handle', 'onForm'); $this->registerEvent('register_get_handle', 'onForm');
$this->registerEvent('register_set_handle', 'onRegistered'); $this->registerEvent('register_set_handle', 'onRegistered');
$this->registerEvent('register_set_errorconflict', 'onRegisterError'); $this->registerEvent('register_set_errorconflict', 'onRegisterError', 'accountnext');
$this->registerEvent('register_set_errornotacceptable', 'onRegisterNotAcceptable'); $this->registerEvent('register_set_errornotacceptable', 'onRegisterNotAcceptable', 'accountnext');
$this->registerEvent('register_get_errorserviceunavailable', 'onServiceUnavailable'); $this->registerEvent('register_get_errorserviceunavailable', 'onServiceUnavailable', 'accountnext');
} }
function display() function display()

View file

@ -253,7 +253,7 @@ class Chat extends WidgetBase
} }
$m->body = rawurldecode($message); $m->body = rawurldecode($message);
$m->html = prepareString($m->body, false, true); //$m->html = prepareString($m->body, false, true);
$m->published = gmdate('Y-m-d H:i:s'); $m->published = gmdate('Y-m-d H:i:s');
$m->delivered = gmdate('Y-m-d H:i:s'); $m->delivered = gmdate('Y-m-d H:i:s');
@ -265,7 +265,7 @@ class Chat extends WidgetBase
$p = new Publish; $p = new Publish;
$p->setTo($to); $p->setTo($to);
//$p->setHTML($m->html); //$p->setHTML($m->html);
$p->setContent(htmlspecialchars($m->body)); $p->setContent($m->body);
if($muc) { if($muc) {
$p->setMuc(); $p->setMuc();
@ -485,11 +485,11 @@ class Chat extends WidgetBase
function prepareMessage(&$message) function prepareMessage(&$message)
{ {
if(isset($message->html)) { /*if(isset($message->html)) {
$message->body = $message->html; $message->body = $message->html;
} else { } else {
$message->body = prepareString(htmlentities($message->body , ENT_COMPAT,'UTF-8')); $message->body = prepareString(htmlentities($message->body , ENT_COMPAT,'UTF-8'));
} }*/
if($message->type == 'groupchat') { if($message->type == 'groupchat') {
$message->color = stringToColor($message->session.$message->resource.$message->jidfrom.$message->type); $message->color = stringToColor($message->session.$message->resource.$message->jidfrom.$message->type);

View file

@ -77,7 +77,6 @@ var Chat = {
}; };
bubble.querySelector('span.user').innerHTML = message.resource; bubble.querySelector('span.user').innerHTML = message.resource;
var conversation = document.getElementById(id); var conversation = document.getElementById(id);
if(conversation) { if(conversation) {
conversation.appendChild(bubble); conversation.appendChild(bubble);
@ -110,6 +109,7 @@ var Chat = {
if(bubble) { if(bubble) {
bubble.querySelector('div.bubble div').innerHTML = message.body; bubble.querySelector('div.bubble div').innerHTML = message.body;
bubble.querySelector('div.bubble span.info').innerHTML = message.published; bubble.querySelector('div.bubble span.info').innerHTML = message.published;
movim_append(id, bubble.outerHTML); movim_append(id, bubble.outerHTML);

View file

@ -196,9 +196,9 @@ class Rooms extends WidgetBase
array_push($arr, array_push($arr,
array( array(
'type' => 'conference', 'type' => 'conference',
'name' => $c->name, 'name' => htmlentities($c->name),
'autojoin' => $c->autojoin, 'autojoin' => $c->autojoin,
'nick' => $c->nick, 'nick' => htmlentities($c->nick),
'jid' => $c->conference)); 'jid' => $c->conference));
} }

View file

@ -22,6 +22,7 @@
"react/socket-client": "0.4.*@dev", "react/socket-client": "0.4.*@dev",
"forxer/Gravatar": "~1.2", "forxer/Gravatar": "~1.2",
"respect/validation": "0.8.*" "respect/validation": "0.8.*",
"ezyang/htmlpurifier": "^4.7"
} }
} }

View file

@ -52,8 +52,8 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
$port = 5222; $port = 5222;
$dns = \Moxl\Utils::resolveHost($msg->host); $dns = \Moxl\Utils::resolveHost($msg->host);
if(isset($dns[0]['target']) && $dns[0]['target'] != null) $msg->host = $dns[0]['target']; if(isset($dns->target) && $dns->target != null) $msg->host = $dns->target;
if(isset($dns[0]['port']) && $dns[0]['port'] != null) $port = $dns[0]['port']; if(isset($dns->port) && $dns->port != null) $port = $dns->port;
#fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
$connector->create($msg->host, $port)->then($xmpp_behaviour); $connector->create($msg->host, $port)->then($xmpp_behaviour);
} }
@ -111,6 +111,8 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s
|| $message == '<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>') { || $message == '<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>') {
stream_set_blocking($conn->stream, 1); stream_set_blocking($conn->stream, 1);
stream_context_set_option($conn->stream, 'ssl', 'allow_self_signed', true); stream_context_set_option($conn->stream, 'ssl', 'allow_self_signed', true);
#stream_context_set_option($conn->stream, 'ssl', 'verify_peer_name', false);
#stream_context_set_option($conn->stream, 'ssl', 'verify_peer', false);
$out = stream_socket_enable_crypto($conn->stream, 1, STREAM_CRYPTO_METHOD_TLS_CLIENT); $out = stream_socket_enable_crypto($conn->stream, 1, STREAM_CRYPTO_METHOD_TLS_CLIENT);
$restart = true; $restart = true;
@ -137,7 +139,7 @@ $xmpp_behaviour = function (React\Stream\Stream $stream) use (&$conn, $loop, &$s
\RPC::clear(); \RPC::clear();
if(!empty($msg)) { if(!empty($msg)) {
//[MaJ[MaJ[MaJ[MaI[MaI[MaI[MaI[MaI[MaI[MaI[MaI[MaIecho json_encode($msg).""; //echo json_encode($msg)."";
echo base64_encode(gzcompress(json_encode($msg), 9)).""; echo base64_encode(gzcompress(json_encode($msg), 9))."";
//fwrite(STDERR, colorize(json_encode($msg).' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n"); //fwrite(STDERR, colorize(json_encode($msg).' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n");
} }