From deb20fdfca35c64066fe4e375099350dc77ea408 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 22 May 2023 15:18:52 -0500 Subject: initial commit --- _classes/Comment.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 _classes/Comment.php (limited to '_classes/Comment.php') diff --git a/_classes/Comment.php b/_classes/Comment.php new file mode 100644 index 0000000..6d4fd48 --- /dev/null +++ b/_classes/Comment.php @@ -0,0 +1,26 @@ +timestamp = date('Y-m-d H:i:s'); + $this->username = $username; + $this->comment = $comment; + $this->postURL = $postURL; + } + + function saveComment(string $fileName) + { + if (file_exists($fileName)) { + $sourceData = file_get_contents($fileName); + $tempArray = json_decode($sourceData); + array_push($tempArray, $this); + $jsonData = json_encode($tempArray, JSON_PRETTY_PRINT); + file_put_contents($fileName, $jsonData); + } else { + die('Error: The ' . $fileName . ' file does not exist.'); + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2