Example #1
0
 function stage6()
 {
     $this->setConfig('ZBX_CONFIG_FILE_CORRECT', true);
     $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'));
     $config->save();
     try {
         $error = false;
         $config->load();
         if ($config->config['DB']['TYPE'] != $this->getConfig('DB_TYPE')) {
             $error = true;
         } elseif ($config->config['DB']['SERVER'] != $this->getConfig('DB_SERVER')) {
             $error = true;
         } elseif ($config->config['DB']['PORT'] != $this->getConfig('DB_PORT')) {
             $error = true;
         } elseif ($config->config['DB']['DATABASE'] != $this->getConfig('DB_DATABASE')) {
             $error = true;
         } elseif ($config->config['DB']['USER'] != $this->getConfig('DB_USER')) {
             $error = true;
         } elseif ($config->config['DB']['PASSWORD'] != $this->getConfig('DB_PASSWORD')) {
             $error = true;
         } elseif ($this->getConfig('DB_TYPE') == ZBX_DB_DB2 && $config->config['DB']['SCHEMA'] != $this->getConfig('DB_SCHEMA')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER'] != $this->getConfig('ZBX_SERVER')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER_PORT'] != $this->getConfig('ZBX_SERVER_PORT')) {
             $error = true;
         } elseif ($config->config['ZBX_SERVER_NAME'] != $this->getConfig('ZBX_SERVER_NAME')) {
             $error = true;
         }
         $error_text = 'Unable to overwrite the existing configuration file. ';
     } catch (ConfigFileException $e) {
         $error = true;
         $error_text = 'Unable to create the configuration file. ';
     }
     clear_messages();
     if ($error) {
         $this->setConfig('ZBX_CONFIG_FILE_CORRECT', false);
     }
     $this->DISABLE_NEXT_BUTTON = !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false);
     $this->HIDE_CANCEL_BUTTON = !$this->DISABLE_NEXT_BUTTON;
     $table = array('Configuration file', BR(), '"' . Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH . '"', BR(), 'created: ', $this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? new CSpan(_('OK'), 'ok') : new CSpan(_('Fail'), 'fail'));
     return array($table, BR(), BR(), $this->DISABLE_NEXT_BUTTON ? array(new CSubmit('retry', _('Retry')), BR(), BR()) : null, !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? array($error_text, BR(), 'Please install it manually, or fix permissions on the conf directory.', BR(), BR(), 'Press the "Download configuration file" button, download the configuration file ', 'and save it as ', BR(), '"' . Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH . '"', BR(), BR(), new CSubmit('save_config', 'Download configuration file'), BR(), BR()) : array('Congratulations on successful installation of Zabbix frontend.', BR(), BR()), 'When done, press the ' . ($this->DISABLE_NEXT_BUTTON ? '"Retry"' : '"Finish"') . ' button');
 }
