sammo를 쓰는 일부 파일을 getRootDB()를 이용하도록 수정
메시지 DB 형태 변경. 메시지를 전송하는 별도의 함수 sendMessage(), sendRawMessage() 생성 j_msgsubmit.php 전면 수정 가능한 메일함을 구해오는 getMailboxList() 함수 추가 CheckBlock를 getBlockLevel로 변경하고, 내부 구현 수정
This commit is contained in:
@@ -28,10 +28,7 @@ switch($btn) {
|
|||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
break;
|
break;
|
||||||
case "블럭 해제":
|
case "블럭 해제":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
getDB()->query('update general set block=0 where no IN %li', $genlist);
|
||||||
$query = "update general set block=0 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "1단계 블럭":
|
case "1단계 블럭":
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
@@ -60,10 +57,7 @@ switch($btn) {
|
|||||||
break;
|
break;
|
||||||
case "강제 사망":
|
case "강제 사망":
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
getDB()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
|
||||||
$query = "update general set turn0=0,killturn=0,turntime='$date' where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "특기 부여":
|
case "특기 부여":
|
||||||
$query = "select year,month from game where no=1";
|
$query = "select year,month from game where no=1";
|
||||||
|
|||||||
+18
-57
@@ -14,79 +14,40 @@ if($me['userlevel'] < 5) {
|
|||||||
echo '_admin4.php';//TODO:debug all and replace
|
echo '_admin4.php';//TODO:debug all and replace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NOTE: 왜 기능이 admin2와 admin4가 같이 있는가?
|
||||||
|
//NOTE: 왜 블럭 시 admin4에선 금쌀을 없애지 않는가?
|
||||||
switch($btn) {
|
switch($btn) {
|
||||||
case "블럭 해제":
|
case "블럭 해제":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
getDB()->query('update general set block=0 where no IN %li', $genlist);
|
||||||
$query = "update general set block=0 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "1단계 블럭":
|
case "1단계 블럭":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
|
||||||
$query = "update general set block=1,killturn=24 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
|
|
||||||
$query = "select user_id from general where no='$genlist[$i]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$uid[$i] = $gen['user_id'];
|
|
||||||
}
|
|
||||||
$connect = dbConn("sammo");
|
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
for($i=0; $i < sizeof($uid); $i++) {
|
$db = getDB();
|
||||||
//블럭정보
|
$db->query('update general set block=1,killturn=24 where no IN %li',$genlist);
|
||||||
$query = "update MEMBER set block_num=block_num+1,block_date='$date' where id='$uid[$i]'";
|
//FIXME: subquery로 하는게 더 빠를 듯.
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$uid = $db->queryFirstColumn('select user_id from general where no IN %li', $genlist);
|
||||||
}
|
getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
|
||||||
break;
|
break;
|
||||||
case "2단계 블럭":
|
case "2단계 블럭":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
|
||||||
$query = "update general set block=2,killturn=24 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
|
|
||||||
$query = "select user_id from general where no='$genlist[$i]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$uid[$i] = $gen['user_id'];
|
|
||||||
}
|
|
||||||
$connect = dbConn("sammo");
|
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
for($i=0; $i < sizeof($uid); $i++) {
|
$db = getDB();
|
||||||
//블럭정보
|
$db->query('update general set block=2,killturn=24 where no IN %li',$genlist);
|
||||||
$query = "update MEMBER set block_num=block_num+1,block_date='$date' where id='$uid[$i]'";
|
$uid = $db->queryFirstColumn('select user_id from general where no IN %li', $genlist);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "3단계 블럭":
|
case "3단계 블럭":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
|
||||||
$query = "update general set block=3,killturn=24 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
|
|
||||||
$query = "select user_id from general where no='$genlist[$i]'";
|
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$gen = MYDB_fetch_array($result);
|
|
||||||
$uid[$i] = $gen['user_id'];
|
|
||||||
}
|
|
||||||
$connect = dbConn("sammo");
|
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
for($i=0; $i < sizeof($uid); $i++) {
|
$db = getDB();
|
||||||
//블럭정보
|
$db->query('update general set block=3,killturn=24 where no IN %li',$genlist);
|
||||||
$query = "update MEMBER set block_num=block_num+1,block_date='$date' where id='$uid[$i]'";
|
$uid = $db->queryFirstColumn('select user_id from general where no IN %li', $genlist);
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
getRootDB()->query('update MEMBER set block_num=block_num+1,block_date=%s where id IN %ls', $date, $uid);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "무한삭턴":
|
case "무한삭턴":
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
getDB()->query('update general set killturn=8000 where no IN %li',$genlist);
|
||||||
$query = "update general set killturn=8000 where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "강제 사망":
|
case "강제 사망":
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
for($i=0; $i < sizeof($genlist); $i++) {
|
getDB()->query('update general set turn0=0,killturn=0,turntime=%s where no IN %li',$date, $genlist);
|
||||||
$query = "update general set turn0=0,killturn=0,turntime='$date' where no='$genlist[$i]'";
|
|
||||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "메세지 전달":
|
case "메세지 전달":
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ include "func.php";
|
|||||||
CheckLogin();
|
CheckLogin();
|
||||||
$connect = dbConn();
|
$connect = dbConn();
|
||||||
|
|
||||||
if(CheckBlock($connect) != 1 && CheckBlock($connect) != 3) {
|
if(getBlockLevel() != 1 && getBlockLevel() != 3) {
|
||||||
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
$me = MYDB_fetch_array($result);
|
$me = MYDB_fetch_array($result);
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ CheckLogin(1);
|
|||||||
$connect = dbConn();
|
$connect = dbConn();
|
||||||
increaseRefresh($connect, "서신전달", 1);
|
increaseRefresh($connect, "서신전달", 1);
|
||||||
|
|
||||||
if(CheckBlock($connect) == 1 || CheckBlock($connect) == 3) {
|
if(getBlockLevel() == 1 || getBlockLevel() == 3) {
|
||||||
$msg = "";
|
$msg = "";
|
||||||
$genlist = 0;
|
$genlist = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ include "func.php";
|
|||||||
CheckLogin();
|
CheckLogin();
|
||||||
$connect = dbConn();
|
$connect = dbConn();
|
||||||
|
|
||||||
if(CheckBlock($connect) != 1 && CheckBlock($connect) != 3) {
|
if(getBlockLevel() != 1 && getBlockLevel() != 3) {
|
||||||
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||||
$me = MYDB_fetch_array($result);
|
$me = MYDB_fetch_array($result);
|
||||||
|
|||||||
+3
-6
@@ -19,7 +19,7 @@ function randF(){
|
|||||||
return mt_rand() / mt_getrandmax();
|
return mt_rand() / mt_getrandmax();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// $_SESSION['p_id'] 의 값을 받아옴
|
||||||
function getGeneralID(){
|
function getGeneralID(){
|
||||||
//TODO: 서버마다 p_id가 다를 수 있도록 조치
|
//TODO: 서버마다 p_id가 다를 수 있도록 조치
|
||||||
if(!isset($_SESSION['p_id'])){
|
if(!isset($_SESSION['p_id'])){
|
||||||
@@ -67,11 +67,8 @@ function checkLimit($userlevel, $con, $conlimit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckBlock($connect) {
|
function getBlockLevel() {
|
||||||
$query = "select block from general where user_id='{$_SESSION['p_id']}'";
|
return getDB()->queryFirstField('select block from general where user_id= %i', getGeneralID());
|
||||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
|
||||||
$me = MYDB_fetch_array($result);
|
|
||||||
return $me['block'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandGenName() {
|
function getRandGenName() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ function LogHistory($connect, $isFirst=0) {
|
|||||||
$current_url = util::get_current_url();
|
$current_url = util::get_current_url();
|
||||||
$map_path = explode('/',parse_url($current_url, PHP_URL_PASS));
|
$map_path = explode('/',parse_url($current_url, PHP_URL_PASS));
|
||||||
array_pop($map_path);
|
array_pop($map_path);
|
||||||
array_push($map_path, 'map.php?type=2&graphic=0');
|
$map_path[] = 'map.php?type=2&graphic=0';
|
||||||
$map_path = join('/', $map_path);
|
$map_path = join('/', $map_path);
|
||||||
|
|
||||||
$client = new GuzzleHttp\Client();
|
$client = new GuzzleHttp\Client();
|
||||||
|
|||||||
+107
-22
@@ -7,51 +7,43 @@ class Message{
|
|||||||
public $id;
|
public $id;
|
||||||
public $mailbox;
|
public $mailbox;
|
||||||
public $type;
|
public $type;
|
||||||
|
public $isSender;
|
||||||
public $src;
|
public $src;
|
||||||
public $dest;
|
public $dest;
|
||||||
public $time;
|
public $time;
|
||||||
public $message;
|
public $message;
|
||||||
|
|
||||||
public $rawType;
|
|
||||||
|
|
||||||
function __construct($row){
|
function __construct($row){
|
||||||
$this->raw_type = $row['type'];
|
|
||||||
|
|
||||||
$this->id = $row['id'];
|
$this->id = $row['id'];
|
||||||
$this->mailbox = $row['mailbox'];
|
$this->mailbox = $row['mailbox'];
|
||||||
|
$this->type = $row['type'];
|
||||||
if($this->rawType === 'public'){
|
$this->isSender = $row['is_sender'] != 0;
|
||||||
$this->type = 'public';
|
|
||||||
}
|
|
||||||
else if(util::ends_with($this->rawType, 'national')){
|
|
||||||
$this->type = 'national';
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$this->type = 'private';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->src = [
|
$this->src = [
|
||||||
'id' => $row['src'],
|
'id' => $row['src'],
|
||||||
'name' => $row['src_name'],
|
'name' => $row['src_name'],
|
||||||
'nation' => $row['src_nation'],
|
'nation' => $row['src_nation'],
|
||||||
'color' => $row['src_color']
|
'color' => $row['src_color'],
|
||||||
|
'nation_id' => $row['src_nation_id']
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->src['nation'] === NULL){
|
if($this->src['nation'] === null){
|
||||||
$this->src['nation'] = '재야';
|
$this->src['nation'] = '재야';
|
||||||
$this->src['color'] = '#FFFFFF';
|
$this->src['color'] = '#FFFFFF';
|
||||||
|
$this->src['nation_id'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dest = [
|
$this->dest = [
|
||||||
'id' => $row['dest'],
|
'id' => $row['dest'],
|
||||||
'name' => $row['dest_name'],
|
'name' => $row['dest_name'],
|
||||||
'nation' => $row['dest_nation'],
|
'nation' => $row['dest_nation'],
|
||||||
'color' => $row['dest_color']
|
'color' => $row['dest_color'],
|
||||||
|
'nation_id' => $row['dest_nation_id']
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->dest['nation'] === NULL){
|
if($this->dest['nation'] === null){
|
||||||
$this->dest['nation'] = '재야';
|
$this->dest['nation'] = '재야';
|
||||||
$this->dest['color'] = '#FFFFFF';
|
$this->dest['color'] = '#FFFFFF';
|
||||||
|
$this->dest['nation_id'] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->datetime = $row['time'];
|
$this->datetime = $row['time'];
|
||||||
@@ -88,7 +80,7 @@ function getRawMessage($mailbox, $limit=30, $fromTime=NULL){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMessage($msgType, $limit=30, $fromTime=NULL){
|
function getMessage($msgType, $limit=30, $fromTime=NULL){
|
||||||
$generalID = genID();
|
$generalID = getGeneralID();
|
||||||
if($generalID === NULL){
|
if($generalID === NULL){
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -109,10 +101,103 @@ function getMessage($msgType, $limit=30, $fromTime=NULL){
|
|||||||
else{
|
else{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendRawMessage($msgType, $isSender, $mailbox, $src, $dest, $msg, $date){
|
||||||
|
|
||||||
|
getDB()->insert('message', array(
|
||||||
|
'address' => $dest,
|
||||||
|
'type' => 'receive',
|
||||||
|
'src' => $src['id'],
|
||||||
|
'dest' => $dest['id'],
|
||||||
|
'time' => $date,
|
||||||
|
'src_nation_id' => util::array_get($src['nation_id'], null),
|
||||||
|
'src_name' => util::array_get($src['name'], null),
|
||||||
|
'src_nation' => util::array_get($src['nation'], null),
|
||||||
|
'src_color' => util::array_get($src['color'], null),
|
||||||
|
'src_icon' => util::array_get($src['icon'], null),
|
||||||
|
'dest_nation_id' => util::array_get($dest['nation_id'], null),
|
||||||
|
'dest_name' => util::array_get($dest['name'], null),
|
||||||
|
'dest_nation' => util::array_get($dest['nation'], null),
|
||||||
|
'dest_color' => util::array_get($dest['color'], null),
|
||||||
|
'message' => $msg
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendMessage($msgType, $src, $dest, $msg, $date = null){
|
||||||
|
if($date === null){
|
||||||
|
$date = $datetime->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
if($msgType === 'public'){
|
||||||
|
//dest는 필요하지 않음
|
||||||
|
$srcMailbox = null;
|
||||||
|
$destMailbox = 9999;
|
||||||
|
$dest['id'] = 9999;
|
||||||
|
}
|
||||||
|
else if($msgType === 'national'){
|
||||||
|
//dest는 nation_id만 필요함
|
||||||
|
$dest['id'] = $dest['nation_id'] + 9000;
|
||||||
|
|
||||||
|
if($src['nation_id'] === $dest['nation_id']){
|
||||||
|
$srcMailbox = null;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$srcMailbox = $src['nation_id'] + 9000;
|
||||||
|
}
|
||||||
|
$destMailbox = $dest['nation_id'] + 9000;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//dest는 id, name이 필수
|
||||||
|
$srcMailbox = $src['id'];
|
||||||
|
$destMailbox = $dest['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($srcMailbox !== null){
|
||||||
|
sendRawMessage($msgType, true, $srcMailbox, $src, $dest, $msg, $date);
|
||||||
|
}
|
||||||
|
sendRawMessage($msgType, false, $destMailbox, $src, $dest, $msg, $date);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMailboxList(){
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
$generalID = getGeneralID();
|
||||||
|
$db = getDB();
|
||||||
|
$me = $db->queryFirstRow('select no,nation,level from general where user_id=%i', $generalID);
|
||||||
|
|
||||||
|
//가장 최근에 주고 받은 사람.
|
||||||
|
$latestMessage = util::array_get(getMessage('private', 1)[0], null);
|
||||||
|
if($latestMessage !== null){
|
||||||
|
if($latestMessage->src == $generalID){
|
||||||
|
$latestMessage = $latestMessage->dest;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$latestMessage = $latestMessage->src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nations = [];
|
||||||
|
foreach ($db->query('select nation, name, color from nation') as $nation) {
|
||||||
|
$nations[$nation['nation']] = $nation;
|
||||||
|
}
|
||||||
|
$nations[0] = [
|
||||||
|
'nation' => 0,
|
||||||
|
'name' => '재야',
|
||||||
|
'color' => '#ffffff'
|
||||||
|
];
|
||||||
|
|
||||||
|
$generals = $db->query('select no, nation, name, level from general where npc < 2 and no != %i order by name asc', $generalID);
|
||||||
|
foreach ($generals as $general) {
|
||||||
|
$nations[$general['nation']] = $general;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'me' => $me,
|
||||||
|
'latest' => $latestMessage,
|
||||||
|
'nations' => $nations
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function genList($connect) {
|
function genList($connect) {
|
||||||
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
||||||
|
|||||||
+53
-139
@@ -3,9 +3,6 @@ include 'lib.php';
|
|||||||
include 'func.php';
|
include 'func.php';
|
||||||
require_once('func_message.php');
|
require_once('func_message.php');
|
||||||
|
|
||||||
// $msg, $genlist
|
|
||||||
|
|
||||||
|
|
||||||
$post = parseJsonPost();
|
$post = parseJsonPost();
|
||||||
|
|
||||||
if(!isset($post['genlist']) || !isset($post['msg'])){
|
if(!isset($post['genlist']) || !isset($post['msg'])){
|
||||||
@@ -18,7 +15,7 @@ if(!isset($post['genlist']) || !isset($post['msg'])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$dest = $post['dest'];
|
$destMailbox = $post['dest_mailbox'];
|
||||||
$msg = $post['msg'];
|
$msg = $post['msg'];
|
||||||
$datetime = new DateTime();
|
$datetime = new DateTime();
|
||||||
$date = $datetime->format('Y-m-d H:i:s');
|
$date = $datetime->format('Y-m-d H:i:s');
|
||||||
@@ -39,9 +36,7 @@ $db = getDB();
|
|||||||
$connect = dbConn();
|
$connect = dbConn();
|
||||||
increaseRefresh($connect, '서신전달', 1);
|
increaseRefresh($connect, '서신전달', 1);
|
||||||
|
|
||||||
//$msg,$genlist 두가지 값을 받
|
if(getBlockLevel() == 1 || getBlockLevel() == 3) {
|
||||||
|
|
||||||
if(CheckBlock($connect) == 1 || CheckBlock($connect) == 3) {
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
@@ -50,9 +45,6 @@ if(CheckBlock($connect) == 1 || CheckBlock($connect) == 3) {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$conlimit = $db->queryFirstField('select conlimit from game where no=1');
|
$conlimit = $db->queryFirstField('select conlimit from game where no=1');
|
||||||
|
|
||||||
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`msgindex`,`userlevel`,`con`,`picture`,`imgsvr` from `general` where `user_id` = %s_p_id',
|
$me = $db->queryFirstRow('select `no`,`name`,`nation`,`level`,`msgindex`,`userlevel`,`con`,`picture`,`imgsvr` from `general` where `user_id` = %s_p_id',
|
||||||
@@ -89,106 +81,55 @@ if($msg == ''){
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$src = $me['no'];
|
$src = [
|
||||||
$src_name = $me['name'];
|
'id' => $me['no'],
|
||||||
$src_icon = $me['picture'];
|
'name' => $me['name'],
|
||||||
$src_nation_id = $me['nation'];
|
'icon' => $me['picture'],
|
||||||
if($src_nation_id == 0) {
|
'nation_id' => $me['nation'],
|
||||||
$src_nation = '재야';
|
'nation' => null
|
||||||
$src_color = '#FFFFFF';
|
];
|
||||||
}
|
if($src['nation_id'] != 0) {
|
||||||
else{
|
|
||||||
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$src_nation_id);
|
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$src_nation_id);
|
||||||
$src_nation = $nation['name'];
|
$src['nation'] = $nation['name'];
|
||||||
$src_color = '#'.$nation['color'];
|
$src['color'] = '#'.$nation['color'];
|
||||||
$src_color = str_replace('##', '#', $src_color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
$src['color'] = str_replace('##', '#', $src['color']); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
||||||
}
|
}
|
||||||
|
|
||||||
// 전체 메세지
|
// 전체 메세지
|
||||||
if($dest == 9999) {
|
if($destMailbox == 9999) {
|
||||||
|
sendMessage('public', $src, [], $msg, $date);
|
||||||
$db->insert('message', array(
|
|
||||||
'address' => $dest,
|
|
||||||
'type' => 'global',
|
|
||||||
'src' => $src,
|
|
||||||
'dest' => $dest,
|
|
||||||
'time' => $date,
|
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
|
||||||
'src_color' => $src_color,
|
|
||||||
'src_icon' => $src_icon,
|
|
||||||
'message' => $msg
|
|
||||||
));
|
|
||||||
|
|
||||||
// 국가 메세지
|
// 국가 메세지
|
||||||
} elseif($dest >= 9000) {
|
} elseif($destMailbox >= 9000) {
|
||||||
$real_nation = $dest - 9000;
|
|
||||||
|
if($me['level'] < 5){
|
||||||
|
$real_nation = $me['nation_id'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$real_nation = $dest - 9000;
|
||||||
|
}
|
||||||
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$real_nation);
|
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$real_nation);
|
||||||
|
|
||||||
if($nation === NULL || empty($nation)){
|
if($nation === NULL || empty($nation)){
|
||||||
$dest = 9998;
|
$dest = ['nation_id' => 0];
|
||||||
$dest_nation = '재야';
|
|
||||||
$dest_color = '#FFFFFF';
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$dest_nation = $nation['name'];
|
$color = '#'.$nation['color'];
|
||||||
$dest_color = '#'.$nation['color'];
|
$color = str_replace('##', '#', $color);
|
||||||
$dest_color = str_replace('##', '#', $dest_color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
//FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
||||||
|
$dest = [
|
||||||
|
'nation_id' => $nation['nation'],
|
||||||
|
'color' => $color
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendMessage('national', $src, $dest, $msg, $date);
|
||||||
if($nation['nation'] == $me['nation'] || $me['level'] < 5){
|
|
||||||
$db->insert('message', array(
|
|
||||||
'address' => $dest,
|
|
||||||
'type' => 'receive_nation',
|
|
||||||
'src' => $src,
|
|
||||||
'dest' => $dest,
|
|
||||||
'time' => $date,
|
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
|
||||||
'src_color' => $src_color,
|
|
||||||
'src_icon' => $src_icon,
|
|
||||||
'dest_nation' => $dest_nation,
|
|
||||||
'dest_color' => $dest_color,
|
|
||||||
'message' => $msg
|
|
||||||
));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$db->insert('message', array(
|
|
||||||
'address' => $src_nation_id + 9000,
|
|
||||||
'type' => 'send_nation',
|
|
||||||
'src' => $src,
|
|
||||||
'dest' => $dest,
|
|
||||||
'time' => $date,
|
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
|
||||||
'src_color' => $src_color,
|
|
||||||
'src_icon' => $src_icon,
|
|
||||||
'dest_nation' => $dest_nation,
|
|
||||||
'dest_color' => $dest_color,
|
|
||||||
'message' => $msg
|
|
||||||
));
|
|
||||||
$db->insert('message', array(
|
|
||||||
'address' => $dest,
|
|
||||||
'type' => 'receive_nation',
|
|
||||||
'src' => $src,
|
|
||||||
'dest' => $dest,
|
|
||||||
'time' => $date,
|
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
|
||||||
'src_color' => $src_color,
|
|
||||||
'src_icon' => $src_icon,
|
|
||||||
'dest_nation' => $dest_nation,
|
|
||||||
'dest_color' => $dest_color,
|
|
||||||
'message' => $msg
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 개인 메세지
|
// 개인 메세지
|
||||||
} elseif($dest > 0) {
|
} 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();
|
$msg_interval = $datetime->getTimestamp() - $last_msg->getTimestamp();
|
||||||
|
//NOTE: 여기서 유저 레벨을 구별할 코드가 필요할까?
|
||||||
if($msg_interval < 2){
|
if($msg_interval < 2){
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
@@ -198,11 +139,10 @@ if($dest == 9999) {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['last_msg'] = $date;
|
|
||||||
|
$destUser = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `user_id` = %s',$destMailbox);
|
||||||
|
|
||||||
$dest_user = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `user_id` = %s',$dest);
|
if($destUser == NULL || empty($destUser)){
|
||||||
|
|
||||||
if($dest_user == NULL || empty($dest_user)){
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
'result' => false,
|
'result' => false,
|
||||||
@@ -211,49 +151,23 @@ if($dest == 9999) {
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$dest_name = $dest_user['name'];
|
$_SESSION['last_msg'] = $date;
|
||||||
if($dest_user['nation'] == 0){
|
|
||||||
$dest_nation = $nation['name'];
|
|
||||||
$dest_color = '#'.$nation['color'];
|
|
||||||
$dest_color = str_replace('##', '#', $dest_color);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$dest_user['nation']);
|
|
||||||
$dest_nation = $nation['name'];
|
|
||||||
$dest_color = '#'.$nation['color'];
|
|
||||||
$dest_color = str_replace('##', '#', $dest_color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->insert('message', array(
|
$dest = [
|
||||||
'address' => $src_nation_id + 9000,
|
'id' => $destMailbox,
|
||||||
'type' => 'send',
|
'name' => $dest_user['name']
|
||||||
'src' => $src,
|
];
|
||||||
'dest' => $dest,
|
if($dest_user['nation'] != 0){
|
||||||
'time' => $date,
|
$nation = $db->queryFirstRow('select nation,name,color from nation where nation=%i',$dest_user['nation']);
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
$color = $nation['color'];
|
||||||
'src_color' => $src_color,
|
$color = str_replace('##', '#', $color);
|
||||||
'src_icon' => $src_icon,
|
//FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
||||||
'dest_name' => $dest_name,
|
$dest['color'] = $color;
|
||||||
'dest_nation' => $dest_nation,
|
$dest['nation'] = $nation['name'];
|
||||||
'dest_color' => $dest_color,
|
$dest['nation_id'] = $nation['nation'];
|
||||||
'message' => $msg
|
}
|
||||||
));
|
sendMessage('private', $src, $dest, $msg, $date);
|
||||||
$db->insert('message', array(
|
|
||||||
'address' => $dest,
|
|
||||||
'type' => 'receive',
|
|
||||||
'src' => $src,
|
|
||||||
'dest' => $dest,
|
|
||||||
'time' => $date,
|
|
||||||
'src_name' => $src_name,
|
|
||||||
'src_nation' => $src_nation,
|
|
||||||
'src_color' => $src_color,
|
|
||||||
'src_icon' => $src_icon,
|
|
||||||
'dest_name' => $dest_name,
|
|
||||||
'dest_nation' => $dest_nation,
|
|
||||||
'dest_color' => $dest_color,
|
|
||||||
'message' => $msg
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|||||||
+14
-4
@@ -432,14 +432,24 @@ $game_schema = "
|
|||||||
$message_schema = "
|
$message_schema = "
|
||||||
CREATE TABLE `message` (
|
CREATE TABLE `message` (
|
||||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
`address` INT(11) NOT NULL,
|
`mailbox` INT(11) NOT NULL COMMENT '9999 == public, >= 9000 national',
|
||||||
`type` ENUM('send','receive') NOT NULL,
|
`type` ENUM('private','national','public') NOT NULL,
|
||||||
|
`is_sender` BIT(1) NOT NULL,
|
||||||
`src` INT(11) NOT NULL,
|
`src` INT(11) NOT NULL,
|
||||||
`dest` INT(11) NOT NULL,
|
`dest` INT(11) NOT NULL,
|
||||||
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`src_nation_id` INT(11) NULL DEFAULT NULL,
|
||||||
|
`src_name` VARCHAR(15) NOT NULL,
|
||||||
|
`src_nation` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
`src_color` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
`src_icon` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
`dest_nation_id` INT(11) NULL DEFAULT NULL,
|
||||||
|
`dest_name` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
`dest_nation` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
`dest_color` VARCHAR(15) NULL DEFAULT NULL,
|
||||||
`message` TEXT NOT NULL,
|
`message` TEXT NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
INDEX `by_owner` (`address`, `time`),
|
INDEX `by_owner` (`mailbox`, `time`),
|
||||||
INDEX `by_dest` (`dest`, `time`),
|
INDEX `by_dest` (`dest`, `time`),
|
||||||
INDEX `by_full` (`src`, `dest`, `time`)
|
INDEX `by_full` (`src`, `dest`, `time`)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user