예제 #1
0
 /**
  * Requests authorisation, so that our jabber account is allowed to send messages to the users.
  * @param string $email
  * @access public static
  * @return bool
  */
 function JabberRequestAuth($email)
 {
     global $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;
     }
     if (!isset($fs->prefs['jabber_ssl'])) {
         $fs->prefs['jabber_ssl'] = true;
     }
     $JABBER = new Jabber($fs->prefs['jabber_username'], $fs->prefs['jabber_password'], $fs->prefs['jabber_ssl'], $fs->prefs['jabber_port']);
     $JABBER->login();
     $JABBER->send("<presence to='" . Jabber::jspecialchars($email) . "' type='subscribe'/>");
     $JABBER->disconnect();
 }
예제 #2
0
 public function send_message($to, $text, $subject = '', $type = 'normal')
 {
     if (!isset($this->session['jid'])) {
         return false;
     }
     if (!in_array($type, array('chat', 'normal', 'error', 'groupchat', 'headline'))) {
         $type = 'normal';
     }
     return $this->send("<message from='" . Jabber::jspecialchars($this->session['jid']) . "'\n                                     to='" . Jabber::jspecialchars($to) . "'\n                                     type='{$type}'\n                                     id='" . uniqid('msg') . "'>\n                              <subject>" . Jabber::jspecialchars($subject) . "</subject>\n                              <body>" . Jabber::jspecialchars($text) . "</body>\n                            </message>");
 }