e_lib 코드들을 composer로 이동

func_http 삭제. guzzle로 대체

php 파일에서 include, require 앞에 있는 구문들을 전부 뒤로 이동.
This commit is contained in:
2018-01-28 21:38:04 +09:00
parent d422c03003
commit 373bcde70b
263 changed files with 22305 additions and 11284 deletions
-1
View File
@@ -1,7 +1,6 @@
<?php
include "lib.php";
include "func.php";
require_once '../e_lib/util.php';
//로그인 검사
$isgen = util::array_get($_POST['isgen'], '');
+1 -2
View File
@@ -1,8 +1,7 @@
<?php
$yearmonth = $_POST['yearmonth'];
include "lib.php";
include "func.php";
$yearmonth = $_POST['yearmonth'];
//로그인 검사
CheckLogin();
$connect = dbConn();
+4 -2
View File
@@ -1,8 +1,10 @@
<?php
// $btn0~15, $gold0~15
include "lib.php";
include "func.php";
// $btn0~15, $gold0~15
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $title, $msg, $num
include "lib.php";
include "func.php";
// $title, $msg, $num
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $btn, $msg, $scoutmsg, $rate, $bill, $secretlimit
include "lib.php";
include "func.php";
// $btn, $msg, $scoutmsg, $rate, $bill, $secretlimit
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $turn, $command, $cost, $name, $nationname, $note, $double, $third, $fourth
include "lib.php";
include "func.php";
// $turn, $command, $cost, $name, $nationname, $note, $double, $third, $fourth
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $msg, $genlist
include "lib.php";
include "func.php";
// $msg, $genlist
//로그인 검사
CheckLogin(1);
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $btn, $level, $genlist, $outlist
include "lib.php";
include "func.php";
// $btn, $level, $genlist, $outlist
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $title, $msg, $num
include "lib.php";
include "func.php";
// $title, $msg, $num
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $msg
include "lib.php";
include "func.php";
// $msg
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $btn, $msg
include "lib.php";
include "func.php";
// $btn, $msg
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
// $btn, $name, $troop
include "lib.php";
include "func.php";
// $btn, $name, $troop
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,8 +1,8 @@
<?php
//TODO: 등용장 재 디자인.
//xxx: 일단 비활성화
die("<script>location.replace('msglist.php');</script>");
header('Location:msglist.php');
die();
include "lib.php";
include "func.php";
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
include "lib.php";
include "func.php";
//////////////////////////장수성격//////////////////////////////////////////////
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
////////////////////////////////////////////////////////////////////////
include "lib.php";
include "func.php";
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
include "lib.php";
include "func.php";
//////////////////////////장수성격//////////////////////////////////////////////
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
////////////////////////////////////////////////////////////////////////
include "lib.php";
include "func.php";
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
include "lib.php";
include "func.php";
//////////////////////////장수성격//////////////////////////////////////////////
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
////////////////////////////////////////////////////////////////////////
include "lib.php";
include "func.php";
//로그인 검사
CheckLogin();
$connect = dbConn();
+2 -2
View File
@@ -1,10 +1,10 @@
<?php
include "lib.php";
include "func.php";
//////////////////////////장수성격//////////////////////////////////////////////
//은둔 안전 유지 재간 출세 할거 정복 패권 의협 대의 왕좌
////////////////////////////////////////////////////////////////////////
include "lib.php";
include "func.php";
//로그인 검사
CheckLogin();
$connect = dbConn();
+5 -19
View File
@@ -1,6 +1,5 @@
<?php
require_once('../e_lib/util.php');
include "func_http.php";
require(__dir__.'/../vendor/autoload.php');
function getHistory($count, $year, $month, $isFirst=0) {
$fp = @fopen("logs/_history.txt", "r");
@@ -79,26 +78,13 @@ function LogHistory($connect, $isFirst=0) {
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정보를 가져옴 */
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Start HTTP');
//$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($http->GetErr() == true) { return false; }
$http->setHttpVersion("1.1");
$cookie = "";
$http->Get($map_path, $cookie);
if(STEP_LOG) pushStepLog(date('Y-m-d H:i:s').', Response end, '.$http->GetError());
if($http->GetErr() == true) { return false; }
$map = $http->Response["body"];
$client = new GuzzleHttp\Client();
$response = $client->get($map_path);
$map = (string)$response->getBody();
$map = str_replace("'", '<_quot_>', $map);
$map = str_replace('"', '<_dquot_>', $map);
$http->Close();
if($http->GetErr() == true) { return false; }
$log = getHistory(20, $admin['year'], $admin['month'], $isFirst);
$genlog = getGenHistory(50, $admin['year'], $admin['month'], $isFirst);
-288
View File
@@ -1,288 +0,0 @@
<?php
class HTTP{
var $Socket, $Server, $Port, $Timeout, $HttpVersion = "1.0", $Url, $Length, $ResponseTime, $ErrNum, $ErrMsg;
var $headers = array();
var $Response = array();
var $Err = false;
var $_chunkedLength =0;
function HTTP($Server, $Port = 80, $Timeout = 30){
$this->Server = $Server;
$this->Port = $Port;
$this->Timeout = $Timeout;
$this->Socket = @fsockopen ($this->Server, $this->Port, $errno, $errstr, $this->Timeout);
if(!$this->Socket){
$this->Error(0, "Socket Connection Fail");
}
}
function setTimeout($Timeout){
$this->Timeout = $Timeout;
}
function setHttpVersion($HttpVersion){
$this->HttpVersion = $HttpVersion;
}
function Head($Url = "/") {
$this->Url = $Url;
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
return $this->Read();
}
function isHead($Url = "/"){
$this->Url = $Url;
$msg = sprintf("HEAD %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
if($Cookie != ""){
$msg .= $this->PutCookie($Cookie);
}
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
return $this->isOK();
}
function GetHead($Url = "/") {
$this->Url = $Url;
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
$out = $this->ReadHeader();
return $out;
}
function Get($Url = "/", $Cookie="") {
$this->Url = $Url;
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
if($Cookie != ""){
$msg .= $this->PutCookie($Cookie);
}
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
return $this->Read();
}
function isGet($Url = "/", $Cookie=""){
$this->Url = $Url;
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
if($Cookie != ""){
$msg .= $this->PutCookie($Cookie);
}
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
return $this->isOK();
}
function isGetAll($Url = "/", $Cookie=""){
$this->Url = $Url;
$msg = sprintf("GET %s HTTP/%s\r\n", $this->Url, $this->HttpVersion);
if($Cookie != ""){
$msg .= $this->PutCookie($Cookie);
}
$msg .= $this->PutHead();
$msg .= "\r\n\r\n";
fputs($this->Socket, $msg);
$data = $this->Read();
$this->Length = strlen($data);
return $this->isOK($data);
}
function Post($Url, $Data, $Cookie = ""){
$this->Url = $Url;
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
if($Cookie != ""){
$this->PutCookie($Cookie);
}
$this->PutHead();
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
$out = "";
while (list ($k, $v) = each ($Data)) {
if(strlen($out) != 0) $out .= "&";
$out .= rawurlencode($k). "=" .rawurlencode($v);
}
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n");
fputs($this->Socket, "$out");
fputs($this->Socket, "\r\n");
return $this->Read();
}
function IsPost($Url, $Data, $Cookie = ""){
$this->Url = $Url;
fputs($this->Socket,sprintf("POST %s HTTP/%s\r\n", $this->Url, $this->HttpVersion));
if($Cookie != ""){
$this->PutCookie($Cookie);
}
$this->PutHead();
fputs($this->Socket, "Content-type: application/x-www-form-urlencoded\r\n");
$out = "";
while (list ($k, $v) = each ($Data)) {
if(strlen($out) != 0) $out .= "&";
$out .= rawurlencode($k). "=" .rawurlencode($v);
}
fputs($this->Socket, "Content-length: ".strlen($out)."\r\n\r\n");
fputs($this->Socket, "$out");
fputs($this->Socket, "\r\n");
return $this->isOk();
}
function PutHead(){
$msg = "";
$msg .= "Accept: */*\r\n";
$msg .= "Accept-Language: ko\r\n";
$msg .= "Accept-Encoding: gzip, deflate\r\n";
$msg .= "User-Agent: Mozilla/4.0 (compatible; 62che)\r\n";
while (list($name, $value) = each ($this->headers)) {
$msg .= "$name: $value\r\n";
}
$msg .= "Host: ".$this->Server.":".$this->Port."\r\n";
$msg .= "Connection: close\r\n";
return $msg;
}
function AddHeader($name, $value){
$this->headers[$name] = $value;
}
function PutCookie($cookie){
$msg = "";
if(is_array($cookie)){
$out = "";
while (list ($k, $v) = each ($cookie)) {
if(strlen($out) != 0) $out .= ";";
$out .= rawurlencode($k). "=" .rawurlencode($v);
}
$msg = "Cookie: $out\n";
} else {
$msg = "Cookie: $cookie\n";
}
return $msg;
}
function Read(){
$out = $this->ReadHeader();
$chunked = isset($this->Response['transfer-encoding']) && ('chunked' == $this->Response['transfer-encoding']);
$gzipped = isset($this->Response['content-encoding']) && ('gzip' == $this->Response['content-encoding']);
$body = '';
$this->_chunkLength = 0;
while(!feof($this->Socket)){
if ($chunked) {
$buf = $this->_readChunked();
} else {
$buf = fread($this->Socket, 4096);
}
$body .= $buf;
}
if($gzipped){
$body = gzinflate(substr($body, 10));
}
$this->Response['body'] = $body;
$out .= $body;
return $out;
}
function ReadHeader(){
$out = '';
$buf = $this->_readLine();
if (sscanf($buf, 'HTTP/%s %s', $http_version, $returncode) != 2) {
$this->Error(0,"Malformed response");
return false;
} else {
$this->Response["protocol"] = 'HTTP/' . $http_version;
$this->Response["code"] = intval($returncode);
}
$out .= $buf;
while(!feof($this->Socket)){
$buf = $this->_readLine();
$out .= $buf;
if($buf == "\n" || $buf == "\r\n"){
break;
}
list($name,$value) = split(":",rtrim($buf,"\r\n"),2);
$this->Response[strtolower($name)] = trim($value);
}
$this->Response["header"] = $out;
return $out;
}
function isOk($buffer = ""){
if($buffer == "") $buffer .= fgets($this->Socket, 128);
if(preg_match('/^HTTP\/.* (2\d{2}|3\d{2}).*/', $buffer)){
return true;
}
return false;
}
function _readLine(){
$line = '';
while(!feof($this->Socket)){
$line .= fgets($this->Socket, 4096);
if (substr($line, -2) == "\r\n" || substr($line, -1) == "\n") {
return $line;
}
}
return $line;
}
function _readAll(){
$data = '';
while(!feof($this->Socket)){
$data .= fread($this->Socket, 4096);
}
return $data;
}
function _readChunked(){
// at start of the next chunk?
if (0 == $this->_chunkLength) {
$line = $this->_readLine();
if (preg_match('/^([0-9a-f]+)/i', $line, $matches)) {
$this->_chunkLength = hexdec($matches[1]);
// Chunk with zero length indicates the end
if (0 == $this->_chunkLength) {
$this->_readAll(); // make this an eof()
return '';
}
}
}
$data = fread($this->Socket, $this->_chunkLength);
$this->_chunkLength -= strlen($data);
if (0 == $this->_chunkLength) {
$this->_readLine(); // Trailing CRLF
}
return $data;
}
function Close(){
fclose($this->Socket);
}
function Error($errnum, $errmsg){
$this->Err = true;
$this->ErrNum = $errnum;
$this->ErrMsg = $errmsg;
}
function GetErr() {
return $this->Err;
}
function GetError() {
if($this->Err == true) {
return "{$this->ErrNum}, {$this->ErrMsg}";
} else {
return "No Err";
}
}
}
+1 -2
View File
@@ -1,7 +1,6 @@
<?php
require_once(__dir__.'/d_setting/conf.php');
require_once(__dir__.'/../e_lib/util.php');
require_once(__dir__.'/../e_lib/plates.php');
require(__dir__.'/../vendor/autoload.php');
class Message{
//기본 정보
-1
View File
@@ -1,7 +1,6 @@
<?php
include "lib.php";
include "func.php";
require('../e_lib/util.php');
$turnterm = util::array_get($_POST['turnterm'],'0');
$sync = util::array_get($_POST['sync'],'0');
-1
View File
@@ -2,7 +2,6 @@
include "lib.php";
include "schema.php";
include "func.php";
require "../e_lib/util.php";
if(file_exists("d_setting/set.php")) error("이미 set.php가 생성되어 있습니다.<br><br>재설치하려면 해당 파일을 지우세요");
+2 -3
View File
@@ -1,11 +1,10 @@
<?php
// $msg, $genlist
include 'lib.php';
include 'func.php';
require_once('../e_lib/util.php');
require_once('func_message.php');
// $msg, $genlist
$post = parseJsonPost();
-1
View File
@@ -1,7 +1,6 @@
<?php
include "lib.php";
include "func.php";
require "../e_lib/util.php";
$id = $_POST['id'];
$pw = $_POST['pw'];
+1
View File
@@ -1,4 +1,5 @@
<?php
require(__dir__.'/../vendor/autoload.php');
/******************************************************************************
체섭용 인클루드 파일
******************************************************************************/
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
require(__dir__.'/../vendor/autoload.php');
include "lib.php";
include "func.php";
require_once('../e_lib/util.php');
$connect = dbConn("sammo");
$id = util::array_get($_POST['id'],'');
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
include "lib.php";
include "func.php";
include "schema.sql";
include "schema.php";
$connect = dbConn();
+3 -2
View File
@@ -1,4 +1,7 @@
<?php
include "lib.php";
include "func.php";
//////////////////////////국가색////////////////////////////////////////////////
//"FF0000",빨강 "800000",갈색 "A0522D",연갈색 "FF6347",토마토 "FFA500",오렌지
//"FFDAB9",살색 "FFD700",금색 "FFFF00",노랑색 "7CFC00",잔디색 "00FF00",밝은녹색
@@ -35,8 +38,6 @@
// 0 "방랑군"
////////////////////////////////////////////////////////////////////////
include "lib.php";
include "func.php";
$connect=dbConn();
-1
View File
@@ -1,6 +1,5 @@
<?php
include "lib.php";
include "../e_lib/util.php";
$connect=dbConn();
$query = "select month from game";