From 3b956676b11bd7209a92e3ed92319cab59cfe1d2 Mon Sep 17 00:00:00 2001 From: Jackson Dou Date: Sun, 25 Jun 2023 18:38:28 +0800 Subject: [PATCH] update --- src/admin/controllers/profile/password.php | 43 ++++---- src/admin/views/footer.php | 2 +- src/admin/views/login/footer.php | 4 +- src/admin/views/navbar.php | 4 +- src/admin/views/profile/edit.php | 106 ++++++++------------ src/admin/views/profile/password.php | 63 ++++++++++++ src/admin/views/profile/view.php | 111 +++++++++------------ src/admin/views/settings/menu.php | 6 +- src/admin/views/settings/view.php | 2 +- src/core/language/zh-CN/language.php | 1 + src/install/function/Database.php | 1 + src/public/views/common/footer.php | 2 +- src/public/views/common/navbar.php | 32 +++--- 13 files changed, 196 insertions(+), 181 deletions(-) create mode 100755 src/admin/views/profile/password.php diff --git a/src/admin/controllers/profile/password.php b/src/admin/controllers/profile/password.php index 4bf45c6..0eb8b44 100755 --- a/src/admin/controllers/profile/password.php +++ b/src/admin/controllers/profile/password.php @@ -1,30 +1,27 @@ post('old_password'), + 'new_password' => post('new_password'), + 'hashed_password' => hash('sha256', post('new_password')), + 'user_key' => $AdminInfo['admin_key'], + 'user_password' => $AdminInfo['admin_password'], + ); -if (!isset($_POST['submit'])) { - exit('405 / Method Not Allowed'); -} - -$FormData = array( - 'old_password' => post('old_password'), - 'new_password' => post('new_password'), - 'hashed_password' => hash('sha256', post('new_password')), - 'user_key' => $AdminInfo['admin_key'], - 'user_password' => $AdminInfo['admin_password'], -); - -if (hash('sha256', $FormData['old_password']) == $FormData['user_password']) { - $result = $DB->update('admin', array('admin_password' => $FormData['hashed_password']), array('admin_key' => $FormData['user_key'])); - if ($result) { - setMessage('Password changed successfully !'); - unset($_SESSION['UIISC_ADMIN']); - redirect('admin/login'); + if (hash('sha256', $FormData['old_password']) == $FormData['user_password']) { + $result = $DB->update('admin', array('admin_password' => $FormData['hashed_password']), array('admin_key' => $FormData['user_key'])); + if ($result) { + setMessage('Password changed successfully !'); + unset($_SESSION['UIISC_ADMIN']); + redirect('admin/login'); + } else { + setMessage("Something went's wrong !", 'danger'); + redirect('admin/settings'); + } } else { - setMessage("Something went's wrong !", 'danger'); + setMessage('Invalid user password !', 'danger'); redirect('admin/settings'); } -} else { - setMessage('Invalid user password !', 'danger'); - redirect('admin/settings'); } diff --git a/src/admin/views/footer.php b/src/admin/views/footer.php index d017048..983e328 100755 --- a/src/admin/views/footer.php +++ b/src/admin/views/footer.php @@ -4,7 +4,7 @@