Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login Form #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
session_start();
if (!isset($_SESSION["username"]) && !in_array(basename(get_included_files()[0]),array("index.php"))) exit();

function eSMAutoload($class)
{
Expand Down
5 changes: 5 additions & 0 deletions conf/esm.config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"login": {
"enable": true,
"username": "username",
"sha256pass": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
},
"esm": {
"version": "2.5",
"website": "http://www.ezservermonitor.com",
Expand Down
48 changes: 47 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
require 'autoload.php';
$Config = new Config();
$update = $Config->checkUpdate();

if (!$Config->get('login:enable'))
$_SESSION["username"]="login_disabled";
else if ( isset($_POST["cmd"]) && $_POST["cmd"]=="Login") {
if (isset($_POST["username"]) && $_POST["username"]==$Config->get('login:username')
&&
isset($_POST["password"]) && hash("sha256", $_POST["password"])==$Config->get('login:sha256pass')){
$_SESSION["username"]=$_POST["username"];
}else{
header("Location:?err=true");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -71,6 +84,39 @@

<div id="main-container">


<?php if (!isset($_SESSION["username"])): ?>
<div class="box">
<form method="POST" action="">
<div class="box-header">
<h1>Login</h1>
<ul>
<li><a href="#" class="reload" onclick='$("#submitbtn").click()'><span class="icon-play"></span></a></li>
</ul>
</div>
<div class="box-content">
<table class="firstBold">
<tbody>
<tr>
<td>Username</td>
<td><input class="input" name="username" type="text" placeholder="Username"></td>
</tr>
<tr>
<td>Password</td>
<td><input class="input" name="password" type="password" placeholder="Password"></td>
</tr>
<?php if (isset($_GET["err"])): ?>
<td><li style="color:red;list-style:none;"><span class="icon-warning"></span> Wrong username or password.</li><td>
<?php endif; ?>
</tbody>
</table>
<input id=submitbtn class="box-header button" type="submit" name="cmd" class="btn btn-primary signup" value="Login">
</div>
</form>
</div>
<?php else: ?>


<div class="box column-left" id="esm-system">
<div class="box-header">
<h1>System</h1>
Expand Down Expand Up @@ -372,7 +418,7 @@

</div>


<?php endif; ?>

<div class="cls"></div>

Expand Down
19 changes: 19 additions & 0 deletions web/css/_src/frontend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ table.firstBold tbody tr td:first-child {
}
}

/* --------------------------- */
/* == Login */
/* --------------------------- */
.button {
color: #fff;
border-style: none;
width: 100%;
font-weight: bold;
text-transform: uppercase;
}
.input {
border: 0px;
width: 100%;
height: 100%;
}







Expand Down
Loading