See Release Notes
Long Term Support Release
1 <?php 2 /** 3 * XMPPHP: The PHP XMPP Library 4 * Copyright (C) 2008 Nathanael C. Fritz 5 * This file is part of SleekXMPP. 6 * 7 * XMPPHP is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * XMPPHP is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with XMPPHP; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 * @category xmpphp 22 * @package XMPPHP 23 * @author Nathanael C. Fritz <JID: fritzy@netflint.net> 24 * @author Stephan Wentz <JID: stephan@jabber.wentz.it> 25 * @author Michael Garvin <JID: gar@netflint.net> 26 * @copyright 2008 Nathanael C. Fritz 27 */ 28 29 /** XMPPHP_XMPP 30 * 31 * This file is unnecessary unless you need to connect to older, non-XMPP-compliant servers like Dreamhost's. 32 * In this case, use instead of XMPPHP_XMPP, otherwise feel free to delete it. 33 * The old Jabber protocol wasn't standardized, so use at your own risk. 34 * 35 */ 36 require_once "XMPP.php"; 37 38 class XMPPHP_XMPPOld extends XMPPHP_XMPP { 39 /** 40 * 41 * @var string 42 */ 43 protected $session_id; 44 45 public function __construct($host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null) { 46 parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel); 47 if(!$server) $server = $host; 48 $this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">'; 49 $this->fulljid = "{$user}@{$server}/{$resource}"; 50 } 51 52 /** 53 * Override XMLStream's startXML 54 * 55 * @param parser $parser 56 * @param string $name 57 * @param array $attr 58 */ 59 public function startXML($parser, $name, $attr) { 60 if($this->xml_depth == 0) { 61 $this->session_id = $attr['ID']; 62 $this->authenticate(); 63 } 64 parent::startXML($parser, $name, $attr); 65 } 66 67 /** 68 * Send Authenticate Info Request 69 * 70 */ 71 public function authenticate() { 72 $id = $this->getId(); 73 $this->addidhandler($id, 'authfieldshandler'); 74 $this->send("<iq type='get' id='$id'><query xmlns='jabber:iq:auth'><username>{$this->user}</username></query></iq>"); 75 } 76 77 /** 78 * Retrieve auth fields and send auth attempt 79 * 80 * @param XMLObj $xml 81 */ 82 public function authFieldsHandler($xml) { 83 $id = $this->getId(); 84 $this->addidhandler($id, 'oldAuthResultHandler'); 85 if($xml->sub('query')->hasSub('digest')) { 86 $hash = sha1($this->session_id . $this->password); 87 print "{$this->session_id} {$this->password}\n"; 88 $out = "<iq type='set' id='$id'><query xmlns='jabber:iq:auth'><username>{$this->user}</username><digest>{$hash}</digest><resource>{$this->resource}</resource></query></iq>"; 89 } else { 90 $out = "<iq type='set' id='$id'><query xmlns='jabber:iq:auth'><username>{$this->user}</username><password>{$this->password}</password><resource>{$this->resource}</resource></query></iq>"; 91 } 92 $this->send($out); 93 94 } 95 96 /** 97 * Determine authenticated or failure 98 * 99 * @param XMLObj $xml 100 */ 101 public function oldAuthResultHandler($xml) { 102 if($xml->attrs['type'] != 'result') { 103 $this->log->log("Auth failed!", XMPPHP_Log::LEVEL_ERROR); 104 $this->disconnect(); 105 throw new XMPPHP_Exception('Auth failed!'); 106 } else { 107 $this->log->log("Session started"); 108 $this->event('session_start'); 109 } 110 } 111 } 112 113 114 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body