-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
53 lines (49 loc) · 1.87 KB
/
login.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
session_start();
if(isset($_SESSION['login']) && $_SESSION['login'] == true)
{
header("location: index.php");
exit;
}
$username = $passphrase = "";
$errmsg = "";
if(isset($_POST['button']))
{
$username = escapeshellarg(trim($_POST['username']));
$passphrase = escapeshellarg(trim($_POST['passphrase']));
exec("sudo /var/www/html/chkpasswd $username $passphrase", $output, $ret);
if($ret != 0)
{
$errmsg = "Invalid username or password";
} else {
$_SESSION['login'] = true;
header("location: index.php");
exit;
}
}
$pageTitle = "System Login";
include_once("header.php");
?>
<div id="page-wrapper">
<div id="page-inner">
<div class="row" style="padding-right:15px;padding-left:15px;">
<div class="col-md-12">
<h2><?=$pageTitle?></h2>
</div>
</div>
<hr />
<div class="row" style="padding-right:15px;padding-left:15px;">
<?php if($errmsg != "") { ?>
<p><div class="alert alert-warning alert-dismissable"><?=$errmsg?><button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button></div></p>
<?php } ?>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<div style="width:100px;float:left">Username:</div>
<input type="text" style="width:200px;float:left;margin-left:20px;" class="form-control" name="username" placeholder="Enter your Username" /><br style="clear:left;"/>
<div style="width:100px;float:left">Passphrase:</div>
<input type="password" style="width:200px;float:left;margin-left:20px;" class="form-control" name="passphrase" placeholder="Enter your Passphrase" /><br style="clear:left;"/>
<input type="submit" class="btn btn-primary" name="button" value="Login" />
</form>
</div>
</div>
</div>
<?php include_once("footer.php"); ?>