Simple, text-based PHP chat system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

<!--The legacy interface that supports lack of JS -->
header("X-Frame-Options: DENY");
header("Content-Security-Policy: frame-ancestors 'none'", false);
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, initial-scale=1">
<title>Simple Chat</title>
<link rel="shortcut icon" type="image/png" href="chat.png"/>
<link rel="stylesheet" href="style.css" />
<div id="information">
<p><strong>Note:</strong> all times are in UTC.</p>
<div id="messages">
$chat = fopen("chat.txt", "a+") or die("Error upon opening file");
while(!feof($chat)) {
echo "<div class=\"message\">" . fgets($chat) ."</div>";
echo fread($chat,filesize("chat.txt"));
<input type="button" value="Refresh" onclick="history.go(0)" />
<form action="post.php" method="POST">
<input type="text" name="name" <?php if ($_SESSION['name'] !== null) {echo 'value=' . $_SESSION['name'];} ?> />
<input type="text" id="message" name="message" autofocus />
<input type="submit" value="Send" />
<!-- These don\'t actually get displayed to the user, but they are sent along with the request-->
<input type="checkbox" name="type" value="nojs" style="display:none" checked/>
<br /><br />
<a href="#">Simple Chat</a> code &copy; Josias 2018, 2019, 2020. <a href="">See source code</a>