tools.class.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of operation_log
  7. *
  8. * @author Administrator
  9. */
  10. class tools {
  11. private static $_tools;
  12. public static function getInstance() {
  13. if (!self::$_tools) {
  14. $c = __CLASS__;
  15. self::$_tools = new $c;
  16. }
  17. return self::$_tools;
  18. }
  19. /*
  20. * update password when login success
  21. */
  22. public function updatePassword() {
  23. if ($_SESSION['ONLINE_USER']['is_demo'] == "t") {
  24. $str = "DEMO cannot update password.";
  25. } else {
  26. $opsw = common::check_input($_POST ['opsw']);
  27. $npsw = common::check_input($_POST ['npsw']);
  28. if (empty(utils::checkPassword($npsw))) {
  29. $username = _getLoginName();
  30. $sql = "select ra_password as password from ra_online_user where lower(user_login) = '" . strtolower($username) . "'";
  31. $rs = common::excuteObjectSql($sql);
  32. $str = '';
  33. if (!empty($rs)) {
  34. if ($rs['password'] == $opsw) {
  35. $sql = "UPDATE ra_online_user SET ra_password = '" . $npsw . "', last_pwd_change = now() WHERE lower(user_login) = '" . strtolower($username) . "'";
  36. $rls = common::excuteUpdateSql($sql);
  37. if (!$rls) {
  38. $str = "Password modification failed!";
  39. } else {
  40. $str = " Your password has been modified!";
  41. }
  42. } else {
  43. $str = "Old password is incorrect!";
  44. }
  45. } else {
  46. $str = "Old password is incorrect!";
  47. }
  48. } else {
  49. $str = "The new password is too simple(must include numbers and letters)";
  50. }
  51. }
  52. $returnData = array("msg" => $str);
  53. common::echo_json_encode(200, $returnData);
  54. exit();
  55. }
  56. }
  57. ?>