-
Notifications
You must be signed in to change notification settings - Fork 1
/
secure_section.php
48 lines (37 loc) · 1.01 KB
/
secure_section.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
<?php
$TITLE="Home";
require_once "header.php";
?>
<?php
$usr_map = array();
$username = $_POST["username"];
$password = $_POST["password"];
$dir = getcwd();
$file = fopen("$dir/users.txt", "r");
while (! feof($file)) {
while ($string = fgets($file)) {
$tokens = explode("|", $string);
$test_username = trim($tokens[0]);
$test_password = trim($tokens[1]);
array_push($usr_map, "$test_username");
if (strcmp($test_username, $username) == 0 && strcmp($test_password, $password) == 0) {
session_start();
$_SESSION["username"] = $username;
break;
}
}
}
if(session_status() === PHP_SESSION_ACTIVE) {
echo "<h3>Users List </h3>";
echo "<p>";
foreach ($usr_map as $value) {
echo "$value<br>";
}
echo "</p>";
} else {
unset($GLOBALS['usr_map']);
unset($GLOBALS['pwd_map']);
echo "<h3 style=\"color:red\">You need to login to see the contain of this page!</h3>";
}
?>
<?php require_once "footer.php"; ?>