function eventHandler() { if (isset($_REQUEST['back'][$this->getStep()])) { $this->doBack(); } if ($this->getStep() == 1) { if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } $this->DISABLE_NEXT_BUTTON = true; } elseif ($this->getStep() == 2) { $this->setConfig('DB_TYPE', get_request('type', $this->getConfig('DB_TYPE'))); $this->setConfig('DB_SERVER', get_request('server', $this->getConfig('DB_SERVER', 'localhost'))); $this->setConfig('DB_PORT', get_request('port', $this->getConfig('DB_PORT', '0'))); $this->setConfig('DB_DATABASE', get_request('database', $this->getConfig('DB_DATABASE', 'zabbix'))); $this->setConfig('DB_USER', get_request('user', $this->getConfig('DB_USER', 'root'))); $this->setConfig('DB_PASSWORD', get_request('password', $this->getConfig('DB_PASSWORD', ''))); $this->setConfig('DB_SCHEMA', get_request('schema', $this->getConfig('DB_SCHEMA', ''))); if (isset($_REQUEST['retry'])) { if (!$this->checkConnection()) { $this->DISABLE_NEXT_BUTTON = true; unset($_REQUEST['next']); } } elseif (!isset($_REQUEST['next'][$this->getStep()])) { $this->DISABLE_NEXT_BUTTON = true; unset($_REQUEST['next']); } if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } } elseif ($this->getStep() == 3) { $this->setConfig('ZBX_SERVER', get_request('zbx_server', $this->getConfig('ZBX_SERVER', 'localhost'))); $this->setConfig('ZBX_SERVER_PORT', get_request('zbx_server_port', $this->getConfig('ZBX_SERVER_PORT', '10051'))); $this->setConfig('ZBX_SERVER_NAME', get_request('zbx_server_name', $this->getConfig('ZBX_SERVER_NAME', ''))); if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } } elseif ($this->getStep() == 4 && isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } elseif ($this->getStep() == 5) { if (isset($_REQUEST['save_config'])) { // make zabbix.conf.php downloadable header('Content-Type: application/x-httpd-php'); header('Content-Disposition: attachment; filename="' . basename(CConfigFile::CONFIG_FILE_PATH) . '"'); $config = new CConfigFile(Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH); $config->config = array('DB' => array('TYPE' => $this->getConfig('DB_TYPE'), 'SERVER' => $this->getConfig('DB_SERVER'), 'PORT' => $this->getConfig('DB_PORT'), 'DATABASE' => $this->getConfig('DB_DATABASE'), 'USER' => $this->getConfig('DB_USER'), 'PASSWORD' => $this->getConfig('DB_PASSWORD'), 'SCHEMA' => $this->getConfig('DB_SCHEMA')), 'ZBX_SERVER' => $this->getConfig('ZBX_SERVER'), 'ZBX_SERVER_PORT' => $this->getConfig('ZBX_SERVER_PORT'), 'ZBX_SERVER_NAME' => $this->getConfig('ZBX_SERVER_NAME')); die($config->getString()); } } if (isset($_REQUEST['next'][$this->getStep()])) { $this->doNext(); } }
function eventHandler() { if (hasRequest('back') && array_key_exists($this->getStep(), getRequest('back'))) { $this->doBack(); } if ($this->getStep() == 1) { if (hasRequest('next') && array_key_exists(1, getRequest('next'))) { $finalResult = CFrontendSetup::CHECK_OK; foreach ($this->frontendSetup->checkRequirements() as $req) { if ($req['result'] > $finalResult) { $finalResult = $req['result']; } } if ($finalResult == CFrontendSetup::CHECK_FATAL) { $this->STEP_FAILED = true; unset($_REQUEST['next']); } else { $this->doNext(); } } } elseif ($this->getStep() == 2) { $this->setConfig('DB_TYPE', getRequest('type', $this->getConfig('DB_TYPE'))); $this->setConfig('DB_SERVER', getRequest('server', $this->getConfig('DB_SERVER', 'localhost'))); $this->setConfig('DB_PORT', getRequest('port', $this->getConfig('DB_PORT', '0'))); $this->setConfig('DB_DATABASE', getRequest('database', $this->getConfig('DB_DATABASE', 'zabbix'))); $this->setConfig('DB_USER', getRequest('user', $this->getConfig('DB_USER', 'root'))); $this->setConfig('DB_PASSWORD', getRequest('password', $this->getConfig('DB_PASSWORD', ''))); $this->setConfig('DB_SCHEMA', getRequest('schema', $this->getConfig('DB_SCHEMA', ''))); if (hasRequest('next') && array_key_exists(2, getRequest('next'))) { if ($this->checkConnection()) { $this->doNext(); } else { $this->STEP_FAILED = true; unset($_REQUEST['next']); } } } elseif ($this->getStep() == 3) { $this->setConfig('ZBX_SERVER', getRequest('zbx_server', $this->getConfig('ZBX_SERVER', 'localhost'))); $this->setConfig('ZBX_SERVER_PORT', getRequest('zbx_server_port', $this->getConfig('ZBX_SERVER_PORT', '10051'))); $this->setConfig('ZBX_SERVER_NAME', getRequest('zbx_server_name', $this->getConfig('ZBX_SERVER_NAME', ''))); if (hasRequest('next') && array_key_exists(3, getRequest('next'))) { $this->doNext(); } } elseif ($this->getStep() == 4) { if (hasRequest('next') && array_key_exists(4, getRequest('next'))) { $this->doNext(); } } elseif ($this->getStep() == 5) { if (hasRequest('save_config')) { // make zabbix.conf.php downloadable header('Content-Type: application/x-httpd-php'); header('Content-Disposition: attachment; filename="' . basename(CConfigFile::CONFIG_FILE_PATH) . '"'); $config = new CConfigFile(Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH); $config->config = ['DB' => ['TYPE' => $this->getConfig('DB_TYPE'), 'SERVER' => $this->getConfig('DB_SERVER'), 'PORT' => $this->getConfig('DB_PORT'), 'DATABASE' => $this->getConfig('DB_DATABASE'), 'USER' => $this->getConfig('DB_USER'), 'PASSWORD' => $this->getConfig('DB_PASSWORD'), 'SCHEMA' => $this->getConfig('DB_SCHEMA')], 'ZBX_SERVER' => $this->getConfig('ZBX_SERVER'), 'ZBX_SERVER_PORT' => $this->getConfig('ZBX_SERVER_PORT'), 'ZBX_SERVER_NAME' => $this->getConfig('ZBX_SERVER_NAME')]; die($config->getString()); } } if (hasRequest('next') && array_key_exists($this->getStep(), getRequest('next'))) { $this->doNext(); } }