diff --git a/.gitignore b/.gitignore index 4b691209f..82fddbca0 100644 --- a/.gitignore +++ b/.gitignore @@ -264,6 +264,7 @@ web/public_php/db_version_tool web/public_php/db_version_web web/public_php/role_service web/public_php/role_support +web/public_php/role_admin web/public_php/role_domain web/public_php/db_version_ring web/public_php/config_user.php diff --git a/web/public_php/admin/common.php b/web/public_php/admin/common.php index ceb9aa87b..8badd0636 100644 --- a/web/public_php/admin/common.php +++ b/web/public_php/admin/common.php @@ -25,7 +25,7 @@ require_once(NELTOOL_SYSTEMBASE. 'nel/admin_modules_itf.php'); // lets set up the database - $db = new sql_db(NELTOOL_DBHOST, NELTOOL_DBUSER, NELTOOL_DBPASS, NELTOOL_DBNAME); + $db = new sql_db(NELTOOL_DBHOST, NELTOOL_DBPORT, NELTOOL_DBUSER, NELTOOL_DBPASS, NELTOOL_DBNAME); if (!is_object($db)) die("error on db init"); // lets set up the smarty template engine diff --git a/web/public_php/admin/config.php b/web/public_php/admin/config.php index 5fdfd1c58..9c0e9b44a 100644 --- a/web/public_php/admin/config.php +++ b/web/public_php/admin/config.php @@ -6,6 +6,7 @@ // database information for nel tool define('NELTOOL_DBHOST', $cfg['db']['tool']['host']); + define('NELTOOL_DBPORT', $cfg['db']['tool']['port']); define('NELTOOL_DBUSER', $cfg['db']['tool']['user']); define('NELTOOL_DBPASS', $cfg['db']['tool']['pass']); define('NELTOOL_DBNAME', $cfg['db']['tool']['name']); diff --git a/web/public_php/admin/functions_mysqli.php b/web/public_php/admin/functions_mysqli.php index 82ef9efa7..d5ba09a9a 100644 --- a/web/public_php/admin/functions_mysqli.php +++ b/web/public_php/admin/functions_mysqli.php @@ -41,13 +41,14 @@ class sql_db // // Constructor // - function __construct($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true) + function __construct($sqlserver, $sqlport, $sqluser, $sqlpassword, $database, $persistency = true) { $this->persistency = $persistency; $this->user = $sqluser; $this->password = $sqlpassword; $this->server = $sqlserver; + $this->port = $sqlport; $this->dbname = $database; if($this->persistency) @@ -55,7 +56,7 @@ class sql_db $this->server = 'p:'.$this->server; } - $this->db_connect_id = mysqli_connect($this->server, $this->user, $this->password); + $this->db_connect_id = mysqli_connect($this->server, $this->user, $this->password, NULL, $this->port); if($this->db_connect_id) { if($database != "") diff --git a/web/public_php/admin/nel/nel_message.php b/web/public_php/admin/nel/nel_message.php index ab0e55f0e..7e069b8c2 100644 --- a/web/public_php/admin/nel/nel_message.php +++ b/web/public_php/admin/nel/nel_message.php @@ -40,7 +40,7 @@ { if ($this->isReading()) { - $val = ord($this->Buffer{$this->Pos++}); + $val = ord($this->Buffer[$this->Pos++]); debug(sprintf ("read uint8 '%d'
\n", $val)); } else @@ -59,10 +59,10 @@ { if ($this->isReading()) { - $val = ord($this->Buffer{$this->Pos++}); - $val += ord($this->Buffer{$this->Pos++})*256; - $val += ord($this->Buffer{$this->Pos++})*(double)256*256; - $val += ord($this->Buffer{$this->Pos++})*(double)256*256*256; + $val = ord($this->Buffer[$this->Pos++]); + $val += ord($this->Buffer[$this->Pos++])*256; + $val += ord($this->Buffer[$this->Pos++])*(double)256*256; + $val += ord($this->Buffer[$this->Pos++])*(double)256*256*256; debug(sprintf ("read uint32 '%d'
\n", $val)); // var_dump($val); } diff --git a/web/public_php/login/client_install.php b/web/public_php/login/client_install.php index db93f8caa..4836bb958 100644 --- a/web/public_php/login/client_install.php +++ b/web/public_php/login/client_install.php @@ -74,7 +74,7 @@ die2(); } $domainName = getPost("domain"); - $nelLink = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$DBHost user:$DBUserName"); + $nelLink = mysqli_connect($DBHost, $DBUserName, $DBPassword, NULL, $DBPort) or die2 (__FILE__. " " .__LINE__." Can't connect to database host:$DBHost user:$DBUserName"); mysqli_select_db ($nelLink, $DBName) or die2 (__FILE__. " " .__LINE__." Can't access to the table dbname:$DBName"); $domainName = mysqli_real_escape_string($nelLink, $domainName); diff --git a/web/public_php/login/config.php b/web/public_php/login/config.php index 6ae107119..bfa47a4f1 100644 --- a/web/public_php/login/config.php +++ b/web/public_php/login/config.php @@ -16,6 +16,7 @@ if ($cfg['db']['shard']['host'] != $cfg['db']['ring']['host']) // where we can find the mysql database $DBHost = $cfg['db']['shard']['host']; +$DBPort = $cfg['db']['shard']['port']; $DBUserName = $cfg['db']['shard']['user']; $DBPassword = $cfg['db']['shard']['pass']; $DBName = $cfg['db']['shard']['name']; diff --git a/web/public_php/login/r2_login.php b/web/public_php/login/r2_login.php index b0a8a2d79..7c945b2a0 100644 --- a/web/public_php/login/r2_login.php +++ b/web/public_php/login/r2_login.php @@ -45,9 +45,9 @@ if ($resultCode == 0 && $cookie != "") { // gather the domain information (server version, patch urls and backup patch url - global $DBHost, $DBUserName, $DBPassword, $DBName, $AutoInsertInRing; + global $DBHost, $DBPort, $DBUserName, $DBPassword, $DBName, $AutoInsertInRing; - $link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); + $link = mysqli_connect($DBHost, $DBUserName, $DBPassword, NULL, $DBPort) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); mysqli_select_db ($link, $DBName) or die (errorMsgBlock(3005, 'main', $DBName, $DBHost, $DBUserName)); $query = "SELECT * FROM domain WHERE domain_id=$domainId"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); @@ -191,7 +191,7 @@ if ($AutoCreateRingInfo) { // check if the ring user exist, and create it if not - $ringDb = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die(errorMsgBlock(3004, 'Ring', $DBHost, $RingDBUserName)); + $ringDb = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword, NULL, $DBPort) or die(errorMsgBlock(3004, 'Ring', $DBHost, $RingDBUserName)); mysqli_select_db ($ringDb, $domainInfo['ring_db_name']) or die(errorMsgBlock(3005, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName)); $query = "SELECT user_id FROM ring_users where user_id = '".$id."'"; $result = mysqli_query ($ringDb, $query) or die(errorMsgBlock(3006, $query, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName, mysqli_error($ringDb))); @@ -268,11 +268,11 @@ // return true if the check is ok function checkUserValidity ($login, $password, $clientApplication, $cp, &$id, &$reason, &$priv, &$extended, &$domainId, $lang) { - global $DBHost, $DBUserName, $DBPassword, $DBName, $AcceptUnknownUser; + global $DBHost, $DBPort, $DBUserName, $DBPassword, $DBName, $AcceptUnknownUser; setMsgLanguage($lang); - $link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); + $link = mysqli_connect($DBHost, $DBUserName, $DBPassword, NULL, $DBPort) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); mysqli_select_db ($link, $DBName) or die (errorMsgBlock(3005, 'main', $DBName, $DBHost, $DBUserName)); // we map the client application to the domain name @@ -445,12 +445,12 @@ function askSalt($login, $lang) { global $PHP_SELF; - global $DBHost, $DBUserName, $DBPassword, $DBName; + global $DBHost, $DBPort, $DBUserName, $DBPassword, $DBName; global $AcceptUnknownUser; setMsgLanguage($lang); - $link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); + $link = mysqli_connect($DBHost, $DBUserName, $DBPassword, NULL, $DBPort) or die (errorMsgBlock(3004, 'main', $DBHost, $DBUserName)); mysqli_select_db ($link, $DBName) or die (errorMsgBlock(3005, 'main', $DBName, $DBHost, $DBUserName)); $login = mysqli_real_escape_string($link, $login); diff --git a/web/public_php/ring/edit_session.php b/web/public_php/ring/edit_session.php index 4fef39520..ec365d5e9 100644 --- a/web/public_php/ring/edit_session.php +++ b/web/public_php/ring/edit_session.php @@ -16,9 +16,9 @@ $domainInfo = getDomainInfo($domainId); - global $DBHost, $RingDBUserName, $RingDBPassword; + global $DBHost, $DBPort, $RingDBUserName, $RingDBPassword; - $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die ("Can't connect to database host:$DBHost user:$RingDBUserName"); + $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword, NULL, $DBPort) or die ("Can't connect to database host:$DBHost user:$RingDBUserName"); mysqli_select_db($link, $domainInfo['ring_db_name']) or die ("Can't access to the db dbname:" . $domainInfo['ring_db_name']); // Find out if the character has an open editing session diff --git a/web/public_php/ring/invite_pioneer.php b/web/public_php/ring/invite_pioneer.php index bb1f5ca7e..3d59b0189 100644 --- a/web/public_php/ring/invite_pioneer.php +++ b/web/public_php/ring/invite_pioneer.php @@ -42,9 +42,9 @@ if (isset($_POST["execute"])) { // lookup in the database to convert character name into - global $DBHost, $RingDBUserName, $RingDBPassword; + global $DBHost, $DBPort, $RingDBUserName, $RingDBPassword; - $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die ("Can't connect to database host:$DBHost user:$RingDBUserName"); + $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword, NULL, $DBPort) or die ("Can't connect to database host:$DBHost user:$RingDBUserName"); mysqli_select_db($link, $domainInfo['ring_db_name']) or die ("Can't access to the table dbname:" . $domainInfo['ring_db_name']); // extract the character that have the specified name diff --git a/web/public_php/ring/join_shard.php b/web/public_php/ring/join_shard.php index abc6aee7b..4a92fc5d4 100644 --- a/web/public_php/ring/join_shard.php +++ b/web/public_php/ring/join_shard.php @@ -184,8 +184,8 @@ function displayAllShards(&$onlineShardsBySessionId) } // List all shards of the domain, including offline ones - global $DBName, $DBHost, $DBUserName, $DBPassword; - $link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die("Can't connect to nel database"); + global $DBName, $DBHost, $DBPort, $DBUserName, $DBPassword; + $link = mysqli_connect($DBHost, $DBUserName, $DBPassword, NULL, $DBPort) or die("Can't connect to nel database"); mysqli_select_db($link, $DBName) or die ("Can't access to the db dbname:$DBName"); $domainId = (int) $domainId; diff --git a/web/public_php/ring/session_tools.php b/web/public_php/ring/session_tools.php index e5f12763f..0c0f1df04 100644 --- a/web/public_php/ring/session_tools.php +++ b/web/public_php/ring/session_tools.php @@ -108,12 +108,12 @@ function inviteOwnerInSession($charId, $domainId, $sessionId) $RSMPort = $addr[1]; global $rsmProxy, $rsmSkel, $userId, $charId, $callbackClient, /*$SessionId,*/ $SessionToolsResult; - global $DBHost, $RingDBUserName, $RingDBPassword; + global $DBHost, $DBPort, $RingDBUserName, $RingDBPassword; $SessionId = $sessionId; $DomainId = $domainId; - $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die("Can't connect to ring database"); + $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword, NULL, $DBPort) or die("Can't connect to ring database"); mysqli_select_db($link, $domainInfo['ring_db_name']) or die ("Can't access to the db dbname:" . $domainInfo['ring_db_name']); $sessionId = (int) $sessionId; diff --git a/web/public_php/setup/database.php b/web/public_php/setup/database.php index 6137cb00f..b0a97eec9 100644 --- a/web/public_php/setup/database.php +++ b/web/public_php/setup/database.php @@ -42,7 +42,8 @@ function connect_database($continue, $name) { $cfg['db'][$name]['host'], $cfg['db'][$name]['user'], $cfg['db'][$name]['pass'], - $cfg['db'][$name]['name']); + $cfg['db'][$name]['name'], + $cfg['db'][$name]['port']); if (mysqli_connect_errno()) { printalert("danger", "Failed to connect to the " . $name . " SQL server: " . mysqli_connect_error()); $con = null; diff --git a/web/public_php/setup/install.php b/web/public_php/setup/install.php index 31a7a88e1..270491dda 100644 --- a/web/public_php/setup/install.php +++ b/web/public_php/setup/install.php @@ -30,6 +30,8 @@ require_once('setup/version.php'); $roleService = isset($_POST["roleService"]) && $_POST["roleService"] == "on"; $roleSupport = isset($_POST["roleSupport"]) && $_POST["roleSupport"] == "on"; $roleDomain = isset($_POST["roleDomain"]) && $_POST["roleDomain"] == "on"; + + $continue = true; if (!$roleService && !$roleSupport && !$roleDomain) { printalert("danger", "No server roles selected"); @@ -61,13 +63,13 @@ require_once('setup/version.php'); } if ($continue) { if ($roleService) { - $continue = validate_writable($continue, "login/logs/"); - $continue = validate_writable($continue, "admin/graphs_output/"); - $continue = validate_writable($continue, "admin/templates/default_c/"); + $continue = validate_writable($continue, "login/logs/") && $continue; + $continue = validate_writable($continue, "admin/graphs_output/") && $continue; + $continue = validate_writable($continue, "admin/templates/default_c/") && $continue; } if ($roleSupport) { - $continue = validate_writable($continue, "ams/cache/"); - $continue = validate_writable($continue, "ams/templates_c/"); + $continue = validate_writable($continue, "ams/cache/") && $continue; + $continue = validate_writable($continue, "ams/templates_c/") && $continue; } $continue = validate_writable($continue, "./"); if ($continue) { @@ -77,7 +79,7 @@ require_once('setup/version.php'); $con = null; if ($continue) { // NOTE: Also test if this is reachable when not Service role - $con = mysqli_connect($_POST["nelSqlHostname"], $_POST["nelSqlUsername"], $_POST["nelSqlPassword"]); + $con = mysqli_connect($_POST["nelSqlHostname"], $_POST["nelSqlUsername"], $_POST["nelSqlPassword"], NULL, $_POST["nelSqlPort"]); if (mysqli_connect_errno()) { printalert("danger", "Failed to connect to Service SQL: " . mysqli_connect_error()); $continue = false; @@ -89,44 +91,28 @@ require_once('setup/version.php'); if ($roleService) { // Create NeL database - $continue = create_use_database($continue, $con, $_POST["nelDatabase"]); + $continue = create_use_database($continue, $con, $_POST["nelDatabase"]) && $continue; // Create NeL Tools database - $continue = create_use_database($continue, $con, $_POST["toolDatabase"]); + $continue = create_use_database($continue, $con, $_POST["toolDatabase"]) && $continue; } if ($roleDomain) { // Create Ring database - $continue = create_use_database($continue, $con, $_POST["domainDatabase"]); - } - - if ($con) { - mysqli_close($con); - printalert("info", "Disconnected from the Service SQL server"); + $continue = create_use_database($continue, $con, $_POST["domainDatabase"]) && $continue; } if ($roleSupport) { - if ($continue) { - $con = mysqli_connect($_POST["amsSqlHostname"], $_POST["amsSqlUsername"], $_POST["amsSqlPassword"]); - if (mysqli_connect_errno()) { - printalert("danger", "Failed to connect to Support SQL: " . mysqli_connect_error()); - $continue = false; - $con = null; - } else { - printalert("success", "Connected to the Support SQL server"); - } - } - // Create AMS database - $continue = create_use_database($continue, $con, $_POST["amsDatabase"]); + $continue = create_use_database($continue, $con, $_POST["amsDatabase"]) && $continue; // Create AMS Library database - $continue = create_use_database($continue, $con, $_POST["amsLibDatabase"]); + $continue = create_use_database($continue, $con, $_POST["amsLibDatabase"]) && $continue; + } - if ($con) { - mysqli_close($con); - printalert("info", "Disconnected from the Support SQL server"); - } + if ($con) { + mysqli_close($con); + printalert("info", "Disconnected from the Service SQL server"); } // Write config.php @@ -140,6 +126,7 @@ require_once('setup/version.php'); $config = str_replace("%privatePhpDirectory%", addslashes(realpath($cwd . "/" . $_POST["privatePhpDirectory"])), $config); $config = str_replace("%publicPhpDirectory%", addslashes(realpath($cwd)), $config); $config = str_replace("%nelSqlHostname%", addslashes($_POST["nelSqlHostname"]), $config); + $config = str_replace("%nelSqlPort%", addslashes($_POST["nelSqlPort"]), $config); $config = str_replace("%nelSqlUsername%", addslashes($_POST["nelSqlUsername"]), $config); $config = str_replace("%nelSqlPassword%", addslashes($_POST["nelSqlPassword"]), $config); $config = str_replace("%nelDatabase%", addslashes($_POST["nelDatabase"]), $config); @@ -193,15 +180,15 @@ require_once('setup/version.php'); require_once('database.php'); if ($roleSupport) { - $continue = upgrade_support_databases($continue); + $continue = upgrade_support_databases($continue) && $continue; } if ($roleService) { - $continue = upgrade_service_databases($continue); + $continue = upgrade_service_databases($continue) && $continue; } if ($roleDomain) { - $continue = upgrade_domain_databases($continue); + $continue = upgrade_domain_databases($continue) && $continue; } if ($roleService) { diff --git a/web/public_php/setup/upgrade.php b/web/public_php/setup/upgrade.php index b29c04e2c..128f3ee56 100644 --- a/web/public_php/setup/upgrade.php +++ b/web/public_php/setup/upgrade.php @@ -51,13 +51,11 @@ if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { $config = str_replace("%privatePhpDirectory%", addslashes($PRIVATE_PHP_PATH), $config); $config = str_replace("%publicPhpDirectory%", addslashes($PUBLIC_PHP_PATH), $config); $config = str_replace("%nelSqlHostname%", addslashes($cfg['db']['shard']['host']), $config); + $config = str_replace("%nelSqlPort%", addslashes($cfg['db']['shard']['port']), $config); $config = str_replace("%nelSqlUsername%", addslashes($cfg['db']['shard']['user']), $config); $config = str_replace("%nelSqlPassword%", addslashes($cfg['db']['shard']['pass']), $config); $config = str_replace("%nelDatabase%", addslashes($cfg['db']['shard']['name']), $config); $config = str_replace("%toolDatabase%", addslashes($cfg['db']['tool']['name']), $config); - $config = str_replace("%amsSqlHostname%", addslashes($cfg['db']['lib']['host']), $config); - $config = str_replace("%amsSqlUsername%", addslashes($cfg['db']['lib']['user']), $config); - $config = str_replace("%amsSqlPassword%", addslashes($cfg['db']['lib']['pass']), $config); $config = str_replace("%amsDatabase%", addslashes($cfg['db']['web']['name']), $config); $config = str_replace("%amsLibDatabase%", addslashes($cfg['db']['lib']['name']), $config); $config = str_replace("%nelSetupPassword%", addslashes($NEL_SETUP_PASSWORD), $config); @@ -66,10 +64,15 @@ if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { $config = str_replace("%cryptKey%", addslashes($cfg['crypt']['key']), $config); $config = str_replace("%cryptKeyIMAP%", addslashes($SUPPORT_GROUP_IMAP_CRYPTKEY), $config); if ($NEL_SETUP_VERSION_CONFIGURED < 2) { - $config = str_replace("%domainDatabase%", "mini01", $config); + $config = str_replace("%domainDatabase%", addslashes($NEL_DOMAIN_NAME + "_ring"), $config); } else { $config = str_replace("%domainDatabase%", addslashes($cfg['db']['ring']['name']), $config); } + if ($NEL_SETUP_VERSION_CONFIGURED < 9) { + $config = str_replace("%domainUsersDir%", addslashes("/home/nevrax/" + $NEL_DOMAIN_NAME + "/www"), $config); + } else { + $config = str_replace("%domainUsersDir%", addslashes($USERS_DIR), $config); + } if (file_put_contents("config.php", $config)) { printalert("success", "Generated config.php"); } else { diff --git a/web/public_php/setup/version.php b/web/public_php/setup/version.php index baffede3f..86734aff3 100644 --- a/web/public_php/setup/version.php +++ b/web/public_php/setup/version.php @@ -1,6 +1,6 @@