Update index.php

This commit is contained in:
awesomeuser 2023-08-02 00:00:30 +00:00
parent 9bae2868f3
commit 06c2d53f3a

View file

@ -70,6 +70,10 @@
</div>
<?php
// make sure the file, well, exists
$myfile = fopen("posts.txt", "a");
fclose($myfile);
// read file into string
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
$content = fread($myfile, filesize("posts.txt"));
@ -82,7 +86,7 @@
if (!is_null($_POST["signature"]) && strlen($_POST["signature"]) != 0) {
$signature = htmlspecialchars($_POST["signature"]);
}
$content = "<div class='post'><h2>" . $signature . "</h2><i>UTC" . date("m/d/Y H:i") . "</i><div>" . htmlspecialchars($_POST["body"]) . "</div></div>" . $content;
$content = "<div class='post'><h2>" . $signature . "</h2><i>UTC " . date("Y/m/d H:i") . "</i><div>" . htmlspecialchars($_POST["body"]) . "</div></div>" . $content;
// write string back into the file
$myfile = fopen("posts.txt", "w") or die("Unable to open file!");