<?php
/* vim: set ts=4 tw=0 sw=4 noet: */
- require_once 'config.php';
- require_once $CFG->root . 'lib/utils.inc.php';
+ require_once 'config.php';
+ require_once $CFG->root . 'lib/utils.inc.php';
- $auth_url = $_SERVER['PHP_SELF'] . '?op=login';
- $login = $_SERVER['PHP_SELF'];
- $login_form = <<<LF
+ $auth_url = $_SERVER['PHP_SELF'] . '?op=login';
+ $login = $_SERVER['PHP_SELF'];
+ $login_form = <<<LF
<!DOCTYPE html>
<html>
- <head>
- <meta charset="UTF-8">
- <title>Login</title>
- <link rel="stylesheet" href="css/auth.css">
- </head>
- <body>
- <div class="container">
- <div id="login-form">
- <h3>Login</h3>
- <fieldset>
- <form action="$auth_url" method="post">
- <input type="email" name="user" required value="Email" onBlur="if(this.value=='')this.value='Email'" onFocus="if(this.value=='Email')this.value='' "/>
- <input type="password" name="password" required value="Password" onBlur="if(this.value=='')this.value='Password'" onFocus="if(this.value=='Password')this.value='' "/>
- <input type="submit" value="Login"/>
-<!-- <footer class="clearfix">
- <p><span class="info">?</span><a href="#">Forgot Password</a></p>
- </footer>-->
- </form>
- </fieldset>
- </div> <!-- end login-form -->
- <p class="footer">Powered by <a href="https://qtadmin.datanom.net">
- QtAdmin</a>. © 2015 by Michael Rasmussen</p>
- </div>
- </body>
+ <head>
+ <meta charset="UTF-8">
+ <title>Login</title>
+ <link rel="stylesheet" href="css/auth.css">
+ </head>
+ <body>
+ <div class="container">
+ <div id="login-form">
+ <h3>Login</h3>
+ <fieldset>
+ <form action="$auth_url" method="post">
+ <input type="email" name="user" required value="Email" onBlur="if(this.value=='')this.value='Email'" onFocus="if(this.value=='Email')this.value='' "/>
+ <input type="password" name="password" required value="Password" onBlur="if(this.value=='')this.value='Password'" onFocus="if(this.value=='Password')this.value='' "/>
+ <input type="submit" value="Login"/>
+<!-- <footer class="clearfix">
+ <p><span class="info">?</span><a href="#">Forgot Password</a></p>
+ </footer>-->
+ </form>
+ </fieldset>
+ </div> <!-- end login-form -->
+ <p class="footer">Powered by <a href="https://qtadmin.datanom.net">
+ QtAdmin</a>. © 2015 by Michael Rasmussen</p>
+ </div>
+ </body>
</html>
LF;
</html>
LE;
- $util = Utils::getInstance();
- if (isset($_GET['op']))
- $action = $_GET['op'];
- else
- $action = 'default';
+ $util = new Utils;
+ if (isset($_GET['op']))
+ $action = $_GET['op'];
+ else
+ $action = 'default';
- if ($action == 'logout') {
- // logout
- $util->logout();
- echo $login_form;
- } else if ($action == 'login') {
- // login
- $user = $_POST['user'];
- $password = $_POST['password'];
- if ($util->login($user, $password)) {
- header('Location: index.php');
- } else {
- $error = $util->getLoginStatus();
- $error = str_replace('__ERROR__', $error, $login_error);
- echo $error;
- }
- } else {
- echo $login_form;
- }
+ if ($action == 'logout') {
+ // logout
+ $util->logout();
+ echo $login_form;
+ } else if ($action == 'login') {
+ // login
+ $user = $_POST['user'];
+ $password = $_POST['password'];
+ if ($util->login($user, $password)) {
+ header('Location: index.php');
+ } else {
+ $error = $util->getLoginStatus();
+ $error = str_replace('__ERROR__', $error, $login_error);
+ echo $error;
+ }
+ } else {
+ echo $login_form;
+ }
?>