Example #1
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 #2
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 #3
0
 function stage5()
 {
     $this->setConfig('ZBX_CONFIG_FILE_CORRECT', true);
     $config_file_name = Z::getInstance()->getRootDir() . CConfigFile::CONFIG_FILE_PATH;
     $config = new CConfigFile($config_file_name);
     $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')];
     $error = false;
     if (!$config->save()) {
         $error = true;
         $messages[] = ['type' => 'error', 'message' => $config->error];
     }
     if ($error) {
         $this->SHOW_RETRY_BUTTON = true;
         $this->setConfig('ZBX_CONFIG_FILE_CORRECT', false);
         $message_box = makeMessageBox(false, $messages, _('Cannot create the configuration file.'), false, true);
         $message = [new CTag('p', true, _('Alternatively, you can install it manually:')), new CTag('ol', true, [new CTag('li', true, new CLink(_('Download the configuration file'), 'setup.php?save_config=1')), new CTag('li', true, _s('Save it as "%1$s"', $config_file_name))])];
     } else {
         $this->DISABLE_CANCEL_BUTTON = true;
         $this->DISABLE_BACK_BUTTON = true;
         $message_box = null;
         $message = [(new CTag('h1', true, _('Congratulations! You have successfully installed Zabbix frontend.')))->addClass(ZBX_STYLE_GREEN), new CTag('p', true, _s('Configuration file "%1$s" created.', $config_file_name))];
     }
     return [new CTag('h1', true, _('Install')), (new CDiv([$message_box, $message]))->addClass(ZBX_STYLE_SETUP_RIGHT_BODY)];
 }