page->ajaxReplace = array(); $this->GetUsers(); $this->username = $gpAdmin['username']; if( !isset($this->users[$this->username]) ){ msg($langmessage['OOPS']); return; } $this->user_info = $this->users[$this->username]; $cmd = \gp\tool::GetCommand(); switch($cmd){ case 'changeprefs': $this->DoChange(); break; } $this->Form(); } public function DoChange(){ global $gpAdmin; $this->ChangeEmail(); $this->ChangePass(); $this->SaveUserFile(); } public function ChangeEmail(){ global $langmessage; if( empty($_POST['email']) ){ $this->users[$this->username]['email'] = ''; return; } if( $this->ValidEmail($_POST['email']) ){ $this->users[$this->username]['email'] = $_POST['email']; }else{ msg($langmessage['invalid_email']); } } public function ValidEmail($email){ return (bool)preg_match('/^[^@]+@[^@]+\.[^@]+$/', $email); } /** * 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']); } public function Form(){ global $langmessage, $gpAdmin; if( $_SERVER['REQUEST_METHOD'] == 'POST'){ $array = $_POST; }else{ $array = $this->user_info + $gpAdmin; } $array += array('email'=>''); echo '

'.$langmessage['Preferences'].'

'; echo '
'; echo ''; echo ''; //email echo ''; echo ''; echo ''; echo ''; echo ''; $this->AlgoSelect(); echo '
'.$langmessage['general_settings'].'
'; echo $langmessage['email_address']; echo ''; echo ''; echo '
'.$langmessage['change_password'].'
'; echo $langmessage['old_password']; echo ''; echo ''; echo '
'; echo $langmessage['new_password']; echo ''; echo ''; echo '
'; echo $langmessage['repeat_password']; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ' '; echo ' '; echo '
'; echo '

'; echo ''; echo $langmessage['see_also']; echo ' '; echo \gp\tool::Link('Admin_Configuration',$langmessage['configuration'],'','data-cmd="gpabox"'); echo '

'; echo ''; echo '
'; } } } namespace{ class admin_preferences extends \gp\admin\Settings\Preferences{} }