Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/helpwithmath/WebGrades/
Upload File :
Current File : /usr/home/beeson/public_html/helpwithmath/WebGrades/WebGradesEnroll.php

<?php 
 
 // target page of a form to allow a student to enroll in WebGrades by submitting their email address
 // presumes the database already contains information on the class for which the student is enrolling.

session_start(); 

function validate_email($email)
{  // Create the syntactical validation regular expression
   $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
   // Presume that the email is invalid
   $valid = 0;
   // Validate the syntax
   if (eregi($regexp, $email))
   { list($username,$domaintld) = split("@",$email);
      // Validate the domain
     if (getmxrr($domaintld,$mxrecords))  // works on PacWeb server, but not on localhost 
         $valid = 1;
   } 
   else 
      $valid = 0;
   return $valid;
}

if($_GET['state'] == "Edit"  && !is_null($_POST['Email']) && validate_email($_POST['Email']))   
   { session_start();
     $_SESSION['OK'] = "ok";
     $_SESSION['Email'] = $_POST['Email'];  
     $_SESSION['WhichDisk'] = "7";
     $_SESSION['ProductType'] = "Prepaid";
     if(!empty($_REQUEST['Submit32']))
        $_SESSION['OS'] = "Win32";
     if(!empty($_REQUEST['Submit64']))
        $_SESSION['OS'] = "Win64";
     if(!empty($_REQUEST['SubmitMac']))
        $_SESSION['OS'] = "Mac";
        //  these values will be checked in download4.php to determine what file to download
	 header("Location: ../download4.php");
   }


require_once('DB.php');
require_once('../queryWebGrades.php');

if(isset($_POST['ClassName']))
   $ClassName = $_POST['ClassName'];
else 
   $ClassName = $_GET['ClassName'];
if(isset($_POST['Teacher']))
   $Teacher = $_POST['Teacher'];
else 
   $Teacher = $_GET['Teacher'];
if(isset($_POST['Email']))
   $Email = $_POST['Email'];
else 
   $Email = $_GET['Email'];
if(isset($_POST['School']))
   $School = $_POST['School'];
else
   $School = $_GET['School'];
if(isset($_POST['StartDate']))
   $StartDate = $_POST['StartDate'];
else
   $StartDate = $_GET['StartDate'];
if(isset($_POST['FirstName']))
   $FirstName = $_POST['FirstName'];
else
   $FirstName = $_GET['FirstName'];
if(isset($_POST['LastName']))
   $LastName = $_POST['LastName'];
else
   $LastName = $_GET['LastName'];
   
// The following code prevents accessing this page without supplying the required data

if(!isset($Email)) die();
if($_GET['state'] != "Edit")
{
   if(!isset($ClassName)) die();
    if(!isset($Teacher))  $Teacher = "Dr. Beeson";  // see CheckEnrollment.php, can't get this to be passed yet
    if(!isset($School)) die();
    if(!isset($StartDate)) die();
    if(!isset($FirstName))die();
    if(!isset($LastName)) die();
   }
else
   { if($_SESSION['OK'] != "ok")
       die();
   }

$success = 0;



function getStudentNumber($SecretNumber)
// the secret number is congruent to 17 mod 23
// but student numbers auto-increment from 0
{   return $SecretNumber / 23;
}

