-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.php
49 lines (44 loc) · 1.57 KB
/
index.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
<?php
error_reporting(0); // Disable error reporting
session_start(); // Start PHP session handling
// Set your username and password here.
$secretusername = 'username';
$secretpassword = 'password';
// If the user already has a session, then it passes them on to the viewer page.
// Otherwise, it prompts them for the username/password and compares those
// to the ones you set above.
if ($_SESSION['authenticated'] == true) {
header('Location: viewer.php');
} else {
$error = null;
if (!empty($_GET)) {
$username = empty($_GET['username']) ? null : $_GET['username'];
$password = empty($_GET['password']) ? null : $_GET['password'];
if ($username == $secretusername && $password == $secretpassword) {
$_SESSION['authenticated'] = true;
// Redirect to your secure location
header('Location: viewer.php');
return;
} else {
$error = 'Incorrect username or password';
}
}
echo $error;
?>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<div class="login">
<h1>Mostly Secure Camera Viewer</h1>
<form action="index.php">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br /><br />
<input type="submit" value="login" style="background-color: grey;border: none;color: white;text-align: center;padding: 15px 32px;text-decoration: none;display: inline-block;font-size: 16px;" />
</form>
</div>
</body>
<?php
} ?>