迅睿開源框架是一款PHP8高性能·簡(jiǎn)單易用的PHP開源開發(fā)框架, 基于MIT開源許可協(xié)議發(fā)布,不限制商業(yè)使用,以多端互聯(lián)為設(shè)計(jì)理念, 支持的微信公眾號(hào)、小程序、APP客戶端、移動(dòng)端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
業(yè)務(wù)經(jīng)理
微信掃描以上二維碼
028-61286886
技術(shù)咨詢
搭建演示站,怎么禁止用戶修改數(shù)據(jù),實(shí)現(xiàn)官方演示站的這種效果
需要二次開發(fā)了,用鉤子實(shí)現(xiàn)攔截提交
下面是官網(wǎng)的代碼可以參考
\Phpcmf\Hooks::on('cms_init', function() { $msg = '演示系統(tǒng)禁止變更數(shù)據(jù)的操作'; if (\Phpcmf\Service::L('Router')->class == 'login') { return; } if (\Phpcmf\Service::L('Router')->class == 'file') { exit(\Phpcmf\Service::C()->_json(0, $msg)); } // cms 初始化后的運(yùn)行 if (in_array($uri, [ 'cloud/index', 'cloud/update', 'cloud/down_file', 'cloud/install_app', 'menu/use_edit', 'api/menu', 'backup/index', 'backup/add', 'form/add', 'site/add', 'module/install', 'module/uninstall', 'content/index', 'backup/index', 'module/form_index', 'check/php_index', ])) { exit($msg); } if (IS_API_HTTP) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (in_array(\Phpcmf\Service::L('Router')->method, [ 'del', 'install', 'uninstall', 'uninstall', ]) || strpos(\Phpcmf\Service::L('Router')->method, 'del') !== false) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (strpos(\Phpcmf\Service::L('Router')->method, '_edit') !== false) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (IS_POST) { if (!IS_ADMIN) { exit(\Phpcmf\Service::C()->_msg(0, $msg)); } if (in_array(\Phpcmf\Service::L('Router')->class, [ 'tpl_pc', 'tpl_mobile', 'module_create', 'module_content', 'theme', 'system_theme', ])) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } exit(\Phpcmf\Service::C()->_json(0, $msg)); } });
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
需要二次開發(fā)了,用鉤子實(shí)現(xiàn)攔截提交
下面是官網(wǎng)的代碼可以參考
\Phpcmf\Hooks::on('cms_init', function() { $msg = '演示系統(tǒng)禁止變更數(shù)據(jù)的操作'; if (\Phpcmf\Service::L('Router')->class == 'login') { return; } if (\Phpcmf\Service::L('Router')->class == 'file') { exit(\Phpcmf\Service::C()->_json(0, $msg)); } // cms 初始化后的運(yùn)行 if (in_array($uri, [ 'cloud/index', 'cloud/update', 'cloud/down_file', 'cloud/install_app', 'menu/use_edit', 'api/menu', 'backup/index', 'backup/add', 'form/add', 'site/add', 'module/install', 'module/uninstall', 'content/index', 'backup/index', 'module/form_index', 'check/php_index', ])) { exit($msg); } if (IS_API_HTTP) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (in_array(\Phpcmf\Service::L('Router')->method, [ 'del', 'install', 'uninstall', 'uninstall', ]) || strpos(\Phpcmf\Service::L('Router')->method, 'del') !== false) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (strpos(\Phpcmf\Service::L('Router')->method, '_edit') !== false) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } if (IS_POST) { if (!IS_ADMIN) { exit(\Phpcmf\Service::C()->_msg(0, $msg)); } if (in_array(\Phpcmf\Service::L('Router')->class, [ 'tpl_pc', 'tpl_mobile', 'module_create', 'module_content', 'theme', 'system_theme', ])) { exit(\Phpcmf\Service::C()->_json(0, $msg)); } exit(\Phpcmf\Service::C()->_json(0, $msg)); } });開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!