function up_4012_4100($_prefix, $_link) { $commands[] = array(1146, "TRUNCATE TABLE `" . DBManager::RealEscape($_prefix) . "operators`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `groups` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `last_chat_allocation`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `groups_hidden` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL AFTER `groups_status`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `fullname` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `login_id`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `description` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `fullname`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `fullname`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `permissions` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `email`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `webspace` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `permissions`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `languages` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `auto_accept_chats` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `login_ip_range` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `password_change` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `password`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `password_change_request` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `system_id` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `id`;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `websites_users` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `websites_config` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "operators` ADD `sign_off` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "visitor_goals` ADD `query` INT( 11 ) unsigned NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `dynamic` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `external` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `internal` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `created` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `standard` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `opening_hours` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `functions` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `chat_inputs_hidden` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `ticket_inputs_hidden` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `chat_inputs_required` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `ticket_inputs_required` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `max_chats` INT( 11 ) NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `hide_chat_group_selection` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `hide_ticket_group_selection` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "groups` ADD `visitor_filters` TEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $commands[] = array(1050, "CREATE TABLE IF NOT EXISTS `" . DBManager::RealEscape($_prefix) . "images` (`id` INT UNSIGNED NOT NULL DEFAULT '0',`online` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',`button_type` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',`image_type` varchar(32) COLLATE utf8_bin NOT NULL DEFAULT '',`data` LONGTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`,`button_type`,`image_type`,`online`)) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_bin;"); $commands[] = array(1050, "CREATE TABLE IF NOT EXISTS `" . DBManager::RealEscape($_prefix) . "stats_aggs_goals_queries` (`year` smallint(5) unsigned NOT NULL DEFAULT '0',`month` tinyint(3) unsigned NOT NULL DEFAULT '0',`day` tinyint(3) unsigned NOT NULL DEFAULT '0',`goal` int(10) unsigned NOT NULL DEFAULT '0',`query` int(10) unsigned NOT NULL DEFAULT '0',`amount` int(10) unsigned NOT NULL DEFAULT '0',PRIMARY KEY (`year`,`month`,`day`,`goal`,`query`),KEY `target` (`goal`),KEY `query` (`query`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"); $commands[] = array(1060, "ALTER TABLE `" . DBManager::RealEscape($_prefix) . "visitor_browsers` ADD `pre_message` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;"); $res = processCommandList($commands, $_link); // import buttons importButtons(LIVEZILLA_PATH . "banner/", $_prefix, $_link); return $res; }
function createTables($id = 0) { global $RESPONSE, $INTERNAL, $DB_CONNECTOR; if ($INTERNAL[CALLER_SYSTEM_ID]->Level == USER_LEVEL_ADMIN) { $connection = new DBManager($_POST[POST_INTERN_DATABASE_USER], $_POST[POST_INTERN_DATABASE_PASS], $_POST[POST_INTERN_DATABASE_HOST], "", $_POST[POST_INTERN_DATABASE_PREFIX]); if (!empty($_POST["p_db_ext"])) { DBManager::$Extension = strtolower($_POST["p_db_ext"]); } if (DBManager::$Extension == "mysql" && !function_exists("mysql_connect")) { $RESPONSE->SetStandardResponse($id, base64_encode("PHP MySQL extension is missing (php_mysql.dll)")); return false; } else { if (DBManager::$Extension == "mysqli" && !function_exists("mysqli_connect")) { $RESPONSE->SetStandardResponse($id, base64_encode("PHP MySQLi extension is missing (php_mysqli.dll)")); return false; } } $connection->InitConnection(); if (!DBManager::$Provider) { $error = DBManager::GetError(); $RESPONSE->SetStandardResponse($id, base64_encode("Can't connect to database. Invalid host or login! (" . DBManager::GetErrorCode() . (!empty($error) ? ": " . $error : "") . ")")); return false; } else { $connection->Query(false, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"); $db_selected = $connection->SelectDatabase(DBManager::RealEscape($_POST[POST_INTERN_DATABASE_NAME])); if (!$db_selected) { if (!empty($_POST[POST_INTERN_DATABASE_CREATE])) { $resultcr = $connection->Query(false, "CREATE DATABASE `" . DBManager::RealEscape($_POST[POST_INTERN_DATABASE_NAME]) . "`"); if (!$resultcr) { $RESPONSE->SetStandardResponse($id, base64_encode(DBManager::GetErrorCode() . ": " . DBManager::GetError())); } else { unset($_POST[POST_INTERN_DATABASE_CREATE]); return createTables(); } } else { $RESPONSE->SetStandardResponse(2, base64_encode(DBManager::GetErrorCode() . ": " . DBManager::GetError())); } } else { $resultvc = $connection->Query(false, "SELECT `version`,`chat_id`,`ticket_id` FROM `" . DBManager::RealEscape($_POST[POST_INTERN_DATABASE_PREFIX]) . DATABASE_INFO . "` ORDER BY `version` DESC LIMIT 1"); if ($rowvc = @DBManager::FetchArray($resultvc)) { if (VERSION != $rowvc["version"] && !empty($rowvc["version"])) { $upres = initUpdateDatabase($rowvc["version"], $connection, $_POST[POST_INTERN_DATABASE_PREFIX]); if ($upres === true) { $RESPONSE->SetStandardResponse(1, base64_encode("")); return true; } } } $resultv = $connection->Query(false, $sql = "SELECT VERSION() as `mysql_version`"); if (!$resultv) { $RESPONSE->SetStandardResponse($id, base64_encode(DBManager::GetErrorCode() . ": " . DBManager::GetError() . "\r\n\r\nSQL: " . $sql)); return false; } else { $mrow = @DBManager::FetchArray($resultv); $mversion = explode(".", $mrow["mysql_version"]); if (count($mversion) > 0 && $mversion[0] < MYSQL_NEEDED_MAJOR) { $RESPONSE->SetStandardResponse($id, base64_encode("LiveZilla requires MySQL version " . MYSQL_NEEDED_MAJOR . " or greater. The MySQL version installed on your server is " . $mrow["mysql_version"] . ".")); return false; } } $commands = explode("###", str_replace("<!--version-->", VERSION, str_replace("<!--prefix-->", $_POST[POST_INTERN_DATABASE_PREFIX], file_get_contents(LIVEZILLA_PATH . "_definitions/dump.lsql")))); foreach ($commands as $sql) { if (empty($sql)) { continue; } $result = $connection->Query(false, trim($sql)); if (!$result && DBManager::GetErrorCode() != 1050 && DBManager::GetErrorCode() != 1005 && DBManager::GetErrorCode() != 1062) { $RESPONSE->SetStandardResponse($id, base64_encode(DBManager::GetErrorCode() . ": " . DBManager::GetError() . "\r\n\r\nSQL: " . $sql)); return false; } } importButtons(PATH_IMAGES . "buttons/", $_POST[POST_INTERN_DATABASE_PREFIX], $connection); $DB_CONNECTOR = $connection; $RESPONSE->SetStandardResponse(1, base64_encode("")); return true; } } } return false; }