From 14e5e1459779b52e7baa103f7ac05c8d307ddbc5 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 11 Mar 2018 02:42:18 +0900 Subject: [PATCH] =?UTF-8?q?DB=20=EA=B3=84=EC=A0=95=EC=9D=84=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=ED=95=98=EC=A7=80=20=EC=95=8A=EA=B3=A0=EB=8F=84=20?= =?UTF-8?q?=EB=A6=AC=EC=85=8B=EC=9D=B4=20=EA=B0=80=EB=8A=A5=ED=95=9C=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이미 기능이 사라진 N생성 버튼 제거 - 기존의 DB까지 포함한 초기화를 '완전 리셋' - 제대로 동작하지 않던 폐쇄중 로그인 변경 - 리셋 프로세스에 권한을 제대로 검사하지 않는 문제 해결 --- che_close/func.php | 2 +- che_close/install.php | 26 +++++++++++++---- che_close/install2.php | 5 +++- che_close/install2_ok.php | 4 +-- che_close/install3_ok.php | 1 + che_close/install_ok.php | 50 +++++++++++++++++++++----------- che_close/lib.php | 55 ++++++++++++++++++++++++++++++++++++ che_close/logout_process.php | 6 +++- che_close/reset.php | 24 +--------------- i_entrance/adminAction.js | 4 +-- i_entrance/adminInc.php | 6 ++-- i_entrance/adminPost.php | 3 ++ 12 files changed, 132 insertions(+), 54 deletions(-) diff --git a/che_close/func.php b/che_close/func.php index cd662c1..96aeb76 100644 --- a/che_close/func.php +++ b/che_close/func.php @@ -90,7 +90,7 @@ function delInDir($dir) { deldir("$dir/$FolderOrFile"); } // recursive else { - unlink("$dir/$FolderOrFile"); + @unlink("$dir/$FolderOrFile"); } } } diff --git a/che_close/install.php b/che_close/install.php index 10f0fc7..04057a2 100644 --- a/che_close/install.php +++ b/che_close/install.php @@ -1,8 +1,23 @@
재설치하려면 해당 파일을 지우세요"); +include "lib.php"; - @chmod(".",0707); +$justReset = isset($_GET['just_reset'])?intval($_GET['just_reset']):0; + +if(file_exists("d_setting/set.php")){ + //DB 리셋만 하려는 것인지 검사 필요. + $connect = dbConn(); + requireUserLevel($connect, 5); + + if(!$justReset){ + error("이미 set.php가 생성되어 있습니다.

재설치하려면 해당 파일을 지우세요"); + } + +} +else{ + $justReset = 0; +} + +@chmod(".",0707); ?> @@ -72,9 +87,10 @@ if(!$check) {

- + diff --git a/che_close/install2.php b/che_close/install2.php index 4f2f068..15f6bf4 100644 --- a/che_close/install2.php +++ b/che_close/install2.php @@ -1,5 +1,8 @@ diff --git a/che_close/install2_ok.php b/che_close/install2_ok.php index 9473682..3891252 100644 --- a/che_close/install2_ok.php +++ b/che_close/install2_ok.php @@ -3,7 +3,7 @@ include "lib.php"; include "func.php"; $connect=dbConn(); - +requireUserLevel($connect, 5); $query = "select count(no) as cnt from general where user_id = 'admin'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); @@ -80,7 +80,7 @@ if($img < 1) { $picture = 'default.jpg'; }; $connect ) or Error(__LINE__.MYDB_error($connect),""); -$pw = md5('12qw!@QW12qw!@QW'); +$pw = md5('12');//부운영자는 계정은 만들지만 로그인 가능하게 하진 않는다. $picture = 'pic_2.jpg'; if($img < 1) { $picture = 'default.jpg'; }; diff --git a/che_close/install3_ok.php b/che_close/install3_ok.php index 815739b..5784571 100644 --- a/che_close/install3_ok.php +++ b/che_close/install3_ok.php @@ -3,6 +3,7 @@ include "lib.php"; include "func.php"; $connect=dbConn(); +requireUserLevel($connect, 5); LogHistory($connect, 1); diff --git a/che_close/install_ok.php b/che_close/install_ok.php index f57a9ab..0c0a05d 100644 --- a/che_close/install_ok.php +++ b/che_close/install_ok.php @@ -3,22 +3,38 @@ include "lib.php"; include "schema.sql"; include "func.php"; -if(file_exists("d_setting/set.php")) error("이미 set.php가 생성되어 있습니다.

재설치하려면 해당 파일을 지우세요"); +$justReset = isset($_POST['just_reset'])?intval($_POST['just_reset']):0; -// 호스트네임, 아이디, DB네임, 비밀번호의 공백여부 검사 -if(isBlank($hostname)) Error("HostName을 입력하세요",""); -if(isBlank($user_id)) Error("User ID 를 입력하세요",""); -if(isBlank($dbname)) Error("DB NAME을 입력하세요",""); -// DB에 커넥트 하고 DB NAME으로 select DB -$connect = MYDB_connect($hostname,$user_id,$password) or Error("MySQL-DB Connect
Error!!!",""); -if(MYDB_error($connect)) Error(__LINE__.MYDB_error($connect),""); -MYDB_select_db($dbname, $connect) or Error("MySQL-DB Select
Error!!!",""); +if(file_exists("d_setting/set.php")){ + $connect = dbConn(); + requireUserLevel($connect, 5); + + if(!$justReset){ + error("이미 set.php가 생성되어 있습니다.

재설치하려면 해당 파일을 지우세요"); + } +} +else{ + $justReset = 0; +} + +if(!$justReset){ + // 호스트네임, 아이디, DB네임, 비밀번호의 공백여부 검사 + if(isBlank($hostname)) Error("HostName을 입력하세요",""); + if(isBlank($user_id)) Error("User ID 를 입력하세요",""); + if(isBlank($dbname)) Error("DB NAME을 입력하세요",""); + + // DB에 커넥트 하고 DB NAME으로 select DB + $connect = MYDB_connect($hostname,$user_id,$password) or Error("MySQL-DB Connect
Error!!!",""); + if(MYDB_error($connect)) Error(__LINE__.MYDB_error($connect),""); + MYDB_select_db($dbname, $connect) or Error("MySQL-DB Select
Error!!!",""); +} delInDir("logs"); delInDir("data/session"); @unlink("data/connected.php"); + // 관리자 테이블 삭제 if(isTable($connect, "game", $dbname)) @MYDB_query("drop table game", $connect) or Error("drop ".MYDB_error($connect),""); // 락 테이블 삭제 @@ -77,13 +93,15 @@ if(!isTable($connect, "statistic",$dbname)) @MYDB_query($statistic_schema, $conn // 연감 테이블 생성 if(!isTable($connect, "history",$dbname)) @MYDB_query($history_schema, $connect) or Error("create history ".MYDB_error($connect),""); -// 파일로 DB 정보 저장 -$file=@fopen("d_setting/set.php","w") or Error("set.php 파일 생성 실패

디렉토리의 퍼미션을 707로 주십시요",""); -@fwrite($file,"\n") or Error("set.php 파일 생성 실패

디렉토리의 퍼미션을 707로 주십시요",""); -@fclose($file); -@mkdir("data",0707); -@chmod("data",0707); -@chmod("d_setting/set.php",0707); +if(!$justReset){ + // 파일로 DB 정보 저장 + $file=@fopen("d_setting/set.php","w") or Error("set.php 파일 생성 실패

디렉토리의 퍼미션을 707로 주십시요",""); + @fwrite($file,"\n") or Error("set.php 파일 생성 실패

