if (isset($_POST["Submit"])) {
// Remove any tabs
$_POST["name"] = str_replace("\t"," ",$_POST["name"]);
$_POST["msg"] = str_replace("\t"," ",$_POST["msg"]);
// Make name and string lower case for bad language filter
$_POST["name"] = strtolower(stripslashes(trim(htmlspecialchars($_POST["name"]))));
$_POST["msg"] = strtolower(stripslashes(trim(htmlspecialchars($_POST["msg"]))));
if (!file_exists("messages.txt")) {
echo " Messages.txt doesn't exsist. Please create a file call messages.txt on your server ";
} else if ($_POST["name"] == NULL || $_POST["msg"] == NULL) {
echo "Name & message are required fields. Please enter your name and message. ";
} else if (strpos($_POST["msg"], trim($fillinname)) !== FALSE) {
echo "Please fix your message. ";
} else {
$filename = "messages.txt";
$handle = fopen($filename,"r");
$read = file_get_contents($filename);
if ($read != "" || $read != NULL) {
$array = explode("\n", $read);
if ($array[0] != NULL || $array[0] != "") {
list($name, $msg, $time, $ip) = explode("\t", $array[0]);
$ip = trim($ip);
// Convert timestamp to unix timestamp and get current unix timestamp
$strtime = strtotime($time);
$flood_gate_time = $strtime+$floodtime;
$curtime = time();
$valid = true;
}
if ($ip == $_SERVER['REMOTE_ADDR'] && $flood_gate_time > $curtime) {
echo "You must wait ".$floodtime." seconds before posting again ";
} else {
writetofile($_POST["name"],$_POST["msg"]);
}
} else {
writetofile($_POST["name"],$_POST["msg"]);
}
} // end if file exists
} // end submit
?> |