Revision: 1625
Updated Code
at October 31, 2006 14:40 by ryansobol
Updated Code
function send_http_request($host, $path, $args, $method)
{
if (empty($host) || empty($path) || empty($args) || empty($method)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
$method $path HTTP/1.0
Host: $host
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($host, 80))
{
$result = fwrite($socket, $output);
fclose($socket);
return $result;
}
return false;
}
Revision: 1624
Updated Code
at October 31, 2006 14:35 by ryansobol
Updated Code
function send_http_request($host, $path, $args, $method)
{
if (empty($host) || empty($path) || empty($args) || empty($method)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
$method $path HTTP/1.0
Host: $host
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($host, 80))
{
fwrite($socket, $output);
fclose($socket);
return true;
}
return false;
}
Revision: 1623
Updated Code
at October 31, 2006 14:31 by ryansobol
Updated Code
function send_request($host, $path, $args, $method)
{
if (empty($host) || empty($path) || empty($args) || empty($method)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
$method $path HTTP/1.0
Host: $host
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($host, 80))
{
fwrite($socket, $output);
fclose($socket);
return true;
}
return false;
}
Revision: 1622
Updated Code
at October 31, 2006 14:28 by ryansobol
Updated Code
function send_request($host, $path, $args, $method)
{
if (empty($path) || empty($args)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
$method $path HTTP/1.0
Host: $host
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($host, 80))
{
fwrite($socket, $output);
fclose($socket);
return true;
}
return false;
}
Revision: 1621
Updated Code
at October 31, 2006 14:27 by ryansobol
Updated Code
function post_request($host, $path, $args, $method)
{
if (empty($path) || empty($args)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
$method $path HTTP/1.0
Host: $host
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($host, 80))
{
fwrite($socket, $output);
fclose($socket);
return true;
}
return false;
}
Revision: 1620
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 31, 2006 14:23 by ryansobol
Initial Code
function post_request($path, $args)
{
if (empty($path) || empty($args)) return false;
$temp = array();
foreach ($args as $key => $value) { array_push($temp, "$key=$value"); }
$params = implode("&", $temp);
$params_length = strlen($params);
$output = <<<END
POST $path HTTP/1.0
Host: $_SERVER[SERVER_NAME]
User-Agent: PHP-script
Content-Type: application/x-www-form-urlencoded
Content-Length: $params_length
$params
END;
global $logger; $logger->debug($output);
if ($socket = fsockopen($_SERVER['SERVER_NAME'], 80))
{
fwrite($socket, $output);
fclose($socket);
return true;
}
return false;
}
Initial URL
Initial Description
Sends a request to a supplied path for a given host. It can send either a GET or POST request and can pass parameters.
Initial Title
send_http_request()
Initial Tags
http, php, post
Initial Language
PHP