갠메 전송 시스템 추가
This commit is contained in:
@@ -3582,6 +3582,42 @@ function increateRefreshEx($type, $cnt=1, $db=NULL){
|
||||
'p_id'=>$p_id
|
||||
));
|
||||
}
|
||||
|
||||
$date = date('Y_m_d H:i:s');
|
||||
$date2 = substr($date, 0, 10);
|
||||
$online = onlinenum($connect);
|
||||
$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}";
|
||||
fwrite($fp, $msg."\n");
|
||||
fclose($fp);
|
||||
|
||||
$proxy_headers = array(
|
||||
'HTTP_VIA',
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_FORWARDED_FOR',
|
||||
'HTTP_X_FORWARDED',
|
||||
'HTTP_FORWARDED',
|
||||
'HTTP_CLIENT_IP',
|
||||
'HTTP_FORWARDED_FOR_IP',
|
||||
'VIA',
|
||||
'X_FORWARDED_FOR',
|
||||
'FORWARDED_FOR',
|
||||
'X_FORWARDED',
|
||||
'FORWARDED',
|
||||
'CLIENT_IP',
|
||||
'FORWARDED_FOR_IP',
|
||||
'HTTP_PROXY_CONNECTION'
|
||||
);
|
||||
|
||||
$str = "";
|
||||
foreach($proxy_headers as $x) {
|
||||
if(isset($_SERVER[$x])) $str .= "//{$x}:{$_SERVER[$x]}";
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+197
-86
@@ -3,6 +3,7 @@
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require_once('../e_lib/util.php');
|
||||
require_once('func_message.php');
|
||||
|
||||
|
||||
@@ -18,11 +19,13 @@ if(!isset($post['genlist']) || !isset($post['msg'])){
|
||||
}
|
||||
|
||||
|
||||
$genlist = $post['genlist'];
|
||||
$dest = $post['dest'];
|
||||
$msg = $post['msg'];
|
||||
$datetime = new DateTime();
|
||||
$date = $datetime->format('Y-m-d H:i:s');
|
||||
|
||||
//로그인 검사
|
||||
if(!CheckLoginEx()){
|
||||
if(!CheckLoginEx($db)){
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'result' => false,
|
||||
@@ -31,6 +34,9 @@ if(!CheckLoginEx()){
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
$db = newDB();
|
||||
|
||||
$connect = dbConn();
|
||||
increaseRefresh($connect, "서신전달", 1);
|
||||
|
||||
@@ -45,7 +51,7 @@ if(CheckBlock($connect) == 1 || CheckBlock($connect) == 3) {
|
||||
]));
|
||||
}
|
||||
|
||||
$db = newDB();
|
||||
|
||||
|
||||
|
||||
$conlimit = $db->queryFirstField("select conlimit from game where no=1");
|
||||
@@ -63,104 +69,209 @@ if($con >= 2) {
|
||||
]));
|
||||
}
|
||||
|
||||
//FIXME: 원래는 필요없는 값이지만 예전 코드와 꼬일 수 있어 유지함.
|
||||
$msg = str_replace("|", "", $msg);
|
||||
|
||||
//TODO: 몰라서 임시로 값 세팅해봄. 추후에 용도를 확인하고 수정 필요
|
||||
//$s = 50;
|
||||
//$msg = _String::SubStrForWidth($msg, $s, 198);
|
||||
|
||||
//SubStrForWidth는 반각은 1, 전각은 2로 측정하는듯 보이나, 대부분 글자수 단위로 카운트 하고 있어 mb_substr로 처리함.
|
||||
$msg = mb_substr($msg, 0, 99, 'UTF-8');
|
||||
$msg = trim($msg);
|
||||
|
||||
//TODO : 몰라서 임시로 값 세팅해봄. 추후에 용도를 확인하고 수정 필요
|
||||
$s = 50;
|
||||
$msg = _String::SubStrForWidth($msg, $s, 198);
|
||||
if($msg == ''){
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'result' => true,
|
||||
'reason' => 'SUCCESS',
|
||||
'redirect' => 'msglist.php',
|
||||
'page_target' => '#msglist'
|
||||
]));
|
||||
}
|
||||
|
||||
$date = date('Y-m-d H:i:s');
|
||||
$src = $me['no'];
|
||||
$src_name = $me['name'];
|
||||
$src_icon = $me['picture'];
|
||||
$src_nation_id = $me['nation'];
|
||||
if($src_nation_id == 0) {
|
||||
$src_nation = '재야';
|
||||
$src_color = '#FFFFFF';
|
||||
}
|
||||
else{
|
||||
$nation = $db->queryFirstRow("select nation,name,color from nation where nation=%d_nation",array(
|
||||
'nation' => $src_nation_id
|
||||
));
|
||||
$src_nation = $nation['name'];
|
||||
$src_color = '#'.$nation['color'];
|
||||
$src_color = str_replace('##', '#', $src_color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
||||
}
|
||||
|
||||
// 전체 메세지
|
||||
if($genlist == 9999 && str_replace(" ", "", $msg) != "") {
|
||||
//echo '<script>console.log('.$me['nation'].')</script>';
|
||||
if($me['nation'] == 0) {
|
||||
$nation['name'] = '재야';
|
||||
$nation['color'] = 'FFFFFF';
|
||||
} else {
|
||||
$query = "select nation,name,color from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
}
|
||||
PushMsg(1, 0, $me['picture'], $me['imgsvr'], "{$me['name']}:", $nation['color'], $nation['name'], $nation['color'], $msg);
|
||||
if($dest == 9999) {
|
||||
|
||||
$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
|
||||
));
|
||||
|
||||
//PushMsg(1, 0, $me['picture'], $me['imgsvr'], "{$me['name']}:", $nation['color'], $nation['name'], $nation['color'], $msg);
|
||||
// 국가 메세지
|
||||
} elseif($genlist >= 9000 && $msg != "") {
|
||||
if($me['nation'] == 0) {
|
||||
$nation['name'] = '재야';
|
||||
$nation['color'] = 'FFFFFF';
|
||||
$nation['nation'] = 0;
|
||||
} else {
|
||||
$query = "select nation,name,color from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
}
|
||||
|
||||
$genlist -= 9000;
|
||||
} elseif($dest >= 9000) {
|
||||
$real_nation = $dest - 9000;
|
||||
$query = "select nation,name,color from nation where nation='$genlist'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dest = MYDB_fetch_array($result);
|
||||
$nation = $db->queryFirstRow("select nation,name,color from nation where nation=%d_nation",array(
|
||||
'nation' => $real_nation
|
||||
));
|
||||
|
||||
//$dest가 없다는건 수신도 재야.
|
||||
if(empty($dest)){
|
||||
$dest['name'] = '재야';
|
||||
$dest['color'] = 'FFFFFF';
|
||||
$dest['nation'] = 0;
|
||||
if($nation === NULL || empty($nation)){
|
||||
$dest = 9998;
|
||||
$dest_nation = '재야';
|
||||
$dest_color = '#FFFFFF';
|
||||
}
|
||||
else{
|
||||
$dest_nation = $nation['name'];
|
||||
$dest_color = '#'.$nation['color'];
|
||||
$dest_color = str_replace('##', '#', $dest_color); //FIXME: nation table에서 color가 #포함된 걸로 바뀔 경우를 대비
|
||||
}
|
||||
|
||||
if($nation['nation'] == $dest['nation']) {
|
||||
PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:", $nation['color'], $dest['name'], $dest['color'], $msg);
|
||||
} else {
|
||||
//타국에 보내는 경우
|
||||
PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], $msg);
|
||||
// 수뇌이면 발송, 아니면 자국으로 돌림
|
||||
if($me['level'] >= 5) {
|
||||
PushMsg(3, $dest['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], $msg);
|
||||
} else {
|
||||
PushMsg(2, $nation['nation'], $me['picture'], $me['imgsvr'], "{$me['name']}:{$nation['name']}▶", $nation['color'], $dest['name'], $dest['color'], "반송");
|
||||
}
|
||||
|
||||
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($genlist > 0 && $msg != "") {
|
||||
$query = "select name,msgindex from general where no='$genlist'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
//발신, 수신인 코딩
|
||||
$who = $me['no'] * 10000 + $genlist;
|
||||
} elseif($dest > 0) {
|
||||
$last_msg = new DateTime(util::array_get($_SESSION['last_msg'], '0000-00-00'));
|
||||
|
||||
$msg = addslashes(SQ2DQ($msg));
|
||||
|
||||
$query = "select msg{$me['msgindex']}_when as priv_when from general where no='{$me['no']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$prev_msg = MYDB_fetch_array($result);
|
||||
$diff_second = strtotime($date) - strtotime($prev_msg['priv_when']);
|
||||
|
||||
if($diff_second < 3) {
|
||||
$who = 1 * 10000 + $me['no']; // 운영자가 본인에게
|
||||
$msg = "개인메세지는 3초당 1건만 보낼 수 있습니다!";
|
||||
//자신에게 표시
|
||||
$me['msgindex']++;
|
||||
if($me['msgindex'] >= 10) { $me['msgindex'] = 0; }
|
||||
$query = "update general set msgindex='{$me['msgindex']}',msg{$me['msgindex']}='$msg',msg{$me['msgindex']}_type='10',msg{$me['msgindex']}_who='$who',msg{$me['msgindex']}_when='$date',newmsg=1 where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
//자신에게 표시
|
||||
$me['msgindex']++;
|
||||
if($me['msgindex'] >= 10) { $me['msgindex'] = 0; }
|
||||
$query = "update general set msgindex='{$me['msgindex']}',msg{$me['msgindex']}='$msg',msg{$me['msgindex']}_type='9',msg{$me['msgindex']}_who='$who',msg{$me['msgindex']}_when='$date' where no='{$me['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
|
||||
// 상대에게 발송
|
||||
$you['msgindex']++;
|
||||
if($you['msgindex'] >= 10) { $you['msgindex'] = 0; }
|
||||
$query = "update general set msgindex='{$you['msgindex']}',msg{$you['msgindex']}='$msg',msg{$you['msgindex']}_type='10',msg{$you['msgindex']}_who='$who',msg{$you['msgindex']}_when='$date',newmsg=1 where no='$genlist'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$msg_interval = $datetime->getTimestamp() - $last_msg->getTimestamp();
|
||||
if($msg_interval < 2){
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'result' => false,
|
||||
'reason' => "개인메세지는 2초당 1건만 보낼 수 있습니다!",
|
||||
'redirect' => NULL
|
||||
]));
|
||||
}
|
||||
|
||||
$fp = fopen("logs/_gen_msg.txt", "a");
|
||||
//로그 파일에 기록
|
||||
fwrite($fp, _String::Fill($me['name'],12," ")." > "._String::Fill($you['name'],12," ")." | {$msg}\n");
|
||||
fclose($fp);
|
||||
|
||||
$_SESSION['last_msg'] = $date;
|
||||
|
||||
$dest_user = $db->queryFirstRow('select `no`,`name`,`nation` from `general` where `user_id` = %s_p_id',array(
|
||||
'p_id'=>$dest));
|
||||
|
||||
if($dest_user == NULL || empty($dest_user)){
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'result' => false,
|
||||
'reason' => '존재하지 않는 유저입니다.',
|
||||
'redirect' => NULL
|
||||
]));
|
||||
}
|
||||
|
||||
$dest_name = $dest_user['name'];
|
||||
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=%d_nation",array(
|
||||
'nation' => $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(
|
||||
'address' => $src_nation_id + 9000,
|
||||
'type' => 'send',
|
||||
'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
|
||||
));
|
||||
$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{
|
||||
header('Content-Type: application/json');
|
||||
die(json_encode([
|
||||
'result' => false,
|
||||
'reason' => "알 수 없는 에러",
|
||||
'redirect' => NULL
|
||||
]));
|
||||
}
|
||||
|
||||
//echo "<script>location.replace('msglist.php');</script>";
|
||||
|
||||
Reference in New Issue
Block a user