rework characters

This commit is contained in:
Amberstone 2024-10-08 08:02:48 +09:00
parent 43090e28a2
commit 15b67c7038
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
28 changed files with 450 additions and 284 deletions

View file

@ -4,30 +4,9 @@ include_once "./_common.php";
check_demo(); check_demo();
auth_check($auth[$sub_menu], "d"); auth_check($auth[$sub_menu], "d");
$ch = sql_fetch("select * from {$g5['character_table']} where ch_id = '{$ch_id}'");
if (!$ch['ch_id']) { if (!Character::delete($ch_id)) {
alert("{$ch['ch_id']} : 캐릭터 자료가 존재하지 않습니다."); alert("{$ch['ch_id']} : 캐릭터 자료가 존재하지 않습니다.");
} else {
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_thumb']);
@unlink($prev_file_path);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_head']);
@unlink($prev_file_path);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_body']);
@unlink($prev_file_path);
sql_query("DELETE FROM {$g5['character_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query("DELETE FROM {$g5['value_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query("DELETE FROM {$g5['exp_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query("DELETE FROM {$g5['title_has_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query("DELETE FROM {$g5['closthes_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query("DELETE FROM {$g5['inventory_table']} where ch_id = '{$ch['ch_id']}' ");
$sql = " update {$g5['member_table']}
set ch_id = ''
where mb_id = '{$ch['mb_id']}' and ch_id = '{$ch['ch_id']}' ";
sql_query($sql);
} }
goto_url("./character_list.php?$qstr"); goto_url("./character_list.php?$qstr");

View file

@ -1,39 +1,6 @@
<?php <?php
include_once "./_common.php"; include_once "./_common.php";
function insert_character($data)
{
global $g5;
$sql = "INSERT INTO {$g5['character_table']} SET " . implode(', ', array_map(function ($k, $v) {
return "{$k} = '" . sql_real_escape_string($v) . "'";
}, array_keys($data), $data));
sql_query($sql);
return ['ch_id' => sql_insert_id()];
}
function update_character($ch_id, $data, $old_data)
{
global $g5, $ad;
$sql = "UPDATE {$g5['character_table']} SET " . implode(', ', array_map(function ($k, $v) {
return "{$k} = '" . sql_real_escape_string($v) . "'";
}, array_keys($data), $data)) . " WHERE ch_id = '" . sql_real_escape_string($ch_id) . "'";
sql_query($sql);
$file_fields = ['thumb', 'head', 'body'];
foreach ($file_fields as $field) {
if ($ad["ad_use_{$field}"] && !$ad["ad_url_{$field}"] && $old_data["ch_{$field}"] != $data["ch_{$field}"]) {
$prev_file_path = str_replace(G5_URL, G5_PATH, $old_data["ch_{$field}"]);
@unlink($prev_file_path);
}
}
}
function update_member_character($mb_id, $ch_id)
{
global $g5;
sql_query("UPDATE {$g5['member_table']} SET ch_id = '" . sql_real_escape_string($ch_id) . "' WHERE mb_id = '" . sql_real_escape_string($mb_id) . "'");
}
function insert_default_clothes($ch_id, $ch_body) function insert_default_clothes($ch_id, $ch_body)
{ {
global $g5; global $g5;
@ -177,9 +144,9 @@ foreach ($file_fields as $field => $file_key) {
} }
if ($w == '') { if ($w == '') {
$result = insert_character($character_data); $result = Character::createFromAdminPage($character_data);
$ch_id = $result['ch_id']; $ch_id = $result['ch_id'];
update_member_character($mb['mb_id'], $ch_id); Character::setMemberMainCharacter($mb['mb_id'], $ch_id);
if (isset($character_data['ch_body'])) { if (isset($character_data['ch_body'])) {
insert_default_clothes($ch_id, $character_data['ch_body']); insert_default_clothes($ch_id, $character_data['ch_body']);
} }
@ -188,8 +155,8 @@ if ($w == '') {
if (!$ch['ch_id']) { if (!$ch['ch_id']) {
alert("캐릭터 정보가 존재하지 않습니다."); alert("캐릭터 정보가 존재하지 않습니다.");
} }
update_character($ch_id, $character_data, $ch); Character::updateFromAdminPage($ch_id, $character_data);
update_member_character($mb['mb_id'], $ch_id); Character::setMemberMainCharacter($mb['mb_id'], $ch_id);
if (isset($character_data['ch_body'])) { if (isset($character_data['ch_body'])) {
update_or_insert_default_clothes($ch_id, $character_data['ch_body']); update_or_insert_default_clothes($ch_id, $character_data['ch_body']);
} }

View file

@ -17,13 +17,12 @@ if ($_POST['act_button'] == "선택수정") {
if (!$ch['ch_id']) { if (!$ch['ch_id']) {
$msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n'; $msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n';
} else { } else {
$sql = " update {$g5['character_table']} Character::update($_POST["ch_id"][$k], [
set ch_type = '{$_POST['ch_type'][$k]}', "ch_type" => $_POST["ch_type"][$k],
ch_side = '{$_POST['ch_side'][$k]}', "ch_side" => $_POST["ch_side"][$k],
ch_class = '{$_POST['ch_class'][$k]}', "ch_class" => $_POST["ch_class"][$k],
ch_state = '{$_POST['ch_state'][$k]}' "ch_state" => $_POST["ch_state"][$k]
where ch_id = '{$_POST['ch_id'][$k]}' "; ]);
sql_query($sql);
} }
} }
} else if ($_POST['act_button'] == "선택승인") { } else if ($_POST['act_button'] == "선택승인") {
@ -34,10 +33,9 @@ if ($_POST['act_button'] == "선택수정") {
if (!$ch['ch_id']) { if (!$ch['ch_id']) {
$msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n'; $msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n';
} else { } else {
$sql = " update {$g5['character_table']} Character::update($_POST["ch_id"][$k], [
set ch_state = '승인' "ch_state" => "승인"
where ch_id = '{$_POST['ch_id'][$k]}' "; ]);
sql_query($sql);
} }
} }
} else if ($_POST['act_button'] == "선택삭제") { } else if ($_POST['act_button'] == "선택삭제") {
@ -48,10 +46,10 @@ if ($_POST['act_button'] == "선택수정") {
if (!$ch['ch_id']) { if (!$ch['ch_id']) {
$msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n'; $msg .= $ch['ch_id'] . ' : 캐릭터 자료가 존재하지 않습니다.\\n';
} else { } else {
$sql = " update {$g5['character_table']} Character::update($_POST["ch_id"][$k], [
set ch_state = '삭제' "ch_state" => "삭제"
where ch_id = '{$_POST['ch_id'][$k]}' "; ]);
sql_query($sql);
$sql = " update {$g5['member_table']} $sql = " update {$g5['member_table']}
set ch_id = '' set ch_id = ''
where mb_id = '{$ch['mb_id']}' and ch_id = '{$ch['ch_id']}' "; where mb_id = '{$ch['mb_id']}' and ch_id = '{$ch['ch_id']}' ";

View file

@ -91,8 +91,9 @@ $colspan = 5;
<?php <?php
for ($i = 0; $row = sql_fetch_array($result); $i++) { for ($i = 0; $row = sql_fetch_array($result); $i++) {
$ch_left = sql_fetch("select ch_thumb, ch_name, ch_id from {$g5['character_table']} where ch_id = '{$row['co_left']}'"); // getDetail 에는 ch_id 를 기본 포함합니다.
$ch_right = sql_fetch("select ch_thumb, ch_name, ch_id from {$g5['character_table']} where ch_id = '{$row['co_right']}'"); $ch_left = Character::getDetail($row['co_left'], ["ch_name", "ch_thumb"]);
$ch_right = Character::getDetail($row['co_right'], ["ch_name", "ch_thumb"]);
$bg = 'bg' . ($i % 2); $bg = 'bg' . ($i % 2);
?> ?>

View file

@ -9,27 +9,28 @@ auth_check($auth[$sub_menu], 'w');
check_token(); check_token();
if (!$co_left && $ch_name_left) { if (!$co_left && $ch_name_left) {
$ch = sql_fetch("select ch_id, ch_name, ch_exp from {$g5['character_table']} where ch_name = '{$ch_name_left}'"); $ch = Character::getDetailByName($ch_name_left, ["ch_name", "ch_exp"]);
$co_left = $ch['ch_id']; if (empty($co_left)) {
if (!$co_left)
alert("존재하지 않는 캐릭터 입니다."); alert("존재하지 않는 캐릭터 입니다.");
}
} }
if (!$co_right && $ch_name_right) { if (!$co_right && $ch_name_right) {
$ch = sql_fetch("select ch_id, ch_name, ch_exp from {$g5['character_table']} where ch_name = '{$ch_name_right}'"); $ch = Character::getDetailByName($ch_name_right, ["ch_name", "ch_exp"]);
$co_right = $ch['ch_id'];
if (!$co_right) if (empty($ch)) {
alert("존재하지 않는 캐릭터 입니다."); alert("존재하지 않는 캐릭터 입니다.");
}
} }
$sql_common = " co_left = '{$_POST['co_left']}', $sql_common = "
co_left = '{$_POST['co_left']}',
co_right = '{$_POST['co_right']}', co_right = '{$_POST['co_right']}',
co_order = '{$_POST['co_order']}', co_order = '{$_POST['co_order']}',
co_date = '{$_POST['co_date']}' "; co_date = '{$_POST['co_date']}' ";
$sql = " insert into {$g5['couple_table']} $sql = "INSERT INTO {$g5['couple_table']}
set $sql_common "; set $sql_common ";
sql_query($sql); sql_query($sql);
goto_url('./couple_list.php?' . $qstr); goto_url('./couple_list.php?' . $qstr);

View file

@ -13,7 +13,7 @@ for ($i = 0; $i < $count; $i++) {
// 실제 번호를 넘김 // 실제 번호를 넘김
$k = $_POST['chk'][$i]; $k = $_POST['chk'][$i];
$ch_id = $_POST['ch_id'][$k]; $ch_id = $_POST['ch_id'][$k];
$ch = sql_fetch("select ch_id, ch_name, ch_exp, ch_rank, ch_point from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getDetail($ch_id, ["ch_id", "ch_name", "ch_exp", "ch_rank", "ch_point"]);
// 포인트 내역정보 // 포인트 내역정보
$sql = " select * from {$g5['exp_table']} where ex_id = '{$_POST['ex_id'][$k]}' "; $sql = " select * from {$g5['exp_table']} where ex_id = '{$_POST['ex_id'][$k]}' ";
@ -35,16 +35,14 @@ for ($i = 0; $i < $count; $i++) {
// 포인트 UPDATE // 포인트 UPDATE
$sum_point = get_exp_sum($ch_id); $sum_point = get_exp_sum($ch_id);
$sql = " update {$g5['character_table']} set ch_exp = '$sum_point' where ch_id = '{$ch_id}' "; Character::update($ch_id, ["ch_exp" => $sum_point]);
sql_query($sql);
$rank_info = get_rank_exp($sum_point, $ch_id); $rank_info = get_rank_exp($sum_point, $ch_id);
// 기존 랭크에서 변동이 있을 경우에만 실행 // 기존 랭크에서 변동이 있을 경우에만 실행
if ($ch['ch_rank'] != $rank_info['rank']) { if ($ch['ch_rank'] != $rank_info['rank']) {
$state_point = $ch['ch_point'] + $rank_info['add_point']; $state_point = $ch['ch_point'] + $rank_info['add_point'];
// 스탯 포인트 변동 사항 및 랭크 변동사항 저장 // 스탯 포인트 변동 사항 및 랭크 변동사항 저장
$rank_up_sql = " update {$g5['character_table']} set ch_rank = '{$rank_info['rank']}', ch_point = '{$state_point}' where ch_id = '$ch_id' "; Character::update($ch_id, ["ch_rank" => $rank_info["rank"], "ch_point" => $state_point]);
sql_query($rank_up_sql);
} }
} }

View file

@ -15,25 +15,17 @@ if ($ex_point < 0) {
if ($take_type == 'A') { if ($take_type == 'A') {
// 전체지급 // 전체지급
$sql_common = " from {$g5['character_table']} "; foreach(Character::getList() as $chara) {
$sql_search = " where ch_state = '승인' "; if (($ex_point < 0) && ($ex_point * (-1) > $chara['ch_exp'])) continue;
$sql = " select * {$sql_common} {$sql_search} ";
$result = sql_query($sql);
for ($i = 0; $ch = sql_fetch_array($result); $i++) {
if (($ex_point < 0) && ($ex_point * (-1) > $ch['ch_exp']))
continue;
insert_exp($ch['ch_id'], $ex_point, $ex_content, $action); insert_exp($ch['ch_id'], $ex_point, $ex_content, $action);
} }
} else { } else {
// 개별지급 // 개별지급
if (!$ch_id && $ch_name) { if (!$ch_id && $ch_name) {
$ch = sql_fetch("select ch_id, ch_name, ch_exp from {$g5['character_table']} where ch_name = '{$ch_name}'"); $ch = Character::getDetailByName($ch_name, ["ch_name", "ch_exp"]);
$ch_id = $ch['ch_id']; $ch_id = $ch['ch_id'];
} else { } else {
$ch = sql_fetch("select ch_id, ch_name, ch_exp from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getDetail($ch_id, ["ch_name", "ch_exp"]);
} }
if (!$ch['ch_id']) if (!$ch['ch_id'])

View file

@ -6,7 +6,6 @@
include_once './_common.php'; include_once './_common.php';
auth_check($auth[$sub_menu], 'w'); auth_check($auth[$sub_menu], 'w');
check_token(); check_token();
if (!$it_id && $it_name) { if (!$it_id && $it_name) {
@ -25,22 +24,17 @@ if (!$it_id && $it_name) {
$item_count = $item_count ? $item_count : 1; $item_count = $item_count ? $item_count : 1;
if ($take_type == 'A') { if ($take_type == 'A') {
// 전체지급 $list = Character::getListDetailWithCondition(["ch_id", "ch_name"]);
$sql_common = " from {$g5['character_table']} "; foreach($list as $ch) {
$sql_search = " where ch_state = '승인' ";
$sql = " select ch_id, ch_name {$sql_common} {$sql_search} ";
$result = sql_query($sql);
for ($i = 0; $ch = sql_fetch_array($result); $i++) {
Item::giveItem($ch['ch_id'], $it_id, $it, $item_count, "시스템 지급"); Item::giveItem($ch['ch_id'], $it_id, $it, $item_count, "시스템 지급");
} }
} else { } else {
// 개별지급 // 개별지급
if (!$ch_id && $ch_name) { if (!$ch_id && $ch_name) {
$ch = sql_fetch("select ch_id, ch_name from {$g5['character_table']} where ch_name = '{$ch_name}'"); $ch = Character::getDetailByName($ch_name, ["ch_name"]);
$ch_id = $ch['ch_id']; $ch_id = $ch['ch_id'];
} else { } else {
$ch = sql_fetch("select ch_id, ch_name from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getDetail($ch_id, ["ch_name"]);
} }
if (!$ch['ch_id']) { if (!$ch['ch_id']) {

View file

@ -188,7 +188,7 @@ $frm_submit = '<div class="list_confirm">
for ($i = 0; $row = sql_fetch_array($result); $i++) { for ($i = 0; $row = sql_fetch_array($result); $i++) {
$bg = 'bg' . ($i % 2); $bg = 'bg' . ($i % 2);
$ti = sql_fetch("select * from {$g5['title_table']} where ti_id = '{$row['ti_id']}'"); $ti = sql_fetch("select * from {$g5['title_table']} where ti_id = '{$row['ti_id']}'");
$ch = sql_fetch("select ch_name, ch_title from {$g5['character_table']} where ch_id = '{$row['ch_id']}'"); $ch = Character::getDetail($row["ch_id"], ["ch_name", "ch_title"]);
?> ?>
<tr class="<?php echo $bg; ?>"> <tr class="<?php echo $bg; ?>">
<td> <td>

View file

@ -25,15 +25,9 @@ if (!$ti['ti_id']) {
if ($take_type == 'A') { if ($take_type == 'A') {
// 전체지급 // 전체지급
$sql_common = " from {$g5['character_table']} "; foreach(Character::getList() as $ch) {
$sql_search = " where ch_state = '승인' ";
$sql = " select ch_id, ch_name {$sql_common} {$sql_search} ";
$result = sql_query($sql);
for ($i = 0; $ch = sql_fetch_array($result); $i++) {
// 동일 타이틀 중복 지급 여부 체크 // 동일 타이틀 중복 지급 여부 체크
$m_ti = sql_fetch("select count(*) as cnt from {$g5['title_has_table']} where ti_id = '{$ti_id}' and ch_id = '{$ch['ch_id']}'"); $m_ti = sql_fetch("SELECT count(*) AS cnt FROM {$g5['title_has_table']} WHERE ti_id = '{$ti_id}' AND ch_id = '{$ch['ch_id']}'");
if (!$m_ti['cnt']) { if (!$m_ti['cnt']) {
$sql = " insert into {$g5['title_has_table']} $sql = " insert into {$g5['title_has_table']}
@ -41,6 +35,7 @@ if ($take_type == 'A') {
ch_name = '{$ch['ch_name']}', ch_name = '{$ch['ch_name']}',
ti_id = '{$ti['ti_id']}', ti_id = '{$ti['ti_id']}',
hi_use = '1'"; hi_use = '1'";
sql_query($sql); sql_query($sql);
} }
} }
@ -48,10 +43,10 @@ if ($take_type == 'A') {
} else { } else {
// 개별지급 // 개별지급
if (!$ch_id && $ch_name) { if (!$ch_id && $ch_name) {
$ch = sql_fetch("select ch_id, ch_name from {$g5['character_table']} where ch_name = '{$ch_name}'"); $ch = Character::getDetailByName($ch_name, ["ch_name"]);
$ch_id = $ch['ch_id']; $ch_id = $ch['ch_id'];
} else { } else {
$ch = sql_fetch("select ch_id, ch_name from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getDetail($ch_id, ["ch_name"]);
} }
if (!$ch['ch_id']) if (!$ch['ch_id'])

View file

@ -12,14 +12,23 @@ if (!$is_member) {
} else { } else {
echo "<ul>"; echo "<ul>";
$condition = [
"ch_name" => ["%{$keyword}%", "LIKE"],
"ch_state" => ["승인", "="]
];
$order = [
"ch_name" => "ASC"
];
if ($option == 'user') { if ($option == 'user') {
$sql = " select ch_thumb, ch_name, ch_id, mb_id from {$g5['character_table']} where ch_name like '%{$keyword}%' and ch_state = '승인' and mb_id != '{$config['cf_admin']}' and ch_type = 'main' order by ch_name asc"; $condition["mb_id"] = [$config['ch_admin'], "!="];
} else { $condition["ch_type"] = ["main", "="];
$sql = " select ch_thumb, ch_name, ch_id, mb_id from {$g5['character_table']} where ch_name like '%{$keyword}%' and ch_state = '승인' order by ch_name asc";
} }
$result = sql_query($sql); $list = Character::getListDetailWithCondition(["ch_name", "mb_id"], $condition, $order);
for ($i = 0; $row = sql_fetch_array($result); $i++) {
foreach($list as $row) {
?> ?>
<li> <li>
<a href="#" <a href="#"
@ -29,7 +38,7 @@ if (!$is_member) {
</li> </li>
<?php <?php
} }
if ($i == 0) { if (empty($list)) {
echo "<li class='no-data' style='line-height:1.2; padding:5px 5px 15px; font-size:11px; word-break:keep-all;'>[ {$keyword} ]에 대한 검색결과가 존재하지 않습니다.</li>"; echo "<li class='no-data' style='line-height:1.2; padding:5px 5px 15px; font-size:11px; word-break:keep-all;'>[ {$keyword} ]에 대한 검색결과가 존재하지 않습니다.</li>";
} }
echo "</ul>"; echo "</ul>";

View file

@ -14,7 +14,7 @@ if (!$is_member) {
$sql = " select mb_nick, mb_name, mb_id, ch_id from {$g5['member_table']} where mb_name like '%{$keyword}%' and mb_level > 1 order by mb_nick asc"; $sql = " select mb_nick, mb_name, mb_id, ch_id from {$g5['member_table']} where mb_name like '%{$keyword}%' and mb_level > 1 order by mb_nick asc";
$result = sql_query($sql); $result = sql_query($sql);
for ($i = 0; $row = sql_fetch_array($result); $i++) { for ($i = 0; $row = sql_fetch_array($result); $i++) {
$ch = sql_fetch("select ch_thumb, ch_name from {$g5['character_table']} where ch_id = '{$row['ch_id']}'"); $ch = Character::getDetail($row['ch_id'], ["ch_thumb", "ch_name"]);
?> ?>
<li> <li>
<a href="#" <a href="#"

View file

@ -1,8 +1,178 @@
<?php <?php
class Character Extends Module class Character extends Module
{ {
protected $_rawdata; protected $_rawdata;
private static function filterData($data, $columnNames)
{
$filteredData = [];
foreach ($data as $key => $value) {
if (in_array($key, $columnNames)) {
$filteredData[$key] = $value;
}
}
return $filteredData;
}
private static function prepareSetParts($filteredData)
{
$setParts = [];
foreach ($filteredData as $key => $value) {
$escapedValue = sql_real_escape_string($value);
$setParts[] = "{$key} = '{$escapedValue}'";
}
return implode(', ', $setParts);
}
/**
* 사용자 입력에 함수를 사용하지 마세요. 검증이 별도로 없으므로 심각한 위험을 초래할 있습니다.
* 단순 조회에는 기존 함수를 사용하세요. 코드의 복잡도가 증가할 있습니다.
* @param array $req_columns
* @param array $condition
* @return array|bool|null
*/
public static function getDetailWithCondition($req_columns = [], $condition = [])
{
global $g5;
if (!isset($g5["connect_db"]) || !isset($g5["character_table"])) {
return [];
}
// 이름이나 id 조건이 없으면 단일 캐릭터 조회가 안 되므로 빈 값 반환
if (!isset($condition['ch_id']) && !isset($condition['ch_name'])) {
return [];
}
$table_columns = self::getTableColumns($g5["character_table"]);
$valid_columns = [];
if (!empty($req_columns)) {
foreach ($req_columns as $column) {
if (in_array($column, $table_columns)) {
$valid_columns[] = $column;
}
}
}
$columns = !empty($valid_columns) ? implode(", ", $valid_columns) : "ch.ch_id";
$where_conditions = [];
foreach ($condition as $field => $value) {
if (is_array($value) && count($value) == 2) {
$operator = $value[1];
$where_conditions[] = "ch.{$field} {$operator} '" . sql_real_escape_string($value[0]) . "'";
} else {
$where_conditions[] = "ch.{$field} = '" . sql_real_escape_string($value) . "'";
}
}
$where_clause = implode(" AND ", $where_conditions);
$sql = "SELECT {$columns} FROM {$g5["character_table"]} ch WHERE {$where_clause} LIMIT 1";
$result = sql_fetch($sql);
return $result ?: [];
}
/**
* 사용자 입력에 함수를 사용하지 마세요. 검증이 별도로 없으므로 심각한 위험을 초래할 있습니다.
* 단순 조회에는 기존 함수를 사용하세요. 코드의 복잡도가 증가할 있습니다.
* @param array $req_columns
* @param array $condition
* @param array $req_order
* @return array
*/
public static function getListDetailWithCondition($req_columns = [], $condition = ["ch_state" => ["승인", "="]], $req_order = ["ch_id" => "ASC"])
{
global $g5;
if (!isset($g5["connect_db"]) || !isset($g5["character_table"])) {
return [];
}
$characters = [];
$table_columns = self::getTableColumns($g5["character_table"]);
$valid_columns = [];
if (!empty($req_columns)) {
foreach ($req_columns as $column) {
if (in_array($column, $table_columns)) {
$valid_columns[] = $column;
}
}
}
$columns = !empty($valid_columns) ? implode(", ", $valid_columns) : "*";
// condition 설정
$where_conditions = [];
foreach ($condition as $field => $value) {
if (in_array($field, $table_columns)) {
if (is_array($value) && count($value) == 2) {
$operator = $value[1];
$where_conditions[] = "{$field} {$operator} '" . sql_real_escape_string($value[0]) . "'";
} else {
$where_conditions[] = "{$field} = '" . sql_real_escape_string($value) . "'";
}
}
}
$where_clause = implode(" AND ", $where_conditions);
// 정렬 순서 설정
$order_parts = [];
foreach ($req_order as $field => $direction) {
if (in_array($field, $table_columns)) {
$order_parts[] = "{$field} {$direction}";
}
}
$order = implode(", ", $order_parts);
// sql 생성
$sql = "SELECT {$columns} FROM {$g5["character_table"]} WHERE {$where_clause} ORDER BY {$order}";
$result = sql_query($sql);
// 결과 생성
while ($row = sql_fetch_array($result)) {
$characters[] = $row;
}
return $characters;
}
public static function update($character_id, $data)
{
global $g5;
if ($character_id && (is_array($data) || is_object($data))) {
$character_id = intval($character_id);
$prepare = is_array($data) ? $data : (array) $data;
$columnNames = self::getTableColumns($g5['character_table']);
$filteredData = self::filterData($prepare, $columnNames);
if (!empty($filteredData)) {
$updateParts = self::prepareSetParts($filteredData);
$sql = "UPDATE {$g5['character_table']} SET {$updateParts} WHERE ch_id = '{$character_id}'";
sql_query($sql);
}
}
}
public static function insert($data)
{
global $g5;
if (is_array($data) || is_object($data)) {
$prepare = is_array($data) ? $data : (array) $data;
$columnNames = self::getTableColumns($g5['character_table']);
$filteredData = self::filterData($prepare, $columnNames);
if (!empty($filteredData)) {
$insertParts = self::prepareSetParts($filteredData);
$sql = "INSERT INTO {$g5['character_table']} SET {$insertParts}";
sql_query($sql);
return sql_insert_id();
}
}
}
public static function exists($character_id) public static function exists($character_id)
{ {
global $g5; global $g5;
@ -30,7 +200,7 @@ class Character Extends Module
@unlink($prev_file_path); @unlink($prev_file_path);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_body']); $prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_body']);
@unlink($prev_file_path); @unlink($prev_file_path);
} catch(Exception $x) { } catch (Exception $x) {
} }
@ -42,10 +212,63 @@ class Character Extends Module
sql_query("DELETE FROM {$g5['inventory_table']} WHERE ch_id = '{$character_id}' "); sql_query("DELETE FROM {$g5['inventory_table']} WHERE ch_id = '{$character_id}' ");
$mb_id = self::getMemberID($character_id); $mb_id = self::getMemberID($character_id);
$sql = "UPDATE {$g5['member_table']} SET ch_id = '' WHERE mb_id = '{$mb_id}' AND ch_id = '{$mb_id}' ";
self::setMemberMainCharacter($mb_id);
return true;
}
return false;
}
public static function setMemberMainCharacter($member_id, $character_id = "")
{
global $g5;
$sql = "UPDATE {$g5['member_table']} SET ch_id = '{$character_id}' WHERE mb_id = '{$member_id}'";
sql_query($sql); sql_query($sql);
} }
public static function createFromAdminPage($data)
{
global $g5;
$sql = "INSERT INTO {$g5['character_table']} SET " . implode(', ', array_map(function ($k, $v) {
return "{$k} = '" . sql_real_escape_string($v) . "'";
}, array_keys($data), $data));
sql_query($sql);
return ['ch_id' => sql_insert_id()];
}
public static function updateFromAdminPage($character_id, $data)
{
global $g5;
$ad = sql_fetch("SELECT * FROM {$g5['article_default_table']}");
$ch = self::getCharacter($character_id);
$sql = "UPDATE {$g5['character_table']} SET " . implode(', ', array_map(function ($k, $v) {
return "{$k} = '" . sql_real_escape_string($v) . "'";
}, array_keys($data), $data)) . " WHERE ch_id = '" . sql_real_escape_string($character_id) . "'";
sql_query($sql);
$file_fields = ['thumb', 'head', 'body'];
foreach ($file_fields as $field) {
if ($ad["ad_use_{$field}"] && !$ad["ad_url_{$field}"] && $ch["ch_{$field}"] != $data["ch_{$field}"]) {
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch["ch_{$field}"]);
@unlink($prev_file_path);
}
}
}
public static function getDetailByName($character_name, $req_columns)
{
$character_name = sql_real_escape_string($character_name);
return self::getDetailWithCondition($req_columns, ["ch_name" => [$character_name, "="]]);
}
public static function getDetail($character_id, $req_columns)
{
$character_id = intval($character_id);
return self::getDetailWithCondition($req_columns, ["ch_id" => [$character_id, "="]]);
} }
public static function getImages($character_id) public static function getImages($character_id)
@ -181,7 +404,7 @@ class Character Extends Module
if (isset($g5["connect_db"]) && isset($g5["character_table"]) && isset($g5["value_table"])) { if (isset($g5["connect_db"]) && isset($g5["character_table"]) && isset($g5["value_table"])) {
$info_list = []; $info_list = [];
$rawdata = sql_query("SELECT ar_code, av_value FROM {$g5["value_table"]} WHERE ch_id = '{$character_id}'"); $rawdata = sql_query("SELECT ar_code, av_value FROM {$g5["value_table"]} WHERE ch_id = '{$character_id}'");
while($r = sql_fetch_array($rawdata)) { while ($r = sql_fetch_array($rawdata)) {
$info_list[$r["ar_code"]] = $r["av_value"]; $info_list[$r["ar_code"]] = $r["av_value"];
} }
} }
@ -221,6 +444,31 @@ class Character Extends Module
return self::getInfo($character_id, $extra_code); return self::getInfo($character_id, $extra_code);
} }
public static function getCountByMemberID($member_id)
{
global $g5;
$member_id = intval($member_id);
return (int) sql_fetch("SELECT count(ch_id) AS cnt FROM {$g5["character_table"]} WHERE mb_id = '{$member_id}'")["cnt"];
}
public static function getListByMemberID($member_id)
{
global $g5;
$member_id = intval($member_id);
$characters = [];
$sql = "SELECT * FROM {$g5["character_table"]} WHERE mb_id = '{$member_id}' AND ch_state != '삭제' ORDER BY ch_id ASC";
$res = sql_query($sql);
while ($r = sql_fetch_array($res)) {
$characters[] = $r;
}
return $characters;
}
/** /**
* get character list * get character list
* @param string $side * @param string $side
@ -230,21 +478,15 @@ class Character Extends Module
*/ */
public static function getList($side = "", $class = "", $state = "승인") public static function getList($side = "", $class = "", $state = "승인")
{ {
global $g5; $condition = ["ch_state" => [$state, "="]];
if ($side) {
$character = []; $condition["ch_side"] = [$side, "="];
$s = ''; }
$s .= $side ? " and ch_side = '{$side}' " : ""; if ($class) {
$s .= $class ? " and ch_class = '{$class}' " : ""; $condition["ch_class"] = [$class, "="];
$sql = "SELECT * FROM {$g5["character_table"]} WHERE ch_state = '{$state}' {$s} ORDER BY ch_id ASC";
$res = sql_query($sql);
while($r = sql_fetch_array($res)) {
$character[] = $r;
} }
return $character; return self::getListDetailWithCondition([], $condition);
} }
/** /**
@ -304,26 +546,6 @@ class Character Extends Module
return ""; return "";
} }
/**
* get member name
* @param mixed $member_id
* @return mixed
*/
public static function getMemberName($member_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["member_table"])) {
$data = sql_fetch("SELECT mb.mb_nick FROM {$g5['member_table']} mb WHERE mb.mb_nick = '{$member_id}'");
if (!empty($data)) {
return $data["mb_nick"];
} else {
return "";
}
}
return "";
}
/** /**
* get member name (compatible name for avocadoedition) * get member name (compatible name for avocadoedition)
* @param mixed $member_id * @param mixed $member_id
@ -331,16 +553,18 @@ class Character Extends Module
*/ */
public static function get_member_name($member_id) public static function get_member_name($member_id)
{ {
return self::getMemberName($member_id); return Member::getName($member_id);
} }
public static function fixMemberCharacter() public static function fixMemberCharacter()
{ {
global $g5, $is_member, $member, $character; global $g5, $is_member, $member, $character;
if (isset($g5["connect_db"]) && isset($g5["member_table"]) && isset($g5["character_table"]) && $is_member && ( if (
isset($g5["connect_db"]) && isset($g5["member_table"]) && isset($g5["character_table"]) && $is_member && (
$member["mb_id"] != $character["mb_id"] || $member["ch_id"] == "" || !$character["ch_id"] $member["mb_id"] != $character["mb_id"] || $member["ch_id"] == "" || !$character["ch_id"]
)) { )
) {
$character_sql = "SELECT * FROM {$g5["character_table"]} where mb_id = '{$member['mb_id']}' limit 0, 1"; $character_sql = "SELECT * FROM {$g5["character_table"]} where mb_id = '{$member['mb_id']}' limit 0, 1";
$character = sql_fetch($character_sql); $character = sql_fetch($character_sql);

View file

@ -0,0 +1,24 @@
<?php
class Member extends Module
{
/**
* get member name
* @param mixed $member_id
* @return mixed
*/
public static function getName($member_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["member_table"])) {
$data = sql_fetch("SELECT mb.mb_nick FROM {$g5['member_table']} mb WHERE mb.mb_nick = '{$member_id}'");
if (!empty($data)) {
return $data["mb_nick"];
} else {
return "";
}
}
return "";
}
}

View file

@ -7,6 +7,19 @@ class Module
protected $variables = []; protected $variables = [];
protected $createdAt; protected $createdAt;
protected static function getTableColumns($table)
{
global $g5;
$columnsRaw = sql_query("SHOW COLUMNS FROM {$table}");
$columnNames = [];
if ($columnsRaw) {
while ($row = sql_fetch_array($columnsRaw)) {
$columnNames[] = $row['Field'];
}
}
return $columnNames;
}
public function __construct($err = 0) public function __construct($err = 0)
{ {
$this->createdAt = microtime(true); $this->createdAt = microtime(true);

View file

@ -13,8 +13,8 @@ $list = [];
for ($i = 0; $co = sql_fetch_array($result); $i++) { for ($i = 0; $co = sql_fetch_array($result); $i++) {
$list[$i] = $co; $list[$i] = $co;
$ch_left = sql_fetch("select ch_name, ch_thumb, mb_id from {$g5['character_table']} where ch_id = '{$co['co_left']}'"); $ch_left = Character::getDetail($co['co_left'], ["ch_name", "ch_thumb", "mb_id"]);
$ch_right = sql_fetch("select ch_name, ch_thumb, mb_id from {$g5['character_table']} where ch_id = '{$co['co_right']}'"); $ch_right = Character::getDetail($co['co_right'], ["ch_name", "ch_thumb", "mb_id"]);
$ch_left['ch_name'] = explode(' ', $ch_left['ch_name']); $ch_left['ch_name'] = explode(' ', $ch_left['ch_name']);
$ch_left['ch_name'] = $ch_left['ch_name'][0]; $ch_left['ch_name'] = $ch_left['ch_name'][0];

View file

@ -90,7 +90,7 @@ function get_character_head($ch_id)
function get_member_name($mb_id) function get_member_name($mb_id)
{ {
return Character::getMemberName($mb_id); return Member::getName($mb_id);
} }
function get_character($ch_id) function get_character($ch_id)

View file

@ -41,18 +41,15 @@ function insert_exp($ch_id, $exp, $content = '', $rel_action = '')
sql_query($sql); sql_query($sql);
// 경험치 UPDATE // 경험치 UPDATE
$sql = " update {$g5['character_table']} set ch_exp = '$ex_ch_exp' where ch_id = '$ch_id' "; Character::update($ch_id, ["ch_exp" => intval($ex_ch_exp)]);
sql_query($sql);
$rank_info = get_rank_exp($ex_ch_exp, $ch_id); $rank_info = get_rank_exp($ex_ch_exp, $ch_id);
// 기존 랭크에서 변동이 있을 경우에만 실행 // 기존 랭크에서 변동이 있을 경우에만 실행
if ($ch['ch_rank'] != $rank_info['rank']) { if ($ch['ch_rank'] != $rank_info['rank']) {
$state_point = $ch['ch_point'] + $rank_info['add_point']; $state_point = $ch['ch_point'] + $rank_info['add_point'];
// 스탯 포인트 변동 사항 및 랭크 변동사항 저장 // 스탯 포인트 변동 사항 및 랭크 변동사항 저장
$rank_up_sql = " update {$g5['character_table']} set ch_rank = '{$rank_info['rank']}', ch_point = '{$state_point}' where ch_id = '$ch_id' "; Character::update($ch_id, ["ch_rank" => $rank_info['rank'], "ch_point" => $state_point]);
sql_query($rank_up_sql);
} }
return 1; return 1;

View file

@ -28,7 +28,8 @@ function get_rank_exp($exp, $ch_id)
global $g5; global $g5;
$result = []; $result = [];
$ch = sql_fetch("SELECT ch_rank FROM {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getDetail($ch_id, ["ch_rank"]);
$ch_rank = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_id = '{$ch['ch_rank']}'"); $ch_rank = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_id = '{$ch['ch_rank']}'");
$level = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_exp <= {$exp} ORDER BY lv_exp DESC limit 0, 1"); $level = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_exp <= {$exp} ORDER BY lv_exp DESC limit 0, 1");

View file

@ -1,6 +1,8 @@
<?php <?php
include_once './_common.php'; include_once './_common.php';
$ch = sql_fetch("select * from {$g5['character_table']} where ch_id=" . $ch_id);
$ch = Character::getCharacter($ch_id);
if (!$ch['ch_id']) { if (!$ch['ch_id']) {
alert("캐릭터 정보가 존재하지 않습니다."); alert("캐릭터 정보가 존재하지 않습니다.");
} }

View file

@ -1,7 +1,7 @@
<?php <?php
include_once './_common.php'; include_once './_common.php';
$ch = sql_fetch("select * from {$g5['character_table']} where ch_id=" . $ch_id); $ch = Character::getCharacter($ch_id);
$mb = get_member($ch['mb_id']); $mb = get_member($ch['mb_id']);
/** 추가 항목 설정값 가져오기 **/ /** 추가 항목 설정값 가져오기 **/

View file

@ -1,33 +1,16 @@
<?php <?php
include_once "./_common.php"; include_once "./_common.php";
$ch = sql_fetch("select * from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getMemberID($ch_id);
if (!$ch['ch_id']) {
alert("{$ch['ch_id']} : 캐릭터 자료가 존재하지 않습니다."); if ($ch == "") {
alert("캐릭터 자료가 존재하지 않습니다.");
} }
if ($ch['mb_id'] != $member['mb_id'] && !$is_admin) {
if ($ch != $member['mb_id'] && !$is_admin) {
alert("삭제권한이 없습니다."); alert("삭제권한이 없습니다.");
} }
Character::delete($ch_id);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_thumb']);
@unlink($prev_file_path);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_head']);
@unlink($prev_file_path);
$prev_file_path = str_replace(G5_URL, G5_PATH, $ch['ch_body']);
@unlink($prev_file_path);
sql_query(" delete from {$g5['character_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query(" delete from {$g5['value_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query(" delete from {$g5['exp_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query(" delete from {$g5['title_has_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query(" delete from {$g5['closthes_table']} where ch_id = '{$ch['ch_id']}' ");
sql_query(" delete from {$g5['inventory_table']} where ch_id = '{$ch['ch_id']}' ");
$sql = " update {$g5['member_table']}
set ch_id = ''
where mb_id = '{$ch['mb_id']}' and ch_id = '{$ch['ch_id']}' ";
sql_query($sql);
goto_url("./index.php"); goto_url("./index.php");

View file

@ -66,23 +66,27 @@ if ($w == "") {
if (!$is_add_character && !$is_admin) { if (!$is_add_character && !$is_admin) {
alert("현재 캐릭터 생성 기간이 아닙니다.", "./index.php"); alert("현재 캐릭터 생성 기간이 아닙니다.", "./index.php");
} }
$ch = sql_fetch("select count(ch_id) as cnt from {$g5['character_table']} where mb_id = '{$member['mb_id']}'");
$ch = Character::getCountByMemberID($member['mb_id']);
// 생성한 캐릭터 갯수 제한 체크 // 생성한 캐릭터 갯수 제한 체크
if ($ch['cnt'] > $config['cf_character_count']) { if ($ch > $config['cf_character_count']) {
alert("생성 가능한 캐릭터 갯수를 초과하였습니다.", "./index.php"); alert("생성 가능한 캐릭터 갯수를 초과하였습니다.", "./index.php");
} }
$ch = [];
$ch['ch_state'] = '수정중'; $ch['ch_state'] = '수정중';
$ch['ch_type'] = 'main'; $ch['ch_type'] = 'main';
$ch['mb_id'] = $member['mb_id']; $ch['mb_id'] = $member['mb_id'];
$ch['ch_point'] = $config['cf_status_point']; $ch['ch_point'] = $config['cf_status_point'];
} else { } else {
$ch = sql_fetch("select * from {$g5['character_table']} where ch_id = '{$ch_id}'"); $ch = Character::getCharacter($ch_id);
if (empty($ch)) { if (empty($ch)) {
alert("캐릭터 내역이 존재하지 않습니다."); alert("캐릭터 내역이 존재하지 않습니다.");
} }
if (!$is_mod_character && !$is_admin) { if (!$is_mod_character && !$is_admin) {
if ($in['ch_id'] != $ch['ch_id'] || $in['it_type'] != '프로필수정') { if ($in['ch_id'] != $ch['ch_id'] || $in['it_type'] != '프로필수정') {
alert("캐릭터 수정 기간이 아닙니다."); alert("캐릭터 수정 기간이 아닙니다.");

View file

@ -25,25 +25,22 @@ $character_image_url = G5_DATA_URL . "/character/" . $mb_id;
@mkdir($character_image_path, G5_DIR_PERMISSION); @mkdir($character_image_path, G5_DIR_PERMISSION);
@chmod($character_image_path, G5_DIR_PERMISSION); @chmod($character_image_path, G5_DIR_PERMISSION);
$sql_article = "";
// 기본 데이터 등록 // 기본 데이터 등록
$ad = sql_fetch("select * from {$g5['article_default_table']}"); $ad = sql_fetch("select * from {$g5['article_default_table']}");
$sql_article .= "
ch_state = '{$ch_state}', $sql_data = [
ch_type = '{$ch_type}', "ch_state" => $ch_state,
mb_id = '{$mb_id}', "ch_type" => $ch_type,
ch_side = '{$ch_side}', "mb_id" => $mb_id,
ch_class = '{$ch_class}', "ch_side" => $ch_side,
ch_name = '{$ch_name}', "ch_class" => $ch_class,
ch_point = '{$ch_point}' "ch_name" => $ch_name,
"; "ch_point" => $ch_point
];
// 이미지 등록 // 이미지 등록
// -- 두상 // -- 두상
if ($ad['ad_use_thumb']) { if ($ad['ad_use_thumb']) {
if ($_FILES['ch_thumb_file']['name']) { if ($_FILES['ch_thumb_file']['name']) {
// 확장자 따기 // 확장자 따기
$exp = explode(".", $_FILES['ch_thumb_file']['name']); $exp = explode(".", $_FILES['ch_thumb_file']['name']);
@ -63,7 +60,7 @@ if ($ad['ad_use_thumb']) {
} }
} }
$sql_article .= " , ch_thumb = '{$ch_thumb}'"; $sql_data["ch_thumb"] = $ch_thumb;
} }
// -- 흉상 // -- 흉상
if ($ad['ad_use_head']) { if ($ad['ad_use_head']) {
@ -86,7 +83,7 @@ if ($ad['ad_use_head']) {
} }
} }
$sql_article .= " , ch_head = '{$ch_head}'"; $sql_data["ch_head"] = $ch_head;
} }
// -- 전신 // -- 전신
if ($ad['ad_use_body']) { if ($ad['ad_use_body']) {
@ -108,17 +105,17 @@ if ($ad['ad_use_body']) {
alert("이미지 경로가 올바르지 않습니다."); alert("이미지 경로가 올바르지 않습니다.");
} }
} }
$sql_article .= " , ch_body = '{$ch_body}'";
$sql_data["ch_body"] = $ch_body;
} }
if ($w == '') { if ($w == '') {
$sql = " insert into {$g5['character_table']} set {$sql_article}"; $ch_id = Character::insert($sql_data);
sql_query($sql);
$ch_id = sql_insert_id(); if ($mb['ch_id'] == "") {
if ($mb['ch_id'] == "")
sql_query("update {$g5['member_table']} set ch_id = '{$ch_id}' where mb_id = '{$mb['mb_id']}'"); sql_query("update {$g5['member_table']} set ch_id = '{$ch_id}' where mb_id = '{$mb['mb_id']}'");
}
if ($ch_body) { if ($ch_body) {
$sql = " insert into {$g5['closthes_table']} $sql = " insert into {$g5['closthes_table']}
@ -133,7 +130,7 @@ if ($w == '') {
} else { } else {
// 기존 캐릭터 데이터 호출 // 기존 캐릭터 데이터 호출
$ch = get_character($ch_id); $ch = Character::getCharacter($ch_id);
if (!$ch['ch_id']) if (!$ch['ch_id'])
alert("캐릭터 정보가 존재하지 않습니다."); alert("캐릭터 정보가 존재하지 않습니다.");
@ -155,11 +152,7 @@ if ($w == '') {
@unlink($prev_file_path); @unlink($prev_file_path);
} }
Character::update($ch_id, $sql_data);
$sql = " update {$g5['character_table']}
set {$sql_article}
where ch_id = '{$ch_id}'";
sql_query($sql);
if ($mb['ch_id'] == "") if ($mb['ch_id'] == "")
sql_query("update {$g5['member_table']} set ch_id = '{$ch_id}' where mb_id = '{$mb['mb_id']}'"); sql_query("update {$g5['member_table']} set ch_id = '{$ch_id}' where mb_id = '{$mb['mb_id']}'");
@ -272,5 +265,4 @@ if ($in_id && !$in['it_use_ever']) {
delete_inventory($in_id); delete_inventory($in_id);
} }
goto_url('./viewer.php?ch_id=' . $ch_id, false); goto_url('./viewer.php?ch_id=' . $ch_id);
?>

View file

@ -2,17 +2,9 @@
include_once './_common.php'; include_once './_common.php';
include_once './_head.php'; include_once './_head.php';
$ch_array = []; $ch_array = Character::getListByMemberID($member['mb_id']);
$character_result = sql_query("select * from {$g5['character_table']} where mb_id = '{$member['mb_id']}' and ch_state != '삭제'");
for ($i = 0; $row = sql_fetch_array($character_result); $i++) {
$ch_array[$i] = $row;
}
if ($i == 1) {
//goto_url('./viewer.php?ch_id='.$ch_array[0]['ch_id']);
}
?> ?>
<section> <section>
<div> <div>
<table class="theme-form"> <table class="theme-form">
@ -34,7 +26,7 @@ if ($i == 1) {
<?= $ch['ch_name'] ?> <?= $ch['ch_name'] ?>
</option> </option>
<?php } ?> <?php } ?>
<select> </select>
<input type="submit" value="변경" class="ui-btn" /> <input type="submit" value="변경" class="ui-btn" />
</form> </form>
</td> </td>
@ -43,7 +35,6 @@ if ($i == 1) {
</table> </table>
</div> </div>
</section> </section>
<section> <section>
<div class="list-character-box"> <div class="list-character-box">
<?php for ($i = 0; $i < count($ch_array); $i++) { <?php for ($i = 0; $i < count($ch_array); $i++) {

View file

@ -1,7 +1,7 @@
<?php <?php
include_once './_common.php'; include_once './_common.php';
$ch = get_character($ch_id); $ch = Character::getCharacter($ch_id);
if ($ch['mb_id'] != $member['mb_id']) { if ($ch['mb_id'] != $member['mb_id']) {
alert("등록권한이 없습니다."); alert("등록권한이 없습니다.");
} }
@ -9,10 +9,12 @@ if ($ch['mb_id'] != $member['mb_id']) {
if ($w == '') { if ($w == '') {
// 신규 입력 // 신규 입력
if (!$_POST['re_ch_id']) { if (!$_POST['re_ch_id']) {
$re_ch = sql_fetch("select * from {$g5['character_table']} where ch_name = '{$search_re_ch_name}'"); $re_ch = Character::getCharacterByName($search_re_ch_name);
$re_ch = $re_ch ? $re_ch->getLegacy() : [];
$_POST['re_ch_id'] = $re_ch['ch_id']; $_POST['re_ch_id'] = $re_ch['ch_id'];
} }
if (isset($re_ch['ch_id'])) {
$sql = " insert into {$g5['relation_table']} $sql = " insert into {$g5['relation_table']}
set ch_id = '{$_POST['ch_id']}', set ch_id = '{$_POST['ch_id']}',
re_ch_id = '{$_POST['re_ch_id']}', re_ch_id = '{$_POST['re_ch_id']}',
@ -21,7 +23,7 @@ if ($w == '') {
rm_order = '{$_POST['rm_order']}', rm_order = '{$_POST['rm_order']}',
rm_memo = '{$_POST['rm_memo']}'"; rm_memo = '{$_POST['rm_memo']}'";
sql_query($sql); sql_query($sql);
}
} else if ($w == 'u') { } else if ($w == 'u') {
// 수정사항 // 수정사항
$sql = " update {$g5['relation_table']} $sql = " update {$g5['relation_table']}
@ -32,7 +34,6 @@ if ($w == '') {
where rm_id = '{$_POST['rm_id']}' where rm_id = '{$_POST['rm_id']}'
"; ";
sql_query($sql); sql_query($sql);
} }
goto_url('./viewer.php?ch_id=' . $ch_id); goto_url('./viewer.php?ch_id=' . $ch_id);

View file

@ -1,7 +1,6 @@
<?php <?php
include_once './_common.php'; include_once './_common.php';
$sql = " update {$g5['character_table']}
set ch_title = '{$ti_id}' Character::update($ch_id, ["ch_title" => $ti_id]);
where ch_id = '{$ch_id}'";
sql_query($sql);
echo "Y"; echo "Y";

View file

@ -8,11 +8,12 @@ if ($point > 0) {
alert("소지" . $config['cf_money'] . " 보다 많은 " . $config['cf_money'] . j($config['cf_money'], '은') . " 보낼 수 없습니다."); alert("소지" . $config['cf_money'] . " 보다 많은 " . $config['cf_money'] . j($config['cf_money'], '은') . " 보낼 수 없습니다.");
} }
if (!$ch_id) { if (!$ch_id) {
$re_ch = sql_fetch("select * from {$g5['character_table']} where ch_name = '{$ch_name}'"); $re_ch = Character::getCharacterByName($ch_name);
} else { } else {
$re_ch = get_character($ch_id); $re_ch = Character::getCharacter($ch_id);
} }
$recv_name = get_member_name($re_ch['mb_id']);
$recv_name = Member::getName($re_ch['mb_id']);
if (!$recv_name) { if (!$recv_name) {
alert("상대를 확인할 수 없습니다."); alert("상대를 확인할 수 없습니다.");