30 include_once
'inc.php';
36 $allowupgrade =
false;
39 $setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
40 $langs->setDefaultLang($setuplang);
42 $langs->load(
"install");
45 $useforcedwizard =
false;
46 $forcedfile =
"./install.forced.php";
47 if ($conffile ==
"/etc/dolibarr/conf.php") {
48 $forcedfile =
"/etc/dolibarr/install.forced.php";
50 if (@file_exists($forcedfile)) {
51 $useforcedwizard =
true;
52 include_once $forcedfile;
68 print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
69 print
'<span class="inline-block">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
72 $useragent = $_SERVER[
'HTTP_USER_AGENT'];
73 if (!empty($useragent)) {
75 $browserversion = $tmp[
'browserversion'];
76 $browsername = $tmp[
'browsername'];
77 if ($browsername ==
'ie' && $browserversion < 7) {
78 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
84 $arrayphpminversionerror = array(5, 6, 0);
85 $arrayphpminversionwarning = array(7, 0, 0);
87 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
90 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
95 if (empty($force_install_nophpinfo)) {
96 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MoreInformation").
'</a>)';
101 $arrayphpmaxversionwarning = array(8, 1, 0);
103 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
110 if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
111 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETKo");
112 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
116 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
121 if (!function_exists(
"session_id")) {
122 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
125 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
130 if (!extension_loaded(
"mbstring")) {
131 $langs->load(
"errors");
132 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"MBString").
"<br>\n";
135 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"MBString").
"<br>\n";
139 if (!extension_loaded(
"json")) {
140 $langs->load(
"errors");
141 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"JSON").
"<br>\n";
144 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"JSON").
"<br>\n";
148 if (!function_exists(
"imagecreate")) {
149 $langs->load(
"errors");
150 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"GD").
"<br>\n";
153 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
158 if (!function_exists(
"curl_init")) {
159 $langs->load(
"errors");
160 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Curl").
"<br>\n";
163 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
167 if (!function_exists(
"easter_date")) {
168 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Calendar").
"<br>\n";
170 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
174 if (!function_exists(
"simplexml_load_string")) {
175 $langs->load(
"errors");
176 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Xml").
"<br>\n";
179 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Xml").
"<br>\n";
183 if (!function_exists(
"utf8_encode")) {
184 $langs->load(
"errors");
185 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"UTF8").
"<br>\n";
188 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
192 if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
193 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
194 $langs->load(
"errors");
195 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Intl").
"<br>\n";
198 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
203 if (!function_exists(
"imap_open")) {
204 $langs->load(
"errors");
205 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"IMAP").
"<br>\n";
208 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"IMAP").
"<br>\n";
211 if (!class_exists(
'ZipArchive')) {
212 $langs->load(
"errors");
213 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
216 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
220 $memrequiredorig =
'64M';
221 $memrequired = 64 * 1024 * 1024;
222 $memmaxorig = @ini_get(
"memory_limit");
223 $memmax = @ini_get(
"memory_limit");
224 if ($memmaxorig !=
'') {
225 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
227 if (strtoupper($reg[2]) ==
'G') {
228 $memmax = $reg[1] * 1024 * 1024 * 1024;
230 if (strtoupper($reg[2]) ==
'M') {
231 $memmax = $reg[1] * 1024 * 1024;
233 if (strtoupper($reg[2]) ==
'K') {
234 $memmax = $reg[1] * 1024;
237 if ($memmax >= $memrequired || $memmax == -1) {
238 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
240 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
247 if (is_readable($conffile) && filesize($conffile) > 8) {
250 include_once $conffile;
255 $allowupgrade =
true;
257 $allowupgrade =
false;
265 if (@copy($conffile.
".example", $conffile)) {
270 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
272 $fp = @fopen($conffile,
"w");
274 @fwrite($fp,
'<?php');
278 dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
283 $allowupgrade =
false;
289 if (!file_exists($conffile)) {
290 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
291 print
'<br><br><div class="error">';
292 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
293 print
'</div><br><br>'.
"\n";
295 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
299 print
'<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
302 } elseif (!is_writable($conffile)) {
305 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
307 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
310 print
'<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
317 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
319 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
322 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
334 if (file_exists($conffile)) {
335 include_once $conffile;
336 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
337 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
338 print
'<span class="error">A '.$conffiletoshow.
' file exists with a dolibarr_main_document_root to '.$dolibarr_main_document_root.
' that seems wrong. Try to fix or remove the '.$conffiletoshow.
' file.</span><br>'.
"\n";
339 dol_syslog(
"A '".$conffiletoshow.
"' file exists with a dolibarr_main_document_root to ".$dolibarr_main_document_root.
" that seems wrong. Try to fix or remove the '".$conffiletoshow.
"' file.", LOG_WARNING);
341 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
344 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
345 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
346 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
347 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
348 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
350 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
355 $conf->db->type = $dolibarr_main_db_type;
356 $conf->db->host = $dolibarr_main_db_host;
357 $conf->db->port = $dolibarr_main_db_port;
358 $conf->db->name = $dolibarr_main_db_name;
359 $conf->db->user = $dolibarr_main_db_user;
360 $conf->db->pass = $dolibarr_main_db_pass;
361 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
362 if ($db->connected && $db->database_selected) {
371 if (empty($dolibarr_main_db_encryption)) {
372 $dolibarr_main_db_encryption = 0;
374 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
375 if (empty($dolibarr_main_db_cryptkey)) {
376 $dolibarr_main_db_cryptkey =
'';
378 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
380 $conf->setValues($db);
382 if (defined(
'SYSLOG_FILE')) {
383 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
385 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
389 $dolibarrlastupgradeversionarray = preg_split(
'/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL :
''));
394 if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) {
395 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
396 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
405 print
'<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
407 $foundrecommandedchoice = 0;
409 $available_choices = array();
410 $notavailable_choices = array();
412 if (empty($dolibarr_main_db_host)) {
413 $foundrecommandedchoice = 1;
417 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
418 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
420 $choice .=
'<td class="listofchoicesdesc">';
421 $choice .= $langs->trans(
"FreshInstallDesc");
422 if (empty($dolibarr_main_db_host)) {
425 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
430 $choice .=
'<td class="center">';
432 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
434 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
436 $choice .=
'</td>'.
"\n";
437 $choice .=
'</tr>'.
"\n";
439 $positionkey = ($foundrecommandedchoice ? 999 : 0);
441 $available_choices[$positionkey] = $choice;
443 $notavailable_choices[$positionkey] = $choice;
447 $allowupgrade =
true;
448 if (empty($dolibarr_main_db_host)) {
449 $allowupgrade =
false;
452 $allowupgrade =
false;
455 $allowupgrade =
true;
458 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
462 $migrationscript = array();
463 $handle = opendir($dir);
464 if (is_resource($handle)) {
465 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
466 while (($file = readdir($handle)) !==
false) {
468 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
470 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
471 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
475 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
477 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
481 foreach ($migrationscript as $migarray) {
485 $recommended_choice =
false;
486 $version = DOL_VERSION;
487 $versionfrom = $migarray[
'from'];
488 $versionto = $migarray[
'to'];
489 $versionarray = preg_split(
'/[\.-]/', $version);
490 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
491 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
493 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
494 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
495 $newversionfrombis =
'';
496 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
497 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
501 if (count($dolibarrlastupgradeversionarray) >= 2) {
503 if ($allowupgrade && empty($foundrecommandedchoice) &&
504 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
506 $foundrecommandedchoice = 1;
507 $recommended_choice =
true;
515 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
516 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
517 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
518 $choice .=
'<td class="listofchoicesdesc">';
519 $choice .= $langs->trans(
"UpgradeDesc");
521 if ($recommended_choice) {
524 $choice .=
'<div class="center">';
525 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
526 if ($count < count($migarray)) {
527 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
533 $choice .=
'<td class="center">';
536 if ($foundrecommandedchoice == 2) {
539 if ($foundrecommandedchoice == 1) {
540 $foundrecommandedchoice = 2;
543 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
545 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
548 $choice .= $langs->trans(
"NotAvailable");
551 $choice .=
'</tr>'.
"\n";
554 $available_choices[$count] = $choice;
556 $notavailable_choices[$count] = $choice;
561 if (empty($available_choices)) {
562 $available_choices = $notavailable_choices;
563 $notavailable_choices = array();
567 krsort($available_choices, SORT_NATURAL);
569 print
'<table width="100%" class="listofchoices">';
570 foreach ($available_choices as $choice) {
574 print
'</table>'.
"\n";
576 if (count($notavailable_choices)) {
577 print
'<br><div id="AShowChoices" style="opacity: 0.5">';
578 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
581 print
'<div id="navail_choices" style="display:none">';
583 print
'<table width="100%" class="listofchoices">';
584 foreach ($notavailable_choices as $choice) {
588 print
'</table>'.
"\n";
594 print
'<script type="text/javascript">
596 $("div#AShowChoices").click(function() {
598 $("div#navail_choices").toggle();
600 if ($("div#navail_choices").css("display") == "none") {
601 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
603 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
609 $(".runupgrade").click(function() {
610 return confirm("'.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'");
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
versiondolibarrarray()
Return version Dolibarr.
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays).
dol_is_dir($folder)
Test if filename is a directory.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
getBrowserInfo($user_agent)
Return information about user browser.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header of install pages.
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
dol_decode($chain, $key='1')
Decode a base 64 encoded + specific delta change.