<?
	chdir("..");
	if ( $_POST['change'] ){
		switch($_POST['paypal_subcode']) {
			case 'M': $_POST['paypal_sub'] = "Monthly"; break;
			case 'Y': $_POST['paypal_sub'] = "Yearly"; break;
		}
		$a_string = array(
			'siteurl','sitename','adminemail','adlogin','adpassword',
			'requirepaid','paypal_email','paypal_price','paypal_subcode','paypal_sub',
			'att_max_size','att_filetypes',
			'dbServer','dbUser','dbPass','dbName'
		);
		$str = "<?\n";
		while ($a = each($_POST)){
			if (in_array($a[0], $a_string)){
				$str .= '$'."{$a[0]} = \"".preg_replace("/[\"\\\\]/", "\\\\\\0", $a[1])."\";\n";
			}
		}
		$str .= "\n?>";
		$f = fopen("config.php", "w");
		if ($f){
			fwrite($f, $str);
			fclose($f);
#			echo "<div style='color: red;'>Update variables successful.</div><br>";
		}else{
#			echo "<div style='color: red;'>Update variables failed. Check write permissions for file \"config.php\".</div><br>";
		}
	}
	ob_start();

	include("config.php");
	include("admin/accesscontrol.php");

	include("admin/header.php");
?>
<p><font face=arial size=3>
	<P><b>
		To update your settings, simply change them using the form below and then click on the
		"Update Settings &gt;&gt;" button at the bottom of the page.
	</B> 
	<form method="POST">
	<input type="hidden" name="action" value="config">
	<TABLE class=design bgColor=#ffffff cellPadding=3 cellSpacing=0 width=100% border='1' BORDERCOLOR="#C0C0C0" STYLE="border-collapse: collapse">
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			Site Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Site Name:</TD>
		<TD width=60% class='a1'><input size=55 name="sitename" value="<?=$sitename?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Site URL:</TD>
		<TD width=60% class='a1'><input size=55 name="siteurl" value="<?=$siteurl?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Maximum File Size (in Kb):</TD>
		<TD width=60% class='a1'><input size=55 name="att_max_size" value="<?=$att_max_size?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Allowed File Types (seperated by a |):</TD>
		<TD width=60% class='a1'><input size=55 name="att_filetypes" value="<?=$att_filetypes?>"></TD>
	</TR>
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			Admin Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Email:</TD>
		<TD width=60% class='a1'><input size=55 name="adminemail" value="<?=$adminemail?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">User Name:</TD>
		<TD width=60% class='a1'><input size=55 name="adlogin" value="<?=$adlogin?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Password:</TD>
		<TD width=60% class='a1'><input size=55 name="adpassword" value="<?=$adpassword?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Free Or Paid Subscription? (Turn on for Paid):</TD>
		<TD><input type=checkbox class=checkbox name=requirepaid value=1 <? if ($requirepaid) echo 'checked'; ?>></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">PayPal Email:</TD>
		<TD width=60% class='a1'><input size=55 name="paypal_email" value="<?=$paypal_email?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Subscription Price:</TD>
		<TD width=60% class='a1'><input size=55 name="paypal_price" value="<?=$paypal_price?>"></TD>
	</TR>
	<tr>
		<td><b>Subscription Type</b>:
		<td><SELECT name="paypal_subcode">
			<OPTION value="">---------
			<OPTION value="M"<?=($paypal_subcode == 'M' ? " selected" : '')?>>Monthly</OPTION>
			<OPTION value="Y"<?=($paypal_subcode == 'Y' ? " selected" : '')?>>Yearly</OPTION>
		</SELECT></td></tr>
	<input type=hidden name=paypal_sub value="<?=$paypal_sub?>">
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			MySQL Database Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Server:</TD>
		<TD width=60% class='a1'><input size=55 name="dbServer" value="<?=$dbServer?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">User:</TD>
		<TD width=60% class='a1'><input size=55 name="dbUser" value="<?=$dbUser?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Password:</TD>
		<TD width=60% class='a1'><input size=55 name="dbPass" value="<?=$dbPass?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Database Name:</TD>
		<TD width=60% class='a1'><input size=55 name="dbName" value="<?=$dbName?>"></TD>
	</TR>
	<TR>
		<TD class='a1' colspan=2 align=right>
			<input type="submit" name=change value="Update Settings &gt;&gt;">
		</TD>
	</TR>
	</table>
	</form>
	<br><br><br>
</p>
<?
	include("admin/footer.php");
?>