16
I have modified that index.php page from the hosting module so it doesn't have all that color and crap.. I'm not quite done as you can see when you look at the code.
I'm trying to make it easier to deal with. Easier to add items to the boxes and such.
Quote:
<?
include ('../../mainfile.php');
include ('../../header.php');
extract($_POST);
if(!isset($dn))
{
// domain type
$d="n";
// payment frequency
$f="y";
// taxes quebec, taxes canada
$tax="no";
}
$frequency = "year";
if($f==="m") $frequency="month";
if($f==="y") $frequency="year";
$plan[0][1]=0;
$plan[0][0]="No Hosting - $".$plan[0][1];
$plan[1][1]=3;
$plan[1][0]="Basic 50MB 500MB - $".$plan[1][1];
$plan[2][1]=6;
$plan[2][0]="Standard 100MB 1000MB - $".$plan[2][1];
$plan[3][1]=10;
$plan[3][0]="Professional 200MB 5000MB - ".$plan[3][1];
if($planselect<0) $planselect=0;
$plancount=4;
$extraspace[0][1]=0;
$extraspace[0][0]="+0 MB - $".$extraspace[0][1];
$extraspace[1][1]=2;
$extraspace[1][0]="+100 MB - $".$extraspace[1][1];
$extraspace[2][1]=5;
$extraspace[2][0]="+500 MB - $".$extraspace[2][1];
$extraspace[3][1]=10;
$extraspace[3][0]="+1000 MB - $".$extraspace[3][1];
$extraspace[4][1]=20;
$extraspace[4][0]="+4000 MB - $".$extraspace[4][1];
if($spaceselect<0) $spaceselect=0;
$extraspacecount=5;
$extrabandwidth[0][1]=0;
$extrabandwidth[0][0]="+0GB - $".$extrabandwidth[0][1];
$extrabandwidth[1][1]=10;
$extrabandwidth[1][0]="+5GB - $".$extrabandwidth[1][1];
$extrabandwidth[2][1]=15;
$extrabandwidth[2][0]="+10GB - $".$extrabandwidth[2][1];
$extrabandwidth[3][1]=50;
$extrabandwidth[3][0]="+25GB - $".$extrabandwidth[3][1];
$bandwidthcount=4;
if($f==="y") {
$diskspace = ($extraspace[$spaceselect][1]*12);
$bandwidth = ($extrabandwidth[$bandwidthselect][1]*12);
$plancost = ($plan[$planselect][1]*12);
$monthlyfee=0;
if ($d==="m") {
$domain=0;
} else {
$domain =12;
}
} else {
$diskspace = $extraspace[$spaceselect][1];
$bandwidth = $extrabandwidth[$bandwidthselect][1];
$plancost = $plan[$planselect][1];
$monthlyfee=1;
if ($d==="m") {
$domain=0;
} else {
$domain = "1";
}
}
$setup=10;
$subtotal = $domain+$bandwidth+$diskspace+$plancost+$monthlyfee;
/*if($tax==="IA") {
$gst = $subtotal*0.06;
} else {
$gst = "0";
}*/
?>
<form name="hosting" id="hosting" method="post">
<table width="400px" border="0" cellspacing="0" cellpadding="0">
<!-- DOMAIN NAME -->
<tr><td colspan="2"><b>Domain Name</b></td></tr>
<tr>
<td colspan="2"><input type="text" size="40" name="dn" value="<?php echo $dn;?>">
<select name="tld">
<option <? if($tld===".com") { ?>selected<? } ?>>.com</option>
<option <? if($tld===".org") { ?>selected<? } ?>>.org</option>
<option <? if($tld===".net") { ?>selected<? } ?>>.net</option>
<option <? if($tld===".aviary.info") { ?>selected<? } ?>>.aviary.info</option>
<option <? if($tld===".ca") { ?>selected<? } ?>>.ca</option>
</select></td>
</tr>
<tr>
<td colspan="2"><input type="radio" name="d" value="n" <? if($d==="n") {?>checked<? } ?> ><font face="tahoma,arial" size="2">Purchase new domain - $12<br/>
<input type="radio" name="d" value="t" <? if($d==="t") {?>checked<? } ?> ><font face="tahoma,arial" size="2">Transfer my domain - $12<br/>
<input type="radio" name="d" value="m" <? if($d==="m") {?>checked<? } ?> ><font face="tahoma,arial" size="2">I will manage my own domain name - $0<br />
<input type="radio" name="d" value="m" <? if($d==="m") {?>checked<? } ?> ><font face="tahoma,arial" size="2">I want a subdomain (select .aviary.info above) - $0
</td>
</tr>
<tr><td colspan="2" height="10"></td></tr>
<?
//HOSTING PLANS
print "<tr><td><b>Hosting Plans</b></td>";
print "<td><select name=\"planselect\" style=\"width:225px\">\n";
for($i=0; $i < $plancount; $i++) {
print "<option value=".$i;
if($planselect==$i) print " selected ";
print ">".$plan[$i][0]."</option>";
}
print "</select></td></tr>\n";
//End Hosting Plans
//DISKSPACE
print "<tr><td><b>Additional Diskspace</b></td>";
print "<td><select name=\"spaceselect\" style=\"width:225px\">\n";
for($i=0; $i < $extraspacecount; $i++) {
print "<option value=".$i;
if($spaceselect==$i) print " selected ";
print ">".$extraspace[$i][0]."</option>";
}
print "</select></td></tr>\n";
//End DISKSPACE
//Bandwidth
print "<tr><td><b>Additional Bandwidth</b></td>";
print "<td><select name=\"bandwidthselect\" style=\"width:225px\">\n";
for($i=0; $i < $bandwidthcount; $i++) {
print "<option value=".$i;
if($bandwidthselect==$i) print " selected ";
print ">".$extrabandwidth[$i][0]."</option>";
}
print "</select></td></tr>\n";
//End Bandwidth
?>
<tr><td colspan="2" height="10"></td></tr>
<!-- PAYMENT FREQUENCY -->
<tr><td colspan="2"><b>Payment Frequency</b></td></tr>
<tr><td colspan="2"><input type="radio" name="f" value="y" <? if($f==="y") {?>checked<? } ?> ><font face="tahoma,arial" size="2">Annual Payments</td></tr>
<tr><td colspan="2"><input type="radio" name="f" value="m" <? if($f==="m") {?>checked<? } ?> >Pay Monthly +$1/month (administrative costs)</td></tr>
<?
/* <tr><td colspan="2" height="10"></td></tr>
<!-- TAXES -->
<tr><td colspan="2"><b>Taxes</b></td></tr>
<tr><td colspan="2"><input type="radio" name="tax" value="no" <? if($tax==="no") { ?>checked<? } ?> ><font face="tahoma,arial" size="2">I do NOT live in Iowa</td></tr>
<tr><td colspan="2"><input type="radio" name="tax" value="IA" <? if($tax==="IA") { ?>checked<? } ?> ><font face="tahoma,arial" size="2">Iowa Resident 6%</td></tr>
*/
?>
<tr><td colspan="2" height="10"></td></tr>
<!-- CALCULATE -->
<tr><td colspan="2"align="center"><b><? if(isset($dn)) { ?>Invoice Totals<? } else { ?><? } ?></b></td></tr>
<? if(isset($dn)) { ?>
<tr><td colspan="2" align="left"><b><i>One-time charges</i></b></td></tr>
<tr><td><font size="1" face="tahoma,arial">Setup:</td><td align="right"><font size="1" face="tahoma,arial">$10.00</td></tr>
<tr>
<td><b>Due Today</b></td>
<td align="right"><b><?= sprintf("$%01.2f",$setup) ?></b></td>
</tr>
<tr><td colspan="2" align="left"><b><i>Recurring Charges</i></b></td></tr>
<tr><td><font size="1" face="tahoma,arial">Domain Name: <?= $dn . $tld ?></td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$domain) ?></td></tr>
<tr><td><font size="1" face="tahoma,arial">Plan: <?= $plan[$planselect][0] ?></td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$plancost) ?></td></tr>
<tr><td><font size="1" face="tahoma,arial">Extra Diskspace: <?= $extraspace[$spaceselect][0] ?></td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$diskspace) ?></td></tr>
<tr><td><font size="1" face="tahoma,arial">Extra Bandwidth: <?= $extrabandwidth[$bandwidthselect][0] ?></td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$bandwidth) ?></td></tr>
<? if($f==="m") print "<tr><td><font size=\"1\" face=\"tahoma,arial\">Monthly Billing Fee</td><td align=\"right\"><font size=\"1\" face=\"tahoma,arial\">".sprintf("$%01.2f",$monthlyfee)."</td></tr>"; ?>
<? /* <tr><td><font size="1" face="tahoma,arial">Subtotal</td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$subtotal) ?></td></tr>
<tr><td><font size="1" face="tahoma,arial">IA State Sales Tax (6%)</td><td align="right"><font size="1" face="tahoma,arial"><?= sprintf("$%01.2f",$gst) ?></td></tr> */ ?>
<?php $total = sprintf("%01.2f",($subtotal+$gst));?>
<tr>
<td><b>Due each <?= $frequency ?></b></td>
<td align="right"><b>$<?= $total ?></b></td>
</tr>
<? } ?>
<tr><td colspan="2" align="center"><font size="1"></font> <input type="submit" Value="<? if(isset($dn)) { ?>Recalculate<? } else { ?>Calculate<? } ?>"></td></tr>
<tr><td colspan="2" height="10"></td></tr>
<? if(isset($dn)) { ?>
<!-- CHECKOUT -->
<tr>
<td colspan="2" align="center">
<? if($dn != "") {
$days="365";
$yahoof = "Y";
if($f==="m") {$days="30"; $yahoof="M";}
$company_id = "";
$companyname="Chad Kovac DBA IA Parrot";
$business_email = "chad@aviary.info";
/*
$paysystems = "https://secure.paysystems1.com/cgi-v310/payment/onlinesale-tpppro.asp?product1=" .
$plandesc."-".$dn.$tld."-".$d."-".$planselect."-".$dk."-".$b."-".$f . "&companyid=" . $company_id . "&total=" .
$total. "&repeatamount=" . $total .
"&formget=N&redirect=http://www.webhostingcanada.org/success.php" .
"&redirectfail=http://www.webhostingcanada.org/fail.php&reoccur=Y&cycle=" .
$days . "&totalperiod=100";
*/
$paypal = "https://www.paypal.com/subscriptions/business=" . $business_email . "&item_number=" .
$planselect.$d.$planselect.$spaceselect.$bandwidthselect.$f . "&item_name=Hosting%20".$dn.$tld."&no_note=0&cy_code=CAD" .
"&a1=" . $setup . "&p1=1&t1=D" .
"&a3=" . $total . "&p3=1&t3=" . $yahoof .
"&src=1&sra=1";
?>
<font size=+1><a href="<?= $paypal ?>" target=_blank><b>CLICK HERE to Checkout via PayPal</b></a></font><br>(Paypal to <?=$companyname?>)
<? } else { ?>
<font face="tahoma,arial" color="red">Please type in your <b>Domain Name</b> above, and then click on Recalculate.</font>
<? } ?>
</td>
</tr>
<? } ?>
</table>
</form>
<?
include XOOPS_ROOT_PATH.'/footer.php';
?>
I've also started rearranging the code so it makes more sense and I'm removing all of the <? ?> garbage all over the place so the server doesn't have to stop and start. I'm not sure if PHP is like ASP in this matter but in ASP every time you stop and start the script the server slows down... the more you do it, the slower it all goes.
I also modified this to have a "setup" fee.
I commented/removed tax calculations.
I added a business name.
Reformatted the form and layout.
Cleaned up a few misc bugs including the paypal link.
Keep in mind, I'm not a PHP programmer so be careful with this and give feedback if possible.