<?
function constForm() {
$myFile = "../config.php";
$fh = fopen($myFile, 'w') or die("can't open file. set chmod to 777");
$text = file_get_contents("config.tpl");
$text = preg_replace("'%SSERVER%'",$_POST['sserver'],$text);
$text = preg_replace("'%SUSER%'",$_POST['suser'],$text);
$text = preg_replace("'%SPASS%'",$_POST['spass'],$text);
$text = preg_replace("'%SDB%'",$_POST['sdb'],$text);
$text = preg_replace("'%PREFIX%'",$_POST['prefix'],$text);
fwrite($fh, $text);
fclose($fh);
}
function mysql_exec_batch ($p_query, $p_transaction_safe = true) {
if ($p_transaction_safe) {
$p_query = 'START TRANSACTION;' . $p_query . '; COMMIT;';
};
$query_split = preg_split ("/[;]+/", $p_query);
foreach ($query_split as $command_line) {
$command_line = trim($command_line);
if ($command_line != '') {
$query_result = mysql_query($command_line);
if ($query_result == 0) {
break;
};
};
};
return $query_result;
}
function createDB() {
mysql_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysql_select_db(SQL_DB);
$str = file_get_contents("mafiadb.sql");
$str = preg_replace("'%PREFIX%'",$_POST['prefix'],$str);
$result = mysql_exec_batch($str);
}
?>