Exemple #1
0
 /**
  * @param string $message
  * @param string $scope
  * @return void
  */
 public function write($message, $scope = Output::SCOPE_PRIVATE)
 {
     if ($scope == Output::SCOPE_PUBLIC) {
         $this->xmpp->presence(null, 'available', $this->getChatroom() . '/Git');
         $this->xmpp->message($this->getChatroom(), sprintf('[%s] %s', $this->getUser(), $message), 'groupchat');
         $this->xmpp->presence(null, 'unavailable', $this->getChatroom() . '/Git');
     }
 }
 /**
  * Processes the message (sends using jabber).
  * @param object $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
  * @return true if ok, false if error
  */
 function send_message($eventdata)
 {
     global $CFG;
     if (!empty($CFG->noemailever)) {
         // hidden setting for development sites, set in config.php if needed
         debugging('$CFG->noemailever active, no jabber message sent.', DEBUG_MINIMAL);
         return true;
     }
     //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
     static $jabberaddresses = array();
     if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
         $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
     }
     $jabberaddress = $jabberaddresses[$eventdata->userto->id];
     //calling s() on smallmessage causes Jabber to display things like < Jabber != a browser
     $jabbermessage = fullname($eventdata->userfrom) . ': ' . $eventdata->smallmessage;
     if (!empty($eventdata->contexturl)) {
         $jabbermessage .= "\n" . get_string('view') . ': ' . $eventdata->contexturl;
     }
     $jabbermessage .= "\n(" . get_string('noreply', 'message') . ')';
     $conn = new XMPPHP_XMPP($CFG->jabberhost, $CFG->jabberport, $CFG->jabberusername, $CFG->jabberpassword, 'moodle', $CFG->jabberserver);
     try {
         //$conn->useEncryption(false);
         $conn->connect();
         $conn->processUntil('session_start');
         $conn->presence();
         $conn->message($jabberaddress, $jabbermessage);
         $conn->disconnect();
     } catch (XMPPHP_Exception $e) {
         debugging($e->getMessage());
         return false;
     }
     return true;
 }
 /**
  * Processes the message (sends using jabber).
  * @param object $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
  * @return true if ok, false if error
  */
 function send_message($eventdata)
 {
     global $CFG;
     if (message_output_jabber::_jabber_configured()) {
         //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
         static $jabberaddresses = array();
         if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
             $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', $eventdata->userto->email, $eventdata->userto->id);
         }
         $jabberaddress = $jabberaddresses[$eventdata->userto->id];
         $jabbermessage = fullname($eventdata->userfrom) . ': ' . $eventdata->smallmessage;
         if (!empty($eventdata->contexturl)) {
             $jabbermessage .= "\n" . get_string('view') . ': ' . $eventdata->contexturl;
         }
         $jabbermessage .= "\n(" . get_string('noreply', 'message') . ')';
         $conn = new XMPPHP_XMPP($CFG->jabberhost, $CFG->jabberport, $CFG->jabberusername, $CFG->jabberpassword, 'moodle', $CFG->jabberserver);
         try {
             //$conn->useEncryption(false);
             $conn->connect();
             $conn->processUntil('session_start');
             $conn->presence();
             $conn->message($jabberaddress, $jabbermessage);
             $conn->disconnect();
         } catch (XMPPHP_Exception $e) {
             debugging($e->getMessage());
             return false;
         }
     }
     //note that we're reporting success if message was sent or if Jabber simply isnt configured
     return true;
 }