Example #2
0
 function stage6()
 {
     global $ZBX_CONFIGURATION_FILE;
     $this->setConfig('ZBX_CONFIG_FILE_CORRECT', true);
     $config = new CConfigFile($ZBX_CONFIGURATION_FILE);
     $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'));
     $config->save();
     if ($config->load()) {
         $error = '';
         if ($config->config['DB']['TYPE'] != $this->getConfig('DB_TYPE')) {
             $error = 'Config file DB type is not equal to wizard input.';
         } else {
             if ($config->config['DB']['SERVER'] != $this->getConfig('DB_SERVER')) {
                 $error = 'Config file DB server is not equal to wizard input.';
             } else {
                 if ($config->config['DB']['PORT'] != $this->getConfig('DB_PORT')) {
                     $error = 'Config file DB port is not equal to wizard input.';
                 } else {
                     if ($config->config['DB']['DATABASE'] != $this->getConfig('DB_DATABASE')) {
                         $error = 'Config file DB database is not equal to wizard input.';
                     } else {
                         if ($config->config['DB']['USER'] != $this->getConfig('DB_USER')) {
                             $error = 'Config file DB user is not equal to wizard input.';
                         } else {
                             if ($config->config['DB']['PASSWORD'] != $this->getConfig('DB_PASSWORD')) {
                                 $error = 'Config file DB password is not equal to wizard input.';
                             } else {
                                 if ($this->getConfig('DB_TYPE') == 'IBM_DB2' && $config->config['DB']['SCHEMA'] != $this->getConfig('DB_SCHEMA')) {
                                     $error = 'Config file DB schema is not equal to wizard input.';
                                 } else {
                                     if ($config->config['ZBX_SERVER'] != $this->getConfig('ZBX_SERVER')) {
                                         $error = 'Config file Zabbix server is not equal to wizard input.';
                                     } else {
                                         if ($config->config['ZBX_SERVER_PORT'] != $this->getConfig('ZBX_SERVER_PORT')) {
                                             $error = 'Config file Zabbix server port is not equal to wizard input.';
                                         } else {
                                             if ($config->config['ZBX_SERVER_NAME'] != $this->getConfig('ZBX_SERVER_NAME')) {
                                                 $error = 'Config file Zabbix server name is not equal to wizard input.';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $error = $config->error;
     }
     clear_messages();
     if (!empty($error)) {
         error($error);
         show_messages();
         $this->setConfig('ZBX_CONFIG_FILE_CORRECT', false);
     }
     $this->DISABLE_NEXT_BUTTON = !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false);
     $table = new CTable(null, 'requirements');
     $table->setAlign('center');
     $table->addRow(array('Configuration file: ', $this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? new CSpan(S_OK, 'ok') : new CSpan(S_FAIL, 'fail')));
     return array($table, BR(), $this->DISABLE_NEXT_BUTTON ? array(new CButton('retry', S_RETRY), BR(), BR()) : null, !$this->getConfig('ZBX_CONFIG_FILE_CORRECT', false) ? array('Please install configuration file manually, or fix permissions on conf directory.', BR(), BR(), 'Press "Save configuration file" button, download configuration file ', 'and save it as ', BR(), '"' . $ZBX_CONFIGURATION_FILE . '"', BR(), BR(), new CButton('save_config', "Save configuration file"), BR(), BR()) : null, 'When done, press the ' . ($this->DISABLE_NEXT_BUTTON ? '"Retry"' : '"Next"') . ' button');
 }
Example #3
0
 /**
  * Load zabbix config file.
  */
 protected function loadConfigFile()
 {
     $configFile = $this->getRootDir() . CConfigFile::CONFIG_FILE_PATH;
     $config = new CConfigFile($configFile);
     $this->config = $config->load();
 }
Example #4
0
/********** START INITIALIZATION *********/
set_error_handler('zbx_err_handler');
unset($show_setup);
if (defined('ZBX_DENY_GUI_ACCESS')) {
    if (isset($ZBX_GUI_ACCESS_IP_RANGE) && is_array($ZBX_GUI_ACCESS_IP_RANGE)) {
        $user_ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
        if (!str_in_array($user_ip, $ZBX_GUI_ACCESS_IP_RANGE)) {
            $DENY_GUI = TRUE;
        }
    } else {
        $DENY_GUI = TRUE;
    }
}
if (file_exists($ZBX_CONFIGURATION_FILE) && !isset($_COOKIE['ZBX_CONFIG']) && !isset($DENY_GUI)) {
    $config = new CConfigFile($ZBX_CONFIGURATION_FILE);
    if ($config->load()) {
        $config->makeGlobal();
    } else {
        $show_warning = true;
        define('ZBX_DISTRIBUTED', false);
        define('ZBX_PAGE_NO_AUTHORIZATION', true);
        error($config->error);
    }
    require_once 'include/db.inc.php';
    if (!isset($show_warning)) {
        $error = '';
        if (!DBconnect($error)) {
            $_REQUEST['message'] = $error;
            define('ZBX_DISTRIBUTED', false);
            define('ZBX_PAGE_NO_AUTHORIZATION', true);
            $show_warning = true;