Sindbad~EG File Manager
<?php
$WhichDisk = $_GET['WhichDisk'];
$SerialNumber = $_GET['SerialNumber'];
$ProductType = $_GET['ProductType'];
function makeOptions($n, $selected)
{ for($i=0;$i<=$n;$i++)
{ if($i==$selected)
echo("<option selected=\"selected\" value=$i> $i </option>");
else
echo("<option value=$i> $i </option>");
}
}
function getSelected($productID, $Which, $Type)
{ if($productID == 1 && $Which == 7 && $Type == "individual")
return 1;
if($productID == 2 && $Which == 3 && $Type == "individual")
return 1;
if($productID == 3 && $Which == 1 && $Type == "individual")
return 1;
if($productID == 4 && $Which == 7 && $Type == "lab")
return 1;
if($productID == 5 && $Which == 3 && $Type == "lab")
return 1;
if($productID == 6 && $Which == 1 && $Type == "lab")
return 1;
return 0;
}
function add_underscores($x)
// replaces spaces by underscores and return the result
{ return ereg_replace(" ", "_", $x);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<?php include ('include/head.php'); ?>
<body onmousemove="closesubnav(event);">
<?php include ('include/body.php'); ?>
<?php
require_once('DB.php');
require_once('query.php');
require_once('GetSerialNumber.php');
?>
<div class="style1" id="pageName">
<h2> Purchase MathXpert
<img alt="MathXpert logo" src="TransparentMathXpertLogo.gif" height="50" width="118"/>
</h2>
<p>
Select desired quantities.
<p>Calculus includes Precalculus and Algebra. Precalculus includes Algebra.
</p>
<p> One-semester versions will run for five months from the date of purchase. You must be connected to the Internet to run these versions. </p>
<p> Grapher only makes graphs; no symbolic mathematics. </p>
<p>MathXpert runs on any version of Windows. You can run it on a Mac using Parallels or BootCamp, or on Linux using WINE. </p>
<form name="OrderForm" action="Order.php" onsubmit="return validatePurchaseForm()" method="post" >
<table><td> <?php // this invisible table holds two tables as entries ?>
<table border="1">
<tr> <td> <strong> For individuals</strong></td><td><strong>Price </strong></td><td><strong>Quantity</strong></td> </tr>
<?php
$sql = "SELECT * FROM Products";
$q = query($sql);
$format = "%01.2f"; // good for American currency, dollars and cents
$count = 0;
while($q->fetchInto($row))
{ $rows[$count] = $row;
++ $count;
}
// now we want to move the Grapher into $rows[3], from last position, and move everything above that down one
$temp = $rows[$count-1]; // grapher
for($i=$count-1; $i > 3; $i--)
{ $rows[$i] = $rows[$i-1];
}
$rows[3] = $temp;
// Now swap entries 4,5,6 with 7,8,9 respectively
for($i=4;$i<7;$i++)
{ $temp = $rows[$i];
$rows[$i] = $rows[$i+3];
$rows[$i+3] = $temp;
}
for($i=0; $i < $count ; ++$i)
{ $row = $rows[$i];
$selected = getSelected($row[0],$WhichDisk, $ProductType); // $row[0] is the product ID
$nSelections = $row[4]; // database contains the default number of choices of quantity
$price = "$" . sprintf($format,$row[2]); // $row[2] is the price, but it needs to be formatted
$name = $row[3]; // but unfortunately it may contain spaces, which are not allowed in HTML name tags
$name = add_underscores($name);
$names[$row[0]] = $name; // so $names[productID] is the name of the selection box for how many of that productID
echo "<tr> <td> $row[1] </td> <td align=right> $price </td> <td> <select name=$name> "; // short name, e.g. "calculus" or "algebra"
makeOptions($nSelections,$selected); // outputs the <option tags
echo "</select>"; // close the selection tag
echo "</tr>"; // close the table row
if($i == 3)
{ echo "</table></td><td width=40> </td><td align=top> <table border=\"1\">";
echo "<tr> <td> <strong> For one-semester use only </strong></td><td><strong>Price </strong></td><td><strong>Quantity</strong></td> </tr>";
}
if($i == 6)
{
echo "</table></td></table>";
echo "<p></p><table border=\"1\">";
echo "<tr> <td> <strong> For school computer labs </strong></td><td><strong>Price </strong></td><td><strong>Quantity</strong></td> </tr>";
}
}
echo " </table> <p>Lab licenses are good for a single-room lab of up to 35 computers. </p>";
?>
<!--
<p>
(<span style="font-style: italic">Optional</span>) Where did you learn about MathXpert?
<input type="text" name="PromoCode" width = "90">
</p>
-->
<p>
<input type="submit" name="Submit" value="Continue">
</p>
</form>
<script>
function validatePurchaseForm()
{
var nItems;
var n1 = document.forms["OrderForm"]["<?php echo $names[7]?>"].value ;
var n2 = document.forms["OrderForm"]["<?php echo $names[8]?>"].value;
var n3 = document.forms["OrderForm"]["<?php echo $names[9]?>"].value;
if((n1 > 0 && n2 > 0) ||( n1 > 0 && n3 > 0) || (n2 > 0 && n3 > 0))
{
alert("Only one one-semester version of MathXpert can be purchased at a time.");
return false;
}
nitems = <?php for($i = 1 ; $i <= $count; $i++) // this PHP code writes Javascript for the form validation
{ $boxname = $names[$i];
echo "document.forms[\"OrderForm\"][\"$boxname\"].value";
if($i < $count-1) echo "+"; else echo ";";
} ?>
if(nitems == 0)
{ alert("To continue, you must select a nonzero quantity of items to purchase.");
return false;
}
if(document.forms["OrderForm"]["calculus"].value == 1 &&
document.forms["OrderForm"]["precalculus"].value == 1 &&
document.forms["OrderForm"]["algebra"].value == 1
)
{ alert("You selected Calculus, Precalculus, and Algebra. That is probably not what you really want, since Calculus includes Precalculus and Precalculus includes Algebra. It might be what you want, if you happen to have three grandchildren who live in different houses and each needs a different version of MathXpert. You will be allowed to continue, but if it is not what you really want, just use the browser's back arrow.");
}
}
</script>
</div>
<?php include ('include/footer.php'); ?>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists