assign("login_failed", TRUE); $smarty->assign("task", $_GET['task']); } else { $smarty->assign("login_failed", FALSE); $smarty->assign("hideLoginForm", TRUE); } if(isset($_POST['email'])) { $query = mysql_query("select * from users where email = '".addslashes($_POST['email'])."'", $conn); if(mysql_num_rows($query) == 1) { $res = mysql_fetch_assoc($query); $smarty->assign("password_sent", TRUE); $newPassword = generateRandomString(8); mysql_query("update users set password = '".$newPassword."' where user_id = '".$res['user_id']."'", $conn); // Text erzeugen $smarty_mail = new Smarty; $smarty_mail->template_dir = $smarty->template_dir; $smarty_mail->compile_dir = $smarty->compile_dir; $smarty_mail->assign("lang", $_SESSION['language']); $smarty_mail->assign("newPassword", $newPassword); $smarty_mail->assign("CONFIG", $CONFIG); while(list($key, $val) = each($res)) { $smarty_mail->assign($key, $val); } $mailText = $smarty_mail->fetch("mail_templates/password/password.tpl.txt"); if($_SESSION['language'] == "DE") { $subject = "Ihr Passwort zur WindCommunity"; } else { $subject = "Your WindCommunity password"; } $message = Swift_Message::newInstance(); $message->setSubject($subject); $message->setFrom(array($CONFIG['noreply_email'])); $message->setBody($mailText, 'text/plain'); $message->setTo(array($res['email'])); $transport = Swift_MailTransport::newInstance(); $mailer = Swift_Mailer::newInstance($transport); $mailer->send($message); } else { if( $_SESSION['language'] == 'DE' ) { $smarty->assign("error", "Zu der eingegebenen E-Mail-Adresse existiert kein gültiges Benutzerkonto."); } else { $smarty->assign("error", "We could not find your account data."); } $smarty->assign("email", $_POST['email']); } mysql_free_result($query); } $smarty->assign("tplContent", "home/login_failed.tpl.html"); $smarty->display("main/main.tpl.html"); ?>