codingneko /
nerve
| 1 | <html> |
||
| 2 | <head> |
||
| 3 | <meta charset="utf-8" /> |
||
| 4 | <title>Nerve</title> |
||
| 5 | <link rel="stylesheet" type="text/css" href="style.css"> |
||
| 6 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
||
| 7 | <script src="scripts/script.js"></script> |
||
| 8 | <noscript> |
||
| 9 | Javascript is recommended and needed if you want to Nerve to automatically refresh messages.<br /> |
||
| 10 | </noscript> |
||
| 11 | </head> |
||
| 12 | <?php |
||
| 13 | session_start(); |
||
| 14 | |||
| 15 | //Configuration |
||
| 16 | $file = "database.json"; |
||
| 17 | $max_file_size = "4000000"; |
||
| 18 | $password = ""; //leave it as is for no password |
||
| 19 | $max_messages = 10; //set this to 0 for unlimited |
||
| 20 | $auto_remove_files = true; |
||
| 21 | |||
| 22 | if (!isset($_SESSION['logged_in'])) { |
||
| 23 | $_SESSION['logged_in'] = false; |
||
| 24 | } |
||
| 25 | $logged_in = false; |
||
| 26 | |||
| 27 | if (!$_SESSION['logged_in'] && $password != "") { |
||
|
1 ignored issue
–
show
introduced
by
Loading history...
|
|||
| 28 | require_once("functions/login.php"); |
||
| 29 | }else if ($_SESSION['logged_in'] || $password == "") { |
||
|
1 ignored issue
–
show
|
|||
| 30 | // display messages |
||
| 31 | require_once("functions/display_messages.php"); |
||
| 32 | $messages = get_messages($file); |
||
| 33 | $logged_in = true; |
||
| 34 | //get last message |
||
| 35 | $last_msg = show_messages($messages, "last_msg"); |
||
| 36 | if (count($messages['messages']) > $max_messages && $max_messages != 0) { |
||
| 37 | array_shift($messages['messages']); |
||
| 38 | $jsondata = json_encode($messages, JSON_PRETTY_PRINT); |
||
| 39 | file_put_contents($file, $jsondata); |
||
| 40 | $file_to_remove = "images/" . $messages['messages'][0]['file']; |
||
| 41 | unlink($file_to_remove); |
||
| 42 | } |
||
| 43 | // post messages |
||
| 44 | require_once("functions/post_messages.php"); |
||
| 45 | |||
| 46 | ?> |
||
| 47 | <body> |
||
| 48 | <div id="messages-container-php"> |
||
| 49 | <?php |
||
| 50 | echo show_messages($messages, "messages"); |
||
| 51 | ?> |
||
| 52 | </div> |
||
| 53 | <?php |
||
| 54 | if ($logged_in) { |
||
|
1 ignored issue
–
show
|
|||
| 55 | ?> |
||
| 56 | <div id="messages"></div> |
||
| 57 | <?php |
||
| 58 | } |
||
| 59 | ?> |
||
| 60 | <form action="" enctype="multipart/form-data" method="post"> |
||
| 61 | <textarea name="message" placeholder="type in a message" cols="42"></textarea><br /><br /> |
||
| 62 | <input type="file" name="file" id="uploadFile"> |
||
| 63 | <input type="submit" name="submit" /> |
||
| 64 | </form> |
||
| 65 | </body> |
||
| 66 | </html> |
||
| 67 | <?php |
||
| 68 | } |
||
| 69 | ?> |
||
| 70 |