From 2b01b838c802226ad8f097aa5b7f4512de73d8e7 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 6 Dec 2001 17:29:15 +0000 Subject: - Removed annoying Windows end-of-line characters. --- modules/jabber.module | 316 +++++++++++++++++++++++++------------------------- 1 file changed, 158 insertions(+), 158 deletions(-) (limited to 'modules/jabber.module') diff --git a/modules/jabber.module b/modules/jabber.module index 5eaceb65d..c16f1f419 100644 --- a/modules/jabber.module +++ b/modules/jabber.module @@ -1,159 +1,159 @@ -"; - - fwrite($session, $message, strlen($message)); -} - -function jabber_recv($session, $timout = 50) { - - /* - ** Returns a chunk of data, read from the socket descriptor '$session'. - ** If the call fails, or if no data is read after the specified timout, - ** false will be returned. - */ - - while ($count < $timout) { - $data = fread($session, 1); - if ($data) { - $message .= $data; - } - else { - usleep(100); - $count = $count + 1; - } - } - - if ($message) { - // print "RECV: ". htmlentities($message) ."
"; - - return $message; - } - else { - return 0; - } -} - -function jabber_auth($username, $password, $server) { - global $jabber; - - $session = fsockopen($server, 5222, $errno, $errstr, 5); - - if ($session) { - - $xml_parser = xml_parser_create(); - xml_set_element_handler($xml_parser, "startElement", "endElement"); - xml_set_character_data_handler($xml_parser, "characterData"); - - /* - ** Switch the given socket descriptor '$session' to non-blocking mode: - */ - - set_socket_blocking($session, false); - - /* - ** A jabber session consists of two parallel XML streams, one from - ** the client to the server and one from the server to the client. - ** On connecting to a Jabber server, a Jabber client initiates the - ** client-to-server XML stream and the server responds by initiating - ** the server-to-client XML stream: - */ - - jabber_send($session, ""); - - jabber_send($session, ""); - - $data = jabber_recv($session); - - if (!xml_parse($xml_parser, $data, 0)) { - watchdog("error", "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser)); - return 0; - } - - if ($jabber["error"]) { - watchdog("error", "protocol error: ". $jabber["data"]); - return 0; - } - - /* - ** Hash the password: - */ - - jabber_send($session, "$username$passworddrupal"); - - $data = jabber_recv($session); - - if (!xml_parse($xml_parser, $data, 0)) { - watchdog("error", "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser)); - } - - if ($jabber["error"]) { - watchdog("error", "protocol error: ". $jabber["data"]); - return 0; - } - - xml_parser_free($xml_parser); - - return 1; - } - else { - watchdog("error", "failed to open socket to jabber server:\n $errno, $errstr"); - - return 0; - } -} - -function jabber_page() { - global $theme; - - $theme->header(); - $theme->box("Jabber", jabber_auth_help()); - $theme->footer(); -} - -function jabber_auth_help() { - $site = variable_get("site_name", "this web site"); - - $output = " -

You may login to %s using a Jabber ID. The format of a Jabber ID is the same as an email address: name@server An example of valid Jabber ID is mwlily@jabber.com.

-

Jabber is an open source instant messaging system designed to give the power of choice and freedom back to the users of instant messaging. By creating an extensible and powerful server and protocol, Jabber has succeeded in this goal. Not only does Jabber allow its users to use (and create) clients for numerous platforms, but it allows people to communicate to whomever they want in the way which is most convenient for them.

"; - - return sprintf(t($output), $site); -} - +"; + + fwrite($session, $message, strlen($message)); +} + +function jabber_recv($session, $timout = 50) { + + /* + ** Returns a chunk of data, read from the socket descriptor '$session'. + ** If the call fails, or if no data is read after the specified timout, + ** false will be returned. + */ + + while ($count < $timout) { + $data = fread($session, 1); + if ($data) { + $message .= $data; + } + else { + usleep(100); + $count = $count + 1; + } + } + + if ($message) { + // print "RECV: ". htmlentities($message) ."
"; + + return $message; + } + else { + return 0; + } +} + +function jabber_auth($username, $password, $server) { + global $jabber; + + $session = fsockopen($server, 5222, $errno, $errstr, 5); + + if ($session) { + + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + + /* + ** Switch the given socket descriptor '$session' to non-blocking mode: + */ + + set_socket_blocking($session, false); + + /* + ** A jabber session consists of two parallel XML streams, one from + ** the client to the server and one from the server to the client. + ** On connecting to a Jabber server, a Jabber client initiates the + ** client-to-server XML stream and the server responds by initiating + ** the server-to-client XML stream: + */ + + jabber_send($session, ""); + + jabber_send($session, ""); + + $data = jabber_recv($session); + + if (!xml_parse($xml_parser, $data, 0)) { + watchdog("error", "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser)); + return 0; + } + + if ($jabber["error"]) { + watchdog("error", "protocol error: ". $jabber["data"]); + return 0; + } + + /* + ** Hash the password: + */ + + jabber_send($session, "$username$passworddrupal"); + + $data = jabber_recv($session); + + if (!xml_parse($xml_parser, $data, 0)) { + watchdog("error", "XML error: '". xml_error_string(xml_get_error_code($xml_parser)) ."' at line ". xml_get_current_line_number($xml_parser)); + } + + if ($jabber["error"]) { + watchdog("error", "protocol error: ". $jabber["data"]); + return 0; + } + + xml_parser_free($xml_parser); + + return 1; + } + else { + watchdog("error", "failed to open socket to jabber server:\n $errno, $errstr"); + + return 0; + } +} + +function jabber_page() { + global $theme; + + $theme->header(); + $theme->box("Jabber", jabber_auth_help()); + $theme->footer(); +} + +function jabber_auth_help() { + $site = variable_get("site_name", "this web site"); + + $output = " +

You may login to %s using a Jabber ID. The format of a Jabber ID is the same as an email address: name@server An example of valid Jabber ID is mwlily@jabber.com.

+

Jabber is an open source instant messaging system designed to give the power of choice and freedom back to the users of instant messaging. By creating an extensible and powerful server and protocol, Jabber has succeeded in this goal. Not only does Jabber allow its users to use (and create) clients for numerous platforms, but it allows people to communicate to whomever they want in the way which is most convenient for them.

"; + + return sprintf(t($output), $site); +} + ?> \ No newline at end of file -- cgit v1.2.3