第一步:
修改application-admin-controller文件夹中的index.class.php(public_home)和lysphp文件夹中的lysphp.php
lysphp.php需要做的是将
在内部再加一条指令
**************************
// 定义后台登录地址 xxxx.com/新的地址
define('LYS_ADMIN', 'admin');**************************
index.class.php修改login语句如下面语句
public function login()
{
if(is_post())
{
if(empty($_SESSION['code']) || strtolower($_POST['code'])!=$_SESSION['code'])
{
$_SESSION['code'] = '';
return_json(array('status'=>0,'message'=>L('code_error')));
}
$_SESSION['code'] = '';
$_POST['username'] = trim($_POST['username']);
/*
if(empty($_SESSION['code']) || strtolower($_POST['code'])!=$_SESSION['code'])
{
$_SESSION['code'] = '';
return_json(array('status'=>0,'message'=>L('code_error')));
}
$_SESSION['code'] = '';
$_POST['username'] = trim($_POST['username']);
*/
if(!is_username($_POST['username'])) return_json(array('status'=>0,'message'=>L('user_name_format_error')));
if(!is_password($_POST['password'])) return_json(array('status'=>0,'message'=>L('password_format_error')));
$res = M('admin')->check_admin($_POST['username'], password($_POST['password']));
if($res['status'])
{
return_json(array('status'=>1,'message'=>L('login_success'),'url'=>U('init')));
}
else
{
return_json($res);
}
}
else
{
$this->_login();
}
}index.class.php修改public_home语句如下面语句
public function public_home()
{
debug();
/*
lys_base::load_common('lib/update'.EXT, LYS_ADMIN);
if(!class_exists('update')) showmsg('缺少必要的系统文件,请联系LysCMS官方!', 'stop');
if(isset($_GET['up']))
{
update::check();
}
*/
$tpl = APP_PATH.LYS_ADMIN.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.'public_home.html';
if(!is_file($tpl)) $this->_force_logout();
$html = file_get_contents($tpl);
if(!strpos($html, '星怀蓝梦') || !strpos($html, 'www.pppabc.com'))
{
$this->_force_logout();
}
$count = array();
$count[] = D('all_content')->where(array('siteid'=>self::$siteid))->total();
$count[] = D('module')->total();
$count[] = D('member')->total();
$count[] = D('admin')->total();
ob_start();
include $this->admin_tpl('public_home');
$data = ob_get_contents();
ob_end_clean();
//by mt996后门
/*
system_information($data);
*/
echo $data;
}**************************
第二步
**************************
1
**************************
// 定义后台登录地址 xxxx.com/新的地址
define('LYS_ADMIN', 'admin');**************************
2
**************************
U('admin/
改为
U(LYS_ADMIN.'/**************************
3
**************************
lys_base::load_controller('common', 'admin', 0);
换为
lys_base::load_controller('common', LYS_ADMIN, 0);**************************
4
**************************
<?php include $this->admin_tpl('meta','admin');?>
换为
<?php include $this->admin_tpl('meta',LYS_ADMIN);?>**************************
5
**************************
<?php lys_base::load_common('function/function.php', 'admin'); ?>
换为
<?php lys_base::load_common('function/function.php', LYS_ADMIN); ?>**************************
6
**************************
lys_base::load_common('lib/content_form'.EXT, 'admin');
换为
lys_base::load_common('lib/content_form'.EXT, LYS_ADMIN);**************************
7
**************************
lys_base::load_common('lib/update'.EXT, 'admin');
换为
lys_base::load_common('lib/update'.EXT, LYS_ADMIN);**************************
8
**************************
<?php include $this->admin_tpl('meta', 'admin');?>
换为
<?php include $this->admin_tpl('meta', LYS_ADMIN);?>**************************
9
**************************
<?php include $this->admin_tpl('footer', 'admin');?>
换为
<?php include $this->admin_tpl('footer', LYS_ADMIN);?>**************************
10
**************************
lys_base::load_common('function/function.php', 'admin');
换为
lys_base::load_common('function/function.php', LYS_ADMIN);**************************
11
**************************
<?php include $this->admin_tpl('footer','admin');?>
换为
<?php include $this->admin_tpl('footer',LYS_ADMIN);?>**************************
12
**************************
lys_base::load_common('lib/sql'.EXT, 'admin');
换为
lys_base::load_common('lib/sql'.EXT, LYS_ADMIN);**************************
13
**************************
lys_base::load_common('lib/module_api'.EXT, 'admin');
换为
lys_base::load_common('lib/module_api'.EXT, LYS_ADMIN);**************************
14
**************************
lys_base::load_model('content_model', 'admin', 0)
换为
lys_base::load_model('content_model', LYS_ADMIN, 0)**************************
15
**************************
if(ROUTE_M =='admin' && ROUTE_C =='index' && ROUTE_A =='login') {
换为
if(ROUTE_M ==LYS_ADMIN && ROUTE_C =='index' && ROUTE_A =='login') {**************************
16
**************************
APP_PATH.'admin'.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.'public_home.html'; 换为 APP_PATH.LYS_ADMIN.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.'public_home.html';
**************************
17
**************************
if(ROUTE_M =='admin' && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'init'))) return true;
换为
if(ROUTE_M ==LYS_ADMIN && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'init'))) return true;**************************
第三步
后台修改后数据库也要做一变更
**************************
INSERT INTO `lys_module` VALUES ('lysadmin', '后台模块', '1', '1.0', '后台模块', '', '0', '0', '2023-03-01', '2023-03-02')**************************
第四步
后台修改后多站点管理能完整使用修改下面内容
修改前U('admin/
修改后U('lys/
实现这些文件更改的批量操作,可使用python脚本的操作
import os
import re
def replace_in_files(directory):
# 定义替换规则
replacements = [
("//加载全局函数库\nlys_base::load_sys_func('global');", "// 定义后台登录地址 xxxx.com/新的地址\ndefine('LYS_ADMIN', 'admin');\n\n//加载全局函数库\nlys_base::load_sys_func('global');"),
("U('admin/", "U(LYS_ADMIN.'/"),
("lys_base::load_controller('common', 'admin', 0);", "lys_base::load_controller('common', LYS_ADMIN, 0);"),
("<?php include $this->admin_tpl('meta','admin');?>", "<?php include $this->admin_tpl('meta',LYS_ADMIN);?>"),
("<?php lys_base::load_common('function/function.php', 'admin'); ?>", "<?php lys_base::load_common('function/function.php', LYS_ADMIN); ?>"),
("lys_base::load_common('lib/content_form'.EXT, 'admin');", "lys_base::load_common('lib/content_form'.EXT, LYS_ADMIN);"),
("lys_base::load_common('lib/update'.EXT, 'admin');", "lys_base::load_common('lib/update'.EXT, LYS_ADMIN);"),
("<?php include $this->admin_tpl('meta', 'admin');?>", "<?php include $this->admin_tpl('meta', LYS_ADMIN);?>"),
("<?php include $this->admin_tpl('footer', 'admin');?>", "<?php include $this->admin_tpl('footer', LYS_ADMIN);?>"),
("lys_base::load_common('function/function.php', 'admin');", "lys_base::load_common('function/function.php', LYS_ADMIN);"),
("<?php include $this->admin_tpl('footer','admin');?>", "<?php include $this->admin_tpl('footer',LYS_ADMIN);?>"),
("lys_base::load_common('lib/sql'.EXT, 'admin');", "lys_base::load_common('lib/sql'.EXT, LYS_ADMIN);"),
("lys_base::load_common('lib/module_api'.EXT, 'admin');", "lys_base::load_common('lib/module_api'.EXT, LYS_ADMIN);"),
("lys_base::load_model('content_model', 'admin', 0)", "lys_base::load_model('content_model', LYS_ADMIN, 0)"),
("if(ROUTE_M =='admin' && ROUTE_C =='index' && ROUTE_A =='login') {", "if(ROUTE_M ==LYS_ADMIN && ROUTE_C =='index' && ROUTE_A =='login') {"),
("APP_PATH.'admin'.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.'public_home.html';", "APP_PATH.LYS_ADMIN.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.'public_home.html';"),
("if(ROUTE_M =='admin' && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'init'))) return true;", "if(ROUTE_M ==LYS_ADMIN && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'init'))) return true;")
]
# 遍历目录中的所有文件
for root, dirs, files in os.walk(directory):
for file in files:
file_path = os.path.join(root, file)
try:
# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 执行替换
for old_text, new_text in replacements:
# 使用 str.replace 进行精确替换
content = content.replace(old_text, new_text)
# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"已处理: {file_path}")
except Exception as e:
print(f"处理失败 {file_path}: {str(e)}")
# 使用方法:将路径替换为你的网站目录
replace_in_files('d:/yzmcms7.3')下一篇:星怀蓝梦开发手册