inventory and etc update

This commit is contained in:
Amberstone 2024-10-09 07:50:59 +09:00
parent 15b67c7038
commit 8c18b8ceed
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
19 changed files with 258 additions and 170 deletions

View file

@ -1,2 +1,2 @@
<?php
include_once "./common.php";
require_once "./common.php";

View file

@ -2,4 +2,4 @@
if (!defined('_GNUBOARD_'))
exit;
include_once G5_PATH . '/head.php';
require_once G5_PATH . '/head.php';

View file

@ -2,4 +2,4 @@
if (!defined('_GNUBOARD_'))
exit;
include_once G5_PATH . '/tail.php';
require_once G5_PATH . '/tail.php';

View file

@ -14,7 +14,7 @@ if ($ex_point < 0) {
}
if ($take_type == 'A') {
// 전체지급
// 추후 일괄지급은 전용 함수로 최적화 예정
foreach(Character::getList() as $chara) {
if (($ex_point < 0) && ($ex_point * (-1) > $chara['ch_exp'])) continue;
insert_exp($ch['ch_id'], $ex_point, $ex_content, $action);

View file

@ -25,6 +25,7 @@ $item_count = $item_count ? $item_count : 1;
if ($take_type == 'A') {
$list = Character::getListDetailWithCondition(["ch_id", "ch_name"]);
// 추후 일괄지급은 전용 함수로 최적화 예정
foreach($list as $ch) {
Item::giveItem($ch['ch_id'], $it_id, $it, $item_count, "시스템 지급");
}

View file

@ -12,6 +12,7 @@ if (!$is_member) {
} else {
echo "<ul>";
$keyword = addslashes($keyword);
$condition = [
"ch_name" => ["%{$keyword}%", "LIKE"],
"ch_state" => ["승인", "="]
@ -23,10 +24,10 @@ if (!$is_member) {
if ($option == 'user') {
$condition["mb_id"] = [$config['ch_admin'], "!="];
$condition["ch_type"] = ["main", "="];
$condition["ch_type"] = "main";
}
$list = Character::getListDetailWithCondition(["ch_name", "mb_id"], $condition, $order);
$list = Character::getListDetailWithCondition(["ch_name", "mb_id"], $condition, $order, 20);
foreach($list as $row) {
?>

View file

@ -5,10 +5,10 @@
* 커스터마이징 하시는 편이 좋습니다.
* ------------
*/
include_once __DIR__ . "/_common.php";
require_once __DIR__ . "/_common.php";
if (defined('G5_THEME_PATH') && file_exists(G5_THEME_PATH . "/bgm.php")) {
include_once G5_THEME_PATH . '/bgm.php';
require_once G5_THEME_PATH . '/bgm.php';
return;
}

View file

@ -3,27 +3,6 @@ class Character extends Module
{
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);
}
/**
* 사용자 입력에 함수를 사용하지 마세요. 검증이 별도로 없으므로 심각한 위험을 초래할 있습니다.
* 단순 조회에는 기존 함수를 사용하세요. 코드의 복잡도가 증가할 있습니다.
@ -71,6 +50,7 @@ class Character extends Module
return $result ?: [];
}
/**
* 사용자 입력에 함수를 사용하지 마세요. 검증이 별도로 없으므로 심각한 위험을 초래할 있습니다.
* 단순 조회에는 기존 함수를 사용하세요. 코드의 복잡도가 증가할 있습니다.
@ -79,7 +59,7 @@ class Character extends Module
* @param array $req_order
* @return array
*/
public static function getListDetailWithCondition($req_columns = [], $condition = ["ch_state" => ["승인", "="]], $req_order = ["ch_id" => "ASC"])
public static function getListDetailWithCondition($req_columns = [], $condition = ["ch_state" => ["승인", "="]], $req_order = ["ch_id" => "ASC"], $limit = 0)
{
global $g5;
if (!isset($g5["connect_db"]) || !isset($g5["character_table"])) {
@ -122,8 +102,12 @@ class Character extends Module
}
$order = implode(", ", $order_parts);
if ($limit !== 0) {
$limit = "LIMIT {$limit}";
}
// sql 생성
$sql = "SELECT {$columns} FROM {$g5["character_table"]} WHERE {$where_clause} ORDER BY {$order}";
$sql = "SELECT {$columns} FROM {$g5["character_table"]} WHERE {$where_clause} ORDER BY {$order} {$limit}";
$result = sql_query($sql);
// 결과 생성
@ -146,7 +130,7 @@ class Character extends Module
$filteredData = self::filterData($prepare, $columnNames);
if (!empty($filteredData)) {
$updateParts = self::prepareSetParts($filteredData);
$updateParts = self::prepareQueryString($filteredData);
$sql = "UPDATE {$g5['character_table']} SET {$updateParts} WHERE ch_id = '{$character_id}'";
sql_query($sql);
}
@ -164,7 +148,7 @@ class Character extends Module
$filteredData = self::filterData($prepare, $columnNames);
if (!empty($filteredData)) {
$insertParts = self::prepareSetParts($filteredData);
$insertParts = self::prepareQueryString($filteredData);
$sql = "INSERT INTO {$g5['character_table']} SET {$insertParts}";
sql_query($sql);
@ -176,14 +160,12 @@ class Character extends Module
public static function exists($character_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["character_table"])) {
$data = sql_fetch("SELECT ch.ch_name FROM {$g5['character_table']} ch WHERE ch.ch_id = '{$character_id}'");
if (!empty($data)) {
return true;
} else {
return false;
}
return !empty($data);
}
return false;
}
@ -262,13 +244,13 @@ class Character extends Module
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, "="]]);
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, "="]]);
return self::getDetailWithCondition($req_columns, ["ch_id" => $character_id]);
}
public static function getImages($character_id)

