<?php require ("functions.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Refresh" content="5;URL=<?php echo "http://www.eclectic-blue.com/?page=readComments&news=" . $news; ?>">
<title>Updating . . .</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
<!--
#updatebox {
background-color: #D2CCCA;
border: 2px solid #000;
padding: 10px;
font: 10px;
height: 150px;
width: 200px;
position: absolute;
	top: 40%;
	left: 40%;
text-align: center;
}
-->
</style>
</head>

<body>
<div id="updatebox">
<p>Updating...</p>
<?php
// FUCK YOU http://industria-farmaceutica.com/
$blockedSite = "http://industria-farmaceutica.com";
if (is_substr ($blockedSite, $ENTRY) 
	OR is_substr ($blockedSite, $AUTHOR) 
	OR is_substr ($blockedSite, $HOMEPAGE)) 
	{die ("Go away industria-farmaceutic.com!");}

$dbh = mysql_connect ("localhost", "eclecti_site", "eclectic") or die (mysql_error());
mysql_select_db ("eclecti_site");

if (empty ($AUTHOR) OR empty ($ENTRY) OR empty ($HOMEPAGE) OR empty ($imgNum)) {
	echo "Fill in all the fields.";
}
if (md5 ($imgNum) != $_SESSION['img_num']) {die ("<p>Authentication Failed.</p>");}

else {
	$careful = "SELECT * FROM `comments` WHERE `ENTRY` = '" . $ENTRY . "' AND `NEWS` = '" . $news . "' LIMIT 1";
	$sql = mysql_query ($careful, $dbh);
	if (mysql_num_rows ($sql) > 0) {
		echo "<br /><p>Your comment has been added</p>";
	}
	else {
		$query = "INSERT INTO `comments` 
			( `DATETIME` , `NEWS` , `AUTHOR` , `ENTRY` , `HOMEPAGE` ) 
			VALUES ( '" . date ("Y-m-d H:i:s") . "' , '" . $news . "' , '" . $AUTHOR . "' , '" . htmlentities ($ENTRY) . "' , '" . $HOMEPAGE . "' );";
		$mysql = mysql_query ($query, $dbh);
		if ($mysql) {echo "<br /><p>Sucess!</p>";}
		else {echo "<br /><p>Failure</p>";}
	}
	echo "<br /><a href=\"?page=readComments&news=" . $news . "\">Go Back</a>";
}

?>
</div>
</body>
</html>