-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.php
28 lines (27 loc) · 874 Bytes
/
validate.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
<?php
session_start();
// Check to see whether the username exists.
if (isset($_POST['username'])) {
$users = file_get_contents("../server_data/users.txt");
$username = '[' . $_POST['username'] . ']';
if (strpos($users, $username) !== false) {
// Set the session variables.
$_SESSION['logged_in'] = true;
$_SESSION['username'] = $_POST['username'];
$_SESSION['token'] = md5(uniqid(rand(), true));
// Check to see if the user is in a group.
if (file_exists("../server_data/users/" . $_POST['username'] . "/group/group.txt")) {
$group = file_get_contents("../server_data/users/" . $_POST['username'] . "/group/group.txt");
$_SESSION['group'] = $group;
}
header("Location: ftpgui.php");
exit;
}
else {
header("Location: login.php?attempts=1&username=" . $_POST['username']);
exit;
}
}
header("Location: login.php?attempts=1");
exit;
?>