세션 시작 방식을 Session 클래스를 이용하도록 변경

This commit is contained in:
2018-04-01 00:28:55 +09:00
parent 0b584c7b0d
commit 3ea95da4a6
6 changed files with 80 additions and 70 deletions
+9 -6
View File
@@ -4,15 +4,18 @@ namespace sammo;
include "lib.php";
include "func.php";
//로그인 검사
CheckLogin();
$connect = dbConn();
$session = Session::requireLogin()->loginGame();
if(Session::getUserGrade() < 5) {
//echo "<script>location.replace('_admin2.php');</script>";
echo '_admin2.php';//TODO:debug all and replace
if($session->userGrade < 5) {
header('location:_admin2.php');
}
$generalID = getGeneralID();
$generalID = $session->generalID;
if(!$generalID){
header('location:_admin2.php');
}
$connect = dbConn();
switch($btn) {
case "전체 접속허용":
+10 -8
View File
@@ -3,15 +3,17 @@ namespace sammo;
function CheckLogin($type=0) {
if(!isset($_SESSION['userID'])) {
if($type == 0) {
header('Location: ../');
}
else {
header('Location: index.php');
}
exit();
//TODO: 직접해라. setReadOnly() 호출이 필요하다.
if(Session::Instance()->loginGame()->generalID){
return;
}
if($type == 0) {
header('Location: ../');
}
else {
header('Location: index.php');
}
exit();
}
+7 -12
View File
@@ -4,33 +4,28 @@ namespace sammo;
include "lib.php";
include "func.php";
$session = Session::Instance()->loginGame();
$connect = dbConn();
increaseRefresh("메인", 2);
increaseRefresh("메인", 1);
checkTurn($connect);
$db = DB::db();
//로그인 검사
if(!isSigned()){
header('Location:../');
if(!$session->userID){
header('Location:..');
die();
}
$userID = Session::getUserID();
if(!$userID){
header('Location:../');
die();
}
$me = $db->queryFirstRow('select no,con,turntime,newmsg,newvote,map from general where owner = %i', $userID);
$me = $db->queryFirstRow('SELECT no,con,turntime,newmsg,newvote,map from general where owner = %i', $userID);
//그새 사망이면
if($me === null) {
resetSessionGeneralValues();
$session->loginGame();
header('Location: ../');
die();
}
$session->setReadOnly();
if($me['newmsg'] == 1 && $me['newvote'] == 1) {
$query = "update general set newmsg=0,newvote=0 where owner='{$_SESSION['userID']}'";
+2 -2
View File
@@ -28,7 +28,7 @@ if(!isset($post['genlist']) || !isset($post['msg'])){
$destMailbox = $post['dest_mailbox'];
$msg = $post['msg'];
$datetime = new DateTime();
$datetime = new \DateTime();
$date = $datetime->format('Y-m-d H:i:s');
//로그인 검사
@@ -120,7 +120,7 @@ if($destMailbox == 9999) {
// 개인 메세지
} elseif($destMailbox > 0) {
$last_msg = new DateTime(Util::array_get($_SESSION['last_msg'], '0000-00-00'));
$last_msg = new \DateTime(Util::array_get($_SESSION['last_msg'], '0000-00-00'));
$msg_interval = $datetime->getTimestamp() - $last_msg->getTimestamp();
//NOTE: 여기서 유저 레벨을 구별할 코드가 필요할까?
+2 -24
View File
@@ -96,11 +96,9 @@ $_taxrate = 0.01; // 군량 매매시 세율
//$images = "http://jwh1807.vipweb.kr/images";
//$image = "http://jwh1807.vipweb.kr/image";
$image1 = "../d_pic";
$images = "/images";
$image = "/image";
$images = "/images";
$image = "/image";
unset($member);
unset($setup);
// Data, Icon, 세션디렉토리의 쓰기 권한이 없다면 에러 처리
// 단, 폴더가 없는 경우라면 폴더를 생성 할 필요가 있음.
@@ -113,26 +111,6 @@ if(is_dir(__DIR__."/data")){
session_cache_limiter('nocache, must_revalidate');//NOTE: 캐시가 가능하도록 설정해야 할 수도 있음. 주의!
// 세션 변수의 등록
//NOTE: ajax등의 경우에는 session_write_close로 빠르게 끝낼 수 있어야한다.
session_start();
//첫 등장
if(!Util::array_get($_SESSION['p_ip'], null)) {
$_SESSION['p_ip'] = getenv("REMOTE_ADDR");
$_SESSION['p_time'] = time();
}
//id, 이름, 국가는 로그인에서
//초과된 세션은 로그아웃(1시간)
//TODO: 로그아웃 원리를 다시 확인
if($_SESSION['p_time']+3600 < time()) {
resetSessionGeneralValues();
$_SESSION['p_time'] = time();
} else {
$_SESSION['p_time'] = time();
}
/**
* Session에 보관된 장수 정보를 제거함.
* _prefix_p_no, _prefix_p_name 두 값임