-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
45 lines (36 loc) · 1.4 KB
/
functions.php
File metadata and controls
45 lines (36 loc) · 1.4 KB
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
<?// Function to validate user credentials
function validateCredentials($username, $password) {
// Read usernames and passwords from the file
$users = file("../../private/users.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Loop through each line in the file
foreach ($users as $user) {
// Split the line into username and password
list($storedEmail, $storedPassword, $storedName, $storedPhone, $storedKey) = explode(":", $user);
// Check if the provided username and password match
if ($username === $storedEmail && $password === $storedPassword) {
return true; // Credentials are valid
}
}
return false; // Credentials are invalid
}
function validateKey($key) {
// Read usernames and passwords from the file
$users = file("../../private/users.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Loop through each line in the file
foreach ($users as $user) {
// Split the line into username and password
list($storedEmail, $storedPassword, $storedName, $storedPhone, $storedKey) = explode(":", $user);
// Check if the provided username and password match
if ($storedKey === $key) {
$user=[
"name" => $storedName,
"email" => $storedEmail,
"phone" => $storedPhone,
"key" => $key
];
return $user;
}
}
return false; // Credentials are invalid
}
?>