break time
This commit is contained in:
parent
eaa44c41d4
commit
4f875a2561
1 changed files with 16 additions and 7 deletions
19
index.php
19
index.php
|
@ -77,28 +77,37 @@
|
|||
</div>
|
||||
|
||||
<?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
|
||||
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
||||
$content = fread($myfile, filesize("posts.txt"));
|
||||
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
|
||||
$signature = "anonymous";
|
||||
if (!is_null($_POST["signature"]) && strlen($_POST["signature"]) != 0) {
|
||||
$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
|
||||
$myfile = fopen("posts.txt", "w") or die("Unable to open file!");
|
||||
fwrite($myfile, $content);
|
||||
fclose($myfile);
|
||||
|
||||
// update size with new change
|
||||
$size = strlen($content);
|
||||
}
|
||||
|
||||
// show content
|
||||
echo $content;
|
||||
// read and show content
|
||||
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
||||
while(!feof($myfile)) {
|
||||
echo fgets($myfile) . "<br>";
|
||||
}
|
||||
fclose($myfile);
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
|
Reference in a new issue