diff --git a/code/web/public_php/ams/index.php b/code/web/public_php/ams/index.php index 1ab707e79..de2e93235 100644 --- a/code/web/public_php/ams/index.php +++ b/code/web/public_php/ams/index.php @@ -18,7 +18,7 @@ ini_set( 'display_errors', 'on' ); class SystemExit extends Exception {} try { -if (!file_exists( '../config.php')) { +if (!file_exists('../role_support')) { header("Cache-Control: max-age=1"); header('Location: ../setup', true, 303); throw new SystemExit(); diff --git a/code/web/public_php/setup/auth.php b/code/web/public_php/setup/auth.php index 8289289f9..b31646042 100644 --- a/code/web/public_php/setup/auth.php +++ b/code/web/public_php/setup/auth.php @@ -9,24 +9,34 @@ try { $pageTitle = "Authenticate"; include('header.php'); +require_once('config.php'); + ?>
- + + +

Continue

- + + +
diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php new file mode 100644 index 000000000..564e74039 --- /dev/null +++ b/code/web/public_php/setup/database.php @@ -0,0 +1,117 @@ +" . $name . " SQL server: " . mysqli_connect_error()); + $con = null; + } else { + printalert("success", "Connected to the " . $name . " SQL server"); + } + } + + return $con; +} + +function disconnect_database($con, $name) { + if ($con) { + mysqli_close($con); + printalert("info", "Disconnected from the " . $name . " SQL server"); + } +} + +function upgrade_service_databases($continue_r) { + $continue = $continue_r; + + $con = null; + $con = connect_database($continue, "shard"); + $continue = ($con != null); + if ($continue && get_db_version("shard") < 1) { + $continue = update_database_structure($continue, $con, "nel_00001.sql"); + $continue = set_db_version($continue, "shard", 1); + } + disconnect_database($con, "shard"); + + $con = null; + $con = connect_database($continue, "tool"); + $continue = ($con != null); + if ($continue && get_db_version("tool") < 1) { + $continue = update_database_structure($continue, $con, "nel_tool_00001.sql"); + $continue = set_db_version($continue, "tool", 1); + } + disconnect_database($con, "tool"); + + return $continue; +} + +function upgrade_support_databases($continue_r) { + $continue = $continue_r; + + $con = null; + $con = connect_database($continue, "web"); + $continue = ($con != null); + if ($continue && get_db_version("web") < 1) { + $continue = update_database_structure($continue, $con, "nel_ams_00001.sql"); + $continue = set_db_version($continue, "web", 1); + } + disconnect_database($con, "web"); + + $con = null; + $con = connect_database($continue, "lib"); + $continue = ($con != null); + if ($continue && get_db_version("lib") < 1) { + $continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql"); + $continue = set_db_version($continue, "lib", 1); + } + if ($continue && get_db_version("lib") < 2) { + $continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql"); + $continue = set_db_version($continue, "lib", 2); + } + disconnect_database($con, "lib"); + + return $continue; +} + +function upgrade_domain_databases($continue_r) { + $continue = $continue_r; + + $con = null; + $con = connect_database($continue, "ring"); + $continue = ($con != null); + if ($continue && get_db_version("ring") < 1) { + $continue = update_database_structure($continue, $con, "ring_domain_00001.sql"); + $continue = set_db_version($continue, "ring", 1); + } + disconnect_database($con, "ring"); + + return $continue; +} + +?> diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index 8fdade460..496161724 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -75,11 +75,14 @@ include('header.php'); if ($roleService) { // Create NeL database $continue = create_use_database($continue, $con, $_POST["nelDatabase"]); - $continue = update_database_structure($continue, $con, "nel_00001.sql"); // Create NeL Tools database $continue = create_use_database($continue, $con, $_POST["toolDatabase"]); - $continue = update_database_structure($continue, $con, "nel_tool_00001.sql"); + } + + if ($roleDomain) { + // Create Ring database + $continue = create_use_database($continue, $con, $_POST["domainDatabase"]); } if ($con) { @@ -101,12 +104,9 @@ include('header.php'); // Create AMS database $continue = create_use_database($continue, $con, $_POST["amsDatabase"]); - $continue = update_database_structure($continue, $con, "nel_ams_00001.sql"); // Create AMS Library database $continue = create_use_database($continue, $con, $_POST["amsLibDatabase"]); - $continue = update_database_structure($continue, $con, "nel_ams_lib_00001.sql"); - $continue = update_database_structure($continue, $con, "nel_ams_lib_00002.sql"); if ($con) { mysqli_close($con); @@ -158,6 +158,24 @@ include('header.php'); } } + require_once('database.php'); + + if ($roleSupport) { + $continue = upgrade_support_databases($continue); + } + + if ($roleService) { + $continue = upgrade_service_databases($continue); + } + + if ($roleDomain) { + $continue = upgrade_domain_databases($continue); + } + + if ($roleService) { + // TODO: Create the default admin user + } + if ($roleSupport) { // Load AMS Library if ($continue) { @@ -191,7 +209,11 @@ include('header.php'); } } - if ($continue && $roleSupport) { + if ($roleDomain) { + // TODO: Register the domain with the nel database etc + } + + if ($continue && $roleService) { if (file_put_contents("role_service", "1")) { printalert("success", "Service role successfully installed"); } else { @@ -414,7 +436,7 @@ include('header.php');
-

Domain

+

Domain (Multiple domains require separate installations, as they may run different versions)