2011-09-25 21:33:22 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2010 Frank Karlitschek karlitschek@kde.org
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$RUNTIME_NOAPPS = TRUE; //no apps
|
2011-10-03 18:41:52 +00:00
|
|
|
require_once('../../lib/base.php');
|
2011-09-25 21:33:22 +00:00
|
|
|
|
|
|
|
// Someone lost their password:
|
|
|
|
if (isset($_POST['user'])) {
|
|
|
|
if (OC_User::userExists($_POST['user'])) {
|
|
|
|
$token = sha1($_POST['user']+uniqId());
|
|
|
|
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
|
2011-12-18 22:08:00 +00:00
|
|
|
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
|
2011-09-26 19:11:50 +00:00
|
|
|
if (!empty($email)) {
|
2012-02-16 18:45:00 +00:00
|
|
|
$link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php').'?user='.$_POST['user'].'&token='.$token;
|
2011-10-03 18:41:52 +00:00
|
|
|
$tmpl = new OC_Template('core/lostpassword', 'email');
|
2011-09-26 19:11:50 +00:00
|
|
|
$tmpl->assign('link', $link);
|
|
|
|
$msg = $tmpl->fetchPage();
|
|
|
|
$l = new OC_L10N('core');
|
2012-03-19 08:09:18 +00:00
|
|
|
$from = 'lostpassword-noreply@' . $_SERVER['HTTP_HOST'];
|
|
|
|
mail($email, $l->t('Owncloud password reset'), $msg, 'From:' . $from);
|
2011-09-26 19:11:50 +00:00
|
|
|
}
|
2011-10-03 18:41:52 +00:00
|
|
|
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true));
|
2011-09-25 21:33:22 +00:00
|
|
|
} else {
|
2011-10-03 18:41:52 +00:00
|
|
|
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false));
|
2011-09-25 21:33:22 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-10-03 18:41:52 +00:00
|
|
|
OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false));
|
2011-09-25 21:33:22 +00:00
|
|
|
}
|