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);
383 $validfoundconf =
false;
388 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
389 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
390 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";
391 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);
393 $validfoundconf =
true;
395 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
398 if (preg_match(
'/(crypted|dolcrypt):/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
399 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
400 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
401 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
402 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
403 } elseif (preg_match(
'/dolcrypt:/i', $dolibarr_main_db_pass)) {
404 $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass;
405 $dolibarr_main_db_pass =
dolDecrypt($dolibarr_main_db_pass);
407 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
412 $conf->db->type = $dolibarr_main_db_type;
413 $conf->db->host = $dolibarr_main_db_host;
414 $conf->db->port = $dolibarr_main_db_port;
415 $conf->db->name = $dolibarr_main_db_name;
416 $conf->db->user = $dolibarr_main_db_user;
417 $conf->db->pass = $dolibarr_main_db_pass;
419 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, (
string) $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
420 if ($db->connected && $db->database_selected) {
427 $dolibarrlastupgradeversionarray = array();
430 if (empty($dolibarr_main_db_encryption)) {
431 $dolibarr_main_db_encryption = 0;
433 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
434 if (empty($dolibarr_main_db_cryptkey)) {
435 $dolibarr_main_db_cryptkey =
'';
437 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
439 $conf->setValues($db);
441 if (defined(
'SYSLOG_FILE')) {
442 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
444 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
450 } elseif ($validfoundconf) {
451 print
'Failed to connect with data found int the current conf.php file.<br>';
456 print $langs->trans(
"VersionLastUpgrade").
' <b><span class="badge-text okinversed">'.
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE',
getDolGlobalString(
'MAIN_VERSION_LAST_INSTALL')).
'</span></b> - ';
457 print $langs->trans(
"VersionProgram").
' <b><span class="badge-text okinversed">'.DOL_VERSION.
'</span></b>';
466 print
'<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/gear.svg" width="20" alt="Database"> ';
467 print
'<span class="soustitre valignmiddle">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
469 $foundrecommandedchoice = 0;
471 $available_choices = array();
472 $notavailable_choices = array();
474 if (empty($dolibarr_main_db_host)) {
475 $foundrecommandedchoice = 1;
479 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
480 $choice .=
'<td class="nowrap center firstcolumn"><b>'.$langs->trans(
"FreshInstall").
'</b>';
482 $choice .=
'<td class="listofchoicesdesc">';
483 $choice .= $langs->trans(
"FreshInstallDesc");
484 if (empty($dolibarr_main_db_host)) {
487 $choice .=
'<div class="><br>';
488 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
493 $choice .=
'<td class="center lastcolumn">';
495 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
497 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
499 $choice .=
'</td>'.
"\n";
500 $choice .=
'</tr>'.
"\n";
502 $positionkey = ($foundrecommandedchoice ? 999 : 0);
504 $available_choices[$positionkey] = $choice;
506 $notavailable_choices[$positionkey] = $choice;
510 $allowupgrade =
true;
511 if (empty($dolibarr_main_db_host)) {
512 $allowupgrade =
false;
515 $allowupgrade =
false;
518 $allowupgrade =
true;
521 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
525 $migrationscript = array();
526 $handle = opendir($dir);
527 if (is_resource($handle)) {
528 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
529 while (($file = readdir($handle)) !==
false) {
531 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
533 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
534 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
538 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
540 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
544 foreach ($migrationscript as $migarray) {
546 $recommended_choice =
false;
547 $version = DOL_VERSION;
548 $versionfrom = $migarray[
'from'];
549 $versionto = $migarray[
'to'];
550 $versionarray = preg_split(
'/[\.-]/', $version);
551 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
552 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
554 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
555 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
556 $newversionfrombis =
'';
557 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
558 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
562 if (is_array($dolibarrlastupgradeversionarray) && count($dolibarrlastupgradeversionarray) >= 2) {
564 if ($allowupgrade && empty($foundrecommandedchoice) &&
565 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
567 $foundrecommandedchoice = 1;
568 $recommended_choice =
true;
578 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
579 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
580 $choice .=
'<td class="nowrap center firstcolumn"><span class="opacitymedium">'.$langs->trans(
"Upgrade").
'</span><br><b>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
581 $choice .=
'<td class="listofchoicesdesc">';
582 $choice .= $langs->trans(
"UpgradeDesc");
584 if ($recommended_choice) {
587 $choice .=
'<div class=""><br>';
588 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
589 if ($count < count($migarray)) {
590 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
596 $choice .=
'<td class="center lastcolumn">';
599 if ($foundrecommandedchoice == 2) {
602 if ($foundrecommandedchoice == 1) {
603 $foundrecommandedchoice = 2;
606 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
608 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'"';
609 if ($recommended_choice) {
610 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"InstallChoiceSuggested")).
'"';
612 $choice .=
' title="'.dol_string_nohtmltag($langs->trans(
"MigrationAlreadyDone")).
'"';
615 $choice .= $langs->trans(
"Start");
619 $choice .= $langs->trans(
"NotAvailable");
622 $choice .=
'</tr>'.
"\n";
624 if ($allowupgrade && $recommended_choice) {
625 $available_choices[$count] = $choice;
627 $notavailable_choices[$count] = $choice;
632 if (empty($available_choices)) {
633 $available_choices = $notavailable_choices;
634 $notavailable_choices = array();
638 krsort($available_choices, SORT_NATURAL);
640 print
'<table width="100%" class="listofchoices">';
641 foreach ($available_choices as $choice) {
645 print
'</table>'.
"\n";
647 if (count($notavailable_choices)) {
648 print
'<br><div id="AShowChoices" class="opacitymedium cursorpointer">';
649 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
652 print
'<div id="navail_choices" style="display:none">';
654 print
'<table class="centpercent listofchoices">';
655 foreach ($notavailable_choices as $choice) {
659 print
'</table>'.
"\n";
665print
'<script type="text/javascript">
667$("div#AShowChoices").click(function() {
669 $("div#navail_choices").toggle();
671 if ($("div#navail_choices").css("display") == "none") {
672 $(this).text(\'> '.dol_escape_js($langs->transnoentitiesnoconv(
'ShowNotAvailableOptions')).
'...\');
674 $(this).text(\'> '.
dol_escape_js($langs->transnoentitiesnoconv(
'HideNotAvailableOptions')).
'...\');
680$(".runupgrade").click(function() {
681 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), 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='')
Decode a string with a symmetric encryption.