- else {
- $conf = file_get_contents("../config/config.php.sample");
- $conf = str_replace('$config["base_url"] = \'/unrealircd-webpanel/\'', '$config["base_url"] = \''.BASE_URL.'\'', $conf);
- $conf = str_replace('$config["unrealircd"]["rpc_user"] = \'adminpanel\'', '$config["unrealircd"]["rpc_user"] = \''.$opts->rpc_user.'\'', $conf);
- $conf = str_replace('$config["unrealircd"]["rpc_password"] = \'securepassword\'', '$config["unrealircd"]["rpc_password"] = \''.$opts->rpc_password.'\'', $conf);
- $conf = str_replace('$config["unrealircd"]["host"] = \'127.0.0.1\'', '$config["unrealircd"]["host"] = \''.$opts->rpc_iphost.'\'', $conf);
- $conf = str_replace('$config["unrealircd"]["port"] = \'8600\'', '$config["unrealircd"]["port"] = \''.$opts->rpc_port.'\'', $conf);
- if (isset($opts->rpc_ssl))
- $conf = str_replace('$config["unrealircd"]["tls_verify_cert"] = false', '$config["unrealircd"]["tls_verify_cert"] = true', $conf);
-
- $conf = str_replace("//\"$auth_method\"", "\"$auth_method\"", $conf); // enable our auth method
-
- if ($auth_method == "sql_auth")
- {
- $conf = str_replace('//$config["mysql"]["host"] = "127.0.0.1"', '$config["mysql"]["host"] = "'.$opts->sql_host.'"', $conf);
- $conf = str_replace('//$config["mysql"]["database"] = "unrealircdwebpanel"', '$config["mysql"]["database"] = "'.$opts->sql_db.'"', $conf);
- $conf = str_replace('//$config["mysql"]["username"] = "unrealircdwebpanel"', '$config["mysql"]["username"] = "'.$opts->sql_user.'"', $conf);
- $conf = str_replace('//$config["mysql"]["password"] = "replace_this_with_your_sql_password"', '$config["mysql"]["password"] = "'.$opts->sql_password.'"', $conf);
- }
- $file = fopen("../config/config.php", 'x+'); // only create it if it doesn't already exist even though we checked earlier
- if ($file)
- {
- fwrite($file, $conf);
- }
- require_once("../config/config.php");
-
- if ($auth_method == "sql_auth")
- if (!sql_auth::create_tables())
- Message::Fail("Could not create SQL tables");
-
- $user = [
- "user_name" => $opts->account_user,
- "user_pass" => $opts->account_password,
- "fname" => $opts->account_fname,
- "lname" => $opts->account_lname,
- "user_bio" => $opts->account_bio,
- "email" => $opts->account_email
- ];
-
- create_new_user($user);
- $lkup = new PanelUser($opts->account_user);
- if (!$lkup->id)
- {
- Message::Fail("Could not create user");
- return;
- }
- $lkup->add_permission(PERMISSION_MANAGE_USERS);
- ?>
- <br>
- Great! Everything has been completely set up for you, and you can now log in.
- <a class="text-center btn btn-primary" href="<?php echo BASE_URL; ?>">Let's go!</a></div>
- <?php
+
+ /* First, write only the config file */
+ write_config_file();
+
+ if ($auth_method == "sql_auth")
+ if (!sql_auth::create_tables())
+ Message::Fail("Could not create SQL tables");
+
+ $user = [
+ "user_name" => $opts->account_user,
+ "user_pass" => $opts->account_password,
+ "fname" => $opts->account_fname,
+ "lname" => $opts->account_lname,
+ "user_bio" => $opts->account_bio,
+ "email" => $opts->account_email
+ ];
+
+ create_new_user($user);
+ $lkup = new PanelUser($opts->account_user);
+ if (!$lkup->id)
+ {
+ Message::Fail("Could not create user");