Guys,
Im having an issue with my code. I am trying to forward the POST data based upon the info in an array.
<?
function get_host ($url)
{
$host = trim ($url);
if (strcasecmp (substr ($host, 0, 7), 'http://') == 0) { $host = substr ($host, 7); }
if (strpos ($host, '/') !== FALSE)
{ $host = substr ($host, 0, strpos ($host, '/')); }
return $host;
}
function get_uri ($url)
{
$uri = trim ($url);
if (strcasecmp (substr ($uri, 0, 7), 'http://') == 0) { $uri = substr ($uri, 7); }
if (strpos ($uri, '/') !== FALSE)
{
$uri = substr ($uri, strpos ($uri, '/')); }
return $uri;
}
require 'config.php';
$ipn_count = count ($ipn);
$i = 0;
while ($i < $ipn_count)
{
if (rtrim ($ipn[$i]) !== '')
{
$ipn_arr = explode (',', $ipn[$i]);
if (1 < count ($ipn_arr))
{
if (strcasecmp ($ipn_arr[0], $_POST['business']) == 0)
{
$url = $ipn_arr[1];
}
}
}
$i++;
}
if (rtrim ($url) !== '')
{
foreach ($_POST as $key => $value) {
$value = urlencode (stripslashes ($value));
$req .= "&$key=$value";
}
$host = get_host ($url);
$uri = get_uri ($url);
$header .= "POST $uri HTTP/1.0\r\n";
$header .= "Host: $host:80\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$header .= "Connection: Close";
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp)
{
}
else
{
fputs ($fp, $header . $req);
}
fclose ($fp);
}
?>
It forwards the requests, so I know the array is working, but it does not forward all the data contained in the original POST. What am I doing wrong? Is there a way of logging all POST requests to the script so I can debug?
Chris.