<?php
if(file_exists("include/constant.php")) {
include("include/database.php");
}
class Process {
function Process() {
if(isset($_POST['subconst'])) {
$this->constForm();
}
else if(isset($_POST['substruc'])) {
$this->createStruc();
}
else if(isset($_POST['subwdata'])) {
$this->createWdata();
}
else if(isset($_POST['subacc'])) {
$this->createAcc();
}
else{
header("Location: install.php");
}
}
/*
$dbuser="username";
$dbpass="password";
$dbname="mydata"; //the name of the database
$chandle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
echo "Connected to database server<br>";
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser);
echo "Database " . $database . " is selected";
mysql_close($chandle);
*/
function constForm() {
$myFile = "include/constant.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$text = file_get_contents("data/constant_format.tpl");
$text = preg_replace("'%SERVERNAME%'",$_POST['servername'],$text);
$text = preg_replace("'%SPEED%'",$_POST['speed'],$text);
$text = preg_replace("'%UTOUT%'",$_POST['timeout'],$text);
$text = preg_replace("'%MAX%'",$_POST['wmax'],$text);
$text = preg_replace("'%EMAILAUTH%'",$_POST['aemail'],$text);
$text = preg_replace("'%GP%'",$_POST['gpack'],$text);
$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);
$text = preg_replace("'%CONNECTT%'", $_POST['connectt'], $text);
fwrite($fh, $text);
if(file_exists("include/constant.php")) {
header("Location: install.php?s=2");
}
else {
header("Location: install.php?s=1&c=1");
}
fclose($fh);
}
function createStruc() {
global $database;
$str = file_get_contents("data/structure.sql");
$str = preg_replace("'%PREFIX%'",TB_PREFIX,$str);
if($database->connection->multi_query($str)) {
header("Location: install.php?s=3");
}
else {
header("Location: install.php?s=2&c=1");
}
}
function createWdata() {
header("Location: include/wdata.php");
}
function createAcc() {
global $database;
$time = time();
$q = "INSERT INTO ".TB_PREFIX."USERS VALUES (0, '".$_POST['user']."', '".md5($_POST['pass'])."', ".ADMIN.", '".$_POST['email']."', $time, 1, 0, 0, '', 0)";
if($database->query($q)) {
if(CONNECT_TYPE) {
$uid = $database->connection->insert_id;
}
else {
$uid = mysql_insert_id($database->connection);
}
$wq2 = "UPDATE ".TB_PREFIX."WDATA set occupied = 1 where id = 320801";
$database->query($wq2);
$vname = $_POST['user']."\'s village";
$q2 = "INSERT into ".TB_PREFIX."VDATA values (320801, $uid, '$vname', 1, 2, 0, 750, 750, 750, 800, 750, 800, $time)";
$database->query($q2);
$q3 = "INSERT into ".TB_PREFIX."FDATA (vref, f26,f26t) values(320801, 1,15)";
$database->query($q3);
header("Location: install.php?s=5");
}
}
};
$process = new Process;
?>