This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Setup</title> | ||
</head> | ||
<?php | ||
// Check if setup has already run | ||
$userFile = json_decode(file_get_contents('db/login.json'), true); | ||
|
||
$userFile[] = $userFile; | ||
if ($userFile[0] == ""){ | ||
header("Location: ../index.php"); | ||
} | ||
?> | ||
<body> | ||
<h1>Welcome to PHPSocial setup!</h1> | ||
<p>This setup guide will guide you through setting up PHPSocial.</p> | ||
<h3>First, enter a username and password</h3> | ||
<p>This will be used for the admin account, so pick something secure</p> | ||
<form method="POST" action="page2.php"> | ||
<input type="text" placeholder="Username" name="username"></input> | ||
<input type="password" placeholder="Password" name="password"></input><br><br> | ||
<input type="submit" value="Next"></input> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Setup</title> | ||
</head> | ||
<?php | ||
if ($_SERVER["REQUEST_METHOD"] == "POST"){ | ||
$username = $_POST['username']; | ||
$password = $_POST['password']; | ||
|
||
// Hash the password | ||
$hashedPassword = password_hash($password, PASSWORD_DEFAULT); | ||
|
||
// Load existing user data | ||
$users = json_decode(file_get_contents('../db/login.json'), true); | ||
|
||
// Check if username already exists | ||
if (isset($users[$username])) { | ||
echo "Username already exists. Please choose a different username."; | ||
exit; | ||
} | ||
|
||
// Add new user to the user data | ||
$users[$username] = [ | ||
'password' => $hashedPassword, | ||
'admin' => true | ||
]; | ||
|
||
// Save the updated user data | ||
file_put_contents('../db/login.json', json_encode($users)); | ||
} | ||
?> | ||
<body> | ||
<h1>Finished!</h1> | ||
<p>Thanks for installing PHPSocial!</p> | ||
<a href="/">Login</a> | ||
</body> | ||
</html> |