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 (!function_exists(
"utf8_encode")) {
215 $extensionko[] =
'UTF8';
218 $extensionok[] =
'UTF8';
222if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
223 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
224 $extensionko[] =
'Intl';
227 $extensionok[] =
'Intl';
232if (PHP_VERSION_ID <= 80300) {
233 if (!function_exists(
"imap_open")) {
234 $extensionko[] =
'IMAP';
237 $extensionok[] =
'IMAP';
242if (!class_exists(
'ZipArchive')) {
243 $extensionko[] =
'ZIP';
246 $extensionok[] =
'ZIP';
249if (!empty($extensionok)) {
251 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
252 print $langs->trans(
"PHPSupport",
'<b>'.implode(
', ', $extensionok).
'</b>').
"<br>\n";
254if (!empty($extensionko)) {
256 print
img_picto(
'',
'warning',
'class="pictofixedwidth error"');
257 print $langs->trans(
"ErrorPHPDoesNotSupport",
'<b>'.implode(
', ', $extensionko).
'</b>').
"<br>\n";
262$memrequiredorig =
'64M';
263$memrequired = 64 * 1024 * 1024;
264$memmaxorig = @ini_get(
"memory_limit");
265$memmax = @ini_get(
"memory_limit");
266if ($memmaxorig !=
'') {
268 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
270 if (strtoupper($reg[2]) ==
'G') {
271 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
273 if (strtoupper($reg[2]) ==
'M') {
274 $memmax = (int) $reg[1] * 1024 * 1024;
276 if (strtoupper($reg[2]) ==
'K') {
277 $memmax = (int) $reg[1] * 1024;
280 if ($memmax >= $memrequired || $memmax == -1) {
281 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
282 print $langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
284 print
img_picto(
'',
'warning',
'class="pictofixedwidth warning"');
285 print $langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
299 $allowupgrade =
true;
301 $allowupgrade =
false;
318 @fwrite($fp,
'<?php');
327 $allowupgrade =
false;
333 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle pictofixedwidth"> ';
334 print $langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
335 print
'<br><br><div class="error">';
336 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
337 print
'</div><br><br>'.
"\n";
339 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
343 print
img_picto(
'',
'warning',
'class="pictofixedwidth error"');
344 print $langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
350 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
351 print $langs->trans(
"ConfFileExists", $conffiletoshow);
353 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
354 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
357 print
img_picto(
'',
'tick',
'class="pictofixedwidth warning"');
358 print $langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
365 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
366 print $langs->trans(
"ConfFileExists", $conffiletoshow);
368 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
369 print $langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
372 print
img_picto(
'',
'tick',
'class="pictofixedwidth"');
373 print $langs->trans(
"ConfFileIsWritable", $conffiletoshow);
384 $validfoundconf =
false;
389 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
390 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
391 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";
392 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);
394 $validfoundconf =
true;
396 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
399 if (preg_match(
'/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
400 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
401 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
402 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
403 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
404 } elseif (preg_match(
'/dolcrypt:/i', $dolibarr_main_db_pass)) {
405 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
406 $dolibarr_main_db_pass =
dolDecrypt($dolibarr_main_db_pass);
408 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
413 $conf->db->type = $dolibarr_main_db_type;
414 $conf->db->host = $dolibarr_main_db_host;
415 $conf->db->port = $dolibarr_main_db_port;
416 $conf->db->name = $dolibarr_main_db_name;
417 $conf->db->user = $dolibarr_main_db_user;
418 $conf->db->pass = $dolibarr_main_db_pass;
421 if (
$db->connected &&
$db->database_selected) {
428 $dolibarrlastupgradeversionarray = array();
430 if (
$db !==
null && $ok) {
431 if (empty($dolibarr_main_db_encryption)) {
432 $dolibarr_main_db_encryption = 0;
434 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
435 if (empty($dolibarr_main_db_cryptkey)) {
436 $dolibarr_main_db_cryptkey =
'';
438 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
442 if (defined(
'SYSLOG_FILE')) {
443 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
445 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
451 } elseif ($validfoundconf) {
452 print
'Failed to connect with data found int the current conf.php file.<br>';
457 print $langs->trans(
"VersionLastUpgrade").
' <b><span class="badge-text okinversed">'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE',
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL')).
'</span></b> - ';
458 print $langs->trans(
"VersionProgram").
' <b><span class="badge-text okinversed">'.DOL_VERSION.
'</span></b>';
467 print
'<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
468 print
'<span class="soustitre valignmiddle">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
470 $foundrecommandedchoice = 0;
472 $available_choices = array();
473 $notavailable_choices = array();
475 if (empty($dolibarr_main_db_host)) {
476 $foundrecommandedchoice = 1;
480 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
481 $choice .=
'<td class="nowrap center firstcolumn"><b>'.$langs->trans(
"FreshInstall").
'</b>';
483 $choice .=
'<td class="listofchoicesdesc">';
484 $choice .= $langs->trans(
"FreshInstallDesc");
485 if (empty($dolibarr_main_db_host)) {
488 $choice .=
'<div class="><br>';
489 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
494 $choice .=
'<td class="center lastcolumn">';
496 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
498 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
500 $choice .=
'</td>'.
"\n";
501 $choice .=
'</tr>'.
"\n";
503 $positionkey = ($foundrecommandedchoice ? 999 : 0);
505 $available_choices[$positionkey] = $choice;
507 $notavailable_choices[$positionkey] = $choice;
511 $allowupgrade =
true;
512 if (empty($dolibarr_main_db_host)) {
513 $allowupgrade =
false;
516 $allowupgrade =
false;
519 $allowupgrade =
true;
522 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
526 $migrationscript = array();
527 $handle = opendir($dir);
528 if (is_resource($handle)) {
529 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
530 while (($file = readdir($handle)) !==
false) {
532 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
534 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
535 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
539 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
541 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
545 foreach ($migrationscript as $migarray) {
547 $recommended_choice =
false;
548 $version = DOL_VERSION;
549 $versionfrom = $migarray[
'from'];
550 $versionto = $migarray[
'to'];
551 $versionarray = preg_split(
'/[\.-]/', $version);
552 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
553 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
555 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
556 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
557 $newversionfrombis =
'';
558 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
559 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
563 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) {
565 if ($allowupgrade && empty($foundrecommandedchoice) &&
566 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
568 $foundrecommandedchoice = 1;
569 $recommended_choice =
true;
579 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
580 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
581 $choice .=
'<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans(
"Upgrade").
'</span><br><b>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
582 $choice .=
'<td class="listofchoicesdesc">';
583 $choice .= $langs->trans(
"UpgradeDesc");
585 if ($recommended_choice) {
588 $choice .=
'<div class=""><br>';
589 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
590 if ($count < count($migarray)) {
591 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
597 $choice .=
'<td class="center lastcolumn">';
600 if ($foundrecommandedchoice == 2) {
603 if ($foundrecommandedchoice == 1) {
604 $foundrecommandedchoice = 2;
607 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
609 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'"';
610 if ($recommended_choice) {
611 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"InstallChoiceSuggested")).
'"';
613 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"MigrationAlreadyDone")).
'"';
616 $choice .= $langs->trans(
"Start");
620 $choice .= $langs->trans(
"NotAvailable");
623 $choice .=
'</tr>'.
"\n";
625 if ($allowupgrade && $recommended_choice) {
626 $available_choices[$count] = $choice;
628 $notavailable_choices[$count] = $choice;
633 if (empty($available_choices)) {
634 $available_choices = $notavailable_choices;
635 $notavailable_choices = array();
639 krsort($available_choices, SORT_NATURAL);
641 print
'<table width="100%" class="listofchoices">';
642 foreach ($available_choices as $choice) {
646 print
'</table>'.
"\n";
648 if (count($notavailable_choices)) {
649 print
'<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
650 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
653 print
'<div id="navail_choices" style="display:none">';
655 print
'<table class="centpercent listofchoices">';
656 foreach ($notavailable_choices as $choice) {
660 print
'</table>'.
"\n";
666print
'<script type="text/javascript">
668$("div#AShowChoices").click(function() {
670 $("div#navail_choices").toggle();
672 if ($("div#navail_choices").css("display") == "none") {
673 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv(
'ShowNotAvailableOptions')).
'...\');
675 $(this).text(\'> '.
dol_escape_js($langs->transnoentitiesnoconv(
'HideNotAvailableOptions')).
'...\');
681$(".runupgrade").click(function() {
682 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...
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.
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.