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",
"errors"));
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 print
img_picto(
'',
'warning',
'class="pictofixedwidth error"');
266 print $langs->trans(
"ErrorPHPDoesNotSupport",
'<b>'.implode(
', ', $extensionko).
'</b>').
"<br>\n";
271$memrequiredorig =
'64M';
272$memrequired = 64 * 1024 * 1024;
273$memmaxorig = @ini_get(
"memory_limit");
274$memmax = @ini_get(
"memory_limit");
275if ($memmaxorig !=
'') {
277 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
279 if (strtoupper($reg[2]) ==
'G') {
280 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
282 if (strtoupper($reg[2]) ==
'M') {
283 $memmax = (int) $reg[1] * 1024 * 1024;
285 if (strtoupper($reg[2]) ==
'K') {
286 $memmax = (int) $reg[1] * 1024;
289 if ($memmax >= $memrequired || $memmax == -1) {
290 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
291 print $langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
293 print
img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
294 print $langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
308 $allowupgrade =
true;
310 $allowupgrade =
false;
327 @fwrite($fp,
'<?php');
336 $allowupgrade =
false;
342 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
343 print $langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
344 print
'<br><br><div class="error">';
345 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
346 print
'</div><br><br>'.
"\n";
348 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
352 print
img_picto(
'',
'warning',
'class="pictofixedwidth error"');
353 print $langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
359 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
360 print $langs->trans(
"ConfFileExists", $conffiletoshow);
362 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
363 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
366 print
img_picto(
'',
'tick',
'class="pictofixedwidth warning"');
367 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
374 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
375 print $langs->trans(
"ConfFileExists", $conffiletoshow);
377 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
378 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
381 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
382 print $langs->trans(
"ConfFileIsWritable", $conffiletoshow);
393 $validfoundconf =
false;
398 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
399 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
400 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";
401 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);
403 $validfoundconf =
true;
405 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
408 if (preg_match(
'/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
409 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
410 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
411 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
412 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
413 } elseif (preg_match(
'/dolcrypt:/i', $dolibarr_main_db_pass)) {
414 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
415 $dolibarr_main_db_pass =
dolDecrypt($dolibarr_main_db_pass);
417 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
422 $conf->db->type = $dolibarr_main_db_type;
423 $conf->db->host = $dolibarr_main_db_host;
424 $conf->db->port = $dolibarr_main_db_port;
425 $conf->db->name = $dolibarr_main_db_name;
426 $conf->db->user = $dolibarr_main_db_user;
427 $conf->db->pass = $dolibarr_main_db_pass;
430 if (
$db->connected &&
$db->database_selected) {
437 $dolibarrlastupgradeversionarray = array();
439 if (
$db !==
null && $ok) {
440 if (empty($dolibarr_main_db_encryption)) {
441 $dolibarr_main_db_encryption = 0;
443 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
444 if (empty($dolibarr_main_db_cryptkey)) {
445 $dolibarr_main_db_cryptkey =
'';
447 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
451 if (defined(
'SYSLOG_FILE')) {
452 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
454 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
460 } elseif ($validfoundconf) {
461 print
'Failed to connect with data found in the current conf.php file.<br>';
466 print $langs->trans(
"VersionLastUpgrade").
' <b><span class="badge-text okinversed">'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE',
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL')).
'</span></b> - ';
467 print $langs->trans(
"VersionProgram").
' <b><span class="badge-text okinversed">'.DOL_VERSION.
'</span></b>';
476 print
'<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
477 print
'<span class="soustitre valignmiddle">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
479 $foundrecommandedchoice = 0;
481 $available_choices = array();
482 $notavailable_choices = array();
484 if (empty($dolibarr_main_db_host)) {
485 $foundrecommandedchoice = 1;
489 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
490 $choice .=
'<td class="nowrap center firstcolumn"><b>'.$langs->trans(
"FreshInstall").
'</b>';
492 $choice .=
'<td class="listofchoicesdesc">';
493 $choice .= $langs->trans(
"FreshInstallDesc");
494 if (empty($dolibarr_main_db_host)) {
497 $choice .=
'<div class="><br>';
498 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
503 $choice .=
'<td class="center lastcolumn">';
505 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
507 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
509 $choice .=
'</td>'.
"\n";
510 $choice .=
'</tr>'.
"\n";
512 $positionkey = ($foundrecommandedchoice ? 999 : 0);
514 $available_choices[$positionkey] = $choice;
516 $notavailable_choices[$positionkey] = $choice;
520 $allowupgrade =
true;
521 if (empty($dolibarr_main_db_host)) {
522 $allowupgrade =
false;
525 $allowupgrade =
false;
528 $allowupgrade =
true;
531 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
535 $migrationscript = array();
536 $handle = opendir($dir);
537 if (is_resource($handle)) {
538 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
539 while (($file = readdir($handle)) !==
false) {
541 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
543 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
544 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
548 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
550 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
554 foreach ($migrationscript as $migarray) {
556 $recommended_choice =
false;
557 $version = DOL_VERSION;
558 $versionfrom = $migarray[
'from'];
559 $versionto = $migarray[
'to'];
560 $versionarray = preg_split(
'/[\.-]/', $version);
561 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
562 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
564 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
565 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
566 $newversionfrombis =
'';
567 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
568 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
572 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) {
574 if ($allowupgrade && empty($foundrecommandedchoice) &&
575 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
577 $foundrecommandedchoice = 1;
578 $recommended_choice =
true;
588 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
589 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
590 $choice .=
'<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans(
"Upgrade").
'</span><br><b>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
591 $choice .=
'<td class="listofchoicesdesc">';
592 $choice .= $langs->trans(
"UpgradeDesc");
594 if ($recommended_choice) {
597 $choice .=
'<div class=""><br>';
598 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
599 if ($count < count($migarray)) {
600 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
606 $choice .=
'<td class="center lastcolumn">';
609 if ($foundrecommandedchoice == 2) {
612 if ($foundrecommandedchoice == 1) {
613 $foundrecommandedchoice = 2;
616 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
618 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'"';
619 if ($recommended_choice) {
620 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"InstallChoiceSuggested")).
'"';
622 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"MigrationAlreadyDone")).
'"';
625 $choice .= $langs->trans(
"Start");
629 $choice .= $langs->trans(
"NotAvailable");
632 $choice .=
'</tr>'.
"\n";
634 if ($allowupgrade && $recommended_choice) {
635 $available_choices[$count] = $choice;
637 $notavailable_choices[$count] = $choice;
642 if (empty($available_choices)) {
643 $available_choices = $notavailable_choices;
644 $notavailable_choices = array();
648 krsort($available_choices, SORT_NATURAL);
650 print
'<table width="100%" class="listofchoices">';
651 foreach ($available_choices as $choice) {
655 print
'</table>'.
"\n";
657 if (count($notavailable_choices)) {
658 print
'<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
659 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
662 print
'<div id="navail_choices" style="display:none">';
664 print
'<table class="centpercent listofchoices">';
665 foreach ($notavailable_choices as $choice) {
669 print
'</table>'.
"\n";
675print
'<script type="text/javascript">
677$("div#AShowChoices").click(function() {
679 $("div#navail_choices").toggle();
681 if ($("div#navail_choices").css("display") == "none") {
682 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv(
'ShowNotAvailableOptions')).
'...\');
684 $(this).text(\'> '.
dol_escape_js($langs->transnoentitiesnoconv(
'HideNotAvailableOptions')).
'...\');
690$(".runupgrade").click(function() {
691 return confirm("'.
dol_escape_js($langs->transnoentitiesnoconv(
"WarningUpgrade"), 0, 1).
'");
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,...
dol_is_dir($folder)
Test if filename is a directory.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
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.
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.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.