关闭DiscuzX3.5注册页面的注册邮箱验证 New
2026/01/25 18:11:41
原文链接https://www.cnblogs.com/tangshiguang/p/6741136.html,原文作者:唐世光
转自其他平台
打开source/class/class_member.php
定位到以下代码,大概533行左右
if(!$activationauth) { $email = $email ? $email : $_GET['email']; checkemail($email); }
修改为
if(!$activationauth) { $email = strtolower(trim($_GET['email'])); if(empty($email) && $_G['setting']['forgeemail']) { $timestamp = date('YmdHis'); $_GET['email'] = $email = 'KB' . $timestamp . '@qq.com'; // 生成随机邮箱,生成邮箱以KB开头,@qq.com结尾 } checkemail($email); // 在生成邮箱后校验}
下面是原文的修改方法,先改完下面的部分,在改我上面提到的部分discuzX3.2后台关闭注册邮箱必填选项的功能。详细过程如下:步骤1:source/admincp/admincp_setting.php 文件查找:
showsetting('setting_access_register_send_register_url', 'settingnew[sendregisterurl]', $setting['sendregisterurl'], 'radio');
大概是440-441行:增加以下代码:
showsetting('setting_access_register_forge_email', 'settingnew[forgeemail]', $setting['forgeemail'], 'radio');
步骤2:打开source/language/lang_admincp.php 文件
查找: 一个邮箱只允许注册一个帐户
大概811行,增加以下代码:
'setting_access_register_forge_email' => '取消注册邮箱必填','setting_access_register_forge_email_comment' => '开启后如果用不不填写注册邮箱,将自动生成一个邮箱地址',
步骤3:修改source/class/class_member.php
大概611行:原文是:
$email = strtolower(trim($_GET['email']));if(empty($this->setting['ignorepassword'])) {if($_GET['password'] !== $_GET['password2']) { showmessage('profile_passwd_notmatch');}if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password'];} else { $password = md5(random(10)); }}
修改为(或直接替换以下:)(在原文随机码的基础上改为了KB+时间戳+@qq.com)
$email = strtolower(trim($_GET['email']));if(empty($email) && $_G['setting']['forgeemail']) { // 生成时间戳格式:年月日时分秒(例如 20250415120711) $timestamp = date('YmdHis'); // 组合随机邮箱前缀码(KB) $_GET['email'] = $email = 'KB' . $timestamp . '@qq.com';}if(empty($this->setting['ignorepassword'])) { if($_GET['password'] !== $_GET['password2']) { showmessage('profile_passwd_notmatch'); } if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password'];} else { $password = md5(random(10));}}
我知道答案 回答被采纳将会获得1 贡献 已有2人回答
转自其他平台
打开source/class/class_member.php
定位到以下代码,大概533行左右
if(!$activationauth) { $email = $email ? $email : $_GET['email']; checkemail($email); }
修改为
if(!$activationauth) { $email = strtolower(trim($_GET['email'])); if(empty($email) && $_G['setting']['forgeemail']) { $timestamp = date('YmdHis'); $_GET['email'] = $email = 'KB' . $timestamp . '@qq.com'; // 生成随机邮箱,生成邮箱以KB开头,@qq.com结尾 } checkemail($email); // 在生成邮箱后校验}
下面是原文的修改方法,先改完下面的部分,在改我上面提到的部分discuzX3.2后台关闭注册邮箱必填选项的功能。详细过程如下:步骤1:source/admincp/admincp_setting.php 文件查找:
showsetting('setting_access_register_send_register_url', 'settingnew[sendregisterurl]', $setting['sendregisterurl'], 'radio');
大概是440-441行:增加以下代码:
showsetting('setting_access_register_forge_email', 'settingnew[forgeemail]', $setting['forgeemail'], 'radio');
步骤2:打开source/language/lang_admincp.php 文件
查找: 一个邮箱只允许注册一个帐户
大概811行,增加以下代码:
'setting_access_register_forge_email' => '取消注册邮箱必填','setting_access_register_forge_email_comment' => '开启后如果用不不填写注册邮箱,将自动生成一个邮箱地址',
步骤3:修改source/class/class_member.php
大概611行:原文是:
$email = strtolower(trim($_GET['email']));if(empty($this->setting['ignorepassword'])) {if($_GET['password'] !== $_GET['password2']) { showmessage('profile_passwd_notmatch');}if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password'];} else { $password = md5(random(10)); }}
修改为(或直接替换以下:)(在原文随机码的基础上改为了KB+时间戳+@qq.com)
$email = strtolower(trim($_GET['email']));if(empty($email) && $_G['setting']['forgeemail']) { // 生成时间戳格式:年月日时分秒(例如 20250415120711) $timestamp = date('YmdHis'); // 组合随机邮箱前缀码(KB) $_GET['email'] = $email = 'KB' . $timestamp . '@qq.com';}if(empty($this->setting['ignorepassword'])) { if($_GET['password'] !== $_GET['password2']) { showmessage('profile_passwd_notmatch'); } if(!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { showmessage('profile_passwd_illegal'); } $password = $_GET['password'];} else { $password = md5(random(10));}}
我知道答案 回答被采纳将会获得1 贡献 已有2人回答