내부 전역 변수값 처리를 위해 함수 정리
conf.php에 getServPrefix 추가. 이후 같은 db에서 다른 서버를 운용할때 사용 가능할 것으로 예상. $_SESSION 값을 직접 받아서 처리하지 않도록 하기위한 용도로 getUserID(), getGeneralID(), getGeneralName() 을 설정 $_SESSION['p_id']를 p_no로 착각하여 구현한 부분 수정 int|null 변환을 위한 toInt 함수 추가 func_string.php에서 null이 입력될 경우 일부 처리 각 서버에 계정이 생성되었는지 확인하는 isSigned()함수 추가
This commit is contained in:
@@ -1,56 +1 @@
|
||||
<?php
|
||||
/*
|
||||
switch(rand()%10) {
|
||||
case 0: // ����
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=auction&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 1: // 11��
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=11st&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 2: // �ѱ��м�����
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=paper&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 3: // ����
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=groupon&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 4: // ���Ϸ�
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=unilook&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 5: // ������
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=makeprice&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 6: // ���Ƿ���Ʈ
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=hreport&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 7: // ��dz����
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=ypbooks&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
case 8: // G����
|
||||
?>
|
||||
<a onmouseover="window.status='http://promotion.gmarket.co.kr/planview/plan.asp?sid=30140';return true" onmouseout="window.status=' ';return true" target="_blank" href="http://click.linkprice.com/click.php?m=gmarket&a=A100457867&l=1492&u_id=<?=$banner_id;?>"><img src="http://image.gmarket.co.kr/UPLOAD_IMAGE/2011/12/27/160_600_1227.gif" border="0" alt="G����" width="160" height="600"></a>
|
||||
<img src="http://track.linkprice.com/lpshow.php?m_id=gmarket&a_id=A100457867&p_id=0000&l_id=1492&l_cd1=2&l_cd2=0" width="1" height="1" border="0" nosave style="display:none">
|
||||
<?php
|
||||
break;
|
||||
case 9: // ����11��
|
||||
?>
|
||||
<iframe src="http://ad.linkprice.com/stlink.php?m=m365&a=A100457867&width=160&height=600&target=_blank&u_id=<?=$banner_id;?>" width="160" height="600" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"></iframe>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -21,4 +21,8 @@ function getDB(){
|
||||
}
|
||||
|
||||
return $uDB;
|
||||
}
|
||||
|
||||
function getServPrefix(){
|
||||
return '_prefix_';
|
||||
}
|
||||
+92
-20
@@ -16,24 +16,89 @@ require_once('func_template.php');
|
||||
require_once('func_message.php');
|
||||
require_once('func_map.php');
|
||||
|
||||
/// 0.0~1.0 사이의 랜덤 float
|
||||
/**
|
||||
* 0.0~1.0 사이의 랜덤 float
|
||||
* @return float
|
||||
*/
|
||||
function randF(){
|
||||
return mt_rand() / mt_getrandmax();
|
||||
}
|
||||
|
||||
/// $_SESSION['p_id'] 의 값을 받아옴
|
||||
function getGeneralID(){
|
||||
//TODO: 서버마다 p_id가 다를 수 있도록 조치
|
||||
if(!isset($_SESSION['p_id'])){
|
||||
return NULL;
|
||||
/**
|
||||
* 로그인한 유저의 전역 id를 받아옴
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getUserID($forceExit=false){
|
||||
$userID = util::array_get($_SESSION['p_id'], null);
|
||||
if(!$userID && $forceExit){
|
||||
header('Location:..');
|
||||
die();
|
||||
}
|
||||
if($_SESSION['p_id']===''){
|
||||
return NULL;
|
||||
}
|
||||
return $_SESSION['p_id'];
|
||||
|
||||
return $userID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 로그인한 유저의 장수 id를 받아옴
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
function getGeneralID($forceExit=false){
|
||||
$username = getUserID();
|
||||
if(!$username){ //유저명 없으면 어차피 의미 없음.
|
||||
return null;
|
||||
}
|
||||
|
||||
$id_key = getServPrefix().'p_no';
|
||||
$generalID = util::array_get($_SESSION[$id_key], null);
|
||||
|
||||
if($generalID){
|
||||
return $generalID;
|
||||
}
|
||||
|
||||
//흠?
|
||||
$generalID = getDB()->queryFirstField('select no from general where user_id = %s', $username);
|
||||
if(!$generalID && $forceExit){
|
||||
header('Location:..');
|
||||
die();
|
||||
}
|
||||
|
||||
if($generalIDid){
|
||||
$_SESSION[$id_key] = $generalID;
|
||||
}
|
||||
|
||||
return $generalID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그인한 유저의 장수명을 받아옴
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
function getGeneralName($forceExit=false)
|
||||
{
|
||||
$generalID = getGeneralID();
|
||||
if(!$generalID){
|
||||
if($forceExit){
|
||||
header('Location:..');
|
||||
die();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$id_key = getServPrefix().'p_name';
|
||||
$generalName = util::array_get($_SESSION[$id_key], null);
|
||||
|
||||
if($generalName){
|
||||
return $generalName;
|
||||
}
|
||||
|
||||
//흠?
|
||||
$generalName = getDB()->queryFirstField('select name from general where no = %i', $generalID);
|
||||
}
|
||||
|
||||
function GetImageURL($imgsvr) {
|
||||
global $image, $image1;
|
||||
@@ -44,9 +109,14 @@ function GetImageURL($imgsvr) {
|
||||
}
|
||||
}
|
||||
|
||||
function CheckLoginEx(){
|
||||
//TODO: 서버 별로 p_id를 다르게 설정할 수 있어야함.
|
||||
if(!isset($_SESSION['p_id'])) {
|
||||
/**
|
||||
* generalID를 이용해 각 서버 등록 여부를 확인함
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isSigned(){
|
||||
$p_id = getGeneralID();
|
||||
if(!$_pid){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -70,7 +140,7 @@ function checkLimit($userlevel, $con, $conlimit) {
|
||||
}
|
||||
|
||||
function getBlockLevel() {
|
||||
return getDB()->queryFirstField('select block from general where user_id= %i', getGeneralID());
|
||||
return getDB()->queryFirstField('select block from general where no = %i', getGeneralID());
|
||||
}
|
||||
|
||||
function getRandGenName() {
|
||||
@@ -1801,7 +1871,9 @@ function getOnlineNum() {
|
||||
|
||||
function onlinegen($connect) {
|
||||
$onlinegen = "";
|
||||
if($_SESSION['p_nation'] == 0) {
|
||||
$generalID = getGeneralID();
|
||||
$nationID = getDB()->queryFirstField('select `nation` from `general` where `no` = %i', $generalID);
|
||||
if($nationID !== null || toInt($nationID) === 0) {
|
||||
$query = "select onlinegen from game where no='1'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$game = MYDB_fetch_array($result);
|
||||
@@ -2140,14 +2212,14 @@ function increateRefreshEx($type, $cnt=1){
|
||||
));
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$p_id = getGeneralID();
|
||||
$generalID = getGeneralID();
|
||||
if($p_id !== NULL){
|
||||
|
||||
$db->query("update `general` set `lastrefresh`= %s_date, `con` = `con`+%d_cnt, `connect`= `connect`+ %d_cnt, '\
|
||||
'`refcnt` = `refcnt` + %d_cnt, `refresh` = `refresh` + %d_cnt where `user_id` =%s_p_id",array(
|
||||
'`refcnt` = `refcnt` + %d_cnt, `refresh` = `refresh` + %d_cnt where `no` =%i_generalID",array(
|
||||
'date'=>$date,
|
||||
'cnt'=>$cnt,
|
||||
'p_id'=>$p_id
|
||||
'p_id'=>$generalID
|
||||
));
|
||||
}
|
||||
|
||||
@@ -2155,7 +2227,7 @@ function increateRefreshEx($type, $cnt=1){
|
||||
$date2 = substr($date, 0, 10);
|
||||
$online = getOnlineNum();
|
||||
$fp = fopen("logs/_{$date2}_refresh.txt", "a");
|
||||
$msg = _String::Fill2($date,20," ")._String::Fill2($_SESSION['p_id'],13," ")._String::Fill2($_SESSION['p_name'],13," ")._String::Fill2($_SESSION['p_ip'],16," ")._String::Fill2($type, 10, " ")." 동접자: {$online}";
|
||||
$msg = _String::Fill2($date,20," ")._String::Fill2(getUserID(),13," ")._String::Fill2(getGeneralName(),13," ")._String::Fill2($_SESSION['p_ip'],16," ")._String::Fill2($type, 10, " ")." 동접자: {$online}";
|
||||
fwrite($fp, $msg."\n");
|
||||
fclose($fp);
|
||||
|
||||
@@ -2184,7 +2256,7 @@ function increateRefreshEx($type, $cnt=1){
|
||||
if($str != "") {
|
||||
file_put_contents("logs/_{$date2}_ipcheck.txt",
|
||||
sprintf("ID:%s//name:%s//REMOTE_ADDR:%s%s\n",
|
||||
$_SESSION['p_id'],$_SESSION['p_name'],$_SERVER['REMOTE_ADDR'],$str), FILE_APPEND);
|
||||
getUserID(), getGeneralName(),$_SERVER['REMOTE_ADDR'],$str), FILE_APPEND);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ function getBill($dedication) {
|
||||
function getCost($armtype) {
|
||||
//FIXME: 정말로 side effect가 없으려면 query는 밖으로 이동해야함.
|
||||
//TODO: 병종 값이 column으로 들어있는건 전혀 옳지 않음. key->value 형태로 바꿔야함
|
||||
return getDB()->queryFirstColumn('select cst%l from game where no=1', intval($armtype));
|
||||
return getDB()->queryFirstColumn('select %b from game where no=1', sprintf('cst%d', $armtype));
|
||||
}
|
||||
|
||||
function TechLimit($startyear, $year, $tech) {
|
||||
|
||||
+11
-11
@@ -50,22 +50,22 @@ function getWorldMap($req){
|
||||
return getHistoryMap($req->year, $req->month);
|
||||
}
|
||||
|
||||
$generalID = getGeneralID();
|
||||
$generalID = getGeneralID(false);
|
||||
|
||||
$db = getDB();
|
||||
|
||||
$game = $db->queryFirstRow('select `startyear`, `year`, `month` from `game` where `no` = 1');
|
||||
$startYear = intval($game['startyear']);
|
||||
$year = intval($game['year']);
|
||||
$month = intval($game['month']);
|
||||
$startYear = toInt($game['startyear']);
|
||||
$year = toInt($game['year']);
|
||||
$month = toInt($game['month']);
|
||||
|
||||
if($generalID && ($req->showMe || $req->neutralView)){
|
||||
$city = $db->queryFirstRow(
|
||||
'select `city`, `nation` from `general` where `user_id`=%i',
|
||||
$generalID);
|
||||
|
||||
$myCity = intval($city['city']);
|
||||
$myNation = intval($city['nation']);
|
||||
$myCity = toInt($city['city']);
|
||||
$myNation = toInt($city['nation']);
|
||||
|
||||
if(!$req->showMe){
|
||||
$myCity = null;
|
||||
@@ -82,7 +82,7 @@ function getWorldMap($req){
|
||||
if($myNation){
|
||||
$spyList = $db->queryFirstField('select `spy` from `nation` where `nation`=%i',
|
||||
$myNation);
|
||||
$spyList = array_map('intval', explode("|", $spyList));
|
||||
$spyList = array_map('toInt', explode("|", $spyList));
|
||||
}
|
||||
else{
|
||||
$spyList = [];
|
||||
@@ -91,17 +91,17 @@ function getWorldMap($req){
|
||||
$nationList = [];
|
||||
foreach($db->query('select `nation`, `name`, `color`, `capital` from `nation`') as $row){
|
||||
$nationList[] = [
|
||||
intval($row['nation']),
|
||||
toInt($row['nation']),
|
||||
$row['name'],
|
||||
$row['color'],
|
||||
intval($row['capital'])
|
||||
toInt($row['capital'])
|
||||
];
|
||||
}
|
||||
|
||||
if($myNation){
|
||||
//굳이 타국 도시에 있는 아국 장수 리스트를 뽑을 이유가 없음. 일단 다 뽑자.
|
||||
$shownByGeneralList =
|
||||
array_map('intval',
|
||||
array_map('toInt',
|
||||
$db->queryFirstColumn('select distinct `city` from `general` where `nation` = %i',
|
||||
$myNation));
|
||||
}
|
||||
@@ -112,7 +112,7 @@ function getWorldMap($req){
|
||||
$cityList = [];
|
||||
foreach($db->query('select `city`, `level`, `state`, `nation`, `region`, `supply` from `city`') as $r){
|
||||
$cityList[] =
|
||||
array_map('intval', [$r['city'], $r['level'], $r['state'], $r['nation'], $r['region'], $r['supply']]);
|
||||
array_map('toInt', [$r['city'], $r['level'], $r['state'], $r['nation'], $r['region'], $r['supply']]);
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
+11
-6
@@ -82,7 +82,7 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
||||
}
|
||||
|
||||
function getMessage($msgType, $limit=30, $fromTime=NULL){
|
||||
$generalID = getGeneralID();
|
||||
$generalID = getGeneralID(false);
|
||||
if($generalID === NULL){
|
||||
return [];
|
||||
}
|
||||
@@ -91,12 +91,12 @@ function getMessage($msgType, $limit=30, $fromTime=NULL){
|
||||
return getRawMessage(9999, $limit, $fromTime);
|
||||
}
|
||||
else if($msgType === 'private'){
|
||||
return getRawMessage($genID, $limit, $fromTime);
|
||||
return getRawMessage($generalID, $limit, $fromTime);
|
||||
}
|
||||
else if($msgType === 'national'){
|
||||
$nationID = getDB()->queryFirstField(
|
||||
'select `nation` from `general` where user_id = %i',
|
||||
$genID
|
||||
'select `nation` from `general` where no = %i',
|
||||
$generalID
|
||||
);
|
||||
return getRawMessage(9000 + $nationID, $limit, $fromTime);
|
||||
}
|
||||
@@ -164,9 +164,14 @@ function sendMessage($msgType, $src, $dest, $msg, $date = null){
|
||||
function getMailboxList(){
|
||||
$result = [];
|
||||
|
||||
$generalID = getGeneralID();
|
||||
$generalID = getGeneralID(false);
|
||||
|
||||
if(!$generalID){
|
||||
|
||||
}
|
||||
|
||||
$db = getDB();
|
||||
$me = $db->queryFirstRow('select no,nation,level from general where user_id=%i', $generalID);
|
||||
$me = $db->queryFirstRow('select no,nation,level from general where no=%i', $generalID);
|
||||
|
||||
//가장 최근에 주고 받은 사람.
|
||||
$latestMessage = util::array_get(getMessage('private', 1)[0], null);
|
||||
|
||||
@@ -224,6 +224,9 @@ class _String {
|
||||
|
||||
//중간정렬
|
||||
public static function staticFill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size) / 2;
|
||||
@@ -239,6 +242,9 @@ class _String {
|
||||
}
|
||||
|
||||
public static function Fill($str, $maxsize, $ch) {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size) / 2;
|
||||
@@ -256,6 +262,9 @@ class _String {
|
||||
|
||||
//우측정렬
|
||||
public static function Fill2($str, $maxsize, $ch='0') {
|
||||
if(!$str){
|
||||
$str = '';
|
||||
}
|
||||
$size = strlen($str);
|
||||
|
||||
$count = ($maxsize - $size);
|
||||
|
||||
+2
-2
@@ -25,8 +25,8 @@ if($post['year']){
|
||||
]);
|
||||
}
|
||||
|
||||
$post['year'] = intval($post['year']);
|
||||
$post['month'] = intval($post['month']);
|
||||
$post['year'] = toInt($post['year']);
|
||||
$post['month'] = toInt($post['month']);
|
||||
}
|
||||
else{
|
||||
$post['year'] = null;
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ $datetime = new DateTime();
|
||||
$date = $datetime->format('Y-m-d H:i:s');
|
||||
|
||||
//로그인 검사
|
||||
if(!CheckLoginEx($db)){
|
||||
if(!isSigned()){
|
||||
returnJson([
|
||||
'result' => false,
|
||||
'reason' => '로그인되지 않았습니다.',
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
use utilphp\util as util;
|
||||
|
||||
if(!isSigned()){
|
||||
|
||||
}
|
||||
+45
-8
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
use utilphp\util as util;
|
||||
|
||||
/******************************************************************************
|
||||
체섭용 인클루드 파일
|
||||
******************************************************************************/
|
||||
@@ -84,16 +86,16 @@ if(is_dir("data")){
|
||||
|
||||
|
||||
session_save_path('data/session');
|
||||
session_cache_limiter('nocache, must_revalidate');
|
||||
session_cache_limiter('nocache, must_revalidate');//NOTE: 캐시가 가능할 수도 있음. 주의!
|
||||
session_set_cookie_params(0, '/');
|
||||
session_cache_expire(60); // 60분
|
||||
|
||||
// 세션 변수의 등록
|
||||
//FIXME:session_start()를 각자 수행하고, ajax등의 경우에는 session_write_close로 빠르게 끝낼 수 있어야한다.
|
||||
//NOTE: ajax등의 경우에는 session_write_close로 빠르게 끝낼 수 있어야한다.
|
||||
session_start();
|
||||
|
||||
//첫 등장
|
||||
if(!isset($_SESSION['p_ip']) || $_SESSION['p_ip'] == "") {
|
||||
if(!util::array_get($_SESSION['p_ip'], null)) {
|
||||
$_SESSION['p_ip'] = getenv("REMOTE_ADDR");
|
||||
$_SESSION['p_time'] = time();
|
||||
}
|
||||
@@ -101,9 +103,8 @@ if(!isset($_SESSION['p_ip']) || $_SESSION['p_ip'] == "") {
|
||||
//id, 이름, 국가는 로그인에서
|
||||
//초과된 세션은 로그아웃(1시간)
|
||||
if($_SESSION['p_time']+3600 < time()) {
|
||||
$_SESSION['p_id'] = "";
|
||||
$_SESSION['p_name'] = "";
|
||||
$_SESSION['p_nation'] = 0;
|
||||
unset($_SESSION['p_id']);
|
||||
unset($_SESSION[getServPrefix().'p_name']);
|
||||
$_SESSION['p_time'] = time();
|
||||
session_destroy();
|
||||
} else {
|
||||
@@ -180,6 +181,7 @@ function isTable($connect, $str, $dbname='') {
|
||||
|
||||
// 빈문자열 경우 1을 리턴
|
||||
function isblank($str) {
|
||||
//FIXME: 리턴 값은 boolean이 더 적절하다.
|
||||
$temp=str_replace(" ","",$str);
|
||||
$temp=str_replace("\n","",$temp);
|
||||
$temp=strip_tags($temp);
|
||||
@@ -208,6 +210,30 @@ function PrintElapsedTime() {
|
||||
echo "<table width=1000 align=center style=font-size:10;><tr><td align=right>경과시간 : {$_endTime}초</td></tr></table>";
|
||||
}
|
||||
|
||||
/**
|
||||
* '비교적' 안전한 int 변환
|
||||
* null -> null
|
||||
* int -> int
|
||||
* float -> int
|
||||
* numeric(int, float) 포함 -> int
|
||||
* 기타 -> 예외처리
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
function toInt($val){
|
||||
if($val === null){
|
||||
return null;
|
||||
}
|
||||
if(is_int($val)){
|
||||
return $val;
|
||||
}
|
||||
if(is_numeric($val)){
|
||||
return intval($val);//
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('올바르지 않은 타입형 :'.$val);
|
||||
}
|
||||
|
||||
function LogText($prefix, $variable){
|
||||
$fp = fopen('logs/dbg_logs.txt', 'a+');
|
||||
if($fp == false){
|
||||
@@ -217,10 +243,19 @@ function LogText($prefix, $variable){
|
||||
$fp = fopen('logs/dbg_logs.txt', 'a+');
|
||||
}
|
||||
}
|
||||
fwrite($fp, sprintf('%s : %s\n', $prefix, var_export($_POST, true)));
|
||||
fwrite($fp, sprintf('%s : %s'."\n", $prefix, var_export($_POST, true)));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function dictToArray($dict, $keys){
|
||||
$result = [];
|
||||
|
||||
foreach($keys as $key){
|
||||
$result[] = util::array_get($dict[$key], null);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function parseJsonPost(){
|
||||
// http://thisinterestsme.com/receiving-json-post-data-via-php/
|
||||
// http://thisinterestsme.com/php-json-error-handling/
|
||||
@@ -279,7 +314,9 @@ function parseJsonPost(){
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
LogText($_SERVER['REQUEST_URI'], $_POST);
|
||||
if(isset($_POST) && count($_POST) > 0){
|
||||
LogText($_SERVER['REQUEST_URI'], $_POST);
|
||||
}
|
||||
extract($_POST, EXTR_SKIP);
|
||||
//XXX: $_POST를 추출 없이 그냥 쓰는 경우가 많아서 일단 디버깅을 위해 씀!!!! 절대 production 서버에서 사용 금지!
|
||||
//todo: $_POST로 제공되는 데이터를 각 페이지마다 분석할것.
|
||||
+21
-18
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
use utilphp\util as util;
|
||||
//FIXME: 이 프로세스 전체가 필요없을 수 있다. session 디렉토리를 관리하지 않거나, 자동 로그인을 처리하는 방법을 생각할 것.
|
||||
|
||||
$connect = dbConn("sammo");
|
||||
use utilphp\util as util;
|
||||
|
||||
$id = util::array_get($_POST['id'],'');
|
||||
$pw = util::array_get($_POST['pw'], '');
|
||||
@@ -13,30 +12,34 @@ $conmsg = util::array_get($_POST['conmsg'], '');
|
||||
|
||||
$pw = substr($pw, 0, 32);
|
||||
|
||||
|
||||
|
||||
//회원 테이블에서 정보확인
|
||||
$query = "select no,name from MEMBER where id='$id' and pw='$pw'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$member = MYDB_fetch_array($result);
|
||||
$member = getRootDB()->queryFirstRow('select no,name from MEMBER where id=%s and pw=%s', $id, $pw);
|
||||
|
||||
$connect = dbConn();
|
||||
|
||||
if(!$member) {
|
||||
MessageBox("아이디나 암호가 올바르지 않습니다!!!");
|
||||
//TODO:login_process를 rest 형태로 처리
|
||||
//header ("Location: index.php");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//NOTE: 왜 Session을 지우는가?
|
||||
DeleteSession();
|
||||
|
||||
$db = getDB();
|
||||
|
||||
//회원 테이블에서 정보확인
|
||||
$query="select no,name,nation,block,killturn from general where user_id='$id'";
|
||||
$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(!$member) {
|
||||
//MessageBox("아이디나 암호가 올바르지 않습니다!!!");
|
||||
//TODO:login_process를 rest 형태로 처리
|
||||
header ("Location: index.php");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(!$me) {
|
||||
//MessageBox("캐릭터가 없습니다!!!");
|
||||
MessageBox("캐릭터가 없습니다!!!");
|
||||
//TODO:login_process를 rest 형태로 처리
|
||||
header ("Location: index.php");
|
||||
//header ("Location: index.php");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -52,9 +55,9 @@ case 3:
|
||||
MessageBox("절대 1계정만 사용하십시오! {$me['killturn']}시간 후 재등록 가능합니다."); break;
|
||||
}
|
||||
|
||||
$_SESSION[getServPrefix().'p_no'] = toInt($me['no']);
|
||||
$_SESSION['p_id'] = $id;
|
||||
$_SESSION['p_name'] = $me['name'];
|
||||
$_SESSION['p_nation'] = $me['nation'];
|
||||
$_SESSION[getServPrefix().'p_name'] = $me['name'];
|
||||
$_SESSION['p_time'] = time();
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
+6
-30
@@ -1,37 +1,13 @@
|
||||
<?php
|
||||
//NOTE: 전역 로그아웃 외에 게임 로그아웃이 의미가 있나?
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$connect=dbConn();
|
||||
unset($_SESSION['p_id']);
|
||||
unset($_SESSION['p_ip']);
|
||||
unset($_SESSION[getServPrefix().'p_no']);
|
||||
unset($_SESSION[getServPrefix().'p_name']);
|
||||
|
||||
$query = "select no,user_id,password,name from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$_SESSION['p_id'] = "";
|
||||
$_SESSION['p_name'] = "";
|
||||
$_SESSION['p_nation'] = 0;
|
||||
|
||||
$id = $me['user_id'];
|
||||
$pw = $me['password'];
|
||||
$conmsg = $me['conmsg'];
|
||||
|
||||
//���Ǻ��� ����
|
||||
session_destroy();
|
||||
|
||||
//echo "<script>location.replace('start.php');</script>";
|
||||
//echo 'start.php';//TODO:debug all and replace
|
||||
header('Location:start.php');
|
||||
|
||||
/*
|
||||
<html>
|
||||
a
|
||||
<form name=form1 action=../login.php method=post>
|
||||
<input type=hidden name=id value='<?=$id;?>'>
|
||||
<input type=hidden name=pw value='<?=$pw;?>'>
|
||||
<input type=hidden name=conmsg value='<?=$conmsg;?>'>
|
||||
</form>
|
||||
<script>form1.submit();</script>
|
||||
</html>
|
||||
*/
|
||||
|
||||
header('Location:start.php');
|
||||
@@ -40,8 +40,7 @@ if(!$me2) {
|
||||
}
|
||||
|
||||
$_SESSION['p_id'] = $id;
|
||||
$_SESSION['p_name'] = $me['name'];
|
||||
$_SESSION['p_nation'] = $me['nation'];
|
||||
$_SESSION['p_ip'] = getenv("REMOTE_ADDR");
|
||||
$_SESSION['p_time'] = time();
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
|
||||
use utilphp\util as util;
|
||||
CheckLogin(1);
|
||||
$connect = dbConn();
|
||||
increaseRefresh($connect, "턴반복", 1);
|
||||
|
||||
Reference in New Issue
Block a user