if (isset($_POST['send'])) {
if (isset($_POST['team_name']) && $_POST['team_name'] != ""
&& isset($_POST['teacher_email']) && $_POST['teacher_email'] != "")
email($_POST['team_name'], $_POST['teacher_email']);
else
error("You have not supplied one or more information");
} else {
?>
Enter your official team name. For verification purposes, please also enter the email address of your supervising teacher. Your PIN will be emailed to your teacher.
}
include "../footer.php";
function email($team_name, $teacher_email)
{
$dataFile = "../files/teams.dat";
$headerLine = `head -1 $dataFile | ../files/.crypt`;
#$teamLine = `tail -n +2 $dataFile | ../files/.crypt | fgrep "\t$team_name\t" | head -1`;
$handle = popen("tail -n +2 $dataFile | ../files/.crypt ", 'r');
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
if (strlen($buffer) > 0) {
list($schoolName, $teamName, ) = preg_split("/\t/", $buffer);
if ($teamName == $team_name) {
$teamLine = $buffer;
break;
}
}
}
pclose($handle);
}
$header = split("\t", trim($headerLine));
$team = split("\t", trim($teamLine));
$teacher_email = strtolower($teacher_email);
foreach ($header as $idx=>$desc) {
if ($desc == "Supervising Teacher") {
$teacher_name = $team[$idx];
} elseif ($desc == "Supervising Teacher's Email") {
if ($teacher_email != strtolower($team[$idx])) {
error("You gave the wrong email address.");
return;
}
} elseif ($desc == "PIN")
$password = $team[$idx];
}
$to = "$teacher_name <$teacher_email>";
$to .= ", progcomp@cse.unsw.edu.au";
#$to = "meicheng@cse.unsw.edu.au";
$subject .= "UNSW COMPUTING ProgComp: PIN for $team_name";
$message = <<
}
function information($message)
{
?>
}
function testmail($to, $subject, $message, $headers)
{
echo "\n";
echo $headers."\n";
echo "TO: ".$to."\n";
echo "SUBJECT: ".$subject."\n";
echo $message."\n";
echo " \n";
}
?>
|