<?php
if (isset($_REQUEST['id'])) $id = $_REQUEST['id'];
if (isset($_POST['sendto'])) $sendto = $_POST['sendto'];
if (isset($_POST['submit'])) $submit = $_POST['submit'];

// 14-Apr-04 Added the check for missing email address on form

$msg = "";
if ( isset( $submit ) ) {
   // check for crap, log it
   $st = strip_tags($sendto);
   $st = stripslashes($st);
   if ( strstr($sendto, ':') || (strlen($st) != strlen($sendto)) ) {
$fp = fopen( "email.log", "a" );
fwrite( $fp, "Garbage ".date("F j, Y g:ia")."> [[$st]] was [[$sendto]]\n" );
fwrite( $fp, "" );
fclose( $fp );
      $sendto = "";
   }
   if ( $sendto == "" ) {
      $msg = "<p><center><font color='white'><big><strong>I need an email address to send it to!</strong></big></font></center></p>";
   } else {
require("link.php");
   $result = mysqli_query($link, "select * from alumni where id=" . $id ) or die( "No alumni record for id $id" );
   $line = mysqli_fetch_array( $result );
$fp = fopen( "email.log", "a" );
fwrite( $fp, "Sendto ".date("F j, Y g:ia")."> $sendto\n" );
fwrite( $fp, "" );
fclose( $fp );
   $txt = "$sendto requested ".$line["first_name"].' '.$line["last_name"];
if (stristr($sendto, "manueledor") === false) {
   mail( $sendto,
         $line["first_name"] . ' ' . $line["last_name"] . " email address" . " from dorvalhigh.com",
	 $line["email"],
	 "From: ".$line['email'] );
}
else
   $txt = "(Denied) $txt";
   $result = mysqli_query($link, "select * from alumni where email='" . $sendto . "'" );
   if ( mysqli_num_rows( $result ) ) {
      $line = mysqli_fetch_array( $result );
      $txt = $txt ."\n(". $line["first_name"] ." ". $line["last_name"] .")";
   }
   mail( "ralphb@dorvalhigh.com", "email requested", $txt, "From: security@dorvalhigh.com" );
   header( "Location: http://www.dorvalhigh.com/index.php" );
   exit;
   }
}

if ( !isset( $id ) ) die( "No id provided" );
$save_id = $id;
?>

<html>

<head>
<meta http-equiv="Pragma" content="no-cache">
<title>Bio</title>
<style>
<!--
{ background-color: rgb(140,0,140); color: rgb(255,255,255) }
-->
</style>
<script>
<!--
function Email(name) {
window.open('contact.php?select='+name,'contact','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=675,height=475');
}
-->
</script>

</head>

<body text="#FFFf00" bgcolor="#800080" vlink="#FFFFFF">

<h3 align="center"><font color="#F5FC01"><big><big><strong>Request Email Address</strong></big></big></font></h3>

<hr>
<p><a href="http://www.dorvalhigh.com/index.php" style="color: #FFFF00">Return</a></p>

<?php
// replace Email with the alumni count
require("link.php");
$result = mysqli_query($link, "select * from alumni where id=" . $id ) or die( "No alumni record for id $id" );
$line = mysqli_fetch_array( $result );
echo "<center>In an effort to thwart spiders and robots that mine email addresses, I've added an extra layer for validation.<br>";
echo "The requested address will be emailed to you. This prevents anyones email address from appearing anywhere on the site.";
echo "<form method='post' name='mailrequest' action='" . $_SERVER['PHP_SELF'] . "?id=$save_id'>";
echo '<h4><font color="#F5FC01"><big><big><strong>'.$line["first_name"]." ".$line["last_name"].'</strong></big></big></font></h3>';
echo "Your email address: <input type='text' name='sendto' size='30' maxlength='60'><br><br>";
echo $msg;
echo "<input type='submit' name='submit' value='Email to me'>";
echo "<input type=button value='Send from here' onclick='javascript:Email(\"$id\");'>";
echo "</form></center>";
?>
<p><a href="http://www.dorvalhigh.com/index.php" style="color: #FFFF00">Return</a></p>
</body>
</html>
