This commit is contained in:
eldy 2011-09-29 22:21:57 +02:00
parent 1122903694
commit 8ff32f8ada
11 changed files with 4285 additions and 4301 deletions

View File

@ -350,7 +350,6 @@ else
print '<td align="center">';
if ($allowinstall)
{
//print '<a href="licence.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>'; // To restore licence page
print '<a href="fileconf.php?selectlang='.$setuplang.'">'.$langs->trans("Start").'</a>';
}
else

File diff suppressed because it is too large Load Diff

View File

@ -74,462 +74,462 @@ if (! is_writable($conffile))
if ($action == "set")
{
print '<h3>'.$langs->trans("Database").'</h3>';
print '<h3>'.$langs->trans("Database").'</h3>';
print '<table cellspacing="0" cellpadding="4" border="0" width="100%">';
$error=0;
print '<table cellspacing="0" cellpadding="4" border="0" width="100%">';
$error=0;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
{
print "<tr><td>";
print $langs->trans("ServerConnection")." : ".$conf->db->host."</td><td>".$langs->trans("OK")."</td></tr>";
$ok = 1 ;
}
else
{
print "<tr><td>Failed to connect to server : ".$conf->db->host."</td><td>".$langs->trans("Error")."</td></tr>";
}
{
print "<tr><td>";
print $langs->trans("ServerConnection")." : ".$conf->db->host."</td><td>".$langs->trans("OK")."</td></tr>";
$ok = 1 ;
}
else
{
print "<tr><td>Failed to connect to server : ".$conf->db->host."</td><td>".$langs->trans("Error")."</td></tr>";
}
if ($ok)
{
if($db->database_selected == 1)
{
dolibarr_install_syslog("etape2: Connexion successful to database : ".$conf->db->name);
}
else
{
if ($ok)
{
if($db->database_selected == 1)
{
dolibarr_install_syslog("etape2: Connexion successful to database : ".$conf->db->name);
}
else
{
dolibarr_install_syslog("etape2: Connexion failed to database : ".$conf->db->name);
print "<tr><td>Failed to select database ".$conf->db->name."</td><td>".$langs->trans("Error")."</td></tr>";
$ok = 0 ;
}
}
print "<tr><td>Failed to select database ".$conf->db->name."</td><td>".$langs->trans("Error")."</td></tr>";
$ok = 0 ;
}
}
// Affiche version
if ($ok)
{
$version=$db->getVersion();
$versionarray=$db->getVersionArray();
print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
print '<td>'.$version.'</td></tr>';
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
// Affiche version
if ($ok)
{
$version=$db->getVersion();
$versionarray=$db->getVersionArray();
print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
print '<td>'.$version.'</td></tr>';
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
print '<tr><td>'.$langs->trans("DatabaseName").'</td>';
print '<td>'.$db->database_name.'</td></tr>';
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
}
}
$requestnb=0;
$requestnb=0;
// To disable some code
$createtables=1;
$createkeys=1;
$createfunctions=1;
$createdata=1;
// To disable some code
$createtables=1;
$createkeys=1;
$createfunctions=1;
$createdata=1;
// To say sql requests are escaped for mysql so we need to unescape them
$db->unescapeslashquot=1;
// To say sql requests are escaped for mysql so we need to unescape them
$db->unescapeslashquot=1;
/**************************************************************************************
*
* Chargement fichiers tables/*.sql (non *.key.sql)
* A faire avant les fichiers *.key.sql
*
***************************************************************************************/
if ($ok && $createtables)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
/**************************************************************************************
*
* Chargement fichiers tables/*.sql (non *.key.sql)
* A faire avant les fichiers *.key.sql
*
***************************************************************************************/
if ($ok && $createtables)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
$ok = 0;
$handle=opendir($dir);
dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
$ok = 0;
$handle=opendir($dir);
dolibarr_install_syslog("Open tables directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
closedir($handle);
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && ! preg_match('/\.key\.sql$/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
closedir($handle);
}
// Sort list of sql files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
$buffer = '';
$fp = fopen($dir.$file,"r");
if ($fp)
{
while (!feof($fp))
{
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
$buf=preg_replace('/--(.+)*/','',$buf);
$buffer .= $buf;
}
}
fclose($fp);
// Sort list of sql files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
$buffer = '';
$fp = fopen($dir.$file,"r");
if ($fp)
{
while (!feof($fp))
{
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
$buf=preg_replace('/--(.+)*/','',$buf);
$buffer .= $buf;
}
}
fclose($fp);
$buffer=trim($buffer);
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb
{
$buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
}
$buffer=trim($buffer);
if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb
{
$buffer=preg_replace('/type=innodb/i','ENGINE=innodb',$buffer);
}
//print "<tr><td>Creation de la table $name/td>";
$requestnb++;
if ($conf->file->character_set_client == "UTF-8")
{
$buffer=utf8_encode($buffer);
}
//print "<tr><td>Creation de la table $name/td>";
$requestnb++;
if ($conf->file->character_set_client == "UTF-8")
{
$buffer=utf8_encode($buffer);
}
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
// print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
{
//print "<td>Deja existante</td></tr>";
}
else
{
print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
print "\n</td>";
print "<td>".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()."</td></tr>";
$error++;
}
}
}
else
{
print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
print "</td>";
print "<td>".$langs->trans("Error")." Failed to open file ".$dir.$file."</td></tr>";
$error++;
dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
}
}
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
// print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
{
//print "<td>Deja existante</td></tr>";
}
else
{
print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
print "\n</td>";
print "<td>".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()."</td></tr>";
$error++;
}
}
}
else
{
print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey",$name);
print "</td>";
print "<td>".$langs->trans("Error")." Failed to open file ".$dir.$file."</td></tr>";
$error++;
dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
}
}
if ($tablefound)
{
if ($error == 0)
{
print '<tr><td>';
print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td>'.$langs->trans("OK").'</td></tr>';
$ok = 1;
}
}
else
{
print "<tr><td>".$langs->trans("ErrorFailedToFindSomeFiles",$dir)."</td><td>".$langs->trans("Error")."</td></tr>";
dolibarr_install_syslog("Failed to find files to create database in directory ".$dir,LOG_ERR);
}
}
if ($tablefound)
{
if ($error == 0)
{
print '<tr><td>';
print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td>'.$langs->trans("OK").'</td></tr>';
$ok = 1;
}
}
else
{
print "<tr><td>".$langs->trans("ErrorFailedToFindSomeFiles",$dir)."</td><td>".$langs->trans("Error")."</td></tr>";
dolibarr_install_syslog("Failed to find files to create database in directory ".$dir,LOG_ERR);
}
}
/***************************************************************************************
*
* Chargement fichiers tables/*.key.sql
* A faire apres les fichiers *.sql
*
***************************************************************************************/
if ($ok && $createkeys)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
/***************************************************************************************
*
* Chargement fichiers tables/*.key.sql
* A faire apres les fichiers *.sql
*
***************************************************************************************/
if ($ok && $createkeys)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/tables/";
$okkeys = 0;
$handle=opendir($dir);
dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
$okkeys = 0;
$handle=opendir($dir);
dolibarr_install_syslog("Open keys directory ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
closedir($handle);
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file) && preg_match('/\.key\.sql$/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
closedir($handle);
}
// Sort list of sql files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
//print "<tr><td>Creation de la table $name</td>";
$buffer = '';
$fp = fopen($dir.$file,"r");
if ($fp)
{
while (!feof($fp))
{
$buf = fgets($fp, 4096);
// Sort list of sql files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
//print "<tr><td>Creation de la table $name</td>";
$buffer = '';
$fp = fopen($dir.$file,"r");
if ($fp)
{
while (!feof($fp))
{
$buf = fgets($fp, 4096);
// Cas special de lignes autorisees pour certaines versions uniquement
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
{
$versioncommande=explode('.',$reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0)
{
// Version qualified, delete SQL comments
$buf=preg_replace('/^--\sV([0-9\.]+)/i','',$buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
}
}
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i',$buf,$reg))
{
$versioncommande=explode('.',$reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0)
{
// Version qualified, delete SQL comments
$buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i','',$buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
}
}
// Cas special de lignes autorisees pour certaines versions uniquement
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i',$buf,$reg))
{
$versioncommande=explode('.',$reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0)
{
// Version qualified, delete SQL comments
$buf=preg_replace('/^--\sV([0-9\.]+)/i','',$buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
}
}
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i',$buf,$reg))
{
$versioncommande=explode('.',$reg[1]);
//print var_dump($versioncommande);
//print var_dump($versionarray);
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0)
{
// Version qualified, delete SQL comments
$buf=preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i','',$buf);
//print "Ligne $i qualifiee par version: ".$buf.'<br>';
}
}
// Ajout ligne si non commentaire
if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
}
fclose($fp);
// Ajout ligne si non commentaire
if (! preg_match('/^--/i',$buf)) $buffer .= $buf;
}
fclose($fp);
// Si plusieurs requetes, on boucle sur chaque
$listesql=explode(';',$buffer);
foreach ($listesql as $req)
{
$buffer=trim($req);
if ($buffer)
{
//print "<tr><td>Creation des cles et index de la table $name: '$buffer'</td>";
$requestnb++;
if ($conf->file->character_set_client == "UTF-8")
{
$buffer=utf8_encode($buffer);
}
// Si plusieurs requetes, on boucle sur chaque
$listesql=explode(';',$buffer);
foreach ($listesql as $req)
{
$buffer=trim($req);
if ($buffer)
{
//print "<tr><td>Creation des cles et index de la table $name: '$buffer'</td>";
$requestnb++;
if ($conf->file->character_set_client == "UTF-8")
{
$buffer=utf8_encode($buffer);
}
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
//print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
$db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
preg_match('/duplicate key name/i',$db->error()))
{
//print "<td>Deja existante</td></tr>";
$key_exists = 1;
}
else
{
print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
print "\n</td>";
print "<td>".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()."</td></tr>";
$error++;
}
}
}
}
}
else
{
print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
print "</td>";
print "<td>".$langs->trans("Error")." Failed to open file ".$dir.$file."</td></tr>";
$error++;
dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
}
}
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
//print "<td>OK requete ==== $buffer</td></tr>";
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
$db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
$db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
preg_match('/duplicate key name/i',$db->error()))
{
//print "<td>Deja existante</td></tr>";
$key_exists = 1;
}
else
{
print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
print "\n</td>";
print "<td>".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()."</td></tr>";
$error++;
}
}
}
}
}
else
{
print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
print "</td>";
print "<td>".$langs->trans("Error")." Failed to open file ".$dir.$file."</td></tr>";
$error++;
dolibarr_install_syslog("Failed to open file ".$dir.$file,LOG_ERR);
}
}
if ($tablefound && $error == 0)
{
print '<tr><td>';
print $langs->trans("OtherKeysCreation").'</td><td>'.$langs->trans("OK").'</td></tr>';
$okkeys = 1;
}
}
if ($tablefound && $error == 0)
{
print '<tr><td>';
print $langs->trans("OtherKeysCreation").'</td><td>'.$langs->trans("OK").'</td></tr>';
$okkeys = 1;
}
}
/***************************************************************************************
*
* Chargement fichier functions.sql
*
***************************************************************************************/
if ($ok && $createfunctions)
{
// For this file, we use directory according to database type
if ($choix==1) $dir = "mysql/functions/";
elseif ($choix==2) $dir = "pgsql/functions/";
elseif ($choix==3) $dir = "mssql/functions/";
/***************************************************************************************
*
* Chargement fichier functions.sql
*
***************************************************************************************/
if ($ok && $createfunctions)
{
// For this file, we use directory according to database type
if ($choix==1) $dir = "mysql/functions/";
elseif ($choix==2) $dir = "pgsql/functions/";
elseif ($choix==3) $dir = "mssql/functions/";
// Creation donnees
$file = "functions.sql";
if (file_exists($dir.$file))
{
$fp = fopen($dir.$file,"r");
dolibarr_install_syslog("Open function file ".$dir.$file." handle=".$fp,LOG_DEBUG);
if ($fp)
{
$buffer='';
while (!feof($fp))
{
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
$buffer .= $buf."§";
}
}
fclose($fp);
}
//$buffer=preg_replace('/;\';/',";'§",$buffer);
// Creation donnees
$file = "functions.sql";
if (file_exists($dir.$file))
{
$fp = fopen($dir.$file,"r");
dolibarr_install_syslog("Open function file ".$dir.$file." handle=".$fp,LOG_DEBUG);
if ($fp)
{
$buffer='';
while (!feof($fp))
{
$buf = fgets($fp, 4096);
if (substr($buf, 0, 2) <> '--')
{
$buffer .= $buf."§";
}
}
fclose($fp);
}
//$buffer=preg_replace('/;\';/',";'§",$buffer);
// If several requests, we loop on each of them
$listesql=explode('§',$buffer);
foreach ($listesql as $buffer)
{
$buffer=trim($buffer);
if ($buffer)
{
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
print "<!-- Insert line : ".$buffer."<br>-->\n";
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
$ok = 1;
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
|| $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
{
//print "Insert line : ".$buffer."<br>\n";
}
else
{
$ok = 0;
// If several requests, we loop on each of them
$listesql=explode('§',$buffer);
foreach ($listesql as $buffer)
{
$buffer=trim($buffer);
if ($buffer)
{
dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
print "<!-- Insert line : ".$buffer."<br>-->\n";
$resql=$db->query($buffer,0,'dml');
if ($resql)
{
$ok = 1;
$db->free($resql);
}
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
|| $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS')
{
//print "Insert line : ".$buffer."<br>\n";
}
else
{
$ok = 0;
print "<tr><td>".$langs->trans("FunctionsCreation");
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
print "\n</td>";
print "<td>".$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error()."</td></tr>";
$error++;
}
}
}
}
}
}
}
}
print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
if ($ok)
{
print "<td>".$langs->trans("OK")."</td></tr>";
}
else
{
print "<td>".$langs->trans("Error")."</td></tr>";
$ok = 1 ;
}
print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
if ($ok)
{
print "<td>".$langs->trans("OK")."</td></tr>";
}
else
{
print "<td>".$langs->trans("Error")."</td></tr>";
$ok = 1 ;
}
}
}
}
}
/***************************************************************************************
*
* Load files data/*.sql
*
***************************************************************************************/
if ($ok && $createdata)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/data/";
/***************************************************************************************
*
* Load files data/*.sql
*
***************************************************************************************/
if ($ok && $createdata)
{
// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
$dir = "mysql/data/";
// Insert data
$handle=opendir($dir);
dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
// Insert data
$handle=opendir($dir);
dolibarr_install_syslog("Open directory data ".$dir." handle=".$handle,LOG_DEBUG);
$tablefound = 0;
$tabledata=array();
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
{
$tablefound++;
$tabledata[]=$file;
}
}
closedir($handle);
}
// Sort list of data files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
$fp = fopen($dir.$file,"r");
dolibarr_install_syslog("Open data file ".$dir.$file." handle=".$fp,LOG_DEBUG);
if ($fp)
{
$arrayofrequests=array();
// Sort list of data files on alphabetical order (load order is important)
sort($tabledata);
foreach($tabledata as $file)
{
$name = substr($file, 0, dol_strlen($file) - 4);
$fp = fopen($dir.$file,"r");
dolibarr_install_syslog("Open data file ".$dir.$file." handle=".$fp,LOG_DEBUG);
if ($fp)
{
$arrayofrequests=array();
$linefound=0;
$linegroup=0;
$sizeofgroup=1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
// Load all requests
while (!feof($fp))
{
$buffer = fgets($fp, 4096);
$buffer = trim($buffer);
if ($buffer)
{
if (substr($buffer, 0, 2) == '--') continue;
// Load all requests
while (!feof($fp))
{
$buffer = fgets($fp, 4096);
$buffer = trim($buffer);
if ($buffer)
{
if (substr($buffer, 0, 2) == '--') continue;
if ($linefound && ($linefound % $sizeofgroup) == 0)
{
if ($linefound && ($linefound % $sizeofgroup) == 0)
{
$linegroup++;
}
}
if (empty($arrayofrequests[$linegroup])) $arrayofrequests[$linegroup]=$buffer;
else $arrayofrequests[$linegroup].=" ".$buffer;
$linefound++;
}
$linefound++;
}
}
fclose($fp);
@ -538,43 +538,43 @@ if ($action == "set")
// We loop on each requests
foreach($arrayofrequests as $buffer)
{
//dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer);
if ($resql)
{
$ok = 1;
//$db->free($resql); // Not required as request we launch here does not return memory needs.
}
else
{
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
//print "<tr><td>Insertion ligne : $buffer</td><td>";
}
else
{
$ok = 0;
print $langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."<br>";
}
}
}
}
}
//dolibarr_install_syslog("Request: ".$buffer,LOG_DEBUG);
$resql=$db->query($buffer);
if ($resql)
{
$ok = 1;
//$db->free($resql); // Not required as request we launch here does not return memory needs.
}
else
{
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
//print "<tr><td>Insertion ligne : $buffer</td><td>";
}
else
{
$ok = 0;
print $langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."<br>";
}
}
}
}
}
print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
if ($ok)
{
print "<td>".$langs->trans("OK")."</td></tr>";
}
else
{
print "<td>".$langs->trans("Error")."</td></tr>";
$ok = 1 ;
}
}
print '</table>';
print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
if ($ok)
{
print "<td>".$langs->trans("OK")."</td></tr>";
}
else
{
print "<td>".$langs->trans("Error")."</td></tr>";
$ok = 1 ;
}
}
print '</table>';
$db->close();
$db->close();
}
dolibarr_install_syslog("--- install/etape2.php end", LOG_INFO);

View File

@ -73,36 +73,36 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->ok == 1)
{
print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>';
print '<input name="login" value="'.(! empty($_GET["login"])?$_GET["login"]:$force_install_dolibarrlogin).'"></td></tr>';
print '<tr><td>'.$langs->trans("Password").' :</td><td>';
print '<input type="password" name="pass"></td></tr>';
print '<tr><td>'.$langs->trans("PasswordAgain").' :</td><td>';
print '<input type="password" name="pass_verif"></td></tr>';
print '</table>';
print '<tr><td>'.$langs->trans("DolibarrAdminLogin").' :</td><td>';
print '<input name="login" value="'.(! empty($_GET["login"])?$_GET["login"]:$force_install_dolibarrlogin).'"></td></tr>';
print '<tr><td>'.$langs->trans("Password").' :</td><td>';
print '<input type="password" name="pass"></td></tr>';
print '<tr><td>'.$langs->trans("PasswordAgain").' :</td><td>';
print '<input type="password" name="pass_verif"></td></tr>';
print '</table>';
if (isset($_GET["error"]) && $_GET["error"] == 1)
{
print '<br>';
print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 1)
{
print '<br>';
print '<div class="error">'.$langs->trans("PasswordsMismatch").'</div>';
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 2)
{
print '<br>';
print '<div class="error">';
print $langs->trans("PleaseTypePassword");
print '</div>';
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 2)
{
print '<br>';
print '<div class="error">';
print $langs->trans("PleaseTypePassword");
print '</div>';
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 3)
{
print '<br>';
print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
$err=0; // We show button
}
if (isset($_GET["error"]) && $_GET["error"] == 3)
{
print '<br>';
print '<div class="error">'.$langs->trans("PleaseTypeALogin").'</div>';
$err=0; // We show button
}
}

View File

