$ZBX_CONFIG['allowed_db']['MYSQL'] = 'MySQL'; } // POSTGRESQL if (zbx_is_callable(array('pg_pconnect', 'pg_fetch_array', 'pg_fetch_row', 'pg_exec', 'pg_getlastoid'))) { $ZBX_CONFIG['allowed_db']['POSTGRESQL'] = 'PostgreSQL'; } // ORACLE if (zbx_is_callable(array('ocilogon', 'ocierror', 'ociparse', 'ociexecute', 'ocifetchinto'))) { $ZBX_CONFIG['allowed_db']['ORACLE'] = 'Oracle'; } // IBM_DB2 if (zbx_is_callable(array('db2_connect', 'db2_set_option', 'db2_prepare', 'db2_execute', 'db2_fetch_assoc'))) { $ZBX_CONFIG['allowed_db']['IBM_DB2'] = 'IBM DB2'; } // SQLITE3. The false is here to avoid autoloading of the class. if (class_exists('SQLite3', false) && zbx_is_callable(array('ftok', 'sem_acquire', 'sem_release', 'sem_get'))) { $ZBX_CONFIG['allowed_db']['SQLITE3'] = 'SQLite3'; } if (count($ZBX_CONFIG['allowed_db']) == 0) { $ZBX_CONFIG['allowed_db']['no'] = 'No'; } /* * Setup wizard */ global $ZBX_SETUP_WIZARD; $ZBX_SETUP_WIZARD = new CSetupWizard($ZBX_CONFIG); zbx_set_post_cookie('ZBX_CONFIG', serialize($ZBX_CONFIG)); require_once dirname(__FILE__) . '/include/page_header.php'; include 'include/views/js/setup.js.php'; /* * Check configuration
/** * Get list of supported databases. * * @return array */ public function getSupportedDatabases() { $allowedDb = array(); if (zbx_is_callable(array('mysqli_connect', 'mysqli_connect_error', 'mysqli_error', 'mysqli_query', 'mysqli_fetch_assoc', 'mysqli_free_result', 'mysqli_real_escape_string', 'mysqli_close'))) { $allowedDb[ZBX_DB_MYSQL] = 'MySQL'; } if (zbx_is_callable(array('pg_pconnect', 'pg_fetch_array', 'pg_fetch_row', 'pg_exec', 'pg_getlastoid'))) { $allowedDb[ZBX_DB_POSTGRESQL] = 'PostgreSQL'; } if (zbx_is_callable(array('oci_connect', 'oci_error', 'oci_parse', 'oci_execute', 'oci_fetch_assoc', 'oci_commit', 'oci_close', 'oci_rollback', 'oci_field_type', 'oci_new_descriptor', 'oci_bind_by_name', 'oci_free_statement'))) { $allowedDb[ZBX_DB_ORACLE] = 'Oracle'; } if (zbx_is_callable(array('db2_connect', 'db2_set_option', 'db2_commit', 'db2_rollback', 'db2_autocommit', 'db2_prepare', 'db2_execute', 'db2_stmt_errormsg', 'db2_fetch_assoc', 'db2_free_result', 'db2_escape_string', 'db2_close'))) { $allowedDb[ZBX_DB_DB2] = 'IBM DB2'; } // Semaphore related functions are checked elsewhere. The 'false' is to prevent autoloading of the SQLite3 class. if (class_exists('SQLite3', false) && zbx_is_callable(array('ftok', 'sem_acquire', 'sem_release', 'sem_get'))) { $allowedDb[ZBX_DB_SQLITE3] = 'SQLite3'; } return $allowedDb; }
function CheckConnection() { global $DB; // $old_DB = $DB['DB']; if (!empty($DB)) { $old_DB = true; $old_DB_TYPE = $DB['TYPE']; $old_DB_SERVER = $DB['SERVER']; $old_DB_PORT = $DB['PORT']; $old_DB_DATABASE = $DB['DATABASE']; $old_DB_USER = $DB['USER']; $old_DB_PASSWORD = $DB['PASSWORD']; } $DB['TYPE'] = $this->getConfig('DB_TYPE'); if (is_null($DB['TYPE'])) { return false; } $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost'); $DB['PORT'] = $this->getConfig('DB_PORT', '0'); $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix'); $DB['USER'] = $this->getConfig('DB_USER', 'root'); $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', ''); $error = ''; if (!($result = DBconnect($error))) { error($error); } else { $result = DBexecute('CREATE table zabbix_installation_test ( test_row integer )'); $result &= DBexecute('DROP table zabbix_installation_test'); } DBclose(); if ($DB['TYPE'] == 'SQLITE3' && !zbx_is_callable(array('sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) { error('SQLite3 required IPC functions'); $result &= false; } /* restore connection */ global $DB; if (isset($old_DB)) { $DB['TYPE'] = $old_DB_TYPE; $DB['SERVER'] = $old_DB_SERVER; $DB['PORT'] = $old_DB_PORT; $DB['DATABASE'] = $old_DB_DATABASE; $DB['USER'] = $old_DB_USER; $DB['PASSWORD'] = $old_DB_PASSWORD; } DBconnect($error); return $result; }
function CheckConnection() { global $DB; // global $ZBX_MESSAGES; $DB['TYPE'] = $this->getConfig('DB_TYPE'); if (is_null($DB['TYPE'])) { return false; } $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost'); $DB['PORT'] = $this->getConfig('DB_PORT', '0'); $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix'); $DB['USER'] = $this->getConfig('DB_USER', 'root'); $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', ''); $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', ''); $error = ''; if (!($result = DBconnect($error))) { // if(!is_null($ZBX_MESSAGES)) array_pop($ZBX_MESSAGES); error($error); } else { $result = true; if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == 'IBM_DB2') { $db_schema = DBselect("SELECT schemaname FROM syscat.schemata WHERE schemaname='" . db2_escape_string($DB['SCHEMA']) . "'"); $result = DBfetch($db_schema); } if ($result) { $result = DBexecute('CREATE table zabbix_installation_test ( test_row integer )'); $result &= DBexecute('DROP table zabbix_installation_test'); } } DBclose(); if ($DB['TYPE'] == 'SQLITE3' && !zbx_is_callable(array('sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) { error('SQLite3 requires IPC functions'); $result = false; } $DB = null; return $result; }
} $ZBX_CONFIG['allowed_db'] = array(); /* MYSQL */ if (zbx_is_callable(array('mysql_pconnect', 'mysql_select_db', 'mysql_error', 'mysql_select_db', 'mysql_query', 'mysql_fetch_array', 'mysql_fetch_row', 'mysql_data_seek', 'mysql_insert_id'))) { $ZBX_CONFIG['allowed_db']['MYSQL'] = 'MySQL'; } /* POSTGRESQL */ if (zbx_is_callable(array('pg_pconnect', 'pg_fetch_array', 'pg_fetch_row', 'pg_exec', 'pg_getlastoid'))) { $ZBX_CONFIG['allowed_db']['POSTGRESQL'] = 'PostgreSQL'; } /* ORACLE */ if (zbx_is_callable(array('ocilogon', 'ocierror', 'ociparse', 'ociexecute', 'ocifetchinto'))) { $ZBX_CONFIG['allowed_db']['ORACLE'] = 'Oracle'; } /* SQLITE3 */ if (zbx_is_callable(array('sqlite3_open', 'sqlite3_close', 'sqlite3_query', 'sqlite3_error', 'sqlite3_fetch_array', 'sqlite3_query_close', 'sqlite3_exec'))) { $ZBX_CONFIG['allowed_db']['SQLITE3'] = 'SQLite3'; } if (count($ZBX_CONFIG['allowed_db']) == 0) { $ZBX_CONFIG['allowed_db']['no'] = 'No'; } global $ZBX_SETUP_WIZARD; $ZBX_SETUP_WIZARD = new CSetupWizard($ZBX_CONFIG); zbx_set_post_cookie('ZBX_CONFIG', serialize($ZBX_CONFIG)); include_once 'include/page_header.php'; global $ZBX_CONFIGURATION_FILE; if (file_exists($ZBX_CONFIGURATION_FILE)) { if (isset($_REQUEST['message'])) { show_error_message($_REQUEST['message']); } }
function CheckConnection() { global $DB; $DB['TYPE'] = $this->getConfig('DB_TYPE'); if (is_null($DB['TYPE'])) { return false; } $DB['SERVER'] = $this->getConfig('DB_SERVER', 'localhost'); $DB['PORT'] = $this->getConfig('DB_PORT', '0'); $DB['DATABASE'] = $this->getConfig('DB_DATABASE', 'zabbix'); $DB['USER'] = $this->getConfig('DB_USER', 'root'); $DB['PASSWORD'] = $this->getConfig('DB_PASSWORD', ''); $DB['SCHEMA'] = $this->getConfig('DB_SCHEMA', ''); $error = ''; if (!($result = DBconnect($error))) { error($error); } else { $result = true; if (!zbx_empty($DB['SCHEMA']) && $DB['TYPE'] == ZBX_DB_DB2) { $db_schema = DBselect('SELECT schemaname FROM syscat.schemata WHERE schemaname=\'' . db2_escape_string($DB['SCHEMA']) . '\''); $result = DBfetch($db_schema); } if ($result) { $result = DBexecute('CREATE TABLE zabbix_installation_test (test_row INTEGER)'); $result &= DBexecute('DROP TABLE zabbix_installation_test'); } } DBclose(); if ($DB['TYPE'] == ZBX_DB_SQLITE3 && !zbx_is_callable(array('ftok', 'sem_get', 'sem_acquire', 'sem_release', 'sem_remove'))) { error('Support of SQLite3 requires PHP IPC functions'); $result = false; } $DB = null; return $result; }