From 36934a367c3fbeac8a09a8d5b9c8cc6fde596c58 Mon Sep 17 00:00:00 2001 From: slerena Date: Tue, 20 Feb 2007 01:38:59 +0000 Subject: [PATCH] 2007-02-19 Sancho Leren * include/styles/pandora.css: Updated to have new styles for installer. * include/config.inc.php: New skeleton for config, used in wizard. * install.php: NEW wizar/installer for console. * index.php: Some modifications for main page. * operation/incidents/incide*: Some header changes. * operation/active_console/index.php: Header changes. * images/*: New images for wizard. * general/error_*.php: New messages for wizard. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@378 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 19 + pandora_console/general/error_install.php | 55 +++ pandora_console/general/error_perms.php | 56 +++ pandora_console/images/arrow_next.png | Bin 0 -> 473 bytes pandora_console/images/step0.png | Bin 0 -> 226 bytes pandora_console/images/step1.png | Bin 0 -> 226 bytes pandora_console/images/step2.png | Bin 0 -> 258 bytes pandora_console/images/step3.png | Bin 0 -> 266 bytes pandora_console/images/step4.png | Bin 0 -> 250 bytes pandora_console/include/config.inc.php | 102 +++++ pandora_console/include/styles/pandora.css | 20 + pandora_console/index.php | 35 +- pandora_console/install.php | 433 ++++++++++++++++++ .../operation/active_console/index.php | 16 +- .../operation/incidents/incident.php | 17 +- .../operation/incidents/incident_detail.php | 17 +- .../operation/incidents/incident_note.php | 17 +- .../operation/incidents/incident_search.php | 17 +- .../incidents/incident_statistics.php | 17 +- 19 files changed, 764 insertions(+), 57 deletions(-) create mode 100644 pandora_console/general/error_install.php create mode 100644 pandora_console/general/error_perms.php create mode 100644 pandora_console/images/arrow_next.png create mode 100644 pandora_console/images/step0.png create mode 100644 pandora_console/images/step1.png create mode 100644 pandora_console/images/step2.png create mode 100644 pandora_console/images/step3.png create mode 100644 pandora_console/images/step4.png create mode 100644 pandora_console/include/config.inc.php create mode 100644 pandora_console/install.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 95e0064990..506a07b659 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,22 @@ +2007-02-19 Sancho Leren + + * include/styles/pandora.css: Updated to have new styles for + installer. + + * include/config.inc.php: New skeleton for config, used in wizard. + + * install.php: NEW wizar/installer for console. + + * index.php: Some modifications for main page. + + * operation/incidents/incide*: Some header changes. + + * operation/active_console/index.php: Header changes. + + * images/*: New images for wizard. + + * general/error_*.php: New messages for wizard. + 2007-02-19 Sancho Lerena * operation/incidents/incident.php: Pagination finished. diff --git a/pandora_console/general/error_install.php b/pandora_console/general/error_install.php new file mode 100644 index 0000000000..52688bba98 --- /dev/null +++ b/pandora_console/general/error_install.php @@ -0,0 +1,55 @@ + + + + +Pandora FMS - <?php echo $lang_label["header_title"]; ?> + + + + + + + + + + + + +
+
+

Installer active

+
+
+ + +
+


For security reasons, normal operation is not possible until you delete installer file. Please delete ./install.php file before running Pandora FMS Console.
+
+
+ + \ No newline at end of file diff --git a/pandora_console/general/error_perms.php b/pandora_console/general/error_perms.php new file mode 100644 index 0000000000..a399ea191e --- /dev/null +++ b/pandora_console/general/error_perms.php @@ -0,0 +1,56 @@ + + + + +Pandora FMS - <?php echo $lang_label["header_title"]; ?> + + + + + + + + + + + + +
+
+

Bad permission for include/config.php

+
+
+ + +
+


For security reasons, config.php must have restrictive permissions, and "other" users cannot read or write to it. It could be writed only for owner (usually www-data or http daemon user), normal operation is not possible until you change permissions for include/config.phpfile. Please do it, it's for your security.
+
+
+ + \ No newline at end of file diff --git a/pandora_console/images/arrow_next.png b/pandora_console/images/arrow_next.png new file mode 100644 index 0000000000000000000000000000000000000000..679f5dcef728e173631cded4d6d6909375b6f74e GIT binary patch literal 473 zcmV;~0Ve*5P)wm!vC^=|D|cMv9YbK zt^b=?|Cwf{rl$XkJ(-!A|AR39eJB5L5&voj|7HOG0RjL300000j;#Yy00001VoOIv z9|a8%y#N3J32;bRa{vGUNB{r;NB~C3Yd!z~0TM|>K~y-)rIhWGgCGn=!>7fvO0{aE zdH?6!09{*mV4P|5!wkk8auX2XBa>3g&ocjmtS$!>w$X{cJwsgY@#$|pVqQml@Io`=KhQ?FOCE6o#Y^RGDL~1jp*=TE^!5IXi3Ph-O;?tNj*fNGc zQqdV&4U&PG#+d>jXPE+Kautl>BG?5A<|iuLC`sH!$%CjW2721qVcIV(QyDu(zqh!n zih@W$7Sp6xD$))Z`8M#S*5WK4q2=C;)C;a9#8dDRmG;la?>1Eij=SU8P!KD(7gp}k zYvB4XRo)g~xenP>nynG#sP*2)BeP82!WX7pH%!yeIsFZVlwkpC2C|UteFJpPz4SZ7rAC_!6kD%+tj&#G*G@V2M$JK*9p81R2u; z4XG1CuP#hIFww!5`Eu;4aF!IIY&k);GNUt|91(7=%;AP>dgholu3{@&R=7-e;j+fn z5}SfzWmlvv(01lHY@*-Cwo3AZq*Y@oH%VDNPHb6Mw<&;$U-Y)?f1 literal 0 HcmV?d00001 diff --git a/pandora_console/images/step1.png b/pandora_console/images/step1.png new file mode 100644 index 0000000000000000000000000000000000000000..88fd7bbf91cc0babec5bb9e053959245283dcc52 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^3xHURg&9b0E$S)*Qi=gSA+G=b{|7Sv+j#2)PK%F^ zx3{;yfB(L`y!`(C`{&P}UteFpGcZ~YsG`Qx#WBR9H(6kbQG$S(nOVXDxda*00u8AX zLQ-bhjmC{tY@3#+uI2Giyk?`smM9-(O!}A0Hnd92{I;UY?(yZ}6(S6sUBvr;B5VMQ^ge5~BnGvttZw zJWrU91v0lUYSdZC=j|+PBOD>LA|;_J+9Oix`IH8oteqDoAGB6z)K*N8+RBrX(4ndO zv?FR;Ll)aE|KbO;CLEh;*6hVrq|5AfhNba<1W82c-U9RUH` zOr|s@GrhjV@=Ah(MTV0nhlj^yrn%0hdj=*GZcP000&Q0{{R3wQ`Df0000jP)t-s|Ns90 z0093yODs{AMrNb0z1Paq#`1DbN~PVm`OxI zR5*=e5Tr6-5H=$IQ^`P!Dczkjyp|`sQp<&<#y-KO zrOwGqsAb^Nv{j3(R;GpoQ_H{=F1d@%gI!ErR#M5pRmOFTtri=5xlNl)9RsHsFHJU^ zY#cJnyqG!$nx>_Mr5alHCoex%Pue?m#VNP6#iuSmY3%b(1FD$f>Eak-(VHx=#3(_)Y?+pUjA?;~R7R4_ zR*@Dhwb}m5+8USTOcRWRzdzVL=M3Pandora Error + +
+
+
+ +
+
+

Pandora Console Error DB-001

+ Cannot connect with Database, please check your database setup in the + ./include/config.php file and read documentation.

+ Probably any of your user/database/hostname values are incorrect or + database is not running.


+ MySQL ERROR: '. mysql_error().' +
  +
+
'); +} +mysql_select_db($dbname); +$result2=mysql_query("SELECT * FROM tconfig"); +while ($row2=mysql_fetch_array($result2)){ + switch ($row2["token"]) { + case "language_code": $language_code=$row2["value"]; + break; + case "block_size": $block_size=$row2["value"]; + break; + case "days_purge": $days_purge=$row2["value"]; + break; + case "days_compact": $days_compact=$row2["value"]; + break; + case "graph_res": $config_graph_res=$row2["value"]; + break; + case "step_compact": $config_step_compact=$row2["value"]; + break; + case "truetype": $config_truetype=$row2["value"]; + break; + case "graph_order": $config_graph_order=$row2["value"]; + break; + case "bgimage": $config_bgimage=$row2["value"]; + break; + } +} +if ($language_code == 'ast_es') { + $help_code='ast'; + } +else $help_code = substr($language_code,0,2); + +?> + diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 5bde0ff846..ef7bff5254 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -420,4 +420,24 @@ div.nf { color: #9a2f0a; margin-left: 7px; padding: 2px 1px 6px 25px; +} +div#wizard { + text-align: left; + border: 1px solid #999999; + margin-top: 3em; + margin-bottom: -1em; + padding: 20px; + width: 600px; + background-color: #fff; + background: url(../../images/background8.jpg); +} +.mt35 { + margin-top: 35px; +} + +div#install_box { + float: right; + padding-right: 20px; + margin-top: 10px; + width: 350px; } \ No newline at end of file diff --git a/pandora_console/index.php b/pandora_console/index.php index e9c5a476e2..b9d60b2ba7 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1,14 +1,16 @@ + + + +Pandora FMS - Installation Wizard + + + + + + + + + + + + + +

Pandora FMS instalation wizard. Step #1 of 4

+
+
+

Welcome to Pandora FMS installation Wizard

+

This wizard helps you to quick install Pandora FMS console in your system.

+

In three steps checks all dependencies and make your configuration for a quick installation.

+

For more information, please refer to documentation.

+ Pandora FMS Development team + "; + if (file_exists("include/config.php")){ + echo "

Warning: You already have a config.php file. Configuracion and database would be overwritten if you continue.

"; + } + echo " +
+
+
+
+
+ +
+
+ +
+
+ +
"; +} + +function check_extension ( $ext, $label ){ + echo ""; + echo " $label"; + echo ""; + if (!extension_loaded($ext)){ + echo ""; + return 1; + } else { + echo ""; + return 0; + } + echo ""; +} + +function check_include ( $ext, $label ){ + echo ""; + echo " $label"; + echo ""; + if (!include($ext)){ + echo ""; + return 1; + } else { + echo ""; + return 0; + } + echo ""; +} + +function check_exists ( $file, $label ){ + echo ""; + echo " $label"; + echo ""; + if (!file_exists ($file)){ + echo " "; + return 1; + } else { + echo " "; + return 0; + } + echo ""; +} + +function check_generic ( $ok, $label ){ + echo ""; + echo " $label"; + echo ""; + if ($ok == 0 ){ + echo " "; + return 1; + } else { + echo " "; + return 0; + } + echo ""; +} + +function check_variable ( $var, $value, $label, $mode ){ + echo ""; + echo " $label"; + echo ""; + if ($mode == 1){ + if ($var >= $value){ + echo " "; + return 0; + } else { + echo " "; + return 1; + } + } elseif ($var == $value){ + echo " "; + return 0; + } else { + echo " "; + return 1; + } + echo ""; +} + +function install_step2() { + echo " +
+

Pandora FMS console instalation wizard. Step #2 of 4

+
+
"; + echo "

Checking software dependencies

"; + echo ""; + $res = 0; + $res += check_variable(phpversion(),"4.3","PHP version >= 4.3.x",1); + $res += check_extension("mysql","PHP MySQL extension"); + //$res += check_extension("curl","PHP Curl extension"); + $res += check_extension("gd","PHP gd extension"); + $res += check_extension("snmp","PHP smmp extension"); + $res += check_extension("session","PHP session extension"); + $res += check_include("PEAR.php","PEAR PHP Library"); + //$res += check_exists ("/usr/bin/pdflatex","PDF Latex in /usr/bin/pdflatex"); + echo "
+
+
+ +
+
+ +
+
"; + if ($res > 0) { + echo "

You have some uncomplete + dependencies. Please correct it or this installer + could not finish your installation. +

+ Ignore it. Force install Step #3"; + } else { + echo ""; + } + echo " +
+
+
+ "; +} + +function install_step3() { + echo " +
+

Pandora FMS console instalation wizard. Step #3 of 4

+
+
+

Environment and database setup

+

+ This wizard will create your Pandora FMS database, and populate it with data needed to run for first time. + You need a privileged user to create database schema, this is usually root user. + Information about root user will not be used or stored for anymore. +

+

+ Now, please, complete all details to configure your database and enviroment setup +

+
+
DB User with privileges on MySQL
+ +
DB Password for this user
+ +
DB Hostname of MySQL
+ + +
Full path to HTTP publication directory.
+ For example /srv/www/hdtocs/ +
+ + +
Full local URL to Pandora FMS Console.
+ For example http://localhost/pandora_console +
+ + +
+
+
+
+ +
+
+ +
+
+ +
"; +} + +function parse_mysql_dump($url){ + if (file_exists($url)){ + $file_content = file($url); + $query = ""; + foreach($file_content as $sql_line){ + if(trim($sql_line) != "" && strpos($sql_line, "--") === false){ + $query .= $sql_line; + if(preg_match("/;[\040]*\$/", $sql_line)){ + if (!$result = mysql_query($query)) + return 0; + $query = ""; + } + } + } + return 1; + } else { + return 0; + } +} + +function random_name ($size){ + $temp = ""; + for ($a=0;$a< $size;$a++) + $temp = $temp. chr(rand(122,97)); + return $temp; +} + +function install_step4() { + $db_name = "pandora"; + $pandora_config = "include/config.php"; + + if ( (! isset($_POST["user"])) || (! isset($_POST["host"])) || (! isset($_POST["pass"])) ) { + $dbpassword = ""; + $dbuser = ""; + $dbhost = ""; + } else { + $dbpassword = $_POST["pass"]; + $dbuser = $_POST["user"]; + $dbhost = $_POST["host"]; + 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; + echo " +
+

Pandora FMS Console instalation wizard. Step #4 of 4

+
+
+

Creating database and default configuration file

+ "; + if (! mysql_connect ($dbhost,$dbuser,$dbpassword)) { + check_generic ( 0, "Connection with Database"); + } else { + check_generic ( 1, "Connection with Database"); + // Create schema + $step1 = mysql_query ("CREATE DATABASE $db_name"); + check_generic ($step1, "Creating database '$db_name'"); + if ($step1 == 1){ + $step2 = mysql_select_db($db_name); + check_generic ($step2, "Opening database '$db_name'"); + + $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); + $step5 = mysql_query ("GRANT ALL PRIVILEGES ON $db_name.* to pandora@localhost IDENTIFIED BY '".$random_password."'"); + mysql_query ("FLUSH PRIVILEGES"); + check_generic ($step5, "Established privileges for user pandora"); + + $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")); + + $config_new = ' + + + + '; + $step7 = fputs ($cfgout, $config_new); + $step7 = $step7 + fputs ($cfgout, $config_contents); + if ($step7 > 0) + $step7 = 1; + fclose ($cfgin); + fclose ($cfgout); + check_generic ($step7, "Created new config file at '".$pandora_config."'"); + } + } + if (($step7 + $step6 + $step5 + $step4 + $step3 + $step2 + $step1) == 7) { + $everything_ok = 1; + } + echo "
+
+ +
+
+ +
+ +
"; + if ($everything_ok == 1) { + echo ""; + } else { + echo " You get some problems. Installation is not completed. +

Please correct failures before trying again. All database schemes created in this step have been dropped.

"; + + if (mysql_error() != "") + echo "

ERROR: ". mysql_error()."

"; + + mysql_query ("DROP DATABASE $db_name"); + } + echo " +
+
+ +
"; +} + +function install_step5() { + echo " +
+

Pandora FMS console instalation wizard. Finished

+
+
+

Installation complete

+

You now must delete manually this installer for security, ('install.php') and rename your new config file '".$pandora_config."' to 'config.php' before trying to access to your Pandora FMS console. +

Don't forget to check http://pandora.sourceforge.net for updates. +

Click here to access to your Pandora FMS console

+
+
+
+
+
+
+
+
+ +
"; +} + +if (! isset($_GET["step"])){ + install_step1(); +} else { + $step = $_GET["step"]; + switch ($step) { + case 2: install_step2(); + break; + case 3: install_step3(); + break; + case 4: install_step4(); + break; + case 5: install_step5(); + break; + } +} + +?> \ No newline at end of file diff --git a/pandora_console/operation/active_console/index.php b/pandora_console/operation/active_console/index.php index d61e523d2c..f869983147 100644 --- a/pandora_console/operation/active_console/index.php +++ b/pandora_console/operation/active_console/index.php @@ -1,21 +1,23 @@