XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
changepass.php
Go to the documentation of this file.
1 <?php
21 $xoopsOption['pagetype'] = "user";
22 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
23 if (!$GLOBALS['xoopsUser']) {
24  redirect_header(XOOPS_URL, 2, _NOPERM);
25 }
26 $xoopsOption['template_main'] = 'profile_changepass.html';
27 include $GLOBALS['xoops']->path('header.php');
28 
29 if (!isset($_POST['submit'])) {
30  //show change password form
31  include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
32  $form = new XoopsThemeForm(_PROFILE_MA_CHANGEPASSWORD, 'form', $_SERVER['REQUEST_URI'], 'post', true);
33  $form->addElement(new XoopsFormPassword(_PROFILE_MA_OLDPASSWORD, 'oldpass', 15, 50), true);
34  $form->addElement(new XoopsFormPassword(_PROFILE_MA_NEWPASSWORD, 'newpass', 15, 50), true);
35  $form->addElement(new XoopsFormPassword(_US_VERIFYPASS, 'vpass', 15, 50), true);
36  $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
37  $form->assign($GLOBALS['xoopsTpl']);
38 
39  $xoBreadcrumbs[] = array('title' => _PROFILE_MA_CHANGEPASSWORD);
40 
41 } else {
42  $config_handler =& xoops_gethandler('config');
43  $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
45  $oldpass = @$myts->stripSlashesGPC(trim($_POST['oldpass']));
46  $password = @$myts->stripSlashesGPC(trim($_POST['newpass']));
47  $vpass = @$myts->stripSlashesGPC(trim($_POST['vpass']));
48  $errors = array();
49  if (md5($oldpass) != $GLOBALS['xoopsUser']->getVar('pass', 'n')) {
51  }
52  if (strlen($password) < $GLOBALS['xoopsConfigUser']['minpass']) {
53  $errors[] = sprintf(_US_PWDTOOSHORT, $GLOBALS['xoopsConfigUser']['minpass']);
54  }
55  if ($password != $vpass) {
57  }
58 
59  if ($errors) {
60  $msg = implode('<br />', $errors);
61  } else {
62  //update password
63  $GLOBALS['xoopsUser']->setVar('pass', md5($password));
64 
66  if ($member_handler->insertUser($GLOBALS['xoopsUser'])) {
68  } else {
70  }
71  }
72  redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'), 2, $msg);
73 }
74 
75 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
76 ?>