yup
This commit is contained in:
parent
389cd1c1cc
commit
3ea23ed190
1 changed files with 12 additions and 13 deletions
25
index.php
25
index.php
|
@ -77,29 +77,28 @@
|
|||
</div>
|
||||
|
||||
<?php
|
||||
// write to file
|
||||
if (!is_null($_POST["body"]) && strlen($_POST["body"]) != 0) {
|
||||
// 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);
|
||||
// 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"]);
|
||||
}
|
||||
$construct = $signature . " [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>" . $construct;
|
||||
$content = $signature . " [UTC " . date("m/d/Y H:i") . "] " . htmlspecialchars($_POST["body"]) . "<br>" . $construct;
|
||||
|
||||
// write back into the file
|
||||
// write string back into the file
|
||||
$myfile = fopen("posts.txt", "w") or die("Unable to open file!");
|
||||
fwrite($myfile, $construct);
|
||||
fwrite($myfile, $content);
|
||||
fclose($myfile);
|
||||
}
|
||||
|
||||
// read from file
|
||||
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
||||
echo fread($myfile,filesize("posts.txt"));
|
||||
fclose($myfile);
|
||||
// show content
|
||||
echo $content;
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
|
Reference in a new issue