function testDataBase($_host, $_user, $_pass, $_dbname, $_prefix, $_extension = "", $_intense = false) { global $DB_CONNECTOR; $connection = new DBManager($_user, $_pass, $_host, "", $_prefix); 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(); $connection->Query(false, "SET NAMES 'utf8'"); 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 = initUpdateDatabase($version, $connection, $_prefix); 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"; } } $DB_CONNECTOR = $connection; $result = $connection->Query(false, "SELECT * FROM `" . DBManager::RealEscape($_prefix) . DATABASE_OPERATORS . "`"); if (DBManager::GetRowCount($result) == 0) { setManagement($_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; } } }
} else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_DATABASE_TEST) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; dataBaseTest(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SEND_TEST_MAIL) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; sendTestMail(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_CREATE_TABLES) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; createTables(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_MANAGEMENT) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setManagement(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_CONFIG) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setConfig(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_AVAILABILITY) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setAvailability($_POST[POST_INTERN_SERVER_AVAILABILITY]); } } } } } } }
require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; dataBaseTest(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SEND_TEST_MAIL) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; sendTestMail(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_CREATE_TABLES) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; if (createTables()) { setManagement($_POST[POST_INTERN_DATABASE_PREFIX], true); } } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_MANAGEMENT) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setManagement(DB_PREFIX); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_CONFIG) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setConfig(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_SET_AVAILABILITY) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; setAvailability($_POST["p_available"]); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_DOWNLOAD_TRANSLATION) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php"; getTranslationData(); } else { if ($_POST[POST_INTERN_SERVER_ACTION] == INTERN_ACTION_GET_BANNER_LIST) { require LIVEZILLA_PATH . "_lib/functions.internal.man.inc.php";