Commit 38f508db authored by Benjamin Sonntag's avatar Benjamin Sonntag

adding phpmailer autoload class, fixing dolost

parent 1e77caff
RewriteEngine On
RewriteRule /recover/([0-9]*)/([0-9a-fA-F]*) lost.php?id=$1&key=$2 [L]
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
......@@ -64,7 +64,7 @@ if ($found==6 && $_POST["url"]=="") {
$s=fgets($f,1024);
if ($debug) echo ":".$s.":<br>";
}
fputs($f,'user:create("'.$login.'@'.$domain.'","'.$password."\")\n");
fputs($f,'user:create("'.$login.'@'.$domain.'","'.$pass."\")\n");
$s=fgets($f,1024);
if ($debug) echo ":".$s.":<br>";
if (trim($s)=="| OK: User created") {
......
......@@ -42,7 +42,7 @@ if ($found==5 && $_POST["url"]=="") {
if (count($error)==0) {
sleep(5); // Let create some artificial waiting for the one who want to restore many accounts ...
// Does it exist?
$already=@mysql_fetch_assoc(mysql_query("SELECT id FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@jabber.lqdn.fr")."';"));
$already=@mysql_fetch_assoc(mysql_query("SELECT * FROM accounts WHERE jabberid='".addslashes($_POST["login"]."@jabber.lqdn.fr")."';"));
if (!$already) {
$error[]=sprintf(_("This account doesn't exist, or have been permanently destroyed. <a href=\"%s\">Click here to create a new account with this login</a>."),"create.php");
}
......@@ -52,8 +52,23 @@ if ($found==5 && $_POST["url"]=="") {
if ($already["email"]!=hashmail($_POST["email"],$already["email"])) {
$error[]=_("This account's email address is not the one you entered. Please try again with another email address.");
}
$key=substr(md5($csrf_key."-".$already["id"]."-".$already["jabberid"]),0,16);
if (count($error)==0) {
require_once("class.phpmailer.php");
require_once("class.smtp.php");
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->From = $mail_from;
$mail->FromName = $mail_fromname;
$mail->addAddress($_POST["email"]);
$mail->Subject = sprintf(_("Password lost on %s"),$domain);
$mail->Body = sprintf(_("You receive this email because you created an Jabber Chat account on %s and lost your pasword.\n\nPlease click the link below to reset your password.\n\n%s\n\nIf you didn't asked for this password reminder, please ignore this message or contact us.\n\nThanks a lot for your understanding.\nRegards\nThe Jabber Chat Team\n"),$domain,$rooturl."/recover/".$already["id"]."/".$key);
if(!$mail->send()) {
$error[]=_("The email has NOT been sent, please try again later or contact us");
} else {
$info[]=_("An email has been sent to the address you entered. Please check your mail and click the link to reset your password");
}
} // still no error ?
} // no error ?
} // isset ?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment