| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 558e0c7 commit d62a968
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + <?php | ||
| 2 | + $comments = file_get_contents('_comments.json'); | ||
| 3 | + switch($_SERVER["REQUEST_URI"]) { | ||
| 4 | + case '/': | ||
| 5 | + echo file_get_contents('./public/index.html'); | ||
| 6 | + break; | ||
| 7 | + case '/comments.json': | ||
| 8 | + if($_SERVER['REQUEST_METHOD'] === 'POST') { | ||
| 9 | + $commentsDecoded = json_decode($comments, true); | ||
| 10 | + $commentsDecoded[] = ['author' => $_POST['author'], | ||
| 11 | + 'text' => $_POST['text']]; | ||
| 12 | + | ||
| 13 | + $comments = json_encode($commentsDecoded); | ||
| 14 | + file_put_contents('_comments.json', $comments); | ||
| 15 | + } | ||
| 16 | + header('Content-Type: application/json'); | ||
| 17 | + echo $comments; | ||
| 18 | + break; | ||
| 19 | + default: | ||
| 20 | + return false; | ||
| 21 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments