Files
core/twe/j_build_conf.php
T
Hide_D 0c9be5c53f 루트DB를 관리하는 방식을 통째로 변경
- DB 불러오는 방식을 기존의 set.php에서 conf.php의 getRootDB()를 이용하도록 변경
- ADODB 에 기반한 _DB 클래스 폐기
- DBS.php 폐기
- _Setting 클래스 용도 변경
- 서버 목록 정의 방식을 하나로 모음
- 로그인시 세션에 사용자 등급을 추가
- "참여"(donation) 관련 코드 전면 제거
- 서버 리셋시 부운영자 비밀번호 문제 수정
- 서버 오픈,닫힘 여부를 새 서버 목록 정의 방식에 따르도록 수정
- DBS.php가 폐기 되었으므로 서버 오픈시 기본 정보를 json으로 받아오도록 하기 위하여 기본 준비
-  기존에 남아있던 세부 서버 로그인 처리 파일을 제거(enterPost.php)
- DBS.php 삭제로 전콘 변경시에도 각 서버로 json 호출을 하도록 하는 방식으로 준비
- 전콘을 수동으로 서버에 올린뒤 처리할 수 있도록 하던 legacy 코드 제거
- general 테이블에서 userlevel 컬럼을 삭제하고, 세션에 기록된 userGrade를 이용하도록 변경
- 벌점 제한을 모든 유저 공통으로 하도록 수정
- 세부 서버 리셋을 json ajax로 처리하도록 준비
2018-03-07 00:59:31 +09:00

99 lines
2.9 KiB
PHP

<?php
require(__dir__.'/../vendor/autoload.php');
require(__dir__.'/../d_setting/conf.php');
use utilphp\util as util;
/**
* conf.php 파일 생성용 코드
*
* 이 파일만 예외적으로 lib.php, func.php를 참조하지 않고 독자적으로 동작함.
*/
function parseJsonPost(){
// http://thisinterestsme.com/receiving-json-post-data-via-php/
// http://thisinterestsme.com/php-json-error-handling/
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
throw new Exception('Request method must be POST!');
}
//Make sure that the content type of the POST request has been set to application/json
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
if(strcasecmp($contentType, 'application/json') != 0){
throw new Exception('Content type must be: application/json');
}
//Receive the RAW post data.
$content = trim(file_get_contents("php://input"));
//Attempt to decode the incoming RAW post data from JSON.
$decoded = json_decode($content, true);
$jsonError = json_last_error();
//In some cases, this will happen.
if(is_null($decoded) && $jsonError == JSON_ERROR_NONE){
throw new Exception('Could not decode JSON!');
}
//If an error exists.
if($jsonError != JSON_ERROR_NONE){
$error = 'Could not decode JSON! ';
//Use a switch statement to figure out the exact error.
switch($jsonError){
case JSON_ERROR_DEPTH:
$error .= 'Maximum depth exceeded!';
break;
case JSON_ERROR_STATE_MISMATCH:
$error .= 'Underflow or the modes mismatch!';
break;
case JSON_ERROR_CTRL_CHAR:
$error .= 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$error .= 'Malformed JSON';
break;
case JSON_ERROR_UTF8:
$error .= 'Malformed UTF-8 characters found!';
break;
default:
$error .= 'Unknown error!';
break;
}
throw new Exception($error);
}
return $decoded;
}
function returnJson($value, $noCache = true, $pretty = false, $die = true){
header('Content-Type: application/json');
if($noCache){
header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
}
if($pretty){
$flag = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
}
else{
$flag = JSON_UNESCAPED_UNICODE;
}
echo json_encode($value, $flag);
if($die){
die();
}
}
if(file_exist(__dir__.'/d_setting/conf.php')){
returnJson([
'result'=>false,
'reason'=>'이미 설정 파일이 존재합니다.'
]);
}