diff --git a/src/system/common.func.php b/src/system/common.func.php index f2e9b529..a7a89c8b 100755 --- a/src/system/common.func.php +++ b/src/system/common.func.php @@ -665,6 +665,20 @@ function AddFilter($channelid, $type=1, $fieldsnamef=array(), $defaulttid=0, $to } 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')) { require_once(DEDEINC.'/extend.func.php'); diff --git a/src/user/api.php b/src/user/api.php index 0011a33d..1926bfa4 100755 --- a/src/user/api.php +++ b/src/user/api.php @@ -21,7 +21,44 @@ if ($action === 'is_need_check_code') { ), )); 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" : ""; if (!$cfg_ml->IsLogin()) { if ($format === 'json') { diff --git a/src/user/edit_baseinfo.php b/src/user/edit_baseinfo.php index c692abc3..872c31e5 100755 --- a/src/user/edit_baseinfo.php +++ b/src/user/edit_baseinfo.php @@ -63,14 +63,17 @@ if ($dopost == 'save') { 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 (strlen($newsafeanswer) > 30) { diff --git a/src/user/templets/edit_baseinfo.htm b/src/user/templets/edit_baseinfo.htm index 57849bbf..9a043db9 100755 --- a/src/user/templets/edit_baseinfo.htm +++ b/src/user/templets/edit_baseinfo.htm @@ -30,11 +30,6 @@ ShowMsg("请您填写昵称"); return false; } - if (document.form2.vdcode.value == "") { - document.form2.vdcode.focus(); - ShowMsg("请您填写验证码"); - return false; - } } @@ -101,7 +96,10 @@
-
+
+ 修改邮箱 + +
@@ -118,5 +116,25 @@
+ \ No newline at end of file