function getSecretNumber($StudentNumber)
{  return 23* $StudentNumber + 17;
}

   
function enroll(  $ClassName, $Teacher, $Email, $School, $StartDate, $FirstName, $LastName) 
// Store the given data in the webgrades database
{ global $success; 
  // first identify the class
 // $sql = "SELECT * FROM `Classes` WHERE ClassName='$ClassName' AND Teacher='$Teacher' AND School='$School' AND StartDate='$StartDate';";
  $sql = "SELECT * FROM `Classes` WHERE ClassName='$ClassName'  AND School='$School' AND StartDate='$StartDate';";
  //echo $sql; echo "<br>";
  $r = QueryWebGrades($sql);
  $found = false;
  $row = $r->fetchRow();
  if($row==NULL)
      { return "Class not found.  Check the data specified in the web page that contained the form you submitted";
	  }
  else 
      { $success = 1;  // everything from here on must succeed, unless QueryWebGrades causes the whole page to die.
	   // add this student if he isn't already in the Students table
       $ClassID = $row[0];  
       $sql = "SELECT * FROM `Students` WHERE Email='$Email';";
	   $r = QueryWebGrades($sql);
	   $row = $r->fetchRow();
	   if($row != NULL)
	      { // student is already in the database
		     $StudentNumber = $row[0];
		  }
	   else
	      {   $sql = "INSERT INTO `Students` (Email, LastName, FirstName) VALUES('$Email','$LastName','$FirstName');";
		      QueryWebGrades($sql);  // ;does the insertion
	          $sql = "SELECT * FROM `Students` WHERE Email='$Email';";
	          $r = QueryWebGrades($sql);
	          $row = $r->fetchRow();
	          $StudentNumber = $row[0];  
		   }
	   $secretNumber = getSecretNumber($StudentNumber); 	  
	      // secretNumbers are supposed to be congruent to 17 mod 23, so they are not the same as studentNumber in the database
	   $sql = "SELECT * FROM Enrolled WHERE StudentNumber='$StudentNumber' AND ClassID='$ClassID';";
	   $r = QueryWebGrades($sql);
	   if($r->fetchRow() != NULL)
	      return "You were already enrolled for this class.  There is no need to enroll again.   \nYour student number is $secretNumber.  You will need that number to submit your homework from the lab (but from home you will only need your email address).";
       $sql = "INSERT INTO Enrolled (StudentNumber, ClassID) VALUES('$StudentNumber','$ClassID');";
       QueryWebGrades($sql);  // insert this data into the database. 
	   return "You have successfully enrolled in WebGrades for this class.  Your student number is $secretNumber.   You will need that number to view your homework grades.  You will be reminded of it when you submit homework.";
	  }	 
}  
?>

<!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>Enrollment in WebGrades</title>
</head>

<body>
<?php 
 $message = enroll( $ClassName, $Teacher, $Email, $School, $StartDate, $FirstName, $LastName);
 echo "<p>$message</p>";
if($success==1)
{  
   $_SESSION['WhichDisk'] = 7;
   $_SESSION['ProductType'] = "Prepaid";
   $_SESSION['OK'] = "ok";
   $_SESSION['TimeLimit'] = 150;
}
?>

Now you are entitled to download MathXpert Calculus Assistant with WebGrades.   The Download buttons below will let you download a file setup.exe;  save it on 
your computer in a place where you can find it (such as your Desktop), and then run it to install the program.   Some browsers may let you run it directly without saving it first.   If you are not certain which button to click,  read the text below the buttons.

<!--
<form action="../download4.php" method="post" enctype="multipart/form-data" name="form1">
	    <p>
		<input type="submit" name="Submit" value="Download" >         
		</p>
   </form>
<p>   -->
 
 <form action= <?php echo $_SERVER['PHP_SELF']."?state=Edit"?> method="post" enctype="multipart/form-data" name="form1">
    <p></p>
	    <input type="hidden" name = "ProductType" value = <?php echo $ProductType ?> >
	    <input type="hidden" name = "WhichDisk" value = <?php echo $WhichDisk ?> >
	    <input type="hidden" name = "Email" value = <?php echo $Email ?> >
	    <input type="submit" name="Submit32" value="Download Now For 32-bit Windows">   
		<input type="submit" name="Submit64" value="Download Now For 64-bit Windows">   
    <!-- <input type="submit" name="SubmitMac" value = "Download Now for Mac OS X">    -->       
		</p>		
   </form>
   
   <p> To find out if your computer is running a 32-bit or 64-bit version of Windows: </p>
<p> If you are running Windows 7 or Windows Vista: <br>
 Click Start, right-click Computer, and then click Properties.
Under System, you can view the system type. </p>

<p> If you are running Windows XP: <br>
Click Start, right-click My Computer, and then click Properties.
If "x64 Edition" is listed under System, you're running the 64-bit version of Windows XP.
If you don't see "x64 Edition" listed, then you're running the 32-bit version of Windows XP.
	</p>

<p>
   This software will run only when you are connected to the Internet, and it will require you to enter your email address when it starts, so it can verify that you are enrolled in WebGrades.  This software will work while you are enrolled in a class using WebGrades, but it will stop working when your class is over, unless you enroll in another class that uses WebGrades.</p>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists