Log out';
}
function plugin_loginform_convert()
{
return '
' . plugin_basicauthlogout_inline() . '
';
}
function plugin_loginform_action()
{
global $auth_user, $auth_type, $_loginform_messages;
$page = isset($_GET['page']) ? $_GET['page'] : '';
$pcmd = isset($_GET['pcmd']) ? $_GET['pcmd'] : '';
$url_after_login = isset($_GET['url_after_login']) ? $_GET['url_after_login'] : '';
$page_after_login = $page;
if (!$url_after_login) {
$page_after_login = $page;
}
$action_url = get_script_uri() . '?plugin=loginform'
. '&page=' . rawurlencode($page)
. ($url_after_login ? '&url_after_login=' . rawurlencode($url_after_login) : '')
. ($page_after_login ? '&page_after_login=' . rawurlencode($page_after_login) : '');
$username = isset($_POST['username']) ? $_POST['username'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$isset_user_credential = $username || $password ;
if ($username && $password && form_auth($username, $password)) {
// Sign in successfully completed
form_auth_redirect($url_after_login, $page_after_login);
return;
}
if ($pcmd === 'logout') {
// logout
switch ($auth_type) {
case AUTH_TYPE_BASIC:
header('WWW-Authenticate: Basic realm="Please cancel to log out"');
header('HTTP/1.0 401 Unauthorized');
break;
case AUTH_TYPE_FORM:
case AUTH_TYPE_EXTERNAL:
default:
$_SESSION = array();
session_regenerate_id(true); // require: PHP5.1+
session_destroy();
break;
}
$auth_user = '';
return array(
'msg' => 'Log out',
'body' => 'Logged out completely
'
. ''
. $page . ''
);
} else {
// login
ob_start();
?>
$_loginform_messages['login'],
'body' => $body,
);
}
}