break time

This commit is contained in:
awesomeuser 2023-08-01 23:48:04 +00:00
parent eaa44c41d4
commit 4f875a2561

View file

@ -77,28 +77,37 @@
</div> </div>
<?php <?php
$size = filesize("posts.txt");
// write new post to file if necessary
if (!is_null($_POST["body"]) && strlen($_POST["body"]) != 0) {
// read file into string // read file into string
$myfile = fopen("posts.txt", "r") or die("Unable to open file!"); $myfile = fopen("posts.txt", "r") or die("Unable to open file!");
$content = fread($myfile, filesize("posts.txt")); $content = fread($myfile, filesize("posts.txt"));
fclose($myfile); fclose($myfile);
// write new post to file if necessary
if (!is_null($_POST["body"]) && strlen($_POST["body"]) != 0) {
// concatenate new post to the beginning of the string // concatenate new post to the beginning of the string
$signature = "anonymous"; $signature = "anonymous";
if (!is_null($_POST["signature"]) && strlen($_POST["signature"]) != 0) { if (!is_null($_POST["signature"]) && strlen($_POST["signature"]) != 0) {
$signature = htmlspecialchars($_POST["signature"]); $signature = htmlspecialchars($_POST["signature"]);
} }
$content = $signature . " [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>" . $content; $content = $signature . "<br>UTC " . date("m/d/Y H:i") . "<br>" . htmlspecialchars($_POST["body"]) . "<br>" . $content;
// write string back into the file // write string back into the file
$myfile = fopen("posts.txt", "w") or die("Unable to open file!"); $myfile = fopen("posts.txt", "w") or die("Unable to open file!");
fwrite($myfile, $content); fwrite($myfile, $content);
fclose($myfile); fclose($myfile);
// update size with new change
$size = strlen($content);
} }
// show content // read and show content
echo $content; $myfile = fopen("posts.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
echo fgets($myfile) . "<br>";
}
fclose($myfile);
?> ?>
</body> </body>