Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/jabber/XMPP/XMPP_Old.php
Go to the documentation of this file.
00001 <?php
00036 require_once "XMPP.php";
00037 
00038         class XMPPHP_XMPPOld extends XMPPHP_XMPP {
00043                 protected $session_id;
00044 
00045                 public function __construct($host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null) {
00046                         parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);
00047                         if(!$server) $server = $host;
00048                         $this->stream_start = '<stream:stream to="' . $server . '" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">';
00049                         $this->fulljid = "{$user}@{$server}/{$resource}";
00050                 }
00051         
00059                 public function startXML($parser, $name, $attr) {
00060                         if($this->xml_depth == 0) {
00061                                 $this->session_id = $attr['ID'];
00062                                 $this->authenticate();
00063                         }
00064                         parent::startXML($parser, $name, $attr);
00065                 }
00066 
00071                 public function authenticate() {
00072                         $id = $this->getId();
00073                         $this->addidhandler($id, 'authfieldshandler');
00074                         $this->send("<iq type='get' id='$id'><query xmlns='jabber:iq:auth'><username>{$this->user}</username></query></iq>");
00075                 }
00076 
00082                 public function authFieldsHandler($xml) {
00083                         $id = $this->getId();
00084                         $this->addidhandler($id, 'oldAuthResultHandler');
00085                         if($xml->sub('query')->hasSub('digest')) {
00086                                 $hash = sha1($this->session_id . $this->password);
00087                                 print "{$this->session_id} {$this->password}\n";
00088                                 $out = "<iq type='set' id='$id'><query xmlns='jabber:iq:auth'><username>{$this->user}</username><digest>{$hash}</digest><resource>{$this->resource}</resource></query></iq>";
00089                         } else {
00090                                 $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>";
00091                         }
00092                         $this->send($out);
00093 
00094                 }
00095                 
00101                 public function oldAuthResultHandler($xml) {
00102                         if($xml->attrs['type'] != 'result') {
00103                                 $this->log->log("Auth failed!",  XMPPHP_Log::LEVEL_ERROR);
00104                                 $this->disconnect();
00105                                 throw new XMPPHP_Exception('Auth failed!');
00106                         } else {
00107                                 $this->log->log("Session started");
00108                                 $this->event('session_start');
00109                         }
00110                 }
00111         }
00112 
00113 
00114 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations