<html>
<head>
<title>Capcha Challenge for SOS project</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="lightgrey" text="#000000">
<!-- //PHP Code by Angelos Stavrou for the SOS project  
       Copyright 2003 Columbia University
//-->
<script language="JavaScript">
// Function to open a new window without toolbar, addressbar etc.
function OpenWindow(strURL) {
  var prefs='toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,'+'height=550,left=0,top=0';

  YourWindow = window.open(strURL,prefs);

}
</script>

<?php
// File Containing Db-Connect info
require("dbconnect.inc.php4");

$answer = $_REQUEST['answer'];
$captcha = $_REQUEST['captcha'];
$answer = trim($answer);
debug("Answer is : [$answer] and the captcha is: [$captcha]");

if (is_file("$captcha")){
	//read the real answer
	$handle = fopen ("$captcha","r");
	$real_answer = fgets ($handle); 
	$real_answer = trim($real_answer);
	debug("The REAL answer is: [$real_answer]");
	fclose($handle);
	//Clean up the links
	unlink("$captcha");
	unlink("$image_tmp_dir/$captcha.jpg");
	if(strcasecmp($answer, $real_answer)) {
		echo "<center>";
       		echo "<h1><Font Color=\"DarkRed\"> Test Results </font></h1>";
	        echo "<hr>";
		echo "<H1> YOU FAILED THE TEST!!!";
	}
	else { //Test Passed
		echo "</center>";
		//include the proxylet file (no need for html headers)
		include($path_to_proxylet);		
	}
}
else {	// session is expired! Someone probably just hit back or reload
    	echo "<center>";
	echo "<h1><Font Color=\"DarkRed\"> Test Results </font></h1>";
	echo "<hr>";
	echo "<H1> Session Expired Sorry";
}
//Debugging Function
function debug ($arg_1){
        global $debug;
        if ($debug){
                print "$arg_1<BR>";
        }
}


?>

<h5> &copy Columbia University
</body>
</html>
