Virker ikke som om at skidtet faktisk poster noget ??
Og den returnerer ikke det data der ligger i Arrayen, kun HTTP Headeren.
Umm... WTF ??
<?php
/*
Sample code calling PostIt(). Note (no pun intended) that it is better to
test for an error result with isset() rather than simply
if ($Result[\"errno\"])
as the error number can be zero.
*/
include(\"postit.php\");
$d[\"select\"] = \"All\";
$d[\"for\"] = \"The Usual Suspects\";
$Result = PostIt($d, \"status.php\");
if (isset($Result[\"errno\"])) {
$errno = $Result[\"errno\"]; $errstr = $Result[\"errstr\"];
echo \"<B>Error $errno</B> $errstr\";
exit;
}
else {
while (list($key, $val) = each($Result)) echo $val;
}
?>
<?php
/************************************************************************
*
* PostIt - Pretend to be a form.
*
* Copyright (c) 1999 Holotech Enterprises. All rights reserved.
* You may freely modify and use this function for your own purposes. You
* may freely distribute it, without modification and with this notice
* and entire header intact.
*
* This function takes an associative array and a URL. The array is URL-
* encoded and then POSTed to the URL. If the request succeeds, the
* response, if any, is returned in a scalar array. Outputting this is the
* caller\'s responsibility; bear in mind that it will include the HTTP
* headers. If the request fails, an associative array is returned with the
* elements \'errno\' and \'errstr\' corresponding to the error number and
* error message. If you have any questions or comments, please direct
* them to postit@holotech.net
*
* Alan Little
* Holotech Enterprises
*
http://www.holotech.net/ * December 1999
*
************************************************************************/
function PostIt($DataStream, $URL) {
// Strip http:// from the URL if present
$URL = ereg_replace(\"^
http://\", \"\", $URL);
// Separate into Host and URI
$Host = substr($URL, 0, strpos($URL, \"/\"));
$URI = strstr($URL, \"/\");
// Form up the request body
$ReqBody = \"\";
while (list($key, $val) = each($DataStream)) {
if ($ReqBody) $ReqBody.= \"&\";
$ReqBody.= $key.\"=\".urlencode($val);
}
$ContentLength = strlen($ReqBody);
// Generate the request header
$ReqHeader =
\"POST $URI HTTP/1.0\\n\".
\"Host: $Host\\n\".
\"User-Agent: PostIt\\n\".
\"Content-Type: application/x-www-form-urlencoded\\n\".
\"Content-Length: $ContentLength\\n\\n\".
\"$ReqBody\\n\";
// echo $ReqHeader;
// Open the connection to the host
$socket = fsockopen($Host, 80, &$errno, &$errstr);
if (!$socket) {
$Result[\"errno\"] = $errno;
$Result[\"errstr\"] = $errstr;
return $Result;
}
$idx = 0;
fputs($socket, $ReqHeader);
while (!feof($socket) && $Result[$idx-1] != \"0\\r\\n\") {
if (substr($Result[$idx-1], 0, 2) == \"0\\r\\n\") echo \"The End:\".strlen($Result[$idx-1]);
$Result[$idx++] = fgets($socket, 128);
}
return $Result;
}
?>