mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Qual: Amlioration des logs de l'install
This commit is contained in:
parent
a2010f3e7e
commit
b256cc1a15
|
|
@ -38,6 +38,9 @@ $langs->setDefaultLang($setuplang);
|
|||
$langs->load("admin");
|
||||
$langs->load("install");
|
||||
|
||||
dolibarr_install_syslog("etape1: Entering etape1.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans("ConfigurationFile"),"etape2");
|
||||
|
||||
$error = 0;
|
||||
|
|
@ -75,7 +78,7 @@ if ($_POST["action"] == "set")
|
|||
{
|
||||
if (! is_dir($main_dir))
|
||||
{
|
||||
dolibarr_install_syslog ("Repertoire '".$main_dir."' inexistant ou non accessible");
|
||||
dolibarr_install_syslog("etape1: Repertoire '".$main_dir."' inexistant ou non accessible");
|
||||
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ErrorDirDoesNotExists",$main_dir).'<br>';
|
||||
|
|
@ -162,7 +165,7 @@ if ($_POST["action"] == "set")
|
|||
// Creation des sous-répertoires main_data_dir
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog ("Le dossier '".$main_dir."' existe");
|
||||
dolibarr_install_syslog("etape1: Directory '".$main_dir."' exists");
|
||||
|
||||
// Répertoire des documents
|
||||
if (! is_dir($main_data_dir))
|
||||
|
|
@ -197,7 +200,7 @@ if ($_POST["action"] == "set")
|
|||
{
|
||||
if (is_dir($dir[$i]))
|
||||
{
|
||||
dolibarr_install_syslog ("Directory '".$dir[$i]."' exists");
|
||||
dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' exists");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -212,7 +215,7 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog("Directory '".$dir[$i]."' created");
|
||||
dolibarr_install_syslog("etape1: Directory '".$dir[$i]."' created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -242,7 +245,7 @@ if ($_POST["action"] == "set")
|
|||
*/
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
dolibarr_install_syslog("Creation de l'utilisateur: ".$dolibarr_main_db_user);
|
||||
dolibarr_install_syslog("etape1: Creation de l'utilisateur: ".$dolibarr_main_db_user);
|
||||
|
||||
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->pass;
|
||||
$databasefortest=$conf->db->name;
|
||||
|
|
@ -278,7 +281,7 @@ if ($_POST["action"] == "set")
|
|||
{
|
||||
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
dolibarr_install_syslog("User already exists");
|
||||
dolibarr_install_syslog("etape1: User already exists");
|
||||
print '<tr><td>';
|
||||
print $langs->trans("UserCreation").' : ';
|
||||
print $dolibarr_main_db_user;
|
||||
|
|
@ -287,7 +290,7 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog("Failed to create user");
|
||||
dolibarr_install_syslog("etape1: Failed to create user");
|
||||
print '<tr><td>';
|
||||
print $langs->trans("UserCreation").' : ';
|
||||
print $dolibarr_main_db_user;
|
||||
|
|
@ -326,7 +329,7 @@ if ($_POST["action"] == "set")
|
|||
*/
|
||||
if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
|
||||
{
|
||||
dolibarr_install_syslog ("Creation de la base : ".$dolibarr_main_db_name);
|
||||
dolibarr_install_syslog("etape1: Creation de la base : ".$dolibarr_main_db_name);
|
||||
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot);
|
||||
|
||||
|
|
@ -384,7 +387,7 @@ if ($_POST["action"] == "set")
|
|||
*/
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog("connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name);
|
||||
dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name);
|
||||
//print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." user=".$conf->db->user." name=".$conf->db->name;
|
||||
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
||||
|
|
@ -394,7 +397,7 @@ if ($_POST["action"] == "set")
|
|||
// si accès serveur ok et accès base ok, tout est ok, on ne va pas plus loin, on a même pas utilisé le compte root.
|
||||
if ($db->database_selected == 1)
|
||||
{
|
||||
dolibarr_install_syslog("la connexion au serveur par le user ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: la connexion au serveur par le user ".$conf->db->user." est reussie");
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ServerConnection")." : ";
|
||||
print $dolibarr_main_db_host;
|
||||
|
|
@ -402,7 +405,7 @@ if ($_POST["action"] == "set")
|
|||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
|
||||
dolibarr_install_syslog("la connexion a la base : ".$conf->db->name.",par le user : ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: la connexion a la base : ".$conf->db->name.",par le user : ".$conf->db->user." est reussie");
|
||||
print "<tr><td>";
|
||||
print $langs->trans("DatabaseConnection")." : ";
|
||||
print $dolibarr_main_db_name;
|
||||
|
|
@ -414,7 +417,7 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog("la connection au serveur par le user ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: la connection au serveur par le user ".$conf->db->user." est reussie");
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ServerConnection")." : ";
|
||||
print $dolibarr_main_db_host;
|
||||
|
|
@ -422,7 +425,7 @@ if ($_POST["action"] == "set")
|
|||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
|
||||
dolibarr_install_syslog("la connexion a la base ".$conf->db->name.",par le user ".$conf->db->user." a échoué");
|
||||
dolibarr_install_syslog("etape1: la connexion a la base ".$conf->db->name.",par le user ".$conf->db->user." a échoué");
|
||||
print "<tr><td>";
|
||||
print $langs->trans("DatabaseConnection")." : ";
|
||||
print $dolibarr_main_db_name;
|
||||
|
|
@ -441,7 +444,7 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog("la connection au serveur par le user ".$conf->db->user." est rate");
|
||||
dolibarr_install_syslog("etape1: la connection au serveur par le user ".$conf->db->user." est rate");
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ServerConnection")." : ";
|
||||
print $dolibarr_main_db_host;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ if ($dolibarr_main_db_type == "mysql") $choix=1;
|
|||
if ($dolibarr_main_db_type == "mysqli") $choix=1;
|
||||
if ($dolibarr_main_db_type == "pqsql") $choix=2;
|
||||
|
||||
dolibarr_install_syslog("etape2: Entering etape2.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans("CreateDatabaseObjects"),"etape4");
|
||||
|
|
@ -90,7 +91,7 @@ if ($_POST["action"] == "set")
|
|||
if($db->database_selected == 1)
|
||||
{
|
||||
|
||||
dolibarr_install_syslog("Connexion réussie à la base : $dolibarr_main_db_name");
|
||||
dolibarr_install_syslog("etape2: Connexion réussie à la base : $dolibarr_main_db_name");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ $langs->setDefaultLang($setuplang);
|
|||
$langs->load("admin");
|
||||
$langs->load("install");
|
||||
|
||||
dolibarr_install_syslog("etape4: Entering etape4.php page");
|
||||
|
||||
|
||||
|
||||
pHeader($langs->trans("AdminAccountCreation"),"etape5");
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ $langs->load("install");
|
|||
$success=0;
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering etape5.php page");
|
||||
dolibarr_install_syslog("etape5: Entering etape5.php page");
|
||||
|
||||
|
||||
if ($_POST["action"] == "set" || $_POST["action"] == "upgrade")
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ $langs->setDefaultLang($setuplang);
|
|||
|
||||
$langs->load("install");
|
||||
|
||||
dolibarr_install_syslog("licence: Entering licence.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans("License"),"fileconf");
|
||||
|
||||
|
|
|
|||
|
|
@ -58,232 +58,232 @@ if ($dolibarr_main_db_type == "mysqli") $choix=1;
|
|||
if ($dolibarr_main_db_type == "pgsql") $choix=2;
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering upgrade.php page");
|
||||
dolibarr_install_syslog("upgrade: Entering upgrade.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans("DatabaseMigration"),"upgrade2","upgrade");
|
||||
|
||||
if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
{
|
||||
print '<h2>'.$langs->trans("DatabaseMigration").'</h2>';
|
||||
print '<h2>'.$langs->trans("DatabaseMigration").'</h2>';
|
||||
|
||||
if (! $versionfrom && ! $versionto)
|
||||
{
|
||||
print '<div class="error">Parameter versionfrom or version to missing.</div>';
|
||||
exit;
|
||||
}
|
||||
if (! $versionfrom && ! $versionto)
|
||||
{
|
||||
print '<div class="error">Parameter versionfrom or version to missing.</div>';
|
||||
exit;
|
||||
}
|
||||
|
||||
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
|
||||
$error=0;
|
||||
|
||||
// on décode le mot de passe de la base si besoin
|
||||
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.inc.php");
|
||||
if ($dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass);
|
||||
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
|
||||
$error=0;
|
||||
|
||||
// on décode le mot de passe de la base si besoin
|
||||
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.inc.php");
|
||||
if ($dolibarr_main_db_encrypted_pass) $dolibarr_main_db_pass = dolibarr_decode($dolibarr_main_db_encrypted_pass);
|
||||
|
||||
$conf = new Conf();// on pourrait s'en passer
|
||||
$conf->db->type = $dolibarr_main_db_type;
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
$conf->db->user = $dolibarr_main_db_user;
|
||||
$conf->db->pass = $dolibarr_main_db_pass;
|
||||
$conf = new Conf();// on pourrait s'en passer
|
||||
$conf->db->type = $dolibarr_main_db_type;
|
||||
$conf->db->host = $dolibarr_main_db_host;
|
||||
$conf->db->name = $dolibarr_main_db_name;
|
||||
$conf->db->user = $dolibarr_main_db_user;
|
||||
$conf->db->pass = $dolibarr_main_db_pass;
|
||||
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
print "<tr><td nowrap>";
|
||||
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
|
||||
dolibarr_install_syslog($langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK"));
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
dolibarr_install_syslog($langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
||||
if ($db->connected == 1)
|
||||
{
|
||||
print "<tr><td nowrap>";
|
||||
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK"));
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
print "<tr><td nowrap>";
|
||||
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
|
||||
dolibarr_install_syslog("Database connection successfull : $dolibarr_main_db_name");
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
print "<tr><td nowrap>";
|
||||
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
|
||||
dolibarr_install_syslog("upgrade: Database connection successfull : $dolibarr_main_db_name");
|
||||
$ok=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
dolibarr_install_syslog($langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
|
||||
$ok=0;
|
||||
}
|
||||
}
|
||||
|
||||
// Affiche version
|
||||
if ($ok)
|
||||
{
|
||||
$version=$db->getVersion();
|
||||
$versionarray=$db->getVersionArray();
|
||||
print '<tr><td>'.$langs->trans("ServerVersion").'</td>';
|
||||
print '<td align="right">'.$version.'</td></tr>';
|
||||
dolibarr_install_syslog($langs->trans("ServerVersion")." : $version");
|
||||
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
*
|
||||
* Chargement fichiers dans migration
|
||||
*
|
||||
***************************************************************************************/
|
||||
if ($ok)
|
||||
{
|
||||
if ($choix==1) $dir = "../../mysql/migration/";
|
||||
else $dir = "../../pgsql/migration/";
|
||||
|
||||
$filelist=array();
|
||||
$i = 0;
|
||||
$ok = 0;
|
||||
$from='^'.$versionfrom;
|
||||
$to=$versionto.'\.sql$';
|
||||
|
||||
# Recupere list fichier
|
||||
$filesindir=array();
|
||||
$handle=opendir($dir);
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi('\.sql$',$file)) $filesindir[]=$file;
|
||||
}
|
||||
sort($filesindir);
|
||||
|
||||
# Determine les fichiers sql a passer
|
||||
foreach($filesindir as $file)
|
||||
{
|
||||
if (eregi($from,$file))
|
||||
{
|
||||
$filelist[]=$file;
|
||||
|
||||
// Mettre from avec valeur fin de $file
|
||||
}
|
||||
else if (eregi($to,$file))
|
||||
{
|
||||
$filelist[]=$file;
|
||||
}
|
||||
}
|
||||
|
||||
# Boucle sur chaque fichier
|
||||
foreach($filelist as $file)
|
||||
{
|
||||
print '<tr><td nowrap>';
|
||||
print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>';
|
||||
|
||||
$name = substr($file, 0, strlen($file) - 4);
|
||||
$buffer = '';
|
||||
$arraysql = Array();
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buf = fgets($fp, 4096);
|
||||
|
||||
// Cas special de lignes autorisees pour certaines versions uniquement
|
||||
if (eregi('^-- V([0-9\.]+)',$buf,$reg))
|
||||
{
|
||||
$versioncommande=split('\.',$reg[1]);
|
||||
//print var_dump($versioncommande);
|
||||
//print var_dump($versionarray);
|
||||
if (sizeof($versioncommande) && sizeof($versionarray)
|
||||
&& versioncompare($versioncommande,$versionarray) <= 0)
|
||||
{
|
||||
// Version qualified, delete SQL comments
|
||||
$buf=eregi_replace('^-- V([0-9\.]+)','',$buf);
|
||||
//print "Ligne $i qualifiée par version: ".$buf.'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
// Ajout ligne si non commentaire
|
||||
if (! eregi('^--',$buf)) $buffer .= $buf;
|
||||
|
||||
// print $buf.'<br>';
|
||||
|
||||
if (eregi(';',$buffer))
|
||||
{
|
||||
// Found new request
|
||||
$arraysql[$i]=trim($buffer);
|
||||
$i++;
|
||||
$buffer='';
|
||||
}
|
||||
}
|
||||
|
||||
if ($buffer) $arraysql[$i]=trim($buffer);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Loop on each request
|
||||
foreach($arraysql as $i=>$sql)
|
||||
{
|
||||
if ($sql)
|
||||
{
|
||||
// Ajout trace sur requete (eventuellement à commenter si beaucoup de requetes)
|
||||
print('<tr><td valign="top">'.$langs->trans("Request").' '.($i+1)." sql='".$sql."'</td></tr>\n");
|
||||
dolibarr_install_syslog($langs->trans("Request").' '.($i+1)." sql='".$sql);
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
// print '<td align="right">OK</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$errno=$db->errno();
|
||||
$okerror=array( 'DB_ERROR_TABLE_ALREADY_EXISTS',
|
||||
'DB_ERROR_COLUMN_ALREADY_EXISTS',
|
||||
'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
|
||||
'DB_ERROR_RECORD_ALREADY_EXISTS',
|
||||
'DB_ERROR_NOSUCHTABLE',
|
||||
'DB_ERROR_NOSUCHFIELD',
|
||||
'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
|
||||
'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante
|
||||
'DB_ERROR_CANT_DROP_PRIMARY_KEY',
|
||||
'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS'
|
||||
);
|
||||
if (in_array($errno,$okerror))
|
||||
{
|
||||
//print '<td align="right">'.$langs->trans("OK").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td valign="top" colspan="2">';
|
||||
print '<div class="error">'.$langs->trans("Error")." ".$db->errno().": ".$sql."<br>".$db->error()."</font></td>";
|
||||
print '</tr>';
|
||||
dolibarr_install_syslog($langs->trans("Request").' '.($i+1)." ".$langs->trans("Error")." ".$db->errno()." ".$sql."<br>".$db->error());
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right">'.$langs->trans("OK").'</td></tr>';
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right"><font class="error">'.$langs->trans("KO").'</font></td></tr>';
|
||||
$ok = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
|
||||
$ok=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
// Affiche version
|
||||
if ($ok)
|
||||
{
|
||||
$version=$db->getVersion();
|
||||
$versionarray=$db->getVersionArray();
|
||||
print '<tr><td>'.$langs->trans("ServerVersion").'</td>';
|
||||
print '<td align="right">'.$version.'</td></tr>';
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("ServerVersion")." : $version");
|
||||
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
|
||||
}
|
||||
|
||||
if ($db->connected) $db->close();
|
||||
|
||||
|
||||
/***************************************************************************************
|
||||
*
|
||||
* Chargement fichiers dans migration
|
||||
*
|
||||
***************************************************************************************/
|
||||
if ($ok)
|
||||
{
|
||||
if ($choix==1) $dir = "../../mysql/migration/";
|
||||
else $dir = "../../pgsql/migration/";
|
||||
|
||||
$filelist=array();
|
||||
$i = 0;
|
||||
$ok = 0;
|
||||
$from='^'.$versionfrom;
|
||||
$to=$versionto.'\.sql$';
|
||||
|
||||
# Recupere list fichier
|
||||
$filesindir=array();
|
||||
$handle=opendir($dir);
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (eregi('\.sql$',$file)) $filesindir[]=$file;
|
||||
}
|
||||
sort($filesindir);
|
||||
|
||||
# Determine les fichiers sql a passer
|
||||
foreach($filesindir as $file)
|
||||
{
|
||||
if (eregi($from,$file))
|
||||
{
|
||||
$filelist[]=$file;
|
||||
|
||||
// Mettre from avec valeur fin de $file
|
||||
}
|
||||
else if (eregi($to,$file))
|
||||
{
|
||||
$filelist[]=$file;
|
||||
}
|
||||
}
|
||||
|
||||
# Boucle sur chaque fichier
|
||||
foreach($filelist as $file)
|
||||
{
|
||||
print '<tr><td nowrap>';
|
||||
print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>';
|
||||
|
||||
$name = substr($file, 0, strlen($file) - 4);
|
||||
$buffer = '';
|
||||
$arraysql = Array();
|
||||
$fp = fopen($dir.$file,"r");
|
||||
if ($fp)
|
||||
{
|
||||
while (!feof ($fp))
|
||||
{
|
||||
$buf = fgets($fp, 4096);
|
||||
|
||||
// Cas special de lignes autorisees pour certaines versions uniquement
|
||||
if (eregi('^-- V([0-9\.]+)',$buf,$reg))
|
||||
{
|
||||
$versioncommande=split('\.',$reg[1]);
|
||||
//print var_dump($versioncommande);
|
||||
//print var_dump($versionarray);
|
||||
if (sizeof($versioncommande) && sizeof($versionarray)
|
||||
&& versioncompare($versioncommande,$versionarray) <= 0)
|
||||
{
|
||||
// Version qualified, delete SQL comments
|
||||
$buf=eregi_replace('^-- V([0-9\.]+)','',$buf);
|
||||
//print "Ligne $i qualifiée par version: ".$buf.'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
// Ajout ligne si non commentaire
|
||||
if (! eregi('^--',$buf)) $buffer .= $buf;
|
||||
|
||||
// print $buf.'<br>';
|
||||
|
||||
if (eregi(';',$buffer))
|
||||
{
|
||||
// Found new request
|
||||
$arraysql[$i]=trim($buffer);
|
||||
$i++;
|
||||
$buffer='';
|
||||
}
|
||||
}
|
||||
|
||||
if ($buffer) $arraysql[$i]=trim($buffer);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// Loop on each request
|
||||
foreach($arraysql as $i=>$sql)
|
||||
{
|
||||
if ($sql)
|
||||
{
|
||||
// Ajout trace sur requete (eventuellement à commenter si beaucoup de requetes)
|
||||
print('<tr><td valign="top">'.$langs->trans("Request").' '.($i+1)." sql='".$sql."'</td></tr>\n");
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("Request").' '.($i+1)." sql='".$sql);
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
// print '<td align="right">OK</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$errno=$db->errno();
|
||||
$okerror=array( 'DB_ERROR_TABLE_ALREADY_EXISTS',
|
||||
'DB_ERROR_COLUMN_ALREADY_EXISTS',
|
||||
'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
|
||||
'DB_ERROR_RECORD_ALREADY_EXISTS',
|
||||
'DB_ERROR_NOSUCHTABLE',
|
||||
'DB_ERROR_NOSUCHFIELD',
|
||||
'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
|
||||
'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante
|
||||
'DB_ERROR_CANT_DROP_PRIMARY_KEY',
|
||||
'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS'
|
||||
);
|
||||
if (in_array($errno,$okerror))
|
||||
{
|
||||
//print '<td align="right">'.$langs->trans("OK").'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td valign="top" colspan="2">';
|
||||
print '<div class="error">'.$langs->trans("Error")." ".$db->errno().": ".$sql."<br>".$db->error()."</font></td>";
|
||||
print '</tr>';
|
||||
dolibarr_install_syslog("upgrade: ".$langs->trans("Request").' '.($i+1)." ".$langs->trans("Error")." ".$db->errno()." ".$sql."<br>".$db->error());
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right">'.$langs->trans("OK").'</td></tr>';
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right"><font class="error">'.$langs->trans("KO").'</font></td></tr>';
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($db->connected) $db->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ if ($dolibarr_main_db_type == 'mysqli') $choix=1;
|
|||
if ($dolibarr_main_db_type == 'pgsql') $choix=2;
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering upgrade2.php page");
|
||||
dolibarr_install_syslog("upgrade2: Entering upgrade2.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans('DataMigration'),'etape5','upgrade');
|
||||
|
|
@ -96,7 +96,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
|
|||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
dolibarr_install_syslog('Database connection successfull : '.$dolibarr_main_db_name);
|
||||
dolibarr_install_syslog('upgrade2: Database connection successfull : '.$dolibarr_main_db_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -627,7 +627,7 @@ function migrate_price_facture($db,$langs,$conf)
|
|||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for invoice");
|
||||
dolibarr_install_syslog("upgrade2: Upgrade data for invoice");
|
||||
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
|
|
@ -671,7 +671,7 @@ function migrate_price_facture($db,$langs,$conf)
|
|||
$facligne->total_tva = $total_tva;
|
||||
$facligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
dolibarr_install_syslog("upgrade2: Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
$facligne->update_total();
|
||||
|
||||
|
|
@ -733,7 +733,7 @@ function migrate_price_propal($db,$langs,$conf)
|
|||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for propal");
|
||||
dolibarr_install_syslog("upgrade2: Upgrade data for propal");
|
||||
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
|
|
@ -777,7 +777,7 @@ function migrate_price_propal($db,$langs,$conf)
|
|||
$propalligne->total_tva = $total_tva;
|
||||
$propalligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: propalid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
dolibarr_install_syslog("upgrade2: Line $rowid: propalid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
$propalligne->update_total($rowid);
|
||||
|
||||
|
|
@ -839,7 +839,7 @@ function migrate_price_commande($db,$langs,$conf)
|
|||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for order");
|
||||
dolibarr_install_syslog("upgrade2: Upgrade data for order");
|
||||
|
||||
print '<tr><td colspan="4">';
|
||||
|
||||
|
|
@ -883,7 +883,7 @@ function migrate_price_commande($db,$langs,$conf)
|
|||
$commandeligne->total_tva = $total_tva;
|
||||
$commandeligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: commandeid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
dolibarr_install_syslog("upgrade2: Line $rowid: commandeid=$obj->rowid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
$commandeligne->update_total($rowid);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user