Commit 1f8264ac authored by Franco Fichtner's avatar Franco Fichtner

inc: fix authgui indent and hard to read code by adding style

Currently debugging #86 but the file is impossible to read...
parent 708a2cab
......@@ -56,90 +56,88 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
pfSenseHeader("/{$page}");
$username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username'];
if (!empty($_SERVER['REMOTE_ADDR']))
if (!empty($_SERVER['REMOTE_ADDR'])) {
$username .= '@' . $_SERVER['REMOTE_ADDR'];
}
log_error("{$username} attempted to access {$_SERVER['SCRIPT_NAME']} but does not have access to that page. Redirecting to {$page}.");
exit;
} else {
display_error_form("201", gettext("No page assigned to this user! Click here to logout."));
exit;
}
} else
$_SESSION['Post_Login'] = true;
/*
* redirect browsers post-login to avoid pages
* taking action in reponse to a POST request
*/
if (!$_SESSION['Post_Login']) {
$_SESSION['Post_Login'] = true;
require_once("functions.inc");
pfSenseHeader($_SERVER['REQUEST_URI']);
} else {
display_error_form("201", gettext("No page assigned to this user! Click here to logout."));
exit;
}
} else {
$_SESSION['Post_Login'] = true;
}
/*
* Close session data to allow other scripts from same host to come in.
* A session can be reactivated from calling session_start again
*/
session_commit();
/*
* determine if the user is allowed access to the requested page
*/
function display_error_form($http_code, $desc) {
global $config, $g;
$g['theme'] = get_current_theme();
if(isAjax()) {
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
return;
}
/*
* redirect browsers post-login to avoid pages
* taking action in reponse to a POST request
*/
if (!$_SESSION['Post_Login']) {
$_SESSION['Post_Login'] = true;
require_once("functions.inc");
pfSenseHeader($_SERVER['REQUEST_URI']);
exit;
}
?>
<!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="robots" content="index, follow, noodp, noydir" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title><?=$http_code?></title>
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
</head>
<body class="page-login">
<div id="errordesc">
<h1>&nbsp</h1>
<a href="/index.php?logout">
<p id="errortext" style="vertical-align: middle; text-align: center;">
<span style="color: #000000; font-weight: bold;">
<?=$desc;?>
</span>
</p>
</div>
</body>
</html>
/*
* Close session data to allow other scripts from same host to come in.
* A session can be reactivated from calling session_start again
*/
session_commit();
/*
* determine if the user is allowed access to the requested page
*/
function display_error_form($http_code, $desc)
{
global $config, $g;
$g['theme'] = get_current_theme();
if(isAjax()) {
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
return;
}
<?php
?><!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="robots" content="index, follow, noodp, noydir" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title><?=$http_code?></title>
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
</head>
<body class="page-login">
<div id="errordesc">
<h1>&nbsp</h1>
<a href="/index.php?logout">
<p id="errortext" style="vertical-align: middle; text-align: center;">
<span style="color: #000000; font-weight: bold;">
<?=$desc;?>
</span>
</p>
</div>
</body>
</html><?php
} // end function
function display_login_form() {
function display_login_form()
{
require_once("globals.inc");
global $config, $g;
$g['theme'] = get_current_theme();
......@@ -208,103 +206,97 @@ function display_login_form() {
setcookie("cookie_test", time() + 3600);
$have_cookies = isset($_COOKIE["cookie_test"]);
?>
<!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
?><!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
<!--[if IE 9 ]><html lang="en" class="ie ie9 lte9 no-js"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta name="robots" content="index, follow, noodp, noydir" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?=gettext("Login"); ?></title>
<meta name="robots" content="index, follow, noodp, noydir" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
<title><?=gettext("Login"); ?></title>
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
<link href="/themes/<?=$g['theme'];?>/build/css/main.css" media="screen, projection" rel="stylesheet">
<link href="/themes/<?=$g['theme'];?>/assets/images/favicon.png" rel="shortcut icon">
</head>
<body class="page-login">
<!--[if lt IE 9]><script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script><![endif]-->
<div class="container">
<?php
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
$nifty_background = "#999";
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
}
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
?>
</head>
<body class="page-login">
<div class="container">
<?php
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
$nifty_background = "#999";
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
}
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
?>
<main class="login-modal-container">
<header class="login-modal-head" style="height:55px;">
<a class="navbar-brand" href="/">
<img class="brand-logo" src="/themes/<?=$g['theme'];?>/assets/images/default-logo.png" height="30" width="150"/>
<img class="brand-icon" src="/themes/<?=$g['theme'];?>/assets/images/icon-logo.png" height="30" width="29"/>
</a>
</header>
<div class="login-modal-content">
<div id="inputerrors"><?=$_SESSION['Login_Error'];?></div>
<main class="login-modal-container">
<header class="login-modal-head" style="height:55px;">
<a class="navbar-brand" href="/">
<img class="brand-logo" src="/themes/<?=$g['theme'];?>/assets/images/default-logo.png" height="30" width="150"/>
<img class="brand-icon" src="/themes/<?=$g['theme'];?>/assets/images/icon-logo.png" height="30" width="29"/>
</a>
</header>
<form class="clearfix" id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['SCRIPT_NAME'];?>">
<div class="login-modal-content">
<div id="inputerrors"><?=$_SESSION['Login_Error'];?></div>
<div class="form-group">
<label for="usernamefld"><?=gettext("Username:"); ?>*</label>
<input id="usernamefld" type="text" name="usernamefld" class="form-control user" tabindex="1" />
</div>
<form class="clearfix" id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['SCRIPT_NAME'];?>">
<div class="form-group">
<label for="passwordfld"><?=gettext("Password:"); ?>*</label>
<input id="passwordfld" type="password" name="passwordfld" class="form-control pwd" tabindex="2" />
</div>
<div class="form-group">
<label for="usernamefld"><?=gettext("Username:"); ?>*</label>
<input id="usernamefld" type="text" name="usernamefld" class="form-control user" tabindex="1" />
</div>
<input type="hidden" name="login" value="1" /><!-- XXX login workaround -->
<div class="form-group">
<label for="passwordfld"><?=gettext("Password:"); ?>*</label>
<input id="passwordfld" type="password" name="passwordfld" class="form-control pwd" tabindex="2" />
</div>
<button type="submit" name="login" class="btn btn-primary pull-right"><?=gettext("Login"); ?></button>
<input type="hidden" name="login" value="1" /><!-- XXX login workaround -->
</form>
<button type="submit" name="login" class="btn btn-primary pull-right"><?=gettext("Login"); ?></button>
<?php if (!$have_cookies && isset($_POST['login'])): ?>
<br /><br />
<span class="text-danger">
<?= gettext("Your browser must support cookies to login."); ?>
</span>
<?php endif; ?>
</form>
</div>
<?php if (!$have_cookies && isset($_POST['login'])): ?>
<br /><br />
<span class="text-danger">
<?= gettext("Your browser must support cookies to login."); ?>
</span>
<?php endif; ?>
</main>
</div>
</div>
</main>
<footer class="login-foot container-fluid">
<a target="_blank" href="<?=$g['product_website_footer']?>" class="redlnk"><?=$g['product_name']?></a> is &copy;
<?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a> All Rights Reserved.
[<a href="/license.php" class="tblnk">view license</a>]
</footer>
</div>
<script src="/themes/<?=$g['theme'];?>/build/js/main.min.js" type="text/javascript"></script>
<footer class="login-foot container-fluid">
<a target="_blank" href="<?=$g['product_website_footer']?>" class="redlnk"><?=$g['product_name']?></a> is &copy;
<?=$g['product_copyright_years']?> by <a href="<?=$g['product_copyright_url']?>" class="tblnk"><?=$g['product_copyright']?></a> All Rights Reserved.
[<a href="/license.php" class="tblnk">view license</a>]
</footer>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() { jQuery('#usernamefld').focus(); });
//]]>
</script>
</body>
</html>
<script src="/themes/<?=$g['theme'];?>/build/js/main.min.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() { jQuery('#usernamefld').focus(); });
//]]>
</script>
</body>
</html><?php
<?php
} // end function
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment