public static function SendMessage($msg, $to = NULL) { if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) { $jabber_server = sfConfig::get('app_sfJabberPlugin_jabber_server'); $port = sfConfig::get('app_sfJabberPlugin_port'); $username = sfConfig::get('app_sfJabberPlugin_username'); $host = sfConfig::get('app_sfJabberPlugin_host'); $password = sfConfig::get('app_sfJabberPlugin_password'); if ($to == NULL) { $to = sfConfig::get('app_sfJabberPlugin_admin'); } $conn = new XMPPHP_XMPP($jabber_server, $port, $username, $password, 'xmpphp', $host, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_VERBOSE); try { $conn->useSSL(); $conn->connect(); $conn->processUntil('session_start'); $conn->presence(); $conn->message($to, $msg); $conn->disconnect(); } catch (XMPPHP_Exception $e) { } } }
<?php // activate full error reporting //error_reporting(E_ALL & E_STRICT); include 'XMPPHP/XMPP.php'; include 'config.php'; include "process.php"; $s = new samolink($config_dbhost, $config_dbuser, $config_dbpass, $config_dbname, $config_update_interval, $config_owner); $s->load_plugins($config_plugins); #Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports #If this doesn't work, are you running 64-bit PHP with < 5.2.6? $conn = new XMPPHP_XMPP($config_jhost, $config_jport, $config_juser, $config_jpass, $config_jresource, $config_jhost, $printlog = true, $loglevel = XMPPHP_Log::LEVEL_INFO); //$conn = new XMPPHP_XMPP('jabber.ru', 5222, 'sam-o-bot', 'koikke', 'sylwer', 'jabber.ru', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_INFO); $conn->useSSL(false); $conn->useEncryption(false); $conn->autoSubscribe(); $vcard_request = array(); try { $conn->connect(); echo "done\n"; $s->jconn = $conn; while (!$conn->isDisconnected()) { //if ($conn->isSessionStarted()) //{ $msg = $s->update(); if ($msg !== false) { $conn->message($msg['to'], $body = $msg['body']); } //} $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start', 'vcard'), 5); foreach ($payloads as $event) {