本文整理汇总了PHP中Sentinel::setAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::setAdmin方法的具体用法?PHP Sentinel::setAdmin怎么用?PHP Sentinel::setAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::setAdmin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __
}
}
if ($type === 'edit' && !empty($password) || $type === 'add') {
if (mb_strlen($password) < 6) {
$errors['password'] = __('Password must contain at least 6 chars');
}
if ($password !== $password2) {
$errors['password2'] = __('Password confirmation is not the same');
}
}
if (count($errors) === 0) {
if (empty($password)) {
$password = null;
}
if ($roles === 'admin') {
Sentinel::setAdmin($username, $password);
if ($type === 'add') {
Sentinel::log('addadmin ' . $username, $current_user);
}
} else {
$logs = array();
foreach ($logfiles as $fileid => $access) {
if (substr($fileid, 0, 2) === 'f-') {
if ((int) $access === 1) {
$logs[substr($fileid, 2)] = array('r' => true);
}
} else {
if (substr($fileid, 0, 2) === 't-') {
if ((int) $access === 1) {
$tags[substr($fileid, 2)] = array('r' => true);
}
示例2:
break;
/*
|--------------------------------------------------------------------------
| Auth 3. Save data
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| Auth 3. Save data
|--------------------------------------------------------------------------
|
*/
case 'authsave':
if (mb_strlen($_POST['u']) > 0 && mb_strlen($_POST['p']) >= 6) {
Sentinel::setAdmin($_POST['u'], $_POST['p']);
$return['notice'] = Sentinel::save();
}
break;
/*
|--------------------------------------------------------------------------
| Logs 1. Check if $config_file already exists
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| Logs 1. Check if $config_file already exists
|--------------------------------------------------------------------------
|
*/
示例3: sprintf
?>
</div></div></div></div></div></div><div class="tab-pane" id="authactivation"><?php
$return = '';
if (@$_POST['action'] === 'authactivation') {
Sentinel::init();
Sentinel::create();
if (Sentinel::userExists($_POST['username'])) {
$return = '<br/><div class="alert alert-danger" role="alert">' . sprintf(__('User %s already exists!'), '<code>' . $_POST['username'] . '</code>') . '</div>';
} else {
if ($_POST['password'] !== $_POST['password2']) {
$return = '<br/><div class="alert alert-danger" role="alert">' . __('Password confirmation is not the same') . '</div>';
} else {
if (mb_strlen($_POST['password']) < 6) {
$return = '<br/><div class="alert alert-danger" role="alert">' . __('Password must contain at least 6 chars') . '</div>';
} else {
Sentinel::setAdmin($_POST['username'], $_POST['password']);
Sentinel::save();
$return = '<br/><div class="alert alert-success" role="alert">' . __('Authentication has been enabled and admin account has been created!') . '</div>';
}
}
}
}
if (Sentinel::isAuthSet()) {
echo $return;
?>
<br><div class="alert alert-info" role="alert"><?php
_e('Authentication is currently enabled');
?>
</div><br><div class="row"><div class="col-xs-12"><div class="alert alert-danger"><?php
_e('Please remove this file on your server to disable authentication');
?>