conf에 return hint 추가
메시지 전송 준비
This commit is contained in:
@@ -4,6 +4,11 @@ require_once(__dir__.'/../e_lib/meekrodb.2.3.class.php.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.phpmailer.php');
|
||||
require_once(__dir__.'/../e_lib/phpmailer5/class.smtp.php');
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return MeekroDB
|
||||
*/
|
||||
function newRootDB(){
|
||||
$host = '_host_';
|
||||
$user = '_user_';
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
require_once(__dir__.'/../../d_setting/conf.php');
|
||||
|
||||
/**
|
||||
* DB 객체 생성
|
||||
*
|
||||
* @return MeekroDB
|
||||
*/
|
||||
function newDB(){
|
||||
$host = '_host_';
|
||||
$user = '_user_';
|
||||
|
||||
+3
-300
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
require_once(__dir__.'/../e_lib/util.php');
|
||||
include "process_war.php";
|
||||
include "func_process.php";
|
||||
include "func_npc.php";
|
||||
@@ -6,7 +8,7 @@ include "func_tournament.php";
|
||||
include "func_auction.php";
|
||||
include "func_string.php";
|
||||
include "func_history.php";
|
||||
|
||||
require_once("func_message.php");
|
||||
// 37.5 ~ 75
|
||||
function abilityRand() {
|
||||
$total = 150;
|
||||
@@ -3221,216 +3223,6 @@ function nationMsg($connect) {
|
||||
echo "<font color="; echo $me['skin']>0?"orange":"white"; echo ">".$nation['msg']."</font>";
|
||||
}
|
||||
|
||||
function genList($connect) {
|
||||
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
$you = array();
|
||||
|
||||
$query = "select msg{$me['msgindex']}_who as reply,msg{$me['msgindex']}_type as type from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$reply = MYDB_fetch_array($result);
|
||||
if($reply['type'] % 100 == 9) {
|
||||
$reply['reply'] %= 10000;
|
||||
$query = "select no,name from general where no={$reply['reply']}";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
} elseif($reply['type'] % 100 == 10) {
|
||||
$reply['reply'] = floor($reply['reply']/10000);
|
||||
$query = "select no,name from general where no={$reply['reply']}";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
}
|
||||
|
||||
$query = "select nation,color,name from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
echo "
|
||||
<select name=genlist size=1 style=color:white;background-color:black;font-size:13>
|
||||
<optgroup label='즐겨찾기'>";
|
||||
if($me['nation'] != 0) {
|
||||
echo "
|
||||
<option selected style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo $nation['nation']+9000; echo ">【 아국 메세지 】</option>";
|
||||
} else {
|
||||
echo "
|
||||
<option selected style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo 9000; echo ">【 재야 】</option>";
|
||||
}
|
||||
echo "
|
||||
<option value=9999>【 전체 메세지 】</option>";
|
||||
if($you) {
|
||||
echo "
|
||||
<option value={$you['no']}>{$you['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
<option value=1>운영자</option>";
|
||||
|
||||
if($me['level'] >= 5 || $me['userlevel'] >= 5) {
|
||||
echo "
|
||||
</optgroup>
|
||||
<optgroup label='국가메세지'>
|
||||
<option value=9000>【 재야 】</option>";
|
||||
|
||||
$query = "select nation,name,color from nation order by binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$count = MYDB_num_rows($result);
|
||||
for($i=1; $i <= $count; $i++) {
|
||||
$nation = MYDB_fetch_array($result);
|
||||
$nationNation[$nation['nation']] = $nation['nation'];
|
||||
$nationName[$nation['nation']] = $nation['name'];
|
||||
$nationColor[$nation['nation']] = $nation['color'];
|
||||
echo "
|
||||
<option style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo $nation['nation']+9000; echo ">【 {$nation['name']} 】</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
}
|
||||
|
||||
echo "
|
||||
<optgroup label='개인메세지'>
|
||||
<optgroup label='재야'>";
|
||||
$query = "select no,name,npc from general where nation=0 and user_id!='{$_SESSION['p_id']}' and npc<2 order by npc,binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
for($i=0; $i < $gencount; $i++) {
|
||||
$general = MYDB_fetch_array($result);
|
||||
if($general['npc'] >= 2) { $color = "cyan"; }
|
||||
elseif($general['npc'] == 1) { $color = "skyblue"; }
|
||||
else { $color = "white"; }
|
||||
echo "
|
||||
<option value={$general['no']} style=color:{$color};background-color:black;>{$general['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
|
||||
$query = "select nation,name,color from nation order by binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$count = MYDB_num_rows($result);
|
||||
for($i=1; $i <= $count; $i++) {
|
||||
$nation = MYDB_fetch_array($result);
|
||||
echo "
|
||||
<optgroup label='【{$nation['name']}】' style=color:".newColor($nation['color']).";background-color:{$nation['color']};>";
|
||||
|
||||
$query = "select no,name,npc,level from general where nation='{$nation['nation']}' and user_id!='{$_SESSION['p_id']}' and npc<2 order by npc,binary(name)";
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($genresult);
|
||||
for($j=0; $j < $gencount; $j++) {
|
||||
$general = MYDB_fetch_array($genresult);
|
||||
if($general['level'] >= 12) { $general['name'] = "*{$general['name']}*"; }
|
||||
if($general['npc'] >= 2) { $color = "cyan"; }
|
||||
elseif($general['npc'] == 1) { $color = "skyblue"; }
|
||||
else { $color = "white"; }
|
||||
echo "
|
||||
<option value={$general['no']} style=color:{$color};background-color:black;>{$general['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
";
|
||||
}
|
||||
|
||||
function moveMsg($connect, $table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $value) {
|
||||
$query = "update {$table} set {$msgtype}{$msgnum}='$msg',{$msgtype}{$msgnum}_type='$type',{$msgtype}{$msgnum}_who='$who',{$msgtype}{$msgnum}_when='$when' where {$column}='$value'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
function MsgMe($connect, $bg) {
|
||||
$query = "select no,nation,msgindex,
|
||||
msg0,msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,
|
||||
msg0_type,msg1_type,msg2_type,msg3_type,msg4_type,msg5_type,msg6_type,msg7_type,msg8_type,msg9_type,
|
||||
msg0_who,msg1_who,msg2_who,msg3_who,msg4_who,msg5_who,msg6_who,msg7_who,msg8_who,msg9_who,
|
||||
msg0_when,msg1_when,msg2_when,msg3_when,msg4_when,msg5_when,msg6_when,msg7_when,msg8_when,msg9_when
|
||||
from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$index = $me['msgindex'];
|
||||
for($i=0; $i < 10; $i++) {
|
||||
if($me["msg{$index}"]) { echo "\n"; DecodeMsg($connect, $me["msg{$index}"], $me["msg{$index}_type"], $me["msg{$index}_who"], $me["msg{$index}_when"], $bg, $index); }
|
||||
$index--;
|
||||
if($index < 0) { $index = 9; }
|
||||
}
|
||||
}
|
||||
|
||||
function MsgDip($connect, $bg) {
|
||||
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select dip0,dip1,dip2,dip3,dip4,dip0_who,dip1_who,dip2_who,dip3_who,dip4_who,dip0_when,dip1_when,dip2_when,dip3_when,dip4_when,dip0_type,dip1_type,dip2_type,dip3_type,dip4_type from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
if($nation['dip0']) { echo "\n"; DecodeMsg($connect, $nation['dip0'], $nation['dip0_type'], $nation['dip0_who'], $nation['dip0_when'], $bg, 0); }
|
||||
if($nation['dip1']) { echo "\n"; DecodeMsg($connect, $nation['dip1'], $nation['dip1_type'], $nation['dip1_who'], $nation['dip1_when'], $bg, 1); }
|
||||
if($nation['dip2']) { echo "\n"; DecodeMsg($connect, $nation['dip2'], $nation['dip2_type'], $nation['dip2_who'], $nation['dip2_when'], $bg, 2); }
|
||||
if($nation['dip3']) { echo "\n"; DecodeMsg($connect, $nation['dip3'], $nation['dip3_type'], $nation['dip3_who'], $nation['dip3_when'], $bg, 3); }
|
||||
if($nation['dip4']) { echo "\n"; DecodeMsg($connect, $nation['dip4'], $nation['dip4_type'], $nation['dip4_who'], $nation['dip4_when'], $bg, 4); }
|
||||
}
|
||||
|
||||
// type : xx,xx(불가침기간,타입)
|
||||
// who : xxxx,xxxx(발신인, 수신인)
|
||||
function DecodeMsg($connect, $msg, $type, $who, $date, $bg, $num=0) {
|
||||
$query = "select skin,no,nation,name,picture,level from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
// 1 : 전메, 2 : 아국->타국, 3 : 타국->아국
|
||||
// 4 : 합병, 5 : 통합, 6 : 불가침, 7 : 종전, 8 : 파기
|
||||
// 9 : 자신->타인, 10 : 타인 -> 자신, 11 : 등용
|
||||
$category = $type % 100;
|
||||
$term = floor($type / 100);
|
||||
$from = floor($who / 10000);
|
||||
$to = $who % 10000;
|
||||
|
||||
$query = "select name,picture,imgsvr,nation from general where no='$from'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$sndr = MYDB_fetch_array($result);
|
||||
|
||||
if($sndr['nation'] == 0) {
|
||||
$sndrnation['name'] = '재야';
|
||||
$sndrnation['color'] = 'FFFFFF';
|
||||
} else {
|
||||
$query = "select name,color from nation where nation='{$sndr['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$sndrnation = MYDB_fetch_array($result);
|
||||
}
|
||||
|
||||
switch($bg) {
|
||||
case 2:
|
||||
case 4: $bgcolor = "CC6600"; break;
|
||||
}
|
||||
|
||||
if($category == 6) {
|
||||
$query = "select reserved from diplomacy where me='{$sndr['nation']}' and you='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $sndr['name'], $sndrnation['color'], $msg, $date, $num, $from, $term, $me['level'], $dip['reserved']);
|
||||
} elseif($category <= 8) {
|
||||
$query = "select name,color from nation where nation='$to'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvrnation = MYDB_fetch_array($result);
|
||||
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $rcvrnation['name'], $rcvrnation['color'], $msg, $date, $num, $from, $term, $me['level']);
|
||||
} elseif($category <= 11) {
|
||||
$query = "select name,picture,nation from general where no='$to'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvr = MYDB_fetch_array($result);
|
||||
|
||||
if($rcvr['nation'] == 0) {
|
||||
$rcvrnation['name'] = '재야';
|
||||
$rcvrnation['color'] = 'FFFFFF';
|
||||
} else {
|
||||
$query = "select name,color from nation where nation='{$rcvr['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvrnation = MYDB_fetch_array($result);
|
||||
}
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], "{$rcvr['name']}:{$rcvrnation['name']}", $rcvrnation['color'], $msg, $date, $num, $from, $term);
|
||||
}
|
||||
}
|
||||
|
||||
function PushMsg($type, $nation, $picture, $imgsvr, $from, $fromcolor, $to, $tocolor, $msg) {
|
||||
if($nation == 0) { $nation = 0; }
|
||||
@@ -3448,95 +3240,6 @@ function PushMsg($type, $nation, $picture, $imgsvr, $from, $fromcolor, $to, $toc
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function MsgFile($skin, $bg, $nation=0, $level=0) {
|
||||
switch($bg) {
|
||||
case 1: $bgcolor = "000055"; $count = 10; $fl = "_all_msg.txt"; break;
|
||||
case 3: $bgcolor = "336600"; $count = 20; $fl = "_nation_msg{$nation}.txt"; break;
|
||||
}
|
||||
|
||||
if(!file_exists("logs/{$fl}")){
|
||||
return;
|
||||
}
|
||||
$fp = @fopen("logs/{$fl}", "r");
|
||||
@fseek($fp, -$count*300, SEEK_END);
|
||||
$file = @fread($fp, $count*300);
|
||||
@fclose($fp);
|
||||
$code = explode("\r\n",$file);
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$msg = isset($code[count($code)-2-$i]) ? explode("|", $code[count($code)-2-$i]) : array();
|
||||
|
||||
$cnt = count($msg);
|
||||
if(!empty($cnt)){
|
||||
for($k=0; $k < $cnt; $k++) {
|
||||
$msg[$k] = trim($msg[$k]);
|
||||
}
|
||||
}
|
||||
if(!empty($msg)){
|
||||
ShowMsg($skin, $bgcolor, $msg[0], $msg[7], $msg[8], $msg[1], $msg[5], $msg[2], $msg[6], $msg[4], $msg[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ShowMsg($skin, $bgcolor, $type, $picture, $imgsvr, $me, $mycolor, $you, $youcolor, $msg, $date, $num=0, $who=0, $when=0, $level=0, $note="") {
|
||||
if($msg == "") return;
|
||||
|
||||
$msg = Tag2Code($msg);
|
||||
|
||||
$site = ""; $form = ""; $form2 = "";
|
||||
if($type == 11 || ($type >= 4 && $type <= 8 && $level >= 5)) {
|
||||
$corebutton = " <input type=submit name=ok value=수락 onclick='return confirm(\"정말 수락하시겠습니까?\")'><input type=submit name=ok value=거절 onclick='return confirm(\"정말 거절하시겠습니까?\")'>";
|
||||
} else {
|
||||
$corebutton = " 【수락】【거절】";
|
||||
}
|
||||
if($type == 6) {
|
||||
$corebutton .= "<br>비고: {$note}";
|
||||
}
|
||||
switch($type) {
|
||||
case 1: $sign = ""; $corebutton = ""; break;
|
||||
case 2: $sign = ""; $corebutton = ""; break;
|
||||
case 3: $sign = ""; $corebutton = ""; break;
|
||||
case 4: $sign = ""; $site = "d_surrender.php"; break;
|
||||
case 5: $sign = ""; $site = "d_merge.php"; break;
|
||||
case 6: $sign = ""; $site = "d_ally.php"; break;
|
||||
case 7: $sign = ""; $site = "d_cease.php"; break;
|
||||
case 8: $sign = ""; $site = "d_cancel.php"; break;
|
||||
case 9: $sign = ""; $corebutton = ""; break;
|
||||
case 10: $sign = ""; $corebutton = ""; break;
|
||||
case 11: $sign = ""; $site = "d_scout.php"; break;
|
||||
}
|
||||
if($skin == 0) {
|
||||
$bgcolor = "000000"; $picture = "";
|
||||
$naming = "[{$me}{$sign}{$you}]";
|
||||
} else {
|
||||
$imageTemp = GetImageURL($imgsvr);
|
||||
$naming = "[<font color=$mycolor>$me</font>{$sign}<font color=$youcolor>$you</font>]";
|
||||
$picture = "<img src={$imageTemp}/{$picture}>";
|
||||
}
|
||||
if($site != "") {
|
||||
$form = "<form name=scout method=post action={$site}>";
|
||||
$form2 = "</form>";
|
||||
}
|
||||
if($num >= 0) { $num = "<input type=hidden name=num value=$num>"; }
|
||||
else { $num = ""; }
|
||||
if($who > 0) { $who = "<input type=hidden name=gen value=$who>"; }
|
||||
else { $who = ""; }
|
||||
if($when > 0) { $when = "<input type=hidden name=when value=$when>"; }
|
||||
else { $when = ""; }
|
||||
echo "
|
||||
<table width=498 border=1 bordercolordark=gray bordercolorlight=black cellpadding=0 cellspacing=0 bgcolor='$bgcolor' style=font-size:13;table-layout:fixed;word-break:break-all;>
|
||||
<tr>
|
||||
<td width=64 height=64>$picture</td>
|
||||
$form
|
||||
<td width=434 valign=top><b>$naming</b><font size=1><$date></font> <br>{$msg}{$corebutton}</td>
|
||||
$num
|
||||
$who
|
||||
$when
|
||||
$form2
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
}
|
||||
|
||||
function msgprint($connect, $msg, $name, $picture, $imgsvr, $when, $num, $type) {
|
||||
global $_basecolor2, $_basecolor4, $images;
|
||||
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
require_once(__dir__.'/../e_lib/util.php');
|
||||
|
||||
class Message{
|
||||
//기본 정보
|
||||
public $id;
|
||||
public $address;
|
||||
public $type;
|
||||
public $src;
|
||||
public $dest;
|
||||
public $time;
|
||||
public $message;
|
||||
|
||||
//부가 정보
|
||||
public $src_name;
|
||||
public $src_nation;
|
||||
public $src_color;
|
||||
public $src_icon;
|
||||
public $dest_name;
|
||||
public $dest_nation;
|
||||
public $dest_color;
|
||||
|
||||
public $bg_color;
|
||||
|
||||
function __construct($row){
|
||||
$this->id = $row['id'];
|
||||
$this->address = $row['address'];
|
||||
$this->type = $row['type'];
|
||||
$this->src = $row['src'];
|
||||
$this->dest = $row['dest'];
|
||||
$this->time = $row['time'];
|
||||
$this->message = $row['message'];
|
||||
|
||||
$this->src_name = $row['src_name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getRawMessage($address, $limit=30, $fromTime=NULL){
|
||||
//'select * from `message` where `address` = 90 and `time` < "2018-01-21 04:47:20" ORDER BY `time` desc LIMIT 3 ';
|
||||
|
||||
|
||||
$sql = 'select * from `message` where `address` = %d_address';
|
||||
if($fromTime !== NULL){
|
||||
$sql .= ' and `time` <= %s_time';
|
||||
}
|
||||
$sql .= ' ORDER BY `time` desc';
|
||||
if($limit > 0){
|
||||
$sql .= ' LIMIT %d_limit';
|
||||
}
|
||||
|
||||
|
||||
$db = newDB();
|
||||
//TODO: table 네임의 prefix를 처리할 수 있도록 개선
|
||||
$result = $db->query($sql, array(
|
||||
'address' => $address,
|
||||
'limit' => $limit,
|
||||
'time' => $fromTime
|
||||
));
|
||||
|
||||
|
||||
return array_map(function ($row){
|
||||
return new Message($row);
|
||||
}, $result);
|
||||
}
|
||||
|
||||
function getMessage(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
function genList($connect) {
|
||||
$query = "select no,nation,level,msgindex,userlevel from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
$you = array();
|
||||
|
||||
$query = "select msg{$me['msgindex']}_who as reply,msg{$me['msgindex']}_type as type from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$reply = MYDB_fetch_array($result);
|
||||
if($reply['type'] % 100 == 9) {
|
||||
$reply['reply'] %= 10000;
|
||||
$query = "select no,name from general where no={$reply['reply']}";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
} elseif($reply['type'] % 100 == 10) {
|
||||
$reply['reply'] = floor($reply['reply']/10000);
|
||||
$query = "select no,name from general where no={$reply['reply']}";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$you = MYDB_fetch_array($result);
|
||||
}
|
||||
|
||||
$query = "select nation,color,name from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
echo "
|
||||
<select name=genlist size=1 style=color:white;background-color:black;font-size:13>
|
||||
<optgroup label='즐겨찾기'>";
|
||||
if($me['nation'] != 0) {
|
||||
echo "
|
||||
<option selected style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo $nation['nation']+9000; echo ">【 아국 메세지 】</option>";
|
||||
} else {
|
||||
echo "
|
||||
<option selected style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo 9000; echo ">【 재야 】</option>";
|
||||
}
|
||||
echo "
|
||||
<option value=9999>【 전체 메세지 】</option>";
|
||||
if($you) {
|
||||
echo "
|
||||
<option value={$you['no']}>{$you['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
<option value=1>운영자</option>";
|
||||
|
||||
if($me['level'] >= 5 || $me['userlevel'] >= 5) {
|
||||
echo "
|
||||
</optgroup>
|
||||
<optgroup label='국가메세지'>
|
||||
<option value=9000>【 재야 】</option>";
|
||||
|
||||
$query = "select nation,name,color from nation order by binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$count = MYDB_num_rows($result);
|
||||
for($i=1; $i <= $count; $i++) {
|
||||
$nation = MYDB_fetch_array($result);
|
||||
$nationNation[$nation['nation']] = $nation['nation'];
|
||||
$nationName[$nation['nation']] = $nation['name'];
|
||||
$nationColor[$nation['nation']] = $nation['color'];
|
||||
echo "
|
||||
<option style=color:".newColor($nation['color']).";background-color:{$nation['color']} value="; echo $nation['nation']+9000; echo ">【 {$nation['name']} 】</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
}
|
||||
|
||||
echo "
|
||||
<optgroup label='개인메세지'>
|
||||
<optgroup label='재야'>";
|
||||
$query = "select no,name,npc from general where nation=0 and user_id!='{$_SESSION['p_id']}' and npc<2 order by npc,binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($result);
|
||||
for($i=0; $i < $gencount; $i++) {
|
||||
$general = MYDB_fetch_array($result);
|
||||
if($general['npc'] >= 2) { $color = "cyan"; }
|
||||
elseif($general['npc'] == 1) { $color = "skyblue"; }
|
||||
else { $color = "white"; }
|
||||
echo "
|
||||
<option value={$general['no']} style=color:{$color};background-color:black;>{$general['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
|
||||
$query = "select nation,name,color from nation order by binary(name)";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$count = MYDB_num_rows($result);
|
||||
for($i=1; $i <= $count; $i++) {
|
||||
$nation = MYDB_fetch_array($result);
|
||||
echo "
|
||||
<optgroup label='【{$nation['name']}】' style=color:".newColor($nation['color']).";background-color:{$nation['color']};>";
|
||||
|
||||
$query = "select no,name,npc,level from general where nation='{$nation['nation']}' and user_id!='{$_SESSION['p_id']}' and npc<2 order by npc,binary(name)";
|
||||
$genresult = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$gencount = MYDB_num_rows($genresult);
|
||||
for($j=0; $j < $gencount; $j++) {
|
||||
$general = MYDB_fetch_array($genresult);
|
||||
if($general['level'] >= 12) { $general['name'] = "*{$general['name']}*"; }
|
||||
if($general['npc'] >= 2) { $color = "cyan"; }
|
||||
elseif($general['npc'] == 1) { $color = "skyblue"; }
|
||||
else { $color = "white"; }
|
||||
echo "
|
||||
<option value={$general['no']} style=color:{$color};background-color:black;>{$general['name']}</option>";
|
||||
}
|
||||
echo "
|
||||
</optgroup>";
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
function MsgFile($skin, $bg, $nation=0, $level=0) {
|
||||
switch($bg) {
|
||||
case 1: $bgcolor = "000055"; $count = 10; $fl = "_all_msg.txt"; break;
|
||||
case 3: $bgcolor = "336600"; $count = 20; $fl = "_nation_msg{$nation}.txt"; break;
|
||||
}
|
||||
|
||||
if(!file_exists("logs/{$fl}")){
|
||||
return;
|
||||
}
|
||||
$fp = @fopen("logs/{$fl}", "r");
|
||||
@fseek($fp, -$count*300, SEEK_END);
|
||||
$file = @fread($fp, $count*300);
|
||||
@fclose($fp);
|
||||
$code = explode("\r\n",$file);
|
||||
for($i=0; $i < $count; $i++) {
|
||||
$msg = isset($code[count($code)-2-$i]) ? explode("|", $code[count($code)-2-$i]) : array();
|
||||
|
||||
$cnt = count($msg);
|
||||
if(!empty($cnt)){
|
||||
for($k=0; $k < $cnt; $k++) {
|
||||
$msg[$k] = trim($msg[$k]);
|
||||
}
|
||||
}
|
||||
if(!empty($msg)){
|
||||
ShowMsg($skin, $bgcolor, $msg[0], $msg[7], $msg[8], $msg[1], $msg[5], $msg[2], $msg[6], $msg[4], $msg[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// type : xx,xx(불가침기간,타입)
|
||||
// who : xxxx,xxxx(발신인, 수신인)
|
||||
function DecodeMsg($connect, $msg, $type, $who, $date, $bg, $num=0) {
|
||||
$query = "select skin,no,nation,name,picture,level from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
// 1 : 전메, 2 : 아국->타국, 3 : 타국->아국
|
||||
// 4 : 합병, 5 : 통합, 6 : 불가침, 7 : 종전, 8 : 파기
|
||||
// 9 : 자신->타인, 10 : 타인 -> 자신, 11 : 등용
|
||||
$category = $type % 100;
|
||||
$term = floor($type / 100);
|
||||
$from = floor($who / 10000);
|
||||
$to = $who % 10000;
|
||||
|
||||
$query = "select name,picture,imgsvr,nation from general where no='$from'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$sndr = MYDB_fetch_array($result);
|
||||
|
||||
if($sndr['nation'] == 0) {
|
||||
$sndrnation['name'] = '재야';
|
||||
$sndrnation['color'] = 'FFFFFF';
|
||||
} else {
|
||||
$query = "select name,color from nation where nation='{$sndr['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$sndrnation = MYDB_fetch_array($result);
|
||||
}
|
||||
|
||||
switch($bg) {
|
||||
case 2:
|
||||
case 4: $bgcolor = "CC6600"; break;
|
||||
}
|
||||
|
||||
if($category == 6) {
|
||||
$query = "select reserved from diplomacy where me='{$sndr['nation']}' and you='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$dip = MYDB_fetch_array($result);
|
||||
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $sndr['name'], $sndrnation['color'], $msg, $date, $num, $from, $term, $me['level'], $dip['reserved']);
|
||||
} elseif($category <= 8) {
|
||||
$query = "select name,color from nation where nation='$to'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvrnation = MYDB_fetch_array($result);
|
||||
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], $rcvrnation['name'], $rcvrnation['color'], $msg, $date, $num, $from, $term, $me['level']);
|
||||
} elseif($category <= 11) {
|
||||
$query = "select name,picture,nation from general where no='$to'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvr = MYDB_fetch_array($result);
|
||||
|
||||
if($rcvr['nation'] == 0) {
|
||||
$rcvrnation['name'] = '재야';
|
||||
$rcvrnation['color'] = 'FFFFFF';
|
||||
} else {
|
||||
$query = "select name,color from nation where nation='{$rcvr['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$rcvrnation = MYDB_fetch_array($result);
|
||||
}
|
||||
ShowMsg($me['skin'], $bgcolor, $category, $sndr['picture'], $sndr['imgsvr'], "{$sndr['name']}:{$sndrnation['name']}▶", $sndrnation['color'], "{$rcvr['name']}:{$rcvrnation['name']}", $rcvrnation['color'], $msg, $date, $num, $from, $term);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function MsgMe($connect, $bg) {
|
||||
$query = "select no,nation,msgindex,
|
||||
msg0,msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9,
|
||||
msg0_type,msg1_type,msg2_type,msg3_type,msg4_type,msg5_type,msg6_type,msg7_type,msg8_type,msg9_type,
|
||||
msg0_who,msg1_who,msg2_who,msg3_who,msg4_who,msg5_who,msg6_who,msg7_who,msg8_who,msg9_who,
|
||||
msg0_when,msg1_when,msg2_when,msg3_when,msg4_when,msg5_when,msg6_when,msg7_when,msg8_when,msg9_when
|
||||
from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$index = $me['msgindex'];
|
||||
for($i=0; $i < 10; $i++) {
|
||||
if($me["msg{$index}"]) { echo "\n"; DecodeMsg($connect, $me["msg{$index}"], $me["msg{$index}_type"], $me["msg{$index}_who"], $me["msg{$index}_when"], $bg, $index); }
|
||||
$index--;
|
||||
if($index < 0) { $index = 9; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function moveMsg($connect, $table, $msgtype, $msgnum, $msg, $type, $who, $when, $column, $value) {
|
||||
//TODO: moveMsg 쓰는 곳 모두 고쳐!!!
|
||||
$query = "update {$table} set {$msgtype}{$msgnum}='$msg',{$msgtype}{$msgnum}_type='$type',{$msgtype}{$msgnum}_who='$who',{$msgtype}{$msgnum}_when='$when' where {$column}='$value'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
}
|
||||
|
||||
function MsgDip($connect, $bg) {
|
||||
$query = "select no,nation from general where user_id='{$_SESSION['p_id']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$me = MYDB_fetch_array($result);
|
||||
|
||||
$query = "select dip0,dip1,dip2,dip3,dip4,dip0_who,dip1_who,dip2_who,dip3_who,dip4_who,dip0_when,dip1_when,dip2_when,dip3_when,dip4_when,dip0_type,dip1_type,dip2_type,dip3_type,dip4_type from nation where nation='{$me['nation']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$nation = MYDB_fetch_array($result);
|
||||
|
||||
if($nation['dip0']) { echo "\n"; DecodeMsg($connect, $nation['dip0'], $nation['dip0_type'], $nation['dip0_who'], $nation['dip0_when'], $bg, 0); }
|
||||
if($nation['dip1']) { echo "\n"; DecodeMsg($connect, $nation['dip1'], $nation['dip1_type'], $nation['dip1_who'], $nation['dip1_when'], $bg, 1); }
|
||||
if($nation['dip2']) { echo "\n"; DecodeMsg($connect, $nation['dip2'], $nation['dip2_type'], $nation['dip2_who'], $nation['dip2_when'], $bg, 2); }
|
||||
if($nation['dip3']) { echo "\n"; DecodeMsg($connect, $nation['dip3'], $nation['dip3_type'], $nation['dip3_who'], $nation['dip3_when'], $bg, 3); }
|
||||
if($nation['dip4']) { echo "\n"; DecodeMsg($connect, $nation['dip4'], $nation['dip4_type'], $nation['dip4_who'], $nation['dip4_when'], $bg, 4); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ShowMsg($skin, $bgcolor, $type, $picture, $imgsvr, $me, $mycolor, $you, $youcolor, $msg, $date, $num=0, $who=0, $when=0, $level=0, $note="") {
|
||||
if($msg == "") return;
|
||||
|
||||
$msg = Tag2Code($msg);
|
||||
|
||||
$site = ""; $form = ""; $form2 = "";
|
||||
if($type == 11 || ($type >= 4 && $type <= 8 && $level >= 5)) {
|
||||
$corebutton = " <input type=submit name=ok value=수락 onclick='return confirm(\"정말 수락하시겠습니까?\")'><input type=submit name=ok value=거절 onclick='return confirm(\"정말 거절하시겠습니까?\")'>";
|
||||
} else {
|
||||
$corebutton = " 【수락】【거절】";
|
||||
}
|
||||
if($type == 6) {
|
||||
$corebutton .= "<br>비고: {$note}";
|
||||
}
|
||||
switch($type) {
|
||||
case 1: $sign = ""; $corebutton = ""; break;
|
||||
case 2: $sign = ""; $corebutton = ""; break;
|
||||
case 3: $sign = ""; $corebutton = ""; break;
|
||||
case 4: $sign = ""; $site = "d_surrender.php"; break;
|
||||
case 5: $sign = ""; $site = "d_merge.php"; break;
|
||||
case 6: $sign = ""; $site = "d_ally.php"; break;
|
||||
case 7: $sign = ""; $site = "d_cease.php"; break;
|
||||
case 8: $sign = ""; $site = "d_cancel.php"; break;
|
||||
case 9: $sign = ""; $corebutton = ""; break;
|
||||
case 10: $sign = ""; $corebutton = ""; break;
|
||||
case 11: $sign = ""; $site = "d_scout.php"; break;
|
||||
}
|
||||
if($skin == 0) {
|
||||
$bgcolor = "000000"; $picture = "";
|
||||
$naming = "[{$me}{$sign}{$you}]";
|
||||
} else {
|
||||
$imageTemp = GetImageURL($imgsvr);
|
||||
$naming = "[<font color=$mycolor>$me</font>{$sign}<font color=$youcolor>$you</font>]";
|
||||
$picture = "<img src={$imageTemp}/{$picture}>";
|
||||
}
|
||||
if($site != "") {
|
||||
$form = "<form name=scout method=post action={$site}>";
|
||||
$form2 = "</form>";
|
||||
}
|
||||
if($num >= 0) { $num = "<input type=hidden name=num value=$num>"; }
|
||||
else { $num = ""; }
|
||||
if($who > 0) { $who = "<input type=hidden name=gen value=$who>"; }
|
||||
else { $who = ""; }
|
||||
if($when > 0) { $when = "<input type=hidden name=when value=$when>"; }
|
||||
else { $when = ""; }
|
||||
echo "
|
||||
<table width=498 border=1 bordercolordark=gray bordercolorlight=black cellpadding=0 cellspacing=0 bgcolor='$bgcolor' style=font-size:13;table-layout:fixed;word-break:break-all;>
|
||||
<tr>
|
||||
<td width=64 height=64>$picture</td>
|
||||
$form
|
||||
<td width=434 valign=top><b>$naming</b><font size=1><$date></font> <br>{$msg}{$corebutton}</td>
|
||||
$num
|
||||
$who
|
||||
$when
|
||||
$form2
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
//TODO: main.php에서 보낼 대상을 선택할 때 데이터를 받아오도록 처리
|
||||
+60
@@ -15,6 +15,7 @@ ini_set("session.gc_maxlifetime", 604800); // seconds
|
||||
ob_start();
|
||||
|
||||
include "MYDB.php";
|
||||
require_once(__dir__.'/d_setting/conf.php');
|
||||
|
||||
// 각종 변수
|
||||
define('STEP_LOG', true);
|
||||
@@ -115,6 +116,7 @@ echo $_SERVER['PHP_SELF'].'//'.preg_match("/install/i",$_SERVER['PHP_SELF']);
|
||||
|
||||
// MySQL 데이타 베이스에 접근
|
||||
function dbconn($table = "") {
|
||||
//TODO:dbconn 사용하는 모든 녀석들을 없애야한다.
|
||||
global $connect, $HTTP_COOKIE_VARS;
|
||||
$f = @file("d_setting/set.php") or Error("set.php파일이 없습니다. DB설정을 먼저 하십시요!");
|
||||
for($i=1; $i<= 4; $i++) $f[$i] = trim(str_replace("\n","",$f[$i]));
|
||||
@@ -194,6 +196,64 @@ function LogText($prefix, $variable){
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
function parseJsonPost(){
|
||||
// http://thisinterestsme.com/receiving-json-post-data-via-php/
|
||||
// http://thisinterestsme.com/php-json-error-handling/
|
||||
if(strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') != 0){
|
||||
throw new Exception('Request method must be POST!');
|
||||
}
|
||||
|
||||
//Make sure that the content type of the POST request has been set to application/json
|
||||
$contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : '';
|
||||
if(strcasecmp($contentType, 'application/json') != 0){
|
||||
throw new Exception('Content type must be: application/json');
|
||||
}
|
||||
|
||||
//Receive the RAW post data.
|
||||
$content = trim(file_get_contents("php://input"));
|
||||
|
||||
//Attempt to decode the incoming RAW post data from JSON.
|
||||
$decoded = json_decode($content, true);
|
||||
|
||||
|
||||
$jsonError = json_last_error();
|
||||
|
||||
//In some cases, this will happen.
|
||||
if(is_null($decoded) && $jsonError == JSON_ERROR_NONE){
|
||||
throw new Exception('Could not decode JSON!');
|
||||
}
|
||||
|
||||
//If an error exists.
|
||||
if($jsonError != JSON_ERROR_NONE){
|
||||
$error = 'Could not decode JSON! ';
|
||||
|
||||
//Use a switch statement to figure out the exact error.
|
||||
switch($jsonError){
|
||||
case JSON_ERROR_DEPTH:
|
||||
$error .= 'Maximum depth exceeded!';
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
$error .= 'Underflow or the modes mismatch!';
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
$error .= 'Unexpected control character found';
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
$error .= 'Malformed JSON';
|
||||
break;
|
||||
case JSON_ERROR_UTF8:
|
||||
$error .= 'Malformed UTF-8 characters found!';
|
||||
break;
|
||||
default:
|
||||
$error .= 'Unknown error!';
|
||||
break;
|
||||
}
|
||||
throw new Exception($error);
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
LogText($_SERVER['REQUEST_URI'], $_POST);
|
||||
extract($_POST, EXTR_SKIP);
|
||||
//XXX: $_POST를 추출 없이 그냥 쓰는 경우가 많아서 일단 디버깅을 위해 씀!!!! 절대 production 서버에서 사용 금지!
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
require_once("lib.php");
|
||||
require_once("func_message.php");
|
||||
//로그인 검사
|
||||
CheckLogin(1);
|
||||
$connect = dbconn();
|
||||
@@ -26,15 +26,15 @@ $me = MYDB_fetch_array($result);
|
||||
<tr>
|
||||
<td valign=top width=500>
|
||||
전체 메세지(최고75자)<br>
|
||||
<?php MsgFile($me['skin'], 1); ?>
|
||||
<?=MsgFile($me['skin'], 1)?>
|
||||
<br>
|
||||
개인 메세지(최고75자)<br>
|
||||
<?php MsgMe($connect, 2); ?>
|
||||
<?=MsgMe($connect, 2)?>
|
||||
</td>
|
||||
<td valign=top width=500>
|
||||
<?php MsgDip($connect, 4); ?>
|
||||
<?=MsgDip($connect, 4)?>
|
||||
국가 메세지(최고75자)<br>
|
||||
<?php MsgFile($me['skin'], 3, $me['nation']); ?>
|
||||
<?=MsgFile($me['skin'], 3, $me['nation'])?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -2,17 +2,6 @@
|
||||
//임시 땜빵 리팩터링.
|
||||
require_once "lib.php";
|
||||
|
||||
function dbConnRoot() {
|
||||
global $connect, $HTTP_COOKIE_VARS;
|
||||
$f = @file("../d_setting/set.php") or Error("set.php파일이 없습니다. DB설정을 먼저 하십시요!");
|
||||
for($i=1; $i<= 4; $i++) $f[$i] = trim(str_replace("\n","",$f[$i]));
|
||||
if(!$connect) $connect = @MYDB_connect($f[1],$f[2],$f[3]) or Error("DB 접속시 에러가 발생했습니다");
|
||||
@MYDB_select_db($f[4], $connect) or Error("DB Select 에러가 발생했습니다","");
|
||||
return $connect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class General{
|
||||
protected
|
||||
$no, $user_id, $name, $level, $level_exp,
|
||||
|
||||
Reference in New Issue
Block a user