summaryrefslogtreecommitdiffstats
path: root/php/Attic/examples/sample-sp/logout.php
diff options
context:
space:
mode:
Diffstat (limited to 'php/Attic/examples/sample-sp/logout.php')
-rw-r--r--php/Attic/examples/sample-sp/logout.php38
1 files changed, 31 insertions, 7 deletions
diff --git a/php/Attic/examples/sample-sp/logout.php b/php/Attic/examples/sample-sp/logout.php
index b4fd66a6..10a9ca81 100644
--- a/php/Attic/examples/sample-sp/logout.php
+++ b/php/Attic/examples/sample-sp/logout.php
@@ -75,18 +75,42 @@
# PHP 4.3.0 with OpenSSL support required
$fp = fsockopen("ssl://" . $url['host'], $url['port'], $errno, $errstr, 30) or die($errstr ($errno));
+ socket_set_timeout($fp, 10);
fwrite($fp, $soap);
- $ret = fgets($fp);
- if (!preg_match("/^HTTP\/1\\.. 200/i", $ret)) {
- die("User is already logged out");
+ // header
+ do $header .= fread($fp, 1); while (!preg_match('/\\r\\n\\r\\n$/',$header));
+
+ // chunked encoding
+ if (preg_match('/Transfer\\-Encoding:\\s+chunked\\r\\n/',$header))
+ {
+ do {
+ $byte = '';
+ $chunk_size = '';
+
+ do {
+ $chunk_size .= $byte;
+ $byte = fread($fp, 1);
+ } while ($byte != "\\r");
+
+ fread($fp, 1);
+ $chunk_size = hexdec($chunk_size);
+ $response .= fread($fp, $chunk_size);
+ fread($fp, 2);
+ } while ($chunk_size);
}
-
- while (!feof($fp)) {
- $reponse .= @fread($fp, 8192);
+ else
+ {
+ if (preg_match('/Content\\-Length:\\s+([0-9]+)\\r\\n/', $header, $matches))
+ $response = fread($fp, $matches[1]);
+ else
+ while (!feof($fp)) $response .= fread($fp, 1024);
}
-
fclose($fp);
+
+ if (!preg_match("/^HTTP\/1\\.. 200/i", $header)) {
+ die("User is already logged out");
+ }
# Destroy The PHP Session
$_SESSION = array();