Exemple #4
0
function my_action_callback() 
{
	$cmd = $_POST['cmd'];
	
	include 'XMPPHP/XMPP.php';
	
	error_reporting(0);

	//$time_start = microtime_float();
	$conn = new XMPPHP_XMPP('talk.google.com', 5222, '*****@*****.**', 'ns171284', 'xmpphp', 'gmail.com', $printlog=false, $loglevel=XMPPHP_Log::LEVEL_INFO);
	
	try {
		$conn->connect();
	    $conn->processUntil('session_start');
	    $conn->presence();
	     //			$time_end = microtime_float();
	    $conn->message('*****@*****.**', $cmd);
	    $conn->disconnect();
	} catch(XMPPHP_Exception $e) {
	    die($e->getMessage());
	}
	

	//$time = $time_end - $time_start;
	die();
	//die("TOTAL TIME = ".$time);
}
Exemple #5
0
 /**
  * Sends message recipient if log entries are present.
  *
  * @return void
  */
 public function shutdown()
 {
     // If there are events to send, use them as message body.
     // Otherwise, there is no message to be sent.
     if (empty($this->_eventsToSend)) {
         return;
     }
     // Finally, send the IM, but re-throw any exceptions at the
     // proper level of abstraction.
     try {
         $jabber = new XMPPHP_XMPP($this->options['host'], $this->options['port'], $this->options['user'], $this->options['password'], $this->options['resource'], $this->options['server'], false, XMPPHP_Log::LEVEL_VERBOSE);
         try {
             $jabber->connect();
             $jabber->processUntil('session_start');
             $jabber->presence();
             $events = implode('', $this->_eventsToSend);
             $jabber->message($this->options['recipient'], $events);
             $jabber->disconnect();
         } catch (XMPPHP_Exception $e) {
             die($e->getMessage());
         }
     } catch (Exception $e) {
         throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
     }
 }
 protected function sendGroupMessage(\XMPPHP_XMPP $client, $config)
 {
     $client->connect();
     $client->processUntil('session_start', static::TIMEOUT);
     $client->presence(NULL, static::STATUS, $config['to'] . '/Professor X');
     $client->message($config['to'], $config['message'], 'groupchat');
     $client->disconnect();
 }
Exemple #7
0
 /**
  * @param $message
  *
  * @return $this
  */
 protected function send($message)
 {
     $configCurrentProject = $this->getCurrentProjectConfig();
     $host = $configCurrentProject['host'];
     $port = $configCurrentProject['port'];
     $user = $configCurrentProject['user'];
     $password = $configCurrentProject['password'];
     $ressource = $configCurrentProject['ressource'];
     $server = $configCurrentProject['server'];
     $to = $configCurrentProject['to'];
     $type = $configCurrentProject['type'];
     $xmpp = new XMPPHP_XMPP($host, $port, $user, $password, $ressource, $server, false, 4);
     $xmpp->connect();
     $xmpp->processUntil('session_start');
     $xmpp->presence(null, 'available', $to . '/' . $user);
     $xmpp->message($to, $message, $type);
     $xmpp->presence(null, 'unavailable', $to . '/' . $user);
     $xmpp->disconnect();
     return $this;
 }
Exemple #8
0
 public function notify(Commit $commit)
 {
     $old = error_reporting(0);
     $conn = new \XMPPHP_XMPP($this->host, $this->port, $this->username, $this->password, 'sismo', $this->server);
     $conn->connect();
     $conn->processUntil('session_start');
     $conn->presence();
     foreach (explode(',', $this->recipient) as $user) {
         $conn->message($user, $this->format($this->format, $commit));
     }
     $conn->disconnect();
     error_reporting($old);
 }
Exemple #9
0
function xs_send($to, $text)
{
    include TE_DIR . '/lib/XMPPHP/XMPP.php';
    $conn = new XMPPHP_XMPP(XS_SERVER, XS_PORT, XS_LOGIN, XS_PASS, 'xmpphp', XS_SERVIS, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
    try {
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->presence();
        $conn->message($to, $text);
        $conn->disconnect();
    } catch (XMPPHP_Exception $e) {
        die($e->getMessage());
    }
}
function jabber($to, $message)
{
    @(require_once DIR . '/system/lib/XMPPHP/XMPP.php');
    @($conn = new XMPPHP_XMPP($GLOBALS['config']['jabber']['host'], $GLOBALS['config']['jabber']['port'], $GLOBALS['config']['jabber']['user'], $GLOBALS['config']['jabber']['password'], $GLOBALS['config']['jabber']['resource'], $GLOBALS['config']['jabber']['server'], $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO));
    try {
        @$conn->connect();
        @$conn->processUntil('session_start');
        @$conn->presence();
        @$conn->message($to, $message);
        @$conn->disconnect();
        return true;
    } catch (XMPPHP_Exception $e) {
        return false;
    }
}
Exemple #11
0
 public function testAuthException()
 {
     try {
         $xmpp = new XMPPHP_XMPP('jabber.wentz.it', 5222, 'invalidusername', 'invalidpassword', 'xmpphp', 'jabber.wentz.it', true, XMPPHP_Log::LEVEL_VERBOSE);
         $xmpp->useEncryption(false);
         $xmpp->connect(10);
         $xmpp->processUntil('session_start');
         $xmpp->presence();
         $xmpp->message('*****@*****.**', 'This is a test message!');
         $xmpp->disconnect();
     } catch (XMPPHP_Exception $e) {
         return;
     } catch (Exception $e) {
         $this->fail('Unexpected Exception thrown: ' . $e->getMessage());
     }
     $this->fail('Expected XMPPHP_Exception not thrown!');
 }
 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) {
         }
     }
 }
         if (!$cmd[1]) {
             $cmd[1] = $conn->user . '@' . $conn->server;
         }
         // take a note which user requested which vcard
         $vcard_request[$pl['from']] = $cmd[1];
         // request the vcard
         $conn->getVCard($cmd[1]);
     }
     break;
 case 'presence':
     print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
     break;
 case 'session_start':
     print "Session Start\n";
     $conn->getRoster();
     $conn->presence($status = "Cheese!");
     break;
 case 'vcard':
     // check to see who requested this vcard
     $deliver = array_keys($vcard_request, $pl['from']);
     // work through the array to generate a message
     print_r($pl);
     $msg = '';
     foreach ($pl as $key => $item) {
         $msg .= "{$key}: ";
         if (is_array($item)) {
             $msg .= "\n";
             foreach ($item as $subkey => $subitem) {
                 $msg .= "  {$subkey}: {$subitem}\n";
             }
         } else {
 public static function sendXMPMessage($chat, $params = array())
 {
     $data = (array) erLhcoreClassModelChatConfig::fetch('xmp_data')->data;
     $templateMessage = 'xmp_message';
     if (isset($params['template'])) {
         $templateMessage = $params['template'];
     }
     if (isset($data['use_xmp']) && $data['use_xmp'] == 1) {
         if (isset($data['use_standard_xmp']) && $data['use_standard_xmp'] == '0' || !isset($data['use_standard_xmp'])) {
             $conn = new XMPPHP_XMPP($data['host'], $data['port'], $data['username'], $data['password'], $data['resource'], $data['server'], $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
             try {
                 $conn->connect();
                 $conn->processUntil('session_start');
                 $emailRecipient = array();
                 // Email messages
                 $groupRecipients = array();
                 // Group messages
                 if ($chat->department !== false && $chat->department->xmpp_recipients != '') {
                     // Perhaps department has assigned email
                     $emailRecipient = explode(',', $chat->department->xmpp_recipients);
                 } elseif (isset($data['recipients']) && $data['recipients'] != '') {
                     $emailRecipient = explode(',', $data['recipients']);
                 }
                 if ($chat->department !== false && $chat->department->xmpp_group_recipients != '') {
                     $groupRecipients = explode(',', $chat->department->xmpp_group_recipients);
                 }
                 // change status
                 foreach ($groupRecipients as $recipient) {
                     $conn->presence(NULL, 'available', $recipient);
                 }
                 if (!empty($emailRecipient)) {
                     $conn->presence();
                 }
                 $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 5, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id))));
                 $messagesContent = '';
                 foreach ($messages as $msg) {
                     if ($msg->user_id == -1) {
                         $messagesContent .= date(erLhcoreClassModule::$dateDateHourFormat, $msg->time) . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmin', 'System assistant') . ': ' . htmlspecialchars($msg->msg) . "\n";
                     } else {
                         $messagesContent .= date(erLhcoreClassModule::$dateDateHourFormat, $msg->time) . ' ' . ($msg->user_id == 0 ? htmlspecialchars($chat->nick) : htmlspecialchars($msg->name_support)) . ': ' . htmlspecialchars($msg->msg) . "\n";
                     }
                 }
                 $cfgSite = erConfigClassLhConfig::getInstance();
                 $secretHash = $cfgSite->getSetting('site', 'secrethash');
                 foreach ($emailRecipient as $email) {
                     $veryfyEmail = sha1(sha1($email . $secretHash) . $secretHash);
                     $messagesParsed = str_replace(array('{messages}', '{url_accept}', '{chat_id}', '{user_name}'), array($messagesContent, self::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('chat/accept') . '/' . erLhcoreClassModelChatAccept::generateAcceptLink($chat) . '/' . $veryfyEmail . '/' . $email, $chat->id, $chat->user_name), $data[$templateMessage]);
                     $conn->message($email, $messagesParsed);
                 }
                 foreach ($groupRecipients as $email) {
                     list($emailGroup) = explode('/', $email);
                     $veryfyEmail = sha1(sha1($emailGroup . $secretHash) . $secretHash);
                     $messagesParsed = str_replace(array('{messages}', '{url_accept}', '{chat_id}', '{user_name}'), array($messagesContent, self::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('chat/accept') . '/' . erLhcoreClassModelChatAccept::generateAcceptLink($chat) . '/' . $veryfyEmail . '/' . $emailGroup, $chat->id, $chat->user_name), $data[$templateMessage]);
                     $conn->message($emailGroup, $messagesParsed, 'groupchat');
                 }
                 foreach ($groupRecipients as $recipient) {
                     $conn->presence(NULL, 'unavailable', $recipient);
                 }
                 $conn->disconnect();
                 return true;
             } catch (Exception $e) {
                 throw $e;
             }
         } else {
             if (($accessToken = self::getAccessToken()) !== false) {
                 $dataLogin = self::get_dns_srv('gmail.com');
                 $conn = new XMPPHP_XMPP($dataLogin[0], $dataLogin[1], $data['email_gtalk'], $accessToken, 'xmpphp', $dataLogin[0], $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO, true);
                 try {
                     $conn->connect();
                     $conn->processUntil('session_start');
                     $conn->presence();
                     $emailRecipient = array();
                     if ($chat->department !== false && $chat->department->xmpp_recipients != '') {
                         // Perhaps department has assigned email
                         $emailRecipient = explode(',', $chat->department->xmpp_recipients);
                     } elseif (isset($data['recipients']) && $data['recipients'] != '') {
                         $emailRecipient = explode(',', $data['recipients']);
                     }
                     $messages = array_reverse(erLhcoreClassModelmsg::getList(array('limit' => 5, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id))));
                     $messagesContent = '';
                     foreach ($messages as $msg) {
                         if ($msg->user_id == -1) {
                             $messagesContent .= date(erLhcoreClassModule::$dateDateHourFormat, $msg->time) . ' ' . erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmin', 'System assistant') . ': ' . htmlspecialchars($msg->msg) . "\n";
                         } else {
                             $messagesContent .= date(erLhcoreClassModule::$dateDateHourFormat, $msg->time) . ' ' . ($msg->user_id == 0 ? htmlspecialchars($chat->nick) : htmlspecialchars($msg->name_support)) . ': ' . htmlspecialchars($msg->msg) . "\n";
                         }
                     }
                     $cfgSite = erConfigClassLhConfig::getInstance();
                     $secretHash = $cfgSite->getSetting('site', 'secrethash');
                     foreach ($emailRecipient as $email) {
                         $veryfyEmail = sha1(sha1($email . $secretHash) . $secretHash);
                         $conn->message($email, str_replace(array('{messages}', '{url_accept}', '{chat_id}', '{user_name}'), array($messagesContent, self::getBaseHost() . $_SERVER['HTTP_HOST'] . erLhcoreClassDesign::baseurl('chat/accept') . '/' . erLhcoreClassModelChatAccept::generateAcceptLink($chat) . '/' . $veryfyEmail . '/' . $email, $chat->id, $chat->user_name), $data[$templateMessage]));
                     }
                     $conn->disconnect();
                     return true;
                 } catch (Exception $e) {
                     throw $e;
                 }
             } else {
                 throw new Exception('Invalid access token');
             }
         }
     }
 }
 public function sendNotification($user, $subject, $message)
 {
     if ($user->getNotificationMethod() == 'jabber') {
         $conn = new XMPPHP_XMPP(ConfigLine::configByName('jabber_server'), 5222, ConfigLine::configByName('jabber_username'), ConfigLine::configByName('jabber_password'), 'xmpphp', $server = null, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
         try {
             $conn->connect();
             $conn->processUntil('session_start');
             $conn->presence();
             $conn->message($user->getJabber(), $message);
             $conn->disconnect();
         } catch (XMPPHP_Exception $e) {
             echo $e->getMessage();
         }
     } elseif ($user->getNotificationMethod() == 'email') {
         if ($GLOBALS['mail_sending_type'] == 'smtp') {
             $config['username'] = ConfigLine::configByName('mail_smtp_username');
             $config['password'] = ConfigLine::configByName('mail_smtp_password');
             $config['ssl'] = ConfigLine::configByName('mail_smtp_ssl');
             $config['auth'] = ConfigLine::configByName('mail_smtp_login_auth');
             $transport = new Zend_Mail_Transport_Smtp(ConfigLine::configByName('mail_smtp_server'), $config);
         }
         $mail = new Zend_Mail();
         $mail->setFrom(ConfigLine::configByName('mail_sender_adress'), ConfigLine::configByName('mail_sender_name'));
         $mail->addTo($user->getEmail());
         $mail->setSubject($subject);
         $mail->setBodyText($message);
         $mail->send($transport);
     }
 }
 if (defined('WPLC_TIMEOUT')) {
     set_time_limit(WPLC_TIMEOUT);
 } else {
     set_time_limit(120);
 }
 $i = 1;
 $array = array("check" => false);
 /* must record the session ID */
 include '/includes/XMPPHP/XMPP.php';
 #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('server', 5222, 'user', 'pass', 'xmpphp', 'gmail.com', $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
 wplc_error_log("[" . __LINE__ . "] Connecting to XMP server");
 $conn->connect();
 $conn->processUntil('session_start');
 $conn->presence($status = 'Controller available.');
 // Enter the chatroom
 $conn->presence(NULL, "available", "chatroom@server/NickName");
 //$conn->message("chatroom@server", "Test!", "groupchat");
 while ($i < $iterations) {
     session_write_close();
     try {
         wplc_error_log($sessiont . " - Waiting for events");
         $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'), 5);
         foreach ($payloads as $event) {
             $pl = $event[1];
             wplc_error_log($sessiont . " - " . "Event: {$event[0]}");
             switch ($event[0]) {
                 case 'message':
                     if (!isset($_SESSION['messages'])) {
                         $_SESSION['message'] = array();
Exemple #17
0
      				if($cmd[0] == 'vcard') {
     			if(!($cmd[1])) $cmd[1] = $conn->user . '@' . $conn->server;
     			// take a note which user requested which vcard
     			$vcard_request[$pl['from']] = $cmd[1];
     			// request the vcard
     			$conn->getVCard($cmd[1]);
     		}*/
     break;
 case 'presence':
     print "Presence: {$pl['from']} [{$pl['show']}] {$pl['status']}\n";
     break;
 case 'session_start':
     print "Session Start\n";
     $conn->getRoster();
     $s->session_started = true;
     $conn->presence($status = "Как истина - где-то рядом...");
     break;
 case 'vcard':
     // check to see who requested this vcard
     $deliver = array_keys($vcard_request, $pl['from']);
     // work through the array to generate a message
     print_r($pl);
     $msg = '';
     foreach ($pl as $key => $item) {
         $msg .= "{$key}: ";
         if (is_array($item)) {
             $msg .= "\n";
             foreach ($item as $subkey => $subitem) {
                 $msg .= "  {$subkey}: {$subitem}\n";
             }
         } else {
                 $cmd[1] = $conn->user;
             }
             // Take a note which user requested which vcard
             $vcard_request[$from] = $cmd[1];
             // Request the vcard
             $conn->getVCard($cmd[1]);
         }
     }
     break;
 case 'presence':
     echo "Presence: {$from} [{$show}] {$status}\n";
     break;
 case 'session_start':
     echo "Session start\n";
     $conn->getRoster();
     $conn->presence('Quasar!');
     break;
 case 'vcard':
     $deliver = array_keys($vcard_request, $from);
     $msg = '';
     foreach ($data as $key => $item) {
         $msg .= $key . ': ';
         if (is_array($item)) {
             $msg .= "\n";
             foreach ($item as $subkey => $subitem) {
                 $msg .= ' ' . $subkey . ':' . $subitem . "\n";
             }
         } else {
             $msg .= $item . "\n";
         }
     }
Exemple #19
0
                    continue;
                }
                $from = substr($event[1]['from'], 0, strpos($event[1]['from'], '/'));
                $chat = Chat::chatWithUser($from);
                if ($chat != NULL) {
                    $chat->from = $event[1]['from'];
                    $chat->process($event[1]['body']);
                } else {
                    if (strtolower(substr($event[1]['body'], 0, 8)) == 'facepalm') {
                        $chat = new Chat($from, $event[1]['from']);
                        $response = $chat->facepalm(trim(substr($event[1]['body'], 8)));
                    }
                }
                break;
            case 'session_start':
                $conn->presence($status = "Facepalm");
                $conn->autoSubscribe();
                break;
        }
    }
}
class FacepalmClient
{
    //	const BASE_URL = 'http://seppo.is-a-geek.com/facepalm.delapalo.net/web/api/'; // Test URL
    const BASE_URL = 'http://facepalm.delapalo.net/api/';
    // Production URL
    public function facepalm($identifier, $message)
    {
        $info = $identifier;
        $info['reason'] = $message;
        $url = self::BASE_URL . 'touch.php';
Exemple #20
0
    if ($reg->get('new_comment') != false) {
        flush();
        $text = 'Комментарий ' . SITE_URL . '/?id=' . $_REQUEST['id'] . ' ' . $_REQUEST['comment_text'];
        $stor = new Storage();
        $stor = $stor->storType(TE_STORTYPE);
        $h = $stor->make('hamster');
        $h->setProperty('status', 'admin');
        $tos = array();
        $tos = $h->getList();
        if (XS_LOGIN != 'login') {
            include 'lib/XMPPHP/XMPP.php';
            $conn = new XMPPHP_XMPP(XS_HOST, XS_PORT, XS_LOGIN, XS_PASS, 'xmpphp', XS_SERVER, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
            //timeout = 5сек
            $conn->connect(5);
            $conn->processUntil('session_start');
            $conn->presence();
            foreach ($tos as $to) {
                $conn->message($to['email'], $text);
                /*if (!$conn->message) {  //off-line message
                          $text = 'MSG '.$to['email'].' '.$text;
                          $to['email'] = '*****@*****.**';
                          $conn->message($to['email'], $text);
                  }*/
            }
            $conn->disconnect();
        } else {
            $text = 'Комментарий ' . SITE_URL . '/?id=' . $_REQUEST['id'] . ' 

        ' . $_REQUEST['comment_text'];
            include_once 'lib/mail_lib.php';
            // Считываем шаблон.
Exemple #21
0
            
            	Note that we'll be hitting the function every second, but the gateway
            	code may make checks more infrequent than that to avoid excessive
            	polling.
            
            	We show the gateway health to the user via means of XMPP presence aka
            	status for the user.
            */
            $status = null;
            if ($gateway->health_check()) {
                $status = "" . APP_NAME . " connected to {$section}";
            } else {
                $status = "Unhealthy gateway device {$section} :-(";
            }
            if ($current_status != $status) {
                $conn->presence($status);
                $current_status = $status;
            }
            unset($status);
            //print "[$section] @".  memory_get_usage() ." end\n";
        }
        // end of loop
        // terminate
        $conn->disconnect();
        unset($log);
        exit;
    }
    // increase fork count
    $i++;
}
/*
Exemple #22
0
 function enotify($user, $message, $ticketnumber, $fromuser, $tousergroup, $description)
 {
     if ($user == 'system') {
         // an automatic script is running to set some default user info
         $email = 'system@localhost';
         $screenname = '';
         $email_notify = 'n';
         $screenname_notify = 'n';
     } else {
         // get the real user info
         $query = "SELECT email,screenname,email_notify,screenname_notify " . "FROM user WHERE username = ?";
         $result = $this->db->query($query, array($user)) or die("select screename queryfailed");
         $myresult = $result->row_array();
         $email = $myresult['email'];
         $screenname = $myresult['screenname'];
         $email_notify = $myresult['email_notify'];
         $screenname_notify = $myresult['screenname_notify'];
     }
     // if they have specified a screenname then send them a jabber notification
     if ($this->config->item('xmpp_server') && $screenname && $screenname_notify == 'y') {
         include 'libraries/XMPPHP/XMPP.php';
         // edit this to use database jabber user defined in config file
         $conn = new XMPPHP_XMPP("{$xmpp_server}", 5222, "{$this->config}->item('xmpp_user')", "{$this->config}->item('xmpp_password')", 'xmpphp', "{$this->config}->item('xmpp_domain')", $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
         try {
             $conn->connect();
             $conn->processUntil('session_start');
             $conn->presence();
             $conn->message("{$screenname}", "{$message}");
             $conn->disconnect();
         } catch (XMPPHP_Exception $e) {
             //die($e->getMessage());
             $xmppmessage = $e->getMessage();
             echo "{$xmppmessage}";
         }
     }
     // if they have specified an email then send them an email notification
     if ($email && $email_notify == 'y') {
         // HTML Email Headers
         $to = $email;
         // truncate the description to fit in the subject
         $description = substr($description, 0, 40);
         $subject = lang('ticketnumber') . "{$ticketnumber}" . lang('to') . ": {$tousergroup} " . lang('from') . ": {$fromuser} {$description}";
         mail($to, $subject, $message);
     }
 }