<?php

if(!isset($_POST['sublink'])) {
show_linkform();
} else {
eval('function cndstrips($str)
{
  return ' . (get_magic_quotes_gpc() ? 'stripslashes($str)' : '$str') . ';
}');
	//begin error checking
	if(trim($_POST['title']) == "") {
		$error[] = "You did not enter the title of your site.";
	}

	
	if(trim($_POST['URL']) == "") {
		$error[] = "You did not enter the URL of your site";
		
	}

	if(trim($_POST['description']) == "") {
		$error[] = "You did not give a description.";
	}

if(trim($_POST['sdEmail']) == "") {
		$error[] = "You did not enter your email.";
	}

if(empty($_POST['image_code'])) {
    $error[]= "Please validate the image code";
  } else {
     include "./datas/captcha/securimage.php";

    $image = new securimage();
    $valid2 = $image->check($_POST['image_code']);

    if(!$valid2) {
      $error[]= "The code you entered was incorrect";
    }
  }

	if($error) {
		echo "<center>\n";
		foreach($error as $oneError) {
			echo "$oneError<br>\n";
		}
		echo "</center>\n";

		echo show_linkform();

} else { //no error
$adminemail=$email; //Enter the direct email to your autoresponder
$subject="New link submitted from :".$rooturl; //this is to identify the origin of the link submission
$message="Title:".cndstrips($_POST['title'])."\nURL:".cndstrips($_POST['URL'])."\nDescription:".cndstrips($_POST['description']);
$headers = "From: ".$_POST['sdName']."<".$_POST['sdEmail'].">\r\n";
		$headers .= "X-Mailer: Subscription form \r\n";
		$headers .= "Content-Type: text/plain";
@mail($adminemail, $subject, $message, $headers);
echo <<<EOD
<h2><font color="#FF0000">{$_POST['sdName']}, your link has been submitted</h2></font><p>We will review your submission and come back to you<br> You will soon receive info about your link review to this email address : {$_POST['sdEmail']}</p>

EOD;
// You can edit the text above between the "EOD" tag (do not alter them and do not remove the newline) to fit your needs
}
}

/*void*/ function show_linkform()
{
$sdName=(!isset($_GET['sn'])?$_POST['sdName']:urldecode($_GET['sn']));
$sdEmail=(!isset($_GET['se'])?$_POST['sdEmail']:urldecode($_GET['se']));
//just assign the sender vars either their get value(if set) otherwise the post val, even if blank
echo <<<EOD





<form method="POST" action="{$_SERVER['PHP_SELF']}">
<input type="hidden" name="sublink" value="submit">
<table>
<tr><td colspan=2>&nbsp;</td></tr>
<tr><td align="right">Title:</td><td align="left"><input type="text" name="title" value="$title" size="40"></td></tr>
<tr><td align="right">URL:</td><td align="left"><input type="text" name="URL" value="$URL" size="40"></td></tr>
<tr><td align="right">Description:</td><td align="left"><textarea name="description" cols="30" rows="7">Insert the description of your site here</textarea></td></tr>
<tr><td align="right">Email:</td><td align="left"><input type="text" name="sdEmail" value="$sdEmail" size="20"></td></tr>
<tr><td align="right">Name:</td><td align="left"><input type="text" name="sdName" value="$sdName" size="20"></td></tr>
<tr>
    <td  align="right" colspan="2"><img src="./datas/captcha/securimage_show.php"></td>
  </tr>
  <tr>
    <td align="right">Enter the text above :</td> 
   <td align="left"><input type="text" name="image_code" /></td>
  </tr>

<tr><td align="right"><input type="Submit" name="submit" value="submit"></td><td align="left">
<input type="reset" value="Clear"></td></tr>
</table>
</form>
EOD;
}




?>
