You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.5 KiB
PHTML
93 lines
2.5 KiB
PHTML
18 years ago
|
<?php
|
||
17 years ago
|
/**
|
||
|
* Postfix Admin
|
||
|
*
|
||
|
* LICENSE
|
||
|
* This source file is subject to the GPL license that is bundled with
|
||
|
* this package in the file LICENSE.TXT.
|
||
|
*
|
||
11 years ago
|
* Further details on the project are available at http://postfixadmin.sf.net
|
||
17 years ago
|
*
|
||
|
* @version $Id$
|
||
|
* @license GNU GPL v2 or later.
|
||
|
*
|
||
|
* File: login.php
|
||
|
* Authenticates a user, and populates their $_SESSION as appropriate.
|
||
15 years ago
|
* Template File: login.tpl
|
||
17 years ago
|
*
|
||
|
* Template Variables:
|
||
|
*
|
||
13 years ago
|
* none
|
||
17 years ago
|
*
|
||
|
* Form POST \ GET Variables:
|
||
|
*
|
||
|
* fUsername
|
||
|
* fPassword
|
||
7 years ago
|
* token
|
||
17 years ago
|
* lang
|
||
17 years ago
|
*/
|
||
18 years ago
|
|
||
17 years ago
|
require_once('common.php');
|
||
17 years ago
|
|
||
14 years ago
|
if($CONF['configured'] !== true) {
|
||
11 years ago
|
print "Installation not yet configured; please edit config.inc.php or write your settings to config.local.php";
|
||
14 years ago
|
exit;
|
||
|
}
|
||
15 years ago
|
|
||
8 years ago
|
check_db_version(); # check if the database layout is up to date (and error out if not)
|
||
18 years ago
|
|
||
|
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||
|
{
|
||
7 years ago
|
|
||
|
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||
|
|
||
11 years ago
|
$lang = safepost('lang');
|
||
10 years ago
|
$fUsername = trim(safepost('fUsername'));
|
||
11 years ago
|
$fPassword = safepost('fPassword');
|
||
17 years ago
|
|
||
16 years ago
|
if ( $lang != check_language(0) ) { # only set cookie if language selection was changed
|
||
|
setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days
|
||
|
# (language preference cookie is processed even if username and/or password are invalid)
|
||
|
}
|
||
18 years ago
|
|
||
11 years ago
|
$h = new AdminHandler;
|
||
|
if ( $h->login($fUsername, $fPassword) ) {
|
||
11 years ago
|
|
||
8 years ago
|
init_session($fUsername, true);
|
||
11 years ago
|
|
||
11 years ago
|
# they've logged in, so see if they are a domain admin, as well.
|
||
|
|
||
|
if (!$h->init($fUsername)) {
|
||
|
flash_error($PALANG['pLogin_failed']);
|
||
|
}
|
||
18 years ago
|
|
||
11 years ago
|
if (!$h->view()) {
|
||
|
flash_error($PALANG['pLogin_failed']);
|
||
|
}
|
||
|
|
||
|
$adminproperties = $h->result();
|
||
|
|
||
|
if ($adminproperties['superadmin'] == 1) {
|
||
17 years ago
|
$_SESSION['sessid']['roles'][] = 'global-admin';
|
||
|
}
|
||
11 years ago
|
|
||
17 years ago
|
header("Location: main.php");
|
||
|
exit(0);
|
||
11 years ago
|
|
||
|
} else { # $h->login failed
|
||
7 years ago
|
error_log("PostfixAdmin login failed (username: $fUsername, ip_address: {$_SERVER['REMOTE_ADDR']})");
|
||
11 years ago
|
flash_error($PALANG['pLogin_failed']);
|
||
17 years ago
|
}
|
||
18 years ago
|
}
|
||
16 years ago
|
|
||
7 years ago
|
$_SESSION['PFA_token'] = md5(uniqid(rand(), true));
|
||
|
|
||
13 years ago
|
$smarty->assign ('language_selector', language_selector(), false);
|
||
|
$smarty->assign ('smarty_template', 'login');
|
||
11 years ago
|
$smarty->assign ('logintype', 'admin');
|
||
8 years ago
|
$smarty->assign ('forgotten_password_reset', Config::read('forgotten_admin_password_reset'));
|
||
13 years ago
|
$smarty->display ('index.tpl');
|
||
|
|
||
16 years ago
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||
18 years ago
|
?>
|