Welcome to the MangosWeb installer!
Please follow these few steps to set up your new site.
One or more fileds were left empty. Please go back and correct it.'); } // Check if provided info is correct @mysql_connect($_POST['db_host'].":".$_POST['db_port'], $_POST['db_username'], $_POST['db_password']) or die ('Error!
Couldn\'t connect to the MySql server, most likely the given information is wrong. Please go back and correct it.
MySql error log:
'.mysql_error()); @mysql_select_db($_POST['world_db_name']) or die('Error!
Couldn\'t select World db, most likely the given name is wrong. Please go back and correct it.
MySql error log:
'.mysql_error()); @mysql_select_db($_POST['character_db_name']) or die('Error!
Couldn\'t select Characters db, most likely the given name is wrong. Please go back and correct it.
MySql error log:
'.mysql_error()); @mysql_select_db($_POST['db_name']) or die('Error!
Couldn\'t select Realmd db, most likely the given name is wrong. Please go back and correct it.
MySql error log:
'.mysql_error()); // Check if "account" table exsists, so we make (almost) sure mangos is actually installed (which is necesarry for this whole thing to work) @mysql_query("SELECT * FROM `account` LIMIT 1") or die('Error!
Account table not found, seems like mangos isn\'t installed.
MySql error log:
'.mysql_error()); // Everthing should be fine, so first insert info into protected config file $conffile = "../config/config-protected.php"; $build = ''; $build .= " '".$_POST['db_type']."',\n"; $build .= "'db_host' => '".$_POST['db_host']."',\n"; $build .= "'db_port' => '".$_POST['db_port']."',\n"; $build .= "'db_username' => '".$_POST['db_username']."',\n"; $build .= "'db_password' => '".$_POST['db_password']."',\n"; $build .= "'db_name' => '".$_POST['db_name']."',\n"; $build .= "'db_encoding' => 'utf8',\n"; $build .= ");\n"; $build .= "?>"; if (is_writeable($conffile)){ $openconf = fopen($conffile, 'wb'); fwrite($openconf, $build); fclose($openconf); } else { die('Error!
Couldn\'t open config-protected.php for editing, it must be writable by webserver!
Go back, and try again.');} // Preparing for sql injection... (prashing, etc...) $checker = @mysql_query("SELECT * FROM `account_extend` LIMIT 1"); if (isset($_GET['task'])) {$task=$_GET['task'];} else {$task="none";} if (!$checker || $task == "force1") { // Dealing with the full install sql file $sqlopen = @fopen("../sql/full_install.sql", "r"); if ($sqlopen) { while (!feof($sqlopen)) { $queries[] = fgets($sqlopen); } fclose($sqlopen); } else { echo "Error!
Couldn\'t open file full_install.sql. Check if it\'s presented in wwwroot/sql/ and if it\'s readable by webserver!"; $errmsg = error_get_last(); echo "
PHP error log:
".$errmsg['message']; exit();} foreach ($queries as $key => $aquery) { if (trim($aquery) == "" || strpos ($aquery, "--") === 0 || strpos ($aquery, "#") === 0) {unset($queries[$key]);} } unset($key, $aquery); foreach ($queries as $key => $aquery) { $aquery = rtrim($aquery); $compare = rtrim($aquery, ";"); if ($compare != $aquery) {$queries[$key] = $compare . "|br3ak|";} } unset($key, $aquery); $queries = implode($queries); $queries = explode("|br3ak|", $queries); // Sql injection foreach ($queries as $query) { mysql_query($query); } // Extra sql query with db settings $dbinfo = $_POST['db_username'].";".$_POST['db_password'].";".$_POST['db_port'].";".$_POST['db_host'].";".$_POST['world_db_name'].";".$_POST['character_db_name']; mysql_query("UPDATE `realmlist` SET `dbinfo` = '".$dbinfo."' WHERE `id` = 1 LIMIT 1") or die(mysql_error()); } elseif ($task == "force2") { ?> SQL-injection skipped. Now please give an account name which should be the first superadmin. With this you'll be able to administrate the site from the admin panel. The account can be both exsisting or new. If the the account doesn't exsit it'll be created, with the given password. (If the given account already exsist the give password won't take any effect.)
The installer has detected that you already have an installed version of MangosWeb in your database."; echo " You can either proceed, but note that in this case old tables will be dropped and all of your current MangosWeb database data will be irrecoverably lost."; echo "
OR you can skip sql-injection part.
"; echo ""; echo "
"; // This can be added here too, if someone using the installer only to reconfigure MW $dbinfo = $_POST['db_username'].";".$_POST['db_password'].";".$_POST['db_port'].";".$_POST['db_host'].";".$_POST['world_db_name'].";".$_POST['character_db_name']; mysql_query("UPDATE `realmlist` SET `dbinfo` = '".$dbinfo."' WHERE `id` = 1 LIMIT 1") or die(mysql_error()); exit(); } // Now some text if we actually managed to get here :) ?> Database config file and table structure successfully installed! Now please give an account name which should be the first superadmin. With this you'll be able to administrate the site from the admin panel. The account can be both exsisting or new. If the the account doesn't exsit it'll be created, with the given password. (If the given account already exsist the give password won't take any effect.)
No account name was given. Please go back and correct it.'); } //Password hash generator function sha_password($user,$pass){ $user = strtoupper($user); $pass = strtoupper($pass); return SHA1($user.':'.$pass); } mysql_connect($_POST['db_host'].":".$_POST['db_port'], $_POST['db_username'], $_POST['db_password']); mysql_select_db($_POST['db_name']); //Giving root admin rights to the given account $accountid = mysql_query("SELECT `id` FROM `account` WHERE `username` LIKE '".$_POST['account']."'"); $checkacc = mysql_num_rows($accountid); if ($checkacc == 1) { // Account exsist $accountid = mysql_fetch_row($accountid); mysql_query("UPDATE `account_extend` SET `g_id` = '4' WHERE `account_id` = ".$accountid[0]." LIMIT 1 ;"); echo "Congratulations, your MangosWeb is now installed!
Installation finished successfully, now you can login with your administrator account on the site index, ".$_POST['account'].", and do the further configurations!"; } else { // No such account, creating one, in this case pwd is needed, so checking whether it's provided... if (!$_POST['passw'] || !$_POST['passw2']) {die('Error!
One or more fileds were left empty. Please go back and correct it.');} if ($_POST['passw'] != $_POST['passw2']) {die('Error!
Passwords didn\'t match. Please go back and correct it.');} $password = sha_password($_POST['account'], $_POST['passw']); mysql_query("INSERT INTO `account` (`username`, `sha_pass_hash`, `gmlevel`) VALUES ('".$_POST['account']."', '$password', '3' );"); $accountid = mysql_query("SELECT `id` FROM `account` WHERE `username` LIKE '".$_POST['account']."'"); $accountid = mysql_fetch_row($accountid); mysql_query("INSERT INTO `account_extend` (`account_id`, `g_id`) VALUES ('$accountid[0]', '4');"); echo "Congratulations, your MangosWeb is now installed!
Installation finished successfully, now you can login with your administrator account, ".$_POST['account'].", on the site index and do the further configurations!"; echo "
To disable this function and avoid misuse add a file named DISABLE_INSTALLER.php to your install folder to disable the installer!"; } } ?>