Revision 262,
1.8 KB
checked in by niltonneto, 16 years ago
(diff) |
|
-
Property svn:executable set to
*
|
Rev | Line | |
---|
[262] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $fp = stream_socket_client("tcp://im.pr.gov.br:8800", $errno, $errstr, 30); |
---|
| 4 | if (!$fp) { |
---|
| 5 | die("Unable to connect: $errstr ($errno)"); |
---|
| 6 | } |
---|
| 7 | |
---|
| 8 | $xml = "<?xml version='1.0' ?>"; |
---|
| 9 | $xml .= "<stream:stream to='im.pr.gov.br' xmlns='jabber:client' "; |
---|
| 10 | $xml .= "xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; |
---|
| 11 | fwrite($fp, $xml); |
---|
| 12 | usleep(50000); |
---|
| 13 | echo fread($fp, 4096); |
---|
| 14 | echo "\n\n"; |
---|
| 15 | |
---|
| 16 | $xml = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"; |
---|
| 17 | fwrite($fp, $xml); |
---|
| 18 | usleep(50000); |
---|
| 19 | echo fread($fp, 4096); |
---|
| 20 | echo "\n\n"; |
---|
| 21 | |
---|
| 22 | stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); |
---|
| 23 | |
---|
| 24 | $xml = "<?xml version='1.0' encoding='UTF-8'?>"; |
---|
| 25 | $xml .= "<stream:stream to='im.pr.gov.br' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>"; |
---|
| 26 | fwrite($fp, $xml); |
---|
| 27 | usleep(50000); |
---|
| 28 | echo fread($fp, 4096); |
---|
| 29 | echo "\n\n"; |
---|
| 30 | |
---|
| 31 | usleep(50000); |
---|
| 32 | echo fread($fp, 4096); |
---|
| 33 | echo "\n\n"; |
---|
| 34 | |
---|
| 35 | $xml = "<iq type='set' id='conn'><query xmlns='jabber:iq:auth'>"; |
---|
| 36 | $xml .= "<username>teste9</username>"; |
---|
| 37 | $xml .= "<password>teste99</password>"; |
---|
| 38 | $xml .= "<resource>IM</resource>"; |
---|
| 39 | $xml .= "</query></iq>"; |
---|
| 40 | fwrite($fp, $xml); |
---|
| 41 | usleep(50000); |
---|
| 42 | echo fread($fp, 4096); |
---|
| 43 | echo "\n\n"; |
---|
| 44 | |
---|
| 45 | stream_set_blocking ($fp, false); |
---|
| 46 | $xml = "<presence xmlns='jabber:client' from='alexandrecorreia@im.pr.gov.br' />"; |
---|
| 47 | fwrite($fp, $xml); |
---|
| 48 | usleep(50000); |
---|
| 49 | //echo fread($fp, 4096); |
---|
| 50 | //echo "\n\n"; |
---|
| 51 | |
---|
| 52 | //while(1) |
---|
| 53 | //{ |
---|
| 54 | // echo fread($fp, 4096); |
---|
| 55 | // echo "\n\n"; |
---|
| 56 | // sleep(1); |
---|
| 57 | //} |
---|
| 58 | |
---|
| 59 | echo "=================================================\n\n"; |
---|
| 60 | |
---|
| 61 | $time = time(); |
---|
| 62 | do |
---|
| 63 | { |
---|
| 64 | $line = NULL; |
---|
| 65 | $line = fread($fp, 4096); |
---|
| 66 | |
---|
| 67 | if ( !empty($line) ) |
---|
| 68 | var_dump($line); |
---|
| 69 | } |
---|
| 70 | while ( time() - $time < 20 ); |
---|
| 71 | fclose($fp); |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | exit(0); |
---|
| 75 | session_start(); |
---|
| 76 | |
---|
| 77 | echo "<pre>"; |
---|
| 78 | print_r($_SESSION['debug']); |
---|
| 79 | echo "</pre>"; |
---|
| 80 | |
---|
| 81 | session_write_close(); |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.