[ get ¹æ½Ä ]
<?
$server = "itn.pe.kr";
$port = 80;
$method = "get";
$path = "/method_test.php";
$header = array();
$variable = array();
$config = array("version" => "1.0","name" => "Get files through http protocol","debugname" => "http_method.php");
$header["Accept"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
$header["Referer"] = "/";
$header["Accept-Language"] = "ko";
$header["Content-Type"] = "application/x-www-form-urlencoded";
$header["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
$header["Host"] = $server;
$header["Connection"] = "Keep-Alive";
$header["Cache-Control"] = "no-cache";
$variable["test_data"] = "Translation complete!";
$sock = @fsockopen($server, $port);
if (!$sock) $Error("Cannot open socket [$server:$port]");
if ($variable) {
$aid_url = "?";
foreach ($variable as $key => $value) {
$key = urlencode($key);
$value = urlencode($value);
if ($aid_url == "?") $aid_url .= $key."=".$value;
else $aid_url .= "&".$key."=".$value;
}
}
$cmd = "GET ".$path.$aid_url." HTTP/1.1";
if (!$header) $Error("No Any HTTP Headers.");
foreach ($header as $key => $value) {
$cmd .= "\r\n".$key.": ".$value;
}
$cmd .= "\r\n\r\n";
fputs($sock, $cmd);
$str_get = "";
while (!feof($sock)) {
$str_get .= fgets($sock, 1024);
}
echo("$str_get");
?>
[ POST ¹æ½Ä ]
<?
$server = "itn.pe.kr";
$port = 80;
$method = "post";
$path = "/method_test.php";
$header = array();
$variable = array();
$config = array("version" => "1.0","name" => "Get files through http protocol","debugname" => "http_method.php");
$header["Accept"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
$header["Referer"] = "/";
$header["Accept-Language"] = "ko";
$header["Content-Type"] = "application/x-www-form-urlencoded";
$header["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
$header["Host"] = $server;
$header["Connection"] = "Keep-Alive";
$header["Cache-Control"] = "no-cache";
$variable["test_data"] = "Translation complete!";
$sock = @fsockopen($server, $port);
if (!$sock) $Error("Cannot open socket [$server:$port]");
if ($variable) {
$aid_query = "";
foreach ($variable as $key => $value) {
$key = urlencode($key);
$value = urlencode($value);
if (!$aid_query) $aid_query .= $key."=".$value;
else $aid_query .= "&".$key."=".$value;
}
}
$cmd = "POST ".$path." HTTP/1.1";
if (!$header) $Error("No Any HTTP Headers.");
$strlen = strlen($aid_query);
$header["Content-Length"] = $strlen;
foreach ($header as $key => $value) {
$cmd .= "\r\n".$key.": ".$value;
}
$cmd .= "\r\n\r\n";
$cmd .= $aid_query;
fputs($sock,$cmd);
$str_get = "";
while (!feof($sock)) {
$str_get .= fgets($sock, 1024);
}
echo("$str_get")
?>
|