Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -0,0 +1,113 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class BlockUser implements ProtocolImplementationInterface
{
protected $from;
// the jid of the user to block
protected $accountjid;
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq from="%s" type="set" id="%s">
<block xmlns="urn:xmpp:blocking">
<item jid="%s"/>
</block>
</iq>',
$this->getFrom(),
XML::generateId(),
$this->getJabberID()
);
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $accountjid
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setFrom($from)
{
$this->from = (string) $from;
return $this;
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class BlockedUsers implements ProtocolImplementationInterface
{
/**
* {@inheritDoc}
*/
public function toString()
{
return '<iq type="get" id="' . XML::generateId() . '">'
. '<blocklist xmlns="urn:xmpp:blocking"/></iq>';
}
}

View File

@ -47,6 +47,8 @@ use Fabiang\Xmpp\EventListener\Stream\Authentication;
use Fabiang\Xmpp\EventListener\Stream\Bind;
use Fabiang\Xmpp\EventListener\Stream\Session;
use Fabiang\Xmpp\EventListener\Stream\Roster as RosterListener;
use Fabiang\Xmpp\EventListener\Stream\Register as RegisterListener;
use Fabiang\Xmpp\EventListener\Stream\BlockedUsers as BlockedUsersListener;
/**
* Default Protocol implementation.
@ -82,6 +84,8 @@ class DefaultImplementation implements ImplementationInterface
$this->registerListener(new Bind);
$this->registerListener(new Session);
$this->registerListener(new RosterListener);
$this->registerListener(new RegisterListener);
$this->registerListener(new BlockedUsersListener);
}
/**

View File

@ -132,6 +132,13 @@ class Presence implements ProtocolImplementationInterface
*/
protected $nickname;
/**
* Channel password.
*
* @var string
*/
protected $password;
/**
* Constructor.
*
@ -155,7 +162,14 @@ class Presence implements ProtocolImplementationInterface
$presence .= ' to="' . XML::quote($this->getTo()) . '/' . XML::quote($this->getNickname()) . '"';
}
return $presence . '><priority>' . $this->getPriority() . '</priority></presence>';
$presence .= '><priority>' . $this->getPriority() . '</priority>';
if (null !== $this->getPassword()) {
$presence .= "<x xmlns='http://jabber.org/protocol/muc'><password>" . $this->getPassword() . "</password></x>";
}
$presence .= '</presence>';
return $presence;
}
/**
@ -223,4 +237,26 @@ class Presence implements ProtocolImplementationInterface
$this->priority = (int) $priority;
return $this;
}
/**
* Get channel password.
*
* @return string¦null
*/
public function getPassword()
{
return $this->password;
}
/**
* Set channel password.
*
* @param string|null $to
* @return $this
*/
public function setPassword($password = null)
{
$this->password = $password;
return $this;
}
}

View File

