require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::DatabaseTest(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SEND_TEST_MAIL) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::SendTestMail(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_CREATE_TABLES) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; if (ServerManager::CreateTables()) { ServerManager::UpdateUserManagement($_POST[POST_INTERN_DATABASE_PREFIX], true); } } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_MANAGEMENT) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::UpdateUserManagement(DB_PREFIX); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_CONFIG) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::UpdateConfiguration(); ServerManager::UpdateLanguageFiles(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_AVAILABILITY) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::UpdateAvailability($_POST["p_available"]); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_DOWNLOAD_TRANSLATION) { require_once LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; ServerManager::GetTranslationData(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_GET_BANNER_LIST) {
static function ValidateDatabase($_host, $_user, $_pass, $_dbname, $_prefix, $_extension = "", $_intense = false, $_engine) { $connection = new DBManager($_user, $_pass, $_host, "", $_prefix); $_engine = empty($_engine) ? "MyISAM" : $_engine; if (!empty($_extension)) { DBManager::$Extension = $_extension; } if (DBManager::$Extension == "mysql" && !function_exists("mysql_connect")) { return "PHP MySQL extension is missing (php_mysql.dll)"; } else { if (DBManager::$Extension == "mysqli" && !function_exists("mysqli_connect")) { return "PHP/MySQLi extension is missing (php_mysqli.dll)"; } } $connection->InitConnection(); if (!DBManager::$Provider) { $error = DBManager::GetError(); return "Can't connect to database. Invalid host or login! (" . DBManager::GetErrorCode() . (!empty($error) ? ": " . $error : "") . ")"; } else { $db_selected = $connection->SelectDatabase(DBManager::RealEscape($_dbname)); if (!$db_selected) { return DBManager::GetErrorCode() . ": " . DBManager::GetError(); } else { $resultv = $connection->Query(false, "SELECT VERSION() as `mysql_version`"); if (!$resultv) { return DBManager::GetErrorCode() . ": " . DBManager::GetError(); } else { $mrow = @DBManager::FetchArray($resultv); $mversion = explode(".", $mrow["mysql_version"]); if (count($mversion) > 0 && $mversion[0] < MYSQL_NEEDED_MAJOR) { return "LiveZilla requires MySQL version " . MYSQL_NEEDED_MAJOR . " or greater. The MySQL version installed on your server is " . $mrow["mysql_version"] . "."; } } $result = $connection->Query(false, "SELECT `version`,`chat_id`,`ticket_id` FROM `" . DBManager::RealEscape($_prefix) . DATABASE_INFO . "` ORDER BY `version` DESC LIMIT 1"); $row = @DBManager::FetchArray($result); $version = $row["version"]; if (!$result || empty($version)) { return "Cannot read the LiveZilla Database version. Please try to recreate the table structure. If you experience this message during installation process, please try to setup a prefix (for example lz_)."; } if ($version != VERSION && defined("SERVERSETUP") && SERVERSETUP) { $upres = ServerManager::InitUpdateDatabase($version, $connection, $_prefix, $_engine); if ($upres !== true) { return "Cannot update database structure from [" . $version . "] to [" . VERSION . "]. Please make sure that the user " . $_user . " has the MySQL permission to ALTER tables in " . $_dbname . ".\r\n\r\nError: " . $upres; } } else { if ($version != VERSION && empty($_GET["iv"])) { return "Invalid database version: " . $version . " (required: " . VERSION . "). Please validate the database in the server administration panel first.\r\n\r\n"; } } DBManager::$Connector = $connection; $result = $connection->Query(false, "SELECT * FROM `" . DBManager::RealEscape($_prefix) . DATABASE_OPERATORS . "`"); if (DBManager::GetRowCount($result) == 0) { ServerManager::UpdateUserManagement($_prefix, false, true); } if ($_intense && empty($_GET["iv"])) { foreach (get_defined_constants() as $constant => $val) { if (substr($constant, 0, 9) == "DATABASE_") { if (!$connection->Query(false, "SELECT * FROM `" . DBManager::RealEscape($_prefix) . $val . "` LIMIT 1;")) { $code = DBManager::GetErrorCode(); $error = DBManager::GetError(); if ($code == 144 || $code == 145 || $code == 1194) { $connection->Query(true, "REPAIR TABLE `" . DBManager::RealEscape($_prefix) . $val . "`;"); $error .= " - (trying to repair ...)"; } return $code . ": " . $error; } } } } return null; } } }