Update index.php

This commit is contained in:
awesomeuser 2023-08-01 23:27:41 +00:00
parent f7151f335c
commit 739e93ba5d

View file

@ -73,13 +73,20 @@
<?php
// write to file
if (!is_null($_POST["body"]) && strlen($_POST["body"]) != 0) {
$myfile = fopen("posts.txt", "a") or die("Unable to open file! (a)");
// read into a string and concatenate new post to the beginning of the string
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
$construct = fread($myfile,filesize("posts.txt"));
fclose($myfile);
if (!is_null($_POST["signature"]) && strlen($_POST["signature"]) != 0) {
fwrite($myfile, htmlspecialchars($_POST["signature"]) . " [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>");
$construct = htmlspecialchars($_POST["signature"]) . " [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>" + $construct;
} else {
$construct = "anon [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>" + $construct;
}
// write back into the file
$myfile = fopen("posts.txt", "w") or die("Unable to open file!");
fwrite($myfile, $construct);
fclose($myfile);
}
?>
@ -92,7 +99,7 @@
<?php
// read from file
$myfile = fopen("posts.txt", "r") or die("Unable to open file! (r)");
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("posts.txt"));
fclose($myfile);
?>