#!/usr/bin/php LISSY Alexandre, "lissyx" Permission is hereby granted, free of charge, to any person obtaining a copy of this software andassociated 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 thefollowing 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. */ // Modified for Wordpress by James Holding @ www.cubehouse.org $auth = new JabberAuth(); $auth->wp_dir = "/path/to/htdocs/"; // wordpress directory on server /path/to/htdocs/ (with trailing slash) $auth->wp_server = "http://www.example.com/"; // your webserver url http://www.example.com/ (with trailing slash) $auth->play(); class JabberAuth{ var $jabber_user; var $jabber_pass; var $jabber_server; var $jid; var $data; var $dateformat = "M d H:i:s"; var $command; var $mysock; var $stdin; var $stdout; var $wp_dir; var $wp_server; function JabberAuth(){ @define_syslog_variables(); $this->openstd(); } function stop(){ $this->closestd(); exit(0); } function openstd(){ $this->stdout = @fopen("php://stdout", "w"); $this->stdin = @fopen("php://stdin", "r"); } function readstdin(){ $l = @fgets($this->stdin, 3); $length = @unpack("n", $l); $len = $length["1"]; if($len > 0){ $data = @fgets($this->stdin, $len+1); $this->data = $data; } return 0; } function closestd(){ @fclose($this->stdin); @fclose($this->stdout); } function out($message){ @fwrite($this->stdout, $message); $dump = @unpack("nn", $message); $dump = $dump["n"]; } function play(){ do { $this->readstdin(); $length = strlen($this->data); $ret = $this->command(); $this->out($ret); $this->data = NULL; } while (true); } function command() { $data = $this->splitcomm(); switch($data[0]) { case "isuser": $this->jabber_user = $data[1]; $parms = $data[1]; $return = $this->checkuser(); break; case "auth": $this->jabber_user = $data[1]; $this->jabber_pass = $data[3]; $return = $this->checkpass(); break; case "setpass": $return = false; break; default: $this->stop(); break; } $return = ($return) ? 1 : 0; return @pack("nn", 2, $return); } function checkpass(){ include_once($this->wp_dir."wp-includes/class-IXR.php"); $client = new IXR_Client($this->wp_server.'xmlrpc.php'); if (!$client->query('xmpp.user_login', $this->jabber_user, $this->jabber_pass)){ return false; } return true; } function checkuser(){ include_once($this->wp_dir."wp-includes/class-IXR.php"); $client = new IXR_Client($this->wp_server.'xmlrpc.php'); if (!$client->query('xmpp.user_check', $this->jabber_user, "")){ return false; } return true; } function splitcomm(){ return explode(":", $this->data); } } ?>