<?php
	error_reporting(0);
	//error_reporting(E_ALL);

	$username = $_POST['username'];
	$message = $_POST['discuss'];
	
	date_default_timezone_set("Asia/Jakarta");
	$current = time();
	$date = date("Y-m-d H:i:s",$current);
	
	if (filesize("discussion.txt") > 0) {
		$filename = "discussion.txt";
		$file = fopen($filename,"r");
			$readed = fread($file,filesize($filename));
		fclose($file);
	}
	
	if ($username == "<b>PLEASE LOGIN</b>") {
		echo "Told ya to login! Your comment is not posted yet :/";
	}
	else {
		if (empty($message) == false) {
			$oldcontent = $readed;
			$content = $date . " -- " . $username . ": " . $message . "\r\n" . $oldcontent;
			
			$filename = "discussion.txt";
			$opn = fopen($filename,"w");
			$write = $content;
			fputs($opn,$write);
			fclose($opn);
			
			echo "Your comment has been posted!";
		}
		else {
			echo "Why trying to post an empty comment ? You're soo weird and <b>SUSS</b>";
		}
	}
?>