2017-05-22 11:24:21 +02:00
< ? php
///////////////////////////////////////////////////////////////////////////////
//
// NagiosQL
//
///////////////////////////////////////////////////////////////////////////////
//
2017-10-20 15:00:08 +02:00
// (c) 2005-2017 by Martin Willisegger
2017-05-22 11:24:21 +02:00
//
// Project : NagiosQL
// Component : Installer script - step 2
// Website : http://www.nagiosql.org
2017-10-20 15:00:08 +02:00
// Date : $LastChangedDate: 2017-06-22 09:29:35 +0200 (Thu, 22 Jun 2017) $
2017-05-22 11:24:21 +02:00
// Author : $LastChangedBy: martin $
2017-10-20 15:00:08 +02:00
// Version : 3.3.0
// Revision : $LastChangedRevision: 2 $
2017-05-22 11:24:21 +02:00
//
///////////////////////////////////////////////////////////////////////////////
//
// Prevent this file from direct access
// ====================================
if ( preg_match ( '#' . basename ( __FILE__ ) . '#' , htmlspecialchars ( $_SERVER [ 'PHP_SELF' ], ENT_QUOTES , 'utf-8' ))) {
exit ;
}
//
// Define common variables
// =======================
$preIncludeContent = " templates/step2.tpl.htm " ;
$intError = 0 ;
//
// Build content
// =============
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'PASSWD_MESSAGE' ] = $myInstClass -> translate ( 'The NagiosQL first passwords are not equal!' );
$arrTemplate [ 'FIELDS_MESSAGE' ] = $myInstClass -> translate ( 'Please fill in all fields marked with an *' );
$arrTemplate [ 'STEP1_BOX' ] = $myInstClass -> translate ( 'Requirements' );
$arrTemplate [ 'STEP2_BOX' ] = $myInstClass -> translate ( $_SESSION [ 'install' ][ 'mode' ]);
$arrTemplate [ 'STEP3_BOX' ] = $myInstClass -> translate ( 'Finish' );
$arrTemplate [ 'STEP2_TITLE' ] = " NagiosQL " . $myInstClass -> translate ( $_SESSION [ 'install' ][ 'mode' ]) . " : " . $myInstClass -> translate ( " Setup " );
$arrTemplate [ 'STEP2_TEXT1_1' ] = $myInstClass -> translate ( " Please complete the form below. Mandatory fields marked <em>*</em> " );
$arrTemplate [ 'STEP2_TEXT2_1' ] = $myInstClass -> translate ( " Database Configuration " );
$arrTemplate [ 'STEP2_TEXT2_2' ] = $myInstClass -> translate ( " Database Type " );
if ( is_array ( $_SESSION [ 'install' ][ 'dbtype_available' ]) && ( count ( $_SESSION [ 'install' ][ 'dbtype_available' ]) != 0 )) {
$strDBType = " " ;
foreach ( $_SESSION [ 'install' ][ 'dbtype_available' ] AS $elem ) {
$strSelected = " " ;
if ( isset ( $_SESSION [ 'install' ][ 'dbtype' ]) && ( $_SESSION [ 'install' ][ 'dbtype' ] == $elem )) $strSelected = " selected= \" selected \" " ;
$strDBType .= " <option value= \" " . $elem . " \" $strSelected > " . $elem . " </option> \n " ;
}
} else {
$strDBType .= " <option value= \" mysql \" $strSelected >mysql</option> \n " ;
}
$arrTemplate [ 'STEP2_VALUE2_2' ] = $strDBType ;
$arrTemplate [ 'STEP2_TEXT2_3' ] = $myInstClass -> translate ( " Database Server " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_3' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbserver' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_4' ] = $myInstClass -> translate ( " Local hostname or IP address " );
2017-05-22 11:24:21 +02:00
if ( htmlspecialchars ( $_SESSION [ 'install' ][ 'dbserver' ], ENT_QUOTES , 'utf-8' ) == " localhost " ) {
$arrTemplate [ 'STEP2_VALUE2_4' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbserver' ], ENT_QUOTES , 'utf-8' );
} else {
$arrTemplate [ 'STEP2_VALUE2_4' ] = $_SERVER [ 'SERVER_ADDR' ];
}
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_5' ] = $myInstClass -> translate ( " Database Server Port " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_5' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbport' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_6' ] = $myInstClass -> translate ( " Database name " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_6' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbname' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_7' ] = $myInstClass -> translate ( " NagiosQL DB User " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_7' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbuser' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_8' ] = $myInstClass -> translate ( " NagiosQL DB Password " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_8' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'dbpass' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_9' ] = $myInstClass -> translate ( " Administrative Database User " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE2_9' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'admuser' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT2_10' ] = $myInstClass -> translate ( " Administrative Database Password " );
$arrTemplate [ 'STEP2_TEXT2_11' ] = $myInstClass -> translate ( " Drop database if already exists? " );
2017-05-22 11:24:21 +02:00
if ( $_SESSION [ 'install' ][ 'dbdrop' ] == 1 ) { $arrTemplate [ 'STEP2_VALUE2_11' ] = " checked " ;} else { $arrTemplate [ 'STEP2_VALUE2_11' ] = " " ;}
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT3_1' ] = $myInstClass -> translate ( " NagiosQL User Setup " );
$arrTemplate [ 'STEP2_TEXT3_2' ] = $myInstClass -> translate ( " Initial NagiosQL User " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE3_2' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'qluser' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT3_3' ] = $myInstClass -> translate ( " Initial NagiosQL Password " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE3_3' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'qlpass' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT3_4' ] = $myInstClass -> translate ( " Please repeat the password " );
$arrTemplate [ 'STEP2_TEXT4_1' ] = $myInstClass -> translate ( " Nagios Configuration " );
$arrTemplate [ 'STEP2_TEXT4_2' ] = $myInstClass -> translate ( " Import Nagios sample config? " );
2017-05-22 11:24:21 +02:00
if ( $_SESSION [ 'install' ][ 'sample' ] == 1 ) { $arrTemplate [ 'STEP2_VALUE4_2' ] = " checked " ;} else { $arrTemplate [ 'STEP2_VALUE4_2' ] = " " ;}
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_FORM_1' ] = $myInstClass -> translate ( " Next " );
$arrTemplate [ 'STEP2_TEXT5_1' ] = $myInstClass -> translate ( " NagiosQL path values " );
$arrTemplate [ 'STEP2_TEXT5_2' ] = $myInstClass -> translate ( " Create NagiosQL config paths? " );
2017-05-22 11:24:21 +02:00
if ( $_SESSION [ 'install' ][ 'createpath' ] == 1 ) { $arrTemplate [ 'STEP2_VALUE5_2' ] = " checked " ;} else { $arrTemplate [ 'STEP2_VALUE5_2' ] = " " ;}
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT5_3' ] = $myInstClass -> translate ( " NagiosQL config path " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE5_3' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'qlpath' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT5_4' ] = $myInstClass -> translate ( " Nagios config path " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'STEP2_VALUE5_4' ] = htmlspecialchars ( $_SESSION [ 'install' ][ 'nagpath' ], ENT_QUOTES , 'utf-8' );
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT5_5' ] = $myInstClass -> translate ( " Both path values were stored in your configuration target settings for localhost. " );
$arrTemplate [ 'STEP2_TEXT5_6' ] = $myInstClass -> translate ( " If you select the create path option, be sure that the NagiosQL base path exist and the webserver demon has write access to it. So the installer will create the required subdirectories in your localhost's filesystem (hosts, services, backup etc.) " );
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'INSTALL_FIELDS' ] = " " ;
//
// Setting some template values to blank
// =====================================
$arrTemplate [ 'STEP2_TEXT1_2' ] = " " ;
//
// Conditional checks
// =======================
if ( $_SESSION [ 'install' ][ 'mode' ] == " Update " ) {
2017-10-20 15:00:08 +02:00
$arrTemplate [ 'STEP2_TEXT1_2' ] = " <p style= \" color:red; \" ><b> " . $myInstClass -> translate ( " Please backup your database before proceeding! " ) . " </b></p> \n " ;
2017-05-22 11:24:21 +02:00
$arrTemplate [ 'INST_VISIBLE' ] = " hidefield " ;
} else {
$arrTemplate [ 'INSTALL_FIELDS' ] = " ,tfDBprivUser,tfDBprivPass,tfQLuser,tfQLpass " ;
$arrTemplate [ 'INST_VISIBLE' ] = " showfield " ;
}
//
// Write content
// =============
$strContent = $myInstClass -> parseTemplate ( $arrTemplate , $preIncludeContent );
echo $strContent ;
?>