请输入2-5个汉字搜索^_^

首页>>问题解答

pbootcms新版本搜索加ext字段搜索无效 如?keyword=网站&ext_type=专业版 老版本没有问题 修复方法

pbootcms新版本搜索加ext字段搜索无效 如?keyword=网站&ext_type=专业版

原因:修复注入跨表注入增加了访问字段的白名单。

可以取消该功能解决这个问题。

进入目录 apps\home\controller 

找到文件 ParserController.php

搜索 // 只允许白名单中的字段,并且检查字段格式

在3087行附近的代码如下:

// 只允许白名单中的字段,并且检查字段格式

                        if (in_array($key, $this->allowed_fields) && preg_match('/^[\w\-\.]+$/', $key)) {

                            $where3[$key] = $value;

                        }

修改成老版本的:

                        if (preg_match('/^[\w\-\.]+$/', $key)) { // 带有违规字符时不带入查询

                            $where3[$key] = $value;

                        }

修改前:

QQ图片20260519165702.png

修改后:

QQ图片20260519165724.png

如果不使用该功能,就不要修改,以免产生安全问题。

---------下面是方法2,使用一种方法就行了。--------------------------------------

方法2:更安全的方法

进入目录 apps\home\controller 

找到文件 ParserController.php

在第26行左右有个数组如下:

protected $allowed_fields = array(

        'id', 'acode', 'scode', 'subscode', 'title', 'titlecolor', 'subtitle', 

        'filename', 'author', 'source', 'outlink', 'date', 'ico', 'pics', 

        'picstitle', 'content', 'tags', 'enclosure', 'keywords', 'description', 

        'sorting', 'status', 'istop', 'isrecommend', 'isheadline', 'visits', 

        'likes', 'oppose', 'create_user', 'update_user', 'create_time', 

        'update_time', 'gtype', 'gid', 'gnote'

    );

将要查询的字段名添加到数组里就行了。注意一定要按PHP的数组格式添加。如果不会,可以让豆包AI来修改。方法1是为了方便各种奇葩的自定义开发。

# 相关内容: