[COMPOSER] update

This commit is contained in:
Diogo Cordeiro 2019-11-16 16:51:01 +00:00
parent 51b5b1c08c
commit f09e3362aa
51 changed files with 1335 additions and 1050 deletions

View File

@ -6,6 +6,7 @@
"require": {
"php": "^7.3.0",
"ext-bcmath": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-dom": "*",
"ext-gd": "*",
@ -16,7 +17,6 @@
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"ext-ctype": "*",
"apereo/phpcas": "^1.3",
"diogocomposer/xmpphp": "^3.0",
"embed/embed": "^3.4",

559
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ if (!defined('E_USER_DEPRECATED')) {
/**
* phpCAS version. accessible for the user by phpCAS::getVersion().
*/
define('PHPCAS_VERSION', '1.3.7');
define('PHPCAS_VERSION', '1.3.8');
/**
* @addtogroup public

View File

@ -997,7 +997,18 @@ class CAS_Client
// set to callback mode if PgtIou and PgtId CGI GET parameters are provided
if ( $this->isProxy() ) {
$this->_setCallbackMode(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId']));
if(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId'])) {
$this->_setCallbackMode(true);
$this->_setCallbackModeUsingPost(false);
} elseif (!empty($_POST['pgtIou'])&&!empty($_POST['pgtId'])) {
$this->_setCallbackMode(true);
$this->_setCallbackModeUsingPost(true);
} else {
$this->_setCallbackMode(false);
$this->_setCallbackModeUsingPost(false);
}
}
if ( $this->_isCallbackMode() ) {
@ -2329,6 +2340,36 @@ class CAS_Client
return $this->_callback_mode;
}
/**
* @var bool a boolean to know if the CAS client is using POST parameters when in callback mode.
* Written by CAS_Client::_setCallbackModeUsingPost(), read by CAS_Client::_isCallbackModeUsingPost().
*
* @hideinitializer
*/
private $_callback_mode_using_post = false;
/**
* This method sets/unsets usage of POST parameters in callback mode (default/false is GET parameters)
*
* @param bool $callback_mode_using_post true to use POST, false to use GET (default).
*
* @return void
*/
private function _setCallbackModeUsingPost($callback_mode_using_post)
{
$this->_callback_mode_using_post = $callback_mode_using_post;
}
/**
* This method returns true when the callback mode is using POST, false otherwise.
*
* @return bool A boolean.
*/
private function _isCallbackModeUsingPost()
{
return $this->_callback_mode_using_post;
}
/**
* the URL that should be used for the PGT callback (in fact the URL of the
* current request without any CGI parameter). Written and read by
@ -2387,23 +2428,39 @@ class CAS_Client
private function _callback()
{
phpCAS::traceBegin();
if (preg_match('/^PGTIOU-[\.\-\w]+$/', $_GET['pgtIou'])) {
if (preg_match('/^[PT]GT-[\.\-\w]+$/', $_GET['pgtId'])) {
$this->printHTMLHeader('phpCAS callback');
$pgt_iou = $_GET['pgtIou'];
$pgt = $_GET['pgtId'];
phpCAS::trace('Storing PGT `'.$pgt.'\' (id=`'.$pgt_iou.'\')');
echo '<p>Storing PGT `'.$pgt.'\' (id=`'.$pgt_iou.'\').</p>';
$this->_storePGT($pgt, $pgt_iou);
$this->printHTMLFooter();
if ($this->_isCallbackModeUsingPost()) {
$pgtId = $_POST['pgtId'];
$pgtIou = $_POST['pgtIou'];
} else {
$pgtId = $_GET['pgtId'];
$pgtIou = $_GET['pgtIou'];
}
if (preg_match('/^PGTIOU-[\.\-\w]+$/', $pgtIou)) {
if (preg_match('/^[PT]GT-[\.\-\w]+$/', $pgtId)) {
phpCAS::trace('Storing PGT `'.$pgtId.'\' (id=`'.$pgtIou.'\')');
$this->_storePGT($pgtId, $pgtIou);
if (array_key_exists('HTTP_ACCEPT', $_SERVER) &&
( $_SERVER['HTTP_ACCEPT'] == 'application/xml' ||
$_SERVER['HTTP_ACCEPT'] == 'text/xml'
)
) {
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n";
echo '<proxySuccess xmlns="http://www.yale.edu/tp/cas" />';
phpCAS::traceExit("XML response sent");
} else {
$this->printHTMLHeader('phpCAS callback');
echo '<p>Storing PGT `'.$pgtId.'\' (id=`'.$pgtIou.'\').</p>';
$this->printHTMLFooter();
phpCAS::traceExit("HTML response sent");
}
phpCAS::traceExit("Successfull Callback");
} else {
phpCAS::error('PGT format invalid' . $_GET['pgtId']);
phpCAS::traceExit('PGT format invalid' . $_GET['pgtId']);
phpCAS::error('PGT format invalid' . $pgtId);
phpCAS::traceExit('PGT format invalid' . $pgtId);
}
} else {
phpCAS::error('PGTiou format invalid' . $_GET['pgtIou']);
phpCAS::traceExit('PGTiou format invalid' . $_GET['pgtIou']);
phpCAS::error('PGTiou format invalid' . $pgtIou);
phpCAS::traceExit('PGTiou format invalid' . $pgtIou);
}
// Flush the buffer to prevent from sending anything other then a 200

View File

@ -1,21 +1,56 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Composer
Upstream-Contact: Jordi Boggiano <j.boggiano@seld.be>
Source: https://github.com/composer/composer
Copyright (c) Nils Adermann, Jordi Boggiano
Files: *
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
Files: src/Composer/Util/TlsHelper.php
Copyright: 2016, Nils Adermann <naderman@naderman.de>
2016, Jordi Boggiano <j.boggiano@seld.be>
2013, Evan Coury <me@evancoury.com>
License: Expat and BSD-2-Clause
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
License: BSD-2-Clause
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
.
* 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.
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -171,6 +171,7 @@ return array(
'Embed\\Adapters\\Sassmeister' => $vendorDir . '/embed/embed/src/Adapters/Sassmeister.php',
'Embed\\Adapters\\Slides' => $vendorDir . '/embed/embed/src/Adapters/Slides.php',
'Embed\\Adapters\\Snipplr' => $vendorDir . '/embed/embed/src/Adapters/Snipplr.php',
'Embed\\Adapters\\Vimeo' => $vendorDir . '/embed/embed/src/Adapters/Vimeo.php',
'Embed\\Adapters\\Webpage' => $vendorDir . '/embed/embed/src/Adapters/Webpage.php',
'Embed\\Adapters\\Wikipedia' => $vendorDir . '/embed/embed/src/Adapters/Wikipedia.php',
'Embed\\Adapters\\Youtube' => $vendorDir . '/embed/embed/src/Adapters/Youtube.php',
@ -229,6 +230,7 @@ return array(
'Embed\\Providers\\OEmbed\\Twitch' => $vendorDir . '/embed/embed/src/Providers/OEmbed/Twitch.php',
'Embed\\Providers\\OEmbed\\Twitter' => $vendorDir . '/embed/embed/src/Providers/OEmbed/Twitter.php',
'Embed\\Providers\\OEmbed\\Ustream' => $vendorDir . '/embed/embed/src/Providers/OEmbed/Ustream.php',
'Embed\\Providers\\OEmbed\\Vimeo' => $vendorDir . '/embed/embed/src/Providers/OEmbed/Vimeo.php',
'Embed\\Providers\\OEmbed\\WordPress' => $vendorDir . '/embed/embed/src/Providers/OEmbed/WordPress.php',
'Embed\\Providers\\OEmbed\\Youtube' => $vendorDir . '/embed/embed/src/Providers/OEmbed/Youtube.php',
'Embed\\Providers\\OpenGraph' => $vendorDir . '/embed/embed/src/Providers/OpenGraph.php',
@ -603,7 +605,7 @@ return array(
'Intervention\\Image\\ImageManagerStatic' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageManagerStatic.php',
'Intervention\\Image\\ImageServiceProvider' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProvider.php',
'Intervention\\Image\\ImageServiceProviderLaravel4' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php',
'Intervention\\Image\\ImageServiceProviderLaravel5' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php',
'Intervention\\Image\\ImageServiceProviderLaravelRecent' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravelRecent.php',
'Intervention\\Image\\ImageServiceProviderLeague' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php',
'Intervention\\Image\\ImageServiceProviderLumen' => $vendorDir . '/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php',
'Intervention\\Image\\Imagick\\Color' => $vendorDir . '/intervention/image/src/Intervention/Image/Imagick/Color.php',

View File

@ -310,6 +310,7 @@ class ComposerStaticInit444c3f31864f68a3f466e2c19837e185
'Embed\\Adapters\\Sassmeister' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Sassmeister.php',
'Embed\\Adapters\\Slides' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Slides.php',
'Embed\\Adapters\\Snipplr' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Snipplr.php',
'Embed\\Adapters\\Vimeo' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Vimeo.php',
'Embed\\Adapters\\Webpage' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Webpage.php',
'Embed\\Adapters\\Wikipedia' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Wikipedia.php',
'Embed\\Adapters\\Youtube' => __DIR__ . '/..' . '/embed/embed/src/Adapters/Youtube.php',
@ -368,6 +369,7 @@ class ComposerStaticInit444c3f31864f68a3f466e2c19837e185
'Embed\\Providers\\OEmbed\\Twitch' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/Twitch.php',
'Embed\\Providers\\OEmbed\\Twitter' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/Twitter.php',
'Embed\\Providers\\OEmbed\\Ustream' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/Ustream.php',
'Embed\\Providers\\OEmbed\\Vimeo' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/Vimeo.php',
'Embed\\Providers\\OEmbed\\WordPress' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/WordPress.php',
'Embed\\Providers\\OEmbed\\Youtube' => __DIR__ . '/..' . '/embed/embed/src/Providers/OEmbed/Youtube.php',
'Embed\\Providers\\OpenGraph' => __DIR__ . '/..' . '/embed/embed/src/Providers/OpenGraph.php',
@ -742,7 +744,7 @@ class ComposerStaticInit444c3f31864f68a3f466e2c19837e185
'Intervention\\Image\\ImageManagerStatic' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageManagerStatic.php',
'Intervention\\Image\\ImageServiceProvider' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProvider.php',
'Intervention\\Image\\ImageServiceProviderLaravel4' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel4.php',
'Intervention\\Image\\ImageServiceProviderLaravel5' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravel5.php',
'Intervention\\Image\\ImageServiceProviderLaravelRecent' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLaravelRecent.php',
'Intervention\\Image\\ImageServiceProviderLeague' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLeague.php',
'Intervention\\Image\\ImageServiceProviderLumen' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/ImageServiceProviderLumen.php',
'Intervention\\Image\\Imagick\\Color' => __DIR__ . '/..' . '/intervention/image/src/Intervention/Image/Imagick/Color.php',

View File

@ -27,22 +27,22 @@ Requirements
Basic usage
-----------
# `Composer\CaBundle\CaBundle`
### `Composer\CaBundle\CaBundle`
- `CaBundle::getSystemCaRootBundlePath()`: Returns the system CA bundle path, or a path to the bundled one as fallback
- `CaBundle::getBundledCaBundlePath()`: Returns the path to the bundled CA file
- `CaBundle::validateCaFile($filename)`: Validates a CA file using opensl_x509_parse only if it is safe to use
- `CaBundle::validateCaFile($filename)`: Validates a CA file using openssl_x509_parse only if it is safe to use
- `CaBundle::isOpensslParseSafe()`: Test if it is safe to use the PHP function openssl_x509_parse()
- `CaBundle::reset()`: Resets the static caches
## To use with curl
#### To use with curl
```php
$curl = curl_init("https://example.org/");
$caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) {
if (is_dir($caPathOrFile)) {
curl_setopt($curl, CURLOPT_CAPATH, $caPathOrFile);
} else {
curl_setopt($curl, CURLOPT_CAINFO, $caPathOrFile);
@ -51,7 +51,7 @@ if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathO
$result = curl_exec($curl);
```
## To use with php streams
#### To use with php streams
```php
$opts = array(
@ -61,7 +61,7 @@ $opts = array(
);
$caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) {
if (is_dir($caPathOrFile)) {
$opts['ssl']['capath'] = $caPathOrFile;
} else {
$opts['ssl']['cafile'] = $caPathOrFile;
@ -71,7 +71,7 @@ $context = stream_context_create($opts);
$result = file_get_contents('https://example.com', false, $context);
```
## To use with Guzzle
#### To use with Guzzle
```php
$client = new \GuzzleHttp\Client([

View File

@ -24,10 +24,10 @@
"require": {
"ext-openssl": "*",
"ext-pcre": "*",
"php": "^5.3.2 || ^7.0"
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5",
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0"
},

View File

@ -1,7 +1,7 @@
##
## Bundle of CA Root Certificates
##
## Certificate data from Mozilla as of: Wed Jan 23 04:12:09 2019 GMT
## Certificate data from Mozilla as of: Wed Aug 28 03:12:10 2019 GMT
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
@ -14,7 +14,7 @@
## Just configure this file as the SSLCACertificateFile.
##
## Conversion done with mk-ca-bundle.pl version 1.27.
## SHA256: 18372117493b5b7ec006c31d966143fc95a9464a2b5f8d5188e23c5557b2292d
## SHA256: fffa309937c3be940649293f749b8207fabc6eb224e50e4bb3f2c5e44e0d6a6b
##
@ -2613,37 +2613,6 @@ kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
-----END CERTIFICATE-----
Certinomis - Root CA
====================
-----BEGIN CERTIFICATE-----
MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjETMBEGA1UEChMK
Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAbBgNVBAMTFENlcnRpbm9taXMg
LSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMzMTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIx
EzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRD
ZXJ0aW5vbWlzIC0gUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQos
P5L2fxSeC5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SD7J6wWAsOMwaplv/8gzjqh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJ
y29SWwNyhlCVCNSNh4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9
Iff/ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8Vbtaw5Bng
DwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwjY/M50n92Uaf0yKHxDHYi
I0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nM
cyrDflOR1m749fPH0FFNjkulW+YZFzvWgQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVr
hkIGuUE=
-----END CERTIFICATE-----
OISTE WISeKey Global Root GB CA
===============================
-----BEGIN CERTIFICATE-----
@ -3399,3 +3368,109 @@ tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
-----END CERTIFICATE-----
emSign Root CA - G1
===================
-----BEGIN CERTIFICATE-----
MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUw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+bs7Lo3I6LWld
y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
+BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
dBb9HxEGmpv0
-----END CERTIFICATE-----

View File

@ -66,32 +66,21 @@ class CaBundle
if (self::$caPath !== null) {
return self::$caPath;
}
$caBundlePaths = array();
// If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertFile = getenv('SSL_CERT_FILE');
if ($envCertFile && is_readable($envCertFile) && static::validateCaFile($envCertFile, $logger)) {
return self::$caPath = $envCertFile;
}
$caBundlePaths[] = getenv('SSL_CERT_FILE');
// If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertDir = getenv('SSL_CERT_DIR');
if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) {
return self::$caPath = $envCertDir;
}
$caBundlePaths[] = getenv('SSL_CERT_DIR');
$configured = ini_get('openssl.cafile');
if ($configured && strlen($configured) > 0 && is_readable($configured) && static::validateCaFile($configured, $logger)) {
return self::$caPath = $configured;
}
$caBundlePaths[] = ini_get('openssl.cafile');
$caBundlePaths[] = ini_get('openssl.capath');
$configured = ini_get('openssl.capath');
if ($configured && is_dir($configured) && is_readable($configured)) {
return self::$caPath = $configured;
}
$caBundlePaths = array(
$otherLocations = array(
'/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package)
'/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package)
'/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package)
@ -105,15 +94,18 @@ class CaBundle
'/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package
);
foreach ($caBundlePaths as $caBundle) {
if (@is_readable($caBundle) && static::validateCaFile($caBundle, $logger)) {
return self::$caPath = $caBundle;
}
foreach($otherLocations as $location) {
$otherLocations[] = dirname($location);
}
$caBundlePaths = array_merge($caBundlePaths, $otherLocations);
foreach ($caBundlePaths as $caBundle) {
$caBundle = dirname($caBundle);
if (@is_dir($caBundle) && glob($caBundle.'/*')) {
if (self::caFileUsable($caBundle, $logger)) {
return self::$caPath = $caBundle;
}
if (self::caDirUsable($caBundle)) {
return self::$caPath = $caBundle;
}
}
@ -305,4 +297,14 @@ EOT;
self::$caPath = null;
self::$useOpensslParse = null;
}
private static function caFileUsable($certFile, LoggerInterface $logger = null)
{
return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
}
private static function caDirUsable($certDir)
{
return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
}
}

View File

@ -1,17 +1,17 @@
[
{
"name": "apereo/phpcas",
"version": "1.3.7",
"version_normalized": "1.3.7.0",
"version": "1.3.8",
"version_normalized": "1.3.8.0",
"source": {
"type": "git",
"url": "https://github.com/apereo/phpCAS.git",
"reference": "b5b29102c3a42f570c4a3e852f3cf67cae6d6082"
"reference": "40c0769ce05a30c8172b36ceab11124375c8366e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/apereo/phpCAS/zipball/b5b29102c3a42f570c4a3e852f3cf67cae6d6082",
"reference": "b5b29102c3a42f570c4a3e852f3cf67cae6d6082",
"url": "https://api.github.com/repos/apereo/phpCAS/zipball/40c0769ce05a30c8172b36ceab11124375c8366e",
"reference": "40c0769ce05a30c8172b36ceab11124375c8366e",
"shasum": ""
},
"require": {
@ -21,7 +21,7 @@
"require-dev": {
"phpunit/phpunit": "~3.7.10"
},
"time": "2019-04-22T19:48:16+00:00",
"time": "2019-08-18T20:01:55+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -58,30 +58,30 @@
},
{
"name": "composer/ca-bundle",
"version": "1.1.4",
"version_normalized": "1.1.4.0",
"version": "1.2.4",
"version_normalized": "1.2.4.0",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d"
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/558f321c52faeb4828c03e7dc0cfe39a09e09a2d",
"reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"shasum": ""
},
"require": {
"ext-openssl": "*",
"ext-pcre": "*",
"php": "^5.3.2 || ^7.0"
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5",
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0"
},
"time": "2019-01-28T09:30:10+00:00",
"time": "2019-08-30T08:44:50+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -116,25 +116,29 @@
},
{
"name": "diogocomposer/xmpphp",
"version": "v3.0.0",
"version_normalized": "3.0.0.0",
"version": "v3.0.2",
"version_normalized": "3.0.2.0",
"source": {
"type": "git",
"url": "https://github.com/diogogithub/xmpphp.git",
"reference": "c7cdcc588aa47893ab41a1670c5dfe649674a4b0"
"reference": "d95381f8fb5ffbbda0894aea415742daaa2eab22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/diogogithub/xmpphp/zipball/c7cdcc588aa47893ab41a1670c5dfe649674a4b0",
"reference": "c7cdcc588aa47893ab41a1670c5dfe649674a4b0",
"url": "https://api.github.com/repos/diogogithub/xmpphp/zipball/d95381f8fb5ffbbda0894aea415742daaa2eab22",
"reference": "d95381f8fb5ffbbda0894aea415742daaa2eab22",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-dom": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"php": ">=7.0.0"
"php": "^7.3.0"
},
"time": "2019-06-19T02:32:32+00:00",
"time": "2019-11-03T00:18:51+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -147,6 +151,22 @@
"GPL-2.0+"
],
"authors": [
{
"name": "Nathan Fritz",
"email": "fritzy@netflint.net"
},
{
"name": "Stephan Wentz",
"email": "stephan@wentz.it"
},
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de"
},
{
"name": "Vito Tafuni",
"email": "vitotafuni@gmail.com"
},
{
"name": "Ivan Borzenkov",
"email": "ivan.borzenkov@gmail.com"
@ -159,22 +179,6 @@
"name": "BirknerAlex",
"email": "alex.birkner@gmail.com"
},
{
"name": "Stephan Wentz",
"email": "stephan@wentz.it"
},
{
"name": "Nathan Fritz",
"email": "fritzy@netflint.net"
},
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de"
},
{
"name": "Vito Tafuni",
"email": "vitotafuni@gmail.com"
},
{
"name": "Diogo Cordeiro",
"email": "diogo@fc.up.pt"
@ -189,17 +193,17 @@
},
{
"name": "embed/embed",
"version": "v3.4.1",
"version_normalized": "3.4.1.0",
"version": "v3.4.2",
"version_normalized": "3.4.2.0",
"source": {
"type": "git",
"url": "https://github.com/oscarotero/Embed.git",
"reference": "960bbd5a62c5697302bd5394d58efba2e998b787"
"reference": "dc1dc3c126f8a78acdae06b83f591c0728ea131d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/oscarotero/Embed/zipball/960bbd5a62c5697302bd5394d58efba2e998b787",
"reference": "960bbd5a62c5697302bd5394d58efba2e998b787",
"url": "https://api.github.com/repos/oscarotero/Embed/zipball/dc1dc3c126f8a78acdae06b83f591c0728ea131d",
"reference": "dc1dc3c126f8a78acdae06b83f591c0728ea131d",
"shasum": ""
},
"require": {
@ -212,7 +216,7 @@
"friendsofphp/php-cs-fixer": "^2.0",
"phpunit/phpunit": "^4.8|^5.7"
},
"time": "2019-07-20T17:05:41+00:00",
"time": "2019-09-16T19:34:02+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -227,9 +231,9 @@
"authors": [
{
"name": "Oscar Otero",
"role": "Developer",
"email": "oom@oscarotero.com",
"homepage": "http://oscarotero.com"
"homepage": "http://oscarotero.com",
"role": "Developer"
}
],
"description": "PHP library to retrieve page info using oembed, opengraph, etc",
@ -244,17 +248,17 @@
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.11.0",
"version_normalized": "4.11.0.0",
"version": "v4.12.0",
"version_normalized": "4.12.0.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7"
"reference": "a617e55bc62a87eec73bd456d146d134ad716f03"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7",
"reference": "83ab08bc1af7d808a9e0fbf024f1c24bfd73c0a7",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/a617e55bc62a87eec73bd456d146d134ad716f03",
"reference": "a617e55bc62a87eec73bd456d146d134ad716f03",
"shasum": ""
},
"require": {
@ -263,7 +267,7 @@
"require-dev": {
"simpletest/simpletest": "dev-master#72de02a7b80c6bb8864ef9bf66d41d2f58f826bd"
},
"time": "2019-07-14T18:58:38+00:00",
"time": "2019-10-28T03:44:26+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -545,17 +549,17 @@
},
{
"name": "intervention/image",
"version": "2.5.0",
"version_normalized": "2.5.0.0",
"version": "2.5.1",
"version_normalized": "2.5.1.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "39eaef720d082ecc54c64bf54541c55f10db546d"
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/39eaef720d082ecc54c64bf54541c55f10db546d",
"reference": "39eaef720d082ecc54c64bf54541c55f10db546d",
"url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
"shasum": ""
},
"require": {
@ -572,7 +576,7 @@
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"time": "2019-06-24T14:06:31+00:00",
"time": "2019-11-02T09:15:47+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -617,17 +621,17 @@
},
{
"name": "masterminds/html5",
"version": "2.6.0",
"version_normalized": "2.6.0.0",
"version": "2.7.0",
"version_normalized": "2.7.0.0",
"source": {
"type": "git",
"url": "https://github.com/Masterminds/html5-php.git",
"reference": "c961ca6a0a81dc6b55b6859b3f9ea7f402edf9ad"
"reference": "104443ad663d15981225f99532ba73c2f1d6b6f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/c961ca6a0a81dc6b55b6859b3f9ea7f402edf9ad",
"reference": "c961ca6a0a81dc6b55b6859b3f9ea7f402edf9ad",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/104443ad663d15981225f99532ba73c2f1d6b6f2",
"reference": "104443ad663d15981225f99532ba73c2f1d6b6f2",
"shasum": ""
},
"require": {
@ -641,11 +645,11 @@
"sami/sami": "~2.0",
"satooshi/php-coveralls": "1.0.*"
},
"time": "2019-03-10T11:41:28+00:00",
"time": "2019-07-25T07:03:26+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
"dev-master": "2.7-dev"
}
},
"installation-source": "dist",
@ -663,13 +667,13 @@
"name": "Matt Butcher",
"email": "technosophos@gmail.com"
},
{
"name": "Asmir Mustafic",
"email": "goetas@gmail.com"
},
{
"name": "Matt Farina",
"email": "matt@mattfarina.com"
},
{
"name": "Asmir Mustafic",
"email": "goetas@gmail.com"
}
],
"description": "An HTML5 parser and serializer.",
@ -1250,17 +1254,17 @@
},
{
"name": "stomp-php/stomp-php",
"version": "4.5.1",
"version_normalized": "4.5.1.0",
"version": "4.5.2",
"version_normalized": "4.5.2.0",
"source": {
"type": "git",
"url": "https://github.com/stomp-php/stomp-php.git",
"reference": "4c5f0a95330085a86fd852b8ad0b1fbb4e8a4158"
"reference": "9238e4ddb1e7a5ddd673d090be52bdf9d7f225be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/stomp-php/stomp-php/zipball/4c5f0a95330085a86fd852b8ad0b1fbb4e8a4158",
"reference": "4c5f0a95330085a86fd852b8ad0b1fbb4e8a4158",
"url": "https://api.github.com/repos/stomp-php/stomp-php/zipball/9238e4ddb1e7a5ddd673d090be52bdf9d7f225be",
"reference": "9238e4ddb1e7a5ddd673d090be52bdf9d7f225be",
"shasum": ""
},
"require": {
@ -1269,7 +1273,7 @@
"require-dev": {
"phpunit/phpunit": "^5.7"
},
"time": "2019-04-09T08:25:54+00:00",
"time": "2019-07-26T16:38:20+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {

View File

@ -16,5 +16,5 @@ XMPPHP is an elegant PHP library for XMPP (aka Jabber, Google Talk, etc).
Requirements
------------
* PHP 7.0
* PHP 7.3 or later
* SSL Support Compiled

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz
@ -35,7 +34,7 @@ namespace XMPPHP;
use SimpleXMLElement;
/** XMPPHP_XMLStream */
require_once __DIR__ . "/XMPP.php";
require_once __DIR__ . DIRECTORY_SEPARATOR . 'XMPP.php';
/**
* XMPPHP BOSH
@ -51,7 +50,7 @@ require_once __DIR__ . "/XMPP.php";
class BOSH extends XMPP
{
/**
* @var integer
* @var int
*/
protected $rid;
@ -68,7 +67,7 @@ class BOSH extends XMPP
/**
* @var array
*/
protected $http_buffer = array();
protected $http_buffer = [];
/**
* @var string
@ -76,50 +75,58 @@ class BOSH extends XMPP
protected $session = false;
/**
* @var integer
* @var int
*/
protected $inactivity;
/**
* Connect
*
* @param $server
* @param $wait
* @param $session
* @throws Exception
* @throws Exception
*/
public function connect($server = null, $wait = '1', $session = false)
{
public function __construct(
string $host,
int $port,
string $user,
string $password,
string $resource,
?string $server = null,
bool $print_log = false,
?string $log_level = null
) {
parent::__construct($host, $port, $user, $password, $resource, $server, $print_log, $log_level);
if (is_null($server)) {
// If we aren't given the server http url, try and guess it
$port_string = ($this->port AND $this->port != 80) ? ':' . $this->port : '';
$port_string = ($this->port and $this->port != 80) ? ':' . $this->port : '';
$this->http_server = 'http://' . $this->host . $port_string . '/http-bind/';
} else {
$this->http_server = $server;
}
}
/**
* Connect
*
* @param bool $persistent
* @param bool $send_init
* @param int $timeout
* @throws Exception
*/
public function connect(bool $persistent = false, bool $send_init = true, int $timeout = 30): void
{
$this->use_encryption = false;
$this->session = $session;
$this->session = $persistent;
$this->rid = 3001;
$this->sid = null;
$this->inactivity = 0;
if ($session) {
if ($persistent) {
$this->loadSession();
}
if (!$this->sid) {
$body = $this->__buildBody();
$body->addAttribute('hold', '1');
$body->addAttribute('to', $this->server);
$body->addAttribute('route', 'xmpp:' . $this->host . ':' . $this->port);
$body->addAttribute('secure', 'true');
$body->addAttribute('xmpp:version', '1.0', 'urn:xmpp:xbosh');
$body->addAttribute('wait', strval($wait));
$body->addAttribute('wait', strval($timeout));
$body->addAttribute('ack', '1');
$body->addAttribute('xmlns:xmpp', 'urn:xmpp:xbosh');
$buff = '<stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">';
@ -138,11 +145,9 @@ class BOSH extends XMPP
* Load session
*
*/
public function loadSession()
public function loadSession(): void
{
if ($this->session == 'ON_FILE') {
// Session not started so use session_file
$session_file = $this->getSessionFile();
@ -169,7 +174,6 @@ class BOSH extends XMPP
$this->lat = (time() - (isset($_SESSION['XMPPHP_BOSH']['lat']))) ? $_SESSION['XMPPHP_BOSH']['lat'] : 0;
if ($this->lat < $this->inactivity) {
if (isset($_SESSION['XMPPHP_BOSH']['RID'])) {
$this->rid = $_SESSION['XMPPHP_BOSH']['RID'];
}
@ -189,10 +193,10 @@ class BOSH extends XMPP
}
/**
* Get the session file
* Get the session file location
*
*/
public function getSessionFile()
public function getSessionFile(): string
{
return sys_get_temp_dir() . '/' . $this->user . '_' . $this->server . '_session';
}
@ -200,17 +204,15 @@ class BOSH extends XMPP
/**
* Build body
*
* @param $sub
* @return SimpleXMLElement|string
* @param SimpleXMLElement|null $sub
* @return SimpleXMLElement
*/
public function __buildBody($sub = null)
private function __buildBody(?SimpleXMLElement $sub = null): SimpleXMLElement
{
$xml = '<body xmlns="http://jabber.org/protocol/httpbind" xmlns:xmpp="urn:xmpp:xbosh" />';
$xml = new SimpleXMLElement($xml);
$xml = new SimpleXMLElement('<body xmlns="http://jabber.org/protocol/httpbind" xmlns:xmpp="urn:xmpp:xbosh" />');
$xml->addAttribute('content', 'text/xml; charset=utf-8');
$xml->addAttribute('rid', $this->rid);
$this->rid++;
++$this->rid;
if ($this->sid) {
$xml->addAttribute('sid', $this->sid);
}
@ -218,7 +220,6 @@ class BOSH extends XMPP
$xml->addAttribute('xml:lang', 'en');
if ($sub !== null) {
// Ok, so simplexml is lame
$parent = dom_import_simplexml($xml);
$content = dom_import_simplexml($sub);
@ -233,21 +234,19 @@ class BOSH extends XMPP
/**
* Send body
*
* @param $body
* @param $recv
* @param SimpleXMLElement|null $body
* @param bool $recv
* @return bool|string
* @throws Exception
* @throws Exception
*/
public function __sendBody($body = null, $recv = true)
private function __sendBody(?SimpleXMLElement $body = null, bool $recv = true)
{
if (!$body) {
$body = $this->__buildBody();
}
$output = '';
$header = array('Accept-Encoding: gzip, deflate', 'Content-Type: text/xml; charset=utf-8');
$header = ['Accept-Encoding: gzip, deflate', 'Content-Type: text/xml; charset=utf-8'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->http_server);
@ -283,9 +282,8 @@ class BOSH extends XMPP
* @throws Exception
* @throws Exception
*/
public function __process($null1 = null, $null2 = null)
private function __process($null1 = null, $null2 = null)
{
if ($this->http_buffer) {
$this->__parseBuffer();
} else {
@ -298,17 +296,14 @@ class BOSH extends XMPP
return true;
}
public function __parseBuffer()
private function __parseBuffer()
{
while ($this->http_buffer) {
$idx = key($this->http_buffer);
$buffer = $this->http_buffer[$idx];
unset($this->http_buffer[$idx]);
if ($buffer) {
$xml = new SimpleXMLElement($buffer);
$children = $xml->xpath('child::node()');
@ -325,9 +320,8 @@ class BOSH extends XMPP
* Save session
*
*/
public function saveSession()
public function saveSession(): void
{
$_SESSION['XMPPHP_BOSH']['RID'] = (string)$this->rid;
$_SESSION['XMPPHP_BOSH']['SID'] = (string)$this->sid;
$_SESSION['XMPPHP_BOSH']['authed'] = (boolean)$this->authed;
@ -337,7 +331,6 @@ class BOSH extends XMPP
$_SESSION['XMPPHP_BOSH']['lat'] = (string)time();
if ($this->session == 'ON_FILE') {
$session_file = $this->getSessionFile();
$session_file_fp = fopen($session_file, 'r');
flock($session_file_fp, LOCK_EX);
@ -353,13 +346,10 @@ class BOSH extends XMPP
* Process
*
* @param $msg
* @param $null
*
* null param are not used and just to statify Strict Function Declaration
* @throws Exception
* @param int|null $_ unused
* @throws Exception
*/
public function send($msg, $null = null)
public function send($msg, ?int $_ = null)
{
$this->log->log('SEND: ' . $msg, Log::LEVEL_VERBOSE);
$msg = new SimpleXMLElement($msg);
@ -371,18 +361,17 @@ class BOSH extends XMPP
*
* @throws Exception
*/
public function reset()
public function reset(): void
{
$this->xml_depth = 0;
unset($this->xmlobj);
$this->xmlobj = array();
$this->xmlobj = [];
$this->setupParser();
$body = $this->__buildBody();
$body->addAttribute('to', $this->host);
$body->addAttribute('xmpp:restart', 'true', 'urn:xmpp:xbosh');
$buff = '<stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">';
$response = $this->__sendBody($body);
$this->__sendBody($body);
$this->been_reset = true;
xml_parse($this->parser, $buff, false);
}
@ -392,15 +381,14 @@ class BOSH extends XMPP
*
* @throws Exception
*/
public function disconnect()
public function disconnect(): void
{
parent::disconnect();
if ($this->session == 'ON_FILE') {
unlink($this->getSessionFile());
} else {
$keys = array('RID', 'SID', 'authed', 'basejid', 'fulljid', 'inactivity', 'lat');
$keys = ['RID', 'SID', 'authed', 'basejid', 'fulljid', 'inactivity', 'lat'];
foreach ($keys as $key) {
unset($_SESSION['XMPPHP_BOSH'][$key]);
}

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz
@ -53,20 +52,20 @@ class Log
/**
* @var array
*/
protected $data = array();
protected $data = [];
/**
* @var array
*/
protected $names = array('ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE');
protected $names = ['ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE'];
/**
* @var integer
* @var int
*/
protected $runlevel;
/**
* @var boolean
* @var bool
*/
protected $printout;
@ -74,12 +73,12 @@ class Log
* Constructor
*
* @param boolean $printout
* @param int $runlevel
* @param int $runlevel (optional)
*/
public function __construct($printout = false, $runlevel = self::LEVEL_INFO)
public function __construct($printout = false, ?int $runlevel = self::LEVEL_INFO)
{
$this->printout = (boolean)$printout;
$this->runlevel = (int)$runlevel;
$this->printout = (bool) $printout;
$this->runlevel = (int) ($runlevel ?? 0);
}
/**
@ -87,18 +86,23 @@ class Log
* If printout in this instance is set to true, directly output the message
*
* @param string $msg
* @param integer $runlevel
* @param int $runlevel (optional)
*/
public function log($msg, $runlevel = self::LEVEL_INFO)
public function log($msg, $runlevel = self::LEVEL_INFO): void
{
$time = time();
#$this->data[] = array($this->runlevel, $msg, $time);
//$this->data[] = [$this->runlevel, $msg, $time];
if ($this->printout and $runlevel <= $this->runlevel) {
$this->writeLine($msg, $runlevel, $time);
}
}
protected function writeLine($msg, $runlevel, $time)
/**
* @param string $msg
* @param int $runlevel
* @param int $time
*/
protected function writeLine(string $msg, int $runlevel, int $time): void
{
//echo date('Y-m-d H:i:s', $time)." [".$this->names[$runlevel]."]: ".$msg."\n";
echo $time . " [" . $this->names[$runlevel] . "]: " . $msg . "\n";
@ -109,10 +113,10 @@ class Log
* Output the complete log.
* Log will be cleared if $clear = true
*
* @param boolean $clear
* @param integer $runlevel
* @param bool $clear
* @param int $runlevel
*/
public function printout($clear = true, $runlevel = null)
public function printout(bool $clear = true, int $runlevel = null): void
{
if ($runlevel === null) {
$runlevel = $this->runlevel;
@ -123,7 +127,7 @@ class Log
}
}
if ($clear) {
$this->data = array();
$this->data = [];
}
}
}

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz
@ -49,70 +48,67 @@ class Roster
* Contains array with potentially two indexes 'contact' and 'presence'
* @var array
*/
protected $roster_array = array();
protected $roster_array = [];
/**
* Constructor
* @param array $roster_array
*/
public function __construct($roster_array = array())
public function __construct($roster_array = [])
{
if ($this->verifyRoster($roster_array)) {
$this->roster_array = $roster_array; //Allow for pre-population with existing roster
} else {
$this->roster_array = array();
$this->roster_array = [];
}
}
/**
*
* Check that a given roster array is of a valid structure (empty is still valid)
*
* @param array $roster_array
* @return bool
* @return bool true for valid, false otherwise
*/
protected function verifyRoster($roster_array)
protected function verifyRoster(array $roster_array): bool
{
#TODO once we know *what* a valid roster array looks like
return true;
}
/**
*
* Retrieve contact via jid
*
* @param string $jid
* @return mixed
* @return mixed|void
*/
public function getContact($jid)
public function getContact(string $jid)
{
if ($this->isContact($jid)) {
return $this->roster_array[$jid]['contact'];
}
return;
}
/**
*
* Discover if a contact exists in the roster via jid
*
* @param string $jid
* @return bool
*/
public function isContact($jid)
public function isContact(string $jid): bool
{
return (array_key_exists($jid, $this->roster_array));
}
/**
*
* Set presence
*
* @param string $presence
* @param integer $priority
* @param int $priority
* @param string $show
* @param string $status
*/
public function setPresence($presence, $priority, $show, $status)
public function setPresence(string $presence, int $priority, string $show, string $status): void
{
$presence = explode('/', $presence, 2);
$jid = $presence[0];
@ -121,7 +117,7 @@ class Roster
if (!$this->isContact($jid)) {
$this->addContact($jid, 'not-in-roster');
}
$this->roster_array[$jid]['presence'][$resource] = array('priority' => $priority, 'show' => $show, 'status' => $status);
$this->roster_array[$jid]['presence'][$resource] = ['priority' => $priority, 'show' => $show, 'status' => $status];
} else { //Nuke unavailable resources to save memory
unset($this->roster_array[$jid]['resource'][$resource]);
unset($this->roster_array[$jid]['presence'][$resource]);
@ -129,54 +125,64 @@ class Roster
}
/**
*
* Add given contact to roster
*
* @param string $jid
* @param string $subscription
* @param string $name
* @param array $groups
* @param string $name (optional)
* @param array $groups (optional)
*/
public function addContact($jid, $subscription, $name = '', $groups = array())
public function addContact(string $jid, string $subscription, string $name = '', array $groups = []): void
{
$contact = array('jid' => $jid, 'subscription' => $subscription, 'name' => $name, 'groups' => $groups);
$contact = ['jid' => $jid, 'subscription' => $subscription, 'name' => $name, 'groups' => $groups];
if ($this->isContact($jid)) {
$this->roster_array[$jid]['contact'] = $contact;
} else {
$this->roster_array[$jid] = array('contact' => $contact);
$this->roster_array[$jid] = ['contact' => $contact];
}
}
/*
*
* Return best presence for jid
/**
* Get presence
*
* @param string $jid
* @return array best presence for jid
*/
public function getPresence($jid)
public function getPresence(string $jid): array
{
$split = explode('/', $jid, 2);
$jid = $split[0];
if ($this->isContact($jid)) {
$current = array('resource' => '', 'active' => '', 'priority' => -129, 'show' => '', 'status' => ''); //Priorities can only be -128 = 127
$current = [
'resource' => '',
'active' => '',
'priority' => -129, //Priorities can only be -128 = 127
'show' => '',
'status' => ''
];
foreach ($this->roster_array[$jid]['presence'] as $resource => $presence) {
//Highest available priority or just highest priority
if ($presence['priority'] > $current['priority'] and (($presence['show'] == "chat" or $presence['show'] == "available") or ($current['show'] != "chat" or $current['show'] != "available"))) {
if ($presence['priority'] > $current['priority'] and
(
($presence['show'] == "chat" or $presence['show'] == "available") or
($current['show'] != "chat" or $current['show'] != "available")
)
) {
$current = $presence;
$current['resource'] = $resource;
}
}
return $current;
}
return [];
}
/**
*
* Get roster
*
* @return array roster_array
*/
public function getRoster()
public function getRoster(): array
{
return $this->roster_array;
}

View File

@ -63,14 +63,14 @@ class XMLObj
*
* @var array
*/
public $attrs = array();
public $attrs = [];
/**
* Subs?
*
* @var array
*/
public $subs = array();
public $subs = [];
/**
* Node data
@ -83,11 +83,11 @@ class XMLObj
* Constructor
*
* @param string $name
* @param string $ns
* @param array $attrs
* @param string $data
* @param string $ns (optional)
* @param array $attrs (optional)
* @param string $data (optional)
*/
public function __construct($name, $ns = '', $attrs = array(), $data = '')
public function __construct(string $name, string $ns = '', array $attrs = [], string $data = '')
{
$this->name = strtolower($name);
$this->ns = $ns;
@ -102,9 +102,9 @@ class XMLObj
/**
* Dump this XML Object to output.
*
* @param integer $depth
* @param int $depth (optional)
*/
public function printObj($depth = 0)
public function printObj(int $depth = 0): void
{
print str_repeat("\t", $depth) . $this->name . " " . $this->ns . ' ' . $this->data;
print "\n";
@ -116,10 +116,10 @@ class XMLObj
/**
* Return this XML Object in xml notation
*
* @param string $str
* @param string $str (optional)
* @return string
*/
public function toString($str = '')
public function toString(string $str = ''): string
{
$str .= "<{$this->name} xmlns='{$this->ns}' ";
foreach ($this->attrs as $key => $value) {
@ -141,10 +141,10 @@ class XMLObj
* Has this XML Object the given sub?
*
* @param string $name
* @param null $ns
* @return boolean
* @param string|null $ns
* @return bool
*/
public function hasSub($name, $ns = null)
public function hasSub(string $name, ?string $ns = null): bool
{
foreach ($this->subs as $sub) {
if (($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) {
@ -158,11 +158,11 @@ class XMLObj
* Return a sub
*
* @param string $name
* @param string $attrs
* @param string $ns
* @param array|null $attrs (optional)
* @param string|null $ns (optional)
* @return mixed
*/
public function sub($name, $attrs = null, $ns = null)
public function sub(string $name, ?array $attrs = null, ?string $ns = null)
{
#TODO attrs is ignored
foreach ($this->subs as $sub) {
@ -170,5 +170,6 @@ class XMLObj
return $sub;
}
}
return null;
}
}

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz
@ -67,7 +66,7 @@ class XMLStream
*/
protected $buffer;
/**
* @var integer
* @var int
*/
protected $xml_depth = 0;
/**
@ -87,21 +86,21 @@ class XMLStream
*/
protected $stream_end = '</stream>';
/**
* @var boolean
* @var bool
*/
protected $disconnected = false;
/**
* @var boolean
* @var bool
*/
protected $sent_disconnect = false;
/**
* @var array
*/
protected $ns_map = array();
protected $ns_map = [];
/**
* @var array
*/
protected $current_ns = array();
protected $current_ns = [];
/**
* @var array
*/
@ -109,21 +108,21 @@ class XMLStream
/**
* @var array
*/
protected $nshandlers = array();
protected $nshandlers = [];
/**
* @var array
*/
protected $xpathhandlers = array();
protected $xpathhandlers = [];
/**
* @var array
*/
protected $idhandlers = array();
protected $idhandlers = [];
/**
* @var array
*/
protected $eventhandlers = array();
protected $eventhandlers = [];
/**
* @var integer
* @var int
*/
protected $lastid = 0;
/**
@ -145,21 +144,21 @@ class XMLStream
/**
* @var array
*/
protected $until_payload = array();
protected $until_payload = [];
/**
* @var Log
*/
protected $log;
/**
* @var boolean
* @var bool
*/
protected $reconnect = true;
/**
* @var boolean
* @var bool
*/
protected $been_reset = false;
/**
* @var boolean
* @var bool
*/
protected $is_server;
/**
@ -167,37 +166,42 @@ class XMLStream
*/
protected $last_send = 0;
/**
* @var boolean
* @var bool
*/
protected $use_ssl = false;
/**
* @var integer
* @var int
*/
protected $reconnectTimeout = 30;
/**
* Constructor
*
* @param string $host
* @param string $port
* @param boolean $printlog
* @param string $loglevel
* @param boolean $is_server
* @param string|null $host (optional)
* @param string|null $port (optional)
* @param bool $print_log (optional)
* @param string $log_level (optional)
* @param bool $is_server (optional)
*/
public function __construct($host = null, $port = null, $printlog = false, $loglevel = null, $is_server = false)
{
public function __construct(
?string $host = null,
?string $port = null,
bool $print_log = false,
?string $log_level = null,
bool $is_server = false
) {
$this->reconnect = !$is_server;
$this->is_server = $is_server;
$this->host = $host;
$this->port = $port;
$this->setupParser();
$this->log = new Log($printlog, $loglevel);
$this->log = new Log($print_log, $log_level);
}
/**
* Setup the XML parser
*/
public function setupParser()
public function setupParser(): void
{
$this->parser = xml_parser_create('UTF-8');
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
@ -210,6 +214,7 @@ class XMLStream
/**
* Destructor
* Cleanup connection
* @throws Exception
*/
public function __destruct()
{
@ -220,8 +225,9 @@ class XMLStream
/**
* Disconnect from XMPP Host
* @throws Exception
*/
public function disconnect()
public function disconnect(): void
{
$this->log->log("Disconnecting...", Log::LEVEL_VERBOSE);
if (false == (bool)$this->socket) {
@ -238,17 +244,16 @@ class XMLStream
* Send to socket
*
* @param string $msg
* @param null $timeout
* @param int|null $timeout
* @return bool|int
* @throws Exception
*/
public function send($msg, $timeout = NULL)
public function send(string $msg, ?int $timeout = null)
{
if (is_null($timeout)) {
$secs = NULL;
$usecs = NULL;
} else if ($timeout == 0) {
$secs = null;
$usecs = null;
} elseif ($timeout == 0) {
$secs = 0;
$usecs = 0;
} else {
@ -257,16 +262,16 @@ class XMLStream
$secs = floor(($maximum - $usecs) / 1000000);
}
$read = array();
$write = array($this->socket);
$except = array();
$read = [];
$write = [$this->socket];
$except = [];
$select = @stream_select($read, $write, $except, $secs, $usecs);
if ($select === False) {
if ($select === false) {
$this->log->log("ERROR sending message; reconnecting.");
$this->doReconnect();
# TODO: retry send here
// TODO: retry send here
return false;
} elseif ($select > 0) {
$this->log->log("Socket is ready; send it.", Log::LEVEL_VERBOSE);
@ -277,7 +282,7 @@ class XMLStream
$sentbytes = @fwrite($this->socket, $msg);
$this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), Log::LEVEL_VERBOSE);
if ($sentbytes === FALSE) {
if ($sentbytes === false) {
$this->log->log("ERROR sending message; reconnecting.", Log::LEVEL_ERROR);
$this->doReconnect();
return false;
@ -294,7 +299,7 @@ class XMLStream
{
if (!$this->is_server) {
$this->log->log("Reconnecting ($this->reconnectTimeout)...", Log::LEVEL_WARNING);
$this->connect($this->reconnectTimeout, false, false);
$this->connect(false, false, $this->reconnectTimeout);
$this->reset();
$this->event('reconnect');
}
@ -303,16 +308,15 @@ class XMLStream
/**
* Connect to XMPP Host
*
* @param integer $timeout
* @param boolean $persistent
* @param boolean $sendinit
* @throws Exception
* @param bool $persistent (optional)
* @param bool $send_init (optional)
* @param int $timeout (optional)
* @throws Exception
*/
public function connect($timeout = 30, $persistent = false, $sendinit = true)
public function connect(bool $persistent = false, bool $send_init = true, int $timeout = 30): void
{
$this->sent_disconnect = false;
$starttime = time();
$start_time = time();
do {
$this->disconnected = false;
@ -322,21 +326,25 @@ class XMLStream
} else {
$conflag = STREAM_CLIENT_CONNECT;
}
$conntype = 'tcp';
if ($this->use_ssl) $conntype = 'ssl';
$this->log->log("Connecting to $conntype://{$this->host}:{$this->port}");
$this->socket = @stream_socket_client("$conntype://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag);
$conn_type = 'tcp';
if ($this->use_ssl) {
$conn_type = 'ssl';
}
$this->log->log("Connecting to $conn_type://{$this->host}:{$this->port}");
$this->socket = @stream_socket_client("$conn_type://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag);
if (!$this->socket) {
$this->log->log("Could not connect.", Log::LEVEL_ERROR);
$this->disconnected = true;
# Take it easy for a few seconds
sleep(min($timeout, 5));
}
} while (!$this->socket && (time() - $starttime) < $timeout);
} while (!$this->socket && (time() - $start_time) < $timeout);
if ($this->socket) {
stream_set_blocking($this->socket, 1);
if ($sendinit) $this->send($this->stream_start);
if ($send_init) {
$this->send($this->stream_start);
}
} else {
throw new Exception("Could not connect before timeout.");
}
@ -344,12 +352,13 @@ class XMLStream
/**
* Reset connection
* @throws Exception
*/
public function reset()
public function reset(): void
{
$this->xml_depth = 0;
unset($this->xmlobj);
$this->xmlobj = array();
$this->xmlobj = [];
$this->setupParser();
if (!$this->is_server) {
$this->send($this->stream_start);
@ -361,9 +370,9 @@ class XMLStream
* Event?
*
* @param string $name
* @param string $payload
* @param array|null $payload
*/
public function event($name, $payload = null)
public function event(string $name, ?array $payload = null): void
{
$this->log->log("EVENT: $name", Log::LEVEL_DEBUG);
foreach ($this->eventhandlers as $handler) {
@ -377,12 +386,12 @@ class XMLStream
foreach ($this->until as $key => $until) {
if (is_array($until)) {
if (in_array($name, $until)) {
$this->until_payload[$key][] = array($name, $payload);
$this->until_payload[$key][] = [$name, $payload];
if (!isset($this->until_count[$key])) {
$this->until_count[$key] = 0;
}
$this->until_count[$key] += 1;
#$this->until[$key] = false;
//$this->until[$key] = false;
}
}
}
@ -392,14 +401,16 @@ class XMLStream
* Process until a specified event or a timeout occurs
*
* @param string|array $event
* @param integer $timeout
* @return string
* @param int $timeout (optional)
* @return array
* @throws Exception
*/
public function processUntil($event, $timeout = -1)
public function processUntil($event, int $timeout = -1): array
{
$start = time();
if (!is_array($event)) $event = array($event);
if (!is_array($event)) {
$event = array($event);
}
$this->until[] = $event;
end($this->until);
$event_key = key($this->until);
@ -414,7 +425,7 @@ class XMLStream
unset($this->until_count[$event_key]);
unset($this->until[$event_key]);
} else {
$payload = array();
$payload = [];
}
return $payload;
}
@ -428,21 +439,19 @@ class XMLStream
* @return bool
* @throws Exception
*/
private function __process($maximum = 5)
private function __process(int $maximum = 5): bool
{
$remaining = $maximum;
do {
$starttime = (microtime(true) * 1000000);
$read = array($this->socket);
$write = array();
$except = array();
$write = [];
$except = [];
if (is_null($maximum)) {
$secs = NULL;
$usecs = NULL;
} else if ($maximum == 0) {
$secs = null;
$usecs = null;
} elseif ($maximum == 0) {
$secs = 0;
$usecs = 0;
} else {
@ -456,10 +465,10 @@ class XMLStream
$this->doReconnect();
} else {
fclose($this->socket);
$this->socket = NULL;
$this->socket = null;
return false;
}
} else if ($updated > 0) {
} elseif ($updated > 0) {
# XXX: Is this big enough?
$buff = @fread($this->socket, 4096);
if (!$buff) {
@ -467,14 +476,14 @@ class XMLStream
$this->doReconnect();
} else {
fclose($this->socket);
$this->socket = NULL;
$this->socket = null;
return false;
}
}
$this->log->log("RECV: $buff", Log::LEVEL_VERBOSE);
xml_parse($this->parser, $buff, false);
} // Otherwise,
// $updated == 0 means no changes during timeout.
// $updated == 0 means no changes during timeout.
$endtime = (microtime(true) * 1000000);
$time_past = $endtime - $starttime;
@ -488,7 +497,7 @@ class XMLStream
*
* @return Log
*/
public function getLog()
public function getLog(): Log
{
return $this->log;
}
@ -496,9 +505,9 @@ class XMLStream
/**
* Get next ID
*
* @return integer
* @return int
*/
public function getId()
public function getId(): int
{
$this->lastid++;
return $this->lastid;
@ -508,7 +517,7 @@ class XMLStream
* Set SSL
* @param bool $use
*/
public function useSSL($use = true)
public function useSSL(bool $use = true): void
{
$this->use_ssl = $use;
}
@ -516,13 +525,13 @@ class XMLStream
/**
* Add ID Handler
*
* @param integer $id
* @param int $id
* @param string $pointer
* @param string $obj
* @param string|null $obj
*/
public function addIdHandler($id, $pointer, $obj = null)
public function addIdHandler(int $id, string $pointer, ?string $obj = null): void
{
$this->idhandlers[$id] = array($pointer, $obj);
$this->idhandlers[$id] = [$pointer, $obj];
}
/**
@ -531,54 +540,58 @@ class XMLStream
* @param string $name
* @param string $ns
* @param string $pointer
* @param string $obj
* @param integer $depth
*/
public function addHandler($name, $ns, $pointer, $obj = null, $depth = 1)
{
#TODO deprication warning
$this->nshandlers[] = array($name, $ns, $pointer, $obj, $depth);
}
* @param string|null $obj
* @param int $depth
*
* public function addHandler(string $name, string $ns, string $pointer, ?string $obj = null, int $depth = 1): void
* {
* #TODO deprication warning
* $this->nshandlers[] = [$name, $ns, $pointer, $obj, $depth];
* }*/
/**
* Add XPath Handler
*
* @param string $xpath
* @param string $pointer
* @param
* @param string|null $obj
*/
public function addXPathHandler($xpath, $pointer, $obj = null)
public function addXPathHandler(string $xpath, string $pointer, ?string $obj = null): void
{
if (preg_match_all("/\(?{[^\}]+}\)?(\/?)[^\/]+/", $xpath, $regs)) {
$ns_tags = $regs[0];
} else {
$ns_tags = array($xpath);
$ns_tags = [$xpath];
}
$xpath_array = [];
foreach ($ns_tags as $ns_tag) {
list($l, $r) = explode("}", $ns_tag);
if ($r != null) {
$xpart = array(substr($l, 1), $r);
$xpart = [substr($l, 1), $r];
} else {
$xpart = array(null, $l);
$xpart = [null, $l];
}
$xpath_array[] = $xpart;
}
$this->xpathhandlers[] = array($xpath_array, $pointer, $obj);
$this->xpathhandlers[] = [$xpath_array, $pointer, $obj];
}
/**
* Add Event Handler
*
* @param $name
* @param string $name
* @param string $pointer
* @param string $obj
* @param object $obj
*/
public function addEventHandler($name, $pointer, $obj)
public function addEventHandler(string $name, string $pointer, object $obj)
{
$this->eventhandlers[] = array($name, $pointer, $obj);
$this->eventhandlers[] = [$name, $pointer, $obj];
}
public function setReconnectTimeout($timeout)
/**
* @param int $timeout
*/
public function setReconnectTimeout(int $timeout): void
{
$this->reconnectTimeout = $timeout;
}
@ -586,9 +599,9 @@ class XMLStream
/**
* Are we are disconnected?
*
* @return boolean
* @return bool
*/
public function isDisconnected()
public function isDisconnected(): bool
{
return $this->disconnected;
}
@ -596,10 +609,11 @@ class XMLStream
/**
* Process
*
* @throws Exception
*/
public function process()
public function process(): void
{
$this->__process(NULL);
$this->__process(null);
}
/**
@ -609,10 +623,10 @@ class XMLStream
* @return string
* @throws Exception
*/
public function processTime($timeout = NULL)
public function processTime($timeout = null): string
{
if (is_null($timeout)) {
return $this->__process(NULL);
return $this->__process(null);
} else {
return $this->__process($timeout * 1000000);
}
@ -621,21 +635,21 @@ class XMLStream
/**
* Obsolete?
* @param $socket
*/
public function Xapply_socket($socket)
{
$this->socket = $socket;
}
*
* public function Xapply_socket($socket)
* {
* $this->socket = $socket;
* }*/
/**
* XML start callback
*
* @param resource $parser
* @param string $name
* @param $attr
* @param array $attr
* @see xml_set_element_handler
*/
public function startXML($parser, $name, $attr)
public function startXML($parser, string $name, array $attr): void
{
if ($this->been_reset) {
$this->been_reset = false;
@ -646,7 +660,9 @@ class XMLStream
$this->current_ns[$this->xml_depth] = $attr['XMLNS'];
} else {
$this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
if (!$this->current_ns[$this->xml_depth]) $this->current_ns[$this->xml_depth] = $this->default_ns;
if (!$this->current_ns[$this->xml_depth]) {
$this->current_ns[$this->xml_depth] = $this->default_ns;
}
}
$ns = $this->current_ns[$this->xml_depth];
foreach ($attr as $key => $value) {
@ -677,7 +693,7 @@ class XMLStream
* @see xml_set_element_handler
*
*/
public function endXML($parser, $name)
public function endXML($parser, string $name): void
{
#$this->log->log("Ending $name", Log::LEVEL_DEBUG);
#print "$name\n";
@ -689,6 +705,7 @@ class XMLStream
if ($this->xml_depth == 1) {
#clean-up old objects
#$found = false; #FIXME This didn't appear to be in use --Gar
$searchxml = null;
foreach ($this->xpathhandlers as $handler) {
if (is_array($this->xmlobj) && array_key_exists(2, $this->xmlobj)) {
$searchxml = $this->xmlobj[2];
@ -703,7 +720,9 @@ class XMLStream
}
}
if ($searchxml !== null) {
if ($handler[2] === null) $handler[2] = $this;
if ($handler[2] === null) {
$handler[2] = $this;
}
$this->log->log("Calling {$handler[1]}", Log::LEVEL_DEBUG);
$handler[2]->{$handler[1]}($this->xmlobj[2]);
}
@ -717,14 +736,18 @@ class XMLStream
$searchxml = $this->xmlobj[2];
}
if ($searchxml !== null and $searchxml->name == $handler[0] and ($searchxml->ns == $handler[1] or (!$handler[1] and $searchxml->ns == $this->default_ns))) {
if ($handler[3] === null) $handler[3] = $this;
if ($handler[3] === null) {
$handler[3] = $this;
}
$this->log->log("Calling {$handler[2]}", Log::LEVEL_DEBUG);
$handler[3]->{$handler[2]}($this->xmlobj[2]);
}
}
foreach ($this->idhandlers as $id => $handler) {
if (array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) {
if ($handler[1] === null) $handler[1] = $this;
if ($handler[1] === null) {
$handler[1] = $this;
}
$handler[1]->{$handler[0]}($this->xmlobj[2]);
#id handlers are only used once
unset($this->idhandlers[$id]);
@ -762,7 +785,7 @@ class XMLStream
* @see xml_set_character_data_handler
*
*/
public function charXML($parser, $data)
public function charXML($parser, string $data): void
{
if (array_key_exists($this->xml_depth, $this->xmlobj)) {
$this->xmlobj[$this->xml_depth]->data .= $data;
@ -771,8 +794,10 @@ class XMLStream
/**
* Read from socket
* @return bool Did read
* @throws Exception
*/
public function read()
public function read(): bool
{
$buff = @fread($this->socket, 1024);
if (!$buff) {
@ -785,19 +810,20 @@ class XMLStream
}
$this->log->log("RECV: $buff", Log::LEVEL_VERBOSE);
xml_parse($this->parser, $buff, false);
return true;
}
public function time()
public function time(): float
{
list($usec, $sec) = explode(" ", microtime());
return (float)$sec + (float)$usec;
}
public function readyToProcess()
public function readyToProcess(): bool
{
$read = array($this->socket);
$write = array();
$except = array();
$write = [];
$except = [];
$updated = @stream_select($read, $write, $except, 0);
return (($updated !== false) && ($updated > 0));
}

View File

@ -1,5 +1,4 @@
<?php
/**
* XMPPHP: The PHP XMPP Library
* Copyright (C) 2008 Nathanael C. Fritz
@ -59,7 +58,7 @@ class XMPP extends XMLStream
*/
public $user;
/**
* @var boolean
* @var bool
*/
public $track_presence = true;
/**
@ -83,16 +82,16 @@ class XMPP extends XMLStream
*/
protected $basejid;
/**
* @var boolean
* @var bool
*/
protected $authed = false;
protected $session_started = false;
/**
* @var boolean
* @var bool
*/
protected $auto_subscribe = false;
/**
* @var boolean
* @var bool
*/
protected $use_encryption = true;
@ -105,12 +104,20 @@ class XMPP extends XMLStream
* @param string $password
* @param string $resource
* @param string $server
* @param boolean $printlog
* @param string $loglevel
* @param bool $print_log
* @param string $log_level
*/
public function __construct($host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null)
{
parent::__construct($host, $port, $printlog, $loglevel);
public function __construct(
string $host,
int $port,
string $user,
string $password,
string $resource,
?string $server = null,
bool $print_log = false,
?string $log_level = null
) {
parent::__construct($host, $port, $print_log, $log_level);
$this->user = $user;
$this->password = $password;
@ -140,9 +147,9 @@ class XMPP extends XMLStream
/**
* Turn encryption on/ff
*
* @param boolean $useEncryption
* @param bool $useEncryption (optional)
*/
public function useEncryption($useEncryption = true)
public function useEncryption(bool $useEncryption = true): void
{
$this->use_encryption = $useEncryption;
}
@ -150,9 +157,9 @@ class XMPP extends XMLStream
/**
* Turn on auto-authorization of subscription requests.
*
* @param boolean $autoSubscribe
* @param bool $autoSubscribe (optional)
*/
public function autoSubscribe($autoSubscribe = true)
public function autoSubscribe(bool $autoSubscribe = true): void
{
$this->auto_subscribe = $autoSubscribe;
}
@ -162,12 +169,12 @@ class XMPP extends XMLStream
*
* @param string $to
* @param string $body
* @param string $type
* @param string $subject
* @param null $payload
* @param string $type (optional)
* @param string|null $subject (optional)
* @param string|null $payload (optional)
* @throws Exception
*/
public function message($to, $body, $type = 'chat', $subject = null, $payload = null)
public function message(string $to, string $body, string $type = 'chat', ?string $subject = null, ?string $payload = null): void
{
if ($this->disconnected) {
throw new Exception('You need to connect first');
@ -177,13 +184,13 @@ class XMPP extends XMLStream
$type = 'chat';
}
$to = htmlspecialchars($to);
$body = htmlspecialchars($body);
$to = htmlspecialchars($to);
$body = htmlspecialchars($body);
$subject = htmlspecialchars($subject);
$subject = ($subject) ? '<subject>' . $subject . '</subject>' : '';
$payload = ($payload) ? $payload : '';
$sprintf = '<message from="%s" to="%s" type="%s">%s<body>%s</body>%s</message>';
$output = sprintf($sprintf, $this->fulljid, $to, $type, $subject, $body, $payload);
$output = sprintf($sprintf, $this->fulljid, $to, $type, $subject, $body, $payload);
$this->send($output);
}
@ -197,7 +204,7 @@ class XMPP extends XMLStream
* @param null $priority
* @throws Exception
*/
public function presence($status = null, $show = 'available', $to = null, $type = 'available', $priority = null)
public function presence($status = null, $show = 'available', $to = null, $type = 'available', $priority = null): void
{
if ($this->disconnected) {
throw new Exception('You need to connect first');
@ -242,8 +249,9 @@ class XMPP extends XMLStream
* Send Auth request
*
* @param string $jid
* @throws Exception
*/
public function subscribe($jid)
public function subscribe(string $jid): void
{
$this->send("<presence type='subscribe' to='{$jid}' from='{$this->fulljid}' />");
#$this->send("<presence type='subscribed' to='{$jid}' from='{$this->fulljid}' />");
@ -252,9 +260,9 @@ class XMPP extends XMLStream
/**
* Message handler
*
* @param string $xml
* @param XMLObj $xml
*/
public function message_handler($xml)
public function message_handler(XMLObj $xml): void
{
if (isset($xml->attrs['type'])) {
$payload['type'] = $xml->attrs['type'];
@ -272,9 +280,10 @@ class XMPP extends XMLStream
/**
* Presence handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
public function presence_handler($xml)
public function presence_handler(XMLObj $xml): void
{
$payload['type'] = (isset($xml->attrs['type'])) ? $xml->attrs['type'] : 'available';
$payload['show'] = (isset($xml->sub('show')->data)) ? $xml->sub('show')->data : $payload['type'];
@ -302,8 +311,9 @@ class XMPP extends XMLStream
/**
* Retrieves the roster
*
* @throws Exception
*/
public function getRoster()
public function getRoster(): void
{
$id = $this->getID();
$this->send("<iq xmlns='jabber:client' type='get' id='$id'><query xmlns='jabber:iq:roster' /></iq>");
@ -311,9 +321,10 @@ class XMPP extends XMLStream
/**
* Retrieves the vcard
* @param null $jid
* @param string|null $jid
* @throws Exception
*/
public function getVCard($jid = null)
public function getVCard(?string $jid = null): void
{
$id = $this->getID();
$this->addIdHandler($id, 'vcard_get_handler');
@ -327,9 +338,10 @@ class XMPP extends XMLStream
/**
* Features handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function features_handler($xml)
protected function features_handler(XMLObj $xml): void
{
if ($xml->hasSub('starttls') and $this->use_encryption) {
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'><required /></starttls>");
@ -350,9 +362,10 @@ class XMPP extends XMLStream
/**
* SASL success handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function sasl_success_handler($xml)
protected function sasl_success_handler(XMLObj $xml): void
{
$this->log->log("Auth success!");
$this->authed = true;
@ -362,10 +375,10 @@ class XMPP extends XMLStream
/**
* SASL feature handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function sasl_failure_handler($xml)
protected function sasl_failure_handler(XMLObj $xml): void
{
$this->log->log("Auth failed!", Log::LEVEL_ERROR);
$this->disconnect();
@ -376,9 +389,10 @@ class XMPP extends XMLStream
/**
* Resource bind handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function resource_bind_handler($xml)
protected function resource_bind_handler(XMLObj $xml): void
{
if ($xml->attrs['type'] == 'result') {
$this->log->log("Bound to " . $xml->sub('bind')->sub('jid')->data);
@ -395,14 +409,16 @@ class XMPP extends XMLStream
* Roster iq handler
* Gets all packets matching XPath "iq/{jabber:iq:roster}query'
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function roster_iq_handler($xml)
protected function roster_iq_handler(XMLObj $xml): void
{
$status = "result";
$xmlroster = $xml->sub('query');
$contacts = [];
foreach ($xmlroster->subs as $item) {
$groups = array();
$groups = [];
if ($item->name == 'item') {
$jid = $item->attrs['jid']; //REQUIRED
$name = $item->attrs['name']; //MAY
@ -412,7 +428,7 @@ class XMPP extends XMLStream
$groups[] = $subitem->data;
}
}
$contacts[] = array($jid, $subscription, $name, $groups); //Store for action if no errors happen
$contacts[] = [$jid, $subscription, $name, $groups]; //Store for action if no errors happen
} else {
$status = "error";
}
@ -430,9 +446,9 @@ class XMPP extends XMLStream
/**
* Session start handler
*
* @param string $xml
* @param XMLObj $xml
*/
protected function session_start_handler($xml)
protected function session_start_handler(XMLObj $xml): void
{
$this->log->log("Session started");
$this->session_started = true;
@ -442,12 +458,13 @@ class XMPP extends XMLStream
/**
* TLS proceed handler
*
* @param string $xml
* @param XMLObj $xml
* @throws Exception
*/
protected function tls_proceed_handler($xml)
protected function tls_proceed_handler(XMLObj $xml): void
{
$this->log->log("Starting TLS encryption");
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
$this->reset();
}
@ -456,14 +473,14 @@ class XMPP extends XMLStream
*
* @param XMLObj $xml
*/
protected function vcard_get_handler($xml)
protected function vcard_get_handler(XMLObj $xml): void
{
$vcard_array = array();
$vcard_array = [];
$vcard = $xml->sub('vcard');
// go through all of the sub elements and add them to the vcard array
foreach ($vcard->subs as $sub) {
if ($sub->subs) {
$vcard_array[$sub->name] = array();
$vcard_array[$sub->name] = [];
foreach ($sub->subs as $sub_child) {
$vcard_array[$sub->name][$sub_child->name] = $sub_child->data;
}

View File

@ -1,49 +1,59 @@
{
"name": "diogocomposer/xmpphp",
"description": "XMPP PHP Library",
"type": "library",
"keywords": ["jabber", "xmpphp", "xmpp"],
"license": "GPL-2.0+",
"authors": [
{
"name": "Nathan Fritz",
"email": "fritzy@netflint.net"
},
{
"name": "Stephan Wentz",
"email": "stephan@wentz.it"
},
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de"
},
{
"name": "Vito Tafuni",
"email": "vitotafuni@gmail.com"
},
{
"name": "Ivan Borzenkov",
"email": "ivan.borzenkov@gmail.com"
},
{
"name": "bandroidx",
"email": "bandroidx@gmail.com"
},
{
"name": "BirknerAlex",
"email": "alex.birkner@gmail.com"
},
{
"name": "Diogo Cordeiro",
"email": "diogo@fc.up.pt"
}
],
"autoload": {
"psr-4": { "XMPPHP\\": "XMPPHP" }
"name": "diogocomposer/xmpphp",
"description": "XMPP PHP Library",
"type": "library",
"keywords": [
"jabber",
"xmpphp",
"xmpp"
],
"license": "GPL-2.0+",
"authors": [
{
"name": "Nathan Fritz",
"email": "fritzy@netflint.net"
},
"require": {
"php": ">=7.0.0",
"ext-mbstring": "*",
"ext-xml": "*"
{
"name": "Stephan Wentz",
"email": "stephan@wentz.it"
},
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de"
},
{
"name": "Vito Tafuni",
"email": "vitotafuni@gmail.com"
},
{
"name": "Ivan Borzenkov",
"email": "ivan.borzenkov@gmail.com"
},
{
"name": "bandroidx",
"email": "bandroidx@gmail.com"
},
{
"name": "BirknerAlex",
"email": "alex.birkner@gmail.com"
},
{
"name": "Diogo Cordeiro",
"email": "diogo@fc.up.pt"
}
],
"autoload": {
"psr-4": {
"XMPPHP\\": "XMPPHP"
}
},
"require": {
"php": "^7.3.0",
"ext-mbstring": "*",
"ext-xml": "*",
"ext-simplexml": "*",
"ext-dom": "*",
"ext-curl": "*",
"ext-openssl": "*"
}
}

View File

@ -1,5 +1,4 @@
<?php
/**
* @file: XMPPHP Cli example
*
@ -19,18 +18,16 @@
* LEVEL_VERBOSE = 4;
*/
require '../vendor/autoload.php';
$conf = array(
'server' => 'talk.google.com',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'gmail.com',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
);
$conf = [
'server' => 'im.server.tld',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'domain.net',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
];
// Easy and simple for access to variables with their names
extract($conf);
@ -38,13 +35,13 @@ extract($conf);
$conn = new XMPPHP\XMPP($server, $port, $username, $password, $proto, $domain, $printlog, $loglevel);
$conn->autoSubscribe();
$vcard_request = array();
$vcard_request = [];
try {
$conn->connect();
while (!$conn->isDisconnected()) {
$events = array('message', 'presence', 'end_stream', 'session_start', 'vcard');
$events = ['message', 'presence', 'end_stream', 'session_start', 'vcard'];
$payloads = $conn->processUntil($events);
foreach ($payloads as $result) {
@ -56,84 +53,84 @@ try {
switch ($event) {
case 'message':
case 'message':
if (!$body) {
break;
}
if (!$body) {
break;
}
echo str_repeat('-', 80);
echo "Message from: $from";
echo str_repeat('-', 80);
echo "Message from: $from";
if (isset($subject)) {
echo "Subject: $subject";
}
if (isset($subject)) {
echo "Subject: $subject";
}
echo $body;
echo str_repeat('-', 80);
echo $body;
echo str_repeat('-', 80);
$cmd = explode(' ', $body);
$body = "Mi no entender! '$body'";
$conn->message($from, $body, $type);
$cmd = explode(' ', $body);
$body = "Mi no entender! '$body'";
$conn->message($from, $body, $type);
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
if ($cmd[0] == 'vcard') {
if (!isset($cmd[1])) {
$cmd[1] = $conn->user;
}
if ($cmd[0] == 'vcard') {
if (!isset($cmd[1])) {
$cmd[1] = $conn->user;
}
// Take a note which user requested which vcard
$vcard_request[$from] = $cmd[1];
// Request the vcard
$conn->getVCard($cmd[1]);
}
}
break;
// Take a note which user requested which vcard
$vcard_request[$from] = $cmd[1];
// Request the vcard
$conn->getVCard($cmd[1]);
}
}
break;
case 'presence':
case 'presence':
echo "Presence: $from [$show] $status\n";
break;
echo "Presence: $from [$show] $status\n";
break;
case 'session_start':
case 'session_start':
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
case 'vcard':
case 'vcard':
$deliver = array_keys($vcard_request, $from);
$msg = '';
$deliver = array_keys($vcard_request, $from);
$msg = '';
foreach ($data as $key => $item) {
$msg .= $key . ': ';
foreach ($data as $key => $item) {
$msg .= $key . ': ';
if (is_array($item)) {
$msg .= "\n";
foreach ($item as $subkey => $subitem) {
$msg .= ' ' . $subkey . ':' . $subitem . "\n";
}
} else {
$msg .= $item . "\n";
}
}
if (is_array($item)) {
$msg .= "\n";
foreach ($item as $subkey => $subitem) {
$msg .= ' ' . $subkey . ':' . $subitem . "\n";
}
} else {
$msg .= $item . "\n";
}
}
foreach ($deliver as $sendjid) {
unset($vcard_request[$sendjid]);
$conn->message($sendjid, $msg, 'chat');
}
break;
}
foreach ($deliver as $sendjid) {
unset($vcard_request[$sendjid]);
$conn->message($sendjid, $msg, 'chat');
}
break;
}
}
}
} catch (XMPPHP\Exception $e) {

View File

@ -1,5 +1,4 @@
<?php
/**
* @file: XMPPHP Cli example BOSH
*
@ -19,30 +18,28 @@
* LEVEL_VERBOSE = 4;
*/
require '../vendor/autoload.php';
$conf = array(
'server' => 'server.tld',
'port' => 5280,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'server.tld',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
);
$conf = [
'host' => 'server.tld',
'port' => 5280,
'username' => 'username',
'password' => 'password',
'resource' => 'xmpphp',
'server' => 'http://server.tld:5280/xmpp-httpbind',
'print_log' => true,
'log_level' => XMPPHP\Log::LEVEL_VERBOSE,
];
// Easy and simple for access to variables with their names
extract($conf);
$conn = new XMPPHP\BOSH($server, $port, $username, $password, $proto, $domain, $printlog, $loglevel);
$conn = new XMPPHP\BOSH($host, $port, $username, $password, $proto, $server, $print_log, $log_level);
$conn->autoSubscribe();
try {
$conn->connect('http://server.tld:5280/xmpp-httpbind');
$conn->connect();
while (!$conn->isDisconnected()) {
$events = array('message', 'presence', 'end_stream', 'session_start');
$events = ['message', 'presence', 'end_stream', 'session_start'];
$payloads = $conn->processUntil($events);
foreach ($payloads as $result) {
@ -54,49 +51,49 @@ try {
switch ($event) {
case 'message':
case 'message':
if (!$body) {
break;
}
if (!$body) {
break;
}
echo str_repeat('-', 80);
echo "Message from: $from";
echo str_repeat('-', 80);
echo "Message from: $from";
if (isset($subject)) {
echo "Subject: $subject";
}
if (isset($subject)) {
echo "Subject: $subject";
}
echo $body;
echo str_repeat('-', 80);
echo $body;
echo str_repeat('-', 80);
$cmd = explode(' ', $body);
$body = "Mi no entender! '$body'";
$conn->message($from, $body, $type);
$cmd = explode(' ', $body);
$body = "Mi no entender! '$body'";
$conn->message($from, $body, $type);
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
}
break;
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
}
break;
case 'presence':
case 'presence':
echo "Presence: $from [$show] $status\n";
break;
echo "Presence: $from [$show] $status\n";
break;
case 'session_start':
case 'session_start':
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
}
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
}
}
}
} catch (XMPPHP\Exception $e) {

View File

@ -1,5 +1,4 @@
<?php
/**
* @file: XMPPHP Send message example
*
@ -18,18 +17,16 @@
* LEVEL_VERBOSE = 4;
*/
require_once __DIR__.'/../vendor/autoload.php';
$conf = array(
'server' => 'talk.google.com',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'gmail.com',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
);
$conf = [
'server' => 'jabber.domain.com',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'domain.net',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
];
// Easy and simple for access to variables with their names
extract($conf);

View File

@ -1,5 +1,4 @@
<?php
/**
* @file: XMPPHP Cli example
*
@ -22,18 +21,16 @@
session_start();
header('content-type', 'plain/text');
require '../vendor/autoload.php';
$conf = array(
'server' => 'talk.google.com',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'gmail.com',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
);
$conf = [
'server' => 'talk.google.com',
'port' => 5222,
'username' => 'username',
'password' => 'password',
'proto' => 'xmpphp',
'domain' => 'gmail.com',
'printlog' => true,
'loglevel' => XMPPHP\Log::LEVEL_VERBOSE,
];
// Easy and simple for access to variables with their names
extract($conf);
@ -48,11 +45,11 @@ try {
flush();
}
} else {
$_SESSION['messages'] = array();
$_SESSION['messages'] = [];
}
$conn->connect('http://server.tld:5280/xmpp-httpbind', 1, true);
$events = array('message', 'presence', 'end_stream', 'session_start', 'vcard');
$conn->connect();
$events = ['message', 'presence', 'end_stream', 'session_start', 'vcard'];
$payloads = $conn->processUntil($events);
foreach ($payloads as $result) {
@ -64,49 +61,49 @@ try {
switch ($event) {
case 'message':
case 'message':
if (!$body) {
break;
if (!$body) {
break;
}
$cmd = explode(' ', $body);
$msg = str_repeat('-', 80);
$msg .= "\nMessage from: $from\n";
if (isset($subject)) {
$msg .= "Subject: $subject\n";
}
$msg .= $body . "\n";
$msg .= str_repeat('-', 80);
echo "<pre>$msg</pre>";
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
}
$_SESSION['messages'][] = $msg;
flush();
break;
case 'presence':
echo "Presence: $from [$show] $status\n";
break;
case 'session_start':
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
}
$cmd = explode(' ', $body);
$msg = str_repeat('-', 80);
$msg .= "\nMessage from: $from\n";
if (isset($subject)) {
$msg .= "Subject: $subject\n";
}
$msg .= $body . "\n";
$msg .= str_repeat('-', 80);
echo "<pre>$msg</pre>";
if (isset($cmd[0])) {
if ($cmd[0] == 'quit') {
$conn->disconnect();
}
if ($cmd[0] == 'break') {
$conn->send('</end>');
}
}
$_SESSION['messages'][] = $msg;
flush();
break;
case 'presence':
echo "Presence: $from [$show] $status\n";
break;
case 'session_start':
echo "Session start\n";
$conn->getRoster();
$conn->presence('Quasar!');
break;
}
}
} catch (XMPPHP\Exception $e) {
die($e->getMessage());

View File

@ -44,35 +44,35 @@ class XMPPHP_XMLObjTest extends PHPUnit_Framework_TestCase
{
public function testToStringNameNamespace()
{
$xmlobj = new XMPPHP_XMLObj('testname', 'testNameSpace');
$xmlobj = new XMPPHP_XMLObj('testname', 'testNameSpace');
$expected = '<testname xmlns="testNameSpace"></testname>';
$result = $xmlobj->toString();
$result = $xmlobj->toString();
$this->assertSame($expected, $result);
}
public function testToStringNameNamespaceAttr()
{
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', array('attr1' => 'valA', 'attr2' => 'valB'));
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', ['attr1' => 'valA', 'attr2' => 'valB']);
$expected = '<testname xmlns="testNameSpace" attr1="valA" attr2="valB"></testname>';
$result = $xmlobj->toString();
$result = $xmlobj->toString();
$this->assertSame($expected, $result);
}
public function testToStringNameNamespaceData()
{
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', array(), 'I am test data');
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace', [], 'I am test data');
$expected = '<testname xmlns="testNameSpace">I am test data</testname>';
$result = $xmlobj->toString();
$result = $xmlobj->toString();
$this->assertSame($expected, $result);
}
public function testToStringNameNamespaceSub()
{
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace');
$sub1 = new XMPPHP_XMLObj('subName', 'subNameSpace');
$xmlobj->subs = array($sub1);
$expected = '<testname xmlns="testNameSpace"><subname xmlns="subNameSpace"></subname></testname>';
$result = $xmlobj->toString();
$xmlobj = new XMPPHP_XMLObj('testName', 'testNameSpace');
$sub1 = new XMPPHP_XMLObj('subName', 'subNameSpace');
$xmlobj->subs = [$sub1];
$expected = '<testname xmlns="testNameSpace"><subname xmlns="subNameSpace"></subname></testname>';
$result = $xmlobj->toString();
$this->assertSame($expected, $result);
}
}

View File

@ -55,7 +55,7 @@ class XMPPHP_XMPPTest extends PHPUnit_Framework_TestCase
} catch (XMPPHP_Exception $e) {
return;
} catch (Exception $e) {
$this->fail('Unexpected Exception thrown: '.$e->getMessage());
$this->fail('Unexpected Exception thrown: ' . $e->getMessage());
}
$this->fail('Expected XMPPHP_Exception not thrown!');
@ -74,7 +74,7 @@ class XMPPHP_XMPPTest extends PHPUnit_Framework_TestCase
} catch (XMPPHP_Exception $e) {
return;
} catch (Exception $e) {
$this->fail('Unexpected Exception thrown: '.$e->getMessage());
$this->fail('Unexpected Exception thrown: ' . $e->getMessage());
}
$this->fail('Expected XMPPHP_Exception not thrown!');

View File

@ -0,0 +1,22 @@
<?php
namespace Embed\Adapters;
use Embed\Http\Response;
/**
* Adapter to provide information from Vimeo.
* Required when Vimeo returns a 403 status code.
*/
class Vimeo extends Webpage
{
/**
* {@inheritdoc}
*/
public static function check(Response $response)
{
return $response->isValid([200, 403]) && $response->getUrl()->match([
'vimeo.com/*',
]);
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Embed\Providers\OEmbed;
class Vimeo extends EndPoint implements EndPointInterface
{
protected static $pattern = ['vimeo.com/*'];
protected static $endPoint = 'https://vimeo.com/api/oembed.json';
}

View File

@ -9,6 +9,12 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. Internal change
==========================
4.12.0, released 2019-10-27
! PHP 7.4 is supported, thank you Witold Wasiczko, Mateuz Turcza and
Edi Modrić
- PHPDocs for HTMLModule::addElement() and Bool attr are fixed (thanks
Mateusz)
4.11.0, released 2019-07-14
# SafeScripting now matches case-sensitively against its whitelist (previously it was
case-insensitive.) Thanks Dimitri Gritsajuk <gritsajuk.dimitri@gmail.com>

View File

@ -1 +1 @@
4.11.0
4.12.0

View File

@ -1,7 +1,2 @@
HTML Purifier 4.11.x is a maintenance release, collecting a year
and a half of accumulated bug fixes. Most notable fixes are
compatibility with PHP 7.3, and case-sensitive matching for
the SafeScripting whitelist. There are a number small feature
enhancements, including an expanded supported color list,
initial and inherit support for {min-,max-,}{width,height}
and multidimensional array support for purifyArray.
HTML Purifier 4.12.x is a maintenance release which makes
compatibility fixes for PHP 7.4.

View File

@ -7,7 +7,7 @@
* primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS
* FILE, changes will be overwritten the next time the script is run.
*
* @version 4.11.0
* @version 4.12.0
*
* @warning
* You must *not* include any other HTML Purifier files before this file,

View File

@ -19,7 +19,7 @@
*/
/*
HTML Purifier 4.11.0 - Standards Compliant HTML Filtering
HTML Purifier 4.12.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or
@ -58,12 +58,12 @@ class HTMLPurifier
* Version of HTML Purifier.
* @type string
*/
public $version = '4.11.0';
public $version = '4.12.0';
/**
* Constant with version of HTML Purifier.
*/
const VERSION = '4.11.0';
const VERSION = '4.12.0';
/**
* Global configuration object.

View File

@ -7,7 +7,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
{
/**
* @type bool
* @type string
*/
protected $name;
@ -17,7 +17,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef
public $minimized = true;
/**
* @param bool $name
* @param bool|string $name
*/
public function __construct($name = false)
{

View File

@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef
protected function _compileRegex()
{
$raw = str_replace(' ', '', $this->dtd_regex);
if ($raw{0} != '(') {
if ($raw[0] != '(') {
$raw = "($raw)";
}
$el = '[#a-zA-Z0-9_.-]+';

View File

@ -21,7 +21,7 @@ class HTMLPurifier_Config
* HTML Purifier's version
* @type string
*/
public $version = '4.11.0';
public $version = '4.12.0';
/**
* Whether or not to automatically finalize

View File

@ -159,7 +159,7 @@ class HTMLPurifier_Encoder
$len = strlen($str);
for ($i = 0; $i < $len; $i++) {
$in = ord($str{$i});
$in = ord($str[$i]);
$char .= $str[$i]; // append byte to char
if (0 == $mState) {
// When mState is zero we expect either a US-ASCII character

View File

@ -132,9 +132,9 @@ class HTMLPurifier_HTMLModule
* @param string $element Name of element to add
* @param string|bool $type What content set should element be registered to?
* Set as false to skip this step.
* @param string $contents Allowed children in form of:
* @param string|HTMLPurifier_ChildDef $contents Allowed children in form of:
* "$content_model_type: $content_model"
* @param array $attr_includes What attribute collections to register to
* @param array|string $attr_includes What attribute collections to register to
* element?
* @param array $attr What unique attributes does the element define?
* @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.

View File

@ -74,7 +74,12 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer
}
set_error_handler(array($this, 'muteErrorHandler'));
$doc->loadHTML($html, $options);
// loadHTML() fails on PHP 5.3 when second parameter is given
if ($options) {
$doc->loadHTML($html, $options);
} else {
$doc->loadHTML($html);
}
restore_error_handler();
$body = $doc->getElementsByTagName('html')->item(0)-> // <html>

View File

@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform
if (isset($attr['size'])) {
// normalize large numbers
if ($attr['size'] !== '') {
if ($attr['size']{0} == '+' || $attr['size']{0} == '-') {
if ($attr['size'][0] == '+' || $attr['size'][0] == '-') {
$size = (int)$attr['size'];
if ($size < -2) {
$attr['size'] = '-2';

View File

@ -69,7 +69,7 @@ class ImageServiceProvider extends ServiceProvider
} elseif (version_compare(IlluminateApplication::VERSION, '5.0', '<')) {
$provider = '\Intervention\Image\ImageServiceProviderLaravel4';
} else {
$provider = '\Intervention\Image\ImageServiceProviderLaravel5';
$provider = '\Intervention\Image\ImageServiceProviderLaravelRecent';
}
return new $provider($this->app);

View File

@ -4,7 +4,7 @@ namespace Intervention\Image;
use Illuminate\Support\ServiceProvider;
class ImageServiceProviderLaravel5 extends ServiceProvider
class ImageServiceProviderLaravelRecent extends ServiceProvider
{
/**
* Determines if Intervention Imagecache is installed
@ -48,7 +48,7 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
// create image
$app->singleton('image', function ($app) {
return new ImageManager($app['config']->get('image'));
return new ImageManager($this->getImageConfig($app));
});
$app->alias('image', 'Intervention\Image\ImageManager');
@ -86,4 +86,21 @@ class ImageServiceProviderLaravel5 extends ServiceProvider
])->where(['filename' => $filename_pattern]);
}
}
/**
* Return image configuration as array
*
* @param Application $app
* @return array
*/
private function getImageConfig($app)
{
$config = $app['config']->get('image');
if (is_null($config)) {
return [];
}
return $config;
}
}

View File

@ -16,8 +16,8 @@ matrix:
- php: 7.1
env: CS_FIXER=1
- php: 7.2
- php: 7.3
env: BENCHMARK=1
- php: hhvm
fast_finish: true
cache:

View File

@ -12,7 +12,7 @@ HTML5 provides the following features.
- Event-based (SAX-like) parser
- A DOM tree builder
- Interoperability with [QueryPath](https://github.com/technosophos/querypath)
- Runs on **PHP** 5.3.0 or newer and **HHVM** 3.2 or newer
- Runs on **PHP** 5.3.0 or newer
[![Build Status](https://travis-ci.org/Masterminds/html5-php.png?branch=master)](https://travis-ci.org/Masterminds/html5-php)
[![Latest Stable Version](https://poser.pugx.org/masterminds/html5/v/stable.png)](https://packagist.org/packages/masterminds/html5)

View File

@ -1,5 +1,10 @@
# Release Notes
2.7.0 (2019-07-25)
- #164: Drop HHVM support
- #168: Set default encoding in the DOMDocument object
2.6.0 (2019-03-10)
- #163: Allow to pass a charset to the Scanner

View File

@ -38,7 +38,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.6-dev"
"dev-master": "2.7-dev"
}
}
}

View File

@ -176,6 +176,7 @@ class DOMTreeBuilder implements EventHandler
$dt = $impl->createDocumentType('html');
// $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt);
$this->doc = $impl->createDocument(null, null, $dt);
$this->doc->encoding = !empty($options['encoding']) ? $options['encoding'] : 'UTF-8';
}
$this->errors = array();
@ -391,11 +392,6 @@ class DOMTreeBuilder implements EventHandler
// to avoid spl_object_hash collisions whe have to avoid garbage collection of $ele storing it into $pushes
// see https://bugs.php.net/bug.php?id=67459
$this->pushes[spl_object_hash($ele)] = array($pushes, $ele);
// SEE https://github.com/facebook/hhvm/issues/2962
if (defined('HHVM_VERSION')) {
$ele->setAttribute('html5-php-fake-id-attribute', spl_object_hash($ele));
}
}
foreach ($attributes as $aName => $aVal) {
@ -509,12 +505,7 @@ class DOMTreeBuilder implements EventHandler
$lname = Elements::normalizeSvgElement($lname);
}
// See https://github.com/facebook/hhvm/issues/2962
if (defined('HHVM_VERSION') && ($cid = $this->current->getAttribute('html5-php-fake-id-attribute'))) {
$this->current->removeAttribute('html5-php-fake-id-attribute');
} else {
$cid = spl_object_hash($this->current);
}
$cid = spl_object_hash($this->current);
// XXX: HTML has no parent. What do we do, though,
// if this element appears in the wrong place?

View File

@ -167,9 +167,7 @@ class OutputRules implements RulesInterface
$this->outputMode = static::IM_IN_HTML;
$this->out = $output;
// If HHVM, see https://github.com/facebook/hhvm/issues/2727
$this->hasHTML5 = defined('ENT_HTML5') && !defined('HHVM_VERSION');
$this->hasHTML5 = defined('ENT_HTML5');
}
public function addRule(array $rule)

View File

@ -52,6 +52,7 @@ class DOMTreeBuilderTest extends \Masterminds\HTML5\Tests\TestCase
$html = '<!DOCTYPE html><html></html>';
$doc = $this->parse($html);
$this->assertEquals('UTF-8', $doc->encoding);
$this->assertInstanceOf('\DOMDocument', $doc);
$this->assertEquals('html', $doc->documentElement->tagName);
$this->assertEquals('http://www.w3.org/1999/xhtml', $doc->documentElement->namespaceURI);

View File

@ -366,12 +366,25 @@ class Connection
protected function getHostList()
{
$hosts = array_values($this->hosts);
if ($this->params['randomize']) {
if ($this->shouldRandomizeHosts()) {
shuffle($hosts);
}
return $hosts;
}
/**
* Returns whether the broker host list should be shuffled in random order.
*
* This applies when specifying multiple hosts using a failover:// protocol in the URI.
*
* @return bool
* Whether the broker hosts should be shuffled in random order.
*/
protected function shouldRandomizeHosts()
{
return filter_var($this->params['randomize'], FILTER_VALIDATE_BOOLEAN);
}
/**
* Try to connect to given host.
*