32define(
'ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
33include_once
'inc.php';
56@phan-var-force string $lockfile
57@phan-var-force string $lockfile2
65$setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
66$langs->setDefaultLang($setuplang);
68$langs->loadLangs(array(
"install",
"admin"));
71$useforcedwizard =
false;
72$forcedfile =
"./install.forced.php";
73if (
$conffile ==
"/etc/dolibarr/conf.php") {
74 $forcedfile =
"/etc/dolibarr/install.forced.php";
76if (@file_exists($forcedfile)) {
77 $useforcedwizard =
true;
78 include_once $forcedfile;
91print
'<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
92print
'<span class="inline-block valignmiddle">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
95$useragent = $_SERVER[
'HTTP_USER_AGENT'] ??
'';
96if (!empty($useragent)) {
98 $browserversion = $tmp[
'browserversion'];
99 $browsername = $tmp[
'browsername'];
100 if ($browsername ==
'ie' && $browserversion < 7) {
101 print img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
102 print $langs->trans(
"WarningBrowserTooOld").
"<br>\n";
108$arrayphpminversionerror = array(7, 1, 0);
109$arrayphpminversionwarning = array(7, 2, 0);
111 print img_picto(
'',
'warning',
'class="pictofixedwidth error"');
112 print $langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
115 print img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
116 print $langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
119 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
122if (empty($force_install_nophpinfo) && (!file_exists($lockfile) && !file_exists($lockfile2))) {
123 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">';
124 $conf->use_javascript_ajax = 1;
131$arrayphpmaxversionwarning = array(8, 5, 0);
133 print img_picto(
'',
'warning',
'class="pictofixedwidth error"');
134 print $langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
141if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
142 print img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
143 print $langs->trans(
"PHPSupportPOSTGETKo");
144 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
148 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
149 print $langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
154if (!function_exists(
"session_id")) {
155 print img_picto(
'',
'warning',
'class="pictofixedwidth error"');
156 print $langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
159 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
160 print $langs->trans(
"PHPSupportSessions").
"<br>\n";
163$extensionok = array();
164$extensionko = array();
167if (!extension_loaded(
"mbstring")) {
168 $extensionko[] =
'MBString';
171 $extensionok[] =
'MBString';
175if (!extension_loaded(
"json")) {
176 $extensionko[] =
'JSON';
179 $extensionok[] =
'JSON';
183if (!function_exists(
"imagecreate")) {
184 $extensionko[] =
'GD';
187 $extensionok[] =
'GD';
191if (!function_exists(
"curl_init")) {
192 $extensionko[] =
'Curl';
195 $extensionok[] =
'Curl';
199if (!function_exists(
"easter_date")) {
200 $extensionko[] =
'Calendar';
202 $extensionok[] =
'Calendar';
206if (!function_exists(
"simplexml_load_string")) {
207 $extensionko[] =
'Xml';
210 $extensionok[] =
'Xml';
214if (!extension_loaded(
"dom")) {
215 $langs->load(
"errors");
216 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle paddingright"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Dom").
"<br>\n";
219 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle paddingright"> '.$langs->trans(
"PHPSupport",
"Dom").
"<br>\n";
223if (!function_exists(
"utf8_encode")) {
224 $extensionko[] =
'UTF8';
227 $extensionok[] =
'UTF8';
231if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
232 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
233 $extensionko[] =
'Intl';
236 $extensionok[] =
'Intl';
241if (PHP_VERSION_ID <= 80300) {
242 if (!function_exists(
"imap_open")) {
243 $extensionko[] =
'IMAP';
246 $extensionok[] =
'IMAP';
251if (!class_exists(
'ZipArchive')) {
252 $extensionko[] =
'ZIP';
255 $extensionok[] =
'ZIP';
258if (!empty($extensionok)) {
260 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
261 print $langs->trans(
"PHPSupport",
'<b>'.implode(
', ', $extensionok).
'</b>').
"<br>\n";
263if (!empty($extensionko)) {
265 $langs->load(
'errors');
266 print img_picto(
'',
'warning',
'class="pictofixedwidth error"');
267 print $langs->trans(
"ErrorPHPDoesNotSupport",
'<b>'.implode(
', ', $extensionko).
'</b>').
"<br>\n";
272$memrequiredorig =
'64M';
273$memrequired = 64 * 1024 * 1024;
274$memmaxorig = @ini_get(
"memory_limit");
275$memmax = @ini_get(
"memory_limit");
276if ($memmaxorig !=
'') {
278 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
280 if (strtoupper($reg[2]) ==
'G') {
281 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
283 if (strtoupper($reg[2]) ==
'M') {
284 $memmax = (int) $reg[1] * 1024 * 1024;
286 if (strtoupper($reg[2]) ==
'K') {
287 $memmax = (int) $reg[1] * 1024;
290 if ($memmax >= $memrequired || $memmax == -1) {
291 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
292 print $langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
294 print img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
295 print $langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
309 $allowupgrade =
true;
311 $allowupgrade =
false;
328 @fwrite($fp,
'<?php');
337 $allowupgrade =
false;
343 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
344 print $langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
345 print
'<br><br><div class="error">';
346 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
347 print
'</div><br><br>'.
"\n";
349 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
353 print img_picto(
'',
'warning',
'class="pictofixedwidth error"');
354 print $langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
360 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
361 print $langs->trans(
"ConfFileExists", $conffiletoshow);
363 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
364 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
367 print img_picto(
'',
'tick',
'class="pictofixedwidth warning"');
368 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
375 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
376 print $langs->trans(
"ConfFileExists", $conffiletoshow);
378 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
379 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
382 print img_picto(
'',
'tick',
'class="pictofixedwidth"');
383 print $langs->trans(
"ConfFileIsWritable", $conffiletoshow);
394 $validfoundconf =
false;
399 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
400 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
401 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";
402 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);
404 $validfoundconf =
true;
406 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
409 if (preg_match(
'/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
410 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
411 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
412 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
413 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
414 } elseif (preg_match(
'/dolcrypt:/i', $dolibarr_main_db_pass)) {
415 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
416 $dolibarr_main_db_pass =
dolDecrypt($dolibarr_main_db_pass);
418 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
423 $conf->db->type = $dolibarr_main_db_type;
424 $conf->db->host = $dolibarr_main_db_host;
425 $conf->db->port = $dolibarr_main_db_port;
426 $conf->db->name = $dolibarr_main_db_name;
427 $conf->db->user = $dolibarr_main_db_user;
428 $conf->db->pass = $dolibarr_main_db_pass;
431 if ($db->connected && $db->database_selected) {
438 $dolibarrlastupgradeversionarray = array();
440 if ($db !==
null && $ok) {
441 if (empty($dolibarr_main_db_encryption)) {
442 $dolibarr_main_db_encryption = 0;
444 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
445 if (empty($dolibarr_main_db_cryptkey)) {
446 $dolibarr_main_db_cryptkey =
'';
448 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
450 $conf->setValues($db);
452 if (defined(
'SYSLOG_FILE')) {
453 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
455 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
461 } elseif ($validfoundconf) {
462 print
'Failed to connect with data found in the current conf.php file.<br>';
467 print $langs->trans(
"VersionLastUpgrade").
' <b><span class="badge-text okinversed">'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE',
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL')).
'</span></b> - ';
468 print $langs->trans(
"VersionProgram").
' <b><span class="badge-text okinversed">'.DOL_VERSION.
'</span></b>';
477 print
'<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
478 print
'<span class="soustitre valignmiddle">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
480 $foundrecommandedchoice = 0;
482 $available_choices = array();
483 $notavailable_choices = array();
485 if (empty($dolibarr_main_db_host)) {
486 $foundrecommandedchoice = 1;
490 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
491 $choice .=
'<td class="nowrap center firstcolumn"><b>'.$langs->trans(
"FreshInstall").
'</b>';
493 $choice .=
'<td class="listofchoicesdesc">';
494 if (empty($dolibarr_main_db_host)) {
496 $choice .=
'<div class=">';
497 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
499 $choice .=
'<br><br>';
502 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"FreshInstallDesc").
'</span>';
505 $choice .=
'<td class="center lastcolumn">';
507 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
509 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
511 $choice .=
'</td>'.
"\n";
512 $choice .=
'</tr>'.
"\n";
514 $positionkey = ($foundrecommandedchoice ? 999 : 0);
516 $available_choices[$positionkey] = $choice;
518 $notavailable_choices[$positionkey] = $choice;
522 $allowupgrade =
true;
523 if (empty($dolibarr_main_db_host)) {
524 $allowupgrade =
false;
527 $allowupgrade =
false;
530 $allowupgrade =
true;
533 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
537 $migrationscript = array();
538 $handle = opendir($dir);
539 if (is_resource($handle)) {
540 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
541 while (($file = readdir($handle)) !==
false) {
543 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
545 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
546 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
550 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
552 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
556 foreach ($migrationscript as $migarray) {
558 $recommended_choice =
false;
559 $version = DOL_VERSION;
560 $versionfrom = $migarray[
'from'];
561 $versionto = $migarray[
'to'];
562 $versionarray = preg_split(
'/[\.-]/', $version);
563 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
564 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
566 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
567 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
568 $newversionfrombis =
'';
569 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
570 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
574 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) {
576 if ($allowupgrade && empty($foundrecommandedchoice) &&
577 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
579 $foundrecommandedchoice = 1;
580 $recommended_choice =
true;
590 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
591 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
592 $choice .=
'<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans(
"Upgrade").
'</span><br><b>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
593 $choice .=
'<td class="listofchoicesdesc">';
595 if ($recommended_choice) {
597 $choice .=
'<div class="">';
598 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
599 if ($count < count($migarray)) {
600 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
602 $choice .=
'</div><br><br>';
605 $choice .=
'<span class="opacitymedium">';
606 $choice .= $langs->trans(
"UpgradeDesc");
607 $choice .=
'</span>';
610 $choice .=
'<td class="center lastcolumn">';
613 if ($foundrecommandedchoice == 2) {
616 if ($foundrecommandedchoice == 1) {
617 $foundrecommandedchoice = 2;
620 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
622 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'"';
623 if ($recommended_choice) {
624 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"InstallChoiceSuggested")).
'"';
626 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"MigrationAlreadyDone")).
'"';
629 $choice .= $langs->trans(
"Start");
633 $choice .= $langs->trans(
"NotAvailable");
636 $choice .=
'</tr>'.
"\n";
638 if ($allowupgrade && $recommended_choice) {
639 $available_choices[$count] = $choice;
641 $notavailable_choices[$count] = $choice;
646 if (empty($available_choices)) {
647 $available_choices = $notavailable_choices;
648 $notavailable_choices = array();
652 krsort($available_choices, SORT_NATURAL);
654 print
'<table class="centpercent listofchoices">';
655 foreach ($available_choices as $choice) {
659 print
'</table>'.
"\n";
661 if (count($notavailable_choices)) {
662 print
'<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
663 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
666 print
'<div id="navail_choices" style="display:none">';
668 print
'<table class="centpercent listofchoices">';
669 foreach ($notavailable_choices as $choice) {
673 print
'</table>'.
"\n";
679print
'<script type="text/javascript">
681$("div#AShowChoices").click(function() {
683 $("div#navail_choices").toggle();
685 if ($("div#navail_choices").css("display") == "none") {
686 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv(
'ShowNotAvailableOptions')).
'...\');
688 $(this).text(\'> '.
dol_escape_js($langs->transnoentitiesnoconv(
'HideNotAvailableOptions')).
'...\');
694$(".runupgrade").click(function() {
695 return confirm(\''.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'\');
701dolibarr_install_syslog("- check: end");
702pFooter(1); // Never display next button
versiontostring($versionarray)
Return a version in a string from a version into an array.
versiondolibarrarray()
Return version Dolibarr.
versionphparray()
Return version PHP.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_is_dir($folder)
Test if filename is a directory.
getDoliDBInstance($type, $host, $user, $pass, $name, $port, $forcenew=false)
Return a DoliDB instance (database handler).
getDolGlobalInt($key, $default=0)
Return a 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 the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getBrowserInfo($user_agent)
Return information about user browser.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
pHeader($subtitle, $next, $action='set', $param='', $forcejqueryurl='', $csstable='main-inside')
Show HTML header 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.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.