本文整理汇总了PHP中AdminHandler::init方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHandler::init方法的具体用法?PHP AdminHandler::init怎么用?PHP AdminHandler::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHandler
的用法示例。
在下文中一共展示了AdminHandler::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setcookie
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)
}
$h = new AdminHandler();
if ($h->login($fUsername, $fPassword)) {
session_regenerate_id();
$_SESSION['sessid'] = array();
$_SESSION['sessid']['roles'] = array();
$_SESSION['sessid']['roles'][] = 'admin';
$_SESSION['sessid']['username'] = $fUsername;
$_SESSION['PFA_token'] = md5(uniqid(rand(), true));
# they've logged in, so see if they are a domain admin, as well.
if (!$h->init($fUsername)) {
flash_error($PALANG['pLogin_failed']);
}
if (!$h->view()) {
flash_error($PALANG['pLogin_failed']);
}
$adminproperties = $h->result();
if ($adminproperties['superadmin'] == 1) {
$_SESSION['sessid']['roles'][] = 'global-admin';
}
header("Location: main.php");
exit(0);
} else {
# $h->login failed
error_log("PostfixAdmin login failed (username: {$fUsername})");
flash_error($PALANG['pLogin_failed']);
示例2: create_admin
function create_admin($values)
{
DEFINE('POSTFIXADMIN_SETUP', 1);
# avoids instant redirect to login.php after creating the admin
$handler = new AdminHandler(1, 'setup.php');
$formconf = $handler->webformConfig();
if (!$handler->init($values['username'])) {
return array(1, "", $handler->errormsg);
}
if (!$handler->set($values)) {
return array(1, "", $handler->errormsg);
}
if (!$handler->store()) {
return array(1, "", $handler->errormsg);
}
return array(0, $handler->infomsg['success'], array());
}