<?php
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>Add a Website to the Top site</title>
</head>
<body>
<div class="header">
<a href="<?php echo $url_topsite; ?>"><img src="<?php echo $design; ?>/images/logo.png" alt="Top site" /></a>
</div>
<div class="content">
<?php
//We check if the form has been submitted
if(isset($_POST['confirmation']) and $_POST['confirmation']=='true')
{
//We remove slashes depending of the configuration
if(get_magic_quotes_gpc())
{
$_POST['name'] = stripslashes($_POST['name']);
$_POST['url'] = stripslashes($_POST['url']);
$_POST['description'] = stripslashes($_POST['description']);
$_POST['banner'] = stripslashes($_POST['banner']);
$_POST['email'] = stripslashes($_POST['email']);
}
//We get the futur ID of the Website
$req1 = mysql_fetch_array(mysql_query('select max(id) as id from topsite'));
$id = intval($req1['id'])+1;
//We send an email to the webmaster
if($mail)
{
$subject = 'Your website subscription - Top site';
$message = "Hy,
You recieve this message after the subscription of your website(".$_POST['url'].") on our top site.
An Admin will check it soon and decide to accept it or not.
You can start earning votes by sharing the following link on your website:
<a href=\"".$url_root."vote.php?id=".$id."\">Vote for this Website</a>
Thank you";
$to = $_POST['email'];
$headers = "From: \"Top site\"<".$mail_webmaster.">\n";
$headers .= "Reply-To: ".$mail_webmaster."\n";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"";
mail($to,$subject,$message,$headers);
}
//We protect the variables and we limit the number of letters of some fields
$name = mysql_escape_string(substr($_POST['name'],0,55));
$url = mysql_escape_string($_POST['url']);
$description = mysql_escape_string(substr($_POST['description'],0,255));
$banner = mysql_escape_string($_POST['banner']);
$email = mysql_escape_string($_POST['email']);
//On ajoute le site a la bdd
if(mysql_query('insert into topsite (id, name, url, description, banner, email, votes, status) values ("'.$id.'", "'.$name.'", "'.$url.'", "'.$description.'", "'.$banner.'", "'.$email.'", 0, "no")'))
{
echo '<strong>Your website has successfully been submited, an admin will check it soon.</strong><br />
You can start earning votes:<br />
<input type="text" value="'.htmlentities('<a href="'.$url_root.'vote.php?id='.$id.'">Vote for this Website</a>').'" size="50" onclick="this.select();" />';
}
else
{
echo '<strong>An error occurred while submitting the website.</strong>';
}
}
else
{
//We display the form
?>
To add your website to this top site, you have to fill the following form:<br />
<form action="new.php" method="post" class="form">
<input type="hidden" name="confirmation" value="true" />
<label for="name">Website Name</label><input type="text" name="name" id="name" maxlength="55" /><br />
<label for="url">URL</label><input type="text" name="url" id="url" /><br />
<label for="description">Description</label><input type="text" name="description" id="description" maxlength="255" /><br />
<label for="banner">Banner</label><input type="text" name="banner" id="banner" /><br />
<label for="email">Email</label><input type="text" name="email" id="email" /><br />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
</div>
<div class="foot">
<a href="<?php echo $url_topsitee; ?>">Return to the Top site</a> - <a href="http://www.webestools.com/">Webestools</a>
</div>
</body>
</html>