View file

@ -1,40 +1,125 @@
<?php
class Item extends Module
{
private $_rawdata;
public static function exists($item_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"])) {
$data = sql_fetch("SELECT it_name FROM {$g5['item_table']} WHERE it_id = '{$item_id}'");
return !empty($data);
}
return false;
}
public static function getItem($item_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"])) {
$result = sql_fetch("SELECT * FROM {$g5['item_table']} WHERE it_id = '{$item_id}'");
if (!empty($result)) {
return $result;
}
}
return [];
}
public static function getImage($item_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"])) {
$result = sql_fetch("SELECT it_img FROM {$g5['item_table']} WHERE it_id = '{$item_id}'");
return $result['it_img'];
if (!empty($result)) {
return $result["it_img"];
}
}
return [];
}
public static function getDetailImage($item_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"])) {
$result = sql_fetch("SELECT it_1 FROM {$g5['item_table']} WHERE it_id = '{$item_id}'");
return $result['it_1'];
if (!empty($result)) {
return $result["it_1"];
}
}
return [];
}
public static function getName($item_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"])) {
$result = sql_fetch("SELECT it_name FROM {$g5['item_table']} WHERE it_id = '{$item_id}'");
return $result['it_name'];
if (!empty($result)) {
return $result["it_name"];
}
}
return [];
}
public static function getInventoryItem($inventory_id)
{
global $g5;
if (isset($g5["connect_db"]) && isset($g5["item_table"]) && isset($g5["inventory_table"]) ) {
$result = sql_fetch("SELECT * FROM {$g5['inventory_table']} inv, {$g5['item_table']} itm WHERE inv.in_id = '{$inventory_id}' AND inv.it_id = itm.it_id");
if (!empty($result)) {
return $result;
}
}
return [];
}
public static function sendItem($character_id, $receive_character_id, $inventory_id, $memo = "")
{
global $g5, $member;
if (isset($g5["connect_db"]) && isset($g5["item_table"]) && isset($g5["inventory_table"]) ) {
$send_chara = Character::getDetail($character_id, ["ch_name"]);
$recv_chara = Character::getDetail($receive_character_id, ["ch_name"]);
$item = self::getInventoryItem($inventory_id);
if (!empty($item)) {
self::addGetLog($item["it_id"], $character_id, $item, "전송");
$inven_sql = "UPDATE {$g5['inventory_table']} SET
ch_id = '{$recv_chara['ch_id']}',
ch_name = '{$recv_chara['ch_name']}',
se_ch_id = '{$send_chara['ch_id']}',
se_ch_name = '{$send_chara['ch_name']}',
re_ch_id = '{$recv_chara['ch_id']}',
re_ch_name = '{$recv_chara['ch_name']}',
in_memo = '{$memo}'
where in_id = '{$inventory_id}'";
sql_query($inven_sql);
$recv_mb_id = $recv_chara['mb_id'];
$memo_content = "[ {$send_chara['ch_name']}님이 보내신 《{$item['it_name']}》선물이 도착 하였습니다. ] 캐릭터 인벤토리를 확인하세요.";
send_memo($member['mb_id'], $recv_mb_id, $memo_content);
return true;
}
}
return false;
}
public static function giveItem($character_id, $item_id, $item = null, $count = 1, $type = "획득")
{
@ -170,4 +255,19 @@ class Item extends Module
}
}
public function __construct($item_id)
{
global $g5;
$data = self::getItem($item_id);
if ($data) {
$this->_rawdata = $data;
parent::init($this->_rawdata);
}
}
public function getLegacy()
{
return $this->_rawdata;
}
}

