联系官方销售客服

1835022288

028-61286886

求助 版主:官方研发技术组
搭建演示站,怎么禁止用户修改数据
类型:迅睿CMS 更新时间:2022-05-26 11:05:58


搭建演示站,怎么禁止用户修改数据,实现官方演示站的这种效果

8be92c70114ce2295257a383be523c8

回帖
  • #1楼    迅睿框架创始人
    2022-05-26 10:56:43
    Google Pixel 手机 0
    需要二次开发了,用钩子实现拦截提交下面是官网的代码可以参考
    \Phpcmf\Hooks::on('cms_init', function() {
    
        
    
      	$msg = '演示系统禁止变更数据的操作';
        
        
        if (\Phpcmf\Service::L('Router')->class == 'login') {
        	
            return;
        }
      	if (\Phpcmf\Service::L('Router')->class == 'file') {
        	exit(\Phpcmf\Service::C()->_json(0, $msg));
        }
        // cms 初始化后的运行
    
        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));
        }
    });
    满意答案
  • 大兔子
    #2楼    大兔子
    2022-05-26 11:05:58
    Chrome 0
    迅睿框架创始人:搞定了,老大