2012-10-25 Miguel de Dios <miguel.dedios@artica.es>

* pandoradb_data.sql: fixed the lost fields in the table "tgrupo"
	when install.
	 
	* install.php: fixed the installation on DBs with names as for
	example "name1.name2".
	
	Fixes: #3573766




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7092 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-10-25 14:39:04 +00:00
parent 34eb90e1dc
commit 9667426b1a
2 changed files with 84 additions and 87 deletions

View File

@ -2,7 +2,7 @@
// Pandora FMS - http://pandorafms.com // Pandora FMS - http://pandorafms.com
// ================================================== // ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas // Copyright (c) 2005-2012 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list // Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or // This program is free software; you can redistribute it and/or
@ -31,46 +31,71 @@
<link rel="stylesheet" href="include/styles/install.css" type="text/css"> <link rel="stylesheet" href="include/styles/install.css" type="text/css">
</head> </head>
<script type="text/javascript"> <script type="text/javascript">
options_text = new Array('An existing Database','A new Database'); options_text = new Array('An existing Database','A new Database');
options_values = new Array('db_exist','db_new'); options_values = new Array('db_exist','db_new');
function ChangeDBDrop(causer) { function ChangeDBDrop(causer) {
if (causer.value != 'db_exist') { if (causer.value != 'db_exist') {
window.document.step2_form.drop.checked = 0; window.document.step2_form.drop.checked = 0;
window.document.step2_form.drop.disabled = 1; window.document.step2_form.drop.disabled = 1;
}
else {
window.document.step2_form.drop.disabled = 0;
}
} }
else { function ChangeDBAction(causer) {
window.document.step2_form.drop.disabled = 0; var i = 0;
if (causer.value == 'oracle') {
window.document.step2_form.db_action.length = 1;
}
else {
window.document.step2_form.db_action.length = 2;
}
while (i < window.document.step2_form.db_action.length) {
window.document.step2_form.db_action.options[i].value = options_values[i];
window.document.step2_form.db_action.options[i].text = options_text[i];
i++;
}
window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1;
ChangeDBDrop(window.document.step2_form.db_action);
} }
}
function ChangeDBAction(causer) {
var i = 0;
if (causer.value == 'oracle') {
window.document.step2_form.db_action.length = 1;
}
else {
window.document.step2_form.db_action.length = 2;
}
while (i < window.document.step2_form.db_action.length) {
window.document.step2_form.db_action.options[i].value = options_values[i];
window.document.step2_form.db_action.options[i].text = options_text[i];
i++;
}
window.document.step2_form.db_action.options[window.document.step2_form.db_action.length-1].selected=1;
ChangeDBDrop(window.document.step2_form.db_action);
}
</script> </script>
<body> <body>
<div style='height: 10px'> <div style='height: 10px'>
<?php
$version = '5.0dev';
$build = '120621';
$banner = "v$version Build $build";
error_reporting(0);
// ---------------
// Main page code
// ---------------
if (! isset($_GET["step"])) {
install_step1();
}
else {
$step = $_GET["step"];
switch ($step) {
case 11: install_step1_licence();
break;
case 2: install_step2();
break;
case 3: install_step3();
break;
case 4: install_step4();
break;
case 5: install_step5();
break;
}
}
?>
</div>
</body>
</html>
<?php <?php
$version = '5.0dev';
$build = '120621';
$banner = "v$version Build $build";
error_reporting(0);
function check_extension ( $ext, $label ) { function check_extension ( $ext, $label ) {
echo "<tr><td>"; echo "<tr><td>";
echo "<span class='arr'> $label </span>"; echo "<span class='arr'> $label </span>";
@ -184,11 +209,11 @@ function parse_mysql_dump($url) {
$file_content = file($url); $file_content = file($url);
$query = ""; $query = "";
foreach($file_content as $sql_line) { foreach($file_content as $sql_line) {
if(trim($sql_line) != "" && strpos($sql_line, "--") === false) { if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
$query .= $sql_line; $query .= $sql_line;
if(preg_match("/;[\040]*\$/", $sql_line)) { if(preg_match("/;[\040]*\$/", $sql_line)) {
if (!$result = mysql_query($query)) { if (!$result = mysql_query($query)) {
echo mysql_error(); //Uncomment for debug echo mysql_error(); //Uncomment for debug
echo "<i><br>$query<br></i>"; echo "<i><br>$query<br></i>";
return 0; return 0;
} }
@ -208,7 +233,7 @@ function parse_postgresql_dump($connection, $url, $debug = false) {
$query = ""; $query = "";
foreach($file_content as $sql_line) { foreach ($file_content as $sql_line) {
$clean_line = trim($sql_line); $clean_line = trim($sql_line);
$comment = preg_match("/^(\s|\t)*--.*$/", $clean_line); $comment = preg_match("/^(\s|\t)*--.*$/", $clean_line);
if ($comment) { if ($comment) {
@ -258,7 +283,7 @@ function parse_oracle_dump($connection, $url, $debug = false) {
$query = ""; $query = "";
$plsql_block = false; $plsql_block = false;
foreach($file_content as $sql_line) { foreach ($file_content as $sql_line) {
$clean_line = trim($sql_line); $clean_line = trim($sql_line);
$comment = preg_match("/^(\s|\t)*--.*$/", $clean_line); $comment = preg_match("/^(\s|\t)*--.*$/", $clean_line);
if ($comment) { if ($comment) {
@ -361,7 +386,6 @@ function print_logo_status ($step, $step_total) {
</div>"; </div>";
} }
function install_step1() { function install_step1() {
global $banner; global $banner;
@ -693,12 +717,12 @@ function install_step4() {
// Drop database if needed and don't want to install over an existing DB // Drop database if needed and don't want to install over an existing DB
if ($dbdrop == 1) { if ($dbdrop == 1) {
mysql_query ("DROP DATABASE IF EXISTS $dbname"); mysql_query ("DROP DATABASE IF EXISTS `$dbname`");
} }
// Create schema // Create schema
if ($dbaction == 'db_new' || $dbdrop == 1) { if ($dbaction == 'db_new' || $dbdrop == 1) {
$step1 = mysql_query ("CREATE DATABASE $dbname"); $step1 = mysql_query ("CREATE DATABASE `$dbname`");
check_generic ($step1, "Creating database '$dbname'"); check_generic ($step1, "Creating database '$dbname'");
} }
else { else {
@ -718,8 +742,8 @@ function install_step4() {
$host = 'localhost'; $host = 'localhost';
if ($dbhost != 'localhost') if ($dbhost != 'localhost')
$host = $_SERVER['SERVER_ADDR']; $host = $_SERVER['SERVER_ADDR'];
$step5 = mysql_query ("GRANT ALL PRIVILEGES ON $dbname.* to pandora@$host $step5 = mysql_query ("GRANT ALL PRIVILEGES ON `$dbname`.* to pandora@$host
IDENTIFIED BY '".$random_password."'"); IDENTIFIED BY '".$random_password."'");
mysql_query ("FLUSH PRIVILEGES"); mysql_query ("FLUSH PRIVILEGES");
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>"); 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>");
@ -784,7 +808,7 @@ function install_step4() {
oracle_drop_all_objects($connection); oracle_drop_all_objects($connection);
} }
$step1 = parse_oracle_dump($connection, "pandoradb.oracle.sql"); $step1 = parse_oracle_dump($connection, "pandoradb.oracle.sql");
check_generic($step1, "Creating schema"); check_generic($step1, "Creating schema");
@ -1120,31 +1144,4 @@ function install_step5() {
</div> </div>
</div>"; </div>";
} }
// ---------------
// Main page code
// ---------------
if (! isset($_GET["step"])) {
install_step1();
}
else {
$step = $_GET["step"];
switch ($step) {
case 11: install_step1_licence();
break;
case 2: install_step2();
break;
case 3: install_step3();
break;
case 4: install_step4();
break;
case 5: install_step5();
break;
}
}
?> ?>
</body>
</html>

View File

@ -132,7 +132,7 @@ UNLOCK TABLES;
-- --
LOCK TABLES `tgrupo` WRITE; LOCK TABLES `tgrupo` WRITE;
INSERT INTO `tgrupo` VALUES INSERT INTO `tgrupo` (`id_grupo`, `nombre`, `icon`, `parent`, `propagate`, `disabled`, `custom_id`, `id_skin`, `other`) VALUES
(2,'Servers','server_database',0,0,0,'',1,''), (2,'Servers','server_database',0,0,0,'',1,''),
(4,'Firewalls','firewall',0,0,0,'',1,''), (4,'Firewalls','firewall',0,0,0,'',1,''),
(8,'Databases','database_gear',0,0,0,'',1,''), (8,'Databases','database_gear',0,0,0,'',1,''),