Changeset 343
- Timestamp:
- 02/20/08 00:30:16 (16 years ago)
- Location:
- plugins/jabberNotifications
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/jabberNotifications/_public.php
r291 r343 3 3 * This is Jabber Notifications, a plugin for Dotclear 2 * 4 4 * * 5 * Copyright (c) 2007 5 * Copyright (c) 2007,2008 * 6 6 * Oleksandr Syenchuk, Olivier Tétard and contributors. * 7 7 * * … … 69 69 'pass'=>$core->blog->settings->jn_pass, 70 70 'port'=>$core->blog->settings->jn_port, 71 'con'=>$core->blog->settings->jn_con, 71 72 'gateway'=>$core->blog->settings->jn_gateway 72 73 ); 73 $j = new jabberNotifier($settings['serv'],$settings['port'],$settings['user'],$settings['pass'] );74 $j = new jabberNotifier($settings['serv'],$settings['port'],$settings['user'],$settings['pass'],$settings['con']); 74 75 75 76 $msg = html::decodeEntities(html::clean($cur->comment_content)); -
plugins/jabberNotifications/class.jabbernotifier.php
r291 r343 3 3 * This is Jabber Notifications, a plugin for Dotclear 2 * 4 4 * * 5 * Copyright (c) 2007 5 * Copyright (c) 2007,2008 * 6 6 * Oleksandr Syenchuk, Olivier Tétard and contributors. * 7 7 * * … … 29 29 public $done = false; 30 30 31 public function __construct($serv,$port,$user,$pass )31 public function __construct($serv,$port,$user,$pass,$con) 32 32 { 33 33 $this->serv = $serv; … … 36 36 $this->pass = $pass; 37 37 38 $this->j = new Jabber( );38 $this->j = new Jabber($serv,$port,$user,$pass,$con); 39 39 $this->messages = array(); 40 40 $this->status = 'init'; … … 64 64 } 65 65 } 66 67 66 68 67 public function commitThroughGateway($url) … … 94 93 $this->status = 'ok'; # Will be changed on error 95 94 96 if ($this->j->connect($t his->serv,$this->port,$timeout)) {95 if ($this->j->connect($timeout)) { 97 96 $this->j->execute($timeout); 98 97 if (!$this->done) { -
plugins/jabberNotifications/forms.php
r291 r343 1 1 <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 2 3 2 /***************************************************************\ 4 3 * This is Jabber Notifications, a plugin for Dotclear 2 * 5 4 * * 6 * Copyright (c) 2007 5 * Copyright (c) 2007,2008 * 7 6 * Oleksandr Syenchuk, Olivier Tétard and contributors. * 8 7 * * … … 40 39 __('Enable Jabber notifications').'</label></p> 41 40 42 <div id="jn_config"> 41 <div id="jn_config" class="two-cols"> 42 <div class="col"> 43 43 <p><label class="required">'.__('Username:').' '. 44 44 form::field('jn_user',20,255,html::escapeHTML($jn_user)).'</label></p> … … 51 51 <p><label>'.__('HTTP gateway (leave empty to disable):').' '. 52 52 form::field('jn_gateway',40,255,html::escapeHTML($jn_gateway)).'</label></p> 53 </div> 54 <p class="col">'.__('Secure connection:').'<br/>'. 55 form::radio(array('jn_con','jn_con1'),'',$jn_con == ''). 56 '<label class="classic" for="jn_con1"> '.__('None').'</label><br/>'. 57 form::radio(array('jn_con','jn_con2'),'ssl://',$jn_con == 'ssl://'). 58 '<label class="classic" for="jn_con2"> '.__('SSL').'</label><br/>'. 59 form::radio(array('jn_con','jn_con3'),'tls://',$jn_con == 'tls://'). 60 '<label class="classic" for="jn_con3"> '.__('TLS').'</label><br/>'. 61 '</p><br class="clear" /> 53 62 </div> 54 63 <p><input type="submit" name="jn_action_config" value="'.__('save').'" />'. … … 65 74 $jn_forms['help'] = ' 66 75 <h3>Passerelle HTTP</h3> 67 <p>Certains héb érgeurs (comme Free.fr) n\'autorisent pas les connexions sur le port 5222utilisé par les serveurs Jabber. Pour contourner ce problème, vous pouvez utiliser une passerelle HTTP.</p>76 <p>Certains hébergeurs (comme Free.fr) n\'autorisent pas les connexions sur le port 5222 qui est utilisé par les serveurs Jabber. Pour contourner ce problème, vous pouvez utiliser une passerelle HTTP.</p> 68 77 <p>La passerelle HTTP permet d\'envoyer les notifications Jabber à une page web (accessible généralement sur le port 80) qui se charge de la connexion XMPP pour vous.</p> 69 78 <h4>Considérations de sécurité</h4> -
plugins/jabberNotifications/index.php
r292 r343 1 1 <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 2 3 2 /***************************************************************\ 4 3 * This is Jabber Notifications, a plugin for Dotclear 2 * 5 4 * * 6 * Copyright (c) 2007 5 * Copyright (c) 2007,2008 * 7 6 * Oleksandr Syenchuk, Olivier Tétard and contributors. * 8 7 * * … … 29 28 30 29 // Vérification de l'installation 31 if ($core->blog->settings->jn_enab === null )32 { 33 $core->blog->settings->put('jn_serv','','string',' Server',true,true);30 if ($core->blog->settings->jn_enab === null || isset($_GET['reset'])) 31 { 32 $core->blog->settings->put('jn_serv','','string','Host',true,true); 34 33 $core->blog->settings->put('jn_port',5222,'integer','Port',true,true); 34 $core->blog->settings->put('jn_con','','string','Secure connection protocol',true,true); 35 35 $core->blog->settings->put('jn_user','','string','Username used to connect to the jabber server',true,true); 36 36 $core->blog->settings->put('jn_pass','','string','Password used to connect to the jabber server',true,true); … … 48 48 $jn_serv = $core->blog->settings->jn_serv; 49 49 $jn_port = $core->blog->settings->jn_port; 50 $jn_con = $core->blog->settings->jn_con; 50 51 $jn_gateway = $core->blog->settings->jn_gateway; 51 52 $jn_dest = ''; … … 68 69 $jn_serv = $_POST['jn_serv']; 69 70 $jn_port = $_POST['jn_port']; 71 $jn_con = $_POST['jn_con']; 70 72 $jn_gateway = $_POST['jn_gateway']; 71 73 $jn_dest = $_POST['jn_dest']; … … 103 105 $core->blog->settings->put('jn_serv',$jn_serv,null,null,true,true); 104 106 $core->blog->settings->put('jn_port',$jn_port,null,null,true,true); 107 $core->blog->settings->put('jn_con',$jn_con,null,null,true,true); 105 108 $core->blog->settings->put('jn_enab',true,null,null,true,true); 106 109 $core->blog->settings->put('jn_gateway',$jn_gateway,'string','HTTP Gateway',true); … … 114 117 elseif (isset($_POST['jn_action_test'])) { 115 118 $time = microtime(true); 116 $j = new jabberNotifier($jn_serv,$jn_port,$jn_user,$jn_pass );119 $j = new jabberNotifier($jn_serv,$jn_port,$jn_user,$jn_pass,$jn_con); 117 120 $j->setMessage('Jabber Notifications test. UNIX timestamp is '.time().' s.'); 118 121 $j->addDestination(explode(',',$jn_dest)); -
plugins/jabberNotifications/lib/class_ConnectionSocket.php
r271 r343 58 58 public $socket = null; 59 59 public $error = ''; 60 public $debug = false; 60 61 61 62 function socket_open($hostname,$port,$timeout) … … 79 80 function socket_write($data) 80 81 { 82 if ($this->debug) { 83 echo '=> '.$data."\n"; 84 } 81 85 return fwrite($this->socket,$data); 82 86 } … … 87 91 $buffer = fread($this->socket,$byte_count); 88 92 set_magic_quotes_runtime(get_magic_quotes_runtime()); 89 93 if ($this->debug && $buffer) { 94 echo '<= '.$buffer."\n"; 95 } 90 96 return $buffer; 91 97 } -
plugins/jabberNotifications/lib/class_Jabber.php
r291 r343 1 1 <?php 2 /* Jabber Client Library 3 * Version 0.8 2 /***************************************************************\ 3 * This is JabberMessage * 4 * * 5 * Copyright (c) 2008 * 6 * Oleksandr Syenchuk * 7 * * 8 * This is an open source software, distributed under the GNU * 9 * General Public License (version 2) terms and conditions. * 10 * * 11 * You should have received a copy of the GNU General Public * 12 * License along JabberMessage (see COPYING.txt); * 13 * if not, write to the Free Software Foundation, Inc., * 14 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 15 \***************************************************************/ 16 17 /* JabberMessage is based on 'Jabber Client Library', Version 0.8 4 18 * Copyright 2002-2005, eSite Media Inc. 5 19 * Portions Copyright 2002, Carlo Zottmann 6 20 * http://www.centova.com 7 * ============================================================================8 *9 * This file was contributed (in part or whole) by a third party, and is10 * released under the GNU LGPL. Please see the CREDITS and LICENSE sections11 * below for details.12 *13 *****************************************************************************14 *15 * DETAILS16 *17 * This is an event-driven Jabber client class implementation. This library18 * allows PHP scripts to connect to and communicate with Jabber servers.19 *20 *21 * CREDITS & COPYRIGHTS22 *23 * This class was originally based on Class.Jabber.PHP v0.4 (Copyright 2002,24 * Carlo "Gossip" Zottmann).25 *26 * The code for this class has since been nearly completely rewritten by Steve27 * Blinch for eSite Media Inc. All such modified code is Copyright 2002-2005,28 * eSite Media Inc.29 *30 * The original Class.Jabber.PHP was released under the GNU General Public31 * License (GPL); however, we have received written permission from the32 * original author and copyright holder, Carlo Zottmann, to relicense our33 * version of this class and release it under the GNU Lesser General Public34 * License (LGPL). This allows compatibility with Centova's35 * proprietary software license.36 *37 *38 * LICENSE39 *40 * class_Jabber.php - Jabber Client Library41 * Copyright (C) 2002-2005, eSite Media Inc.42 * Copyright (C) 2002, Carlo Zottmann43 *44 * This library is free software; you can redistribute it and/or modify it45 * under the terms of the GNU Lesser General Public License as published by the46 * Free Software Foundation; either version 2.1 of the License, or (at your47 * option) any later version.48 *49 * This library is distributed in the hope that it will be useful, but WITHOUT50 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or51 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License52 * for more details.53 *54 * You should have received a copy of the GNU Lesser General Public License55 * along with this library; if not, write to the Free Software Foundation,56 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA57 *58 *59 * JABBER is a registered trademark of Jabber Inc.60 *61 21 */ 62 22 … … 66 26 class Jabber 67 27 { 68 public $jid = '';69 28 public $use_msg_composing = true; 70 29 public $use_msg_delivered = false; … … 119 78 public $protocol_version = false; // set this to an XMPP protocol revision to include it in the <stream:stream> tag 120 79 121 public function __construct() 80 private $host; 81 private $port; 82 private $jid; 83 private $password; 84 85 private $username; 86 private $server; 87 private $con; 88 89 public function __construct($host,$port,$jid,$password,$con='') 122 90 { 123 91 $this->_unique_counter = 0; 124 125 92 $this->xml = new XMLParser(); 93 94 $this->host = $host; 95 $this->port = (int) $port; 96 $this->password = $password; 97 98 $pos = strpos($jid,'@'); 99 if ($pos === false) { 100 $this->jid = $jid.'@'.$this->host; 101 $this->server = $host; 102 $this->username = $jid; 103 } 104 else { 105 $this->jid = $jid; 106 $this->server = substr($jid,$pos+1); 107 $this->username = substr($jid,0,$pos); 108 } 109 110 if ($con !== '' && $con !== 'ssl://' && $con !== 'tls://') { 111 $con = ''; 112 } 113 $this->con = $con; 126 114 } 127 115 … … 207 195 // 208 196 // 209 function connect($server_host,$server_port=5222,$connect_timeout=null,$alternate_ip=false) { 210 211 if (is_null($connect_timeout)) $connect_timeout = 4; 197 function connect($con_timeout=4,$alternate_ip=false) 198 { 212 199 $connector = $this->_connector; 213 200 214 201 $this->_connection = new $connector(); 215 $this->_server_host = $ server_host;216 $this->_server_port = $ server_port;217 $this->_server_ip = $alternate_ip ? $alternate_ip : $ server_host;218 $this->_connect_timeout = $connect_timeout;202 $this->_server_host = $this->host; 203 $this->_server_port = $this->port; 204 $this->_server_ip = $alternate_ip ? $alternate_ip : $this->host; 205 $this->_connect_timeout = (int) $con_timeout; 219 206 220 207 $this->roster = array(); … … 228 215 229 216 function _connect_socket() { 230 if ($this->_connection->socket_open($this-> _server_ip,$this->_server_port,$this->_connect_timeout)) {217 if ($this->_connection->socket_open($this->con.$this->_server_ip,$this->_server_port,$this->_connect_timeout)) { 231 218 $this->_send("<?xml version='1.0' encoding='UTF-8' ?" . ">\n"); 232 219 233 220 $xmpp_version = ($this->protocol_version) ? " version='{$this->protocol_version}'" : ''; 234 221 235 $this->_send("<stream:stream to='{$this-> _server_host}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'{$xmpp_version}>\n");222 $this->_send("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'{$xmpp_version}>\n"); 236 223 return true; 237 224 } else { … … 263 250 264 251 // prepare our shiny new JID 265 $this->_username = $ username;252 $this->_username = $this->username; 266 253 $this->_password = $password; 267 254 $this->_resource = $resource; … … 622 609 // handle Stream packets 623 610 function _handle_stream(&$packet) { 624 if ($packet["stream:stream"]['@']['from'] == $this-> _server_host611 if ($packet["stream:stream"]['@']['from'] == $this->server 625 612 && $packet["stream:stream"]['@']['xmlns'] == "jabber:client" 626 613 && $packet["stream:stream"]['@']["xmlns:stream"] == "http://etherx.jabber.org/streams") … … 650 637 { 651 638 $auth_id = $packet['iq']['@']['id']; 652 $this->_sendauth_digest($auth_id); 639 640 /* 641 if (isset($packet['iq']['#']['query'][0]['#']['digest'])) { 642 $this->_sendauth_digest($auth_id); 643 } 644 elseif (isset($packet['iq']['#']['query'][0]['#']['password'])) { 645 $this->_sendauth_plaintext($auth_id); 646 } 647 else { 648 // 649 //echo "===\n";var_dump($packet);echo "\n"; 650 $this->_sendauth_digest($auth_id); 651 //} 652 //*/ 653 //$this->_sendauth_digest($auth_id); 654 $this->_sendauth_plaintext($auth_id); 653 655 $this->_set_iq_handler("_on_authentication_result",$auth_id); 654 656 } … … 812 814 return true; 813 815 } 814 815 // receives the results of a roster query 816 // 817 // Note: You should always browse services BEFORE calling get_roster(), as this 818 // will ensure that the correct services get marked as "registered" in $this->services, 819 // and each roster contact will automatically have its "transport" element set to the 820 // correct transport. 821 function _on_roster_result(&$packet) { 822 $packet_type = $packet['iq']['@']['type']; 823 824 // did we get a result? if so, process it, and remember the service list 825 if (($packet_type=="result") || ($packet_type=="set")) { 826 827 $roster_updated = false; 828 829 $itemlist = &$packet['iq']['#']['query'][0]['#']['item']; 830 $number_of_contacts = is_array($itemlist) ? count($itemlist) : 0; 831 832 for ($a = 0; $a < $number_of_contacts; $a++) 833 { 834 $queryitem = &$itemlist[$a]; 835 $jid = strtolower($queryitem['@']['jid']); 836 837 $subscription = $queryitem['@']['subscription']; 838 839 840 list($u_username,$u_domain,$u_resource) = $this->_split_jid($jid); 841 $jid = ($u_username?"{$u_username}@":"").$u_domain; 842 843 844 $is_new = !isset($this->roster[$jid]); 845 846 847 // Is it a transport? 848 $is_service = (!strlen($u_username)); 849 if ($is_service) { 850 // are we registered with it? 851 /*if ($u_resource=="registered") {*/ 852 if (!in_array($subscription,array("none","remove"))) { // if we're not subscribed to it, then we'll consider it unregistered 853 $this->services[$jid]["registered"] = true; 854 } 855 /*}*/ 856 } 857 858 // don't add the entry to the roster if it's a service, and we've been 859 // configured to handle service presence internally (via $this->services) 860 if (!($is_service && $this->handle_services_internally)) { 861 // if not new, don't clobber the old presence/availability 862 $u_jid = $u_username."@".$u_domain; 863 $status = $is_new?"Offline":$this->roster[$jid]["status"]; 864 $show = $is_new?"off":$this->roster[$jid]["show"]; 865 866 // if presence was received before roster, grab the show value from the presence 867 if ($this->presence_cache[$u_jid]) { 868 if (!$show || $is_new) { 869 $show = $this->presence_cache[$u_jid]["show"]; 870 } 871 if (!$status || $is_new) { 872 $status = $this->presence_cache[$u_jid]["status"]; 873 } 874 875 // remove any cached presence info, as the roster item now exists 876 unset($this->presence_cache[$u_jid]); 877 } 878 879 $rostername = $queryitem['@']['name'] ? $queryitem['@']['name'] : $rostername = $u_username; 880 881 882 // prepare the roster item 883 $rosteritem = array( 884 "name" => $rostername, 885 "subscription" => $queryitem['@']['subscription'], 886 "ask" => $queryitem['@']['ask'], 887 "group" => $queryitem['#']['group'][0]['#'], 888 "status" => $status, 889 "show" => $show, 890 "username" => $u_username, 891 "domain" => $u_domain, 892 "resource" => $u_resource, 893 "jid" => $u_jid, 894 "transport" => $this->get_transport($u_domain) 895 ); 896 if ($is_new) { 897 // if it's a new entry, just add it to the roster 898 $this->roster[$jid] = $rosteritem; 899 } else { 900 // otherwise, carefully update the existing entry, preserving 901 // any elements that may have been added externally 902 foreach ($rosteritem as $k=>$v) { 903 $this->roster[$jid][$k] = $v; 904 } 905 } 906 907 // you may wish to set roster_single_update to TRUE before 908 // calling your initial browse(); this will allow you to 909 // initialize your entire roster in one swoop, rather than 910 // doing it contact-by-contact 911 if ($this->roster_single_update) { 912 $roster_updated = true; 913 } 914 else { 915 $this->_call_handler("rosterupdate",$jid,$is_new); 916 } 917 } 918 } 919 920 if ($this->roster_single_update && $roster_updated) { 921 $this->_call_handler("rosterupdate",NULL,false); 922 } 923 924 // choke on error 925 } 926 elseif ($packet_type=="error") { 927 $this->_handle_iq_error($packet); 928 929 // confusion sets in 930 } 931 } 932 933 // receives the results of an account registration 'get' query (retrieving fields) 934 function _on_register_get_result(&$packet) { 935 $packet_type = $packet['iq']['@']['type']; 936 $reg_id = $this->_unique_id("reg"); 937 938 if ($packet_type=="result") { 939 940 if (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) { 941 $this->_call_handler("regfailure",-1,"Username already registered",""); 942 return; 943 } 944 945 $key = $packet['iq']['#']['query'][0]['#']['key'][0]['#']; 946 unset($packet); 947 948 // Looks like CJP just hardcoded these fields, regardless of what the server sends...?! 949 // FIXME: parse fields dynamically this when time permits 950 $payload = "<username>{$this->_username}</username> 951 <password>{$this->_password}</password> 952 <email>{$this->_reg_email}</email> 953 <name>{$this->_reg_name}</name>\n"; 954 955 $payload .= ($key) ? "<key>$key</key>\n" : ''; 956 957 $this->_set_iq_handler("_on_register_set_result",$reg_id); 958 $this->_send_iq($this->_server_host, 'set', $reg_id, "jabber:iq:register", $payload); 959 960 961 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 962 $this->_handle_iq_error(&$packet,"regfailure"); 963 964 } else { 965 $this->_call_handler("regfailure",-2,"Unrecognized response from server",""); 966 } 967 } 968 969 // receives the results of an account registration 'set' query (the actual result of 970 // the account registration attempt) 971 function _on_register_set_result(&$packet) { 972 $packet_type = $packet['iq']['@']['type']; 973 $error_code = 0; 974 975 if ($packet_type=="result") { 976 977 if ($this->_resource) { 978 $this->jid = "{$this->_username}@{$this->_server_host}/{$this->_resource}"; 979 } else { 980 $this->jid = "{$this->_username}@{$this->_server_host}"; 981 } 982 $this->_call_handler("registered",$this->jid); 983 984 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 985 // "conflict" error, i.e. already registered 986 if ($packet['iq']['#']['error'][0]['@']['code'] == '409') { 987 $this->_call_handler("regfailure",-1,"Username already registered",""); 988 } else { 989 $this->_handle_iq_error(&$packet,"regfailure"); 990 } 991 992 } else { 993 $this->_call_handler("regfailure",-2,"Unrecognized response from server"); 994 } 995 } 996 997 function _on_deregister_result(&$packet) { 998 999 $packet_type = $packet['iq']['@']['type']; 1000 1001 if ($packet_type=="result") { 1002 $this->_call_handler("deregistered",$this->jid); 1003 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1004 $this->_handle_iq_error(&$packet,"deregfailure"); 1005 } else { 1006 $this->_call_handler("deregfailure",-2,"Unrecognized response from server"); 1007 } 1008 } 1009 1010 1011 // receives the result of a password change 1012 function _on_chgpassword_result(&$packet) { 1013 $packet_type = $packet['iq']['@']['type']; 1014 if ($packet_type=="result") { 1015 $this->_call_handler("passwordchanged"); 1016 1017 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1018 $this->_handle_iq_error(&$packet,"passwordfailure"); 1019 } else { 1020 $this->_call_handler("passwordfailure",-2,"Unrecognized response from server"); 1021 } 1022 } 1023 1024 // receives the result of a service (transport) registration 1025 function _on_servicefields_result(&$packet) { 1026 $packet_type = $packet['iq']['@']['type']; 1027 $packet_id = $packet['iq']['@']['id']; 1028 1029 if ($packet_type=="result") { 1030 1031 $reg_key = ""; 1032 $reg_instructions = ""; 1033 $reg_x = ""; 1034 $fields = array(); 1035 1036 foreach ($packet['iq']['#']['query'][0]['#'] as $element => $data) { 1037 switch($element) { 1038 case "key": 1039 $reg_key = $data[0]['#']; 1040 break; 1041 case "instructions": 1042 $reg_instructions = $data[0]['#']; 1043 break; 1044 case "x": 1045 $reg_x = $data[0]['#']; 1046 break; 1047 default: 1048 $fields[] = $element; 1049 break; 1050 } 1051 } 1052 $this->_call_handler("servicefields",&$fields,$packet_id,$reg_key,$reg_instructions,&$reg_x); 1053 1054 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1055 $this->_handle_iq_error(&$packet,"servicefieldsfailure"); 1056 } else { 1057 $this->_call_handler("servicefieldsfailure",-2,"Unrecognized response from server"); 1058 } 1059 } 1060 1061 function _on_serviceregister_result(&$packet) { 1062 $packet_type = $packet['iq']['@']['type']; 1063 $from = $packet['iq']['@']['from']; 1064 if ($packet_type == 'result') { 1065 if (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) { 1066 $this->_call_handler("serviceregfailure",-1,"Already registered with service",""); 1067 } else { 1068 $jid = $this->_bare_jid($from); 1069 $this->_call_handler("serviceregistered",$from); 1070 } 1071 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1072 $this->_handle_iq_error(&$packet,"serviceregfailure"); 1073 } else { 1074 $this->_call_handler("serviceregfailure",-2,"Unrecognized response from server"); 1075 } 1076 } 1077 1078 function _on_servicedereg_initial_result(&$packet) { 1079 1080 $packet_type = $packet['iq']['@']['type']; 1081 $from = $packet['iq']['@']['from']; 1082 1083 if ($packet_type == 'result') { 1084 1085 // we're now deregistered with the transport, but we need to remove 1086 // our roster subscription 1087 $dereg_id = $this->_unique_id("svcdereg"); 1088 $this->_set_iq_handler("_on_servicedereg_final_result",$dereg_id); 1089 1090 1091 $this->services[$from]["registered"] = false; 1092 $this->services[$from]["subscription"] = "none"; 1093 1094 $payload = "<item jid='{$from}' subscription='remove'/>"; 1095 1096 if ($this->_send_iq(NULL, 'set', $dereg_id, "jabber:iq:roster", $payload)) { 1097 1098 return $dereg_id; 1099 } 1100 else { 1101 return false; 1102 } 1103 1104 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1105 $this->_handle_iq_error(&$packet,"servicederegfailure"); 1106 } else { 1107 $this->_call_handler("servicederegfailure",-2,"Unrecognized response from server"); 1108 } 1109 } 1110 1111 function _on_servicedereg_final_result(&$packet) 1112 { 1113 $packet_type = $packet['iq']['@']['type']; 1114 if ($packet_type == 'result') { 1115 $this->_call_handler("servicederegistered"); 1116 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1117 $this->_handle_iq_error(&$packet,"servicederegfailure"); 1118 } else { 1119 $this->_call_handler("servicederegfailure",-2,"Unrecognized response from server"); 1120 } 1121 } 1122 1123 function _on_rosteradd_result(&$packet) { 1124 $packet_type = $packet['iq']['@']['type']; 1125 if ($packet_type == 'result') { 1126 1127 $this->_call_handler("rosteradded",$packet['iq']['@']['id']); 1128 1129 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1130 $this->_handle_iq_error(&$packet,"rosteraddfailure"); 1131 } else { 1132 $this->_call_handler("rosteraddfailure",-2,"Unrecognized response from server"); 1133 } 1134 } 1135 1136 function _on_rosterupdate_result(&$packet) { 1137 $packet_type = $packet['iq']['@']['type']; 1138 if ($packet_type == 'result') { 1139 $this->_call_handler("contactupdated",$packet['iq']['@']['id']); 1140 1141 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1142 $this->_handle_iq_error(&$packet,"contactupdatefailure"); 1143 } else { 1144 $this->_call_handler("contactupdatefailure",-2,"Unrecognized response from server"); 1145 } 1146 } 1147 function _on_rosterremove_result(&$packet) { 1148 $packet_type = $packet['iq']['@']['type']; 1149 if ($packet_type == 'result') { 1150 $this->_call_handler("rosterremoved",$packet['iq']['@']['id']); 1151 1152 } elseif ($packet_type == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { 1153 $this->_handle_iq_error(&$packet,"rosterremovefailure"); 1154 } else { 1155 $this->_call_handler("rosterremovefailure",-2,"Unrecognized response from server"); 1156 } 1157 } 816 1158 817 1159 818 function _on_private_data(&$packet) { … … 1323 982 $sleepfunc = $this->_sleep_func; 1324 983 1325 $iterations = 0; 984 $iterations = 0; 1326 985 do { 1327 986 $line = $this->_connection->socket_read(16384); … … 1338 997 1339 998 if ($incoming != "") { 1340 999 1341 1000 $temp = $this->_split_incoming($incoming); 1342 1343 1001 $packet_count = count($temp); 1344 1002 1345 1003 for ($a = 0; $a < $packet_count; $a++) { 1346 1004 $this->_packet_queue[] = $this->xml->xmlize($temp[$a]); 1005 //var_dump($this->xml->xmlize($temp[$a]));echo "\n---\n"; 1347 1006 } 1348 1007 } -
plugins/jabberNotifications/lib/class_XMLParser.php
r271 r343 76 76 $children = array(); 77 77 78 if ( !empty($vals[$i]['value'])) {78 if (isset($vals[$i]['value'])) { 79 79 array_push($children, trim($vals[$i]['value'])); 80 80 } -
plugins/jabberNotifications/locales/fr/main.po
r292 r343 1 1 # French translation of Jabber Notification 2 # Copyright (c) 2007 .3 # Oleksandr Syenchuk <sacha@xn--phnix-csa.net>, 200 7;2 # Copyright (c) 2007,2008. 3 # Oleksandr Syenchuk <sacha@xn--phnix-csa.net>, 2008; 4 4 # Olivier Tétard <toutoune25@free.fr>, 2007. 5 5 -
plugins/jabberNotifications/test.php
r291 r343 1 1 <?php 2 # Edit, than run this file from a shell ! 3 # $ php test.php 4 2 5 $t1 = microtime(true); 3 6 4 7 include_once dirname(__FILE__).'/lib/class_Jabber.php'; 5 8 6 $ serv = 'serv';9 $host = 'host'; 7 10 $port = 5222; 8 $user = 'user'; 11 $con = 'ssl://'; # or '' or 'tls://' 12 $user = 'user@server'; 9 13 $pass = 'pass'; 10 14 $dest = 'dest@serv.tld'; … … 21 25 private $messages; 22 26 23 public function __construct($serv,$port,$user,$pass )27 public function __construct($serv,$port,$user,$pass,$con='') 24 28 { 25 29 $this->serv = $serv; … … 28 32 $this->pass = $pass; 29 33 30 $this->j = new Jabber( );34 $this->j = new Jabber($serv,$port,$user,$pass,$con); 31 35 32 36 $this->messages = array(); … … 44 48 public function commit($timeout=4) 45 49 { 46 echo " Attemp to commit...\n";47 if ($this->j->connect($this->serv,$this->port,$timeout))48 {49 echo " Connected ;)\n";50 echo "[S] Attemp to commit...\n"; 51 if ($this->j->connect($timeout)) { 52 $this->j->_connection->debug = true; 53 echo "[I] Connected ;)\n"; 50 54 $this->j->execute($timeout); 51 echo " STOPPED\n";55 echo "[S] STOPPED\n"; 52 56 return true; 53 } else { 57 } 58 else { 54 59 echo "[E] Connection failure\n"; 55 60 } … … 60 65 { 61 66 $this->j->login($this->user,$this->pass); 62 echo " Logged in\n";67 echo "[I] Logged in\n"; 63 68 } 64 69 65 70 public function handleAuthenticated() 66 71 { 67 echo " Authenticated\n";72 echo "[I] Authenticated\n"; 68 73 foreach ($this->messages as $m) 69 74 { 70 $this->j->message($m[0]," chat",NULL,$m[1]);75 $this->j->message($m[0],"normal",NULL,$m[1]); 71 76 } 72 echo " All sended\n";77 echo "[I] All sended\n"; 73 78 $this->j->terminated = true; 74 79 } … … 80 85 } 81 86 82 $j = new jabberNotifier($ serv,$port,$user,$pass);83 $j->addMessage($dest,' Test...'.time().'!');87 $j = new jabberNotifier($host,$port,$user,$pass,$con); 88 $j->addMessage($dest,'/me makes a test... '.time().'!'); 84 89 $j->commit(8); 85 90 86 91 echo "Total execution time : ".(microtime(true) - $t1)." s\n"; 87 //*/ 92 88 93 ?>
Note: See TracChangeset
for help on using the changeset viewer.