<?php
/*=====================================================================*\
|| ###################################################################
-|| # Bugdar [#]version[#]
-|| # Copyright 2002-[#]year[#] Blue Static
+|| # Bugdar
+|| # Copyright 2002-2007 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
-|| # the Free Software Foundation; version [#]gpl[#] of the License.
+|| # the Free Software Foundation; version 2 of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
'passwordreset'
);
-define('SVN', '$Id$');
$focus['user'] = 'focus';
require_once('./global.php');
require_once('./includes/api_user.php');
-require_once('./includes/class_api_error.php');
-
-APIError(array(new API_Error_Handler($message), 'user_cumulative'));
// ###################################################################
-if ($bugsys->userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout')
+if (bugdar::$userinfo['userid'] AND $_REQUEST['do'] != 'logout' AND $_POST['do'] != 'cplogin' AND $_REQUEST['do'] != 'cplogout')
{
- $message->error(_('You are already logged in.'));
+ $message->error(T('You are already logged in.'));
}
// ###################################################################
if (empty($_REQUEST['do']))
{
- eval('$template->flush("' . $template->fetch('login') . '");');
+ BSTemplate::fetch('login')->evaluate()->flush();
}
// ###################################################################
if ($_POST['do'] == 'login' OR $_POST['do'] == 'cplogin')
{
- $keeplogin = $bugsys->input_clean('rememberme', TYPE_BOOL);
+ $keeplogin = $input->inputClean('rememberme', TYPE_BOOL);
if ($_POST['cplogin'])
{
$keeplogin = 0;
$url = 'index.php';
}
- if ($auth->authenticateLogin($bugsys->in['email'], $bugsys->in['password'], $keeplogin))
+ if ($auth->authenticateLogin($input->in['email'], $input->in['password'], $keeplogin))
{
if ($_POST['do'] == 'cplogin')
{
- $hash = $funct->rand(90);
+ $hash = BSFunctions::random(90);
$db->query("DELETE FROM " . TABLE_PREFIX . "adminsession WHERE dateline < " . (TIMENOW - 3600));
$db->query("INSERT INTO " . TABLE_PREFIX . "adminsession (sessionid, userid, dateline) VALUES ('$hash', " . $auth->bugdarUser['userid'] . ", " . TIMENOW . ")");
- $funct->cookie(COOKIE_PREFIX . 'adminsession', $hash, false);
+ BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', $hash, false);
}
- $message->redirect(_('Welcome back! You are now logged in.'), $url);
+ $message->redirect(T('Welcome back! You are now logged in.'), $url);
}
else
{
- $message->error(_('Invalid email or password.'));
+ $message->error(T('Invalid email or password.'));
}
}
if ($_REQUEST['do'] == 'logout')
{
- if ($bugsys->userinfo['userid'])
+ if (bugdar::$userinfo['userid'])
{
- $db->query("DELETE FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $bugsys->input_escape(COOKIE_PREFIX . 'adminsession') . "'");
+ $db->query("DELETE FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $input->inputEscape(COOKIE_PREFIX . 'adminsession') . "'");
$auth->clearCookies();
- $funct->cookie(COOKIE_PREFIX . 'adminsession');
- $message->redirect(_('You have been logged out.'), ($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : 'index.php'));
+ BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
+ $message->redirect(T('You have been logged out.'), ($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : 'index.php'));
}
else
{
- $message->error(_('You need to be logged in to access this feature.'));
+ $message->error(T('You need to be logged in to access this feature.'));
}
}
if ($_POST['do'] == 'sendpw')
{
- $user = new UserAPI($bugsys);
- $user->set('email', $bugsys->in['email'], true, false); // don't verify so we don't get errors about existing emails
- $user->set_condition(array('email'));
+ $user = new UserAPI();
+ $user->set('email', $input->in['email'], true, false); // don't verify so we don't get errors about existing emails
+ $user->setCondition(array('email'));
$user->fetch();
if ($message->hasErrors())
}
else
{
- $activator = $funct->rand(25);
- $db->query("INSERT INTO " . TABLE_PREFIX . "passwordreset (activatorid, dateline, userid) VALUES ('" . $activator . "', " . TIMENOW . ", " . $user->objdata['userid'] . ")");
-
- eval('$email = "' . $template->fetch('email/passwordreset.xml') . '";');
- $email = $bugsys->xml->parse($email);
+ $activator = BSFunctions::random(25);
+ $db->query("INSERT INTO " . TABLE_PREFIX . "passwordreset (activatorid, dateline, userid) VALUES ('" . $activator . "', " . TIMENOW . ", " . $user->record['userid'] . ")");
- $mail->setSubject($email['email']['subject']['value']);
- $mail->setBodyText($email['email']['bodyText']['value']);
+ $email = get_email_text('password_reset');
+ $mail = new BSMail();
+ $mail->setSubject($email['subject']);
+ $mail->setBodyText(sprintf($email['bodyText'], $user->record['displayname'], bugdar::$options['trackertitle'], bugdar::$options['trackerurl'], $activator));
+ $mail->setFromAddress(MAIL_FROM_ADDRESS);
+ $mail->setFromName(MAIL_FROM_NAME);
+ $mail->send($user->record['email'], $user->record['displayname']);
- $mail->send($user->objdata['email'], $user->objdata['displayname']);
-
- $message->message(sprintf(_('An email has been dispatched to %1$s that contains instructions on how to reset your password.'), $user->objdata['email']));
+ $message->message(sprintf(T('An email has been dispatched to %1$s that contains instructions on how to reset your password.'), $user->record['email']));
}
}
if ($_REQUEST['do'] == 'lostpw')
{
- eval('$template->flush("' . $template->fetch('lostpassword') . '");');
+ BSTemplate::fetch('lostpassword')->evaluate()->flush();
}
// ###################################################################
$db->query("DELETE FROM " . TABLE_PREFIX . "passwordreset WHERE dateline < " . (TIMENOW - 86400));
// now look for ours
- $activation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "passwordreset WHERE activatorid = '" . $bugsys->input_escape('activator') . "'");
+ $activation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "passwordreset WHERE activatorid = '" . $input->inputEscape('activator') . "'");
if (!$activation)
{
$message->error(L_INVALID_ID);
}
- $user = new UserAPI($bugsys);
+ $user = new UserAPI();
$user->set('userid', $activation['userid']);
- $user->set_condition();
- if ($bugsys->in['fix_password'] != $bugsys->in['confirm_password'])
+ if ($input->in['fix_password'] != $input->in['confirm_password'])
{
- $message->addError(_('The passwords you entered do not patch.'));
+ $message->addError(T('The passwords you entered do not patch.'));
}
- if (empty($bugsys->in['fix_password']))
+ if (empty($input->in['fix_password']))
{
- $message->addError(_('Your new password cannot be empty.'));
+ $message->addError(T('Your new password cannot be empty.'));
}
- $user->set('password', $bugsys->in['fix_password']);
+ $user->set('password', $input->in['fix_password']);
if (!$message->hasErrors())
{
$db->query("DELETE FROM " . TABLE_PREFIX . "passwordreset WHERE userid = " . $activation['userid']);
$user->update();
- $message->redirect(_('Your password has been changed successfully. You will now be redirected to the login page.'), 'login.php');
+ $message->redirect(T('Your password has been changed successfully. You will now be redirected to the login page.'), 'login.php');
}
else
{
$db->query("DELETE FROM " . TABLE_PREFIX . "passwordreset WHERE dateline < " . (TIMENOW - 86400));
// now look for ours
- $activation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "passwordreset WHERE activatorid = '" . $bugsys->input_escape('activator') . "'");
+ $activation = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "passwordreset WHERE activatorid = '" . $input->inputEscape('activator') . "'");
if (!$activation)
{
- $message->error(_('Invalid activation reset key. Please make sure you copied the URL exactly as it appeared in the email.'));
+ $message->error(T('Invalid activation reset key. Please make sure you copied the URL exactly as it appeared in the email.'));
}
- eval('$template->flush("' . $template->fetch('passwordreset') . '");');
+ $tpl = new BSTemplate('passwordreset');
+ $tpl->vars = array(
+ 'activation' => $activation,
+ 'message' => $message
+ );
+ $tpl->evaluate()->flush();
}
// ###################################################################
{
if ($_COOKIE[COOKIE_PREFIX . 'adminsession'])
{
- $db->query("DELETE FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $bugsys->input_escape(COOKIE_PREFIX . 'adminsession') . "'");
- $funct->cookie(COOKIE_PREFIX . 'adminsession');
- $message->redirect(_('You have been logged out.'), 'admin/');
+ $db->query("DELETE FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $input->inputEscape(COOKIE_PREFIX . 'adminsession') . "'");
+ BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
+ $message->redirect(T('You have been logged out.'), 'admin/');
}
else
{
- $message->error(_('You are not logged in.'));
+ $message->error(T('You are not logged in.'));
}
}
-/*=====================================================================*\
-|| ###################################################################
-|| # $HeadURL$
-|| # $Id$
-|| ###################################################################
-\*=====================================================================*/
-?>
+?>
\ No newline at end of file