<?php
if ($_POST[submit]) {  
	$file = "inc/config.php";
	$fh = fopen($file, "w") or die("can't open file");
	$confData = "<?php" . " \r\n";
	$confData .= "// S40 CMS by AWEN art studio" . " \r\n";
	$confData .= "\$s40[installed] 			= 	true;" . " \r\n";
	$confData .= "\$s40[title] 				= 	\"".$_POST[title]."\";" . " \r\n";
	$confData .= "\$s40[version] 				= 	\"".$_POST[version]."\";" . " \r\n";
	$confData .= "\$s40[slogan] 			= 	\"".$_POST[slogan]."\";" . " \r\n";
	$confData .= "\$s40[keywords] 			= 	\"S40 CMS, content, management, system, cms\";" . " \r\n";
	$confData .= "\$s40[description] 		= 	\"S40 CMS Free flat file Content Management System\";" . " \r\n";
	$confData .= "\$s40[theme] 				= 	\"default\";" . " \r\n";
	$confData .= "\$s40[lang] 				= 	\"".$_POST[lang]."\";" . " \r\n";
	$confData .= "\$s40[langdir] 				= 	\"".$_POST[langdir]."\";" . " \r\n";
	$confData .= "\$s40[home] 				= 	\"".$_POST[home]."\";" . " \r\n";
	$confData .= "\$s40[name] 				= 	\"".$_POST[name]."\";" . " \r\n";
	$confData .= "\$s40[passkey] 			= 	\"".$_POST[passkey]."\";" . " \r\n";
	$confData .= "\$s40[user] 				= 	\"".$_POST[username]."\";" . " \r\n";
	$confData .= "\$s40[pass] 				= 	\"".base64_encode($_POST[password].$_POST[passkey])."\";" . " \r\n";
	$confData .= "\$s40[sidecol] 			= 	\"right\";" . " \r\n";
	$confData .= "\$s40[imagesize] 		= 	\"770\";" . " \r\n";
	$confData .= "\$s40[thumbsize] 			= 	\"120\";" . " \r\n";
	$confData .= "\$s40[headerbar] 			= 	true;" . " \r\n";
	$confData .= "?>";	
	fwrite($fh, $confData);
	fclose($fh);
	unlink("inc/install.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $l[installprocess]; ?></title>
<meta http-equiv="refresh" content="0" />
<?php } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $l[installprocess]; ?></title>
<style type="text/css">
<!--
body {
	background-color: #221A15;
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
	font-size: 18px;
	margin: 0px;
}
h1  {
	margin: 0px;
	padding: 0px;
	font-size: 1.5em;
}
#ipage {
	width: 640px;
	margin-top: 3%;
	margin-right: auto;
	margin-bottom: auto;
	margin-left: auto;
	color: #221A15;
	background-color: #00CACA;
	padding: 5px;
	border: 2px solid #090;
}
#iform {
	padding: 10px;
}
#iform fieldset {
	border: 1px solid #0FF;
	padding: 3px;
	text-align: center;
}
#iform fieldset legend  {
	font-size: 1em;
	color: #221A15;
}
#iform .field {
	font-size: 1.5em;
	text-align: center;
	width: 500px;
}
#iform .cancel {
	background-color: #FCC;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	font-size: 1.4em;
	color: #221A15;
	text-align: center;
	font-style: italic;
	font-weight: bold;
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
#iform .save {
	background-color: #6F6;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	font-size: 1.4em;
	color: #221A15;
	text-align: center;
	font-style: italic;
	font-weight: bold;
	font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

-->
</style>
<link href="libs/spry/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="libs/spry/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<script src="libs/spry/SpryValidationTextField.js" type="text/javascript"></script>
<script src="libs/spry/SpryValidationConfirm.js" type="text/javascript"></script>

</head>

<body>
<div id="ipage">
  <h1><?php echo $l[installprocess]; ?></h1>
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="iform">
    <fieldset>
      <legend><?php echo $l[nameofsite]; ?></legend>
      <span id="sprytextfield1">
      <input name="title" type="text" class="field" id="title" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span></span>
    </fieldset>
    <fieldset>
      <legend><?php echo $l[slogonofsite]; ?></legend>
      <span id="sprytextfield2">
      <input name="slogan" type="text" class="field" id="slogan" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span></span>
    </fieldset>
    <fieldset><legend><?php echo $l[urlofsite]; ?></legend>
      <span id="sprytextfield3">
      <input name="home" type="text" class="field" id="home" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span><span class="textfieldInvalidFormatMsg"><?php echo $l[invalidvalue]; ?></span></span>
    </fieldset>
    <fieldset><legend><?php echo $l[yourname]; ?></legend>
      <span id="sprytextfield4">
      <input name="name" type="text" class="field" id="name" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span></span>
    </fieldset>
    <fieldset><legend><?php echo $l[username]; ?></legend>
      <span id="sprytextfield5">
      <input name="username" type="text" class="field" id="username" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span><span class="textfieldMinCharsMsg"><?php echo $l[minsix];?></span><span class="textfieldMaxCharsMsg"><?php echo $l[max24];?></span></span>
    </fieldset>
    <fieldset><legend><?php echo $l[password]; ?></legend>
      <span id="sprytextfield6">
      <input name="password" type="password" class="field" id="password" />
      <span class="textfieldRequiredMsg"><?php echo $l[requiredfield]; ?></span><span class="textfieldMinCharsMsg"><?php echo $l[minsix];?></span><span class="textfieldMaxCharsMsg"><?php echo $l[max24];?></span></span>
    </fieldset>
    <fieldset><legend><?php echo $l[passwordconfirm]; ?></legend>
      <span id="spryconfirm1">
      <input name="passwordconfirm" type="password" class="field" id="passwordconfirm" />
      <span class="confirmRequiredMsg"><?php echo $l[requiredfield]; ?></span><span class="confirmInvalidMsg"><?php echo $l[passwordsdontmatch];?></span></span>
    </fieldset>
	<fieldset>
    <legend><?php echo $l[save];?></legend>
	  <input name="passkey" type="hidden" id="passkey" value="<?php echo mt_rand(1000000000,9999999999); ?>" />
     <input name="version" type="hidden" id="version" value="<?php echo $s40[version]; ?>" />
	  <input name="lang" type="hidden" id="lang" value="<?php echo $s40[lang]; ?>" />
      <input name="langdir" type="hidden" id="langdir" value="<?php echo $s40[langdir]; ?>" />
	  <input name="submit" type="hidden" id="submit" value="true" />
	  <input name="Reset" type="reset" class="cancel" id="button" value="<?php echo $l[cancel];?>" />
    <input name="" type="submit" class="save" value="<?php echo $l[save];?>" /></fieldset>
  </form>
</div>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["change"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "url", {hint:"http://www.example.com/", validateOn:["change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {hint:"John Daw", validateOn:["change"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {validateOn:["change"], minChars:6, maxChars:24});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["change"], minChars:6, maxChars:24});
var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "password", {validateOn:["change"]});
//-->
</script>
</body>
</html>
