template_dir = './templates';
$smarty->compile_dir = './templates_c';
$smarty->cache_dir = './cache';
$smarty->config_dir = './configs';
$error_msg = "";
$cf = new ClientConfiguration();
$cf->parse('testcc.xml') or $error_msg .= "No configuration could be loaded.";
if ($_POST['SaveCC']) {
if ($_POST['ArchType']) {
$error_msg .= "Found an architecture: you submitted " . $_POST['ArchType']. "
\n";
$cf->set("architecture_template", $_POST['ArchType']);
#$error_msg .= "ERROR: Could not set the Architecture Template
\n";
}
if ($_POST['Logfile']) {
$error_msg .= "Found a logfile: you submitted " . $_POST['Logfile'] . "
\n";
$cf->set("log_file",$_POST['Logfile']);
#$error_msg .= "ERROR: Could not set the Logfile
\n";
}
if ($_POST['RootMountPoint']) {
$error_msg .= "Found a root mount point: you submitted " . $_POST['RootMountPoint'] . "
\n";
$cf->set("root_mount_point",$_POST['RootMountPoint']);
#$error_msg .= "ERROR: Could not set the Root Mount Point
\n";
}
if ($_POST['Network_Iface']) {
$error_msg .= "Found a network interface: you submitted " . $_POST['Network_Iface'] . "
\n";
$cf->set("network_interface", $_POST['Network_Iface']);
#$error_msg .= "ERROR: Could not set the Network Interface
\n";
}
if ($_POST['Network_Type']) {
$error_msg .= "Found a Network Type: you submitted " . $_POST['Network_Type'] . "
\n";
$cf->set("network_type", $_POST['Network_Type']);
#$error_msg .= "ERROR: Could not set the Network Type
\n";
}
if ($_POST['dhcp_options']) {
$error_msg .= "Found DHCP Options. You submitted " . $_POST['dhcp_options'] . "
\n";
$cf->set("network_dhcp_options", $_POST['dhcp_options']);
#$error_msg .= "ERROR: Could not set the dhcp options
\n";
}
if ($_POST['ip']) {
$error_msg .= "Found an IP: you submitted " . $_POST['ip'] . "
\n";
$cf->set("network_ip",$_POST['ip']);
#$error_msg .= "ERROR: Could not set the IP
\n";
}
if ($_POST['broadcast']) {
$error_msg .= "Found an broadcast IP: you submitted " . $_POST['broadcast'] . "
\n";
$cf->set("network_broadcast", $_POST['broadcast']);
#$error_msg .= "ERROR: Could not set the broadcast IP
\n";
}
if ($_POST['netmask']) {
$error_msg .= "Found an netmask IP: you submitted " . $_POST['netmask'] . "
\n";
$cf->set("network_netmask", $_POST['netmask']);
#$error_msg .= "ERROR: Could not set the netmask IP
\n";
}
if ($_POST['gateway']) {
$error_msg .= "Found an gateway IP: you submitted " . $_POST['gateway'] . "
\n";
$cf->set("network_gateway",$_POST['gateway']);
#$error_msg .= "ERROR: Could not set the gateway IP
\n";
}
if ($_POST['http_proxy']) {
$error_msg .= "Found an HTTP Proxy IP: you submitted " . $_POST['http_proxy'] . "
\n";
$cf->set("http_proxy", $_POST['http_proxy']);
#$error_msg .= "ERROR: Could not set the HTTP Proxy IP
\n";
}
if ($_POST['ftp_proxy']) {
$error_msg .= "Found an FTP Proxy IP: you submitted " . $_POST['ftp_proxy'] . "
\n";
$cf->set("ftp_proxy", $_POST['ftp_proxy']);
#$error_msg .= "ERROR: Could not set the FTP Proxy IP
\n";
}
if ($_POST['rsync_proxy']) {
$error_msg .= "Found an RSYNC Proxy IP: you submitted " . $_POST['rsync_proxy'] . "
\n";
$cf->set("rsync_proxy",$_POST['rsync_proxy']);
#$error_msg .= "ERROR: Could not set the RSYNC Proxy IP
\n";
}
$dns_servers = array();
if ($_POST['dnsserver']) {
$error_msg .= "Found an DNS server: you submitted " . $_POST['dnsserver'] . "
\n";
array_push($dns_servers, $_POST['dnsserver']);
}
if ($_POST['dnsserver2']) {
$error_msg .= "Found an alternate DNS server: you submitted " . $_POST['dnsserver2'] . "
\n";
array_push($dns_servers, $_POST['dnsserver2']);
}
if ($dns_servers) {
$cf->set("dns_servers", $dns_servers);
$error_msg .= "ERROR: Could not set the DNS Server
\n";
}
if ($_POST['EnableSSH']) {
$error_msg .= "Found an Enable SSH Flag: you set it to " . $_POST['EnableSSH'] . "
\n";
$cf->set("enable_ssh", $_POST['EnableSSH']);
#$error_msg .= "ERROR: Could not set the SSH flag
\n";
}
if ($_POST['Verbose']) {
$error_msg .= "Found an Verbose Mode Flag: you set it to " . $_POST['Verbose'] . "
\n";
$cf->set("verbose", $_POST['Verbose']);
#$error_msg .= "ERROR: Could not set the Verbose mode flag
\n";
}
if ($_POST['RootPass1'] and $_POST['RootPass2']) {
$error_msg .= "Found a root password1: you submitted " . $_POST['RootPass1'] . "
\n";
$error_msg .= "Found a root password2: you submitted " . $_POST['RootPass2'] . "
\n";
if ($_POST['RootPass1'] == $_POST['RootPass2']) {
$error_msg .= "Trying to set the root password.
";
$cf->set("root_passwd",hash_password($_POST['RootPass1']));
$error_msg .= "ERROR: Could not set the root password
\n";
} else {
$error_msg .= "ERROR: Passwords DO NOT MATCH!
\n";
}
}
if ($_POST['Modules']) {
$error_msg .= "Found an Additional Module: you submitted " . $_POST['Modules'] . "
\n";
$cf->set("kernel_modules", $_POST['Modules']);
#$error_msg .= "ERROR: Could not set the Kernel Modules
\n";
}
if ($_POST['SaveCC']) {
$error_msg .= "Trying to save the profile.
\n";
#SAVE VALUES
file_put_contents('testcc.xml', $cf->serialize()); #PHP 5 only
#$error_msg .= "ERROR: Could not save the profile!
\n";
}
if ($error_msg == "") {
$error_msg = "Values saved successfully";
}
}
$smarty->assign('error_msg',$error_msg);
#########################################
$smarty->assign('advanced', True);
$subarches['i386'] = 'x86';
$subarches['i486'] = 'x86';
$subarches['i586'] = 'x86';
$subarches['i686'] = 'x86';
$subarches['x86_64'] = 'amd64';
$subarches['parisc'] = 'hppa';
$smarty->assign('subarches', $subarches);
#Choose the architecture for the Install.
#import platform
#arch = platform.machine()
#if arch in subarches:
# arch = subarches[arch]
#Arch selection string here.
$arches["x86"] = "x86 (Pentium and Athlon Series)";
$arches["amd64"] = "AMD Athlon 64 and Opteron";
$arches["ppc"] = "PPC (New World) Macs";
$arches["sparc"] = "Sparc (don't know how to be more specific yet";
$arches["alpha"] = "Alpha";
$arches["hppa"] = "HPPA";
$smarty->assign('arches', $arches);
$modules = list_modules();
$smarty->assign('modules', $modules);
$smarty->display('clientconfig.tpl');
?>