diff --git a/ecrire/inc/install.php b/ecrire/inc/install.php index 23ad0dfbf283497ff20911ae193eb399f52557b9..21bc099a0e6a8fe15363822a8fe4ad44ff233364 100644 --- a/ecrire/inc/install.php +++ b/ecrire/inc/install.php @@ -43,30 +43,28 @@ function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $lda . "spip_connect_db(" . "'$adr','$port','$login','$pass','$base'" . ",'$type', '$pref','$ldap');\n"; - } -function install_mode_appel($server_db, $tout=true) -{ - return ($server_db != 'mysql') ? '' - : (($tout ? test_rappel_nom_base_mysql($server_db) : '') - . test_sql_mode_mysql($server_db) ); -} +// Analyse si un fichier contient le resultat de la fonction install_connexion +// y compris ce qu'elle produisait dans les versions precedentes // http://doc.spip.org/@analyse_fichier_connection function analyse_fichier_connection($file) { - $s = @join('', file($file)); if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) { array_shift($regs); return $regs; - } else if (preg_match("#spip_connect_db\('([^']*)'\s*,\s*'([^']*)'\s*,\s*'([^']*)'\s*,\s*'([^']*)'\s*,\s*'([^']*)'\s*,\s*'([^']*)#", $s, $regs)) { - $regs[2] = $regs[1] . (!$regs[2] ? '' : ":$port_db;"); - array_shift($regs); - array_shift($regs); - return $regs; - } else spip_log("$file n'est pas un fichier de connexion"); + } else { + $arg = '\s*\'([^\']*)\'\s*,'; + if (preg_match("#spip_connect_db\($arg$arg$arg$arg\s*'([^']*)'\s*(?:,\s*'([^']*))?#", $s, $regs)) { + $regs[2] = $regs[1] . (!$regs[2] ? '' : ":$port_db;"); + array_shift($regs); + array_shift($regs); + return $regs; + } + } + spip_log("$file n'est pas un fichier de connexion"); return ''; } @@ -82,6 +80,13 @@ function bases_referencees($exclu='') } +function install_mode_appel($server_db, $tout=true) +{ + return ($server_db != 'mysql') ? '' + : (($tout ? test_rappel_nom_base_mysql($server_db) : '') + . test_sql_mode_mysql($server_db) ); +} + // // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-) // (sert a l'etape 1 de l'installation)