All pastes #372680 Raw Edit

Anonymous

public text v1 · immutable
#372680 ·published 2007-02-26 06:56 UTC
rendered paste body
<?php
$required = array(
				'site_name' => 'site',
				'admin' => 'admin',
				'email' => 'email',
				'url' => 'url',
				'dir' => 'dir'
			);
$config_array = array();
$errors = array();
foreach ($required as $config_name=>$post_name) {
	if (!isset($_POST["$post_name"]) || trim($_POST["$post_name"]) == '') {
		$errors[] "Missing $post_name";
		continue;
	}
	$config_array["$config_name"] = addslashes($_POST["$post_name"]);
}
$coded = 'Coded by Erm';

if (!empty($errors)) {
	echo "<div class=\"results\">";
	echo "You must fill in required fields!<BR>";
	echo "Return to the <A HREF=\"values.php\">Setup Page</A>.<br />";
	echo implode($errors,'<br />');
	echo "</div>";
	die("<div class=\"center\">$coded</div>");
}

$fh = fopen ('conf.php', 'w'); 
fwrite ($fh, '<?php');
fwrite($fh, "// REQUIRED INFO\n");
foreach ($config_array as $config_name=>$config_value) {
	fwrite($fh,"// $config_name\n");
	fwrite($fh,"$config_name = \"$config_value\";\n");
}
fclose ($fh);
?>