View file

@ -20,6 +20,27 @@ class Module
return $columnNames;
}
protected static function prepareQueryString($filteredData)
{
$setParts = [];
foreach ($filteredData as $key => $value) {
$escapedValue = sql_real_escape_string($value);
$setParts[] = "{$key} = '{$escapedValue}'";
}
return implode(', ', $setParts);
}
protected static function filterData($data, $columnNames)
{
$filteredData = [];
foreach ($data as $key => $value) {
if (in_array($key, $columnNames)) {
$filteredData[$key] = $value;
}
}
return $filteredData;
}
public function __construct($err = 0)
{
$this->createdAt = microtime(true);
@ -60,9 +81,8 @@ class Module
return array_key_exists($key, $this->variables) ? $this->variables[$key] : null;
}
public function gets()
public function gets(...$args)
{
$args = func_get_args();
$ret = new stdClass();
foreach ($args as $arg) {
$ret->$arg = $this->get($arg);

View file

@ -10,6 +10,7 @@ header('P3P: CP="ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV
if (!defined('G5_SET_TIME_LIMIT')) {
define('G5_SET_TIME_LIMIT', 0);
}
define("__ADVDIR__", __DIR__);
@set_time_limit(G5_SET_TIME_LIMIT);
@ -62,9 +63,7 @@ function load_libs($base_dir, $load_type = "class")
try {
if ($file->isDir()) {
$parent_folder_name = $file->getFilename();
$class_file = $file->getPathname() . DIRECTORY_SEPARATOR . "{$parent_folder_name}.{$load_type}.php";
if (file_exists($class_file)) {
require_once $class_file;
$loaded_files[] = $class_file;
@ -235,8 +234,8 @@ function chrome_domain_session_name()
}
}
include_once __DIR__ . "/classes/event_handler.php";
include_once __DIR__ . "/classes/module.class.php";
require_once __DIR__ . "/classes/event_handler.php";
require_once __DIR__ . "/classes/module.class.php";
$extra_headers = [
'HTTP_X_REAL_IP',
@ -278,7 +277,7 @@ foreach ($var_filter as $val) {
$g5_path = g5_path();
// gnuboard5 configuration file
include_once $g5_path['path'] . '/config.php';
require_once $g5_path['path'] . '/config.php';
$_system = new stdClass;
$_system->g5_path = $g5_path;
@ -378,10 +377,10 @@ $g5_debug = [
'sql' => []
];
include_once G5_LIB_PATH . '/hook.lib.php';
include_once G5_LIB_PATH . '/get_data.lib.php';
include_once G5_LIB_PATH . '/cache.lib.php';
include_once G5_LIB_PATH . '/url.lib.php';
require_once G5_LIB_PATH . '/hook.lib.php';
require_once G5_LIB_PATH . '/get_data.lib.php';
require_once G5_LIB_PATH . '/cache.lib.php';
require_once G5_LIB_PATH . '/url.lib.php';
$g5_object = new G5_object_cache();
@ -390,10 +389,10 @@ $g5_object = new G5_object_cache();
//------------------------------------------------------------------------------
$dbconfig_file = G5_DATA_PATH . '/' . G5_DBCONFIG_FILE;
if (file_exists($dbconfig_file)) {
include_once $dbconfig_file;
include_once G5_LIB_PATH . '/common.lib.php'; // 공통 라이브러리
require_once $dbconfig_file;
require_once G5_LIB_PATH . '/common.lib.php'; // 공통 라이브러리
include_once G5_PATH . "/extraconfig.php";
require_once G5_PATH . "/extraconfig.php";
$connect_db = sql_connect(G5_MYSQL_HOST, G5_MYSQL_USER, G5_MYSQL_PASSWORD) or die('MySQL Connect Error!!!');
$select_db = sql_select_db(G5_MYSQL_DB, $connect_db) or die('MySQL DB Error!!!');
@ -409,15 +408,13 @@ if (file_exists($dbconfig_file)) {
EventHandler::triggerEvent("amber.load_config_after");
} else {
?><!doctype html>
?><!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>오류! <?php echo G5_VERSION ?> 설치하기</title>
<link rel="stylesheet" href="install/install.css">
</head>
<body>
<div id="ins_bar">
<span id="bar_img">AVOCADO EDITION</span>
@ -439,7 +436,6 @@ if (file_exists($dbconfig_file)) {
<p>GPL! OPEN SOURCE GNUBOARD</p>
</div>
</body>
</html><?php
exit;
}
@ -454,16 +450,13 @@ if (strstr($url, 'adm')) {
if (!defined('G5_IS_ADMIN')) {
$cssconfig_file = G5_DATA_PATH . '/css/_design.config.css';
if (!file_exists($cssconfig_file)) {
?>
<!doctype html>
?><!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>오류! <?php echo G5_VERSION ?> 설치하기</title>
<link rel="stylesheet" href="<?= G5_URL ?>/install/install.css">
</head>
<body>
<div id="ins_bar">
<span id="bar_img">AVOCADO EDITION</span>
@ -484,9 +477,7 @@ if (!defined('G5_IS_ADMIN')) {
<p>GPL! OPEN SOURCE GNUBOARD</p>
</div>
</body>
</html>
<?php exit;
</html><?php exit;
}
}

View file

@ -4,6 +4,9 @@ if (!defined('_GNUBOARD_'))
$yoil = ["", "", "", "", "", "", ""];
$is_add_register = $config['cf_1'] ? true : false;
$is_add_character = $config['cf_2'] ? true : false;
$is_mod_character = $config['cf_3'] ? true : false;
$is_able_search = ($config['cf_4'] && $config['cf_6'] && $character['ch_search'] < $config['cf_search_count']) ? true : false;
function get_category_list($bo_table = '', $ca_name = '')
{
@ -62,7 +65,6 @@ function help($help = "")
return $str;
}
function upload_file($srcfile, $destfile, $dir)
{
if ($destfile == "")
@ -72,8 +74,6 @@ function upload_file($srcfile, $destfile, $dir)
return true;
}
function check_site_auth()
{
global $g5, $config, $is_member;
@ -234,6 +234,34 @@ function get_site_content($co_id)
return $result;
}
// 쪽지 보내기
function send_memo($se_mb_id, $re_mb_id, $memo_content)
{
global $g5, $config;
// 쪽지 INSERT
$tmp_row = sql_fetch(" select max(me_id) as max_me_id from {$g5['memo_table']} ");
$me_id = $tmp_row['max_me_id'] + 1;
$sql = " insert into {$g5['memo_table']}
set me_id = '{$me_id}',
me_recv_mb_id = '{$re_mb_id}',
me_send_mb_id = '{$se_mb_id}',
me_send_datetime = '" . G5_TIME_YMDHIS . "',
me_memo = '{$memo_content}'";
sql_query($sql);
$se_mb_name = get_member_name($se_mb_id);
// 실시간 쪽지 알림 기능
$sql = " update {$g5['member_table']}
set mb_memo_call = '" . $se_mb_name . "'
where mb_id = '{$re_mb_id}' ";
sql_query($sql);
return true;
}
function emote_ev($comment)
{
global $g5;

View file

@ -2,11 +2,6 @@
if (!defined('_GNUBOARD_'))
exit;
/*******************************************
경험치 부분
********************************************/
// 경험치 부여
function insert_exp($ch_id, $exp, $content = '', $rel_action = '')
{
global $config;

View file

@ -19,6 +19,7 @@ function get_status($ch_id, $st_id)
return $result;
}
function get_status_by_name($ch_id, $st_name)
{
global $g5;
@ -95,6 +96,7 @@ function set_status($ch_id, $st_id, $hunt, $msg = '')
return $message;
}
function set_status_by_name($ch_id, $st_name, $hunt, $msg = '')
{
global $g5;

View file

@ -9,6 +9,7 @@ function get_title($ti_id)
$ti = sql_fetch("select * from {$g5['title_table']} where ti_id = '{$ti_id}' and ti_use = 'Y'");
return $ti;
}
function get_title_value($ti_id)
{
global $g5;
@ -19,6 +20,7 @@ function get_title_value($ti_id)
return $result;
}
function get_title_image($ti_id)
{
global $g5;

View file

@ -1,7 +1,7 @@
<?php
include_once './_common.php';
$in = sql_fetch("select * from {$g5['inventory_table']} inven, {$g5['item_table']} item where inven.in_id = '{$in_id}' and inven.it_id = item.it_id");
$in = Item::getInventoryItem($in_id);
$ch = get_character($in['ch_id']);
$is_mine = $ch['mb_id'] == $character['mb_id'] ? true : false;

View file

@ -1,53 +1,26 @@
<?php
/**
* @var string|int $in_id
* @var string|int $in_memo
* @var string|int $add_sql
*/
include_once './_common.php';
if ($url) {
$return_url = urldecode($url);
} else {
$return_url = "./viewer.php?ch_id=" . $ch_id;
}
if (!$re_ch_id && $re_ch_name) {
$re_ch = get_character_by_name($re_ch_name);
} else {
$re_ch = get_character($re_ch_id);
}
$return_url = $url ? urldecode($url) : "./viewer.php?ch_id=" . $ch_id;
$re_ch = !$re_ch_id && $re_ch_name ? Character::getCharacterByName($re_ch_name) : Character::getCharacter($re_ch_id);
if (!$re_ch['ch_id']) {
alert("받는 사람의 정보를 확인할 수 없습니다.", $return_url);
}
if ($ch_id == $character['ch_id']) {
$se_ch = $character;
} else {
$se_ch = get_character($ch_id);
}
$in = sql_fetch("select * from {$g5['inventory_table']} inven, {$g5['item_table']} item where inven.in_id = '{$in_id}' and inven.it_id = item.it_id and inven.ch_id = '{$ch_id}'");
if (!$in['in_id']) {
alert("아이템 보유 정보를 확인할 수 없습니다.", $return_url);
}
$se_ch = $ch_id == $character['ch_id'] ? $character : Character::getCharacter($ch_id);
if ($in['in_id'] && $re_ch['ch_id']) {
$inven_sql = "update {$g5['inventory_table']}
set ch_id = '{$re_ch['ch_id']}',
ch_name = '{$re_ch['ch_name']}',
se_ch_id = '{$se_ch['ch_id']}',
se_ch_name = '{$se_ch['ch_name']}',
re_ch_id = '{$re_ch['ch_id']}',
re_ch_name = '{$re_ch['ch_name']}',
in_memo = '{$in_memo}'
{$add_sql}
where in_id = '{$in_id}'";
sql_query($inven_sql);
$recv_mb_id = $re_ch['mb_id'];
$memo_content = "[ " . $se_ch['ch_name'] . "님이 보내신 《" . $in['it_name'] . "》아이템이 도착 하였습니다. ] 캐릭터 인벤토리를 확인하세요.";
// 쪽지 보내기
send_memo($member['mb_id'], $recv_mb_id, $memo_content);
if (Item::sendItem($ch_id, $re_ch_id, $in_id, $in_memo)) {
alert($re_ch['ch_name'] . '님께 선물이 배송되었습니다.', $return_url, FALSE);
} else {
alert("아이템 보유 정보를 확인할 수 없습니다.", $return_url);
}
}
alert('사용 및 적용이 실패하였습니다.', $return_url);

View file

@ -19,12 +19,11 @@ for ($i; $row = sql_fetch_array($pe_inven_result); $i++) {
$inven_list[$p_count] = $row;
$p_count++;
}
$i = 0;
if (defined('G5_THEME_PATH') && is_file(G5_THEME_PATH . "/inventory/list.skin.php")) {
include(G5_THEME_PATH . "/inventory/list.skin.php");
include G5_THEME_PATH . "/inventory/list.skin.php";
} else {
include(G5_PATH . "/inventory/skin/list.skin.php");
include G5_PATH . "/inventory/skin/list.skin.php";
}

View file

@ -1822,7 +1822,6 @@ function referer_check($url = '')
*/
}
// 한글 요일
function get_yoil($date, $full = 0)
{
@ -1836,7 +1835,6 @@ function get_yoil($date, $full = 0)
return $str;
}
// 날짜를 select 박스 형식으로 얻는다
function date_select($date, $name = '')
{
@ -1884,7 +1882,6 @@ function date_select($date, $name = '')
return $s;
}
// 시간을 select 박스 형식으로 얻는다
// 1.04.00
// 경매에 시간 설정이 가능하게 되면서 추가함
@ -1928,7 +1925,6 @@ function time_select($time, $name = "")
return $s;
}
// DEMO 라는 파일이 있으면 데모 화면으로 인식함
function check_demo()
{
@ -1937,7 +1933,6 @@ function check_demo()
alert('데모 화면에서는 하실(보실) 수 없는 작업입니다.');
}
// 문자열이 한글, 영문, 숫자, 특수문자로 구성되어 있는지 검사
function check_string($str, $options)
{
@ -1989,7 +1984,6 @@ function check_string($str, $options)
return ($str == $s);
}
// 한글(2bytes)에서 마지막 글자가 1byte로 끝나는 경우
// 출력시 깨지는 현상이 발생하므로 마지막 완전하지 않은 글자(1byte)를 하나 없앰
function cut_hangul_last($hangul)
@ -2029,11 +2023,11 @@ function bad_tag_convert($code)
global $member, $is_admin;
if ($is_admin && $member['mb_id'] != $view['mb_id']) {
//$code = preg_replace_callback("#(\<(embed|object)[^\>]*)\>(\<\/(embed|object)\>)?#i",
// embed 또는 object 태그를 막지 않는 경우 필터링이 되도록 수정
$code = preg_replace_callback(
"#(\<(embed|object)[^\>]*)\>?(\<\/(embed|object)\>)?#i",
create_function('$matches', 'return "<div class=\"embedx\">보안문제로 인하여 관리자 아이디로는 embed 또는 object 태그를 볼 수 없습니다. 확인하시려면 관리권한이 없는 다른 아이디로 접속하세요.</div>";'),
function ($matches) {
return "<div class=\"embedx\">보안문제로 인하여 관리자 아이디로는 embed 또는 object 태그를 볼 수 없습니다. 확인하시려면 관리권한이 없는 다른 아이디로 접속하세요.</div>";
},
$code
);
}