Sindbad~EG File Manager
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Testing, testing</title>
</head>
<body>
<?php
require_once('DB.php');
require_once('queryWebGrades.php');
$PassedEmail = $_POST['Email'];
function validateNumber($Email, $flag)
// flag % 20 will be used to identify the ProductID idnentifying which CallHome MathXpert Assistant the user is trying to run.
// These ProductIDs are presently 1,2,3 for Calculus, Precalcus, Algebra; 4,5,6 for the Lab Editions of those three,
// then 7,8,9 for the CallHome editions of Calculus, Precalculus, and Algebra, and 10 for the Grapher.
// if flag <= 20 then enrollment in WebGrades is sufficient to run; otherwise you must also have purchased the product from HelpWithMath.
//
// check if a user with this email is allowed to run MathXpert, and if they are enrolled in WebGrades.
// The possible return values are:
// if enrolled in WebGrades and allowed to run: a secret number, at least 17, given by (17 + 23*StudentNumber).
// if email is recognized and they are allowed to run, but not enrolled in WebGrades: 10
// if email is recognized but time limit has expired: 9
// if email is recognized, $flag > 20 (indicating not a PREPAID version) and they are not enrolled in WebGrades: 8
// if email is not recognized: 0
{ if(strcasecmp($Email,"testing2011@gmail.com")==0)
return 40; // just for testing a valid response
$sql = "SELECT * FROM `Students` WHERE Email='$Email';"; // = is case-insensitive in SQL
echo $sql; echo "<br>";
$result = queryWebGrades($sql);
if($result==NULL)
{ return 0; // should never happen, even if there's no data
}
$result->fetchInto($r);
if($r == NULL)
{ return 0; // no student with that email is (or ever was) enrolled or purchased a CallHome version --unrecognized email
}
$enrolled = false;
$StudentNumber = $r[0];
$SecretNumber = 17 + 23 * $StudentNumber;
echo "StudentNumber = $StudentNumber and SecretNumber = $SecretNumber <br>";
// now determine if the student is CURRENTLY enrolled in a WebGrades class
$sql = "SELECT * FROM `Classes` JOIN `Enrolled` ON Classes.ClassID=Enrolled.ClassID WHERE Enrolled.StudentNumber='$StudentNumber' AND CURDATE() <= Classes.EndDate;";
echo $sql; echo "<br>";
$result = queryWebGrades($sql);
if($result == NULL)
{ $enrolled = false;
echo "oops<br>";
}
else
{ $result->fetchInto($r);
if($r != NULL )
{ $enrolled = true;
echo "Enrolled<br>";
}
else
{ $enrolled = false;
echo "not enrolled <br>";
}
}
if($flag <= 20 && $enrolled) // a pre-paid version distributed with a WebGrades class, e.g. in the back of a textbook. They will have to enroll for WebGrades
// before such a version will run.
return $SecretNumber; // user is enrolled in a real class currently
// now check if user has purchased and their license has not expired
$flag = $flag % 20; // the ProductID
$sql = "SELECT * FROM `Expiration` WHERE StudentID='$StudentNumber' AND ProductID >= '$flag' AND CURDATE() <= Expiration.ExpirationDate;";
echo $sql; echo "<br>";
$result = queryWebGrades($sql);
if($result != NULL && $result->fetchRow() != NULL)
{ if($enrolled)
return $SecretNumber;
return 10; // allowed to run, but not enrolled in WebGrades
}
return 9; // email recognized but time limit expired.
}
echo "value of PassedEmail:$PassedEmail"; echo "x<br>";
echo $_POST['Email']; echo "<br>";
$answer = validateNumber($PassedEmail, 27);
echo "Returned $answer<br>";
?>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists