@@ -665,6 +665,20 @@ function AddFilter($channelid, $type=1, $fieldsnamef=array(), $defaulttid=0, $to | |||||
} | } | ||||
echo $dede_addonfields; | echo $dede_addonfields; | ||||
} | } | ||||
/** | |||||
* HideEmail 隐藏邮箱 | |||||
* | |||||
* @param mixed $email | |||||
* @return string | |||||
*/ | |||||
function HideEmail($email) | |||||
{ | |||||
$em = explode("@",$email); | |||||
$name = implode('@', array_slice($em, 0, count($em)-1)); | |||||
$len = floor(strlen($name)/2); | |||||
return substr($name,0, $len) . str_repeat('*', $len) . "@" . end($em); | |||||
} | |||||
//自定义函数接口 | //自定义函数接口 | ||||
if (file_exists(DEDEINC.'/extend.func.php')) { | if (file_exists(DEDEINC.'/extend.func.php')) { | ||||
require_once(DEDEINC.'/extend.func.php'); | require_once(DEDEINC.'/extend.func.php'); | ||||
@@ -21,7 +21,44 @@ if ($action === 'is_need_check_code') { | |||||
), | ), | ||||
)); | )); | ||||
exit; | exit; | ||||
} else { | |||||
} else if ($action === 'get_old_email') { | |||||
$oldpwd = isset($oldpwd)? $oldpwd : ''; | |||||
if (empty($oldpwd)) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "旧密码不能为空", | |||||
"data" => null, | |||||
)); | |||||
exit; | |||||
} | |||||
$row = $dsql->GetOne("SELECT * FROM `#@__member` WHERE mid='".$cfg_ml->M_ID."'"); | |||||
if (function_exists('password_hash') && !empty($row['pwd_new'])) { | |||||
if (!is_array($row) || !password_verify($oldpwd, $row['pwd_new'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "旧密码校验错误", | |||||
"data" => null, | |||||
)); | |||||
exit; | |||||
} | |||||
} else { | |||||
if (!is_array($row) || $row['pwd'] != md5($oldpwd)) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "旧密码校验错误", | |||||
"data" => null, | |||||
)); | |||||
exit; | |||||
} | |||||
} | |||||
echo json_encode(array( | |||||
"code" => 0, | |||||
"msg" => "", | |||||
"data" => array( | |||||
"email" => $row['email'], | |||||
), | |||||
)); | |||||
} else { | |||||
$format = isset($format) ? "json" : ""; | $format = isset($format) ? "json" : ""; | ||||
if (!$cfg_ml->IsLogin()) { | if (!$cfg_ml->IsLogin()) { | ||||
if ($format === 'json') { | if ($format === 'json') { | ||||
@@ -63,14 +63,17 @@ if ($dopost == 'save') { | |||||
exit(); | exit(); | ||||
} | } | ||||
//修改邮箱 | //修改邮箱 | ||||
if ($email != $row['email']) { | |||||
if (!CheckEmail($email)) { | |||||
ShowMsg('邮箱格式不正确', '-1'); | |||||
exit(); | |||||
} else { | |||||
$addupquery .= ",email='$email'"; | |||||
if (!empty($email)) { | |||||
if ($email != $row['email']) { | |||||
if (!CheckEmail($email)) { | |||||
ShowMsg('邮箱格式不正确', '-1'); | |||||
exit(); | |||||
} else { | |||||
$addupquery .= ",email='$email'"; | |||||
} | |||||
} | } | ||||
} | } | ||||
//修改安全问题 | //修改安全问题 | ||||
if ($newsafequestion != 0 && $newsafeanswer != '') { | if ($newsafequestion != 0 && $newsafeanswer != '') { | ||||
if (strlen($newsafeanswer) > 30) { | if (strlen($newsafeanswer) > 30) { | ||||
@@ -30,11 +30,6 @@ | |||||
ShowMsg("请您填写昵称"); | ShowMsg("请您填写昵称"); | ||||
return false; | return false; | ||||
} | } | ||||
if (document.form2.vdcode.value == "") { | |||||
document.form2.vdcode.focus(); | |||||
ShowMsg("请您填写验证码"); | |||||
return false; | |||||
} | |||||
} | } | ||||
</script> | </script> | ||||
</head> | </head> | ||||
@@ -101,7 +96,10 @@ | |||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="form-group row"> | ||||
<label for="iptEmail" class="col-sm-3 col-form-label">邮箱</label> | <label for="iptEmail" class="col-sm-3 col-form-label">邮箱</label> | ||||
<div class="col-sm-9"><input type="email" name="email" id="iptEmail" class="form-control" placeholder="每个邮箱只能注册一个帐号,修改邮箱必须填写正确安全问题答案"></div> | |||||
<div class="col-sm-9"> | |||||
<span id="spEmail"><?php echo HideEmail($row['email']);?> <span class="btn btn-success btn-sm" id="btnChangeEmail">修改邮箱</span></span> | |||||
<span id="iptEmail"></span> | |||||
</div> | |||||
</div> | </div> | ||||
<div class="form-group row"> | <div class="form-group row"> | ||||
<label for="iptEmail" class="col-sm-3 col-form-label">性别</label> | <label for="iptEmail" class="col-sm-3 col-form-label">性别</label> | ||||
@@ -118,5 +116,25 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<?php pasterTempletDiy('foot.htm');?> | <?php pasterTempletDiy('foot.htm');?> | ||||
<script> | |||||
$(document).ready(function () { | |||||
$("#btnChangeEmail").click(function(){ | |||||
if ($("#iptOldpwd").val() === "") { | |||||
ShowMsg("请您填写旧密码"); | |||||
return false; | |||||
} | |||||
$.post("<?php echo $cfg_cmsurl;?>/user/api.php?action=get_old_email",{oldpwd:$("#iptOldpwd").val()},function(result) { | |||||
if (result.code === 0) { | |||||
console.log(result); | |||||
$("#spEmail").hide(); | |||||
$("#iptEmail").html(`<input value="${result.data.email}" type="email" name="email" id="iptEmail" class="form-control">`); | |||||
$("#iptEmail").show(); | |||||
} else { | |||||
ShowMsg(result.msg); | |||||
} | |||||
}); | |||||
}) | |||||
}); | |||||
</script> | |||||
</body> | </body> | ||||
</html> | </html> |