Beispiel #1
0
 public static function lostPasswordConfirmEmail($email)
 {
     global $lC_Database, $lC_Language;
     $lC_Language->loadIniFile('login.php');
     // check for email
     $Qadmin = $lC_Database->query('select * from :table_administrators where user_name = :user_name limit 1');
     $Qadmin->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
     $Qadmin->bindValue(':user_name', $email);
     $Qadmin->execute();
     $admin = $Qadmin->toArray();
     // if email exists we continue
     if ($Qadmin->numberOfRows() > 0) {
         $lC_Database->startTransaction();
         $verify_key = utility::generateUID();
         // set the key to be verified from the resulting email
         $Qsetkey = $lC_Database->query('update :table_administrators set verify_key = :verify_key where user_name = :user_name');
         $Qsetkey->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
         $Qsetkey->bindValue(':user_name', $email);
         $Qsetkey->bindValue(':verify_key', $verify_key);
         $Qsetkey->setLogging($_SESSION['module'], $email);
         $Qsetkey->execute();
         if (!$lC_Database->isError()) {
             $lC_Database->commitTransaction();
             $_SESSION['user_not_exists'] = null;
             $_SESSION['user_confirmed_email'] = $email;
             // set email contents
             $email_text = '';
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_1'), $admin['first_name']) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_2'), $admin['user_name']) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_3'), lc_href_link_admin(FILENAME_DEFAULT, 'login&action=lost_password&email=' . $admin['user_name'] . '&key=' . $verify_key)) . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_4'), $verify_key) . "\n\n";
             $email_text .= $lC_Language->get('text_lost_password_verification_body_line_5') . "\n\n";
             $email_text .= $lC_Language->get('text_lost_password_verification_body_line_6') . "\n\n";
             $email_text .= sprintf($lC_Language->get('text_lost_password_verification_body_line_7'), STORE_NAME) . "\n\n";
             // send verification email
             lc_email($Qadmin->valueProtected('first_name') . ' ' . $Qadmin->valueProtected('last_name'), $Qadmin->valueProtected('user_name'), sprintf($lC_Language->get('text_lost_password_verification_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
             return true;
         } else {
             $lC_Database->rollbackTransaction();
             $_SESSION['user_not_exists'] = true;
             $_SESSION['user_confirmed_email'] = null;
             return false;
         }
     } else {
         $_SESSION['user_not_exists'] = true;
         $_SESSION['user_confirmed_email'] = null;
         return false;
     }
 }