<?php
session_start();
include('global.php');
if(!$template)
{
    $template = 'default';
}
$tpl = file_get_contents('templates/'.$template.'/signup_new.tpl');
$tpl = str_replace('<*FORMSTART*>', '<form action="create.php" method="post">', $tpl);
$tpl = str_replace('<*FORMEND*>', '</form>', $tpl);
$link = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
$result = mysql_query('select * from amfr_domains');
while($row = mysql_fetch_assoc($result))
{
	$dom = $row['domain'];
	$doms .= '<option value="'.$dom.'">'.$dom.'</option>';
}
mysql_close($link);
$tpl = str_replace('<*DOMAINFIELD*>', '<input type="text" name="domain2">&nbsp;<B>.</B>&nbsp;<select name="domain">'.$doms.'</select>', $tpl);
$tpl = str_replace('<*USERNAMEFIELD*>', '<input type="text" name="user">', $tpl);
$tpl = str_replace('<*EMAILFIELD*>', '<input type="text" name="email">', $tpl);
$tpl = str_replace('<*SUBMITBUTTON*>', '<input type="submit" value="Create Account!">', $tpl);
$tpl = str_replace('<*COPYRIGHT*>', '<a href="http://www.amfrservices.com">AMFR Account Creator version 1.0 Final</a>', $tpl);
if($skeys == 'yes')
{
	$skeytpl = str_replace('<*KEYFIELD*>', '<input type="text" name="c2">', file_get_contents('templates/'.$template.'/signup_key.tpl'));
	$tpl = str_replace('<*SIGNUPKEYFILE*>', $skeytpl, $tpl);
}
else
{
	$tpl = str_replace('<*SIGNUPKEYFILE*>', '', $tpl);
}
if($image == 'yes')
{
	$imagetpl = str_replace('<*IMAGEFIELD*>', '<input type="text" name="image2">', file_get_contents('templates/'.$template.'/signup_image.tpl'));
	$imagetpl = str_replace('<*IMAGE*>', '<img src="image.php">', $imagetpl); 
	$tpl = str_replace('<*IMAGEFILE*>', $imagetpl, $tpl);
}
else
{
	$tpl = str_replace('<*IMAGEFILE*>', '', $tpl);
}
echo $tpl;
?>
