diff --git a/common.php b/common.php index 3f0d5e6..81bef93 100644 --- a/common.php +++ b/common.php @@ -1184,6 +1184,24 @@ function EnvOpt($needUpdate = 0) return output("{\"Error\": \"Admin pass error\"}", 403); } } + if (isset($_POST['changePass'])) { + if (!is_numeric($_POST['timestamp'])) return message("Error time" . getconstStr('Back') . "", "Error", 403); + if (abs(time() - $_POST['timestamp']/1000) > 5*60) return message("Timeout" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1']==''||$_POST['newPass2']=='') return message("Empty new pass" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1']!==$_POST['newPass2']) return message("Twice new pass not the same" . getconstStr('Back') . "", "Error", 403); + if ($_POST['newPass1']==getConfig('admin')) return message("New pass same to old one" . getconstStr('Back') . "", "Error", 403); + if ($_POST['oldPass']==sha1(getConfig('admin') . $_POST['timestamp'])) { + $tmp['admin'] = $_POST['newPass1']; + $response = setConfigResponse( setConfig($tmp) ); + if (api_error($response)) { + return message(api_error_msg($response) . "" . getconstStr('Back') . "", "Error", 403); + } else { + return message("Success" . getconstStr('Back') . "", "Success", 200); + } + } else { + return message("Old pass error" . getconstStr('Back') . "", "Error", 403); + } + } if (isset($_GET['preview'])) { $preurl = $_SERVER['PHP_SELF'] . '?preview'; @@ -1388,14 +1406,31 @@ function EnvOpt($needUpdate = 0) $html .= '