@ -38,8 +38,8 @@ $langs->setDefaultLang($setuplang);
$targetversion=DOL_VERSION; // It it's last upgrade
if (isset($_POST["action"]) && preg_match('/upgrade/i',$_POST["action"])) // If it's an old upgrade
{
$tmp=explode('_',$_POST["action"],2);
if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
$tmp=explode('_',$_POST["action"],2);
if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
}
$langs->load("admin");
@ -74,23 +74,23 @@ dolibarr_install_syslog("--- etape5: Entering etape5.php page", LOG_INFO);
// If install, check pass and pass_verif used to create admin account
if ($action == "set")
{
if ($_POST["pass"] <> $_POST["pass_verif"])
{
Header("Location: etape4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if ($_POST["pass"] <> $_POST["pass_verif"])
{
Header("Location: etape4.php?error=1&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($_POST["pass"])) == 0)
{
Header("Location: etape4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($_POST["pass"])) == 0)
{
Header("Location: etape4.php?error=2&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($_POST["login"])) == 0)
{
Header("Location: etape4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
if (dol_strlen(trim($_POST["login"])) == 0)
{
Header("Location: etape4.php?error=3&selectlang=$setuplang".(isset($_POST["login"])?'&login='.$_POST["login"]:''));
exit;
}
}
@ -111,187 +111,187 @@ if (! GETPOST("versionfrom") && ! GETPOST("versionto") && ! is_writable($conffil
if ($action == "set" || preg_match('/upgrade/i',$action))
{
print '<table cellspacing="0" cellpadding="2" width="100%">';
$error=0;
print '<table cellspacing="0" cellpadding="2" width="100%">';
$error=0;
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
$conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
$conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption)?$dolibarr_main_db_encryption:'';
$conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$dolibarr_main_db_cryptkey:'';
$conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
$conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption)?$dolibarr_main_db_encryption:'';
$conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey)?$dolibarr_main_db_cryptkey:'';
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
$ok = 0;
$ok = 0;
// If first install
if ($action == "set")
{
// Active module user
$modName='modUser';
$file = $modName . ".class.php";
dolibarr_install_syslog('install/etape5.php Load module user '.DOL_DOCUMENT_ROOT ."/includes/modules/".$file, LOG_INFO);
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/".$file);
$objMod = new $modName($db);
$result=$objMod->init();
// If first install
if ($action == "set")
{
// Active module user
$modName='modUser';
$file = $modName . ".class.php";
dolibarr_install_syslog('install/etape5.php Load module user '.DOL_DOCUMENT_ROOT ."/includes/modules/".$file, LOG_INFO);
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/".$file);
$objMod = new $modName($db);
$result=$objMod->init();
if (! $result) print 'ERROR in activating module file='.$file;
if ($db->connected == 1)
{
$conf->setValues($db);
if ($db->connected == 1)
{
$conf->setValues($db);
// Create user
include_once(DOL_DOCUMENT_ROOT ."/user/class/user.class.php");
// Create user
include_once(DOL_DOCUMENT_ROOT ."/user/class/user.class.php");
$createuser=new User($db);
$createuser->id=0;
$createuser=new User($db);
$createuser->id=0;
$newuser = new User($db);
$newuser->nom='SuperAdmin';
$newuser->prenom='';
$newuser->login=$_POST["login"];
$newuser->pass=$_POST["pass"];
$newuser->admin=1;
$newuser->entity=0;
$newuser = new User($db);
$newuser->nom='SuperAdmin';
$newuser->prenom='';
$newuser->login=$_POST["login"];
$newuser->pass=$_POST["pass"];
$newuser->admin=1;
$newuser->entity=0;
$conf->global->USER_MAIL_REQUIRED=0; // Force global option to be sure to create a new user with no email
$result=$newuser->create($createuser,1);
if ($result > 0)
{
print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])."<br>";
$success = 1;
}
else
{
if ($newuser->error == 'ErrorLoginAlreadyExists')
{
dolibarr_install_syslog('install/etape5.php AdminLoginAlreadyExists', LOG_WARNING);
print '<br><div class="warning">'.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."</div><br>";
$success = 1;
}
else
{
dolibarr_install_syslog('install/etape5.php FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
print '<br><div class="error">'.$langs->trans("FailedToCreateAdminLogin").' '.$newuser->error.'</div><br><br>';
}
}
$conf->global->USER_MAIL_REQUIRED=0; // Force global option to be sure to create a new user with no email
$result=$newuser->create($createuser,1);
if ($result > 0)
{
print $langs->trans("AdminLoginCreatedSuccessfuly",$_POST["login"])."<br>";
$success = 1;
}
else
{
if ($newuser->error == 'ErrorLoginAlreadyExists')
{
dolibarr_install_syslog('install/etape5.php AdminLoginAlreadyExists', LOG_WARNING);
print '<br><div class="warning">'.$langs->trans("AdminLoginAlreadyExists",$_POST["login"])."</div><br>";
$success = 1;
}
else
{
dolibarr_install_syslog('install/etape5.php FailedToCreateAdminLogin '.$newuser->error, LOG_ERR);
print '<br><div class="error">'.$langs->trans("FailedToCreateAdminLogin").' '.$newuser->error.'</div><br><br>';
}
}
if ($success)
{
$db->begin();
if ($success)
{
$db->begin();
dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when install',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion;
dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_INSTALL const to '.$targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_INSTALL'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_INSTALL',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version when install',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_VERSION_LAST_INSTALL=$targetversion;
if ($useforcedwizard)
{
dolibarr_install_syslog('install/etape5.php set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING',1).",".$db->encrypt(1,1).",'chaine',1,'Disable install warnings',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_REMOVE_INSTALL_WARNING=1;
}
if ($useforcedwizard)
{
dolibarr_install_syslog('install/etape5.php set MAIN_REMOVE_INSTALL_WARNING const to 1', LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_REMOVE_INSTALL_WARNING'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_REMOVE_INSTALL_WARNING',1).",".$db->encrypt(1,1).",'chaine',1,'Disable install warnings',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_REMOVE_INSTALL_WARNING=1;
}
// If we ask to force some modules to be enabled
if (! empty($force_install_module))
{
if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT',$dolibarr_main_document_root);
if (! defined('DOL_DOCUMENT_ROOT_ALT') && ! empty($dolibarr_main_document_root_alt)) define('DOL_DOCUMENT_ROOT_ALT',$dolibarr_main_document_root_alt);
// If we ask to force some modules to be enabled
if (! empty($force_install_module))
{
if (! defined('DOL_DOCUMENT_ROOT') && ! empty($dolibarr_main_document_root)) define('DOL_DOCUMENT_ROOT',$dolibarr_main_document_root);
if (! defined('DOL_DOCUMENT_ROOT_ALT') && ! empty($dolibarr_main_document_root_alt)) define('DOL_DOCUMENT_ROOT_ALT',$dolibarr_main_document_root_alt);
$tmparray=explode(',',$force_install_module);
foreach ($tmparray as $modtoactivate)
{
$modtoactivatenew=preg_replace('/\.class\.php$/i','',$modtoactivate);
$tmparray=explode(',',$force_install_module);
foreach ($tmparray as $modtoactivate)
{
$modtoactivatenew=preg_replace('/\.class\.php$/i','',$modtoactivate);
$file=$modtoactivatenew.'.class.php';
dolibarr_install_syslog('install/etape5.php Activate module file='.$file);
dolibarr_install_syslog('install/etape5.php Activate module file='.$file);
$res=dol_include_once("/includes/modules/".$file);
$res=Activate($modtoactivatenew,1);
if (! $result) print 'ERROR in activating module file='.$file;
}
}
}
}
dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
if (! $resql) dol_print_error($db,'Error in setup program');
dolibarr_install_syslog('install/etape5.php Remove MAIN_NOT_INSTALLED const', LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_NOT_INSTALLED'");
if (! $resql) dol_print_error($db,'Error in setup program');
$db->commit();
}
}
else
{
print $langs->trans("ErrorFailedToConnect")."<br>";
}
}
// If upgrade
elseif (preg_match('/upgrade/i',$action))
{
if ($db->connected == 1)
{
$conf->setValues($db);
$db->commit();
}
}
else
{
print $langs->trans("ErrorFailedToConnect")."<br>";
}
}
// If upgrade
elseif (preg_match('/upgrade/i',$action))
{
if ($db->connected == 1)
{
$conf->setValues($db);
// Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
$tagdatabase=false;
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase=true; // We don't know what it was before, so now we consider we are version choosed.
else
{
$mainversionlastupgradearray=preg_split('/[.-]/',$conf->global->MAIN_VERSION_LAST_UPGRADE);
$targetversionarray=preg_split('/[.-]/',$targetversion);
if (versioncompare($targetversionarray,$mainversionlastupgradearray) > 0) $tagdatabase=true;
}
// Define if we need to update the MAIN_VERSION_LAST_UPGRADE value in database
$tagdatabase=false;
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) $tagdatabase=true; // We don't know what it was before, so now we consider we are version choosed.
else
{
$mainversionlastupgradearray=preg_split('/[.-]/',$conf->global->MAIN_VERSION_LAST_UPGRADE);
$targetversionarray=preg_split('/[.-]/',$targetversion);
if (versioncompare($targetversionarray,$mainversionlastupgradearray) > 0) $tagdatabase=true;
}
if ($tagdatabase)
{
dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_UPGRADE',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version for last upgrade',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_VERSION_LAST_UPGRADE=$targetversion;
}
else
{
dolibarr_install_syslog('install/etape5.php We run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.', LOG_DEBUG);
}
}
else
{
print $langs->trans("ErrorFailedToConnect")."<br>";
}
}
else
{
dol_print_error('','install/etape5.php Unknown choice of action');
}
if ($tagdatabase)
{
dolibarr_install_syslog('install/etape5.php set MAIN_VERSION_LAST_UPGRADE const to value '.$targetversion, LOG_DEBUG);
$resql=$db->query("DELETE FROM llx_const WHERE ".$db->decrypt('name')."='MAIN_VERSION_LAST_UPGRADE'");
if (! $resql) dol_print_error($db,'Error in setup program');
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_VERSION_LAST_UPGRADE',1).",".$db->encrypt($targetversion,1).",'chaine',0,'Dolibarr version for last upgrade',0)");
if (! $resql) dol_print_error($db,'Error in setup program');
$conf->global->MAIN_VERSION_LAST_UPGRADE=$targetversion;
}
else
{
dolibarr_install_syslog('install/etape5.php We run an upgrade to version '.$targetversion.' but database was already upgraded to '.$conf->global->MAIN_VERSION_LAST_UPGRADE.'. We keep MAIN_VERSION_LAST_UPGRADE as it is.', LOG_DEBUG);
}
}
else
{
print $langs->trans("ErrorFailedToConnect")."<br>";
}
}
else
{
dol_print_error('','install/etape5.php Unknown choice of action');
}
// May fail if parameter already defined
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_LANG_DEFAULT',1).",".$db->encrypt($setuplang,1).",'chaine',0,'Default language',1)");
//if (! $resql) dol_print_error($db,'Error in setup program');
// May fail if parameter already defined
$resql=$db->query("INSERT INTO llx_const(name,value,type,visible,note,entity) values(".$db->encrypt('MAIN_LANG_DEFAULT',1).",".$db->encrypt($setuplang,1).",'chaine',0,'Default language',1)");
//if (! $resql) dol_print_error($db,'Error in setup program');
print '</table>';
print '</table>';
$db->close();
$db->close();
}
print "<br>";
@ -302,104 +302,104 @@ print "<br>";
// If first install
if ($action == "set")
{
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
{
// Install is finished
print $langs->trans("SystemIsInstalled")."<br>";
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
{
// Install is finished
print $langs->trans("SystemIsInstalled")."<br>";
$createlock=0;
$createlock=0;
if (! empty($force_install_lockinstall))
{
// Install is finished, we create the lock file
$lockfile=DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
if ($fp)
{
if (! empty($force_install_lockinstall))
{
// Install is finished, we create the lock file
$lockfile=DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
if ($fp)
{
if ($force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
$createlock=1;
}
}
if (empty($createlock))
{
print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
$createlock=1;
}
}
if (empty($createlock))
{
print '<div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
print "<br>";
print "<br>";
print $langs->trans("YouNeedToPersonalizeSetup")."<br><br>";
print $langs->trans("YouNeedToPersonalizeSetup")."<br><br>";
print '<center><a href="../admin/company.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print $langs->trans("GoToSetupArea");
print '</a></center>';
}
else
{
// If here MAIN_VERSION_LAST_UPGRADE is not empty
print $langs->trans("VersionLastUpgrade").': <b><font class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</font></b><br>';
print $langs->trans("VersionProgram").': <b><font class="ok">'.DOL_VERSION.'</font></b><br>';
print $langs->trans("MigrationNotFinished").'<br>';
print "<br>";
print '<center><a href="../admin/company.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print $langs->trans("GoToSetupArea");
print '</a></center>';
}
else
{
// If here MAIN_VERSION_LAST_UPGRADE is not empty
print $langs->trans("VersionLastUpgrade").': <b><font class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</font></b><br>';
print $langs->trans("VersionProgram").': <b><font class="ok">'.DOL_VERSION.'</font></b><br>';
print $langs->trans("MigrationNotFinished").'<br>';
print "<br>";
print '<center><a href="'.$dolibarr_main_url_root .'/install/index.php">';
print $langs->trans("GoToUpgradePage");
print '</a></center>';
}
print '<center><a href="'.$dolibarr_main_url_root .'/install/index.php">';
print $langs->trans("GoToUpgradePage");
print '</a></center>';
}
}
// If upgrade
elseif (preg_match('/upgrade/i',$action))
{
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
{
// Upgrade is finished
print $langs->trans("SystemIsUpgraded")."<br>";
if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION))
{
// Upgrade is finished
print $langs->trans("SystemIsUpgraded")."<br>";
$createlock=0;
$createlock=0;
if (! empty($force_install_lockinstall))
{
// Upgrade is finished, we create the lock file
$lockfile=DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
if ($fp)
{
if (! empty($force_install_lockinstall))
{
// Upgrade is finished, we create the lock file
$lockfile=DOL_DATA_ROOT.'/install.lock';
$fp = @fopen($lockfile, "w");
if ($fp)
{
if ($force_install_lockinstall == 1) $force_install_lockinstall=444; // For backward compatibility
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
fclose($fp);
fwrite($fp, "This is a lock file to prevent use of install pages (set with permission ".$force_install_lockinstall.")");
fclose($fp);
@chmod($lockfile, octdec($force_install_lockinstall));
$createlock=1;
}
}
if (empty($createlock))
{
print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
$createlock=1;
}
}
if (empty($createlock))
{
print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
print "<br>";
print "<br>";
print '<center><a href="../index.php?mainmenu=home'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print $langs->trans("GoToDolibarr");
print '</a></center>';
}
else
{
// If here MAIN_VERSION_LAST_UPGRADE is not empty
print $langs->trans("VersionLastUpgrade").': <b><font class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</font></b><br>';
print $langs->trans("VersionProgram").': <b><font class="ok">'.DOL_VERSION.'</font></b>';
print '<center><a href="../index.php?mainmenu=home'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print $langs->trans("GoToDolibarr");
print '</a></center>';
}
else
{
// If here MAIN_VERSION_LAST_UPGRADE is not empty
print $langs->trans("VersionLastUpgrade").': <b><font class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</font></b><br>';
print $langs->trans("VersionProgram").': <b><font class="ok">'.DOL_VERSION.'</font></b>';
print "<br>";
print "<br>";
print '<center><a href="../install/index.php">';
print $langs->trans("GoToUpgradePage");
print '</a></center>';
}
print '<center><a href="../install/index.php">';
print $langs->trans("GoToUpgradePage");
print '</a></center>';
}
}
else
{
dol_print_error('','install/etape5.php Unknown choice of action');
dol_print_error('','install/etape5.php Unknown choice of action');
}

View File

@ -80,7 +80,8 @@ if (! empty($force_install_message))
}
?>
<table border="0" cellpadding="1" cellspacing="0">
<table
border="0" cellpadding="1" cellspacing="0">
<tr>
<td colspan="3" class="label" align="center">
@ -88,46 +89,44 @@ if (! empty($force_install_message))
</td>
</tr>
<!-- Documents root $dolibarr_main_document_root -->
<!-- Documents root $dolibarr_main_document_root -->
<tr>
<?php
print '<td valign="top" class="label"><b>';
print $langs->trans("WebPagesDirectory");
print "</b></td>";
<?php
print '<td valign="top" class="label"><b>';
print $langs->trans("WebPagesDirectory");
print "</b></td>";
if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
{
//print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
if(! isset($dolibarr_main_url_root) || dol_strlen($dolibarr_main_url_root) == 0)
{
//print "x".$_SERVER["SCRIPT_FILENAME"]." y".$_SERVER["DOCUMENT_ROOT"];
// Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
// ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
{
$dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
// Si le php fonctionne en CGI, alors SCRIPT_FILENAME vaut le path du php et
// ce n'est pas ce qu'on veut. Dans ce cas, on propose $_SERVER["DOCUMENT_ROOT"]
if (preg_match('/^php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i',$_SERVER["SCRIPT_FILENAME"]))
{
$dolibarr_main_document_root=$_SERVER["DOCUMENT_ROOT"];
if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
{
$dolibarr_main_document_root.="/dolibarr/htdocs";
}
}
else
{
$dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
// Nettoyage du path propose
// Gere les chemins windows avec double "\"
$dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
if (! preg_match('/[\\/]dolibarr[\\/]htdocs$/i',$dolibarr_main_document_root))
{
$dolibarr_main_document_root.="/dolibarr/htdocs";
}
}
else
{
$dolibarr_main_document_root = substr($_SERVER["SCRIPT_FILENAME"],0,dol_strlen($_SERVER["SCRIPT_FILENAME"]) - 21);
// Nettoyage du path propose
// Gere les chemins windows avec double "\"
$dolibarr_main_document_root = str_replace('\\\\','/',$dolibarr_main_document_root);
// Supprime les slash ou antislash de fins
$dolibarr_main_document_root = preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
}
}
?>
<td class="label" valign="top">
<?php
// Supprime les slash ou antislash de fins
$dolibarr_main_document_root = preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
}
}
?>
<td class="label" valign="top"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_document_root.'" name="main_dir">';
print '<input type="text" size="60" value="'.$dolibarr_main_document_root.'"'.(empty($force_install_noedit)?'':' disabled="disabled"').' name="main_dir'.(empty($force_install_noedit)?'':'_bis').'">';
?>
</td>
?></td>
<td class="comment"><?php
print $langs->trans("WithNoSlashAtTheEnd")."<br>";
print $langs->trans("Examples").":<br>";
@ -139,7 +138,7 @@ if (! empty($force_install_message))
</td>
</tr>
<!-- Documents URL $dolibarr_main_data_root -->
<!-- Documents URL $dolibarr_main_data_root -->
<tr>
<td valign="top" class="label"><b> <?php print $langs->trans("DocumentsDirectory"); ?></b>
</td>
@ -158,12 +157,10 @@ if (! empty($force_install_message))
}
}
?>
<td class="label" valign="top">
<?php
<td class="label" valign="top"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_data_root.'" name="main_data_dir">';
print '<input type="text" size="60" value="'.$dolibarr_main_data_root.'"'.(empty($force_install_noedit)?'':' disabled="disabled"').' name="main_data_dir'.(empty($force_install_noedit)?'':'_bis').'">';
?>
</td>
?></td>
<td class="comment"><?php
print $langs->trans("WithNoSlashAtTheEnd")."<br>";
print $langs->trans("DirectoryRecommendation")."<br>";
@ -176,43 +173,41 @@ if (! empty($force_install_message))
</td>
</tr>
<!-- Root URL $dolibarr_main_url_root -->
<?php
if (! empty($main_url)) $dolibarr_main_url_root=$main_url;
if (empty($dolibarr_main_url_root))
{
// If defined (Ie: Apache with Linux)
if (isset($_SERVER["SCRIPT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SCRIPT_URI"];
}
// If defined (Ie: Apache with Caudium)
elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
}
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else
{
$proto='http';
if (! empty($_SERVER["HTTP_HOST"])) $serverport=$_SERVER["HTTP_HOST"];
else $serverport=$_SERVER["SERVER_NAME"];
$dolibarr_main_url_root=$proto."://".$serverport.$_SERVER["SCRIPT_NAME"];
}
// Clean proposed URL
$dolibarr_main_url_root = preg_replace('/\/fileconf\.php$/','',$dolibarr_main_url_root); // Remove the /fileconf.php
$dolibarr_main_url_root = preg_replace('/\/$/','',$dolibarr_main_url_root); // Remove the /
$dolibarr_main_url_root = preg_replace('/\/index\.php$/','',$dolibarr_main_url_root); // Remove the /index.php
$dolibarr_main_url_root = preg_replace('/\/install$/','',$dolibarr_main_url_root); // Remove the /install
}
?>
<!-- Root URL $dolibarr_main_url_root -->
<?php
if (! empty($main_url)) $dolibarr_main_url_root=$main_url;
if (empty($dolibarr_main_url_root))
{
// If defined (Ie: Apache with Linux)
if (isset($_SERVER["SCRIPT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SCRIPT_URI"];
}
// If defined (Ie: Apache with Caudium)
elseif (isset($_SERVER["SERVER_URL"]) && isset($_SERVER["DOCUMENT_URI"])) {
$dolibarr_main_url_root=$_SERVER["SERVER_URL"].$_SERVER["DOCUMENT_URI"];
}
// If SCRIPT_URI, SERVER_URL, DOCUMENT_URI not defined (Ie: Apache 2.0.44 for Windows)
else
{
$proto='http';
if (! empty($_SERVER["HTTP_HOST"])) $serverport=$_SERVER["HTTP_HOST"];
else $serverport=$_SERVER["SERVER_NAME"];
$dolibarr_main_url_root=$proto."://".$serverport.$_SERVER["SCRIPT_NAME"];
}
// Clean proposed URL
$dolibarr_main_url_root = preg_replace('/\/fileconf\.php$/','',$dolibarr_main_url_root); // Remove the /fileconf.php
$dolibarr_main_url_root = preg_replace('/\/$/','',$dolibarr_main_url_root); // Remove the /
$dolibarr_main_url_root = preg_replace('/\/index\.php$/','',$dolibarr_main_url_root); // Remove the /index.php
$dolibarr_main_url_root = preg_replace('/\/install$/','',$dolibarr_main_url_root); // Remove the /install
}
?>
<tr>
<td valign="top" class="label"><b> <?php echo $langs->trans("URLRoot"); ?></b>
</td>
<td valign="top" class="label">
<?php
<td valign="top" class="label"><?php
if ($force_install_noedit) print '<input type="hidden" value="'.$dolibarr_main_url_root.'" name="main_url">';
print '<input type="text" size="60" value="'.$dolibarr_main_url_root.'"'.(empty($force_install_noedit)?'':' disabled="disabled"').' name="main_url'.(empty($force_install_noedit)?'':'_bis').'">';
?>
</td>
?></td>
<td class="comment"><?php print $langs->trans("Examples").":<br>"; ?>
<ul>
<li>http://localhost/</li>
@ -221,9 +216,9 @@ if (empty($dolibarr_main_url_root))
</td>
</tr>
<?php
if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
?>
<?php
if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if the installation process is "https://"
?>
<tr>
<td valign="top" class="label"><?php echo $langs->trans("ForceHttps"); ?></td>
<td class="label" valign="top"><input type="checkbox"
@ -233,9 +228,9 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
</td>
</tr>
<?php
}
?>
<?php
}
?>
<!-- Dolibarr database -->
@ -259,56 +254,56 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
$defaultype=! empty($dolibarr_main_db_type)?$dolibarr_main_db_type:($force_install_type?$force_install_type:'mysqli');
$modules = array();
$nbok = $nbko = 0;
$option='';
$modules = array();
$nbok = $nbko = 0;
$option='';
// Scan les drivers
// Scan les drivers
$dir=DOL_DOCUMENT_ROOT.'/lib/databases';
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php/i',$file,$reg))
{
$type=$reg[1];
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php/i',$file,$reg))
{
$type=$reg[1];
// Version min de la base
$versionbasemin=array();
if ($type=='mysql') { $versionbasemin=array(3,1,0); $testfunction='mysql_connect'; }
if ($type=='mysqli') { $versionbasemin=array(4,1,0); $testfunction='mysqli_connect'; }
if ($type=='pgsql') { $versionbasemin=array(8,4,0); $testfunction='pg_connect'; }
if ($type=='mssql') { $versionbasemin=array(2000); $testfunction='mssql_connect'; }
// Version min de la base
$versionbasemin=array();
if ($type=='mysql') { $versionbasemin=array(3,1,0); $testfunction='mysql_connect'; }
if ($type=='mysqli') { $versionbasemin=array(4,1,0); $testfunction='mysqli_connect'; }
if ($type=='pgsql') { $versionbasemin=array(8,4,0); $testfunction='pg_connect'; }
if ($type=='mssql') { $versionbasemin=array(2000); $testfunction='mssql_connect'; }
// Remarques
$note='';
if ($type=='mysql') $note='(Mysql >= '.versiontostring($versionbasemin).')';
if ($type=='mysqli') $note='(Mysql >= '.versiontostring($versionbasemin).')';
if ($type=='pgsql') $note='(Postgresql >= '.versiontostring($versionbasemin).')';
if ($type=='mssql') $note='(SQL Server >= '.versiontostring($versionbasemin).')';
// Remarques
$note='';
if ($type=='mysql') $note='(Mysql >= '.versiontostring($versionbasemin).')';
if ($type=='mysqli') $note='(Mysql >= '.versiontostring($versionbasemin).')';
if ($type=='pgsql') $note='(Postgresql >= '.versiontostring($versionbasemin).')';
if ($type=='mssql') $note='(SQL Server >= '.versiontostring($versionbasemin).')';
// Switch to mysql if mysqli is not present
if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
// Switch to mysql if mysqli is not present
if ($defaultype=='mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql';
// Affiche ligne dans liste
$option.='<option value="'.$type.'"'.($defaultype == $type?' selected="selected"':'');
if (! function_exists($testfunction)) $option.=' disabled="disabled"';
$option.='>';
$option.=$type.'&nbsp; &nbsp;';
if ($note) $option.=' '.$note;
// Experimental
if ($type=='pgsql') $option.=' '.$langs->trans("Experimental");
elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental");
// No available
elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
$option.='</option>';
}
}
}
// Affiche ligne dans liste
$option.='<option value="'.$type.'"'.($defaultype == $type?' selected="selected"':'');
if (! function_exists($testfunction)) $option.=' disabled="disabled"';
$option.='>';
$option.=$type.'&nbsp; &nbsp;';
if ($note) $option.=' '.$note;
// Experimental
if ($type=='pgsql') $option.=' '.$langs->trans("Experimental");
elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental");
// No available
elseif (! function_exists($testfunction)) $option.=' - '.$langs->trans("FunctionNotAvailableInThisPHP");
$option.='</option>';
}
}
}
if ($force_install_noedit && $force_install_type) print '<input id="db_type" type="hidden" value="'.$force_install_type.'" name="db_type">';
print '<select id="db_type" name="db_type'.(empty($force_install_noedit) || empty($force_install_type)?'':'_bis').'"'.($force_install_noedit && $force_install_type?' disabled="disabled"':'').'>';
if ($force_install_noedit && $force_install_type) print '<input id="db_type" type="hidden" value="'.$force_install_type.'" name="db_type">';
print '<select id="db_type" name="db_type'.(empty($force_install_noedit) || empty($force_install_type)?'':'_bis').'"'.($force_install_noedit && $force_install_type?' disabled="disabled"':'').'>';
print $option;
print '</select>';
@ -320,10 +315,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<tr>
<td valign="top" class="label"><b> <?php echo $langs->trans("Server"); ?>
</b></td>
<td valign="top" class="label"><input type="text" name="db_host<?php print ($force_install_noedit==2 && $force_install_dbserver)?'_bis':''; ?>"
<td valign="top" class="label"><input type="text"
name="db_host<?php print ($force_install_noedit==2 && $force_install_dbserver)?'_bis':''; ?>"
<?php if ($force_install_noedit==2 && $force_install_dbserver) print ' disabled="disabled"'; ?>
value="<?php print (! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:(empty($force_install_dbserver)?'localhost':$force_install_dbserver); ?>">
<?php if ($force_install_noedit==2 && $force_install_dbserver) print '<input type="hidden" name="db_host" value="'.((! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:$force_install_dbserver).'">'; ?>
<?php if ($force_install_noedit==2 && $force_install_dbserver) print '<input type="hidden" name="db_host" value="'.((! empty($dolibarr_main_db_host))?$dolibarr_main_db_host:$force_install_dbserver).'">'; ?>
</td>
<td class="comment"><?php echo $langs->trans("ServerAddressDescription"); ?>
</td>
@ -332,10 +328,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<tr>
<td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
<td valign="top" class="label"><input type="text" name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
<td valign="top" class="label"><input type="text"
name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
<?php if ($force_install_noedit==2 && $force_install_port) print ' disabled="disabled"'; ?>
value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
<?php if ($force_install_noedit==2 && $force_install_port) print '<input type="hidden" name="db_port" value="'.((! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port).'">'; ?>
<?php if ($force_install_noedit==2 && $force_install_port) print '<input type="hidden" name="db_port" value="'.((! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port).'">'; ?>
</td>
<td class="comment"><?php echo $langs->trans("ServerPortDescription"); ?>
</td>
@ -343,9 +340,11 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
</tr>
<tr>
<td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?> </b></td>
<td class="label" valign="top"><b> <?php echo $langs->trans("DatabaseName"); ?>
</b></td>
<td class="label" valign="top"><input type="text" id="db_name" name="db_name"
<td class="label" valign="top"><input type="text" id="db_name"
name="db_name"
value="<?php echo (! empty($dolibarr_main_db_name))?$dolibarr_main_db_name:($force_install_database?$force_install_database:'dolibarr'); ?>"></td>
<td class="comment"><?php echo $langs->trans("DatabaseName"); ?></td>
</tr>
@ -364,7 +363,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<tr>
<td class="label" valign="top"><b><?php echo $langs->trans("Login"); ?></b>
</td>
<td class="label" valign="top"><input type="text" id="db_user" name="db_user"
<td class="label" valign="top"><input type="text" id="db_user"
name="db_user"
value="<?php print (! empty($dolibarr_main_db_user))?$dolibarr_main_db_user:$force_install_databaselogin; ?>"></td>
<td class="comment"><?php echo $langs->trans("AdminLogin"); ?></td>
</tr>
@ -372,7 +372,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<tr>
<td class="label" valign="top"><b><?php echo $langs->trans("Password"); ?></b>
</td>
<td class="label" valign="top"><input type="password" id="db_pass" name="db_pass"
<td class="label" valign="top"><input type="password" id="db_pass"
name="db_pass"
value="<?php print (! empty($dolibarr_main_db_pass))?$dolibarr_main_db_pass:$force_install_databasepass; ?>"></td>
<td class="comment"><?php echo $langs->trans("AdminPassword"); ?></td>
</tr>
@ -381,7 +382,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<td class="label" valign="top"><?php echo $langs->trans("CreateUser"); ?>
</td>
<td class="label" valign="top"><input type="checkbox" id="db_create_user" name="db_create_user"
<td class="label" valign="top"><input type="checkbox"
id="db_create_user" name="db_create_user"
<?php if (! empty($force_install_createuser)) print ' checked="on"'; ?>></td>
<td class="comment"><?php echo $langs->trans("CheckToCreateUser"); ?>
</td>
@ -390,8 +392,8 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<!-- Super access -->
<?php
$force_install_databaserootlogin=preg_replace('/__SUPERUSERLOGIN__/','root',$force_install_databaserootlogin);
$force_install_databaserootpass=preg_replace('/__SUPERUSERPASSWORD__/','',$force_install_databaserootpass);
$force_install_databaserootlogin=preg_replace('/__SUPERUSERLOGIN__/','root',$force_install_databaserootlogin);
$force_install_databaserootpass=preg_replace('/__SUPERUSERPASSWORD__/','',$force_install_databaserootpass);
?>
<tr>
<td colspan="3" class="label" align="center"><br>
@ -401,10 +403,10 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
<tr>
<td class="label" valign="top"><?php echo $langs->trans("Login"); ?></td>
<td class="label" valign="top"><input type="text" id="db_user_root" name="db_user_root" class="needroot"
<td class="label" valign="top"><input type="text" id="db_user_root"
name="db_user_root" class="needroot"
value="<?php print (! empty($db_user_root))?$db_user_root:$force_install_databaserootlogin; ?>"></td>
<td class="comment">
<?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
<td class="comment"><?php echo $langs->trans("DatabaseRootLoginDescription"); ?>
<!--
<?php echo '<br>'.$langs->trans("Examples").':<br>' ?>
<ul>
@ -413,15 +415,16 @@ if (! empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') { // Enabled if t
</ul>
</td>
-->
</tr>
<tr>
<td class="label" valign="top"><?php echo $langs->trans("Password"); ?>
</td>
<td class="label" valign="top"><input type="password" id="db_pass_root" name="db_pass_root" class="needroot"
<td class="label" valign="top"><input type="password"
id="db_pass_root" name="db_pass_root" class="needroot"
value="<?php print (! empty($db_pass_root))?$db_pass_root:$force_install_databaserootpass; ?>"></td>
<td class="comment">
<?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
<td class="comment"><?php echo $langs->trans("KeepEmptyIfNoPassword"); ?>
</td>
</tr>
@ -519,9 +522,9 @@ function jscheckparam()
}
</script>
<?php
<?php
// $db->close(); Not database connexion yet
// $db->close(); Not database connexion yet
pFooter($err,$setuplang,'jscheckparam');
?>
pFooter($err,$setuplang,'jscheckparam');
?>

View File

@ -49,29 +49,29 @@ $_REQUEST["logtohtml"]=1;
// et non path absolu.
if (isset($_SERVER["DOCUMENT_URI"]) && $_SERVER["DOCUMENT_URI"])
{
$_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
$_SERVER["PHP_SELF"]=$_SERVER["DOCUMENT_URI"];
}
// Definition des constantes syslog
if (function_exists("define_syslog_variables"))
{
if (version_compare(PHP_VERSION, '5.3.0', '<'))
{
define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
}
if (version_compare(PHP_VERSION, '5.3.0', '<'))
{
define_syslog_variables(); // Deprecated since php 5.3.0, syslog variables no longer need to be initialized
}
}
else
{
// Pour PHP sans syslog (comme sous Windows)
define('LOG_EMERG',0);
define('LOG_ALERT',1);
define('LOG_CRIT',2);
define('LOG_ERR',3);
define('LOG_WARNING',4);
define('LOG_NOTICE',5);
define('LOG_INFO',6);
define('LOG_DEBUG',7);
// Pour PHP sans syslog (comme sous Windows)
define('LOG_EMERG',0);
define('LOG_ALERT',1);
define('LOG_CRIT',2);
define('LOG_ERR',3);
define('LOG_WARNING',4);
define('LOG_NOTICE',5);
define('LOG_INFO',6);
define('LOG_DEBUG',7);
}
$includeconferror='';
@ -89,44 +89,44 @@ $conffiletoshow = "htdocs/conf/conf.php";
if (! defined('DONOTLOADCONF') && file_exists($conffile))
{
$result=include_once($conffile); // Load conf file
if ($result)
{
//if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
$result=include_once($conffile); // Load conf file
if ($result)
{
//if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
// Remove last / or \ on directories or url value
if (! empty($dolibarr_main_document_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root)) $dolibarr_main_document_root=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
if (! empty($dolibarr_main_url_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root)) $dolibarr_main_url_root=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root);
if (! empty($dolibarr_main_data_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_data_root)) $dolibarr_main_data_root=preg_replace('/[\\/]+$/','',$dolibarr_main_data_root);
if (! empty($dolibarr_main_document_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root_alt);
if (! empty($dolibarr_main_url_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root_alt);
// Remove last / or \ on directories or url value
if (! empty($dolibarr_main_document_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root)) $dolibarr_main_document_root=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root);
if (! empty($dolibarr_main_url_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root)) $dolibarr_main_url_root=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root);
if (! empty($dolibarr_main_data_root) && ! preg_match('/^[\\/]+$/',$dolibarr_main_data_root)) $dolibarr_main_data_root=preg_replace('/[\\/]+$/','',$dolibarr_main_data_root);
if (! empty($dolibarr_main_document_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_document_root_alt)) $dolibarr_main_document_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_document_root_alt);
if (! empty($dolibarr_main_url_root_alt) && ! preg_match('/^[\\/]+$/',$dolibarr_main_url_root_alt)) $dolibarr_main_url_root_alt=preg_replace('/[\\/]+$/','',$dolibarr_main_url_root_alt);
// Create conf object
if (! empty($dolibarr_main_document_root))
{
$result=conf($dolibarr_main_document_root);
}
// Load database driver
if ($result)
{
if (! empty($dolibarr_main_document_root) && ! empty($dolibarr_main_db_type))
{
$result=include_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".class.php");
if (! $result)
{
$includeconferror='ErrorBadValueForDolibarrMainDBType';
}
}
}
else
{
$includeconferror='ErrorBadValueForDolibarrMainDocumentRoot';
}
}
else
{
$includeconferror='ErrorBadFormatForConfFile';
}
// Create conf object
if (! empty($dolibarr_main_document_root))
{
$result=conf($dolibarr_main_document_root);
}
// Load database driver
if ($result)
{
if (! empty($dolibarr_main_document_root) && ! empty($dolibarr_main_db_type))
{
$result=include_once($dolibarr_main_document_root . "/lib/databases/".$dolibarr_main_db_type.".class.php");
if (! $result)
{
$includeconferror='ErrorBadValueForDolibarrMainDBType';
}
}
}
else
{
$includeconferror='ErrorBadValueForDolibarrMainDocumentRoot';
}
}
else
{
$includeconferror='ErrorBadFormatForConfFile';
}
}
$conf->global->MAIN_LOGTOHTML=1;
@ -138,11 +138,11 @@ define('DOL_CLASS_PATH', 'class/'); // Filsystem pat
define('DOL_DATA_ROOT',(isset($dolibarr_main_data_root)?$dolibarr_main_data_root:''));
if (! empty($dolibarr_main_document_root_alt))
{
define('DOL_DOCUMENT_ROOT_ALT', $dolibarr_main_document_root_alt); // Filesystem paths to alternate core php (alternate htdocs)
define('DOL_DOCUMENT_ROOT_ALT', $dolibarr_main_document_root_alt); // Filesystem paths to alternate core php (alternate htdocs)
}
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root)?$dolibarr_main_url_root:'')); // URL relative root
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr ($uri, '/'); // $suburi contains url without domain
$suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
@ -170,33 +170,33 @@ if (! empty($dolibarr_main_document_root_alt))
// Security check
if (preg_match('/install.lock/i',$_SERVER["SCRIPT_FILENAME"]))
{
print 'Install pages have been disabled for security reason (directory renamed with .lock suffix).';
print 'Install pages have been disabled for security reason (directory renamed with .lock suffix).';
if (! empty($dolibarr_main_url_root))
{
print 'Click on following link. ';
print '<a href="'.$dolibarr_main_url_root .'/admin/index.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print 'Click here to go to Dolibarr';
print '</a>';
print 'Click on following link. ';
print '<a href="'.$dolibarr_main_url_root .'/admin/index.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print 'Click here to go to Dolibarr';
print '</a>';
}
exit;
exit;
}
$lockfile=DOL_DATA_ROOT.'/install.lock';
if (constant('DOL_DATA_ROOT') && file_exists($lockfile))
{
print 'Install pages have been disabled for security reason (by lock file install.lock into dolibarr root directory).<br>';
if (! empty($dolibarr_main_url_root))
{
print 'Click on following link. ';
print 'If you always reach this page, you must remove install.lock file manually.<br>';
print '<a href="'.$dolibarr_main_url_root .'/admin/index.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print 'Click here to go to Dolibarr';
print '</a>';
}
print 'Install pages have been disabled for security reason (by lock file install.lock into dolibarr root directory).<br>';
if (! empty($dolibarr_main_url_root))
{
print 'Click on following link. ';
print 'If you always reach this page, you must remove install.lock file manually.<br>';
print '<a href="'.$dolibarr_main_url_root .'/admin/index.php?mainmenu=home&leftmenu=setup'.(isset($_POST["login"])?'&username='.urlencode($_POST["login"]):'').'">';
print 'Click here to go to Dolibarr';
print '</a>';
}
else
{
print 'If you always reach this page, you must remove install.lock file manually.<br>';
}
exit;
exit;
}
@ -205,37 +205,37 @@ $conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
define('SYSLOG_FILE_NO_ERROR',1);
define('SYSLOG_FILE_NO_ERROR',1);
}
// Removed magic_quotes
if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6
{
if (get_magic_quotes_gpc())
{
// Forcing parameter setting magic_quotes_gpc and cleaning parameters
// (Otherwise he would have for each position, condition
// Reading stripslashes variable according to state get_magic_quotes_gpc).
// Off mode (recommended, you just do $db->escape when an insert / update.
function stripslashes_deep($value)
{
return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
}
$_GET = array_map('stripslashes_deep', $_GET);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
@set_magic_quotes_runtime(0);
}
if (get_magic_quotes_gpc())
{
// Forcing parameter setting magic_quotes_gpc and cleaning parameters
// (Otherwise he would have for each position, condition
// Reading stripslashes variable according to state get_magic_quotes_gpc).
// Off mode (recommended, you just do $db->escape when an insert / update.
function stripslashes_deep($value)
{
return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value));
}
$_GET = array_map('stripslashes_deep', $_GET);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
@set_magic_quotes_runtime(0);
}
}
// Defini objet langs
@ -247,168 +247,172 @@ $bc[true]=' class="bg2"';
/**
* \brief Load conf file (file must exists)
* \param dolibarr_main_document_root Root directory of Dolibarr bin files
* \return int <0 if KO, >0 if OK
* Load conf file (file must exists)
*
* @param string $dolibarr_main_document_root Root directory of Dolibarr bin files
* @return int <0 if KO, >0 if OK
*/
function conf($dolibarr_main_document_root)
{
global $conf;
global $dolibarr_main_db_type;
global $dolibarr_main_db_host;
global $dolibarr_main_db_port;
global $dolibarr_main_db_name;
global $dolibarr_main_db_user;
global $dolibarr_main_db_pass;
global $character_set_client;
global $conf;
global $dolibarr_main_db_type;
global $dolibarr_main_db_host;
global $dolibarr_main_db_port;
global $dolibarr_main_db_name;
global $dolibarr_main_db_user;
global $dolibarr_main_db_pass;
global $character_set_client;
$return=include_once($dolibarr_main_document_root."/core/class/conf.class.php");
if (! $return) return -1;
$return=include_once($dolibarr_main_document_root."/core/class/conf.class.php");
if (! $return) return -1;
$conf=new Conf();
$conf->db->type = trim($dolibarr_main_db_type);
$conf->db->host = trim($dolibarr_main_db_host);
$conf->db->port = trim($dolibarr_main_db_port);
$conf->db->name = trim($dolibarr_main_db_name);
$conf->db->user = trim($dolibarr_main_db_user);
$conf->db->pass = trim($dolibarr_main_db_pass);
$conf=new Conf();
$conf->db->type = trim($dolibarr_main_db_type);
$conf->db->host = trim($dolibarr_main_db_host);
$conf->db->port = trim($dolibarr_main_db_port);
$conf->db->name = trim($dolibarr_main_db_name);
$conf->db->user = trim($dolibarr_main_db_user);
$conf->db->pass = trim($dolibarr_main_db_pass);
if (empty($character_set_client)) $character_set_client="UTF-8";
$conf->file->character_set_client=strtoupper($character_set_client);
if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; // Old installation
$conf->db->character_set=$dolibarr_main_db_character_set;
if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swedish_ci'; // Old installation
$conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
if (empty($character_set_client)) $character_set_client="UTF-8";
$conf->file->character_set_client=strtoupper($character_set_client);
if (empty($dolibarr_main_db_character_set)) $dolibarr_main_db_character_set='latin1'; // Old installation
$conf->db->character_set=$dolibarr_main_db_character_set;
if (empty($dolibarr_main_db_collation)) $dolibarr_main_db_collation='latin1_swedish_ci'; // Old installation
$conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation;
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
// Forcage du log pour les install et mises a jour
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
define('SYSLOG_FILE_NO_ERROR',1);
}
// Forcage du log pour les install et mises a jour
$conf->syslog->enabled=1;
$conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG');
if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined
{
if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log');
else if (! empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) define('SYSLOG_FILE',$_ENV["TMP"].'/dolibarr_install.log');
else if (! empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) define('SYSLOG_FILE',$_ENV["TEMP"].'/dolibarr_install.log');
else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) define('SYSLOG_FILE','../../../../dolibarr_install.log'); // For DoliWamp
else if (@is_writable('../../')) define('SYSLOG_FILE','../../dolibarr_install.log'); // For others
//print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
}
if (! defined('SYSLOG_FILE_NO_ERROR'))
{
define('SYSLOG_FILE_NO_ERROR',1);
}
return 1;
return 1;
}
/**
* Show header of install pages
*
* @param $soutitre
* @param $next
* @param $action Action code ('set' or 'upgrade')
* @param $param
* @param string $soutitre Sous titre
* @param string $next Next
* @param string $action Action code ('set' or 'upgrade')
* @param string $param Param
* @return void
*/
function pHeader($soutitre,$next,$action='set',$param='')
{
global $conf;
global $langs;
$langs->load("main");
$langs->load("admin");
global $conf;
global $langs;
$langs->load("main");
$langs->load("admin");
// On force contenu dans format sortie
header("Content-type: text/html; charset=".$conf->file->character_set_client);
// On force contenu dans format sortie
header("Content-type: text/html; charset=".$conf->file->character_set_client);
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
print '<html>'."\n";
print '<head>'."\n";
print '<meta http-equiv="content-type" content="text/html; charset='.$conf->file->character_set_client.'">'."\n";
print '<link rel="stylesheet" type="text/css" href="./default.css">'."\n";
print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/smoothness/jquery-ui-latest.custom.css" type="text/css">'."\n";
print '<script type="text/javascript" src="../includes/jquery/js/jquery-latest.min.js"></script>'."\n";
print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n";
print '<title>'.$langs->trans("DolibarrSetup").'</title>'."\n";
print '</head>'."\n";
print '<body>'."\n";
print '<span class="titre">'.$langs->trans("DolibarrSetup");
if ($soutitre) {
print ' - '.$soutitre;
}
print '</span>'."\n";
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
print '<html>'."\n";
print '<head>'."\n";
print '<meta http-equiv="content-type" content="text/html; charset='.$conf->file->character_set_client.'">'."\n";
print '<link rel="stylesheet" type="text/css" href="./default.css">'."\n";
print '<link rel="stylesheet" type="text/css" href="../includes/jquery/css/smoothness/jquery-ui-latest.custom.css" type="text/css">'."\n";
print '<script type="text/javascript" src="../includes/jquery/js/jquery-latest.min.js"></script>'."\n";
print '<script type="text/javascript" src="../includes/jquery/js/jquery-ui-latest.custom.min.js"></script>'."\n";
print '<title>'.$langs->trans("DolibarrSetup").'</title>'."\n";
print '</head>'."\n";
print '<body>'."\n";
print '<span class="titre">'.$langs->trans("DolibarrSetup");
if ($soutitre) {
print ' - '.$soutitre;
}
print '</span>'."\n";
print '<form name="forminstall" action="'.$next.'.php'.($param?'?'.$param:'').'" method="POST">'."\n";
print '<input type="hidden" name="testpost" value="ok">'."\n";
print '<input type="hidden" name="action" value="'.$action.'">'."\n";
print '<form name="forminstall" action="'.$next.'.php'.($param?'?'.$param:'').'" method="POST">'."\n";
print '<input type="hidden" name="testpost" value="ok">'."\n";
print '<input type="hidden" name="action" value="'.$action.'">'."\n";
print '<table class="main" width="100%"><tr><td>'."\n";
print '<table class="main" width="100%"><tr><td>'."\n";
print '<table class="main-inside" width="100%"><tr><td>'."\n";
print '<table class="main-inside" width="100%"><tr><td>'."\n";
}
/**
* Output footer of install pages
*
* @param $nonext
* @param $setuplang
* @param $jscheckfunction
* @param string $nonext No next
* @param string $setuplang Setup lang
* @param string $jscheckfunction Add a javascript check function
* @return void
*/
function pFooter($nonext=0,$setuplang='',$jscheckfunction='')
{
global $conf,$langs;
global $conf,$langs;
$langs->load("main");
$langs->load("admin");
$langs->load("main");
$langs->load("admin");
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
if (! $nonext)
{
print '<div class="nextbutton" id="nextbutton"><input type="submit" value="'.$langs->trans("NextStep").' ->"';
if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"';
print '></div>';
print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br><blink>'.$langs->trans("NextStepMightLastALongTime").'</blink><br><br>'.$langs->trans("PleaseBePatient").'</div>';
}
if ($setuplang)
{
print '<input type="hidden" name="selectlang" value="'.$setuplang.'">';
}
if (! $nonext)
{
print '<div class="nextbutton" id="nextbutton"><input type="submit" value="'.$langs->trans("NextStep").' ->"';
if ($jscheckfunction) print ' onClick="return '.$jscheckfunction.'();"';
print '></div>';
print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br><blink>'.$langs->trans("NextStepMightLastALongTime").'</blink><br><br>'.$langs->trans("PleaseBePatient").'</div>';
}
if ($setuplang)
{
print '<input type="hidden" name="selectlang" value="'.$setuplang.'">';
}
print '</form>'."\n";
print '</form>'."\n";
// If there is some logs in buffer to show
if (isset($conf->logbuffer) && count($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach($conf->logbuffer as $logline)
{
print $logline."<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
print "\n";
}
// If there is some logs in buffer to show
if (isset($conf->logbuffer) && count($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach($conf->logbuffer as $logline)
{
print $logline."<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
print "\n";
}
print '</body>'."\n";
print '</html>'."\n";
print '</body>'."\n";
print '</html>'."\n";
}
/**
* Log function for install pages
*
* @param $message
* @param $level
* @param string $message Message
* @param int $level Level of log
* @return void
*/
function dolibarr_install_syslog($message, $level=LOG_DEBUG)
{
if (! defined('LOG_DEBUG')) define('LOG_DEBUG',6);
dol_syslog($message,$level);
if (! defined('LOG_DEBUG')) define('LOG_DEBUG',6);
dol_syslog($message,$level);
}
?>

View File

@ -1,68 +0,0 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/install/licence.php
* \ingroup install
* \brief Page to show licence (Removed from install process to save time)
*/
include_once("./inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
$setuplang=isset($_POST["selectlang"])?$_POST["selectlang"]:(isset($_GET["selectlang"])?$_GET["selectlang"]:'auto');
$langs->setDefaultLang($setuplang);
$langs->load("install");
// Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard.
$useforcedwizard=false;
if (file_exists("./install.forced.php")) { $useforcedwizard=true; include_once("./install.forced.php"); }
else if (file_exists("/etc/dolibarr/install.forced.php")) { $useforcedwizard=include_once("/etc/dolibarr/install.forced.php"); }
dolibarr_install_syslog("Licence: Entering licence.php page");
/*
* View
*/
pHeader($langs->trans("License"),"fileconf");
// Test if we can run a first install process
if (! is_writable($conffile))
{
print $langs->trans("ConfFileIsNotWritable",$conffiletoshow);
pFooter(1,$setuplang,'jscheckparam');
exit;
}
//print '<pre style="align: center; font-size: 12px">';
$result=dol_print_file($langs,"html/gpl.html",1);
if (! $result)
{
print '<center>'."\n";
print '<textarea readonly="1" rows="26" cols="80">';
dol_print_file($langs,"html/gpl.txt",1);
print '</textarea>';
print '</center>'."\n";
}
//print '</pre>';
pFooter(0,$setuplang);
?>

View File

@ -76,14 +76,14 @@ $error=0;
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// $conf is already instancied inside inc.php
@ -98,44 +98,44 @@ $db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db-
if ($db->connected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
$ok = 1;
print '<tr><td nowrap="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
$ok = 1;
}
else
{
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->transnoentities("Error")."</td></tr>";
dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok = 0;
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->transnoentities("Error")."</td></tr>";
dolibarr_install_syslog("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok = 0;
}
if ($ok)
{
if($db->database_selected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
dolibarr_install_syslog("repair: 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("repair: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok=0;
}
if($db->database_selected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
dolibarr_install_syslog("repair: 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("repair: ".$langs->transnoentities("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("repair: ".$langs->transnoentities("ServerVersion")." : $version");
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
$version=$db->getVersion();
$versionarray=$db->getVersionArray();
print '<tr><td>'.$langs->trans("ServerVersion").'</td>';
print '<td align="right">'.$version.'</td></tr>';
dolibarr_install_syslog("repair: ".$langs->transnoentities("ServerVersion")." : $version");
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
}
// Force l'affichage de la progression
@ -148,47 +148,47 @@ flush();
*/
if ($ok)
{
if ($choix==1) $dir = "mysql/migration/";
elseif ($choix==2) $dir = "pgsql/migration/";
else $dir = "mssql/migration/";
if ($choix==1) $dir = "mysql/migration/";
elseif ($choix==2) $dir = "pgsql/migration/";
else $dir = "mssql/migration/";
$filelist=array();
$i = 0;
$ok = 0;
$from='^'.$versionfrom;
$to=$versionto.'\.sql$';
$filelist=array();
$i = 0;
$ok = 0;
$from='^'.$versionfrom;
$to=$versionto.'\.sql$';
// Recupere list fichier
$filesindir=array();
$handle=opendir($dir);
// Recupere list fichier
$filesindir=array();
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
}
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
}
}
sort($filesindir);
sort($filesindir);
foreach($filesindir as $file)
{
if (preg_match('/repair/i',$file))
{
$filelist[]=$file;
}
}
foreach($filesindir as $file)
{
if (preg_match('/repair/i',$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>';
// 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, dol_strlen($file) - 4);
$name = substr($file, 0, dol_strlen($file) - 4);
// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);
}
// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);
}
}
print '</table>';

View File

@ -25,7 +25,7 @@
include_once("./inc.php");
if (! file_exists($conffile))
{
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
print 'Error: Dolibarr config file was not found. This may means that Dolibarr is not installed yet. Please call the page "/install/index.php" instead of "/install/upgrade.php").';
}
require_once($conffile); if (! isset($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // For backward compatibility
require_once($dolibarr_main_document_root."/lib/admin.lib.php");
@ -71,272 +71,272 @@ $actiondone=0;
// Action to launch the repair or migrate script
if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
{
$actiondone=1;
$actiondone=1;
print '<h3>'.$langs->trans("DatabaseMigration").'</h3>';
print '<h3>'.$langs->trans("DatabaseMigration").'</h3>';
if (! $versionfrom && ! $versionto)
{
print '<div class="error">Parameter versionfrom or version to missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php</div>';
exit;
}
if (! $versionfrom && ! $versionto)
{
print '<div class="error">Parameter versionfrom or version to missing. Upgrade is launched from page install/index.php (like a first install) instead of install/upgrade.php</div>';
exit;
}
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
$error=0;
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
$error=0;
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{
require_once($dolibarr_main_document_root."/lib/security.lib.php");
if (preg_match('/crypted:/i',$dolibarr_main_db_pass))
{
$dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
$dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
$dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
}
else $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
}
// $conf is already instancied inside inc.php
$conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
// $conf is already instancied inside inc.php
$conf->db->type = $dolibarr_main_db_type;
$conf->db->host = $dolibarr_main_db_host;
$conf->db->port = $dolibarr_main_db_port;
$conf->db->name = $dolibarr_main_db_name;
$conf->db->user = $dolibarr_main_db_user;
$conf->db->pass = $dolibarr_main_db_pass;
// Load type and crypt key
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
// Load type and crypt key
if (empty($dolibarr_main_db_encryption)) $dolibarr_main_db_encryption=0;
$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey='';
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
$db=getDoliDBInstance($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
if ($db->connected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
$ok = 1;
}
else
{
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->transnoentities("Error")."</td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok = 0;
}
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ServerConnection")." : $dolibarr_main_db_host ".$langs->transnoentities("OK"));
$ok = 1;
}
else
{
print "<tr><td>".$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->transnoentities("Error")."</td></tr>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok = 0;
}
if ($ok)
{
if($db->database_selected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";
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>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name));
$ok=0;
}
}
if ($ok)
{
if($db->database_selected == 1)
{
print '<tr><td nowrap="nowrap">';
print $langs->trans("DatabaseConnection")." : ".$dolibarr_main_db_name."</td><td align=\"right\">".$langs->trans("OK")."</td></tr>\n";
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>\n";
dolibarr_install_syslog("upgrade: ".$langs->transnoentities("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("upgrade: ".$langs->transnoentities("ServerVersion")." : $version");
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
}
// 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->transnoentities("ServerVersion")." : $version");
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
}
// Force l'affichage de la progression
print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
flush();
// Force l'affichage de la progression
print '<tr><td colspan="2">'.$langs->trans("PleaseBePatient").'</td></tr>';
flush();
/*
* Delete duplicates in table categorie_association
*/
$couples=array();
$filles=array();
$sql = "SELECT fk_categorie_mere, fk_categorie_fille";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
$resql = $db->query($sql);
if ($resql)
{
$num=$db->num_rows($resql);
while ($obj=$db->fetch_object($resql))
{
if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
{
if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
{
$filles[$obj->fk_categorie_fille]=1; // Set record for this child
$couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
}
}
}
/*
* Delete duplicates in table categorie_association
*/
$couples=array();
$filles=array();
$sql = "SELECT fk_categorie_mere, fk_categorie_fille";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: search duplicate sql=".$sql);
$resql = $db->query($sql);
if ($resql)
{
$num=$db->num_rows($resql);
while ($obj=$db->fetch_object($resql))
{
if (! isset($filles[$obj->fk_categorie_fille])) // Only one record as child (a child has only on parent).
{
if ($obj->fk_categorie_mere != $obj->fk_categorie_fille)
{
$filles[$obj->fk_categorie_fille]=1; // Set record for this child
$couples[$obj->fk_categorie_mere.'_'.$obj->fk_categorie_fille]=array('mere'=>$obj->fk_categorie_mere, 'fille'=>$obj->fk_categorie_fille);
}
}
}
dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
dolibarr_install_syslog("upgrade: result is num=".$num." count(couples)=".count($couples));
// If there is duplicates couples or child with two parents
if (count($couples) > 0 && $num > count($couples))
{
$error=0;
// If there is duplicates couples or child with two parents
if (count($couples) > 0 && $num > count($couples))
{
$error=0;
$db->begin();
$db->begin();
$sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: delete association sql=".$sql);
$resqld=$db->query($sql);
if ($resqld)
{
foreach($couples as $key => $val)
{
$sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
$sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
dolibarr_install_syslog("upgrade: insert association sql=".$sql);
$resqli=$db->query($sql);
if (! $resqli) $error++;
}
}
$sql="DELETE FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_install_syslog("upgrade: delete association sql=".$sql);
$resqld=$db->query($sql);
if ($resqld)
{
foreach($couples as $key => $val)
{
$sql ="INSERT INTO ".MAIN_DB_PREFIX."categorie_association(fk_categorie_mere,fk_categorie_fille)";
$sql.=" VALUES(".$val['mere'].", ".$val['fille'].")";
dolibarr_install_syslog("upgrade: insert association sql=".$sql);
$resqli=$db->query($sql);
if (! $resqli) $error++;
}
}
if (! $error)
{
print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
print '<td align="right">'.$langs->trans("Success").' ('.$num.'=>'.count($couples).')</td></tr>';
$db->commit();
}
else
{
print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
print '<td align="right">'.$langs->trans("Failed").'</td></tr>';
$db->rollback();
}
}
}
else
{
print '<div class="error">'.$langs->trans("Error").'</div>';
}
if (! $error)
{
print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
print '<td align="right">'.$langs->trans("Success").' ('.$num.'=>'.count($couples).')</td></tr>';
$db->commit();
}
else
{
print '<tr><td>'.$langs->trans("RemoveDuplicates").'</td>';
print '<td align="right">'.$langs->trans("Failed").'</td></tr>';
$db->rollback();
}
}
}
else
{
print '<div class="error">'.$langs->trans("Error").'</div>';
}
/*
* Remove deprecated indexes and constraints for Mysql
*/
if ($ok && preg_match('/mysql/',$db->type))
{
$versioncommande=explode('.','4.0');
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0) // Si mysql >= 4.0
{
// Suppression vieilles contraintes sans noms et en doubles
// Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999
$listtables=array( 'llx_adherent_options',
/*
* Remove deprecated indexes and constraints for Mysql
*/
if ($ok && preg_match('/mysql/',$db->type))
{
$versioncommande=explode('.','4.0');
if (count($versioncommande) && count($versionarray)
&& versioncompare($versioncommande,$versionarray) <= 0) // Si mysql >= 4.0
{
// Suppression vieilles contraintes sans noms et en doubles
// Les contraintes indesirables ont un nom qui commence par 0_ ou se termine par ibfk_999
$listtables=array( 'llx_adherent_options',
'llx_bank_class',
'llx_c_ecotaxe',
'llx_c_methode_commande_fournisseur', // table renamed
'llx_c_input_method');
$listtables = $db->DDLListTables($conf->db->name,'');
foreach ($listtables as $val)
{
//print "x".$val."<br>";
$sql = "SHOW CREATE TABLE ".$val;
$resql = $db->query($sql);
if ($resql)
{
$values=$db->fetch_array($resql);
$i=0;
$createsql=$values[1];
while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i',$createsql,$reg) && $i < 100)
{
$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
$resqldrop = $db->query($sqldrop);
if ($resqldrop)
{
print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
}
$createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i','XXX',$createsql);
$i++;
}
$db->free($resql);
}
else
{
if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
{
print '<tr><td colspan="2"><font class="error">'.$sql.' : '.$db->lasterror()."</font></td></tr>\n";
}
}
}
}
}
$listtables = $db->DDLListTables($conf->db->name,'');
foreach ($listtables as $val)
{
//print "x".$val."<br>";
$sql = "SHOW CREATE TABLE ".$val;
$resql = $db->query($sql);
if ($resql)
{
$values=$db->fetch_array($resql);
$i=0;
$createsql=$values[1];
while (preg_match('/CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`/i',$createsql,$reg) && $i < 100)
{
$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
$resqldrop = $db->query($sqldrop);
if ($resqldrop)
{
print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
}
$createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i','XXX',$createsql);
$i++;
}
$db->free($resql);
}
else
{
if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
{
print '<tr><td colspan="2"><font class="error">'.$sql.' : '.$db->lasterror()."</font></td></tr>\n";
}
}
}
}
}
/*
* Load sql files
*/
if ($ok)
{
$dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
/*
* Load sql files
*/
if ($ok)
{
$dir = "mysql/migration/"; // We use mysql migration scripts whatever is database driver
$filelist=array();
$i = 0;
$ok = 0;
$from='^'.$versionfrom;
$to=$versionto.'\.sql$';
$filelist=array();
$i = 0;
$ok = 0;
$from='^'.$versionfrom;
$to=$versionto.'\.sql$';
// Get files list
$filesindir=array();
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
}
sort($filesindir);
}
else
{
print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$dir).'</div>';
}
// Get files list
$filesindir=array();
$handle=opendir($dir);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (preg_match('/\.sql$/i',$file)) $filesindir[]=$file;
}
sort($filesindir);
}
else
{
print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$dir).'</div>';
}
// Define which file to run
foreach($filesindir as $file)
{
if (preg_match('/'.$from.'/i',$file))
{
$filelist[]=$file;
}
else if (preg_match('/'.$to.'/i',$file)) // First test may be false if we migrate from x.y.* to x.y.*
{
$filelist[]=$file;
}
}
// Define which file to run
foreach($filesindir as $file)
{
if (preg_match('/'.$from.'/i',$file))
{
$filelist[]=$file;
}
else if (preg_match('/'.$to.'/i',$file)) // First test may be false if we migrate from x.y.* to x.y.*
{
$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>'."\n";
// Boucle sur chaque fichier
foreach($filelist as $file)
{
print '<tr><td nowrap>';
print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>'."\n";
$name = substr($file, 0, dol_strlen($file) - 4);
$name = substr($file, 0, dol_strlen($file) - 4);
// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);
}
}
// Run sql script
$ok=run_sql($dir.$file, 0, '', 1);
}
}
print '</table>';
print '</table>';
if ($db->connected) $db->close();
if ($db->connected) $db->close();
}

File diff suppressed because it is too large Load Diff