Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/helpwithmath_old/
Upload File :
Current File : /usr/home/beeson/public_html/helpwithmath_old/TestDeliverTimeLimited.php

<?php 
// This page enables the user to download a time-limited version of MathXpert from an emailed download link.
/* if(!isset($_GET['CustomerID']) || !isset($_GET['ProductID']))
  { 
     header("Location: ./index.php");  
      // redirect to main web page
    } */
require_once('DB.php');
require_once('query.php');
require_once('queryWebGrades.php');
require_once('dates.php');
session_start();
$CustomerID = $_GET['CustomerID'];
$ProductID = $_GET['ProductID'];
if($ProductID == 7)   
    $_SESSION['WhichDisk'] =  7;
else if($ProductID==8)
    $_SESSION['WhichDisk'] = 3;
else
    $_SESSION['WhichDisk'] = 1;

$_SESSION['OK'] = "ok";
$_SESSION['ProductType'] = "paid";
$days = 153;
$_SESSION['TimeLimit'] = $days; 
// next fetch the product name from the database using $ProductID
$sql = "SELECT ProductName FROM `Products` WHERE ProductID='$ProductID';";
$result = query($sql);
$result->fetchInto($r);
$ProductName = $r[0];
// next fetch the email address from the database
$sql = "SELECT Email FROM `Customers` WHERE CustomerID='$CustomerID';";
$result = query($sql);
$result->fetchInto($r);
$Email = $r[0];


$found = false;
// see if this email is already in the WebGrades database
$sql = "SELECT StudentNumber FROM `Students` WHERE Email='$Email';";
$results = queryWebGrades($sql);
if($results!= NULL)
    { $results->fetchInto($r);
	  if($r != NULL)
	       { $StudentNumber = $r[0];
	         $found = true;
		   }
	}
if($found == false) 
    { // enter this new student
	  $sql = "INSERT INTO `Students` (Email,FirstName,LastName) VALUES('$Email','','');";
	  queryWebGrades($sql);  // store the new record
	  // Now we need to bear in mind that when a student registers for WebGrades, his email might already be there with empty name strings.
	}
$deleted = false;
if($Email=="beesonpublic@gmail.com")
      { // remove old entry from Expiration table
	     $sql = "DELETE FROM `Expiration` WHERE StudentID='$StudentNumber' AND ProductID='$ProductID';";
		 queryWebGrades($sql);
		 $deleted = true;
	   }



  
  
 ?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<?php  include ('include/head.php'); 
// compute the expiration date, which will be $days days from now
$today = getdate();
 
$months = $days/30;  // so it will be 5 when days is 153 
$ExpirationDatePHPArray = add_months($today, $months);
$ExpirationDateSQLFormat = SqlDate($ExpirationDatePHPArray);

echo "Customer ID is $CustomerID and ProductID is $ProductID <br>";

 // see if there's already an entry in the Expiration table for this student and product 
 $sql = "SELECT * FROM `Expiration` WHERE StudentID='$StudentNumber' AND ProductID='$ProductID';";
 $result = queryWebGrades($sql);
 $result->fetchInto($r);
 if($r != NULL)
       $todayflag = false;   // don't touch the existing database entry entry.  They can download again, but the expiration date won't change. 
 else 
    { $sql = "INSERT INTO `Expiration` (StudentID, ProductID, ExpirationDate) VALUES('$StudentNumber', '$ProductID', '$ExpirationDateSQLFormat');";
      queryWebGrades($sql);
	  $todayflag = true;
	}  
?>
<body onmousemove="closesubnav(event);"> 
<?php include ('include/body.php'); ?>
  <div class="style1" id="pageName"> 
  <p></p>
<h3> This page allows you to download your copy of <?php echo $ProductName ?>. </h3>
<body>
<p></p>
 <form action="download4.php">
   <input type="submit" value="Download Now">
 </form>
 <p></p>
 <p> This copy will expire on <?php echo format_date($ExpirationDatePHPArray) ?>, which is five months from 
      <?php  if($todayflag) 
	              echo "today.";
               else 
                  echo "the date of your first download. ";
	 
      ?> 
 </p> 
   </div>   
<?php include ('include/footer.php'); ?>
</body>
</html>

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