/**
  * @return void
  */
 protected function connectXmpp()
 {
     $this->connection = new XMPPHP_XMPP($this->config['host'], $this->config['port'], $this->config['user'], $this->config['password'], $this->config['resource'], $this->config['server']);
     // TODO configurable: $this->connection->useEncryption(FALSE);
     $this->connection->connect();
     $this->connection->processUntil('session_start');
 }
예제 #2
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);
}
 /**
  * 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;
 }
예제 #4
0
 /**
  * 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;
 }
예제 #5
0
파일: Xmpp.php 프로젝트: tegansnyder/Logger
 /**
  * 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());
     }
 }
예제 #6
0
 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();
 }
예제 #7
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);
 }
예제 #8
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());
    }
}
예제 #9
0
function snapRegisterNewXmppUser($emailaddress)
{
    global $APPCONFIG;
    include_once '../extensions/XMPPHP/XMPPHP_XMPP.php';
    $conf = $APPCONFIG['XMPP'];
    $passwd = $conf['userpasswd'];
    $userJID = cleanString($emailaddress) . time() . '@' . $conf['server'];
    $conn = new XMPPHP_XMPP($conf['server'], $conf['port'], $conf['adminuser'], $conf['adminpasswd'], $conf['resource'], $conf['domain']);
    $conn->autoSubscribe(true);
    $conn->useEncryption(false);
    $resp = array();
    try {
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->registerNewUser($userJID, $emailaddress, $passwd);
        $conn->processUntil('done');
        $conn->disconnect();
        return array('xmppuserid' => $userJID, 'xmpppasswd' => $passwd);
    } catch (XMPPHP_Exception $e) {
        return 0;
        //die($e->getMessage());
    }
}
예제 #10
0
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;
    }
}
예제 #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!');
 }
예제 #12
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;
 }
예제 #13
0
 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) {
         }
     }
 }
예제 #14
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);
     }
 }
예제 #15
0
파일: shadow.php 프로젝트: noisywiz/tractor
    $reg = Registry::instance();
    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';
예제 #16
0
 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);
     }
 }
<?php

// activate full error reporting
//error_reporting(E_ALL & E_STRICT);
include '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('talk.google.com', 5222, 'spottersu', 'spotGSP11', 'xmpphp', 'gmail.com', $printlog = true, $loglevel = XMPPHP_Log::LEVEL_INFO);
$conn->autoSubscribe();
$vcard_request = array();
try {
    $conn->connect();
    while (!$conn->isDisconnected()) {
        $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start', 'vcard'));
        foreach ($payloads as $event) {
            $pl = $event[1];
            switch ($event[0]) {
                case 'message':
                    print "---------------------------------------------------------------------------------\n";
                    print "Message from: {$pl['from']}\n";
                    if ($pl['subject']) {
                        print "Subject: {$pl['subject']}\n";
                    }
                    print $pl['body'] . "\n";
                    print "---------------------------------------------------------------------------------\n";
                    $conn->message($pl['from'], $body = "Thanks for sending me \"{$pl['body']}\".", $type = $pl['type']);
                    $cmd = explode(' ', $pl['body']);
                    if ($cmd[0] == 'quit') {
                        $conn->disconnect();
                    }
                    if ($cmd[0] == 'break') {
예제 #18
0
 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');
             }
         }
     }
 }
/**
 * Send quick message.
 */
function send_quick_msg($jbr_user, $msg, $bug_id)
{
    $conn = new XMPPHP_XMPP(plugin_config_get('jbr_server'), plugin_config_get('jbr_port'), plugin_config_get('jbr_login'), plugin_config_get('jbr_pwd'), 'xmpphp', plugin_config_get('jbr_server'), $printlog = False, $loglevel = 'LOGGING_INFO');
    //$conn->useEncryption(false); //Enable this line if you get a error "Fatal error: Cannot access protected property XMPPHP_XMPP::$use_encryption"
    try {
        $conn->connect($timeout = plugin_config_get('jbr_timeout'));
        $conn->processUntil('session_start');
        $conn->message($jbr_user . '@' . plugin_config_get('jbr_server'), $msg);
        $conn->disconnect();
        echo '<center><div align="center" style="width:300px;border: solid 1px;padding:10px;margin-bottom:10px;background-color:#D2F5B0;">';
        echo plugin_lang_get('msg_send_successful');
        echo '</div></center>';
        header('Refresh: 3; URL=' . get_bug_link($bug_id));
    } catch (XMPPHP_Exception $e) {
        $e->getMessage();
        echo '<center><div align="center" style="width:300px;border: solid 1px;padding:10px;margin-bottom:10px;background-color:#FCBDBD;">';
        echo plugin_lang_get('msg_send_error');
        echo '</div></center>';
        header('Refresh: 3; URL=' . get_bug_link($bug_id));
    }
}
예제 #20
0
<?php

if (isset($_POST['username'], $_POST['pwd']) & !empty($_POST['username']) & !empty($_POST['pwd'])) {
    //formulaire envoyé, on tente de se connecter
    $username = $_POST['username'];
    $password = $_POST['pwd'];
    $conn = new XMPPHP_XMPP('chat.euw1.lol.riotgames.com', 5223, $username, 'AIR_' . $password, 'xiff', 'pvp.net', $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
    $conn->autoSubscribe();
    $conn->connect();
    try {
        $payloads = $conn->processUntil(array('session_start', 'roster_received'));
        $conn->presence();
        $conn->processTime(5);
        // now see the results
        $roster = $conn->roster->getRoster();
        //print_r($roster); // you should now see roster array with presence info for each contact
        //le joueur connecté est présent dans sa liste d'amis donc on le supprime
        unset($roster[$conn->jid]);
        //RIP MVC
        ?>
        <section>   

            <div class="bootcards-list">
                <div class="panel panel-default">

                    <div class="panel-body">
                        <h1 class="text-center">Liste de contacts</h1>  
                    </div>                

                    <div class="list-group">
예제 #21
0
파일: nagnot.php 프로젝트: richadams/nagnot
function output($m)
{
    echo "[" . date("Y-m-d h:i:s", mktime()) . "] " . $m . "\n";
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Do the work
include_once "xmpphp/XMPP.php";
output("Received instruction - (im:" . $INPUT['im'] . ",email:" . $INPUT['email'] . ",subject:" . $INPUT['subject'] . ",message:" . $INPUT['message'] . ")");
$im_sent = false;
// Try an IM
try {
    // Attempt to connect and get user roster.
    $conn = new XMPPHP_XMPP($XMPP['server'], $XMPP['port'], $XMPP['username'], $XMPP['password'], $XMPP['resource'], $XMPP['domain']);
    output("Connecting to IM server....");
    $conn->connect();
    $conn->processUntil('session_start');
    $conn->presence();
    output("Retrieving roster....");
    $conn->getRoster();
    $roster = $conn->roster;
    // No specific event to signify end, so use timer instead. 3s should be enough.
    $conn->processTime(3);
    // Determine status of user.
    $active = $roster->getPresence($INPUT['im']);
    output("User " . $INPUT['im'] . " state is '" . $active['show'] . "'....");
    $online = in_array($active['show'], $CONFIG['notify_status']);
    // If they're online, then we're all good.
    if ($online) {
        output("Notifying user via IM....");
        $conn->message($INPUT['im'], $INPUT['subject'] . "\n" . $INPUT['message']);
        // Wait for an acknowledgement (any message sent back)
예제 #22
0
 wplc_error_log("[" . __LINE__ . "] NEW XMP REQUEST");
 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'])) {
예제 #23
0
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'On');
require_once 'classes/XMPPHP/XMPP.php';
require_once 'classes/Curl.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?
Chat::$conn = $conn = new XMPPHP_XMPP('talk.google.com', 5222, 'facepalm.service', 'tr!v!alpassword', 'xmpphp', 'gmail.com', $printlog = true, $loglevel = XMPPHP_Log::LEVEL_WARNING);
$conn->connect();
$client = FacepalmClientXMPP::getInstance();
while (!$conn->isDisconnected()) {
    $payloads = $conn->processUntil(array('message', 'session_start', 'end_stream'), 3600);
    foreach ($payloads as $event) {
        switch ($event[0]) {
            case 'message':
                if ($event[1]['body'] === NULL) {
                    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;
예제 #24
0
 * LEVEL_INFO    = 2;
 * LEVEL_DEBUG   = 3;
 * LEVEL_VERBOSE = 4;
 */
require 'XMPPHP/XMPP.php';
$conf = array('server' => 'talk.google.com', 'port' => 5222, 'username' => 'username', 'password' => 'password', 'proto' => 'xmpphp', 'domain' => 'gmail.com', 'printlog' => true, 'loglevel' => XMPPHP_Log::LEVEL_VERBOSE);
// Easy and simple for access to variables with their names
extract($conf);
$conn = new XMPPHP_XMPP($server, $port, $username, $password, $proto, $domain, $printlog, $loglevel);
$conn->autoSubscribe();
$vcard_request = array();
try {
    $conn->connect();
    while (!$conn->isDisconnected()) {
        $events = array('message', 'presence', 'end_stream', 'session_start', 'vcard');
        $payloads = $conn->processUntil($events);
        foreach ($payloads as $result) {
            list($event, $data) = $result;
            if (isset($data)) {
                extract($data);
            }
            switch ($event) {
                case 'message':
                    if (!$body) {
                        break;
                    }
                    echo str_repeat('-', 80);
                    echo "Message from: {$from}";
                    if (isset($subject)) {
                        echo "Subject: {$subject}";
                    }
예제 #25
0
 pcntl_signal(SIGUSR1, "sig_handler_child");
 while (true) {
     // garbage collect, needed with long running scripts
     gc_collect_cycles();
     // memory debugging assist
     //$mem_used_curr = memory_get_peak_usage();
     //$mem_used_increase = $mem_used_curr - $mem_used_last;
     //print "[$section] @".  memory_get_usage() ." - Peak memory usage currently $mem_used_curr, last was $mem_used_last bytes (+ $mem_used_increase)\n";
     //$mem_used_last = $mem_used_curr;
     /*
     	Wait for a valid event occurs that we can process, OR
     	up to the timeout limit, in which case we then go and
     	check if there's anything in the message queue that
     	needs processing
     */
     $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'), MESSAGE_TIMEOUT_SECONDS);
     foreach ($payloads as $event) {
         $pl = $event[1];
         switch ($event[0]) {
             case 'message':
                 // check sender - we only allow messages from the configured recipient
                 if (preg_match("/^{$config[$section]["xmpp_reciever"]}\\/\\w\$/", $pl["from"])) {
                     // denied
                     $conn->message($pl["from"], $body = "Sorry you are not a user whom is permitted to talk with me. :-(");
                     $log->warning("[{$section}] Denied connection attempt from {$pl["from"]}, only connections from {$config[$section]["xmpp_reciever"]} are permitted");
                     break;
                 }
                 // trim whitespace from message
                 $pl["body"] = trim($pl["body"]);
                 // process message
                 switch ($pl["body"]) {
// Gmail User Password
$G_Pass = "******";
//Actually Register the Printer
$client = Zend_Gdata_ClientLogin::getHttpClient($G_Email, $G_Pass, 'chromiumsync');
// Get Token and Add Headers
$Client_Login_Token = $client->getClientLoginToken();
echo "Client Login Token: " . $Client_Login_Token . "<br /><br />";
// Begin XMPP
$conn = new XMPPHP_XMPP('talk.google.com', 5222, $G_Email, $G_Pass, 'xmpphp', 'gmail.com', $printlog = true, $loglevel = XMPPHP_Log::LEVEL_VERBOSE);
$conn->autoSubscribe();
$vcard_request = array();
//var_dump($conn);
try {
    $conn->connect();
    while (!$conn->isDisconnected()) {
        $payloads = $conn->processUntil(array('message', 'session_start'));
        foreach ($payloads as $event) {
            $pl = $event[1];
            switch ($event[0]) {
                case 'message':
                    $Full_JID = $conn->fulljid;
                    $Bare_JID = $conn->jid;
                    echo "<hr />";
                    //echo  "Message from: " . $pl['from'] . "<br />";
                    if ($pl['from'] == 'cloudprint.google.com') {
                        // We have received a push for this Print Proxy ID + User.
                        // Now we can /fetch print jobs for this Proxy, User, Printer ID
                        echo "Print Job Notification Received for " . $Printer_Proxy . " / " . $Bare_JID . "<br />";
                    }
                    break;
                case 'session_start':
예제 #27
0
파일: jabber.php 프로젝트: Br3nda/laconica
/**
 * connect the configured Jabber account to the configured server
 *
 * @param string $resource Resource to connect (defaults to configured resource)
 *
 * @return XMPPHP connection to the configured server
 */
function jabber_connect($resource = null)
{
    static $conn = null;
    if (!$conn) {
        $conn = new XMPPHP_XMPP(common_config('xmpp', 'host') ? common_config('xmpp', 'host') : common_config('xmpp', 'server'), common_config('xmpp', 'port'), common_config('xmpp', 'user'), common_config('xmpp', 'password'), $resource ? $resource : common_config('xmpp', 'resource'), common_config('xmpp', 'server'), common_config('xmpp', 'debug') ? true : false, common_config('xmpp', 'debug') ? XMPPHP_Log::LEVEL_VERBOSE : null);
        if (!$conn) {
            return false;
        }
        $conn->autoSubscribe();
        $conn->useEncryption(common_config('xmpp', 'encryption'));
        try {
            $conn->connect(true);
            // true = persistent connection
        } catch (XMPPHP_Exception $e) {
            common_log(LOG_ERR, $e->getMessage());
            return false;
        }
        $conn->processUntil('session_start');
    }
    return $conn;
}
예제 #28
0
 /**
  * Checking if the given username exists and the given text password 
  * is correct by trying to connect to and authenticate on xmpp server.
  * @author del Rosario Ernesto <*****@*****.**>
  * @return bool
  */
 public static function check_username_and_password($user = "", $password = "", $conf = array())
 {
     if (empty($user) || empty($password) || !isset($conf["host"]) || !isset($conf["port"])) {
         return null;
     }
     $xmpp = new XMPPHP_XMPP($conf["host"], $conf["port"], $user, $password, $conf["resource"], $conf["server"], $conf["printlog"], $conf["loglevel"]);
     try {
         $xmpp->connect();
         $xmpp->processUntil('session_start');
         $xmpp->disconnect();
         return true;
     } catch (XMPPHP_Exception $e) {
         return false;
     }
 }