31define(
'ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
32include_once
'inc.php';
41$setuplang =
GETPOST(
"selectlang",
'aZ09', 3) ?
GETPOST(
"selectlang",
'aZ09', 3) : $langs->getDefaultLang();
42$langs->setDefaultLang($setuplang);
44$langs->load(
"install");
47$useforcedwizard =
false;
48$forcedfile =
"./install.forced.php";
49if ($conffile ==
"/etc/dolibarr/conf.php") {
50 $forcedfile =
"/etc/dolibarr/install.forced.php";
52if (@file_exists($forcedfile)) {
53 $useforcedwizard =
true;
54 include_once $forcedfile;
70print
'<h3><img class="valignmiddle inline-block paddingright" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
71print
'<span class="inline-block">'.$langs->trans(
"MiscellaneousChecks").
"</span></h3>\n";
74$useragent = $_SERVER[
'HTTP_USER_AGENT'];
75if (!empty($useragent)) {
77 $browserversion = $tmp[
'browserversion'];
78 $browsername = $tmp[
'browsername'];
79 if ($browsername ==
'ie' && $browserversion < 7) {
80 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"WarningBrowserTooOld").
"<br>\n";
86$arrayphpminversionerror = array(7, 0, 0);
87$arrayphpminversionwarning = array(7, 1, 0);
89 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionerror));
92 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooLow",
versiontostring($arrayphpminversionwarning));
97if (empty($force_install_nophpinfo)) {
98 print
' (<a href="phpinfo.php" target="_blank" rel="noopener noreferrer">'.$langs->trans(
"MoreInformation").
'</a>)';
103$arrayphpmaxversionwarning = array(8, 2, 0);
105 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPVersionTooHigh",
versiontostring($arrayphpmaxversionwarning));
112if (!isset($_GET[
"testget"]) && !isset($_POST[
"testpost"])) {
113 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETKo");
114 print
' (<a href="'.dol_escape_htmltag($_SERVER[
"PHP_SELF"]).
'?testget=ok">'.$langs->trans(
"Recheck").
'</a>)';
118 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportPOSTGETOk").
"<br>\n";
123if (!function_exists(
"session_id")) {
124 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupportSessions").
"<br>\n";
127 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupportSessions").
"<br>\n";
132if (!extension_loaded(
"mbstring")) {
133 $langs->load(
"errors");
134 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"MBString").
"<br>\n";
137 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"MBString").
"<br>\n";
141if (!extension_loaded(
"json")) {
142 $langs->load(
"errors");
143 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"JSON").
"<br>\n";
146 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"JSON").
"<br>\n";
150if (!function_exists(
"imagecreate")) {
151 $langs->load(
"errors");
152 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"GD").
"<br>\n";
155 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"GD").
"<br>\n";
159if (!function_exists(
"curl_init")) {
160 $langs->load(
"errors");
161 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Curl").
"<br>\n";
164 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Curl").
"<br>\n";
168if (!function_exists(
"easter_date")) {
169 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Calendar").
"<br>\n";
171 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Calendar").
"<br>\n";
175if (!function_exists(
"simplexml_load_string")) {
176 $langs->load(
"errors");
177 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Xml").
"<br>\n";
180 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Xml").
"<br>\n";
184if (!function_exists(
"utf8_encode")) {
185 $langs->load(
"errors");
186 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"UTF8").
"<br>\n";
189 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"UTF8").
"<br>\n";
193if (empty($_SERVER[
"SERVER_ADMIN"]) || $_SERVER[
"SERVER_ADMIN"] !=
'doliwamp@localhost') {
194 if (!function_exists(
"locale_get_primary_language") || !function_exists(
"locale_get_region")) {
195 $langs->load(
"errors");
196 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"Intl").
"<br>\n";
199 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"Intl").
"<br>\n";
204if (PHP_VERSION_ID <= 80300) {
205 if (!function_exists(
"imap_open")) {
206 $langs->load(
"errors");
207 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"IMAP").
"<br>\n";
210 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"IMAP").
"<br>\n";
215if (!class_exists(
'ZipArchive')) {
216 $langs->load(
"errors");
217 print
'<img src="../theme/eldy/img/warning.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ErrorPHPDoesNotSupport",
"ZIP").
"<br>\n";
220 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPSupport",
"ZIP").
"<br>\n";
224$memrequiredorig =
'64M';
225$memrequired = 64 * 1024 * 1024;
226$memmaxorig = @ini_get(
"memory_limit");
227$memmax = @ini_get(
"memory_limit");
228if ($memmaxorig !=
'') {
229 preg_match(
'/([0-9]+)([a-zA-Z]*)/i', $memmax, $reg);
231 if (strtoupper($reg[2]) ==
'G') {
232 $memmax = (int) $reg[1] * 1024 * 1024 * 1024;
234 if (strtoupper($reg[2]) ==
'M') {
235 $memmax = (int) $reg[1] * 1024 * 1024;
237 if (strtoupper($reg[2]) ==
'K') {
238 $memmax = (int) $reg[1] * 1024;
241 if ($memmax >= $memrequired || $memmax == -1) {
242 print
'<img src="../theme/eldy/img/tick.png" alt="Ok" class="valignmiddle"> '.$langs->trans(
"PHPMemoryOK", $memmaxorig, $memrequiredorig).
"<br>\n";
244 print
'<img src="../theme/eldy/img/warning.png" alt="Warning" class="valignmiddle"> '.$langs->trans(
"PHPMemoryTooLow", $memmaxorig, $memrequiredorig).
"<br>\n";
251if (is_readable($conffile) && filesize($conffile) > 8) {
254 include_once $conffile;
259 $allowupgrade =
true;
261 $allowupgrade =
false;
269 if (@copy($conffile.
".example", $conffile)) {
274 dolibarr_install_syslog(
"check: failed to copy file ".$conffile.
".example into ".$conffile.
". We try to create it.", LOG_WARNING);
276 $fp = @fopen($conffile,
"w");
278 @fwrite($fp,
'<?php');
282 dolibarr_install_syslog(
"check: failed to create a new file ".$conffile.
" into current dir ".getcwd().
". Please check permissions.", LOG_ERR);
287 $allowupgrade =
false;
293if (!file_exists($conffile)) {
294 print
'<img src="../theme/eldy/img/error.png" alt="Error" class="valignmiddle"> '.$langs->trans(
"ConfFileDoesNotExistsAndCouldNotBeCreated", $conffiletoshow);
295 print
'<br><br><div class="error">';
296 print $langs->trans(
"YouMustCreateWithPermission", $conffiletoshow);
297 print
'</div><br><br>'.
"\n";
299 print
'<span class="opacitymedium">'.$langs->trans(
"CorrectProblemAndReloadPage", $_SERVER[
'PHP_SELF'].
'?testget=ok').
'</span>';
303 print
'<img src="../theme/eldy/img/error.png" alt="Warning"> '.$langs->trans(
"ConfFileMustBeAFileNotADir", $conffiletoshow);
306 } elseif (!is_writable($conffile)) {
309 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
311 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
314 print
'<img src="../theme/eldy/img/tick.png" alt="Warning"> '.$langs->trans(
"ConfFileIsNotWritable", $conffiletoshow);
321 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileExists", $conffiletoshow);
323 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileCouldBeCreated", $conffiletoshow);
326 print
'<img src="../theme/eldy/img/tick.png" alt="Ok"> '.$langs->trans(
"ConfFileIsWritable", $conffiletoshow);
338 if (file_exists($conffile)) {
339 include_once $conffile;
340 if (!empty($dolibarr_main_db_type) && !empty($dolibarr_main_document_root)) {
341 if (!file_exists($dolibarr_main_document_root.
"/core/lib/admin.lib.php")) {
342 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";
343 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);
345 require_once $dolibarr_main_document_root.
'/core/lib/admin.lib.php';
348 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
349 require_once $dolibarr_main_document_root.
'/core/lib/security.lib.php';
350 if (preg_match(
'/crypted:/i', $dolibarr_main_db_pass)) {
351 $dolibarr_main_db_encrypted_pass = preg_replace(
'/crypted:/i',
'', $dolibarr_main_db_pass);
352 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
354 $dolibarr_main_db_pass =
dol_decode($dolibarr_main_db_encrypted_pass);
359 $conf->db->type = $dolibarr_main_db_type;
360 $conf->db->host = $dolibarr_main_db_host;
361 $conf->db->port = $dolibarr_main_db_port;
362 $conf->db->name = $dolibarr_main_db_name;
363 $conf->db->user = $dolibarr_main_db_user;
364 $conf->db->pass = $dolibarr_main_db_pass;
365 $db =
getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (
int) $conf->db->port);
366 if ($db->connected && $db->database_selected) {
375 if (empty($dolibarr_main_db_encryption)) {
376 $dolibarr_main_db_encryption = 0;
378 $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
379 if (empty($dolibarr_main_db_cryptkey)) {
380 $dolibarr_main_db_cryptkey =
'';
382 $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
384 $conf->setValues($db);
386 if (defined(
'SYSLOG_FILE')) {
387 $conf->global->SYSLOG_FILE = constant(
'SYSLOG_FILE');
389 $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
393 $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 :
''));
399 print $langs->trans(
"VersionLastUpgrade").
': <b><span class="ok">'.(!
getDolGlobalString(
'MAIN_VERSION_LAST_UPGRADE') ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE).
'</span></b> - ';
400 print $langs->trans(
"VersionProgram").
': <b><span class="ok">'.DOL_VERSION.
'</span></b>';
409 print
'<h3><span class="soustitre">'.$langs->trans(
"ChooseYourSetupMode").
'</span></h3>';
411 $foundrecommandedchoice = 0;
413 $available_choices = array();
414 $notavailable_choices = array();
416 if (empty($dolibarr_main_db_host)) {
417 $foundrecommandedchoice = 1;
421 $choice =
'<tr class="trlineforchoice'.($foundrecommandedchoice ?
' choiceselected' :
'').
'">'.
"\n";
422 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"FreshInstall").
'</b>';
424 $choice .=
'<td class="listofchoicesdesc">';
425 $choice .= $langs->trans(
"FreshInstallDesc");
426 if (empty($dolibarr_main_db_host)) {
429 $choice .=
'<div class="center"><div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div></div>';
434 $choice .=
'<td class="center">';
436 $choice .=
'<a class="button" href="fileconf.php?selectlang='.$setuplang.
'">'.$langs->trans(
"Start").
'</a>';
438 $choice .= ($foundrecommandedchoice ?
'<span class="warning">' :
'').$langs->trans(
"InstallNotAllowed").($foundrecommandedchoice ?
'</span>' :
'');
440 $choice .=
'</td>'.
"\n";
441 $choice .=
'</tr>'.
"\n";
443 $positionkey = ($foundrecommandedchoice ? 999 : 0);
445 $available_choices[$positionkey] = $choice;
447 $notavailable_choices[$positionkey] = $choice;
451 $allowupgrade =
true;
452 if (empty($dolibarr_main_db_host)) {
453 $allowupgrade =
false;
456 $allowupgrade =
false;
459 $allowupgrade =
true;
462 $dir = DOL_DOCUMENT_ROOT.
"/install/mysql/migration/";
466 $migrationscript = array();
467 $handle = opendir($dir);
468 if (is_resource($handle)) {
469 $versiontousetoqualifyscript = preg_replace(
'/-.*/',
'', DOL_VERSION);
470 while (($file = readdir($handle)) !==
false) {
472 if (preg_match(
'/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.sql$/i', $file, $reg)) {
474 if (!empty($reg[2]) && version_compare($versiontousetoqualifyscript, $reg[2]) >= 0) {
475 $migrationscript[] = array(
'from' => $reg[1],
'to' => $reg[2]);
479 $migrationscript =
dol_sort_array($migrationscript,
'from',
'asc', 1);
481 print
'<div class="error">'.$langs->trans(
"ErrorCanNotReadDir", $dir).
'</div>';
485 foreach ($migrationscript as $migarray) {
489 $recommended_choice =
false;
490 $version = DOL_VERSION;
491 $versionfrom = $migarray[
'from'];
492 $versionto = $migarray[
'to'];
493 $versionarray = preg_split(
'/[\.-]/', $version);
494 $dolibarrversionfromarray = preg_split(
'/[\.-]/', $versionfrom);
495 $dolibarrversiontoarray = preg_split(
'/[\.-]/', $versionto);
497 $newversionfrom = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionfrom);
498 $newversionto = preg_replace(
'/(\.[0-9]+)$/i',
'.*', $versionto);
499 $newversionfrombis =
'';
500 if (
versioncompare($dolibarrversiontoarray, $versionarray) < -2) {
501 $newversionfrombis =
' '.$langs->trans(
"or").
' '.$versionto;
505 if (count($dolibarrlastupgradeversionarray) >= 2) {
507 if ($allowupgrade && empty($foundrecommandedchoice) &&
508 (
versioncompare($dolibarrversiontoarray, $dolibarrlastupgradeversionarray) > 0 ||
versioncompare($dolibarrversiontoarray, $versionarray) < -2)
510 $foundrecommandedchoice = 1;
511 $recommended_choice =
true;
519 $choice .=
"\n".
'<!-- choice '.$count.
' -->'.
"\n";
520 $choice .=
'<tr'.($recommended_choice ?
' class="choiceselected"' :
'').
'>';
521 $choice .=
'<td class="nowrap center"><b>'.$langs->trans(
"Upgrade").
'<br>'.$newversionfrom.$newversionfrombis.
' -> '.$newversionto.
'</b></td>';
522 $choice .=
'<td class="listofchoicesdesc">';
523 $choice .= $langs->trans(
"UpgradeDesc");
525 if ($recommended_choice) {
528 $choice .=
'<div class="center">';
529 $choice .=
'<div class="ok suggestedchoice">'.$langs->trans(
"InstallChoiceSuggested").
'</div>';
530 if ($count < count($migarray)) {
531 print $langs->trans(
"MigrateIsDoneStepByStep", DOL_VERSION);
537 $choice .=
'<td class="center">';
540 if ($foundrecommandedchoice == 2) {
543 if ($foundrecommandedchoice == 1) {
544 $foundrecommandedchoice = 2;
547 $choice .=
'<span class="opacitymedium">'.$langs->trans(
"NotYetAvailable").
'</span>';
549 $choice .=
'<a class="button runupgrade" href="upgrade.php?action=upgrade'.($count < count($migrationscript) ?
'_'.$versionto :
'').
'&selectlang='.$setuplang.
'&versionfrom='.$versionfrom.
'&versionto='.$versionto.
'">'.$langs->trans(
"Start").
'</a>';
552 $choice .= $langs->trans(
"NotAvailable");
555 $choice .=
'</tr>'.
"\n";
558 $available_choices[$count] = $choice;
560 $notavailable_choices[$count] = $choice;
565 if (empty($available_choices)) {
566 $available_choices = $notavailable_choices;
567 $notavailable_choices = array();
571 krsort($available_choices, SORT_NATURAL);
573 print
'<table width="100%" class="listofchoices">';
574 foreach ($available_choices as $choice) {
578 print
'</table>'.
"\n";
580 if (count($notavailable_choices)) {
581 print
'<br><div id="AShowChoices" style="opacity: 0.5">';
582 print
'> '.$langs->trans(
'ShowNotAvailableOptions').
'...';
585 print
'<div id="navail_choices" style="display:none">';
587 print
'<table width="100%" class="listofchoices">';
588 foreach ($notavailable_choices as $choice) {
592 print
'</table>'.
"\n";
598print
'<script type="text/javascript">
600$("div#AShowChoices").click(function() {
602 $("div#navail_choices").toggle();
604 if ($("div#navail_choices").css("display") == "none") {
605 $(this).text("> '.$langs->trans(
'ShowNotAvailableOptions').
'...");
607 $(this).text("'.$langs->trans(
'HideNotAvailableOptions').
'...");
613$(".runupgrade").click(function() {
614 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 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.