awfully_unsecure_chat_program/cgi-bin/chat/send.php
2021-01-19 20:01:09 +01:00

37 lines
856 B
PHP

<?php
//set error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
if ($_GET["userMessage"] == "") {
return;
}
$userName = $_GET["userName"];
if ($userName == "") {
$userName = "anon";
}
$microtime = microtime();
//generate message
$dateToWrite = date("Y-m-d, H:i:s");
$messageToWrite = "<div>" . $userName . " says:<br>" . $_GET["userMessage"]. "<br><p style=\"text-align:right;\"> id=". $microtime . " | " . $dateToWrite . "</p><hr></div>";
echo $messageToWrite;
//generate filename
$filename = $microtime . ".php";
$filename = "/srv/www/htdocs/chat/messages/" . $filename;
//echo $filename;
//create and write to file
$handler = fopen($filename, "w");
fwrite($handler, $messageToWrite);
fclose($handler);
chmod($filename, 0777);
header("Location: http://filip-nilsen.com/chat");
exit();
?>