XoopsModules25x /
suico
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Extended User Profile |
||
| 7 | * |
||
| 8 | * You may not change or alter any portion of this comment or credits |
||
| 9 | * of supporting developers from this source code or any supporting source code |
||
| 10 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 11 | * This program is distributed in the hope that it will be useful, |
||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 14 | * |
||
| 15 | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
||
| 16 | * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html) |
||
| 17 | * @package profile |
||
| 18 | * @since 2.3.0 |
||
| 19 | * @author Jan Pedersen |
||
| 20 | * @author Taiwen Jiang <[email protected]> |
||
| 21 | */ |
||
| 22 | |||
| 23 | use XoopsModules\Suico\IndexController; |
||
| 24 | use Xmf\Request; |
||
| 25 | |||
| 26 | $GLOBALS['xoopsOption']['template_main'] = 'suico_changepass.tpl'; |
||
| 27 | require __DIR__ . '/header.php'; |
||
| 28 | /** |
||
| 29 | * Fetching numbers of groups friends videos pictures etc... |
||
| 30 | */ |
||
| 31 | $controller = new IndexController($xoopsDB, $xoopsUser, $xoopsModule); |
||
| 32 | $nbSections = $controller->getNumbersSections(); |
||
| 33 | if (!$GLOBALS['xoopsUser']) { |
||
| 34 | redirect_header(XOOPS_URL, 2, _NOPERM); |
||
| 35 | } |
||
| 36 | $xoopsOption['xoops_pagetitle'] = sprintf(_MD_SUICO_CHANGEPASSWORD, $xoopsModule->getVar('name'), $controller->nameOwner); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 37 | if (!isset($_POST['submit'])) { |
||
| 38 | //show change password form |
||
| 39 | include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||
| 40 | $form = new XoopsThemeForm(_MD_SUICO_CHANGEPASSWORD, 'form', $_SERVER['REQUEST_URI'], 'post', true); |
||
| 41 | $form->addElement(new XoopsFormPassword(_MD_SUICO_OLDPASSWORD, 'oldpass', 15, 50), true); |
||
| 42 | $form->addElement(new XoopsFormPassword(_MD_SUICO_NEWPASSWORD, 'newpass', 15, 50), true); |
||
| 43 | $form->addElement(new XoopsFormPassword(_US_VERIFYPASS, 'vpass', 15, 50), true); |
||
| 44 | $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 45 | $form->assign($GLOBALS['xoopsTpl']); |
||
| 46 | $xoBreadcrumbs[] = ['title' => _MD_SUICO_CHANGEPASSWORD]; |
||
| 47 | } else { |
||
| 48 | /* @var XoopsConfigHandler $configHandler */ |
||
| 49 | $configHandler = xoops_getHandler('config'); |
||
| 50 | $GLOBALS['xoopsConfigUser'] = $configHandler->getConfigsByCat(XOOPS_CONF_USER); |
||
| 51 | $myts = MyTextSanitizer::getInstance(); |
||
| 52 | $oldpass = Request::getString('oldpass', '', 'POST'); |
||
| 53 | $password = Request::getString('newpass', '', 'POST'); |
||
| 54 | $vpass = Request::getString('vpass', '', 'POST'); |
||
| 55 | $errors = []; |
||
| 56 | if (!password_verify($oldpass, $GLOBALS['xoopsUser']->getVar('pass', 'n'))) { |
||
| 57 | $errors[] = _MD_SUICO_WRONGPASSWORD; |
||
| 58 | } |
||
| 59 | if (mb_strlen($password) < $GLOBALS['xoopsConfigUser']['minpass']) { |
||
| 60 | $errors[] = sprintf(_US_PWDTOOSHORT, $GLOBALS['xoopsConfigUser']['minpass']); |
||
| 61 | } |
||
| 62 | if ($password != $vpass) { |
||
| 63 | $errors[] = _US_PASSNOTSAME; |
||
| 64 | } |
||
| 65 | if ($errors) { |
||
| 66 | $msg = implode('<br>', $errors); |
||
| 67 | } else { |
||
| 68 | //update password |
||
| 69 | $GLOBALS['xoopsUser']->setVar('pass', password_hash($password, PASSWORD_DEFAULT)); |
||
| 70 | /* @var XoopsMemberHandler $memberHandler */ |
||
| 71 | $memberHandler = xoops_getHandler('member'); |
||
| 72 | $msg = _MD_SUICO_ERRORDURINGSAVE; |
||
| 73 | if ($memberHandler->insertUser($GLOBALS['xoopsUser'])) { |
||
| 74 | $msg = _MD_SUICO_PASSWORDCHANGED; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/index.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'), 2, $msg); |
||
| 78 | } |
||
| 79 | require __DIR__ . '/footer.php'; |
||
| 80 | require dirname(__DIR__, 2) . '/footer.php'; |
||
| 81 |