Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Commit bd81fa4

Browse files
committed
Fixed major issues
1 parent 31df61c commit bd81fa4

File tree

9 files changed

+45
-5
lines changed

9 files changed

+45
-5
lines changed

LICENSE.zip

19.8 KB
Binary file not shown.

config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
return array(
44
'sitename' => 'PHPSocial',
55
'theme' => 'light.css', // Themes are stored in the /css directory, remeber to include the extension when changing the theme
6-
'adminEnabled' => true // TODO: This is broken, does not affect anything.
6+
'adminEnabled' => true,
7+
// Use [sitename] as a placeholder for the website name, it will be automaticly replaced.
8+
'registerPrompts' => array("Join in on the fun of [sitename],", "Join in on the conversation,", "Talk to your friends on [sitename],")
79
);

css/dark.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,22 @@ body{
1919
color: black;
2020
font-weight: bold;
2121
}
22+
a{
23+
color: blue;
24+
}
2225
.post-textarea{
2326
width: 50%;
2427
height: 200px;
2528
resize: none;
26-
background-color: 5d5e68;
29+
background-color: #5d5e68;
30+
color: white;
31+
}
32+
textarea:focus{
33+
outline: none;
34+
}
35+
textarea{
36+
resize: none;
37+
background-color: #5d5e68;
2738
color: white;
2839
}
2940
.header{

css/login.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
body{
2-
margin: auto;
2+
position: absolute;
3+
left: 50%;
4+
top: 50%;
5+
transform: translateX(-50%) translateY(-50%);
36
width: 20%;
47
padding: 20px;
58
text-align: center;

dashboard.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
3636
if (isset($_POST['content'])) {
37-
$content = $_POST['content'];
37+
$content = strip_tags($_POST['content'], "<a><p><b><i><blink><marquee><br>"); // Strip tags as soon as we can to prevent XSS,
3838

3939
// Generate a unique post ID
4040
$postId = uniqid();
@@ -136,6 +136,7 @@
136136
<div class="createpost">
137137
<form method="POST" action="">
138138
<textarea name="content" placeholder="Enter your message here..." required class="post-textarea"></textarea><br><br>
139+
<p>Allowed tags: &ltb>, &ltp>, &lta>, &lti></p>
139140
<input type="submit" value="Create Post">
140141
</form>
141142
</div>

index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
<a href="login.php">Login</a> <a href="register.php">Register</a>
5454
</div>
5555
<h2><?php echo $configs["sitename"] ?></h2>
56+
<div class="registerBanner">
57+
<?php
58+
$sitename = $configs["sitename"];
59+
60+
$msg = $configs["registerPrompts"];
61+
$rand = rand(0, count($msg) - 1);
62+
echo str_replace("[sitename]", $sitename, $msg[$rand]);
63+
?>
64+
<a href="register.php">Register now!</a>
65+
</div>
5666
</div>
5767
<div class="wrapper">
5868
<!-- Bad solution, but I'm way too tired to fix it, should realy do checks before we actually try to use $messages. -->

logout.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
// Logout user
3+
session_destroy();
4+
header('Location: index.php');
5+
exit;

register.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
echo "Username already exists. Please choose a different username.";
3737
exit;
3838
}
39+
40+
// Check if the username contains a space
41+
if (str_contains($username, ' ')) {
42+
echo "Usernames cannot contain spaces.";
43+
exit;
44+
}
3945

4046
// Add new user to the user data
4147
$users[$username] = [

setup/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
</head>
88
<?php
99
// Check if setup has already run
10-
$userFile = json_decode(file_get_contents('db/login.json'), true);
10+
$userFile = json_decode(file_get_contents('../db/login.json'), true);
1111

1212
$userFile[] = $userFile;
13+
// echo $userFile[0]";
14+
1315
if ($userFile[0] != ""){
1416
header("Location: ../index.php");
1517
}

0 commit comments

Comments
 (0)