//alllow_url_fone = Off 설정에 따른 fsockopen 사용함수
$url_parsed = parse_url($url);
$host = $url_parsed["host"];
$port = $url_parsed["port"]; $port = $port ==0 ? 80 :$port;
$path = $url_parsed["path"];
//if url is without final "/"
//I was getting a 400 error
$path = empty($path) ? "/" : $path; //redirection if url is in wrong format
if (empty($host)){
$host=" ";
$path="/wrong.htm";
} if ($url_parsed["query"] != "") {$path .= "?".$url_parsed["query"];}
$out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
fwrite($fp, $out); $output = 0;
while (!feof($fp)) {
$get_str = fgets($fp, 128);
if($output == 0 && $get_str=="\r\n") {
$output = 1;
}
if($output) echo $get_str; }
fclose($fp);
return;
} //호출부
선언부
function url_include( $url ) {$url_parsed = parse_url($url);
$host = $url_parsed["host"];
$port = $url_parsed["port"]; $port = $port ==0 ? 80 :$port;
$path = $url_parsed["path"];
//if url is without final "/"
//I was getting a 400 error
$path = empty($path) ? "/" : $path; //redirection if url is in wrong format
if (empty($host)){
$host=" ";
$path="/wrong.htm";
} if ($url_parsed["query"] != "") {$path .= "?".$url_parsed["query"];}
$out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
$fp = fsockopen($host, $port, $errno, $errstr, 30);
fwrite($fp, $out); $output = 0;
while (!feof($fp)) {
$get_str = fgets($fp, 128);
if($output == 0 && $get_str=="\r\n") {
$output = 1;
}
if($output) echo $get_str; }
fclose($fp);
return;
} //호출부
if(!empty($_url)) {
url_include($_totalUrl);
}
728x90
'강좌 및 설정 > 기타 설정' 카테고리의 다른 글
ip 주소 확인 (0) | 2022.07.18 |
---|---|
vscode 단축키 모음 (0) | 2022.07.17 |
VS CODE 사용자 코드 조각 html:ko 설정 (0) | 2022.07.15 |
ssl 관련 (0) | 2012.09.05 |
docx 파일 열기시 zip으로 확장자 변경현상 (0) | 2010.07.22 |