# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . ini_set('memory_limit', '128M'); require 'XMPPHP/XMPP.php'; require './lib.php'; require './time.php'; require '../config.php'; putenv("LC_ALL=" . DEFAULT_LANG); setlocale(LC_ALL, DEFAULT_LANG); bindtextdomain("messages", "../locale"); textdomain("messages"); $conn = new XMPPHP_XMPP(JABBER_FEED_HOST, JABBER_FEED_PORT, JABBER_FEED_USER, JABBER_FEED_PASSWORD, JABBER_RESOURCE, JABBER_DOMAIN); $conn->autoSubscribe(); try { $conn->connect(); $bot = new JiskoBot; while(!$conn->isDisconnected()) { $payloads = $conn->processUntil(array('message', 'presence', 'session_start'), JABBER_INTERVAL); if($payloads) { foreach($payloads as $event) { $pl = $event[1]; $from = $bot->get_jid($pl['from']); switch($event[0]) { case 'presence': if($pl['type'] == 'unavailable') { $bot->unregister_jid($from); } elseif($pl['type'] == 'available') { $bot->register_jid($from); } // if available or not break; case 'session_start': $conn->getRoster(); $conn->presence(JABBER_RESOURCE); break; } // switch } // foreach } else { //if $queue = $bot->get_queue(); foreach ($queue as $note) { $message = htmlspecialchars($message, ENT_NOQUOTES); $message = "{$note['username']}{$note['ID']}".stripslashes($note['note']).""; foreach ($bot->_public as $jabber) { if(!$bot->allowable($jabber)) continue; $conn->message($jabber, $message); } // dests } // queue } // end else } // while } catch(XMPPHP_Exception $e) { die($e->getMessage()); }