[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/public/ -> chpwd.php (source)

   1  <?php /* $Id: chpwd.php 102 2008-03-18 19:52:59Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/public/chpwd.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  if (!($user_id = w2PgetParam($_REQUEST, 'user_id', 0))) {
   7      $user_id = $AppUI->user_id;
   8  }
   9  
  10  // check for a non-zero user id

  11  if ($user_id) {
  12      $old_pwd = db_escape(trim(w2PgetParam($_POST, 'old_pwd', null)));
  13      $new_pwd1 = db_escape(trim(w2PgetParam($_POST, 'new_pwd1', null)));
  14      $new_pwd2 = db_escape(trim(w2PgetParam($_POST, 'new_pwd2', null)));
  15  
  16      $perms = &$AppUI->acl();
  17      $canAdminEdit = $perms->checkModule('admin', 'edit');
  18  
  19      // has the change form been posted

  20      if ($new_pwd1 && $new_pwd2 && $new_pwd1 == $new_pwd2) {
  21          // check that the old password matches

  22          $old_md5 = md5($old_pwd);
  23          $q = new DBQuery;
  24          $q->addTable('users');
  25          $q->addQuery('user_id');
  26          $q->addWhere('user_password = \'' . $old_md5 . '\'');
  27          $q->addWhere('user_id = ' . (int)$user_id);
  28          if ($canAdminEdit || $q->loadResult() == $user_id) {
  29              require_once ($AppUI->getModuleClass('admin'));
  30              $user = new CUser();
  31              $user->user_id = $user_id;
  32              $user->user_password = $new_pwd1;
  33  
  34              if (($msg = $user->store())) {
  35                  $AppUI->setMsg($msg, UI_MSG_ERROR);
  36              } else {
  37                  echo '<h1>' . $AppUI->_('Change User Password') . '</h1>';
  38                  if (function_exists('styleRenderBoxTop')) {
  39                      echo styleRenderBoxTop();
  40                  }
  41                  echo '<table width="100%" cellspacing="0" cellpadding="4" border="0" class="std"><tr><td>' . $AppUI->_('chgpwUpdated') . '</td></tr></table>';
  42              }
  43          } else {
  44              echo '<h1>' . $AppUI->_('Change User Password') . '</h1>';
  45              if (function_exists('styleRenderBoxTop')) {
  46                  echo styleRenderBoxTop();
  47              }
  48              echo '<table width="100%" cellspacing="0" cellpadding="4" border="0" class="std"><tr><td>' . $AppUI->_('chgpwWrongPW') . '</td></tr></table>';
  49          }
  50      } else {
  51  ?>
  52  <script language="javascript">
  53  function submitIt() {
  54      var f = document.frmEdit;
  55      var msg = '';
  56  
  57      if (f.new_pwd1.value.length < <?php echo w2PgetConfig('password_min_len'); ?>) {
  58              msg += "<?php echo $AppUI->_('chgpwValidNew', UI_OUTPUT_JS); ?>" + <?php echo w2PgetConfig('password_min_len'); ?>;
  59              f.new_pwd1.focus();
  60      }
  61      if (f.new_pwd1.value != f.new_pwd2.value) {
  62          msg += "\n<?php echo $AppUI->_('chgpwNoMatch', UI_OUTPUT_JS); ?>";
  63          f.new_pwd2.focus();
  64      }
  65      if (msg.length < 1) {
  66          f.submit();
  67      } else {
  68          alert(msg);
  69      }
  70  }
  71  </script>
  72  <h1><?php echo $AppUI->_('Change User Password'); ?></h1>
  73  <?php
  74          if (function_exists('styleRenderBoxTop')) {
  75              echo styleRenderBoxTop();
  76          }
  77  ?>
  78  <form name="frmEdit" method="post" onsubmit="return false">
  79  <input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
  80  <table width="100%" cellspacing="0" cellpadding="4" border="0" class="std">
  81  <?php if (!$canAdminEdit) {
  82  ?>
  83  <tr>
  84      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Current Password'); ?></td>
  85      <td><input type="password" name="old_pwd" class="text" /></td>
  86  </tr>
  87  <?php } ?>
  88  <tr>
  89      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('New Password'); ?></td>
  90      <td><input type="password" name="new_pwd1" class="text" /></td>
  91  </tr>
  92  <tr>
  93      <td align="right" nowrap="nowrap"><?php echo $AppUI->_('Repeat New Password'); ?></td>
  94      <td><input type="password" name="new_pwd2" class="text" /></td>
  95  </tr>
  96  <tr>
  97      <td>&nbsp;</td>
  98      <td align="right" nowrap="nowrap"><input type="button" value="<?php echo $AppUI->_('submit'); ?>" onclick="submitIt()" class="button" /></td>
  99  </tr>
 100  <form>
 101  </table>
 102  <?php
 103      }
 104  } else {
 105      echo '<h1>' . $AppUI->_('Change User Password') . '</h1>';
 106      if (function_exists('styleRenderBoxTop')) {
 107          echo styleRenderBoxTop();
 108      }
 109      echo '<table width="100%" cellspacing="0" cellpadding="4" border="0" class="std"><tr><td>' . $AppUI->_('chgpwLogin') . '</td></tr></table>';
 110  }
 111  ?>


Generated: Fri Jan 9 03:00:02 2009 Cross-referenced by PHPXref 0.7