@ -0,0 +1,196 @@
<?php
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class Register implements ProtocolImplementationInterface
{
protected $to;
protected $from;
protected $step;
protected $accountjid;
protected $password;
protected $sid;
/**
* Constructor.
*
* @param integer $priority
* @param string $to
* @param string $nickname
*/
public function __construct($to = null, $from = null, $step = 'one')
{
$this->setTo($to);
$this->setFrom($from);
$this->setStep($step);
}
/**
* {@inheritDoc}
*/
public function toString()
{
$req ='';
if($this->step == 'one')
{
$req = XML::quoteMessage(
"<iq from='%s' id='%s' to='%s' type='set' xml:lang='en'>
<command xmlns='http://jabber.org/protocol/commands' action='execute' node='http://jabber.org/protocol/admin#add-user'/>
</iq>",
$this->getFrom(),
XML::generateId(),
$this->getTo()
);
}
else
{
$req = XML::quoteMessage(
"<iq from='%s' id='%s' to='%s' type='set' xml:lang='en'>
<command xmlns='http://jabber.org/protocol/commands' node='http://jabber.org/protocol/admin#add-user' sessionid='%s'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>http://jabber.org/protocol/admin</value>
</field>
<field var='accountjid'>
<value>%s</value>
</field>
<field var='password'>
<value>%s</value>
</field>
<field var='password-verify'>
<value>%s</value>
</field>
</x>
</command>
</iq>",
$this->getFrom(),
XML::generateId(),
$this->getTo(),
$this->getSID(),
$this->getJabberID(),
$this->getPassword(),
$this->getPassword()
);
}
return $req;
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getTo()
{
return $this->to;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setTo($to)
{
$this->to = (string) $to;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setPassword($password)
{
$this->password = (string) $password;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getFrom()
{
return $this->from;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setFrom($from)
{
$this->from = (string) $from;
return $this;
}
public function setStep($step)
{
$this->step = (string) $step;
return $this;
}
public function setSID($sid)
{
$this->sid = (string) $sid;
return $this;
}
public function getSID()
{
return $this->sid;
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Copyright 2014 Fabian Grutschus. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of the copyright holders.
*
* @author Fabian Grutschus <f.grutschus@lubyte.de>
* @copyright 2014 Fabian Grutschus. All rights reserved.
* @license BSD
* @link http://github.com/fabiang/xmpp
*/
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class UnblockUser implements ProtocolImplementationInterface
{
// the jid of the user to block
protected $accountjid;
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq type="set" id="%s">
<unblock xmlns="urn:xmpp:blocking">
<item jid="%s"/>
</unblock>
</iq>',
XML::generateId(),
$this->getJabberID()
);
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->accountjid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($accountjid)
{
$this->accountjid = (string) $accountjid;
return $this;
}
}

View File

@ -66,7 +66,7 @@ class User
*
* @var array
*/
protected $groups = array();
protected $groups = [];
public function getName()
{

View File

@ -0,0 +1,228 @@
<?php
namespace Fabiang\Xmpp\Protocol;
use Fabiang\Xmpp\Util\XML;
/**
* Protocol setting for Xmpp.
*
* @package Xmpp\Protocol
*/
class VCard implements ProtocolImplementationInterface
{
/**
* vCard to.
*
* @var string|null
*/
protected $to;
/**
* user firstname.
*
* @var string
*/
protected $firstname;
/**
* user lastname.
*
* @var string
*/
protected $lastname;
protected $jabberid;
protected $mime;
protected $image;
protected $ulr;
/**
* Constructor.
*
* @param integer $priority
* @param string $to
* @param string $nickname
*/
public function __construct($firstname = null, $lastname = null, $jabberid = null)
{
$this->setFirstname($firstname);
$this->setLastname($lastname);
$this->setJabberID($jabberid);
}
/**
* {@inheritDoc}
*/
public function toString()
{
return XML::quoteMessage(
'<iq id="' . XML::generateId() . '" type="set">
<vCard xmlns="vcard-temp">
<FN>%s</FN>
<N>
<FAMILY>%s</FAMILY>
<GIVEN>%s</GIVEN>
<MIDDLE/>
</N>
<NICKNAME>%s</NICKNAME>
<URL>%s</URL>
<PHOTO>
<TYPE>%s</TYPE>
<BINVAL>
%s
</BINVAL>
</PHOTO>
<JABBERID>%s</JABBERID>
<DESC/>
</vCard>
</iq>',
$this->getFirstname().' '.$this->getLastname(),
$this->getLastname(),
$this->getFirstname(),
$this->getFirstname().' '.$this->getLastname(),
$this->getUrl(),
$this->getMime(),
$this->getImage(),
$this->getJabberID()
);
}
/**
* Get nickname.
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set nickname.
*
* @param string $nickname
* @return $this
*/
public function setFirstname($firstname)
{
$this->firstname = (string) $firstname;
return $this;
}
/**
* Get nickname.
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Set nickname.
*
* @param string $nickname
* @return $this
*/
public function setLastname($lastname)
{
$this->lastname = (string) $lastname;
return $this;
}
/**
* Get JabberID.
*
* @return string
*/
public function getJabberID()
{
return $this->jabberid;
}
/**
* Set abberID.
*
* @param string $nickname
* @return $this
*/
public function setJabberID($jabberid)
{
$this->jabberid = (string) $jabberid;
return $this;
}
/**
* Get mime.
*
* @return string
*/
public function getMime()
{
return $this->mime;
}
/**
* Set mime.
*
* @param string $mime
* @return $this
*/
public function setMime($mime)
{
$this->mime = (string) $mime;
return $this;
}
/**
* Get image.
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set image.
*
* @param string $image base64
* @return $this
*/
public function setImage($image)
{
$this->image = (string) $image;
return $this;
}
/**
* Get url.
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set url.
*
* @param string $image base64
* @return $this
*/
public function setUrl($url)
{
$this->url = (string) $url;
return $this;
}
}