디렉토리의 퍼미션을 707로 주십시요",""); + @fclose($file); + @mkdir("data",0707); + @chmod("data",0707); + @chmod("d_setting/set.php",0707); +} $temp=MYDB_fetch_array(MYDB_query("select count(*) from general where level = '1'", $connect)); diff --git a/che_close/lib.php b/che_close/lib.php index 136369a..677d866 100644 --- a/che_close/lib.php +++ b/che_close/lib.php @@ -163,4 +163,59 @@ function PrintElapsedTime() { $_endTime = round(getMicroTime() - $_startTime, 3); echo "
- /inst_b_1.gif border=0 align=absmiddle> + +
경과시간 : {$_endTime}초
"; } + +function requireUserLevel($connect, $reqLevel=5){ + + if(isset($_SESSION['ownUserLevel']) && $_SESSION['ownUserLevel']>=$reqLevel){ + return; + } + + $p_id = isset($_SESSION['p_id'])?$_SESSION['p_id']:null; + if(!$p_id){ + + $query = "select count(*) as cnt from general where userlevel < 4 limit 1"; + $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $cnt = MYDB_fetch_array($result); + + if($cnt['cnt'] == 0){ + //아직 제대로된 계정이 생성되지 않았다면 넘어간다. + //서버 리셋시 ~ 첫 유저 계정 생성시까지 취약점이 되지만, 구조상 어쩔 수 없다. + return; + } + + echo " + + + 로그인 되지 않음 + + + + + 각 서버에 로그인이 되지 않아 유저 정보를 확인할 수 없습니다. 서버 접속을 수행해주세요.
+ + "; + exit(); + } + + $query = "select userlevel from general where user_id='$p_id'"; + $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $me = MYDB_fetch_array($result); + + if($me['userlevel'] < $reqLevel) { + echo " + + + 권한 부족 + + + + + 충분한 권한이 없습니다.
+ + "; + exit(); + } + + $_SESSION['ownUserLevel'] = $reqLevel; +} ?> diff --git a/che_close/logout_process.php b/che_close/logout_process.php index 00d3c88..20ddb89 100644 --- a/che_close/logout_process.php +++ b/che_close/logout_process.php @@ -12,11 +12,15 @@ $_SESSION[p_id] = ""; $_SESSION[p_name] = ""; $_SESSION[p_nation] = 0; +if(isset($_SEESION['ownUserLevel'])){ + unset($_SESSION['ownUserLevel']); +} + $id = $me[user_id]; $pw = $me[password]; $conmsg = $me[conmsg]; -//Ǻ +//���Ǻ��� ���� session_destroy(); echo ""; diff --git a/che_close/reset.php b/che_close/reset.php index 1ca0907..e3d4ace 100644 --- a/che_close/reset.php +++ b/che_close/reset.php @@ -5,29 +5,7 @@ include "schema.sql"; $connect = dbConn(); -print_r($_SESSION); -$query = "select userlevel from general where user_id='$_SESSION[p_id]'"; -$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); -$me = MYDB_fetch_array($result); - -if($me[userlevel] < 5) { - echo " - - -관리메뉴 - - - - -로그인 정보가 없습니다.
관리자라면 폐쇄중 로그인을 1회 실행해 주십시오.
-"; - banner(); - echo " - -"; - - exit(); -} +requireUserLevel($connect, 5); // 삭제 diff --git a/i_entrance/adminAction.js b/i_entrance/adminAction.js index 5fe0f79..868b999 100644 --- a/i_entrance/adminAction.js +++ b/i_entrance/adminAction.js @@ -79,7 +79,7 @@ function Entrance_AdminPost(server, select) { function(response, textStatus) { if(response.result == "SUCCESS") { Popup_WaitHide(); - if(select == 1) { + if(select == 1 || select == 3) { ReplaceFrame(response.installURL); } else { Replace(ENTRANCE+PHP); @@ -102,7 +102,7 @@ function Entrance_AdminNPCCreate(serverDir) { } function Entrance_AdminClosedLogin(serverDir) { - ReplaceFrame(serverDir+'_close'+W+'npc_login'+PHP); + ReplaceFrame(serverDir+'_close'+W+'index'+PHP); } function Entrance_AdminOpen119(serverDir) { diff --git a/i_entrance/adminInc.php b/i_entrance/adminInc.php index 5994943..79c6e8b 100644 --- a/i_entrance/adminInc.php +++ b/i_entrance/adminInc.php @@ -68,11 +68,11 @@ foreach($_serverDirs as $serverDir) {
- + + - - +
diff --git a/i_entrance/adminPost.php b/i_entrance/adminPost.php index 302cea3..39382d6 100644 --- a/i_entrance/adminPost.php +++ b/i_entrance/adminPost.php @@ -40,6 +40,9 @@ if($member['GRADE'] < 6) { rename(ROOT.W.$serverDir, ROOT.W.$serverDir."_rest"); rename(ROOT.W.$serverDir."_close", ROOT.W.$serverDir); $response['result'] = 'SUCCESS'; + } elseif($select == 3) { + $response['installURL'] = ROOT.W."{$serverDir}_close/install.php?just_reset=1"; + $response['result'] = 'SUCCESS'; } } else { $response['result'] = 'FAIL';