2015-08-03 11:35:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace modl;
|
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
use Respect\Validation\Validator;
|
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
class Contact extends Model {
|
|
|
|
public $jid;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $fn;
|
|
|
|
protected $name;
|
|
|
|
protected $date;
|
|
|
|
protected $url;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public $email;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $adrlocality;
|
|
|
|
protected $adrpostalcode;
|
|
|
|
protected $adrcountry;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $gender;
|
|
|
|
protected $marital;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $photobin;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $description;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $protected;
|
|
|
|
protected $privacy;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// User Mood (contain serialized array) - XEP 0107
|
|
|
|
protected $mood;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// User Activity (contain serialized array) - XEP 0108
|
|
|
|
protected $activity;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// User Nickname - XEP 0172
|
|
|
|
protected $nickname;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// User Tune - XEP 0118
|
|
|
|
protected $tuneartist;
|
|
|
|
protected $tunelenght;
|
|
|
|
protected $tunerating;
|
|
|
|
protected $tunesource;
|
|
|
|
protected $tunetitle;
|
|
|
|
protected $tunetrack;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
|
|
|
// User Location
|
2015-08-03 11:35:01 +02:00
|
|
|
protected $loclatitude;
|
|
|
|
protected $loclongitude;
|
|
|
|
protected $localtitude;
|
|
|
|
protected $loccountry;
|
|
|
|
protected $loccountrycode;
|
|
|
|
protected $locregion;
|
|
|
|
protected $locpostalcode;
|
|
|
|
protected $loclocality;
|
|
|
|
protected $locstreet;
|
|
|
|
protected $locbuilding;
|
|
|
|
protected $loctext;
|
|
|
|
protected $locuri;
|
|
|
|
protected $loctimestamp;
|
|
|
|
|
|
|
|
// Accounts
|
|
|
|
protected $twitter;
|
|
|
|
protected $skype;
|
|
|
|
protected $yahoo;
|
|
|
|
|
|
|
|
protected $avatarhash;
|
|
|
|
|
|
|
|
// Datetime
|
|
|
|
public $created;
|
|
|
|
public $updated;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function __construct() {
|
|
|
|
$this->_struct = '
|
|
|
|
{
|
2015-08-19 11:28:28 +02:00
|
|
|
"jid" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128, "mandatory":true, "key":true },
|
2015-08-19 11:28:28 +02:00
|
|
|
"fn" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"name" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"date" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"date", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"url" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"email" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"adrlocality" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"adrpostalcode" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"adrcountry" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"gender" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":1 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"marital" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":20 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"description" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"text"},
|
2015-08-19 11:28:28 +02:00
|
|
|
"mood" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"activity" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"nickname" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tuneartist" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tunelenght" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tunerating" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tunesource" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tunetitle" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"tunetrack" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loclatitude" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loclongitude" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"localtitude" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loccountry" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loccountrycode" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"locregion" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"locpostalcode" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loclocality" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"locstreet" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"locbuilding" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loctext" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"text" },
|
2015-08-19 11:28:28 +02:00
|
|
|
"locuri" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"loctimestamp" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"date", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"twitter" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"skype" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"yahoo" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"avatarhash" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"created" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"date" },
|
2015-08-19 11:28:28 +02:00
|
|
|
"updated" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"date" }
|
|
|
|
}';
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function set($vcard, $jid) {
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('jid', \echapJid($jid));
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$validate_date = Validator::date('Y-m-d');
|
2015-08-03 11:35:01 +02:00
|
|
|
if(isset($vcard->vCard->BDAY)
|
2015-09-10 15:41:45 +02:00
|
|
|
&& $validate_date->validate($vcard->vCard->BDAY))
|
|
|
|
$this->__set('date', (string)$vcard->vCard->BDAY);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('date', date(DATE_ISO8601, strtotime($this->date)));
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('name', (string)$vcard->vCard->NICKNAME);
|
|
|
|
$this->__set('fn', (string)$vcard->vCard->FN);
|
|
|
|
$this->__set('url', (string)$vcard->vCard->URL);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('gender', (string)$vcard->vCard->{'X-GENDER'});
|
|
|
|
$this->__set('marital', (string)$vcard->vCard->MARITAL->STATUS);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('email', (string)$vcard->vCard->EMAIL->USERID);
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('adrlocality', (string)$vcard->vCard->ADR->LOCALITY);
|
|
|
|
$this->__set('adrpostalcode', (string)$vcard->vCard->ADR->PCODE);
|
|
|
|
$this->__set('adrcountry', (string)$vcard->vCard->ADR->CTRY);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
if(filter_var((string)$vcard->vCard->PHOTO, FILTER_VALIDATE_URL)) {
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('photobin', base64_encode(
|
|
|
|
requestUrl((string)$vcard->vCard->PHOTO, 1)));
|
2015-08-03 11:35:01 +02:00
|
|
|
} else {
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('photobin', (string)$vcard->vCard->PHOTO->BINVAL);
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('description', (string)$vcard->vCard->DESC);
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function createThumbnails() {
|
|
|
|
$p = new \Picture;
|
|
|
|
$p->fromBase($this->photobin);
|
|
|
|
$p->set($this->jid);
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if(isset($this->email)) {
|
|
|
|
\createEmailPic(strtolower($this->jid), $this->email);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isPhoto($jid = false, $x = false, $y = false) {
|
|
|
|
if(!$jid) return false;
|
|
|
|
|
|
|
|
$p = new \Picture;
|
|
|
|
$url = $p->get($jid, $sizes[$size][0], $sizes[$size][1]);
|
|
|
|
if($url) return $url;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPhoto($size = 'l', $jid = false) {
|
|
|
|
if($size == 'email') {
|
|
|
|
return BASE_URI.'cache/'.strtolower($this->jid).'_email.jpg';
|
|
|
|
} else {
|
|
|
|
$sizes = array(
|
|
|
|
'wall' => array(1920, 1080),
|
|
|
|
'xxl' => array(1280, 300),
|
|
|
|
'l' => array(210 , false),
|
|
|
|
'm' => array(120 , false),
|
|
|
|
's' => array(50 , false),
|
|
|
|
'xs' => array(28 , false),
|
|
|
|
'xxs' => array(24 , false)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$p = new \Picture;
|
|
|
|
return $p->get($this->jid, $sizes[$size][0], $sizes[$size][1]);
|
|
|
|
}
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function setLocation($stanza) {
|
|
|
|
$this->loclatitude = (string)$stanza->items->item->geoloc->lat;
|
|
|
|
$this->loclongitude = (string)$stanza->items->item->geoloc->lon;
|
|
|
|
$this->localtitude = (int)$stanza->items->item->geoloc->alt;
|
|
|
|
$this->loccountry = (string)$stanza->items->item->geoloc->country;
|
|
|
|
$this->loccountrycode = (string)$stanza->items->item->geoloc->countrycode;
|
|
|
|
$this->locregion = (string)$stanza->items->item->geoloc->region;
|
|
|
|
$this->locpostalcode = (string)$stanza->items->item->geoloc->postalcode;
|
|
|
|
$this->loclocality = (string)$stanza->items->item->geoloc->locality;
|
|
|
|
$this->locstreet = (string)$stanza->items->item->geoloc->street;
|
|
|
|
$this->locbuilding = (string)$stanza->items->item->geoloc->building;
|
|
|
|
$this->loctext = (string)$stanza->items->item->geoloc->text;
|
|
|
|
$this->locuri = (string)$stanza->items->item->geoloc->uri;
|
|
|
|
$this->loctimestamp = date(
|
2015-08-19 11:28:28 +02:00
|
|
|
'Y-m-d H:i:s',
|
2015-08-03 11:35:01 +02:00
|
|
|
strtotime((string)$stanza->items->item->geoloc->timestamp));
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function setTune($stanza) {
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('tuneartist', (string)$stanza->items->item->tune->artist);
|
|
|
|
$this->__set('tunelenght', (int)$stanza->items->item->tune->lenght);
|
|
|
|
$this->__set('tunerating', (int)$stanza->items->item->tune->rating);
|
|
|
|
$this->__set('tunesource', (string)$stanza->items->item->tune->source);
|
|
|
|
$this->__set('tunetitle', (string)$stanza->items->item->tune->title);
|
|
|
|
$this->__set('tunetrack', (string)$stanza->items->item->tune->track);
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function setVcard4($vcard) {
|
2015-09-10 15:41:45 +02:00
|
|
|
$validate_date = Validator::date('Y-m-d');
|
|
|
|
if(isset($vcard->bday->date)
|
|
|
|
&& $validate_date->validate($vcard->bday->date))
|
|
|
|
$this->__set('date', (string)$vcard->bday->date);
|
2015-08-31 14:49:04 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('name', (string)$vcard->nickname->text);
|
|
|
|
$this->__set('fn', (string)$vcard->fn->text);
|
|
|
|
$this->__set('url', (string)$vcard->url->uri);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
if(isset($vcard->gender))
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('gender ', (string)$vcard->gender->sex->text);
|
2015-08-03 11:35:01 +02:00
|
|
|
if(isset($vcard->marital))
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('marital', (string)$vcard->marital->status->text);
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('adrlocality', (string)$vcard->adr->locality);
|
|
|
|
$this->__set('adrcountry', (string)$vcard->adr->country);
|
|
|
|
$this->__set('adrpostalcode', (string)$vcard->adr->code);
|
2015-08-03 11:35:01 +02:00
|
|
|
|
|
|
|
if(isset($vcard->impp)) {
|
|
|
|
foreach($vcard->impp->children() as $c) {
|
|
|
|
list($key, $value) = explode(':', (string)$c);
|
|
|
|
|
|
|
|
switch($key) {
|
|
|
|
case 'twitter' :
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('twitter', str_replace('@', '', $value));
|
2015-08-03 11:35:01 +02:00
|
|
|
break;
|
|
|
|
case 'skype' :
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('skype', (string)$value);
|
2015-08-03 11:35:01 +02:00
|
|
|
break;
|
|
|
|
case 'ymsgr' :
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('yahoo', (string)$value);
|
2015-08-03 11:35:01 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
$this->__set('email', (string)$vcard->email->text);
|
|
|
|
$this->__set('description', trim((string)$vcard->note->text));
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getPlace() {
|
|
|
|
$place = null;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if($this->loctext != '')
|
2015-08-19 11:28:28 +02:00
|
|
|
$place .= $this->loctext.' ';
|
2015-08-03 11:35:01 +02:00
|
|
|
else {
|
|
|
|
if($this->locbuilding != '')
|
|
|
|
$place .= $this->locbuilding.' ';
|
|
|
|
if($this->locstreet != '')
|
|
|
|
$place .= $this->locstreet.'<br />';
|
|
|
|
if($this->locpostalcode != '')
|
|
|
|
$place .= $this->locpostalcode.' ';
|
|
|
|
if($this->loclocality != '')
|
|
|
|
$place .= $this->loclocality.'<br />';
|
|
|
|
if($this->locregion != '')
|
|
|
|
$place .= $this->locregion.' - ';
|
|
|
|
if($this->loccountry != '')
|
|
|
|
$place .= $this->loccountry;
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
return $place;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTrueName() {
|
|
|
|
$truename = '';
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if(isset($this->rostername))
|
|
|
|
$rostername = str_replace('\40', '', $this->rostername);
|
|
|
|
else
|
|
|
|
$rostername = '';
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if(
|
|
|
|
isset($this->rostername)
|
|
|
|
&& $rostername != ''
|
|
|
|
&& !filter_var($rostername, FILTER_VALIDATE_EMAIL)
|
|
|
|
)
|
|
|
|
$truename = $rostername;
|
|
|
|
elseif(
|
|
|
|
isset($this->fn)
|
|
|
|
&& $this->fn != ''
|
|
|
|
&& !filter_var($this->fn, FILTER_VALIDATE_EMAIL)
|
|
|
|
)
|
|
|
|
$truename = $this->fn;
|
|
|
|
elseif(
|
|
|
|
isset($this->nickname)
|
|
|
|
&& $this->nickname != ''
|
|
|
|
&& !filter_var($this->nickname, FILTER_VALIDATE_EMAIL)
|
|
|
|
)
|
|
|
|
$truename = $this->nickname;
|
|
|
|
elseif(
|
|
|
|
isset($this->name)
|
|
|
|
&& $this->name != ''
|
|
|
|
&& !filter_var($this->name, FILTER_VALIDATE_EMAIL)
|
|
|
|
)
|
|
|
|
$truename = $this->name;
|
|
|
|
else
|
|
|
|
$truename = $this->jid;
|
|
|
|
|
|
|
|
return $truename;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAge() {
|
|
|
|
if(isset($this->date)
|
2015-08-19 11:28:28 +02:00
|
|
|
&& $this->date != '0000-00-00T00:00:00+0000'
|
2015-08-03 11:35:01 +02:00
|
|
|
&& $this->date != '1970-01-01 00:00:00'
|
|
|
|
&& $this->date != '1970-01-01 01:00:00'
|
|
|
|
&& $this->date != '1970-01-01T00:00:00+0000') {
|
|
|
|
$age = intval(substr(date('Ymd') - date('Ymd', strtotime($this->date)), 0, -4));
|
|
|
|
if($age != 0)
|
|
|
|
return $age;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getGender() {
|
|
|
|
$gender = getGender();
|
|
|
|
|
|
|
|
if($this->gender != null && $this->gender != 'N') {
|
|
|
|
return $gender[$this->gender];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMarital() {
|
|
|
|
$marital = getMarital();
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if($this->marital != null && $this->marital != 'none') {
|
|
|
|
return $marital[$this->marital];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-10 15:41:45 +02:00
|
|
|
function getAlbum()
|
|
|
|
{
|
|
|
|
$uri = str_replace(
|
|
|
|
' ',
|
|
|
|
'%20',
|
|
|
|
'http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=80c1aa3abfa9e3d06f404a2e781e38f9&artist='.
|
|
|
|
$this->tuneartist.
|
|
|
|
'&album='.
|
|
|
|
$this->tunesource.
|
|
|
|
'&format=json'
|
|
|
|
);
|
|
|
|
|
|
|
|
$json = json_decode(requestURL($uri, 2));
|
|
|
|
|
|
|
|
if($json->album) {
|
|
|
|
$json->album->url = $json->album->image[2]->{'#text'};
|
|
|
|
return $json->album;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
function toRoster() {
|
|
|
|
return array(
|
|
|
|
'jid' => $this->jid,
|
|
|
|
'rostername' => $this->rostername,
|
|
|
|
'rostername' => $this->rostername,
|
|
|
|
'groupname' => $this->groupname,
|
|
|
|
'status' => $this->status,
|
|
|
|
'resource' => $this->resource,
|
|
|
|
'value' => $this->value
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function isEmpty() {
|
|
|
|
if($this->fn == null
|
|
|
|
&& $this->name == null
|
|
|
|
&& $this->date == null
|
|
|
|
&& $this->url == null
|
|
|
|
&& $this->email == null
|
|
|
|
&& $this->description == null) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isOld() {
|
|
|
|
if(strtotime($this->updated) < mktime( // We update the 1 day old vcards
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
gmdate("m"),
|
|
|
|
gmdate("d")-1,
|
|
|
|
gmdate("Y")
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PresenceContact extends Contact {
|
|
|
|
// General presence informations
|
|
|
|
protected $resource;
|
|
|
|
protected $value;
|
|
|
|
protected $priority;
|
|
|
|
protected $status;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// Client Informations
|
|
|
|
protected $node;
|
|
|
|
protected $ver;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// Delay - XEP 0203
|
|
|
|
protected $delay;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// Last Activity - XEP 0256
|
|
|
|
protected $last;
|
|
|
|
|
|
|
|
// Current Jabber OpenPGP Usage - XEP-0027
|
|
|
|
protected $publickey;
|
|
|
|
protected $muc;
|
|
|
|
protected $mucjid;
|
|
|
|
protected $mucaffiliation;
|
|
|
|
protected $mucrole;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->_struct = '
|
|
|
|
{
|
2015-08-19 11:28:28 +02:00
|
|
|
"resource" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":64, "key":true },
|
2015-08-19 11:28:28 +02:00
|
|
|
"value" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11, "mandatory":true },
|
2015-08-19 11:28:28 +02:00
|
|
|
"priority" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"status" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"text"},
|
2015-08-19 11:28:28 +02:00
|
|
|
"node" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"ver" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"delay" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"date"},
|
2015-08-19 11:28:28 +02:00
|
|
|
"last" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"publickey" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"text"},
|
2015-08-19 11:28:28 +02:00
|
|
|
"muc" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"int", "size":1 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"mucjid" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":64 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"mucaffiliation" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":32 },
|
2015-08-19 11:28:28 +02:00
|
|
|
"mucrole" :
|
2015-08-03 11:35:01 +02:00
|
|
|
{"type":"string", "size":32 }
|
|
|
|
}';
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class RosterContact extends Contact {
|
|
|
|
protected $rostername;
|
|
|
|
protected $groupname;
|
|
|
|
protected $status;
|
|
|
|
protected $resource;
|
|
|
|
protected $value;
|
|
|
|
protected $delay;
|
|
|
|
protected $chaton;
|
|
|
|
protected $last;
|
|
|
|
protected $publickey;
|
|
|
|
protected $muc;
|
|
|
|
protected $rosterask;
|
|
|
|
protected $rostersubscription;
|
|
|
|
protected $node;
|
|
|
|
protected $ver;
|
|
|
|
protected $category;
|
|
|
|
//protected $type;
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
$this->_struct = "
|
|
|
|
{
|
2015-08-19 11:28:28 +02:00
|
|
|
'rostername' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'rosterask' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'rostersubscription' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':8 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'groupname' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'resource' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128, 'key':true },
|
2015-08-19 11:28:28 +02:00
|
|
|
'value' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'int', 'size':11, 'mandatory':true },
|
2015-08-19 11:28:28 +02:00
|
|
|
'chaton' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'int', 'size':11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'status' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'text'},
|
2015-08-19 11:28:28 +02:00
|
|
|
'node' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'ver' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':128 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'delay' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'date'},
|
2015-08-19 11:28:28 +02:00
|
|
|
'last' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'int', 'size':11 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'publickey' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'text'},
|
2015-08-19 11:28:28 +02:00
|
|
|
'muc' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'int', 'size':1 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'mucaffiliation' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':32 },
|
2015-08-19 11:28:28 +02:00
|
|
|
'mucrole' :
|
2015-08-03 11:35:01 +02:00
|
|
|
{'type':'string', 'size':32 }
|
|
|
|
}";
|
|
|
|
}
|
2015-08-19 11:28:28 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
// This method is only use on the connection
|
|
|
|
public function setPresence($p) {
|
|
|
|
$this->resource = $p->resource;
|
|
|
|
$this->value = $p->value;
|
|
|
|
$this->status = $p->status;
|
|
|
|
$this->delay = $p->delay;
|
|
|
|
$this->last = $p->last;
|
|
|
|
$this->publickey = $p->publickey;
|
|
|
|
$this->muc = $p->muc;
|
|
|
|
$this->mucaffiliation = $p->mucaffiliation;
|
|
|
|
$this->mucrole = $p->mucrole;
|
|
|
|
}
|
|
|
|
}
|