Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
7a7338a9
Commit
7a7338a9
authored
Jun 15, 2025
by
Nemo Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup
parent
b7059e93
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1121 additions
and
0 deletions
+1121
-0
doc/etc/debug_archive/debug_ruleset_permission.php
doc/etc/debug_archive/debug_ruleset_permission.php
+0
-0
doc/etc/debug_archive/debug_template_loading.php
doc/etc/debug_archive/debug_template_loading.php
+129
-0
doc/etc/debug_archive/force_compile_nouveau_fixed.php
doc/etc/debug_archive/force_compile_nouveau_fixed.php
+119
-0
doc/etc/debug_archive/revevent_test.php
doc/etc/debug_archive/revevent_test.php
+90
-0
doc/etc/debug_archive/test_avatar_fix.php
doc/etc/debug_archive/test_avatar_fix.php
+0
-0
doc/etc/debug_archive/test_masterslave.php
doc/etc/debug_archive/test_masterslave.php
+131
-0
doc/etc/debug_archive/test_reverse_migration.php
doc/etc/debug_archive/test_reverse_migration.php
+123
-0
doc/etc/debug_archive/test_template_compile_fixed.php
doc/etc/debug_archive/test_template_compile_fixed.php
+115
-0
doc/etc/debug_archive/test_template_fix.php
doc/etc/debug_archive/test_template_fix.php
+132
-0
doc/etc/debug_archive/test_user_reverse_migration.php
doc/etc/debug_archive/test_user_reverse_migration.php
+144
-0
doc/etc/debug_archive/test_user_template_setting.php
doc/etc/debug_archive/test_user_template_setting.php
+138
-0
No files found.
debug_ruleset_permission.php
→
d
oc/etc/debug_archive/d
ebug_ruleset_permission.php
View file @
7a7338a9
File moved
doc/etc/debug_archive/debug_template_loading.php
0 → 100644
View file @
7a7338a9
<?php
// 调试模板加载过程
define
(
'CURSCRIPT'
,
'debug'
);
require
'./include/common.inc.php'
;
echo
"<pre>"
;
echo
"=== TEMPLATE LOADING DEBUG ===
\n\n
"
;
// 显示当前用户信息
echo
"User Information:
\n
"
;
echo
"cuser: "
.
(
$cuser
?
$cuser
:
'NOT LOGGED IN'
)
.
"
\n
"
;
echo
"udata exists: "
.
(
isset
(
$udata
)
&&
$udata
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
isset
(
$udata
)
&&
$udata
)
{
echo
"u_templateid: "
.
(
isset
(
$udata
[
'u_templateid'
])
?
$udata
[
'u_templateid'
]
:
'NOT SET'
)
.
"
\n
"
;
}
echo
"
\n
System Constants:
\n
"
;
echo
"TEMPLATEID: "
.
(
defined
(
'TEMPLATEID'
)
?
TEMPLATEID
:
'NOT DEFINED'
)
.
"
\n
"
;
echo
"TPLDIR: "
.
(
defined
(
'TPLDIR'
)
?
TPLDIR
:
'NOT DEFINED'
)
.
"
\n
"
;
echo
"tplrefresh: "
.
(
isset
(
$tplrefresh
)
?
$tplrefresh
:
'NOT SET'
)
.
"
\n
"
;
// 测试template函数的实际行为
echo
"
\n
=== TESTING TEMPLATE FUNCTION ===
\n
"
;
$test_files
=
[
'header'
,
'game'
,
'index'
];
foreach
(
$test_files
as
$test_file
)
{
echo
"
\n
Testing template:
$test_file
\n
"
;
// 直接调用template函数
$template_path
=
template
(
$test_file
);
echo
"Returned path:
$template_path
\n
"
;
echo
"File exists: "
.
(
file_exists
(
$template_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$template_path
))
{
echo
"File size: "
.
filesize
(
$template_path
)
.
" bytes
\n
"
;
// 检查文件内容的前几行来确认是哪个模板
$content
=
file_get_contents
(
$template_path
);
$first_lines
=
implode
(
"
\n
"
,
array_slice
(
explode
(
"
\n
"
,
$content
),
0
,
5
));
echo
"First few lines:
\n
"
.
htmlspecialchars
(
$first_lines
)
.
"
\n
"
;
}
// 检查对应的源文件
$source_nouveau
=
GAME_ROOT
.
'./templates/nouveau/'
.
$test_file
.
'.htm'
;
$source_default
=
GAME_ROOT
.
'./templates/default/'
.
$test_file
.
'.htm'
;
echo
"Nouveau source exists: "
.
(
file_exists
(
$source_nouveau
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
echo
"Default source exists: "
.
(
file_exists
(
$source_default
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 检查编译文件
$compiled_nouveau
=
GAME_ROOT
.
'./gamedata/templates/2_'
.
$test_file
.
'.tpl.php'
;
$compiled_default
=
GAME_ROOT
.
'./gamedata/templates/1_'
.
$test_file
.
'.tpl.php'
;
echo
"Nouveau compiled exists: "
.
(
file_exists
(
$compiled_nouveau
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
echo
"Default compiled exists: "
.
(
file_exists
(
$compiled_default
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$compiled_nouveau
)
&&
file_exists
(
$source_nouveau
))
{
$source_time
=
filemtime
(
$source_nouveau
);
$compiled_time
=
filemtime
(
$compiled_nouveau
);
echo
"Source newer than compiled: "
.
(
$source_time
>
$compiled_time
?
'YES'
:
'NO'
)
.
"
\n
"
;
echo
"Source time: "
.
date
(
'Y-m-d H:i:s'
,
$source_time
)
.
"
\n
"
;
echo
"Compiled time: "
.
date
(
'Y-m-d H:i:s'
,
$compiled_time
)
.
"
\n
"
;
}
}
// 手动测试不同templateid的template函数调用
echo
"
\n
=== MANUAL TEMPLATE ID TESTING ===
\n
"
;
foreach
([
1
,
2
]
as
$tid
)
{
$tdir
=
(
$tid
==
1
)
?
'./templates/default'
:
'./templates/nouveau'
;
echo
"
\n
Testing with templateid=
$tid
, tpldir=
$tdir
:
\n
"
;
$manual_path
=
template
(
'header'
,
$tid
,
$tdir
);
echo
"Returned path:
$manual_path
\n
"
;
echo
"File exists: "
.
(
file_exists
(
$manual_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 检查是否是预期的文件
$expected_file
=
GAME_ROOT
.
'./gamedata/templates/'
.
$tid
.
'_header.tpl.php'
;
echo
"Expected file:
$expected_file
\n
"
;
echo
"Matches expected: "
.
(
$manual_path
==
$expected_file
?
'YES'
:
'NO'
)
.
"
\n
"
;
}
// 检查gamedata/system.php中的模板设置逻辑
echo
"
\n
=== CHECKING SYSTEM.PHP LOGIC ===
\n
"
;
// 模拟不同的u_templateid值
$test_templateids
=
[
0
,
1
,
2
];
foreach
(
$test_templateids
as
$test_id
)
{
echo
"
\n
Simulating u_templateid =
$test_id
:
\n
"
;
$user_templateid
=
$test_id
;
// 复制gamedata/system.php中的逻辑
switch
(
$user_templateid
)
{
case
1
:
$sim_TEMPLATEID
=
1
;
$sim_TPLDIR
=
'./templates/luluxia'
;
echo
"Would set: LULUXIA template
\n
"
;
break
;
case
2
:
$sim_TEMPLATEID
=
2
;
$sim_TPLDIR
=
'./templates/nouveau'
;
echo
"Would set: NOUVEAU template
\n
"
;
break
;
default
:
$sim_TEMPLATEID
=
1
;
$sim_TPLDIR
=
'./templates/default'
;
echo
"Would set: DEFAULT template
\n
"
;
break
;
}
echo
"TEMPLATEID:
$sim_TEMPLATEID
\n
"
;
echo
"TPLDIR:
$sim_TPLDIR
\n
"
;
// 检查目录是否存在
$dir_path
=
GAME_ROOT
.
$sim_TPLDIR
;
echo
"Directory exists: "
.
(
is_dir
(
$dir_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
!
is_dir
(
$dir_path
)
&&
$sim_TPLDIR
!=
'./templates/default'
)
{
echo
"Would fallback to default template
\n
"
;
}
}
echo
"
\n
=== Debug completed ===
\n
"
;
echo
"</pre>"
;
?>
doc/etc/debug_archive/force_compile_nouveau_fixed.php
0 → 100644
View file @
7a7338a9
<?php
// 强制编译nouveau模板的所有文件 - 修复版本
define
(
'CURSCRIPT'
,
'force_compile'
);
require
'./include/common.inc.php'
;
echo
"<pre>"
;
echo
"=== FORCE COMPILE NOUVEAU TEMPLATES (FIXED) ===
\n\n
"
;
// 强制设置为nouveau模板
$nouveau_template_id
=
2
;
$nouveau_template_dir
=
'./templates/nouveau'
;
echo
"Forcing compilation for NOUVEAU template:
\n
"
;
echo
"Template ID:
$nouveau_template_id
\n
"
;
echo
"Template Dir:
$nouveau_template_dir
\n
"
;
echo
"GAME_ROOT: "
.
GAME_ROOT
.
"
\n\n
"
;
// 检查nouveau模板目录 - 修复路径拼接
$nouveau_dir
=
GAME_ROOT
.
$nouveau_template_dir
;
echo
"Nouveau directory:
$nouveau_dir
\n
"
;
echo
"Directory exists: "
.
(
is_dir
(
$nouveau_dir
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 如果还是不存在,尝试其他路径
if
(
!
is_dir
(
$nouveau_dir
))
{
$nouveau_dir_alt
=
GAME_ROOT
.
'./templates/nouveau'
;
echo
"Alternative path:
$nouveau_dir_alt
\n
"
;
echo
"Alternative exists: "
.
(
is_dir
(
$nouveau_dir_alt
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
is_dir
(
$nouveau_dir_alt
))
{
$nouveau_dir
=
$nouveau_dir_alt
;
echo
"Using alternative path.
\n
"
;
}
else
{
echo
"ERROR: Nouveau template directory not found!
\n
"
;
echo
"Checked paths:
\n
"
;
echo
" -
$nouveau_dir
\n
"
;
echo
" -
$nouveau_dir_alt
\n
"
;
exit
;
}
}
echo
"
\n
"
;
// 获取所有.htm文件
$htm_files
=
glob
(
$nouveau_dir
.
'/*.htm'
);
echo
"Found "
.
count
(
$htm_files
)
.
" .htm files in nouveau directory:
\n
"
;
foreach
(
$htm_files
as
$file
)
{
echo
" "
.
basename
(
$file
)
.
"
\n
"
;
}
echo
"
\n
"
;
if
(
count
(
$htm_files
)
==
0
)
{
echo
"ERROR: No .htm files found in nouveau directory!
\n
"
;
exit
;
}
require_once
GAME_ROOT
.
'./include/template.func.php'
;
$success_count
=
0
;
$error_count
=
0
;
foreach
(
$htm_files
as
$htm_file
)
{
$template_name
=
basename
(
$htm_file
,
'.htm'
);
echo
"Compiling:
$template_name
.htm
\n
"
;
try
{
// 强制编译
parse_template
(
$template_name
,
$nouveau_template_id
,
$nouveau_template_dir
);
// 检查编译结果
$compiled_file
=
GAME_ROOT
.
'./gamedata/templates/'
.
$nouveau_template_id
.
'_'
.
$template_name
.
'.tpl.php'
;
if
(
file_exists
(
$compiled_file
))
{
echo
" SUCCESS: "
.
basename
(
$compiled_file
)
.
" ("
.
filesize
(
$compiled_file
)
.
" bytes)
\n
"
;
$success_count
++
;
}
else
{
echo
" ERROR: Compiled file not created at
$compiled_file
\n
"
;
$error_count
++
;
}
}
catch
(
Exception
$e
)
{
echo
" ERROR: "
.
$e
->
getMessage
()
.
"
\n
"
;
$error_count
++
;
}
catch
(
Error
$e
)
{
echo
" FATAL: "
.
$e
->
getMessage
()
.
"
\n
"
;
$error_count
++
;
}
}
echo
"
\n
=== COMPILATION SUMMARY ===
\n
"
;
echo
"Total files processed: "
.
count
(
$htm_files
)
.
"
\n
"
;
echo
"Successful compilations:
$success_count
\n
"
;
echo
"Failed compilations:
$error_count
\n\n
"
;
// 列出所有nouveau编译文件
echo
"=== NOUVEAU COMPILED FILES ===
\n
"
;
$template_dir
=
GAME_ROOT
.
'./gamedata/templates/'
;
echo
"Template directory:
$template_dir
\n
"
;
echo
"Directory exists: "
.
(
is_dir
(
$template_dir
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
is_dir
(
$template_dir
))
{
$files
=
scandir
(
$template_dir
);
$nouveau_files
=
array_filter
(
$files
,
function
(
$file
)
use
(
$nouveau_template_id
)
{
return
strpos
(
$file
,
$nouveau_template_id
.
'_'
)
===
0
;
});
if
(
count
(
$nouveau_files
)
>
0
)
{
foreach
(
$nouveau_files
as
$file
)
{
$filepath
=
$template_dir
.
$file
;
echo
"
$file
("
.
filesize
(
$filepath
)
.
" bytes)
\n
"
;
}
}
else
{
echo
"(No nouveau compiled files found)
\n
"
;
}
}
else
{
echo
"(Template directory does not exist)
\n
"
;
}
echo
"
\n
=== Force compilation completed ===
\n
"
;
echo
"</pre>"
;
?>
doc/etc/debug_archive/revevent_test.php
0 → 100644
View file @
7a7338a9
<?php
define
(
'IN_GAME'
,
true
);
define
(
'GAME_ROOT'
,
'../'
);
include_once
'../include/global.func.php'
;
include_once
'../include/game/revevent.func.php'
;
// 创建测试玩家数据
$test_player
=
array
(
'name'
=>
'Test Player'
,
'clbpara'
=>
array
(
'randver1'
=>
64
,
// 中等值,应该每次提升2点
'randver2'
=>
150
,
// 中等值,应该每次提升50点
'charge1'
=>
0
,
'charge2'
=>
0
,
'charge3'
=>
0
,
'charge4'
=>
0
)
);
// 测试update_charge_values函数
echo
"测试 update_charge_values 函数:
\n
"
;
echo
"初始值: charge1=
{
$test_player
[
'clbpara'
][
'charge1'
]
}
, charge2=
{
$test_player
[
'clbpara'
][
'charge2'
]
}
, "
;
echo
"charge3=
{
$test_player
[
'clbpara'
][
'charge3'
]
}
, charge4=
{
$test_player
[
'clbpara'
][
'charge4'
]
}
\n
"
;
// 模拟5次移动或探索
for
(
$i
=
1
;
$i
<=
5
;
$i
++
)
{
update_charge_values
(
$test_player
);
echo
"第
{
$i
}
次更新后: charge1=
{
$test_player
[
'clbpara'
][
'charge1'
]
}
, charge2=
{
$test_player
[
'clbpara'
][
'charge2'
]
}
, "
;
echo
"charge3=
{
$test_player
[
'clbpara'
][
'charge3'
]
}
, charge4=
{
$test_player
[
'clbpara'
][
'charge4'
]
}
\n
"
;
}
// 测试get_charge_value函数
echo
"
\n
测试 get_charge_value 函数:
\n
"
;
$charge1
=
get_charge_value
(
$test_player
,
'charge1'
);
echo
"charge1 =
{
$charge1
}
\n
"
;
$all_charges
=
get_charge_value
(
$test_player
);
echo
"所有charge值: "
;
print_r
(
$all_charges
);
// 测试set_charge_value函数
echo
"
\n
测试 set_charge_value 函数:
\n
"
;
echo
"设置 charge1 = 100
\n
"
;
set_charge_value
(
$test_player
,
'charge1'
,
100
);
echo
"设置后 charge1 = "
.
get_charge_value
(
$test_player
,
'charge1'
)
.
"
\n
"
;
echo
"设置 charge1 = 200 (应该被限制为101)
\n
"
;
set_charge_value
(
$test_player
,
'charge1'
,
200
);
echo
"设置后 charge1 = "
.
get_charge_value
(
$test_player
,
'charge1'
)
.
"
\n
"
;
echo
"设置 charge3 = 200 (应该被限制为128)
\n
"
;
set_charge_value
(
$test_player
,
'charge3'
,
200
);
echo
"设置后 charge3 = "
.
get_charge_value
(
$test_player
,
'charge3'
)
.
"
\n
"
;
echo
"设置 charge3 = -200 (应该被限制为-128)
\n
"
;
set_charge_value
(
$test_player
,
'charge3'
,
-
200
);
echo
"设置后 charge3 = "
.
get_charge_value
(
$test_player
,
'charge3'
)
.
"
\n
"
;
echo
"设置 charge2 = 1000 (没有上限)
\n
"
;
set_charge_value
(
$test_player
,
'charge2'
,
1000
);
echo
"设置后 charge2 = "
.
get_charge_value
(
$test_player
,
'charge2'
)
.
"
\n
"
;
echo
"设置 charge4 = -5000 (没有下限)
\n
"
;
set_charge_value
(
$test_player
,
'charge4'
,
-
5000
);
echo
"设置后 charge4 = "
.
get_charge_value
(
$test_player
,
'charge4'
)
.
"
\n
"
;
// 测试边界情况
echo
"
\n
测试边界情况:
\n
"
;
$test_player
[
'clbpara'
][
'randver1'
]
=
1
;
// 最小值,应该每次提升1点
$test_player
[
'clbpara'
][
'randver2'
]
=
1
;
// 最小值,应该每次提升1点
$test_player
[
'clbpara'
][
'charge1'
]
=
99
;
// 接近上限
$test_player
[
'clbpara'
][
'charge3'
]
=
127
;
// 接近上限
echo
"设置极限值: randver1=1, randver2=1, charge1=99, charge3=127
\n
"
;
update_charge_values
(
$test_player
);
echo
"更新后: charge1=
{
$test_player
[
'clbpara'
][
'charge1'
]
}
, charge2=
{
$test_player
[
'clbpara'
][
'charge2'
]
}
, "
;
echo
"charge3=
{
$test_player
[
'clbpara'
][
'charge3'
]
}
, charge4=
{
$test_player
[
'clbpara'
][
'charge4'
]
}
\n
"
;
$test_player
[
'clbpara'
][
'randver1'
]
=
128
;
// 最大值,应该每次提升4点
$test_player
[
'clbpara'
][
'randver2'
]
=
256
;
// 最大值,应该每次提升100点
$test_player
[
'clbpara'
][
'charge1'
]
=
98
;
// 接近上限
$test_player
[
'clbpara'
][
'charge3'
]
=
-
127
;
// 接近下限
echo
"设置极限值: randver1=128, randver2=256, charge1=98, charge3=-127
\n
"
;
update_charge_values
(
$test_player
);
echo
"更新后: charge1=
{
$test_player
[
'clbpara'
][
'charge1'
]
}
, charge2=
{
$test_player
[
'clbpara'
][
'charge2'
]
}
, "
;
echo
"charge3=
{
$test_player
[
'clbpara'
][
'charge3'
]
}
, charge4=
{
$test_player
[
'clbpara'
][
'charge4'
]
}
\n
"
;
echo
"
\n
测试完成!
\n
"
;
?>
test_avatar_fix.php
→
doc/etc/debug_archive/
test_avatar_fix.php
View file @
7a7338a9
File moved
doc/etc/debug_archive/test_masterslave.php
0 → 100644
View file @
7a7338a9
<?php
/**
* 主从数据库同步功能测试脚本
* Master-Slave Database Sync Test Script
*/
define
(
'CURSCRIPT'
,
'test_masterslave'
);
require
'./include/common.inc.php'
;
require
'./include/masterslave.func.php'
;
echo
"<h2>主从数据库同步功能测试</h2>"
;
// 显示当前配置
echo
"<h3>当前配置</h3>"
;
echo
"从服务器级别 (slave_level): "
.
$slave_level
.
"<br>"
;
echo
"主服务器名称 (master_server_name): "
.
$master_server_name
.
"<br>"
;
echo
"主数据库服务器 (master_dbhost): "
.
$master_dbhost
.
"<br>"
;
echo
"主数据库名 (master_dbname): "
.
$master_dbname
.
"<br>"
;
echo
"主数据库表前缀 (master_tablepre): "
.
$master_tablepre
.
"<br>"
;
echo
"<hr>"
;
// 测试连接主数据库
echo
"<h3>测试主数据库连接</h3>"
;
if
(
$slave_level
>
0
)
{
$master_db
=
connect_master_db
();
if
(
$master_db
)
{
echo
"<span style='color: green;'>✓ 主数据库连接成功</span><br>"
;
// 测试查询主数据库用户表
$result
=
$master_db
->
query
(
"SELECT COUNT(*) as count FROM
{
$master_tablepre
}
users"
,
'SILENT'
);
if
(
!
$master_db
->
error
()
&&
$master_db
->
num_rows
(
$result
))
{
$count_data
=
$master_db
->
fetch_array
(
$result
);
echo
"主数据库用户数量: "
.
$count_data
[
'count'
]
.
"<br>"
;
}
else
{
echo
"<span style='color: orange;'>⚠ 无法查询主数据库用户表</span><br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 主数据库连接失败</span><br>"
;
}
}
else
{
echo
"<span style='color: blue;'>ℹ 当前为主服务器,无需连接主数据库</span><br>"
;
}
echo
"<hr>"
;
// 测试同步表创建
echo
"<h3>测试同步表</h3>"
;
create_sync_table_if_not_exists
();
$result
=
$db
->
query
(
"SHOW TABLES LIKE '
{
$gtablepre
}
user_sync'"
,
'SILENT'
);
if
(
$db
->
num_rows
(
$result
))
{
echo
"<span style='color: green;'>✓ 同步表存在</span><br>"
;
// 显示同步记录
$sync_result
=
$db
->
query
(
"SELECT * FROM
{
$gtablepre
}
user_sync ORDER BY sync_time DESC LIMIT 5"
);
if
(
$db
->
num_rows
(
$sync_result
))
{
echo
"<h4>最近的同步记录:</h4>"
;
echo
"<table border='1' cellpadding='5'>"
;
echo
"<tr><th>目标用户名</th><th>主服务器用户名</th><th>同步时间</th></tr>"
;
while
(
$sync_data
=
$db
->
fetch_array
(
$sync_result
))
{
echo
"<tr>"
;
echo
"<td>"
.
htmlspecialchars
(
$sync_data
[
'target_username'
])
.
"</td>"
;
echo
"<td>"
.
htmlspecialchars
(
$sync_data
[
'master_username'
])
.
"</td>"
;
echo
"<td>"
.
date
(
'Y-m-d H:i:s'
,
$sync_data
[
'sync_time'
])
.
"</td>"
;
echo
"</tr>"
;
}
echo
"</table>"
;
}
else
{
echo
"暂无同步记录<br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 同步表不存在</span><br>"
;
}
echo
"<hr>"
;
// 功能状态检查
echo
"<h3>功能状态检查</h3>"
;
echo
"是否需要自动同步: "
.
(
should_auto_sync
()
?
"<span style='color: green;'>是</span>"
:
"<span style='color: gray;'>否</span>"
)
.
"<br>"
;
echo
"是否直接使用主数据库: "
.
(
should_use_master_db
()
?
"<span style='color: green;'>是</span>"
:
"<span style='color: gray;'>否</span>"
)
.
"<br>"
;
if
(
$slave_level
>=
1
&&
!
empty
(
$master_server_name
))
{
echo
"主从同步功能: <span style='color: green;'>已启用</span><br>"
;
}
else
{
echo
"主从同步功能: <span style='color: gray;'>未启用</span><br>"
;
}
// 显示当前使用的数据库表前缀
echo
"当前游戏表前缀 (gtablepre): "
.
$gtablepre
.
"<br>"
;
if
(
$slave_level
==
3
)
{
echo
"<span style='color: blue;'>ℹ 当前直接使用主数据库</span><br>"
;
}
echo
"<hr>"
;
// 测试表单(仅在从服务器模式下显示)
if
(
$slave_level
>=
1
&&
!
empty
(
$master_server_name
))
{
echo
"<h3>测试同步功能</h3>"
;
echo
"<form method='post' action='test_masterslave.php'>"
;
echo
"<table>"
;
echo
"<tr><td>主服务器用户名:</td><td><input type='text' name='test_master_username' size='20'></td></tr>"
;
echo
"<tr><td>主服务器密码:</td><td><input type='password' name='test_master_password' size='20'></td></tr>"
;
echo
"<tr><td>目标用户名:</td><td><input type='text' name='test_target_username' size='20' placeholder='留空使用主服务器用户名'></td></tr>"
;
echo
"<tr><td colspan='2'><input type='submit' name='test_sync' value='测试同步'></td></tr>"
;
echo
"</table>"
;
echo
"</form>"
;
// 处理测试同步
if
(
isset
(
$_POST
[
'test_sync'
]))
{
$test_master_username
=
$_POST
[
'test_master_username'
];
$test_master_password
=
$_POST
[
'test_master_password'
];
$test_target_username
=
$_POST
[
'test_target_username'
]
?:
$test_master_username
;
if
(
$test_master_username
&&
$test_master_password
)
{
echo
"<h4>同步测试结果:</h4>"
;
$sync_result
=
sync_user_from_master
(
$test_master_username
,
$test_master_password
,
$test_target_username
);
if
(
$sync_result
[
'success'
])
{
echo
"<span style='color: green;'>✓ "
.
htmlspecialchars
(
$sync_result
[
'message'
])
.
"</span><br>"
;
}
else
{
echo
"<span style='color: red;'>✗ "
.
htmlspecialchars
(
$sync_result
[
'message'
])
.
"</span><br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 请输入用户名和密码</span><br>"
;
}
}
}
echo
"<hr>"
;
echo
"<p><a href='admin.php'>返回管理界面</a> | <a href='user.php'>用户资料</a> | <a href='index.php'>游戏首页</a></p>"
;
?>
doc/etc/debug_archive/test_reverse_migration.php
0 → 100644
View file @
7a7338a9
<?php
/**
* 反向迁移功能测试文件
* Test file for reverse migration functionality
*/
define
(
'CURSCRIPT'
,
'test_reverse_migration'
);
// 包含必要的文件
require
'./include/common.inc.php'
;
require
'./include/masterslave.func.php'
;
// 添加基本的访问控制 - 只允许管理员访问测试页面
if
(
!
$cuser
||
!
$udata
||
$udata
[
'groupid'
]
<
9
)
{
exit
(
'Access Denied - 仅管理员可访问测试页面'
);
}
echo
"<h2>反向迁移功能测试</h2>"
;
echo
"<p style='color: #666; font-size: 12px;'>当前登录用户:
{
$cuser
}
(管理员权限)</p>"
;
// 检查当前配置
echo
"<h3>当前配置状态:</h3>"
;
echo
"Slave Level:
$slave_level
<br>"
;
echo
"Master Server Name:
$master_server_name
<br>"
;
echo
"Master DB Host:
$master_dbhost
<br>"
;
echo
"Master DB Name:
$master_dbname
<br>"
;
// 检查是否为反向迁移模式
if
(
is_reverse_migration_mode
())
{
echo
"<span style='color: green;'>✓ 当前处于反向迁移模式</span><br>"
;
// 测试远端从数据库连接
echo
"<h3>远端从数据库连接测试:</h3>"
;
$slave_db
=
connect_master_db
();
// 复用连接函数,实际连接的是远端从数据库
if
(
$slave_db
)
{
echo
"<span style='color: green;'>✓ 远端从数据库连接成功</span><br>"
;
// 查询远端从数据库用户数量
$result
=
$slave_db
->
query
(
"SELECT COUNT(*) as count FROM
{
$master_tablepre
}
users"
);
if
(
$result
&&
$slave_db
->
num_rows
(
$result
))
{
$data
=
$slave_db
->
fetch_array
(
$result
);
echo
"远端从数据库用户数量:
{
$data
[
'count'
]
}
<br>"
;
}
// 查询远端从数据库玩家数量
$result
=
$slave_db
->
query
(
"SELECT COUNT(*) as count FROM
{
$master_tablepre
}
players WHERE type = 0"
);
if
(
$result
&&
$slave_db
->
num_rows
(
$result
))
{
$data
=
$slave_db
->
fetch_array
(
$result
);
echo
"远端从数据库玩家角色数量:
{
$data
[
'count'
]
}
<br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 远端从数据库连接失败</span><br>"
;
}
// 检查反向迁移表
echo
"<h3>反向迁移表状态:</h3>"
;
create_reverse_migration_table_if_not_exists
();
$result
=
$db
->
query
(
"SHOW TABLES LIKE '
{
$gtablepre
}
reverse_migration'"
);
if
(
$db
->
num_rows
(
$result
))
{
echo
"<span style='color: green;'>✓ 反向迁移表已存在</span><br>"
;
// 查询已迁移的记录
$result
=
$db
->
query
(
"SELECT COUNT(*) as count FROM
{
$gtablepre
}
reverse_migration"
);
if
(
$result
&&
$db
->
num_rows
(
$result
))
{
$data
=
$db
->
fetch_array
(
$result
);
echo
"已记录的反向迁移数量:
{
$data
[
'count'
]
}
<br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 反向迁移表不存在</span><br>"
;
}
// 显示测试表单
echo
"<h3>反向迁移测试:</h3>"
;
if
(
isset
(
$_POST
[
'test_reverse_migrate'
]))
{
$test_local_username
=
$_POST
[
'test_local_username'
];
$test_remote_username
=
$_POST
[
'test_remote_username'
];
$test_remote_password
=
$_POST
[
'test_remote_password'
];
$test_target_username
=
$_POST
[
'test_target_username'
]
?:
$test_remote_username
;
if
(
$test_local_username
&&
$test_remote_username
&&
$test_remote_password
)
{
echo
"<h4>反向迁移测试结果:</h4>"
;
$migrate_result
=
reverse_migrate_user
(
$test_local_username
,
$test_remote_username
,
$test_remote_password
,
$test_target_username
);
if
(
$migrate_result
[
'success'
])
{
echo
"<span style='color: green;'>✓ "
.
htmlspecialchars
(
$migrate_result
[
'message'
])
.
"</span><br>"
;
}
else
{
echo
"<span style='color: red;'>✗ "
.
htmlspecialchars
(
$migrate_result
[
'message'
])
.
"</span><br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 请输入完整的用户名和密码信息</span><br>"
;
}
}
echo
'<form method="post">'
;
echo
'<table border="1" style="margin: 10px 0;">'
;
echo
'<tr><td>本地用户名:</td><td><input type="text" name="test_local_username" placeholder="本地用户名" required></td></tr>'
;
echo
'<tr><td>远端用户名:</td><td><input type="text" name="test_remote_username" placeholder="远端从服务器用户名" required></td></tr>'
;
echo
'<tr><td>远端密码:</td><td><input type="password" name="test_remote_password" placeholder="远端从服务器密码" required></td></tr>'
;
echo
'<tr><td>目标用户名:</td><td><input type="text" name="test_target_username" placeholder="留空则使用远端用户名"></td></tr>'
;
echo
'<tr><td colspan="2"><input type="submit" name="test_reverse_migrate" value="测试反向迁移"></td></tr>'
;
echo
'</table>'
;
echo
'</form>'
;
}
else
{
echo
"<span style='color: orange;'>⚠ 当前不是反向迁移模式 (slave_level =
$slave_level
)</span><br>"
;
echo
"要启用反向迁移功能,请将 config.inc.php 中的
\$
slave_level 设置为 -1<br>"
;
}
// 查询本地数据库状态
echo
"<h3>本地数据库状态:</h3>"
;
$result
=
$db
->
query
(
"SELECT COUNT(*) as count FROM
{
$gtablepre
}
users"
);
if
(
$result
&&
$db
->
num_rows
(
$result
))
{
$data
=
$db
->
fetch_array
(
$result
);
echo
"本地用户数量:
{
$data
[
'count'
]
}
<br>"
;
}
$result
=
$db
->
query
(
"SELECT COUNT(*) as count FROM
{
$tablepre
}
players WHERE type = 0"
);
if
(
$result
&&
$db
->
num_rows
(
$result
))
{
$data
=
$db
->
fetch_array
(
$result
);
echo
"本地玩家角色数量:
{
$data
[
'count'
]
}
<br>"
;
}
echo
"<br><a href='admin.php'>返回管理后台</a>"
;
?>
doc/etc/debug_archive/test_template_compile_fixed.php
0 → 100644
View file @
7a7338a9
<?php
// 测试nouveau模板编译功能 - 修复版本
define
(
'CURSCRIPT'
,
'test'
);
require
'./include/common.inc.php'
;
echo
"<pre>"
;
echo
"=== NOUVEAU TEMPLATE COMPILATION TEST (FIXED) ===
\n\n
"
;
// 显示当前配置
echo
"Current Configuration:
\n
"
;
echo
"TEMPLATEID: "
.
TEMPLATEID
.
"
\n
"
;
echo
"TPLDIR: "
.
TPLDIR
.
"
\n
"
;
echo
"tplrefresh: "
.
$tplrefresh
.
"
\n
"
;
echo
"GAME_ROOT: "
.
GAME_ROOT
.
"
\n\n
"
;
// 检查gamedata/templates目录
echo
"Checking gamedata/templates directory:
\n
"
;
$template_dir
=
GAME_ROOT
.
'./gamedata/templates/'
;
echo
"Template directory: "
.
$template_dir
.
"
\n
"
;
echo
"Directory exists: "
.
(
is_dir
(
$template_dir
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
echo
"Directory writable: "
.
(
is_writable
(
$template_dir
)
?
'YES'
:
'NO'
)
.
"
\n\n
"
;
// 测试不同模板ID的编译
$test_templates
=
[
'header'
,
'game'
,
'index'
];
$test_template_ids
=
[
1
,
2
];
// 默认模板和nouveau模板
foreach
(
$test_template_ids
as
$tid
)
{
$tdir
=
(
$tid
==
1
)
?
'./templates/default'
:
'./templates/nouveau'
;
echo
"=== Testing Template ID:
$tid
(
$tdir
) ===
\n
"
;
foreach
(
$test_templates
as
$template_name
)
{
echo
"
\n
Testing template:
$template_name
\n
"
;
// 检查源文件 - 修复路径拼接
$source_file
=
GAME_ROOT
.
$tdir
.
'/'
.
$template_name
.
'.htm'
;
echo
"Source file:
$source_file
\n
"
;
echo
"Source exists: "
.
(
file_exists
(
$source_file
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$source_file
))
{
// 尝试编译
require_once
GAME_ROOT
.
'./include/template.func.php'
;
try
{
error_reporting
(
E_ALL
);
ini_set
(
'display_errors'
,
1
);
parse_template
(
$template_name
,
$tid
,
$tdir
);
echo
"Compilation: SUCCESS
\n
"
;
// 检查编译后的文件
$compiled_file
=
GAME_ROOT
.
'./gamedata/templates/'
.
$tid
.
'_'
.
$template_name
.
'.tpl.php'
;
echo
"Compiled file:
$compiled_file
\n
"
;
echo
"Compiled exists: "
.
(
file_exists
(
$compiled_file
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$compiled_file
))
{
echo
"File size: "
.
filesize
(
$compiled_file
)
.
" bytes
\n
"
;
}
}
catch
(
Exception
$e
)
{
echo
"Compilation ERROR: "
.
$e
->
getMessage
()
.
"
\n
"
;
}
catch
(
Error
$e
)
{
echo
"Compilation FATAL: "
.
$e
->
getMessage
()
.
"
\n
"
;
}
}
else
{
echo
"Source file not found, skipping compilation.
\n
"
;
}
}
echo
"
\n
"
;
}
// 列出所有编译后的文件
echo
"=== All compiled template files ===
\n
"
;
if
(
is_dir
(
$template_dir
))
{
$files
=
scandir
(
$template_dir
);
$found_files
=
false
;
foreach
(
$files
as
$file
)
{
if
(
$file
!=
'.'
&&
$file
!=
'..'
)
{
$filepath
=
$template_dir
.
$file
;
echo
"
$file
("
.
filesize
(
$filepath
)
.
" bytes)
\n
"
;
$found_files
=
true
;
}
}
if
(
!
$found_files
)
{
echo
"(No compiled files found)
\n
"
;
}
}
else
{
echo
"(Template directory does not exist)
\n
"
;
}
// 额外检查:显示所有模板目录的状态
echo
"
\n
=== Template Directories Status ===
\n
"
;
$template_dirs
=
[
'default'
,
'nouveau'
,
'luluxia'
];
foreach
(
$template_dirs
as
$dir
)
{
$dir_path
=
GAME_ROOT
.
"./templates/
$dir
"
;
echo
"Template '
$dir
':
\n
"
;
echo
" Path:
$dir_path
\n
"
;
echo
" Exists: "
.
(
is_dir
(
$dir_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
is_dir
(
$dir_path
))
{
$htm_files
=
glob
(
$dir_path
.
'/*.htm'
);
echo
" .htm files: "
.
count
(
$htm_files
)
.
"
\n
"
;
if
(
count
(
$htm_files
)
>
0
&&
count
(
$htm_files
)
<=
10
)
{
foreach
(
$htm_files
as
$file
)
{
echo
" "
.
basename
(
$file
)
.
"
\n
"
;
}
}
elseif
(
count
(
$htm_files
)
>
10
)
{
echo
" (Too many files to list: "
.
count
(
$htm_files
)
.
")
\n
"
;
}
}
echo
"
\n
"
;
}
echo
"=== Test completed ===
\n
"
;
echo
"</pre>"
;
?>
doc/etc/debug_archive/test_template_fix.php
0 → 100644
View file @
7a7338a9
<?php
// 测试模板修复是否有效
define
(
'CURSCRIPT'
,
'template_fix_test'
);
require
'./include/common.inc.php'
;
echo
"<pre>"
;
echo
"=== TEMPLATE FIX VERIFICATION ===
\n\n
"
;
// 显示用户信息
echo
"User Information:
\n
"
;
echo
"cuser: "
.
(
$cuser
?
$cuser
:
'NOT LOGGED IN'
)
.
"
\n
"
;
echo
"udata exists: "
.
(
isset
(
$udata
)
&&
$udata
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
isset
(
$udata
)
&&
$udata
)
{
echo
"u_templateid: "
.
(
isset
(
$udata
[
'u_templateid'
])
?
$udata
[
'u_templateid'
]
:
'NOT SET'
)
.
"
\n
"
;
}
// 显示系统常量
echo
"
\n
System Constants:
\n
"
;
echo
"TEMPLATEID: "
.
(
defined
(
'TEMPLATEID'
)
?
TEMPLATEID
:
'NOT DEFINED'
)
.
"
\n
"
;
echo
"TPLDIR: "
.
(
defined
(
'TPLDIR'
)
?
TPLDIR
:
'NOT DEFINED'
)
.
"
\n
"
;
// 显示覆盖变量
echo
"
\n
Override Variables:
\n
"
;
global
$TEMPLATEID_OVERRIDE
,
$TPLDIR_OVERRIDE
;
echo
"TEMPLATEID_OVERRIDE: "
.
(
isset
(
$TEMPLATEID_OVERRIDE
)
?
$TEMPLATEID_OVERRIDE
:
'NOT SET'
)
.
"
\n
"
;
echo
"TPLDIR_OVERRIDE: "
.
(
isset
(
$TPLDIR_OVERRIDE
)
?
$TPLDIR_OVERRIDE
:
'NOT SET'
)
.
"
\n
"
;
// 测试template函数
echo
"
\n
=== TESTING TEMPLATE FUNCTION ===
\n
"
;
$test_files
=
[
'header'
,
'game'
];
foreach
(
$test_files
as
$test_file
)
{
echo
"
\n
Testing template:
$test_file
\n
"
;
$template_path
=
template
(
$test_file
);
echo
"Returned path:
$template_path
\n
"
;
echo
"File exists: "
.
(
file_exists
(
$template_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$template_path
))
{
echo
"File size: "
.
filesize
(
$template_path
)
.
" bytes
\n
"
;
// 检查是否是nouveau模板(通过文件大小判断)
$is_nouveau
=
(
filesize
(
$template_path
)
>
10000
);
// nouveau模板文件通常更大
echo
"Appears to be nouveau template: "
.
(
$is_nouveau
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 检查文件内容的前几行
$content
=
file_get_contents
(
$template_path
);
if
(
strpos
(
$content
,
'nouveau'
)
!==
false
||
strpos
(
$content
,
'cyber'
)
!==
false
)
{
echo
"Contains nouveau/cyber keywords: YES
\n
"
;
}
else
{
echo
"Contains nouveau/cyber keywords: NO
\n
"
;
}
}
}
// 手动测试不同参数的template函数调用
echo
"
\n
=== MANUAL TEMPLATE TESTING ===
\n
"
;
// 测试默认调用
echo
"
\n
Default template() call:
\n
"
;
$default_path
=
template
(
'header'
);
echo
"Path:
$default_path
\n
"
;
// 测试强制nouveau模板
echo
"
\n
Forced nouveau template() call:
\n
"
;
$nouveau_path
=
template
(
'header'
,
2
,
'./templates/nouveau'
);
echo
"Path:
$nouveau_path
\n
"
;
// 比较两个路径
echo
"
\n
Comparison:
\n
"
;
echo
"Default and nouveau paths are different: "
.
(
$default_path
!=
$nouveau_path
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 检查实际使用的模板ID和目录
echo
"
\n
=== EFFECTIVE TEMPLATE SETTINGS ===
\n
"
;
// 模拟template函数内部逻辑
global
$TEMPLATEID_OVERRIDE
,
$TPLDIR_OVERRIDE
;
$effective_templateid
=
isset
(
$TEMPLATEID_OVERRIDE
)
&&
$TEMPLATEID_OVERRIDE
?
$TEMPLATEID_OVERRIDE
:
TEMPLATEID
;
$effective_tpldir
=
isset
(
$TPLDIR_OVERRIDE
)
&&
$TPLDIR_OVERRIDE
?
$TPLDIR_OVERRIDE
:
TPLDIR
;
echo
"Effective TEMPLATEID:
$effective_templateid
\n
"
;
echo
"Effective TPLDIR:
$effective_tpldir
\n
"
;
// 检查对应的编译文件
$expected_compiled
=
GAME_ROOT
.
'./gamedata/templates/'
.
$effective_templateid
.
'_header.tpl.php'
;
echo
"Expected compiled file:
$expected_compiled
\n
"
;
echo
"Expected file exists: "
.
(
file_exists
(
$expected_compiled
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$expected_compiled
))
{
echo
"Expected file size: "
.
filesize
(
$expected_compiled
)
.
" bytes
\n
"
;
}
// 最终验证
echo
"
\n
=== FINAL VERIFICATION ===
\n
"
;
if
(
isset
(
$udata
)
&&
$udata
&&
isset
(
$udata
[
'u_templateid'
])
&&
$udata
[
'u_templateid'
]
==
2
)
{
echo
"User has nouveau template selected (u_templateid=2)
\n
"
;
if
(
isset
(
$TEMPLATEID_OVERRIDE
)
&&
$TEMPLATEID_OVERRIDE
==
2
)
{
echo
"✓ TEMPLATEID_OVERRIDE correctly set to 2
\n
"
;
}
else
{
echo
"✗ TEMPLATEID_OVERRIDE not set correctly
\n
"
;
}
if
(
isset
(
$TPLDIR_OVERRIDE
)
&&
$TPLDIR_OVERRIDE
==
'./templates/nouveau'
)
{
echo
"✓ TPLDIR_OVERRIDE correctly set to nouveau
\n
"
;
}
else
{
echo
"✗ TPLDIR_OVERRIDE not set correctly
\n
"
;
}
$header_path
=
template
(
'header'
);
if
(
strpos
(
$header_path
,
'2_header.tpl.php'
)
!==
false
)
{
echo
"✓ template() function returns nouveau compiled file
\n
"
;
}
else
{
echo
"✗ template() function does not return nouveau compiled file
\n
"
;
}
if
(
file_exists
(
$header_path
)
&&
filesize
(
$header_path
)
>
10000
)
{
echo
"✓ Nouveau template file exists and appears to be correct size
\n
"
;
echo
"SUCCESS: Nouveau template should be working!
\n
"
;
}
else
{
echo
"✗ Nouveau template file missing or incorrect
\n
"
;
}
}
else
{
echo
"User does not have nouveau template selected
\n
"
;
}
echo
"
\n
=== Test completed ===
\n
"
;
echo
"</pre>"
;
?>
doc/etc/debug_archive/test_user_reverse_migration.php
0 → 100644
View file @
7a7338a9
<?php
/**
* 用户端反向迁移功能测试文件
* Test file for user-side reverse migration functionality
*/
define
(
'CURSCRIPT'
,
'test_user_reverse_migration'
);
// 包含必要的文件
require
'./include/common.inc.php'
;
require
'./include/masterslave.func.php'
;
// 添加基本的访问控制 - 只允许管理员访问测试页面
if
(
!
$cuser
||
!
$udata
||
$udata
[
'groupid'
]
<
9
)
{
exit
(
'Access Denied - 仅管理员可访问测试页面'
);
}
echo
"<h2>用户端反向迁移功能测试</h2>"
;
echo
"<p style='color: #666; font-size: 12px;'>当前登录用户:
{
$cuser
}
(管理员权限)</p>"
;
// 检查当前配置
echo
"<h3>当前配置状态:</h3>"
;
echo
"Slave Level:
$slave_level
<br>"
;
echo
"Master Server Name:
$master_server_name
<br>"
;
// 检查是否为反向迁移模式
if
(
is_reverse_migration_mode
())
{
echo
"<span style='color: green;'>✓ 当前处于反向迁移模式</span><br>"
;
echo
"<span style='color: blue;'>ℹ 用户可以在个人资料页面看到反向迁移功能</span><br>"
;
// 模拟用户界面变量设置
$show_sync_button
=
(
$slave_level
>=
1
&&
!
empty
(
$master_server_name
));
$show_reverse_migrate_button
=
(
is_reverse_migration_mode
()
&&
!
empty
(
$master_server_name
));
echo
"<h3>界面显示状态:</h3>"
;
echo
"显示正向同步按钮: "
.
(
$show_sync_button
&&
!
$show_reverse_migrate_button
?
"<span style='color: green;'>是</span>"
:
"<span style='color: red;'>否</span>"
)
.
"<br>"
;
echo
"显示反向迁移按钮: "
.
(
$show_reverse_migrate_button
?
"<span style='color: green;'>是</span>"
:
"<span style='color: red;'>否</span>"
)
.
"<br>"
;
// 测试主数据库连接
echo
"<h3>主数据库连接测试:</h3>"
;
$master_db
=
connect_master_db
();
if
(
$master_db
)
{
echo
"<span style='color: green;'>✓ 主数据库连接成功</span><br>"
;
// 查询主数据库用户数量
$result
=
$master_db
->
query
(
"SELECT COUNT(*) as count FROM
{
$master_tablepre
}
users"
);
if
(
$result
&&
$master_db
->
num_rows
(
$result
))
{
$data
=
$master_db
->
fetch_array
(
$result
);
echo
"主数据库用户数量:
{
$data
[
'count'
]
}
<br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 主数据库连接失败</span><br>"
;
}
// 检查反向迁移表
echo
"<h3>反向迁移表状态:</h3>"
;
create_reverse_migration_table_if_not_exists
();
$result
=
$db
->
query
(
"SHOW TABLES LIKE '
{
$gtablepre
}
reverse_migration'"
);
if
(
$db
->
num_rows
(
$result
))
{
echo
"<span style='color: green;'>✓ 反向迁移表已存在</span><br>"
;
// 查询已迁移的记录
$result
=
$db
->
query
(
"SELECT * FROM
{
$gtablepre
}
reverse_migration ORDER BY sync_time DESC LIMIT 5"
);
if
(
$result
&&
$db
->
num_rows
(
$result
))
{
echo
"<h4>最近的反向迁移记录:</h4>"
;
echo
"<table border='1' style='border-collapse: collapse;'>"
;
echo
"<tr><th>目标用户名</th><th>主服务器用户名</th><th>迁移时间</th></tr>"
;
while
(
$row
=
$db
->
fetch_array
(
$result
))
{
$sync_time_formatted
=
date
(
'Y-m-d H:i:s'
,
$row
[
'sync_time'
]);
echo
"<tr><td>
{
$row
[
'target_username'
]
}
</td><td>
{
$row
[
'master_username'
]
}
</td><td>
$sync_time_formatted
</td></tr>"
;
}
echo
"</table>"
;
}
else
{
echo
"暂无反向迁移记录<br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 反向迁移表不存在</span><br>"
;
}
// 显示用户端测试表单
echo
"<h3>用户端反向迁移测试:</h3>"
;
if
(
isset
(
$_POST
[
'test_user_reverse_migrate'
]))
{
$test_local_username
=
$_POST
[
'test_local_username'
];
$test_remote_username
=
$_POST
[
'test_remote_username'
];
$test_remote_password
=
$_POST
[
'test_remote_password'
];
$test_target_username
=
$_POST
[
'test_target_username'
]
?:
$test_remote_username
;
if
(
$test_local_username
&&
$test_remote_username
&&
$test_remote_password
)
{
echo
"<h4>用户端反向迁移测试结果:</h4>"
;
// 模拟用户端调用
$migrate_result
=
reverse_migrate_user
(
$test_local_username
,
$test_remote_username
,
md5
(
$test_remote_password
),
$test_target_username
);
if
(
$migrate_result
[
'success'
])
{
echo
"<span style='color: green;'>✓ "
.
htmlspecialchars
(
$migrate_result
[
'message'
])
.
"</span><br>"
;
// 检查迁移状态
$migrate_status
=
get_reverse_migration_status
(
$test_target_username
);
if
(
$migrate_status
)
{
echo
"<span style='color: blue;'>ℹ 迁移记录已创建,时间:"
.
date
(
'Y-m-d H:i:s'
,
$migrate_status
[
'sync_time'
])
.
"</span><br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ "
.
htmlspecialchars
(
$migrate_result
[
'message'
])
.
"</span><br>"
;
}
}
else
{
echo
"<span style='color: red;'>✗ 请输入完整的用户名和密码信息</span><br>"
;
}
}
echo
'<form method="post">'
;
echo
'<table border="1" style="margin: 10px 0; border-collapse: collapse;">'
;
echo
'<tr><td style="padding: 5px;">本地用户名:</td><td style="padding: 5px;"><input type="text" name="test_local_username" placeholder="本地用户名" required></td></tr>'
;
echo
'<tr><td style="padding: 5px;">远端用户名:</td><td style="padding: 5px;"><input type="text" name="test_remote_username" placeholder="远端从服务器用户名" required></td></tr>'
;
echo
'<tr><td style="padding: 5px;">远端密码:</td><td style="padding: 5px;"><input type="password" name="test_remote_password" placeholder="远端从服务器密码" required></td></tr>'
;
echo
'<tr><td style="padding: 5px;">目标用户名:</td><td style="padding: 5px;"><input type="text" name="test_target_username" placeholder="留空则使用远端用户名"></td></tr>'
;
echo
'<tr><td colspan="2" style="padding: 5px; text-align: center;"><input type="submit" name="test_user_reverse_migrate" value="测试用户端反向迁移" style="padding: 5px 10px; background-color: #FF6347; color: white; border: none; border-radius: 3px;"></td></tr>'
;
echo
'</table>'
;
echo
'</form>'
;
echo
"<h3>用户界面预览:</h3>"
;
echo
"<div style='border: 1px solid #ccc; padding: 10px; background-color: #f9f9f9;'>"
;
echo
"<strong>在用户个人资料页面会显示:</strong><br>"
;
echo
"<div style='margin-top: 10px; padding: 15px; border: 2px solid #FF6347; background-color: #FFF5EE; border-radius: 5px; max-width: 500px;'>"
;
echo
"<div style='text-align: center; font-weight: bold; color: #CD5C5C; margin-bottom: 10px;'>反向迁移功能 (推送到远端从服务器)</div>"
;
echo
"<div style='text-align: center; font-size: 12px; color: #8B4513; margin-bottom: 10px;'>当前模式:反向迁移模式 | 目标服务器:
$master_server_name
</div>"
;
echo
"<div style='text-align: center;'>"
;
echo
"<input type='text' placeholder='在
{
$master_server_name
}
的用户名' style='margin: 2px; padding: 3px;'><br>"
;
echo
"<input type='password' placeholder='在
{
$master_server_name
}
的密码' style='margin: 2px; padding: 3px;'><br>"
;
echo
"<button style='margin: 5px; padding: 8px 15px; background-color: #FF6347; color: white; border: 1px solid #CD5C5C; border-radius: 3px;'>推送到
{
$master_server_name
}
</button>"
;
echo
"</div>"
;
echo
"<div style='margin-top: 10px; text-align: center; font-size: 11px; color: #888;'>注意:反向迁移将把您的本地账户数据推送到远端从服务器
{
$master_server_name
}
,需要在远端服务器有有效账户进行身份验证。本地数据不会受影响。</div>"
;
echo
"</div>"
;
echo
"</div>"
;
}
else
{
echo
"<span style='color: orange;'>⚠ 当前不是反向迁移模式 (slave_level =
$slave_level
)</span><br>"
;
echo
"要启用用户端反向迁移功能,请将 config.inc.php 中的
\$
slave_level 设置为 -1<br>"
;
if
(
$slave_level
>=
1
)
{
echo
"<span style='color: blue;'>ℹ 当前是正向同步模式,用户可以看到正向同步功能</span><br>"
;
}
}
echo
"<br><a href='user.php'>查看用户个人资料页面</a> | <a href='admin.php'>返回管理后台</a>"
;
?>
doc/etc/debug_archive/test_user_template_setting.php
0 → 100644
View file @
7a7338a9
<?php
// 测试用户模板设置
define
(
'CURSCRIPT'
,
'user_template_test'
);
require
'./include/common.inc.php'
;
echo
"<pre>"
;
echo
"=== USER TEMPLATE SETTING TEST ===
\n\n
"
;
// 检查用户是否登录
if
(
!
$cuser
||
!
$udata
)
{
echo
"ERROR: User not logged in or user data not available.
\n
"
;
echo
"Please log in first to test template settings.
\n
"
;
echo
"cuser: "
.
(
$cuser
?
$cuser
:
'NULL'
)
.
"
\n
"
;
echo
"udata: "
.
(
isset
(
$udata
)
?
'SET'
:
'NULL'
)
.
"
\n
"
;
exit
;
}
echo
"User Information:
\n
"
;
echo
"Username:
$cuser
\n
"
;
echo
"User ID: "
.
(
isset
(
$udata
[
'uid'
])
?
$udata
[
'uid'
]
:
'N/A'
)
.
"
\n
"
;
echo
"Current u_templateid: "
.
(
isset
(
$udata
[
'u_templateid'
])
?
$udata
[
'u_templateid'
]
:
'NOT SET'
)
.
"
\n
"
;
// 显示当前系统设置
echo
"
\n
Current System Settings:
\n
"
;
echo
"TEMPLATEID: "
.
TEMPLATEID
.
"
\n
"
;
echo
"TPLDIR: "
.
TPLDIR
.
"
\n
"
;
// 测试设置不同的模板ID
echo
"
\n
=== TESTING TEMPLATE ID CHANGES ===
\n
"
;
// 首先备份当前设置
$original_templateid
=
isset
(
$udata
[
'u_templateid'
])
?
$udata
[
'u_templateid'
]
:
0
;
$test_ids
=
[
0
,
1
,
2
];
foreach
(
$test_ids
as
$test_id
)
{
echo
"
\n
--- Testing u_templateid =
$test_id
---
\n
"
;
// 更新数据库中的用户模板设置
$db
->
query
(
"UPDATE
{
$gtablepre
}
users SET u_templateid = '
$test_id
' WHERE username = '
$cuser
'"
);
// 重新获取用户数据
$test_udata
=
fetch_userdata_by_username
(
$cuser
);
echo
"Database updated u_templateid: "
.
$test_udata
[
'u_templateid'
]
.
"
\n
"
;
// 模拟系统重新加载时的行为
$user_templateid
=
intval
(
$test_udata
[
'u_templateid'
]);
switch
(
$user_templateid
)
{
case
1
:
$expected_TEMPLATEID
=
1
;
$expected_TPLDIR
=
'./templates/luluxia'
;
$template_name
=
'LULUXIA'
;
break
;
case
2
:
$expected_TEMPLATEID
=
2
;
$expected_TPLDIR
=
'./templates/nouveau'
;
$template_name
=
'NOUVEAU'
;
break
;
default
:
$expected_TEMPLATEID
=
1
;
$expected_TPLDIR
=
'./templates/default'
;
$template_name
=
'DEFAULT'
;
break
;
}
echo
"Expected template:
$template_name
\n
"
;
echo
"Expected TEMPLATEID:
$expected_TEMPLATEID
\n
"
;
echo
"Expected TPLDIR:
$expected_TPLDIR
\n
"
;
// 检查模板目录
$template_dir
=
GAME_ROOT
.
$expected_TPLDIR
;
echo
"Template directory:
$template_dir
\n
"
;
echo
"Directory exists: "
.
(
is_dir
(
$template_dir
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
// 检查编译文件
$compiled_header
=
GAME_ROOT
.
'./gamedata/templates/'
.
$expected_TEMPLATEID
.
'_header.tpl.php'
;
echo
"Compiled header:
$compiled_header
\n
"
;
echo
"Compiled exists: "
.
(
file_exists
(
$compiled_header
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
file_exists
(
$compiled_header
))
{
echo
"Compiled size: "
.
filesize
(
$compiled_header
)
.
" bytes
\n
"
;
}
// 如果是nouveau模板,检查是否会fallback
if
(
$user_templateid
==
2
)
{
$nouveau_source
=
GAME_ROOT
.
'./templates/nouveau/header.htm'
;
echo
"Nouveau source exists: "
.
(
file_exists
(
$nouveau_source
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
if
(
!
is_dir
(
$template_dir
))
{
echo
"WARNING: Nouveau directory not found, would fallback to default!
\n
"
;
}
elseif
(
!
file_exists
(
$nouveau_source
))
{
echo
"WARNING: Nouveau header.htm not found, would fallback to default!
\n
"
;
}
}
}
// 恢复原始设置
echo
"
\n
=== RESTORING ORIGINAL SETTING ===
\n
"
;
$db
->
query
(
"UPDATE
{
$gtablepre
}
users SET u_templateid = '
$original_templateid
' WHERE username = '
$cuser
'"
);
echo
"Restored u_templateid to:
$original_templateid
\n
"
;
// 最终测试:模拟页面重新加载
echo
"
\n
=== SIMULATING PAGE RELOAD ===
\n
"
;
// 重新获取用户数据
$final_udata
=
fetch_userdata_by_username
(
$cuser
);
$final_templateid
=
intval
(
$final_udata
[
'u_templateid'
]);
echo
"Final u_templateid from database:
$final_templateid
\n
"
;
// 模拟gamedata/system.php的逻辑
switch
(
$final_templateid
)
{
case
1
:
$final_TEMPLATEID
=
1
;
$final_TPLDIR
=
'./templates/luluxia'
;
break
;
case
2
:
$final_TEMPLATEID
=
2
;
$final_TPLDIR
=
'./templates/nouveau'
;
break
;
default
:
$final_TEMPLATEID
=
1
;
$final_TPLDIR
=
'./templates/default'
;
break
;
}
echo
"Final TEMPLATEID would be:
$final_TEMPLATEID
\n
"
;
echo
"Final TPLDIR would be:
$final_TPLDIR
\n
"
;
// 测试template函数调用
$final_template_path
=
template
(
'header'
,
$final_TEMPLATEID
,
$final_TPLDIR
);
echo
"Template function would return:
$final_template_path
\n
"
;
echo
"File exists: "
.
(
file_exists
(
$final_template_path
)
?
'YES'
:
'NO'
)
.
"
\n
"
;
echo
"
\n
=== Test completed ===
\n
"
;
echo
"</pre>"
;
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment