--- trunk/server/ocsreports/install.php 2008/03/04 17:07:55 1108 +++ trunk/server/ocsreports/install.php 2008/10/16 15:56:16 1423 @@ -94,15 +94,15 @@ else $instOk = true; } -if( ! $instOk ) { +if( $hnd = @fopen("dbconfig.inc.php", "r") ) { + fclose($hnd); + require("dbconfig.inc.php"); + $valNme = $_SESSION["COMPTE_BASE"]; + $valPass = $_SESSION["PSWD_BASE"]; + $valServ = $_SESSION["SERVEUR_SQL"]; +} - if( $hnd = @fopen("dbconfig.inc.php", "r") ) { - fclose($hnd); - require("dbconfig.inc.php"); - $valNme = $_SESSION["COMPTE_BASE"]; - $valPass = $_SESSION["PSWD_BASE"]; - $valServ = $_SESSION["SERVEUR_SQL"]; - } +if( ! $instOk ) { echo "
@@ -162,7 +162,8 @@ } if($_POST["fin"]=="fin") { - if(!@mysql_connect($_POST["host"],"ocs","ocs")) { + // Configuration done, so try with account from config file + if(!@mysql_connect($valServ,$valNme,$valPass)) { if(mysql_errno()==0) { echo "
ERROR: MySql authentication problem. You must add the 'old-passwords' in your mysql configuration file (my.ini). Then restart mysql, and relaunch install.php
"; die(); @@ -185,10 +186,7 @@ die(); } -fwrite($ch,""); -fclose($ch); - -echo "
MySql config file successfully written
"; +$keepuser=false; $db_file = "files/ocsbase.sql"; if($dbf_handle = @fopen($db_file, "r")) { @@ -201,7 +199,12 @@ foreach ( explode(";", "$sql_query") as $sql_line) { $li++; if(!mysql_query($sql_line)) { - if( mysql_errno()==1062 || mysql_errno()==1061 || mysql_errno()==1044 || mysql_errno()==1065 || mysql_errno()==1060 || mysql_errno()==1054 || mysql_errno()==1091 || mysql_errno()==1061) + if (mysql_errno()==1044 && strpos($sql_line, "GRANT ALL")!==false) { + // Provided user not MySQL Administror + $keepuser=true; + continue; + } + if( mysql_errno()==1062 || mysql_errno()==1061 || mysql_errno()==1065 || mysql_errno()==1060 || mysql_errno()==1054 || mysql_errno()==1091 || mysql_errno()==1061) continue; if( mysql_errno()==1071 ) { @@ -230,6 +233,19 @@ die(); } +if ($keepuser) { + // Provided user not MySQL Administror + // Keep the account used for migration + fwrite($ch,""); + fclose($ch); + echo "
MySql config file successfully written (using ".$_POST["name"]." account)
"; +} else { + // Use account created during installation + fwrite($ch,""); + fclose($ch); + echo "
MySql config file successfully written (using new ocs account)
"; +} + if($dejaLance>0) echo "
Existing database updated
";