Files
core/twe/j_msgsubmit.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

165 lines
3.8 KiB
PHP

<?php
include 'lib.php';
include 'func.php';
use utilphp\util as util;
/**
* 메시지 전송 코드.
*
* TODO: 장기적으로 ajax는 한곳에 모을 필요가 있을 듯.
*/
//읽기 전용이다. 빠르게 세션 끝내자
session_write_close();
$post = parseJsonPost();
if(!isset($post['genlist']) || !isset($post['msg'])){
returnJson([
'result' => false,
'reason' => '올바르지 않은 호출입니다.',
'newSeq' => false
]);
}
$destMailbox = $post['dest_mailbox'];
$msg = $post['msg'];
$datetime = new DateTime();
$date = $datetime->format('Y-m-d H:i:s');
//로그인 검사
if(!isSigned()){
returnJson([
'result' => false,
'reason' => '로그인되지 않았습니다.',
'newSeq' => false
]);
}
$db = getDB();
$connect = dbConn();
increaseRefresh('서신전달', 1);
if(getBlockLevel() == 1 || getBlockLevel() == 3) {
returnJson([
'result' => false,
'reason' => '차단되었습니다.',
'newSeq' => false
]);
}
$conlimit = $db->queryFirstField('select conlimit from game where no=1');
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`con`,`picture`,`imgsvr` from `general` where `owner` = %i', getUserID());
if(!$me){
resetSessionGeneralValues();
returnJson([
'result' => false,
'reason' => '로그인되지 않았습니다.',
'newSeq' => false
]);
}
$con = checkLimit($me['con'], $conlimit);
if($con >= 2) {
returnJson([
'result' => false,
'reason' => '접속 제한입니다.',
'newSeq' => false
]);
}
//SubStrForWidth는 반각은 1, 전각은 2로 측정하는듯 보이나, 대부분 글자수 단위로 카운트 하고 있어 mb_substr로 처리함.
$msg = mb_substr($msg, 0, 99, 'UTF-8');
$msg = trim($msg);
if($msg == ''){
returnJson([
'result' => true,
'reason' => 'SUCCESS',
'newSeq' => false
]);
}
$src = [
'id' => $me['no'],
'name' => $me['name'],
'icon' => $me['picture'],
'nation_id' => $me['nation'],
];
// 전체 메세지
if($destMailbox == 9999) {
sendMessage('public', $src, null, $msg, $date);
// 국가 메세지
} elseif($destMailbox >= 9000) {
if($me['level'] < 5){
$real_nation = $me['nation_id'];
}
else{
$real_nation = $dest - 9000;
}
if(!getNationStaticInfo($real_nation)){
$real_nation = $me['nation_id'];
}
$dest = [
'nation_id' => $real_nation
];
sendMessage('national', $src, $dest, $msg, $date);
// 개인 메세지
} elseif($destMailbox > 0) {
$last_msg = new DateTime(util::array_get($_SESSION['last_msg'], '0000-00-00'));
$msg_interval = $datetime->getTimestamp() - $last_msg->getTimestamp();
//NOTE: 여기서 유저 레벨을 구별할 코드가 필요할까?
if($msg_interval < 2){
returnJson([
'result' => false,
'reason' => '개인메세지는 2초당 1건만 보낼 수 있습니다!',
'newSeq' => false
]);
}
$destUser = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `no` = %s',$destMailbox);
if($destUser == NULL || empty($destUser)){
returnJson([
'result' => false,
'reason' => '존재하지 않는 유저입니다.',
'newSeq' => false
]);
}
$_SESSION['last_msg'] = $date;
$dest = [
'id' => $destMailbox,
'name' => $dest_user['name'],
'nation_id' => $dest_user['nation']
];
sendMessage('private', $src, $dest, $msg, $date);
}
else{
returnJson([
'result' => false,
'reason' => '알 수 없는 에러',
'newSeq' => false
]);
}
returnJson([
'result' => true,
'reason' => 'SUCCESS',
'newSeq' => true
]);