2007-02-20 02:38:59 +01:00
< ? php
2009-01-24 21:11:07 +01:00
2009-06-08 20:26:14 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
2007-02-20 02:38:59 +01:00
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
2008-08-22 20:07:32 +02:00
// as published by the Free Software Foundation for version 2.
2007-02-20 02:38:59 +01:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2009-06-08 20:26:14 +02:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2007-02-20 02:38:59 +01:00
// GNU General Public License for more details.
2009-06-08 20:26:14 +02:00
2007-02-20 02:38:59 +01:00
?>
<! DOCTYPE html PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " >
< html >
< head >
< title > Pandora FMS - Installation Wizard </ title >
< meta http - equiv = " expires " content = " 0 " >
2007-09-04 13:32:19 +02:00
< meta http - equiv = " content-type " content = " text/html; charset=utf-8 " >
2007-02-20 02:38:59 +01:00
< meta name = " resource-type " content = " document " >
< meta name = " distribution " content = " global " >
< meta name = " author " content = " Sancho Lerena, Raul Mateos " >
< meta name = " copyright " content = " This is GPL software. Created by Sancho Lerena and others " >
< meta name = " keywords " content = " pandora, fms, monitoring, network, system, GPL, software " >
< meta name = " robots " content = " index, follow " >
< link rel = " icon " href = " images/pandora.ico " type = " image/ico " >
2007-06-02 15:52:45 +02:00
< link rel = " stylesheet " href = " include/styles/pandora_minimal.css " type = " text/css " >
2007-05-27 14:11:15 +02:00
< link rel = " stylesheet " href = " include/styles/install.css " type = " text/css " >
</ head >
2008-08-22 20:07:32 +02:00
< body bgcolor = " #555555 " >
2007-05-27 14:11:15 +02:00
< ? php
2007-02-20 02:38:59 +01:00
2010-02-10 18:10:10 +01:00
$version = " 3.1-dev " ;
2010-03-17 20:07:49 +01:00
$build = " 100317 " ;
2010-02-10 18:10:10 +01:00
$banner = " v $version Build $build " ;
2007-02-20 02:38:59 +01:00
error_reporting ( 0 );
function check_extension ( $ext , $label ){
echo " <tr><td> " ;
2007-06-27 19:45:42 +02:00
echo " <span class='arr'> $label </span> " ;
2007-02-20 02:38:59 +01:00
echo " </td><td> " ;
if ( ! extension_loaded ( $ext )){
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
2009-12-21 16:23:32 +01:00
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_green.png'> " ;
2007-02-20 02:38:59 +01:00
return 0 ;
}
echo " </td></tr> " ;
}
function check_include ( $ext , $label ){
echo " <tr><td> " ;
2007-06-27 19:45:42 +02:00
echo " <span class='arr'> $label </span> " ;
2007-02-20 02:38:59 +01:00
echo " </td><td> " ;
if ( ! include ( $ext )){
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
2009-12-21 16:23:32 +01:00
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_green.png'> " ;
2007-02-20 02:38:59 +01:00
return 0 ;
}
echo " </td></tr> " ;
}
function check_exists ( $file , $label ){
echo " <tr><td> " ;
2007-06-27 19:45:42 +02:00
echo " <span class='arr'> $label </span> " ;
2007-02-20 02:38:59 +01:00
echo " </td><td> " ;
if ( ! file_exists ( $file )){
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
2009-12-21 16:23:32 +01:00
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_green.png'> " ;
2007-02-20 02:38:59 +01:00
return 0 ;
}
echo " </td></tr> " ;
}
function check_generic ( $ok , $label ){
echo " <tr><td> " ;
2007-06-27 19:45:42 +02:00
echo " <span class='arr'> $label </span> " ;
2007-02-20 02:38:59 +01:00
echo " </td><td> " ;
if ( $ok == 0 ){
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
2009-12-21 16:23:32 +01:00
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_green.png'> " ;
2007-02-20 02:38:59 +01:00
return 0 ;
}
echo " </td></tr> " ;
}
2008-09-01 06:22:26 +02:00
function check_writable ( $fullpath , $label ){
echo " <tr><td> " ;
echo " <span class='arr'> $label </span> " ;
echo " </td><td> " ;
if ( file_exists ( $fullpath ))
if ( is_writable ( $fullpath )){
echo " <img src='images/dot_green.png'> " ;
echo " </td></tr> " ;
return 0 ;
2009-12-21 16:23:32 +01:00
}
else {
2008-09-01 06:22:26 +02:00
echo " <img src='images/dot_red.png'> " ;
echo " </td></tr> " ;
return 1 ;
}
else {
echo " <img src='images/dot_red.png'> " ;
echo " </td></tr> " ;
return 1 ;
}
}
2007-02-20 02:38:59 +01:00
function check_variable ( $var , $value , $label , $mode ){
echo " <tr><td> " ;
2007-06-27 19:45:42 +02:00
echo " <span class='arr'> $label </span> " ;
2007-02-20 02:38:59 +01:00
echo " </td><td> " ;
if ( $mode == 1 ){
if ( $var >= $value ){
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_green.png'> " ;
2007-02-20 02:38:59 +01:00
return 0 ;
2009-12-21 16:23:32 +01:00
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
}
2009-12-21 16:23:32 +01:00
}
elseif ( $var == $value ){
echo " <img src='images/dot_green.png'> " ;
return 0 ;
}
else {
2007-06-27 19:45:42 +02:00
echo " <img src='images/dot_red.png'> " ;
2007-02-20 02:38:59 +01:00
return 1 ;
}
echo " </td></tr> " ;
}
2007-04-11 05:12:48 +02:00
function parse_mysql_dump ( $url ){
if ( file_exists ( $url )){
2009-01-24 21:11:07 +01:00
$file_content = file ( $url );
$query = " " ;
foreach ( $file_content as $sql_line ){
2007-04-11 05:12:48 +02:00
if ( trim ( $sql_line ) != " " && strpos ( $sql_line , " -- " ) === false ){
$query .= $sql_line ;
if ( preg_match ( " /;[ \040 ]* \$ / " , $sql_line )){
2008-07-07 19:33:31 +02:00
if ( ! $result = mysql_query ( $query )) {
2010-02-10 18:10:10 +01:00
echo mysql_error (); //Uncomment for debug
echo " <i><br> $query <br></i> " ;
2007-04-11 05:12:48 +02:00
return 0 ;
2008-07-07 19:33:31 +02:00
}
2007-04-11 05:12:48 +02:00
$query = " " ;
}
}
}
return 1 ;
}
2009-12-21 16:23:32 +01:00
else
return 0 ;
2007-04-11 05:12:48 +02:00
}
function random_name ( $size ){
$temp = " " ;
for ( $a = 0 ; $a < $size ; $a ++ )
$temp = $temp . chr ( rand ( 122 , 97 ));
2009-12-21 16:23:32 +01:00
2007-04-11 05:12:48 +02:00
return $temp ;
}
2010-02-10 18:10:10 +01:00
function print_logo_status ( $step , $step_total ){
global $banner ;
echo "
< div id = 'logo_img' >
< img src = 'images/pandora_logo.png' border = '0' >< br >
< span style = 'font-size: 8px;' > $banner </ span >
< br >< br >
< b > Install step $step of $step_total </ b >
</ div > " ;
}
2007-04-11 05:12:48 +02:00
function install_step1 () {
2010-02-10 18:10:10 +01:00
global $banner ;
2007-04-11 05:12:48 +02:00
echo "
2007-05-27 14:11:15 +02:00
< div id = 'install_container' >
2010-02-10 18:10:10 +01:00
< h1 > Pandora FMS installation wizard . Step #1 of 5</h1>
2008-09-01 06:22:26 +02:00
< div id = 'wizard' style = 'height: 490px;' >
2007-04-11 05:12:48 +02:00
< div id = 'install_box' >
2010-02-10 18:10:10 +01:00
< h2 > Welcome to Pandora FMS installation Wizard </ h2 >
2007-04-11 05:12:48 +02:00
< p > This wizard helps you to quick install Pandora FMS console in your system .</ p >
2008-08-27 12:13:25 +02:00
< p > In four steps checks all dependencies and make your configuration
for a quick installation .</ p >
2007-04-11 05:12:48 +02:00
< p > For more information , please refer to documentation .</ p >
2007-05-27 14:11:15 +02:00
< i > Pandora FMS Development Team </ i >
2007-04-11 05:12:48 +02:00
" ;
if ( file_exists ( " include/config.php " )){
2008-08-27 12:13:25 +02:00
echo " <div class='warn'><b>Warning:</b> You already have a config.php file.
Configuration and database would be overwritten if you continued .</ div > " ;
2007-04-11 05:12:48 +02:00
}
2008-09-01 06:22:26 +02:00
echo " <table width=100%> " ;
2008-09-18 14:01:32 +02:00
$writable = check_writable ( " include " , " Checking if ./include is writable " );
2008-09-01 06:22:26 +02:00
if ( file_exists ( " include/config.php " ))
$writable += check_writable ( " include/config.php " , " Checking if include/config.php is writable " );
echo " </table> " ;
2008-08-27 12:13:25 +02:00
echo " <div class='warn'><b>Warning:</b> This installer will <b>overwrite and destroy</b>
your existing Pandora FMS configuration and < b > Database </ b >. Before continue ,
please < b > be sure that you have no valuable Pandora FMS data in your Database </ b >.< br >
</ div > " ;
echo " <div class='info'><b>Upgrade</b>:
2009-09-21 02:59:34 +02:00
If you want to upgrade from Pandora FMS 2. x to 3.0 version ,
2008-08-27 12:13:25 +02:00
please download the migration tool from our website at
< a href = 'http://www.pandorafms.com' > PandoraFMS . com web site </ a >.</ div > " ;
2010-02-10 18:10:10 +01:00
echo " </div> " ;
print_logo_status ( 1 , 5 );
echo " <div id='install_img'> " ;
2009-12-21 16:23:32 +01:00
if ( $writable == 0 ) {
2008-09-01 06:22:26 +02:00
echo "
2010-02-10 18:10:10 +01:00
< br >< br >
< a href = 'install.php?step=11' >< img align = 'right' src = 'images/arrow_next.png' border = '0' ></ a > " ;
2009-12-21 16:23:32 +01:00
}
2008-09-01 06:22:26 +02:00
else
echo " <div class='warn'><b>ERROR:</b>You need to setup permissions to be able to write in ./include directory</div> " ;
echo "
2007-04-11 05:12:48 +02:00
</ div >
2007-05-27 14:11:15 +02:00
</ div >
< div id = 'foot_install' >
2008-09-01 06:22:26 +02:00
< i > Pandora FMS is an OpenSource Software project registered at
2008-08-27 12:13:25 +02:00
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
2007-05-27 14:11:15 +02:00
</ div >
2007-04-11 05:12:48 +02:00
</ div > " ;
}
2010-02-10 18:10:10 +01:00
function install_step1_licence () {
echo "
< div id = 'install_container' >
< h1 > Pandora FMS installation wizard . Step #2 of 5</h1>
< div id = 'wizard' style = 'height: 520px;' >
< div id = 'install_box' >
< h2 > GPL2 Licence terms agreement </ h2 >
< p > Pandora FMS is an OpenSource software project licensed under the GPL2 licence . Pandora FMS includes , as well , another software also licensed under LGPL and BSD licenses . Before continue , < i > you must accept the licence terms .</ i >.
< p > For more information , please refer to our website at http :// pandorafms . org and contact us if you have any kind of question about the usage of Pandora FMS </ p >
< p > If you dont accept the licence terms , please , close your browser and delete Pandora FMS files .</ p >
" ;
if ( ! file_exists ( " COPYING " )){
echo " <div class='warn'><b>Licence file 'COPYING' is not present in your distribution. This means you have some 'partial' Pandora FMS distribution. We cannot continue without accepting the licence file. " ;
echo " </div> " ;
} else {
echo " <form method=post action='install.php?step=2'> " ;
2010-03-06 14:45:48 +01:00
echo " <textarea name='gpl2' cols=50 rows=17> " ;
2010-02-10 18:10:10 +01:00
echo file_get_contents ( " COPYING " );
echo " </textarea> " ;
echo " <p> " ;
2010-03-04 21:02:29 +01:00
echo " <input type=submit value='Yes, I accept licence terms'> " ;
2010-02-10 18:10:10 +01:00
}
echo " </div> " ;
print_logo_status ( 2 , 5 );
echo " </div>
< div style = 'clear: both;height: 1px;' ><!-- --></ div >
< div id = 'foot_install' >
< i > Pandora FMS is an OpenSource Software project registered at
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
</ div >
</ div > " ;
}
2007-04-11 05:12:48 +02:00
2007-02-20 02:38:59 +01:00
function install_step2 () {
2010-02-10 18:10:10 +01:00
2007-02-20 02:38:59 +01:00
echo "
2007-05-27 14:11:15 +02:00
< div id = 'install_container' >
2010-02-10 18:10:10 +01:00
< h1 > Pandora FMS console installation wizard . Step #3 of 5</h1>
2009-08-19 14:03:45 +02:00
< div id = 'wizard' style = 'min-height: 390px;' >
2007-02-20 02:38:59 +01:00
< div id = 'install_box' > " ;
2008-08-22 20:07:32 +02:00
echo " <h2>Checking software dependencies</h2> " ;
2007-02-20 02:38:59 +01:00
echo " <table border=0 width=230> " ;
$res = 0 ;
2008-10-05 17:00:20 +02:00
$res += check_variable ( phpversion (), " 5.2 " , " PHP version >= 5.2 " , 1 );
2007-02-20 02:38:59 +01:00
$res += check_extension ( " mysql " , " PHP MySQL extension " );
2008-10-05 17:00:20 +02:00
$res += check_extension ( " gd " , " PHP GD extension " );
2009-01-20 21:01:25 +01:00
$res += check_extension ( " ldap " , " PHP LDAP extension " );
2007-04-24 15:38:44 +02:00
$res += check_extension ( " snmp " , " PHP SNMP extension " );
2007-02-20 02:38:59 +01:00
$res += check_extension ( " session " , " PHP session extension " );
2008-08-22 20:07:32 +02:00
$res += check_extension ( " gettext " , " PHP gettext extension " );
2007-02-20 02:38:59 +01:00
$res += check_include ( " PEAR.php " , " PEAR PHP Library " );
2008-09-01 06:22:26 +02:00
$res += check_include ( " DB.php " , " PEAR:DB PHP Library " );
2009-12-05 12:38:12 +01:00
$res += check_include ( " XML/RPC.php " , " PEAR::XML_RPC PHP Library " );
2008-09-01 06:22:26 +02:00
$res += check_exists ( " /usr/bin/twopi " , " Graphviz Binary " );
2010-02-10 18:10:10 +01:00
echo " </table> " ;
echo " </div> " ;
print_logo_status ( 3 , 5 );
echo " <div id='install_img'> " ;
2007-02-20 02:38:59 +01:00
if ( $res > 0 ) {
2008-08-27 12:13:25 +02:00
echo "
< div class = 'warn' > You have some incomplete
2007-04-11 12:09:09 +02:00
dependencies . Please correct them or this installer
will not be able to finish your installation .
2007-05-27 14:11:15 +02:00
</ div >
2010-02-10 18:10:10 +01:00
Ignore it . < a href = 'install.php?step=3' style = 'font-weight: bolder;' > Force install Step #4</a>";
2009-12-21 16:23:32 +01:00
}
else {
2010-02-10 18:10:10 +01:00
echo " <a href='install.php?step=3'><br>
2008-08-27 12:13:25 +02:00
< img align = 'right' src = 'images/arrow_next.png' border = '0' alt = '' ></ a > " ;
2007-02-20 02:38:59 +01:00
}
echo "
</ div >
2009-08-19 14:03:45 +02:00
< div style = 'clear: both;' ><!-- --></ div >
2007-05-27 14:11:15 +02:00
</ div >
< div id = 'foot_install' >
2008-09-01 06:22:26 +02:00
< i > Pandora FMS is an OpenSource Software project registered at
2007-05-27 14:11:15 +02:00
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
</ div >
</ div > " ;
2007-02-20 02:38:59 +01:00
}
2007-05-27 14:11:15 +02:00
2007-02-20 02:38:59 +01:00
function install_step3 () {
echo "
2007-05-27 14:11:15 +02:00
< div id = 'install_container' >
2010-02-10 18:10:10 +01:00
< h1 > Pandora FMS console installation wizard . Step #4 of 5 </h1>
2007-08-21 12:04:01 +02:00
< div id = 'wizard' style = 'height: 640px;' >
2007-02-20 02:38:59 +01:00
< div id = 'install_box' >
2008-08-22 20:07:32 +02:00
< h2 > Environment and database setup </ h2 >
2007-02-20 02:38:59 +01:00
< p >
2008-08-27 12:13:25 +02:00
This wizard will create your Pandora FMS database ,
and populate it with all the data needed to run for the first time .
2007-02-20 02:38:59 +01:00
</ p >
< p >
2007-06-02 15:52:45 +02:00
You need a privileged user to create database schema , this is usually < b > root </ b > user .
Information about < b > root </ b > user will not be used or stored anymore .
</ p >
< p >
2008-08-27 12:13:25 +02:00
Now , please , complete all details to configure your database and environment setup .
2007-05-27 14:11:15 +02:00
</ p >
2008-08-27 12:13:25 +02:00
< div class = 'warn' >
< b > Warning :</ b > This installer will < b > overwrite and destroy </ b > your existing
Pandora FMS configuration and < b > Database </ b >. Before continue ,
please < b > be sure that you have no valuable Pandora FMS data in your Database .</ b >
< br >< br >
</ div >
2007-02-20 02:38:59 +01:00
< form method = 'post' action = 'install.php?step=4' >
< div > DB User with privileges on MySQL </ div >
2007-04-11 05:12:48 +02:00
< input class = 'login' type = 'text' name = 'user' value = 'root' >
2007-02-20 02:38:59 +01:00
< div > DB Password for this user </ div >
2007-06-27 19:45:42 +02:00
< input class = 'login' type = 'password' name = 'pass' value = '' >
2007-04-11 05:12:48 +02:00
2007-02-20 02:38:59 +01:00
< div > DB Hostname of MySQL </ div >
2007-04-11 05:12:48 +02:00
< input class = 'login' type = 'text' name = 'host' value = 'localhost' >
< div > DB Name ( pandora by default ) </ div >
< input class = 'login' type = 'text' name = 'dbname' value = 'pandora' >
2007-02-20 02:38:59 +01:00
2009-05-13 19:00:58 +02:00
< input class = 'login' type = 'checkbox' name = 'drop' value = 1 >
Drop Database if exists
2007-06-02 15:52:45 +02:00
< div > Full path to HTTP publication directory < br >
2008-08-27 12:13:25 +02:00
< span class = 'f9b' > For example / var / www / pandora_console /.
Needed for graphs and attachments .
</ span >
2007-02-20 02:38:59 +01:00
</ div >
2008-08-27 12:13:25 +02:00
< input class = 'login' type = 'text' name = 'path' style = 'width: 190px;'
2008-09-03 17:47:09 +02:00
value = '".dirname (__FILE__)."' >
2007-02-20 02:38:59 +01:00
2008-09-03 17:47:09 +02:00
< div > URL path to Pandora FMS Console < br >
2008-09-03 14:11:53 +02:00
< span class = 'f9b' > For example '/pandora_console' </ span >
2007-02-20 02:38:59 +01:00
</ div >
2008-08-27 12:13:25 +02:00
< input class = 'login' type = 'text' name = 'url' style = 'width: 250px;'
2009-01-24 21:11:07 +01:00
value = '".dirname ($_SERVER["SCRIPT_NAME"])."' >
2007-02-20 02:38:59 +01:00
2010-02-10 18:10:10 +01:00
< div align = 'right' >< br >
2008-08-27 12:13:25 +02:00
< input type = 'image' src = 'images/arrow_next.png' value = 'Step #4' id = 'step4' >
</ div >
2007-02-20 02:38:59 +01:00
</ form >
2010-02-10 18:10:10 +01:00
</ div > " ;
print_logo_status ( 4 , 5 );
echo " </div>
2007-05-27 14:11:15 +02:00
< div id = 'foot_install' >
2008-09-01 06:22:26 +02:00
< i > Pandora FMS is an OpenSource Software project registered at
2007-05-27 14:11:15 +02:00
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
2007-02-20 02:38:59 +01:00
</ div >
</ div > " ;
}
function install_step4 () {
$pandora_config = " include/config.php " ;
2008-08-27 12:13:25 +02:00
if ( ( ! isset ( $_POST [ " user " ])) || ( ! isset ( $_POST [ " dbname " ])) || ( ! isset ( $_POST [ " host " ])) ||
( ! isset ( $_POST [ " pass " ])) ) {
2007-02-20 02:38:59 +01:00
$dbpassword = " " ;
$dbuser = " " ;
$dbhost = " " ;
2007-04-11 05:12:48 +02:00
$dbname = " " ;
2009-12-21 16:23:32 +01:00
}
else {
2007-02-20 02:38:59 +01:00
$dbpassword = $_POST [ " pass " ];
$dbuser = $_POST [ " user " ];
$dbhost = $_POST [ " host " ];
2009-05-13 19:00:58 +02:00
if ( isset ( $_POST [ " drop " ]))
$dbdrop = $_POST [ " drop " ];
else
$dbdrop = 0 ;
2007-04-11 05:12:48 +02:00
$dbname = $_POST [ " dbname " ];
2007-02-20 02:38:59 +01:00
if ( isset ( $_POST [ " url " ]))
$url = $_POST [ " url " ];
else
$url = " http://localhost " ;
if ( isset ( $_POST [ " path " ]))
$path = $_POST [ " path " ];
else
$path = " /var/www " ;
}
$everything_ok = 0 ;
$step1 = 0 ;
$step2 = 0 ;
$step3 = 0 ;
$step4 = 0 ; $step5 = 0 ; $step6 = 0 ; $step7 = 0 ;
2009-12-21 16:23:32 +01:00
2007-02-20 02:38:59 +01:00
echo "
2007-05-27 14:11:15 +02:00
< div id = 'install_container' >
2010-02-10 18:10:10 +01:00
< h1 > Pandora FMS Console installation wizard . Step #5 of 5</h1>
< div id = 'wizard' style = 'height: 480px;' >
2007-02-20 02:38:59 +01:00
< div id = 'install_box' >
2008-08-22 20:07:32 +02:00
< h2 > Creating database and default configuration file </ h2 >
2007-02-20 02:38:59 +01:00
< table > " ;
if ( ! mysql_connect ( $dbhost , $dbuser , $dbpassword )) {
check_generic ( 0 , " Connection with Database " );
2009-12-21 16:23:32 +01:00
}
else {
2007-02-20 02:38:59 +01:00
check_generic ( 1 , " Connection with Database " );
2009-05-13 19:00:58 +02:00
// Drop database if needed
if ( $dbdrop == 1 )
mysql_query ( " DROP DATABASE IF EXISTS $dbname " );
2007-02-20 02:38:59 +01:00
// Create schema
2007-04-11 05:12:48 +02:00
$step1 = mysql_query ( " CREATE DATABASE $dbname " );
check_generic ( $step1 , " Creating database ' $dbname ' " );
2009-12-21 16:23:32 +01:00
if ( $step1 == 1 ) {
2007-04-11 05:12:48 +02:00
$step2 = mysql_select_db ( $dbname );
check_generic ( $step2 , " Opening database ' $dbname ' " );
2007-02-20 02:38:59 +01:00
$step3 = parse_mysql_dump ( " pandoradb.sql " );
check_generic ( $step3 , " Creating schema " );
$step4 = parse_mysql_dump ( " pandoradb_data.sql " );
check_generic ( $step4 , " Populating database " );
$random_password = random_name ( 8 );
2009-05-28 13:32:12 +02:00
$host = 'localhost' ;
if ( $dbhost != 'localhost' )
$host = $_SERVER [ 'SERVER_ADDR' ];
$step5 = mysql_query ( " GRANT ALL PRIVILEGES ON $dbname .* to pandora@ $host
2008-08-27 12:13:25 +02:00
IDENTIFIED BY '".$random_password."' " );
2007-02-20 02:38:59 +01:00
mysql_query ( " FLUSH PRIVILEGES " );
2009-05-13 19:00:58 +02:00
check_generic ( $step5 , " Established privileges for user pandora. A new random password has been generated: <b> $random_password </b><div class='warn'>Please write it down, you will need to setup your Pandora FMS server, editing the </i>/etc/pandora/pandora_server.conf</i> file</div> " );
2007-02-20 02:38:59 +01:00
$step6 = is_writable ( " include " );
check_generic ( $step6 , " Write permissions to save config file in './include' " );
$cfgin = fopen ( " include/config.inc.php " , " r " );
$cfgout = fopen ( $pandora_config , " w " );
$config_contents = fread ( $cfgin , filesize ( " include/config.inc.php " ));
2007-05-27 14:11:15 +02:00
$config_new = ' < ? php
2009-12-21 16:23:32 +01:00
// Begin of automatic config file
$config [ " dbname " ] = " '. $dbname .' " ; // MySQL DataBase name
$config [ " dbuser " ] = " pandora " ; // DB User
$config [ " dbpass " ] = " '. $random_password .' " ; // DB Password
$config [ " dbhost " ] = " '. $dbhost .' " ; // DB Host
$config [ " homedir " ] = " '. $path .' " ; // Config homedir
$config [ " homeurl " ] = " '. $url .' " ; // Base URL
// End of automatic config file
?> ';
2007-02-20 02:38:59 +01:00
$step7 = fputs ( $cfgout , $config_new );
$step7 = $step7 + fputs ( $cfgout , $config_contents );
if ( $step7 > 0 )
$step7 = 1 ;
fclose ( $cfgin );
fclose ( $cfgout );
2007-06-28 16:17:25 +02:00
chmod ( $pandora_config , 0600 );
2007-02-20 02:38:59 +01:00
check_generic ( $step7 , " Created new config file at ' " . $pandora_config . " ' " );
}
}
if (( $step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1 ) == 7 ) {
$everything_ok = 1 ;
}
2010-02-10 18:10:10 +01:00
echo " </table></div> " ;
print_logo_status ( 4 , 5 );
2007-02-20 02:38:59 +01:00
2010-02-10 18:10:10 +01:00
echo " <div id='install_img'> " ;
2007-02-20 02:38:59 +01:00
if ( $everything_ok == 1 ) {
2008-08-27 12:13:25 +02:00
echo " <br><br><a href='install.php?step=5'>
< img align = 'right' src = 'images/arrow_next.png' border = '0' alt = '' ></ a > " ;
2009-12-21 16:23:32 +01:00
}
else {
2009-04-29 12:01:25 +02:00
echo " <div class='warn'><b>There were some problems.
Installation was not completed .</ b >
2007-05-27 14:11:15 +02:00
< p > Please correct failures before trying again .
2010-02-10 18:10:10 +01:00
All database schemes created in this step have been dropped . </ p >
2008-08-27 12:13:25 +02:00
</ div > " ;
2007-02-20 02:38:59 +01:00
if ( mysql_error () != " " )
2007-05-27 14:11:15 +02:00
echo " <div class='warn'> <b>ERROR:</b> " . mysql_error () . " .</div> " ;
2009-05-13 19:00:58 +02:00
if ( $step1 == 1 )
mysql_query ( " DROP DATABASE $dbname " );
2007-02-20 02:38:59 +01:00
}
echo "
</ div >
</ div >
2007-05-27 14:11:15 +02:00
< div id = 'foot_install' >
2009-05-13 19:00:58 +02:00
< i > Pandora FMS is an Open Source Software project registered at
2007-02-20 02:38:59 +01:00
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
</ div >
</ div > " ;
}
2007-05-27 14:11:15 +02:00
2007-02-20 02:38:59 +01:00
function install_step5 () {
echo "
2007-05-27 14:11:15 +02:00
< div id = 'install_container' >
2007-04-24 15:38:44 +02:00
< h1 > Pandora FMS console installation wizard . Finished </ h1 >
2007-02-20 02:38:59 +01:00
< div id = 'wizard' style = 'height: 300px;' >
< div id = 'install_box' >
2008-08-22 20:07:32 +02:00
< h2 > Installation complete </ h2 >
2009-04-29 12:01:25 +02:00
< p > For security , you now must manually delete this installer
( '<i>install.php</i>' ) file before trying to access to your Pandora FMS console .
< p > You should also install Pandora FMS Servers before trying to monitor anything ;
2008-08-27 12:13:25 +02:00
please read documentation on how to install it .</ p >
2010-03-10 18:58:29 +01:00
< p > Default user is < b > 'admin' </ b > with password < b > 'pandora' </ b > , please change it both as soon as possible .</ p >
2008-08-27 12:13:25 +02:00
< p > Don 't forget to check <a href=' http :// pandorafms . com ' > http :// pandorafms . com </ a >
for updates .
2009-04-29 12:01:25 +02:00
< p >< br >< b >< a href = 'index.php' > Click here to access to your Pandora FMS console </ a >.</ b >
2008-08-27 12:13:25 +02:00
</ p >
2010-02-10 18:10:10 +01:00
</ div > " ;
print_logo_status ( 5 , 5 );
echo " </div>
2007-05-27 14:11:15 +02:00
< div id = 'foot_install' >
2008-09-01 06:22:26 +02:00
< i > Pandora FMS is an OpenSource Software project registered at
2007-02-20 02:38:59 +01:00
< a target = '_new' href = 'http://pandora.sourceforge.net' > SourceForge </ a ></ i >
</ div >
</ div > " ;
}
2007-04-11 05:12:48 +02:00
// ---------------
// Main page code
// ---------------
2007-02-20 02:38:59 +01:00
if ( ! isset ( $_GET [ " step " ])){
install_step1 ();
} else {
$step = $_GET [ " step " ];
switch ( $step ) {
2010-02-10 18:10:10 +01:00
case 11 : install_step1_licence ();
break ;
2007-02-20 02:38:59 +01:00
case 2 : install_step2 ();
break ;
case 3 : install_step3 ();
break ;
case 4 : install_step4 ();
break ;
case 5 : install_step5 ();
break ;
}
}
2007-04-11 05:12:48 +02:00
?>
2007-06-02 15:52:45 +02:00
</ body >
</ html >