<html>
<head>
<title>Week #6 Advanced ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>
<?
/*
// Check to see if user comes from a bookmark
// If they come from bookmark, deny access
if($HTTP_REFERER == ""){
print("<strong><font size='3' color='red'>Sorry, you must come from the known domain</font></strong> <a href=\"http://www.timslan.com/scriptskewl/index.html\">here</a><br><br>
<strong>Browser Type:</strong> $HTTP_USER_AGENT<br><br>
<strong>Connecting from IP address:</strong> $REMOTE_ADDR<br><br>
BOOKMARK/ TYPE IN <html></body>");
exit();
}else{
// Check to see if they have come from my domain
$mydomain = "http://www.timslan.com";
$scriptschool = "http://class.scriptschool.com";
$adult = "http://www.adultnetsurprise.com";
if(eregi("$mydomain", $HTTP_REFERER) || eregi("$scriptschool.+", $HTTP_REFERER) || eregi("$adult.+", $HTTP_REFERER)) {
// this visitor has come from my domain, so process the form
print("<h5>Welcome to the entrance point!</h5>
<strong>Youre browser type is:</strong> $HTTP_USER_AGENT<br><br>
<strong>You are connecting to me from:</strong> $REMOTE_ADDR<br><br>");
} else {
// This visitor has NOT come from my domain, so do NOT process the form
print("<strong><font size='3' color='red'>Sorry, you must come from the known domain</font></strong> <a href=\"http://www.timslan.com/scriptskewl/index.html\">here</a><br><br>
<strong>Browser Type:</strong> $HTTP_USER_AGENT<br><br>
<strong>Connecting from IP address:</strong> $REMOTE_ADDR <html></body>");
exit();
}
}
*/
?>
<?
// Assigning variables to typed data
$email1 = $_REQUEST['email1'];
$email2 = $_REQUEST['email2'];
$email3 = $_REQUEST['email3'];
$url1 = $_REQUEST['url1'];
$url2 = $_REQUEST['url2'];
$url3 = $_REQUEST['url3'];
$from = $_REQUEST['from'];
// Headers of email
$subject = "Thought you may like these...";
$body_of_email = "$from thought you would like these:
$url1
$url2
$url3";
$additional_headers = "From: $from\n";
// Set Array of recipients from input data
$recipient = array("$email1" , "$email2" , "$email3");
$urls = array("$url1" , "$url2" , "$url3");
// Count Email & Arrays
$size_of_emails = count($recipient);
$size_of_urls = count($urls);
// Action for when button is pushed
if($_POST['button'] == "push"){
// If the sender address is good - validate recipients email
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from)) {
// Loop through recipient email
for($i = 0; $i < $size_of_emails; $i++) {
// Validate recipient email
if(ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $recipient[$i])) {
// Process email
// if(mail($recipient[$i], $subject, $body_of_email, $additional_headers)) {
// If mail process is good - send mail
print("<br>mail sent to $recipient[$i]");
// If mail process is bad - bail out
//}else{
// print("<br>There was a problem with the form. Mail was not sent.");
// }
// If recipient address is bad - print denial message
}else{
print("<br>Mail not sent to $recipient[$i], invalid email format.");
}
}
// If sender address is bad - bail out
}else{
print("$from is not a valid sender address. Mail not sent");
}
}
?>
<form method='POST' action='<? PHP_SELF ?>'>
<input type='hidden' name='button' value='push'>
<table border='0'>
<tr>
<td colspan='2'><u><h4>Share these URLS with your friends</h4></u></td>
</tr>
<tr>
<td>
<strong>To:</strong><br>
Email 1 <input type='text' name='email1' size='30'><br>
Email 2 <input type='text' name='email2'size='30'><br>
Email 3 <input type='text' name='email3'size='30'><br>
<br>
<strong>URL's to Share:</strong><br>
URL 1 <input type='text' name='url1' size='30'><br>
URL 2 <input type='text' name='url2' size='30'><br>
URL 3 <input type='text' name='url3' size='30'><br>
<br>
<strong>From:</strong> <input type='text' name='from' size='30'><br><br>
<center><input type='submit' value='submit'> <input type='reset' value='reset'></center>
</td>
</tr>
</table>
</form>
<a href='../index.html'>BACK</a>
<br>
<iframe src='wk6advsrc.php' width='100%' height='300'></iframe>
<br>
<a href='../index.html'>BACK</a>
</body>
</html>