95 lines
3.1 KiB
PHP
95 lines
3.1 KiB
PHP
<?php
|
|
include "lib.php";
|
|
include "func.php";
|
|
|
|
//FIXME: 이 프로세스 전체가 필요없을 수 있다. session 디렉토리를 관리하지 않거나, 자동 로그인을 처리하는 방법을 생각할 것.
|
|
|
|
use utilphp\util as util;
|
|
|
|
$id = util::array_get($_POST['id'],'');
|
|
$pw = util::array_get($_POST['pw'], '');
|
|
$conmsg = util::array_get($_POST['conmsg'], '');
|
|
|
|
$pw = substr($pw, 0, 32);
|
|
|
|
|
|
|
|
//회원 테이블에서 정보확인
|
|
$member = getRootDB()->queryFirstRow('select no,name from MEMBER where id=%s and pw=%s', $id, $pw);
|
|
|
|
|
|
if(!$member) {
|
|
MessageBox("아이디나 암호가 올바르지 않습니다!!!");
|
|
//TODO:login_process를 rest 형태로 처리
|
|
//header ("Location: index.php");
|
|
exit(0);
|
|
}
|
|
|
|
//NOTE: 왜 Session을 지우는가?
|
|
DeleteSession();
|
|
|
|
$db = getDB();
|
|
|
|
//회원 테이블에서 정보확인
|
|
$me= $db->queryFirstRow('select no,name,nation,block,killturn from general where user_id= %s', $id);
|
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
$me = MYDB_fetch_array($result);
|
|
|
|
|
|
if(!$me) {
|
|
MessageBox("캐릭터가 없습니다!!!");
|
|
//TODO:login_process를 rest 형태로 처리
|
|
//header ("Location: index.php");
|
|
exit(0);
|
|
}
|
|
|
|
|
|
switch($me['block']) {
|
|
case 1:
|
|
MessageBox("비매너 발언으로 인해, 발언권이 제한됩니다."); break;
|
|
case 2:
|
|
MessageBox("현재 블럭된 계정입니다. 턴 실행이 제한됩니다.");
|
|
MessageBox("절대 1계정만 사용하십시오! {$me['killturn']}시간 후 재등록 가능합니다."); break;
|
|
case 3:
|
|
MessageBox("현재 블럭된 계정입니다. 발언권과 턴 실행이 제한됩니다.");
|
|
MessageBox("절대 1계정만 사용하십시오! {$me['killturn']}시간 후 재등록 가능합니다."); break;
|
|
}
|
|
|
|
$_SESSION[getServPrefix().'p_no'] = toInt($me['no']);
|
|
$_SESSION['p_id'] = $id;
|
|
$_SESSION[getServPrefix().'p_name'] = $me['name'];
|
|
$_SESSION['p_time'] = time();
|
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
|
//
|
|
$query="update general set logcnt=logcnt+1,ip='{$_SESSION['p_ip']}',lastconnect='$date',conmsg='$conmsg' where no_member='{$_SESSION['noMember']}'";
|
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
|
|
$date = date('Y_m_d H:i:s');
|
|
$date2 = substr($date, 0, 10);
|
|
$fp = fopen("logs/_{$date2}_login.txt", "a");
|
|
$msg = _String::Fill2($date,20," ").tab2($id,13," ")._String::Fill2($me['name'],13," ")._String::Fill2($_SESSION['p_ip'],16," ");
|
|
fwrite($fp, $msg."\n");
|
|
fclose($fp);
|
|
|
|
header ("Location: index.php");
|
|
|
|
function DeleteSession() {
|
|
$session_path = "data/session"; // 세션이저장된 디렉토리
|
|
if(!$dir=@opendir($session_path)) echo "디렉토리를 열지못했습니다.";
|
|
|
|
while($file=@readdir($dir)) {
|
|
if(!strstr($file,'sess_')) continue;
|
|
if(strpos($file,'sess_')!=0) continue;
|
|
if (!$atime=@fileatime("$session_path/$file")) continue;
|
|
if (time() > $atime + 86400) { // 10대시 지난시간을 초로 계산해서 적어주시면 됩니다.
|
|
// $return = (@unlink("$session_path/$file"));
|
|
@unlink("$session_path/$file");
|
|
}
|
|
}
|
|
closedir($dir);
|
|
}
|
|
|
|
MYDB_close($connect);
|