首页 > 运营 > 建站经验 > 正文

添加ecshop注册新会员敏感词功能

2019-11-02 15:31:27
字体:
来源:转载
供稿:网友

敏感词一般是指带有敏感政治倾向(或反执政党倾向)、暴力倾向、不健康色彩的词或不文明语。ecshop注册新会员防止恶意使用敏感词作为用户名注册。

效果后台:

添加ecshop注册新会员敏感词功能

效果前台:

添加ecshop注册新会员敏感词功能

添加代码开始:

为ecshop后台->商店设置,添加一个tab“敏感词设置”

1,在ecshop数据库的ecs_shop_config表中插入2条记录(注意你的表前缀和id中10、1001):

INSERT INTO ecs_shop_config (id, parent_id, code, type, store_range, store_dir, value, sort_order) VALUES

(10, 0, sensitive, group, '', '', '', 1),

(1001, 10, reg_sensitive, textarea, '', '', '*administrator* *Admin* *管理* *版主* *斑竹* *吧主* *霸主* *Manager* *主席* *公司* *总经理* *投资商* *股东* *皇帝* *太监* *客服* *他妈的* *你祖宗* *王八蛋* *草* *操* *艹*', 1);

2,languages/zh_cn/admin/shop_config.php,文件尾添加

/* 敏感词设置 */

$_LANG['cfg_name']['sensitive'] = '敏感词设置';

$_LANG['cfg_name']['reg_sensitive'] = '注册敏感词';

$_LANG['cfg_desc']['reg_sensitive'] = '每个关键字一行,可使用通配符 * 如 *管理员*';

前台PHP逻辑处理

1,includes/lib_passport.php,文件尾添加

/**

* 判断用户名是否在敏感词列表中

* @param string $reg_username 注册用户名

* @return boolean

*/

function is_reg_sensitive($reg_username)

{

$senList = !empty($GLOBALS['_CFG']['reg_sensitive']) ? trim($GLOBALS['_CFG']['reg_sensitive']) : '';

$reg_sensitive = '/^('.str_replace(array('//*', "/r/n", ' '), array('.*', '|', ''), preg_quote($senList, '/')).')$/i';

if($senList && @preg_match($reg_sensitive, $reg_username))

{

return true;

}

return false;

}

2、user.php 中找到

/* 验证用户注册用户名是否可以注册 */

elseif ($action == 'is_registered')

{

include_once(ROOT_PATH . 'includes/lib_passport.php');

$username = trim($_GET['username']);

$username = json_str_iconv($username);

if ($user->check_user($username) || admin_registered($username))

{

echo 'false';

}

else

{

echo 'true';

}

}

修改成

/* 验证用户注册用户名是否可以注册 */

elseif ($action == 'is_registered')

{

include_once(ROOT_PATH . 'includes/lib_passport.php');

$username = trim($_GET['username']);

$username = json_str_iconv($username);

if ($user->check_user($username) || admin_registered($username) || is_reg_sensitive($username))

{

echo 'false';

}

else

{

echo 'true';

}

}

End!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表