연감이 62che.com에서만 동작하는 문제 해결
This commit is contained in:
+13
-4
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once('../e_lib/util.php');
|
||||||
include "func_http.php";
|
include "func_http.php";
|
||||||
|
|
||||||
function getHistory($count, $year, $month, $isFirst=0) {
|
function getHistory($count, $year, $month, $isFirst=0) {
|
||||||
@@ -72,17 +73,25 @@ function LogHistory($connect, $isFirst=0) {
|
|||||||
$admin['month'] = 12;
|
$admin['month'] = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = explode('/', __FILE__);
|
//TODO: 웹 접속이 아닌 콘솔일 경우에 대응책 필요. conf등에 저장하는 것을 고려
|
||||||
$url = '/'.$file[count($file)-3].'/'.$file[count($file)-2].'/map.php?type=2&graphic=0';
|
$current_url = util::get_current_url();
|
||||||
|
$map_path = explode('/',parse_url($current_url, PHP_URL_PASS));
|
||||||
|
array_pop($map_path);
|
||||||
|
array_push($map_path, 'map.php?type=2&graphic=0');
|
||||||
|
$map_path = join('/', $map_path);
|
||||||
|
//$file = explode('/', __FILE__);
|
||||||
|
//$url = '/'.$file[count($file)-3].'/'.$file[count($file)-2].'/map.php?type=2&graphic=0';
|
||||||
|
|
||||||
/* 소켓 통신을 통하여 필요한 html정보를 가져옴 */
|
/* 소켓 통신을 통하여 필요한 html정보를 가져옴 */
|
||||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Start HTTP');
|
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Start HTTP');
|
||||||
$http = new HTTP("62che.com", 80, 10);
|
|
||||||
|
//$http = new HTTP("62che.com", 80, 10);
|
||||||
|
$http = new HTTP(parse_url($current_url, PHP_URL_HOST), parse_url($current_url, PHP_URL_PORT), 10);
|
||||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Connect end, '.$http->GetError());
|
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Connect end, '.$http->GetError());
|
||||||
if($http->GetErr() == true) { return false; }
|
if($http->GetErr() == true) { return false; }
|
||||||
$http->setHttpVersion("1.1");
|
$http->setHttpVersion("1.1");
|
||||||
$cookie = "";
|
$cookie = "";
|
||||||
$http->Get($url, $cookie);
|
$http->Get($map_path, $cookie);
|
||||||
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Response end, '.$http->GetError());
|
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Response end, '.$http->GetError());
|
||||||
if($http->GetErr() == true) { return false; }
|
if($http->GetErr() == true) { return false; }
|
||||||
$map = $http->Response["body"];
|
$map = $http->Response["body"];
|
||||||
|
|||||||
+30
-29
@@ -27,9 +27,9 @@ class HTTP{
|
|||||||
|
|
||||||
function Head($Url = "/") {
|
function Head($Url = "/") {
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("HEAD %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
|
|
||||||
return $this->Read();
|
return $this->Read();
|
||||||
@@ -37,12 +37,12 @@ class HTTP{
|
|||||||
|
|
||||||
function isHead($Url = "/"){
|
function isHead($Url = "/"){
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("HEAD %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$msg .= $this->PutCookie($Cookie);
|
$msg .= $this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
|
|
||||||
return $this->isOK();
|
return $this->isOK();
|
||||||
@@ -50,9 +50,9 @@ class HTTP{
|
|||||||
|
|
||||||
function GetHead($Url = "/") {
|
function GetHead($Url = "/") {
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("GET %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
$out = $this->ReadHeader();
|
$out = $this->ReadHeader();
|
||||||
return $out;
|
return $out;
|
||||||
@@ -60,36 +60,36 @@ class HTTP{
|
|||||||
|
|
||||||
function Get($Url = "/", $Cookie="") {
|
function Get($Url = "/", $Cookie="") {
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("GET %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$msg .= $this->PutCookie($Cookie);
|
$msg .= $this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
return $this->Read();
|
return $this->Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isGet($Url = "/", $Cookie=""){
|
function isGet($Url = "/", $Cookie=""){
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("GET %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$msg .= $this->PutCookie($Cookie);
|
$msg .= $this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
return $this->isOK();
|
return $this->isOK();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isGetAll($Url = "/", $Cookie=""){
|
function isGetAll($Url = "/", $Cookie=""){
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
$msg = sprintf("GET %s HTTP/%s\n", $this->Url, $this->HttpVersion);
|
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$msg .= $this->PutCookie($Cookie);
|
$msg .= $this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$msg .= $this->PutHead();
|
$msg .= $this->PutHead();
|
||||||
$msg .= "\n\n";
|
$msg .= "\r\n\r\n";
|
||||||
fputs($this->Socket, $msg);
|
fputs($this->Socket, $msg);
|
||||||
|
|
||||||
$data = $this->Read();
|
$data = $this->Read();
|
||||||
@@ -99,53 +99,53 @@ class HTTP{
|
|||||||
|
|
||||||
function Post($Url, $Data, $Cookie = ""){
|
function Post($Url, $Data, $Cookie = ""){
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
fputs ($this->Socket,sprintf("POST %s HTTP/%s\n", $this->Url, $this->HttpVersion));
|
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$this->PutCookie($Cookie);
|
$this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$this->PutHead();
|
$this->PutHead();
|
||||||
fputs ($this->Socket, "Content-type: application/x-www-form-urlencoded\n");
|
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||||
$out = "";
|
$out = "";
|
||||||
while (list ($k, $v) = each ($Data)) {
|
while (list ($k, $v) = each ($Data)) {
|
||||||
if(strlen($out) != 0) $out .= "&";
|
if(strlen($out) != 0) $out .= "&";
|
||||||
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
||||||
}
|
}
|
||||||
fputs ($this->Socket, "Content-length: ".strlen($out)."\n\n");
|
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n");
|
||||||
fputs ($this->Socket, "$out");
|
fputs($this->Socket, "$out");
|
||||||
fputs ($this->Socket, "\n");
|
fputs($this->Socket, "\r\n");
|
||||||
return $this->Read();
|
return $this->Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
function IsPost($Url, $Data, $Cookie = ""){
|
function IsPost($Url, $Data, $Cookie = ""){
|
||||||
$this->Url = $Url;
|
$this->Url = $Url;
|
||||||
fputs ($this->Socket,sprintf("POST %s HTTP/%s\n", $this->Url, $this->HttpVersion));
|
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
|
||||||
if($Cookie != ""){
|
if($Cookie != ""){
|
||||||
$this->PutCookie($Cookie);
|
$this->PutCookie($Cookie);
|
||||||
}
|
}
|
||||||
$this->PutHead();
|
$this->PutHead();
|
||||||
fputs ($this->Socket, "Content-type: application/x-www-form-urlencoded\n");
|
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
|
||||||
$out = "";
|
$out = "";
|
||||||
while (list ($k, $v) = each ($Data)) {
|
while (list ($k, $v) = each ($Data)) {
|
||||||
if(strlen($out) != 0) $out .= "&";
|
if(strlen($out) != 0) $out .= "&";
|
||||||
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
$out .= rawurlencode($k). "=" .rawurlencode($v);
|
||||||
}
|
}
|
||||||
fputs ($this->Socket, "Content-length: ".strlen($out)."\n\n");
|
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n\r\n");
|
||||||
fputs ($this->Socket, "$out");
|
fputs($this->Socket, "$out");
|
||||||
fputs ($this->Socket, "\n");
|
fputs($this->Socket, "\r\n");
|
||||||
return $this->isOk();
|
return $this->isOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
function PutHead(){
|
function PutHead(){
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$msg .= "Accept: */*\n";
|
$msg .= "Accept: */*\r\n";
|
||||||
$msg .= "Accept-Language: ko\n";
|
$msg .= "Accept-Language: ko\r\n";
|
||||||
$msg .= "Accept-Encoding: gzip, deflate\n";
|
$msg .= "Accept-Encoding: gzip, deflate\r\n";
|
||||||
$msg .= "User-Agent: Mozilla/4.0 (compatible; 62che)\n";
|
$msg .= "User-Agent: Mozilla/4.0 (compatible; 62che)\r\n";
|
||||||
while (list($name, $value) = each ($this->headers)) {
|
while (list($name, $value) = each ($this->headers)) {
|
||||||
$msg .= "$name: $value\n";
|
$msg .= "$name: $value\r\n";
|
||||||
}
|
}
|
||||||
$msg .= "Host: ".$this->Server.":".$this->Port."\n";
|
$msg .= "Host: ".$this->Server.":".$this->Port."\r\n";
|
||||||
$msg .= "Connection: close\n";
|
$msg .= "Connection: close\r\n";
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +173,7 @@ class HTTP{
|
|||||||
$chunked = isset($this->Response['transfer-encoding']) && ('chunked' == $this->Response['transfer-encoding']);
|
$chunked = isset($this->Response['transfer-encoding']) && ('chunked' == $this->Response['transfer-encoding']);
|
||||||
$gzipped = isset($this->Response['content-encoding']) && ('gzip' == $this->Response['content-encoding']);
|
$gzipped = isset($this->Response['content-encoding']) && ('gzip' == $this->Response['content-encoding']);
|
||||||
$body = '';
|
$body = '';
|
||||||
|
$this->_chunkLength = 0;
|
||||||
while(!feof($this->Socket)){
|
while(!feof($this->Socket)){
|
||||||
if ($chunked) {
|
if ($chunked) {
|
||||||
$buf = $this->_readChunked();
|
$buf = $this->_readChunked();
|
||||||
|
|||||||
Reference in New Issue
Block a user