示例#1
0
 /* password check: password is verified front end by javascript. here is to handle the errors from javascript */
 if ($_POST['password_error'] != "") {
     $pwd_errors = explode(",", $_POST['password_error']);
     foreach ($pwd_errors as $pwd_error) {
         if ($pwd_error == "missing_password") {
             $missing_fields[] = _AT('password');
         } else {
             $msg->addError($pwd_error);
         }
     }
 }
 if (!$msg->containsErrors()) {
     // insert into the db.
     $password = $addslashes($_POST['form_password_hidden']);
     $usersDAO = new UsersDAO();
     if (!$usersDAO->setPassword($_GET['id'], $password)) {
         require TR_INCLUDE_PATH . 'header.inc.php';
         $msg->printErrors('DB_NOT_UPDATED');
         require TR_INCLUDE_PATH . 'footer.inc.php';
         exit;
     }
     // send email to user
     $user_row = $usersDAO->getUserByID($_GET['id']);
     $tmp_message = _AT('password_change_msg') . "\n\n";
     $tmp_message .= _AT('web_site') . ' : ' . TR_BASE_HREF . "\n";
     $tmp_message .= _AT('login_name') . ' : ' . $user_row['login'] . "\n";
     require TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php';
     $mail = new TransformableMailer();
     $mail->From = $_config['contact_email'];
     $mail->AddAddress($user_row['email']);
     $mail->Subject = $_config['site_name'] . ': ' . _AT('password_changed');
 if (isset($_POST['form_change'])) {
     /* password check: password is verified front end by javascript. here is to handle the errors from javascript */
     if ($_POST['password_error'] != "") {
         $pwd_errors = explode(",", $_POST['password_error']);
         foreach ($pwd_errors as $pwd_error) {
             if ($pwd_error == "missing_password") {
                 $missing_fields[] = _AC('password');
             } else {
                 $msg->addError($pwd_error);
             }
         }
     }
     if (!$msg->containsErrors()) {
         //save data
         $password = $addslashes($_POST['form_password_hidden']);
         $usersDAO->setPassword(intval($_REQUEST['id']), $password);
         //send confirmation email
         require AC_INCLUDE_PATH . 'classes/phpmailer/acheckermailer.class.php';
         $tmp_message = _AC(array('password_change_confirm', $_config['site_name'], $_base_href)) . "\n\n";
         $mail = new ACheckerMailer();
         $mail->From = $_config['contact_email'];
         $mail->AddAddress($email);
         $mail->Subject = $_config['site_name'] . ': ' . _AC('password_forgot');
         $mail->Body = $tmp_message;
         if (!$mail->Send()) {
             $msg->printErrors('SENDING_ERROR');
             exit;
         }
         $msg->addFeedback('PASSWORD_CHANGED');
         unset($mail);
         header('Location:index.php');