언냐 낼 부산놀러간다..

언냐,,
낼 회사서 포상휴가 보내줘서…부산 호텔간다.
농심호텔 온천이 유명하거든..
넘 신난다..내가 온천좋아하는거 알쥐?
가서 신나게……탕욕 좀해야지…..그동안 피로가 넘많아서
다풀긴 좀 모자라겠지만,,
그담날은 파라다이스부산호텔,,,여길 내가 얼매나 가보고싶었는지..
남친이랑 가면 더 좋을텐디..
시간내기 힘드니 ..
언니 약올리는 소리밖에 안됐네…메롱메롱..
밥때다,,,,,,,,,언냐두 즐 점심하시고……………..ㅋㅋ
언냐,,화로구이먹고잡다…

소켓이용 post, get 방식으로 내용 받아오는 클래스

GET, POST를 이용해 내용을 받아오는 클래스 조회수:2806

검색해보니 나오긴 하는데 제가 필요한 기능을 갖추지 못했더군요.
그래서 제가 필요한 대로 급조해봤습니다.
혹여나 필요하신 분 있을까 해서 올려봅니다. 참조하시기 바랍니다.

사용 예:
server = “phpschool.com”;
$http->port = 80;
$http->method = “get”; // POST를 사용하시려면 post로 변경해 주세요.
$http->path = “/bbs2/inc_board.html”;

$http->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, */*”;
$http->header[“Referer”] = “http://phpschool.com/”;
$http->header[“Accept-Language”] = “ko”;
$http->header[“Content-Type”] = “application/x-www-form-urlencoded”;
$http->header[“User-Agent”] = “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)”;
$http->header[“Host”] = $http->server;
$http->header[“Connection”] = “Keep-Alive”;
$http->header[“Cache-Control”] = “no-cache”;

$http->variable[“code”] = “tnt2”;

$http->openSock();
$data_get = $http->getPage();

echo nl2br(htmlspecialchars($data));

?>

——————————————————————–
class.network.get_Page.php
——————————————————————–

var $server;
var $port;
var $method;
var $sock;
var $path;
var $header = array();
var $variable = array();
var $cmd;
var $config;

function http_get_Page() {
$this->port = 80;
$this->method = “get”;
$this->path = “/”;

$this->config = array(
“version” => “1.0”,
“name” => “Get files through http protocol”,
“debugname” => “class.network.get_Page.php”,
);
}

function openSock() {
$this->sock = @fsockopen($this->server, $this->port);
if (!$this->sock) $this->Error(“Cannot open socket [$this->server:$this->port]”);
}

function getPage() {
if (eregi(“GET”, $this->method)) {
if ($this->variable) {
$aid_url = “?”;
foreach ($this->variable as $key => $value) {
$key = urlencode($key);
$value = urlencode($value);
if ($aid_url == “?”) $aid_url .= $key.”=”.$value;
else $aid_url .= “&”.$key.”=”.$value;
}
}

$cmd = “GET “.$this->path.$aid_url.” HTTP/1.1″;
if (!$this->header) $this->Error(“No Any HTTP Headers.”);

foreach ($this->header as $key => $value) {
$cmd .= “
“.$key.”: “.$value;
}

$cmd .= “

“;
}

if (eregi(“POST”, $this->method)) {
if ($this->variable) {
$aid_query = “”;

foreach ($this->variable as $key => $value) {
$key = urlencode($key);
$value = urlencode($value);
if (!$aid_query) $aid_query .= $key.”=”.$value;
else $aid_query .= “&”.$key.”=”.$value;
}
}

$cmd = “POST “.$this->path.” HTTP/1.1″;
if (!$this->header) $this->Error(“No Any HTTP Headers.”);

$strlen = strlen($aid_query);
$this->header[“Content-Length”] = $strlen;

foreach ($this->header as $key => $value) {
$cmd .= “
“.$key.”: “.$value;
}

$cmd .= “

“;
$cmd .= $aid_query;
}

fputs($this->sock, $cmd);
$str_get = “”;

while (!feof($this->sock)) {
$str_get .= fgets($this->sock, 1024);
}

return $str_get;
}

function Error($message) {
die ($this->config[debugname].” Error: “.$message);
}
}

?>