konvos intergration
This commit is contained in:
parent
9c95258471
commit
e0085d4424
@ -2,7 +2,21 @@
|
||||
CACLS *.* /e /p everyone:f
|
||||
|
||||
echo ^<?php >>config.php
|
||||
echo $knews = "http://knews.cf"; >> config.php
|
||||
echo $kloud = "https://k-loud.cf"; >> config.php
|
||||
echo $konvos = "http://konvos.cf"; >> config.php
|
||||
|
||||
findstr "http://knews.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 echo Already Updated
|
||||
if errorlevel 0 echo $knews = "http://knews.cf"; >> config.php
|
||||
|
||||
findstr "http://k-loud.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 echo Already Updated
|
||||
if errorlevel 0 echo $kloud = "https://k-loud.cf"; >> config.php
|
||||
|
||||
findstr "http://konvos.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 echo Already Updated
|
||||
if errorlevel 0 echo $konvos = "http://konvos.cf"; >> config.php
|
||||
|
||||
findstr "konvosvisible" config.php >nul 2>&1
|
||||
if errorlevel 1 echo Already Updated
|
||||
if errorlevel 0 echo $konvosvisible = "1"; >> config.php
|
||||
|
||||
echo ^?^> >> config.php
|
@ -4,8 +4,4 @@ findstr "http://webclip.ml" config.php >nul 2>&1
|
||||
if errorlevel 1 echo Already Updated
|
||||
if errorlevel 0 cscript replace.vbs "config.php" "http://webclip.ml" "http://klips.cf"
|
||||
|
||||
findstr "knews.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 findstr "k-loud.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 findstr "konvos.cf" config.php >nul 2>&1
|
||||
if errorlevel 1 ImportLines.bat
|
||||
if errorlevel 0 echo Already Updated
|
||||
ImportLines.bat
|
237
builds/converse.min.js
vendored
Normal file
237
builds/converse.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
29
composer.json
Normal file
29
composer.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "piotr-cz/xmpp-prebind-php",
|
||||
"description": "This class is for prebinding a XMPP Session with PHP.",
|
||||
"version": "0.1.0",
|
||||
"type": "library",
|
||||
"keywords": ["xmpp", "php", "prebind"],
|
||||
"homepage": "http://jolicode.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michael Weibel"
|
||||
},
|
||||
{
|
||||
"name": "piotr",
|
||||
"email": "hello@piotr.cz"
|
||||
},
|
||||
{
|
||||
"name": "Alex Knol",
|
||||
"email": "alex@cobrowser.net"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": ["lib/"]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3",
|
||||
"lib-libxml": "*"
|
||||
}
|
||||
}
|
30
css/converse.min.css
vendored
Normal file
30
css/converse.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
33
konvos.php
Normal file
33
konvos.php
Normal file
@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js" type="text/javascript"></script>
|
||||
<style>
|
||||
.hiddenRow { display: none; }
|
||||
</style>
|
||||
<script>
|
||||
function toggleNextRow(row) {
|
||||
var nextRow = $(row).next();
|
||||
nextRow.toggle();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<table width='275' cellspacing='0' cellpadding='1'>
|
||||
<tr onclick="toggleNextRow(this)" BGCOLOR='#0066FF'>
|
||||
<th style='text-align: left;'><font color='white'>Konvos Status</font></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td BGCOLOR='#FFFFFF'>
|
||||
<table id='konvostable' width='275' border='0' cellspacing='0' cellpadding='1'><thead><tr onclick='togglebodyServers()' BGCOLOR='#0066FF'><th style='text-align: left;'><font color='white'>User</font></th><th style='text-align: left;'><font color='white'>Status</font></th></tr></thead>
|
||||
<tbody><td BGCOLOR='#FFFFFF'>Karl</td><td BGCOLOR='#FFFFFF'><?php require "http://konvos.cf:5280/status/karl/html"; ?></td></tr>
|
||||
<tbody><td BGCOLOR='#FFFFFF'>Duly</td><td BGCOLOR='#FFFFFF'><?php require "http://konvos.cf:5280/status/duly/html"; ?></td></tr>
|
||||
<tbody><td BGCOLOR='#FFFFFF'>Darren</td><td BGCOLOR='#FFFFFF'><?php require "http://konvos.cf:5280/status/darren/html"; ?></td></tr>
|
||||
<tbody><td BGCOLOR='#FFFFFF'>Kris</td><td BGCOLOR='#FFFFFF'><?php require "http://konvos.cf:5280/status/kris/html"; ?></td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<div id="clockbox" style="font:12pt Arial; color:#0066FF;"></div>
|
||||
</select>
|
||||
</form>
|
||||
</td>
|
||||
</table>
|
103
lib/Auth/SASL.php
Normal file
103
lib/Auth/SASL.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Client implementation of various SASL mechanisms
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.1
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
require_once(dirname(__FILE__) . '/SASL/Exception.php');
|
||||
|
||||
class Auth_SASL
|
||||
{
|
||||
/**
|
||||
* Factory class. Returns an object of the request
|
||||
* type.
|
||||
*
|
||||
* @param string $type One of: Anonymous
|
||||
* Plain
|
||||
* CramMD5
|
||||
* DigestMD5
|
||||
* Types are not case sensitive
|
||||
*/
|
||||
public static function factory($type)
|
||||
{
|
||||
switch (strtolower($type)) {
|
||||
case 'anonymous':
|
||||
$filename = 'SASL/Anonymous.php';
|
||||
$classname = 'Auth_SASL_Anonymous';
|
||||
break;
|
||||
|
||||
case 'login':
|
||||
$filename = 'SASL/Login.php';
|
||||
$classname = 'Auth_SASL_Login';
|
||||
break;
|
||||
|
||||
case 'plain':
|
||||
$filename = 'SASL/Plain.php';
|
||||
$classname = 'Auth_SASL_Plain';
|
||||
break;
|
||||
|
||||
case 'external':
|
||||
$filename = 'SASL/External.php';
|
||||
$classname = 'Auth_SASL_External';
|
||||
break;
|
||||
|
||||
case 'cram-md5':
|
||||
$filename = 'SASL/CramMD5.php';
|
||||
$classname = 'Auth_SASL_CramMD5';
|
||||
break;
|
||||
|
||||
case 'digest-md5':
|
||||
$filename = 'SASL/DigestMD5.php';
|
||||
$classname = 'Auth_SASL_DigestMD5';
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Auth_SASL_Exception('Invalid SASL mechanism type ("' . $type .'")');
|
||||
break;
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__) . '/' . $filename);
|
||||
$obj = new $classname();
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
71
lib/Auth/SASL/Anonymous.php
Normal file
71
lib/Auth/SASL/Anonymous.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Implmentation of ANONYMOUS SASL mechanism
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.1
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_Anonymous extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Not much to do here except return the token supplied.
|
||||
* No encoding, hashing or encryption takes place for this
|
||||
* mechanism, simply one of:
|
||||
* o An email address
|
||||
* o An opaque string not containing "@" that can be interpreted
|
||||
* by the sysadmin
|
||||
* o Nothing
|
||||
*
|
||||
* We could have some logic here for the second option, but this
|
||||
* would by no means create something interpretable.
|
||||
*
|
||||
* @param string $token Optional email address or string to provide
|
||||
* as trace information.
|
||||
* @return string The unaltered input token
|
||||
*/
|
||||
public function getResponse($token = '')
|
||||
{
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
?>
|
76
lib/Auth/SASL/Common.php
Normal file
76
lib/Auth/SASL/Common.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Common functionality to SASL mechanisms
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.1
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Exception.php');
|
||||
|
||||
class Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Function which implements HMAC MD5 digest
|
||||
*
|
||||
* @param string $key The secret key
|
||||
* @param string $data The data to protect
|
||||
* @return string The HMAC MD5 digest
|
||||
*/
|
||||
protected function HMAC_MD5($key, $data)
|
||||
{
|
||||
if (strlen($key) > 64) {
|
||||
$key = pack('H32', md5($key));
|
||||
}
|
||||
|
||||
if (strlen($key) < 64) {
|
||||
$key = str_pad($key, 64, chr(0));
|
||||
}
|
||||
|
||||
$k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64);
|
||||
$k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64);
|
||||
|
||||
$inner = pack('H32', md5($k_ipad . $data));
|
||||
$digest = md5($k_opad . $inner);
|
||||
|
||||
return $digest;
|
||||
}
|
||||
}
|
||||
?>
|
68
lib/Auth/SASL/CramMD5.php
Normal file
68
lib/Auth/SASL/CramMD5.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Implmentation of CRAM-MD5 SASL mechanism
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.1
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_CramMD5 extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Implements the CRAM-MD5 SASL mechanism
|
||||
* This DOES NOT base64 encode the return value,
|
||||
* you will need to do that yourself.
|
||||
*
|
||||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
* @param string $challenge The challenge supplied by the server.
|
||||
* this should be already base64_decoded.
|
||||
*
|
||||
* @return string The string to pass back to the server, of the form
|
||||
* "<user> <digest>". This is NOT base64_encoded.
|
||||
*/
|
||||
public function getResponse($user, $pass, $challenge)
|
||||
{
|
||||
return $user . ' ' . $this->HMAC_MD5($pass, $challenge);
|
||||
}
|
||||
}
|
||||
?>
|
197
lib/Auth/SASL/DigestMD5.php
Normal file
197
lib/Auth/SASL/DigestMD5.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Implmentation of DIGEST-MD5 SASL mechanism
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.1
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_DigestMD5 extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Provides the (main) client response for DIGEST-MD5
|
||||
* requires a few extra parameters than the other
|
||||
* mechanisms, which are unavoidable.
|
||||
*
|
||||
* @param string $authcid Authentication id (username)
|
||||
* @param string $pass Password
|
||||
* @param string $challenge The digest challenge sent by the server
|
||||
* @param string $hostname The hostname of the machine you're connecting to
|
||||
* @param string $service The servicename (eg. imap, pop, acap etc)
|
||||
* @param string $authzid Authorization id (username to proxy as)
|
||||
* @return string The digest response (NOT base64 encoded)
|
||||
* @access public
|
||||
*/
|
||||
public function getResponse($authcid, $pass, $challenge, $hostname, $service, $authzid = '')
|
||||
{
|
||||
$challenge = $this->parseChallenge($challenge);
|
||||
$authzid_string = '';
|
||||
if ($authzid != '') {
|
||||
$authzid_string = ',authzid="' . $authzid . '"';
|
||||
}
|
||||
|
||||
if (!empty($challenge)) {
|
||||
$cnonce = $this->getCnonce();
|
||||
$digest_uri = sprintf('%s/%s', $service, $hostname);
|
||||
$response_value = $this->getResponseValue($authcid, $pass, $challenge['realm'], $challenge['nonce'], $cnonce, $digest_uri, $authzid);
|
||||
|
||||
if ($challenge['realm']) {
|
||||
return sprintf('username="%s",realm="%s"' . $authzid_string .
|
||||
',nonce="%s",cnonce="%s",nc=00000001,qop=auth,digest-uri="%s",response=%s,maxbuf=%d', $authcid, $challenge['realm'], $challenge['nonce'], $cnonce, $digest_uri, $response_value, $challenge['maxbuf']);
|
||||
} else {
|
||||
return sprintf('username="%s"' . $authzid_string . ',nonce="%s",cnonce="%s",nc=00000001,qop=auth,digest-uri="%s",response=%s,maxbuf=%d', $authcid, $challenge['nonce'], $cnonce, $digest_uri, $response_value, $challenge['maxbuf']);
|
||||
}
|
||||
} else {
|
||||
throw new Auth_SASL_Exception('Invalid digest challenge');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses and verifies the digest challenge*
|
||||
*
|
||||
* @param string $challenge The digest challenge
|
||||
* @return array The parsed challenge as an assoc
|
||||
* array in the form "directive => value".
|
||||
* @access private
|
||||
*/
|
||||
private function parseChallenge($challenge)
|
||||
{
|
||||
$tokens = array();
|
||||
while (preg_match('/^([a-z-]+)=("[^"]+(?<!\\\)"|[^,]+)/i', $challenge, $matches)) {
|
||||
|
||||
// Ignore these as per rfc2831
|
||||
if ($matches[1] == 'opaque' OR $matches[1] == 'domain') {
|
||||
$challenge = substr($challenge, strlen($matches[0]) + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Allowed multiple "realm" and "auth-param"
|
||||
if (!empty($tokens[$matches[1]]) AND ($matches[1] == 'realm' OR $matches[1] == 'auth-param')) {
|
||||
if (is_array($tokens[$matches[1]])) {
|
||||
$tokens[$matches[1]][] = preg_replace('/^"(.*)"$/', '\\1', $matches[2]);
|
||||
} else {
|
||||
$tokens[$matches[1]] = array($tokens[$matches[1]], preg_replace('/^"(.*)"$/', '\\1', $matches[2]));
|
||||
}
|
||||
|
||||
// Any other multiple instance = failure
|
||||
} elseif (!empty($tokens[$matches[1]])) {
|
||||
$tokens = array();
|
||||
break;
|
||||
|
||||
} else {
|
||||
$tokens[$matches[1]] = preg_replace('/^"(.*)"$/', '\\1', $matches[2]);
|
||||
}
|
||||
|
||||
// Remove the just parsed directive from the challenge
|
||||
$challenge = substr($challenge, strlen($matches[0]) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defaults and required directives
|
||||
*/
|
||||
// Realm
|
||||
if (empty($tokens['realm'])) {
|
||||
$tokens['realm'] = "";
|
||||
}
|
||||
|
||||
// Maxbuf
|
||||
if (empty($tokens['maxbuf'])) {
|
||||
$tokens['maxbuf'] = 65536;
|
||||
}
|
||||
|
||||
// Required: nonce, algorithm
|
||||
if (empty($tokens['nonce']) OR empty($tokens['algorithm'])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the response= part of the digest response
|
||||
*
|
||||
* @param string $authcid Authentication id (username)
|
||||
* @param string $pass Password
|
||||
* @param string $realm Realm as provided by the server
|
||||
* @param string $nonce Nonce as provided by the server
|
||||
* @param string $cnonce Client nonce
|
||||
* @param string $digest_uri The digest-uri= value part of the response
|
||||
* @param string $authzid Authorization id
|
||||
* @return string The response= part of the digest response
|
||||
* @access private
|
||||
*/
|
||||
private function getResponseValue($authcid, $pass, $realm, $nonce, $cnonce, $digest_uri, $authzid = '')
|
||||
{
|
||||
if ($authzid == '') {
|
||||
$A1 = sprintf('%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $authcid, $realm, $pass))), $nonce, $cnonce);
|
||||
} else {
|
||||
$A1 = sprintf('%s:%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $authcid, $realm, $pass))), $nonce, $cnonce, $authzid);
|
||||
}
|
||||
$A2 = 'AUTHENTICATE:' . $digest_uri;
|
||||
return md5(sprintf('%s:%s:00000001:%s:auth:%s', md5($A1), $nonce, $cnonce, md5($A2)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the client nonce for the response
|
||||
*
|
||||
* @return string The cnonce value
|
||||
* @access private
|
||||
*/
|
||||
private function getCnonce()
|
||||
{
|
||||
if (file_exists('/dev/urandom') && $fd = fopen('/dev/urandom', 'r')) {
|
||||
return base64_encode(fread($fd, 32));
|
||||
|
||||
} elseif (file_exists('/dev/random') && $fd = fopen('/dev/random', 'r')) {
|
||||
return base64_encode(fread($fd, 32));
|
||||
|
||||
} else {
|
||||
$str = '';
|
||||
for ($i=0; $i<32; $i++) {
|
||||
$str .= chr(mt_rand(0, 255));
|
||||
}
|
||||
|
||||
return base64_encode($str);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
37
lib/Auth/SASL/Exception.php
Normal file
37
lib/Auth/SASL/Exception.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* o 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.
|
||||
* o The names of the authors may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auth SASL Exception
|
||||
*
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com>
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
class Auth_SASL_Exception extends Exception {}
|
63
lib/Auth/SASL/External.php
Normal file
63
lib/Auth/SASL/External.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2008 Christoph Schulz |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Christoph Schulz <develop@kristov.de> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Implmentation of EXTERNAL SASL mechanism
|
||||
*
|
||||
* @author Christoph Schulz <develop@kristov.de>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0.4
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_External extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Returns EXTERNAL response
|
||||
*
|
||||
* @param string $authcid Authentication id (username)
|
||||
* @param string $pass Password
|
||||
* @param string $authzid Autorization id
|
||||
* @return string EXTERNAL Response
|
||||
*/
|
||||
public function getResponse($authcid, $pass, $authzid = '')
|
||||
{
|
||||
return $authzid;
|
||||
}
|
||||
}
|
||||
?>
|
65
lib/Auth/SASL/Login.php
Normal file
65
lib/Auth/SASL/Login.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* This is technically not a SASL mechanism, however
|
||||
* it's used by Net_Sieve, Net_Cyrus and potentially
|
||||
* other protocols , so here is a good place to abstract
|
||||
* it.
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_Login extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Pseudo SASL LOGIN mechanism
|
||||
*
|
||||
* @param string $user Username
|
||||
* @param string $pass Password
|
||||
* @return string LOGIN string
|
||||
*/
|
||||
public function getResponse($user, $pass)
|
||||
{
|
||||
return sprintf('LOGIN %s %s', $user, $pass);
|
||||
}
|
||||
}
|
||||
?>
|
63
lib/Auth/SASL/Plain.php
Normal file
63
lib/Auth/SASL/Plain.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Copyright (c) 2002-2003 Richard Heyes |
|
||||
// | All rights reserved. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | o Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | o 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.|
|
||||
// | o The names of the authors may not be used to endorse or promote |
|
||||
// | products derived from this software without specific prior written |
|
||||
// | permission. |
|
||||
// | |
|
||||
// | 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. |
|
||||
// | |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Author: Richard Heyes <richard@php.net> |
|
||||
// +-----------------------------------------------------------------------+
|
||||
//
|
||||
|
||||
/**
|
||||
* Implmentation of PLAIN SASL mechanism
|
||||
*
|
||||
* @author Richard Heyes <richard@php.net>
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com> (made it work for PHP5)
|
||||
* @access public
|
||||
* @version 1.0
|
||||
* @package Auth_SASL
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/Common.php');
|
||||
|
||||
class Auth_SASL_Plain extends Auth_SASL_Common
|
||||
{
|
||||
/**
|
||||
* Returns PLAIN response
|
||||
*
|
||||
* @param string $authcid Authentication id (username)
|
||||
* @param string $pass Password
|
||||
* @param string $authzid Autorization id
|
||||
* @return string PLAIN Response
|
||||
*/
|
||||
public function getResponse($authcid, $pass, $authzid = '')
|
||||
{
|
||||
return $authzid . chr(0) . $authcid . chr(0) . $pass;
|
||||
}
|
||||
}
|
||||
?>
|
1784
lib/FirePHP/FirePHP.class.php
Normal file
1784
lib/FirePHP/FirePHP.class.php
Normal file
File diff suppressed because it is too large
Load Diff
29
lib/FirePHP/LICENSE
Normal file
29
lib/FirePHP/LICENSE
Normal file
@ -0,0 +1,29 @@
|
||||
Software License Agreement (New BSD License)
|
||||
|
||||
Copyright (c) 2006-2009, Christoph Dorn
|
||||
All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
* Neither the name of Christoph Dorn nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
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.
|
276
lib/FirePHP/fb.php
Normal file
276
lib/FirePHP/fb.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
*
|
||||
* This file is part of FirePHP (http://www.firephp.org/).
|
||||
*
|
||||
* Software License Agreement (New BSD License)
|
||||
*
|
||||
* Copyright (c) 2006-2010, Christoph Dorn
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* * Neither the name of Christoph Dorn nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*
|
||||
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
||||
* @author Christoph Dorn <christoph@christophdorn.com>
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* @package FirePHPCore
|
||||
*/
|
||||
|
||||
if(!class_exists('FirePHP')) {
|
||||
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the given data to the FirePHP Firefox Extension.
|
||||
* The data can be displayed in the Firebug Console or in the
|
||||
* "Server" request tab.
|
||||
*
|
||||
* @see http://www.firephp.org/Wiki/Reference/Fb
|
||||
* @param mixed $Object
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
function fb()
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($instance,'fb'),$args);
|
||||
}
|
||||
|
||||
|
||||
class FB
|
||||
{
|
||||
/**
|
||||
* Enable and disable logging to Firebug
|
||||
*
|
||||
* @see FirePHP->setEnabled()
|
||||
* @param boolean $Enabled TRUE to enable, FALSE to disable
|
||||
* @return void
|
||||
*/
|
||||
public static function setEnabled($Enabled)
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
$instance->setEnabled($Enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if logging is enabled
|
||||
*
|
||||
* @see FirePHP->getEnabled()
|
||||
* @return boolean TRUE if enabled
|
||||
*/
|
||||
public static function getEnabled()
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
return $instance->getEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a filter to be used when encoding an object
|
||||
*
|
||||
* Filters are used to exclude object members.
|
||||
*
|
||||
* @see FirePHP->setObjectFilter()
|
||||
* @param string $Class The class name of the object
|
||||
* @param array $Filter An array or members to exclude
|
||||
* @return void
|
||||
*/
|
||||
public static function setObjectFilter($Class, $Filter)
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
$instance->setObjectFilter($Class, $Filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set some options for the library
|
||||
*
|
||||
* @see FirePHP->setOptions()
|
||||
* @param array $Options The options to be set
|
||||
* @return void
|
||||
*/
|
||||
public static function setOptions($Options)
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
$instance->setOptions($Options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options for the library
|
||||
*
|
||||
* @see FirePHP->getOptions()
|
||||
* @return array The options
|
||||
*/
|
||||
public static function getOptions()
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
return $instance->getOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log object to firebug
|
||||
*
|
||||
* @see http://www.firephp.org/Wiki/Reference/Fb
|
||||
* @param mixed $Object
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function send()
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array($instance,'fb'),$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a group for following messages
|
||||
*
|
||||
* Options:
|
||||
* Collapsed: [true|false]
|
||||
* Color: [#RRGGBB|ColorName]
|
||||
*
|
||||
* @param string $Name
|
||||
* @param array $Options OPTIONAL Instructions on how to log the group
|
||||
* @return true
|
||||
*/
|
||||
public static function group($Name, $Options=null)
|
||||
{
|
||||
$instance = FirePHP::getInstance(true);
|
||||
return $instance->group($Name, $Options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends a group you have started before
|
||||
*
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function groupEnd()
|
||||
{
|
||||
return self::send(null, null, FirePHP::GROUP_END);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log object with label to firebug console
|
||||
*
|
||||
* @see FirePHP::LOG
|
||||
* @param mixes $Object
|
||||
* @param string $Label
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function log($Object, $Label=null)
|
||||
{
|
||||
return self::send($Object, $Label, FirePHP::LOG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log object with label to firebug console
|
||||
*
|
||||
* @see FirePHP::INFO
|
||||
* @param mixes $Object
|
||||
* @param string $Label
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function info($Object, $Label=null)
|
||||
{
|
||||
return self::send($Object, $Label, FirePHP::INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log object with label to firebug console
|
||||
*
|
||||
* @see FirePHP::WARN
|
||||
* @param mixes $Object
|
||||
* @param string $Label
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function warn($Object, $Label=null)
|
||||
{
|
||||
return self::send($Object, $Label, FirePHP::WARN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log object with label to firebug console
|
||||
*
|
||||
* @see FirePHP::ERROR
|
||||
* @param mixes $Object
|
||||
* @param string $Label
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function error($Object, $Label=null)
|
||||
{
|
||||
return self::send($Object, $Label, FirePHP::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps key and variable to firebug server panel
|
||||
*
|
||||
* @see FirePHP::DUMP
|
||||
* @param string $Key
|
||||
* @param mixed $Variable
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function dump($Key, $Variable)
|
||||
{
|
||||
return self::send($Variable, $Key, FirePHP::DUMP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a trace in the firebug console
|
||||
*
|
||||
* @see FirePHP::TRACE
|
||||
* @param string $Label
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function trace($Label)
|
||||
{
|
||||
return self::send($Label, FirePHP::TRACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a table in the firebug console
|
||||
*
|
||||
* @see FirePHP::TABLE
|
||||
* @param string $Label
|
||||
* @param string $Table
|
||||
* @return true
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function table($Label, $Table)
|
||||
{
|
||||
return self::send($Table, $Label, FirePHP::TABLE);
|
||||
}
|
||||
|
||||
}
|
682
lib/XmppPrebind.php
Normal file
682
lib/XmppPrebind.php
Normal file
@ -0,0 +1,682 @@
|
||||
<?php
|
||||
/**
|
||||
* XMPP Prebind for PHP
|
||||
*
|
||||
* @copyright 2011 Amiado Group AG
|
||||
* @author Michael Weibel <michael.weibel@amiadogroup.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* FirePHP for debugging
|
||||
*/
|
||||
include 'FirePHP/fb.php';
|
||||
|
||||
/**
|
||||
* PEAR Auth_SASL
|
||||
*/
|
||||
require 'Auth/SASL.php';
|
||||
|
||||
/**
|
||||
* XMPP Library for connecting to jabber server & receiving sid and rid
|
||||
*/
|
||||
class XmppPrebind {
|
||||
|
||||
const XMLNS_BODY = 'http://jabber.org/protocol/httpbind';
|
||||
const XMLNS_BOSH = 'urn:xmpp:xbosh';
|
||||
const XMLNS_CLIENT = 'jabber:client';
|
||||
const XMLNS_SESSION = 'urn:ietf:params:xml:ns:xmpp-session';
|
||||
const XMLNS_BIND = 'urn:ietf:params:xml:ns:xmpp-bind';
|
||||
const XMLNS_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl';
|
||||
const XMLNS_VCARD = 'vcard-temp';
|
||||
|
||||
const XML_LANG = 'en';
|
||||
const CONTENT_TYPE = 'text/xml charset=utf-8';
|
||||
|
||||
const ENCRYPTION_PLAIN = 'PLAIN';
|
||||
const ENCRYPTION_DIGEST_MD5 = 'DIGEST-MD5';
|
||||
const ENCRYPTION_CRAM_MD5 = 'CRAM-MD5';
|
||||
|
||||
const SERVICE_NAME = 'xmpp';
|
||||
|
||||
protected $jabberHost = '';
|
||||
protected $boshUri = '';
|
||||
protected $resource = '';
|
||||
|
||||
protected $debug = false;
|
||||
/**
|
||||
* FirePHP Instance
|
||||
*
|
||||
* @var FirePHP
|
||||
*/
|
||||
protected $firePhp = null;
|
||||
|
||||
protected $useGzip = false;
|
||||
protected $useSsl = false;
|
||||
protected $encryption = self::ENCRYPTION_PLAIN;
|
||||
|
||||
protected $jid = '';
|
||||
protected $password = '';
|
||||
|
||||
protected $rid = '';
|
||||
protected $sid = '';
|
||||
|
||||
protected $doSession = false;
|
||||
protected $doBind = false;
|
||||
|
||||
protected $mechanisms = array();
|
||||
|
||||
// the Bosh attributes for use in a client using this prebound session
|
||||
protected $wait;
|
||||
protected $requests;
|
||||
protected $ver;
|
||||
protected $polling;
|
||||
protected $inactivity;
|
||||
protected $hold;
|
||||
protected $to;
|
||||
protected $ack;
|
||||
protected $accept;
|
||||
protected $maxpause;
|
||||
|
||||
/**
|
||||
* Session creation response
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Create a new XmppPrebind Object with the required params
|
||||
*
|
||||
* @param string $jabberHost Jabber Server Host
|
||||
* @param string $boshUri Full URI to the http-bind
|
||||
* @param string $resource Resource identifier
|
||||
* @param bool $useSsl Use SSL (not working yet, TODO)
|
||||
* @param bool $debug Enable debug
|
||||
*/
|
||||
public function __construct($jabberHost, $boshUri, $resource, $useSsl = false, $debug = false) {
|
||||
$this->jabberHost = $jabberHost;
|
||||
$this->boshUri = $boshUri;
|
||||
$this->resource = $resource;
|
||||
|
||||
$this->useSsl = $useSsl;
|
||||
|
||||
$this->debug = $debug;
|
||||
if ($this->debug === true) {
|
||||
$this->firePhp = FirePHP::getInstance(true);
|
||||
$this->firePhp->setEnabled(true);
|
||||
}
|
||||
|
||||
/* TODO: Not working
|
||||
if (function_exists('gzinflate')) {
|
||||
$this->useGzip = true;
|
||||
}*/
|
||||
|
||||
/*
|
||||
* The client MUST generate a large, random, positive integer for the initial 'rid' (see Security Considerations)
|
||||
* and then increment that value by one for each subsequent request. The client MUST take care to choose an
|
||||
* initial 'rid' that will never be incremented above 9007199254740991 [21] within the session.
|
||||
* In practice, a session would have to be extraordinarily long (or involve the exchange of an extraordinary
|
||||
* number of packets) to exceed the defined limit.
|
||||
*
|
||||
* @link http://xmpp.org/extensions/xep-0124.html#rids
|
||||
*/
|
||||
if (function_exists('mt_rand')) {
|
||||
$this->rid = mt_rand(1000000000, 10000000000);
|
||||
} else {
|
||||
$this->rid = rand(1000000000, 10000000000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* connect to the jabber server with the supplied username & password
|
||||
*
|
||||
* @param string $username Username without jabber host
|
||||
* @param string $password Password
|
||||
* @param string $route Route
|
||||
*/
|
||||
public function connect($username, $password, $route = false) {
|
||||
$this->jid = $username . '@' . $this->jabberHost;
|
||||
|
||||
if($this->resource) {
|
||||
$this->jid .= '/' . $this->resource;
|
||||
}
|
||||
|
||||
$this->password = $password;
|
||||
|
||||
$response = $this->sendInitialConnection($route);
|
||||
if(empty($response)) {
|
||||
throw new XmppPrebindConnectionException("No response from server.");
|
||||
}
|
||||
|
||||
$body = self::getBodyFromXml($response);
|
||||
if ( empty( $body ) )
|
||||
throw new XmppPrebindConnectionException("No body could be found in response from server.");
|
||||
$this->sid = $body->getAttribute('sid');
|
||||
|
||||
// set the Bosh Attributes
|
||||
$this->wait = $body->getAttribute('wait');
|
||||
$this->requests = $body->getAttribute('requests');
|
||||
$this->ver = $body->getAttribute('ver');
|
||||
$this->polling = $body->getAttribute('polling');
|
||||
$this->inactivity = $body->getAttribute('inactivity');
|
||||
$this->hold = $body->getAttribute('hold');
|
||||
$this->to = $body->getAttribute('to');
|
||||
$this->accept = $body->getAttribute('accept');
|
||||
$this->maxpause = $body->getAttribute('maxpause');
|
||||
|
||||
$this->debug($this->sid, 'sid');
|
||||
|
||||
if(empty($body->firstChild) || empty($body->firstChild->firstChild)) {
|
||||
throw new XmppPrebindConnectionException("Child not found in response from server.");
|
||||
}
|
||||
$mechanisms = $body->getElementsByTagName('mechanism');
|
||||
|
||||
foreach ($mechanisms as $value) {
|
||||
$this->mechanisms[] = $value->nodeValue;
|
||||
}
|
||||
|
||||
if (in_array(self::ENCRYPTION_DIGEST_MD5, $this->mechanisms)) {
|
||||
$this->encryption = self::ENCRYPTION_DIGEST_MD5;
|
||||
} elseif (in_array(self::ENCRYPTION_CRAM_MD5, $this->mechanisms)) {
|
||||
$this->encryption = self::ENCRYPTION_CRAM_MD5;
|
||||
} elseif (in_array(self::ENCRYPTION_PLAIN, $this->mechanisms)) {
|
||||
$this->encryption = self::ENCRYPTION_PLAIN;
|
||||
} else {
|
||||
throw new XmppPrebindConnectionException("No encryption supported by the server is supported by this library.");
|
||||
}
|
||||
|
||||
$this->debug($this->encryption, 'encryption used');
|
||||
|
||||
// Assign session creation response
|
||||
$this->response = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to authenticate
|
||||
*
|
||||
* @throws XmppPrebindException if invalid login
|
||||
* @return bool
|
||||
*/
|
||||
public function auth() {
|
||||
$auth = Auth_SASL::factory($this->encryption);
|
||||
|
||||
switch ($this->encryption) {
|
||||
case self::ENCRYPTION_PLAIN:
|
||||
$authXml = $this->buildPlainAuth($auth);
|
||||
break;
|
||||
case self::ENCRYPTION_DIGEST_MD5:
|
||||
$authXml = $this->sendChallengeAndBuildDigestMd5Auth($auth);
|
||||
break;
|
||||
case self::ENCRYPTION_CRAM_MD5:
|
||||
$authXml = $this->sendChallengeAndBuildCramMd5Auth($auth);
|
||||
break;
|
||||
}
|
||||
$response = $this->send($authXml);
|
||||
|
||||
$body = self::getBodyFromXml($response);
|
||||
|
||||
if (!$body->hasChildNodes() || $body->firstChild->nodeName !== 'success') {
|
||||
throw new XmppPrebindException("Invalid login");
|
||||
}
|
||||
|
||||
$this->sendRestart();
|
||||
$this->sendBindIfRequired();
|
||||
$this->sendSessionIfRequired();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BOSH parameters to properly setup the BOSH client
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBoshInfo()
|
||||
{
|
||||
return array(
|
||||
'wait' => $this->wait,
|
||||
'requests' => $this->requests,
|
||||
'ver' => $this->ver,
|
||||
'polling' => $this->polling,
|
||||
'inactivity' => $this->inactivity,
|
||||
'hold' => $this->hold,
|
||||
'to' => $this->to,
|
||||
'ack' => $this->ack,
|
||||
'accept' => $this->accept,
|
||||
'maxpause' => $this->maxpause,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get jid, sid and rid for attaching
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSessionInfo() {
|
||||
return array('jid' => $this->jid, 'sid' => $this->sid, 'rid' => $this->rid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug if debug enabled
|
||||
*
|
||||
* @param string $msg
|
||||
* @param string $label
|
||||
*/
|
||||
protected function debug($msg, $label = null) {
|
||||
if ($this->firePhp) {
|
||||
$this->firePhp->log($msg, $label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send xmpp restart message after successful auth
|
||||
*
|
||||
* @return string Response
|
||||
*/
|
||||
protected function sendRestart() {
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'to', $this->jabberHost));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'xmlns:xmpp', self::XMLNS_BOSH));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'xmpp:restart', 'true'));
|
||||
|
||||
$restartResponse = $this->send($domDocument->saveXML());
|
||||
|
||||
$restartBody = self::getBodyFromXml($restartResponse);
|
||||
foreach ($restartBody->childNodes as $bodyChildNodes) {
|
||||
if ($bodyChildNodes->nodeName === 'stream:features') {
|
||||
foreach ($bodyChildNodes->childNodes as $streamFeatures) {
|
||||
if ($streamFeatures->nodeName === 'bind') {
|
||||
$this->doBind = true;
|
||||
} elseif ($streamFeatures->nodeName === 'session') {
|
||||
$this->doSession = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $restartResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send xmpp bind message after restart
|
||||
*
|
||||
* @return string Response
|
||||
*/
|
||||
protected function sendBindIfRequired() {
|
||||
if ($this->doBind) {
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$iq = $domDocument->createElement('iq');
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_CLIENT));
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'type', 'set'));
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'id', 'bind_' . rand()));
|
||||
|
||||
$bind = $domDocument->createElement('bind');
|
||||
$bind->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_BIND));
|
||||
|
||||
$resource = $domDocument->createElement('resource');
|
||||
$resource->appendChild($domDocument->createTextNode($this->resource));
|
||||
|
||||
$bind->appendChild($resource);
|
||||
$iq->appendChild($bind);
|
||||
$body->appendChild($iq);
|
||||
|
||||
return $this->send($domDocument->saveXML());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send session if there's a session node in the restart response (within stream:features)
|
||||
*/
|
||||
protected function sendSessionIfRequired() {
|
||||
if ($this->doSession) {
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$iq = $domDocument->createElement('iq');
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_CLIENT));
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'type', 'set'));
|
||||
$iq->appendChild(self::getNewTextAttribute($domDocument, 'id', 'session_auth_' . rand()));
|
||||
|
||||
$session = $domDocument->createElement('session');
|
||||
$session->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SESSION));
|
||||
|
||||
$iq->appendChild($session);
|
||||
$body->appendChild($iq);
|
||||
|
||||
return $this->send($domDocument->saveXML());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send initial connection string
|
||||
*
|
||||
* @param string $route
|
||||
* @return string Response
|
||||
*/
|
||||
protected function sendInitialConnection($route = false) {
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$waitTime = 60;
|
||||
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'hold', '1'));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'to', $this->jabberHost));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'xmlns:xmpp', self::XMLNS_BOSH));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'xmpp:version', '1.0'));
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'wait', $waitTime));
|
||||
|
||||
if ($route)
|
||||
{
|
||||
$body->appendChild(self::getNewTextAttribute($domDocument, 'route', $route));
|
||||
}
|
||||
|
||||
return $this->send($domDocument->saveXML());
|
||||
}
|
||||
|
||||
/**
|
||||
* Send challenge request
|
||||
*
|
||||
* @return string Challenge
|
||||
*/
|
||||
protected function sendChallenge() {
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$auth = $domDocument->createElement('auth');
|
||||
$auth->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
|
||||
$auth->appendChild(self::getNewTextAttribute($domDocument, 'mechanism', $this->encryption));
|
||||
$body->appendChild($auth);
|
||||
|
||||
$response = $this->send($domDocument->saveXML());
|
||||
|
||||
$body = $this->getBodyFromXml($response);
|
||||
$challenge = base64_decode($body->firstChild->nodeValue);
|
||||
|
||||
return $challenge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build PLAIN auth string
|
||||
*
|
||||
* @param Auth_SASL_Common $auth
|
||||
* @return string Auth XML to send
|
||||
*/
|
||||
protected function buildPlainAuth(Auth_SASL_Common $auth) {
|
||||
$authString = $auth->getResponse(self::getNodeFromJid($this->jid), $this->password, self::getBareJidFromJid($this->jid));
|
||||
$authString = base64_encode($authString);
|
||||
$this->debug($authString, 'PLAIN Auth String');
|
||||
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$auth = $domDocument->createElement('auth');
|
||||
$auth->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
|
||||
$auth->appendChild(self::getNewTextAttribute($domDocument, 'mechanism', $this->encryption));
|
||||
$auth->appendChild($domDocument->createTextNode($authString));
|
||||
$body->appendChild($auth);
|
||||
|
||||
return $domDocument->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send challenge request and build DIGEST-MD5 auth string
|
||||
*
|
||||
* @param Auth_SASL_Common $auth
|
||||
* @return string Auth XML to send
|
||||
*/
|
||||
protected function sendChallengeAndBuildDigestMd5Auth(Auth_SASL_Common $auth) {
|
||||
$challenge = $this->sendChallenge();
|
||||
|
||||
$authString = $auth->getResponse(self::getNodeFromJid($this->jid), $this->password, $challenge, $this->jabberHost, self::SERVICE_NAME);
|
||||
$this->debug($authString, 'DIGEST-MD5 Auth String');
|
||||
|
||||
$authString = base64_encode($authString);
|
||||
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$response = $domDocument->createElement('response');
|
||||
$response->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
|
||||
$response->appendChild($domDocument->createTextNode($authString));
|
||||
|
||||
$body->appendChild($response);
|
||||
|
||||
|
||||
$challengeResponse = $this->send($domDocument->saveXML());
|
||||
|
||||
return $this->replyToChallengeResponse($challengeResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send challenge request and build CRAM-MD5 auth string
|
||||
*
|
||||
* @param Auth_SASL_Common $auth
|
||||
* @return string Auth XML to send
|
||||
*/
|
||||
protected function sendChallengeAndBuildCramMd5Auth(Auth_SASL_Common $auth) {
|
||||
$challenge = $this->sendChallenge();
|
||||
|
||||
$authString = $auth->getResponse(self::getNodeFromJid($this->jid), $this->password, $challenge);
|
||||
$this->debug($authString, 'CRAM-MD5 Auth String');
|
||||
|
||||
$authString = base64_encode($authString);
|
||||
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
|
||||
$response = $domDocument->createElement('response');
|
||||
$response->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
|
||||
$response->appendChild($domDocument->createTextNode($authString));
|
||||
|
||||
$body->appendChild($response);
|
||||
|
||||
$challengeResponse = $this->send($domDocument->saveXML());
|
||||
|
||||
return $this->replyToChallengeResponse($challengeResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* CRAM-MD5 and DIGEST-MD5 reply with an additional challenge response which must be replied to.
|
||||
* After this additional reply, the server should reply with "success".
|
||||
*/
|
||||
protected function replyToChallengeResponse($challengeResponse) {
|
||||
$body = self::getBodyFromXml($challengeResponse);
|
||||
$challenge = base64_decode((string)$body->firstChild->nodeValue);
|
||||
if (strpos($challenge, 'rspauth') === false) {
|
||||
throw new XmppPrebindConnectionException('Invalid challenge response received');
|
||||
}
|
||||
|
||||
$domDocument = $this->buildBody();
|
||||
$body = self::getBodyFromDomDocument($domDocument);
|
||||
$response = $domDocument->createElement('response');
|
||||
$response->appendChild(self::getNewTextAttribute($domDocument, 'xmlns', self::XMLNS_SASL));
|
||||
|
||||
$body->appendChild($response);
|
||||
|
||||
return $domDocument->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send XML via CURL
|
||||
*
|
||||
* @param string $xml
|
||||
* @return string Response
|
||||
*/
|
||||
protected function send($xml) {
|
||||
$ch = curl_init($this->boshUri);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
$header = array('Content-Type: ' . self::CONTENT_TYPE);
|
||||
if ($this->useGzip) {
|
||||
$header[] = 'Accept-Encoding: gzip, deflate';
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check if curl failed to get response
|
||||
if ($response === false) {
|
||||
throw new XmppPrebindConnectionException("Cannot connect to service");
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($this->useGzip) {
|
||||
$response = self::compatibleGzInflate($response);
|
||||
}
|
||||
|
||||
$this->debug($xml, 'SENT');
|
||||
$this->debug($response, 'RECV:');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix gzdecompress/gzinflate data error warning.
|
||||
*
|
||||
* @link http://www.mydigitallife.info/2010/01/17/workaround-to-fix-php-warning-gzuncompress-or-gzinflate-data-error-in-wordpress-http-php/
|
||||
*
|
||||
* @param string $gzData
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function compatibleGzInflate($gzData) {
|
||||
if ( substr($gzData, 0, 3) == "\x1f\x8b\x08" ) {
|
||||
$i = 10;
|
||||
$flg = ord( substr($gzData, 3, 1) );
|
||||
if ( $flg > 0 ) {
|
||||
if ( $flg & 4 ) {
|
||||
list($xlen) = unpack('v', substr($gzData, $i, 2) );
|
||||
$i = $i + 2 + $xlen;
|
||||
}
|
||||
if ( $flg & 8 )
|
||||
$i = strpos($gzData, "\0", $i) + 1;
|
||||
if ( $flg & 16 )
|
||||
$i = strpos($gzData, "\0", $i) + 1;
|
||||
if ( $flg & 2 )
|
||||
$i = $i + 2;
|
||||
}
|
||||
return gzinflate( substr($gzData, $i, -8) );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build DOMDocument with standard xmpp body child node.
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
protected function buildBody() {
|
||||
$xml = new DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
$body = $xml->createElement('body');
|
||||
$xml->appendChild($body);
|
||||
|
||||
$body->appendChild(self::getNewTextAttribute($xml, 'xmlns', self::XMLNS_BODY));
|
||||
$body->appendChild(self::getNewTextAttribute($xml, 'content', self::CONTENT_TYPE));
|
||||
$body->appendChild(self::getNewTextAttribute($xml, 'rid', $this->getAndIncrementRid()));
|
||||
$body->appendChild(self::getNewTextAttribute($xml, 'xml:lang', self::XML_LANG));
|
||||
|
||||
if ($this->sid != '') {
|
||||
$body->appendChild(self::getNewTextAttribute($xml, 'sid', $this->sid));
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get jid in form of username@jabberHost
|
||||
*
|
||||
* @param string $jid Jid in form username@jabberHost/Resource
|
||||
* @return string JID
|
||||
*/
|
||||
public static function getBareJidFromJid($jid) {
|
||||
if ($jid == '') {
|
||||
return '';
|
||||
}
|
||||
$splittedJid = explode('/', $jid, 1);
|
||||
return $splittedJid[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get node (username) from jid
|
||||
*
|
||||
* @param string $jid
|
||||
* @return string Node
|
||||
*/
|
||||
public static function getNodeFromJid($jid) {
|
||||
$atPos = strpos($jid, '@');
|
||||
if ($atPos === false) {
|
||||
return '';
|
||||
}
|
||||
return substr($jid, 0, $atPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append new attribute to existing DOMDocument.
|
||||
*
|
||||
* @param DOMDocument $domDocument
|
||||
* @param string $attributeName
|
||||
* @param string $value
|
||||
* @return DOMNode
|
||||
*/
|
||||
protected static function getNewTextAttribute($domDocument, $attributeName, $value) {
|
||||
$attribute = $domDocument->createAttribute($attributeName);
|
||||
$attribute->appendChild($domDocument->createTextNode($value));
|
||||
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get body node from DOMDocument
|
||||
*
|
||||
* @param DOMDocument $domDocument
|
||||
* @return DOMNode
|
||||
*/
|
||||
protected static function getBodyFromDomDocument($domDocument) {
|
||||
$body = $domDocument->getElementsByTagName('body');
|
||||
return $body->item(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse XML and return DOMNode of the body
|
||||
*
|
||||
* @uses XmppPrebind::getBodyFromDomDocument()
|
||||
* @param string $xml
|
||||
* @return DOMNode
|
||||
*/
|
||||
protected static function getBodyFromXml($xml) {
|
||||
$domDocument = new DOMDocument();
|
||||
$domDocument->loadXml($xml);
|
||||
|
||||
return self::getBodyFromDomDocument($domDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rid and increment it by one.
|
||||
* Required by RFC
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getAndIncrementRid() {
|
||||
return $this->rid++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard XmppPrebind Exception
|
||||
*/
|
||||
class XmppPrebindException extends Exception{}
|
||||
|
||||
class XmppPrebindConnectionException extends XmppPrebindException{}
|
46
main.php
46
main.php
@ -7,6 +7,8 @@
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="white" href="css/white.css" />
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue" href="css/blue.css" />
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="red" href="css/red.css" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="css/converse.min.css">
|
||||
<script src="builds/converse.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload=function(){
|
||||
var formref=document.getElementById("switchform")
|
||||
@ -121,4 +123,48 @@ if ($squeezevisible > "0") {
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
require(['converse'], function (converse) {
|
||||
(function () {
|
||||
/* XXX: This function initializes jquery.easing for the https://conversejs.org
|
||||
* website. This code is only useful in the context of the converse.js
|
||||
* website and converse.js itself is NOT dependent on it.
|
||||
*/
|
||||
var $ = converse.env.jQuery;
|
||||
$.extend( $.easing, {
|
||||
easeInOutExpo: function (x, t, b, c, d) {
|
||||
if (t==0) return b;
|
||||
if (t==d) return b+c;
|
||||
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||
},
|
||||
});
|
||||
|
||||
$(window).scroll(function() {
|
||||
if ($(".navbar").offset().top > 50) {
|
||||
$(".navbar-fixed-top").addClass("top-nav-collapse");
|
||||
} else {
|
||||
$(".navbar-fixed-top").removeClass("top-nav-collapse");
|
||||
}
|
||||
});
|
||||
//jQuery for page scrolling feature - requires jQuery Easing plugin
|
||||
$('.page-scroll a').bind('click', function(event) {
|
||||
var $anchor = $(this);
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: $($anchor.attr('href')).offset().top
|
||||
}, 700, 'easeInOutExpo');
|
||||
event.preventDefault();
|
||||
});
|
||||
})();
|
||||
converse.initialize({
|
||||
bosh_service_url: 'https://konvos.cf:5281/http-bind', // Please use this connection manager only for testing purposes
|
||||
keepalive: true,
|
||||
message_carbons: true,
|
||||
play_sounds: true,
|
||||
roster_groups: true,
|
||||
show_controlbox_by_default: true,
|
||||
xhr_user_search: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</html>
|
@ -9,7 +9,6 @@
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue" href="css/blue.css" />
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="red" href="css/red.css" />
|
||||
<link rel="alternate stylesheet" type="text/css" media="screen" title="custom" href="css/custom.php" />
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload=function(){
|
||||
var formref=document.getElementById("switchform")
|
||||
@ -53,6 +52,14 @@ if ($clockvisible > "0") {
|
||||
require "clock.php";
|
||||
} else {
|
||||
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
if ($konvosvisible > "0") {
|
||||
require "konvos.php";
|
||||
} else {
|
||||
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user