/*
* * Post message to host
*/
function Posttohost ($url, $data) {
$url = Parse_url ($url);
if (! $url) return "couldn\ ' t parse url";
if (!isset ($url [\ ' port\ ')) {$url [\ ' port\ '] = "";}
if (!isset ($url [\ ' query\ ')) {$url [\ ' query\ '] = "";}
$encoded = "";
while (list ($k, $v) = each ($data)) {
$encoded. = ($encoded? "&": "");
$encoded. = Rawurlencode ($k). " = ". Rawurlencode ($v);
}
$port = $url [\ ' port\ ']? $url [\ ' port\ ']: 80;
$fp = Fsockopen ($url [\ ' host\ '], $port, $errno, $ERRSTR);
if (! $fp) return "Failed to open socket to $url [host] $port ERROR: $errno-$errstr";
Fputs ($FP, sprintf ("POST%s%s%s http/1.0\\n", $url [\ ' path\ '], $url [\ ' query\ ']? "?": "", $url [\ ' query\ ']));
Fputs ($FP, "Host: $url [host]\\n");
Fputs ($fp, "content-type:application/x-www-form-urlencoded\\n");
Fputs ($FP, "Content-length:".) Strlen ($encoded). "\\n");
Fputs ($fp, "connection:close\\n\\n");
Fputs ($fp, "$encoded \\n");
$line = fgets ($fp, 1024);
if (!eregi ("^http/1\\. ", $line)) return;
$results = ""; $inheader = 1;
while (!feof ($fp)) {
$line = fgets ($fp, 1024);
if ($inheader && ($line = = "\\n" | | $line = = "\\r\\n") {
$inheader = 0;
}
ElseIf (! $inheader) {
$results. = $line;
}
}
Fclose ($FP);
return $results;
}/* End Function Posttohost */
?>
The above describes the Shockwave Flash Object download PHP socket submission of the post details, including the Shockwave Flash object download content, I hope the PHP tutorial interested in a friend helpful.