Example #1
0
 /**
  * Save a user's new password
  *
  */
 public function ChangePass()
 {
     global $langmessage, $config;
     $fields = 0;
     if (!empty($_POST['oldpassword'])) {
         $fields++;
     }
     if (!empty($_POST['password'])) {
         $fields++;
     }
     if (!empty($_POST['password1'])) {
         $fields++;
     }
     if ($fields < 2) {
         return;
         //assume user didn't try to reset password
     }
     //make sure password and password1 match
     if (!$this->CheckPasswords()) {
         return false;
     }
     //check the old password
     $pass_hash = \gp\tool\Session::PassAlgo($this->user_info);
     $oldpass = \gp\tool::hash($_POST['oldpassword'], $pass_hash);
     if ($this->user_info['password'] != $oldpass) {
         msg($langmessage['couldnt_reset_pass']);
         return false;
     }
     self::SetUserPass($this->users[$this->username], $_POST['password']);
 }
Example #2
0
 /**
  * Display the password algorithm being used for the user
  *
  */
 public function PassAlgo($userinfo)
 {
     $algo = \gp\tool\Session::PassAlgo($userinfo);
     switch ($algo) {
         case 'md5':
         case 'sha1':
             $this->has_weak_pass = true;
             echo '<span style="color:red">' . $algo . '</span>';
             return;
     }
     echo $algo;
 }
Example #3
0
 public function SendPassword()
 {
     global $langmessage, $config;
     $users = \gp\tool\Files::Get('_site/users');
     $username = $_POST['username'];
     if (!isset($users[$username])) {
         message($langmessage['OOPS']);
         return false;
     }
     $userinfo = $users[$username];
     if (empty($userinfo['email'])) {
         message($langmessage['no_email_provided']);
         return false;
     }
     $passwordChars = str_repeat('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 3);
     $newpass = str_shuffle($passwordChars);
     $newpass = substr($newpass, 0, 8);
     $pass_hash = \gp\tool\Session::PassAlgo($userinfo);
     $users[$username]['newpass'] = \gp\tool::hash($newpass, $pass_hash);
     if (!\gp\tool\Files::SaveData('_site/users', 'users', $users)) {
         message($langmessage['OOPS']);
         return false;
     }
     if (isset($_SERVER['HTTP_HOST'])) {
         $server = $_SERVER['HTTP_HOST'];
     } else {
         $server = $_SERVER['SERVER_NAME'];
     }
     $link = \gp\tool::AbsoluteLink('Admin', $langmessage['login']);
     $message = sprintf($langmessage['passwordremindertext'], $server, $link, $username, $newpass);
     //send email
     $mailer = new \gp\tool\Emailer();
     if ($mailer->SendEmail($userinfo['email'], $langmessage['new_password'], $message)) {
         list($namepart, $sitepart) = explode('@', $userinfo['email']);
         $showemail = substr($namepart, 0, 3) . '...@' . $sitepart;
         message(sprintf($langmessage['password_sent'], $username, $showemail));
         return true;
     }
     message($langmessage['OOPS'] . ' (Email not sent)');
     return false;
 }