dolibarr 24.0.0-beta
step2.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Cedric GROSS <c.gross@kreiz-it.fr>
5 * Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
6 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28include 'inc.php';
29
42require_once $dolibarr_main_document_root.'/blockedlog/lib/blockedlog.lib.php';
43require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
44require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
45require_once $dolibarr_main_document_root.'/core/lib/security.lib.php';
46
47global $langs;
48
49$ok = 0;
50$db = null;
51
52
53// This page can be long. We increase the time allowed. / Cette page peut etre longue. On augmente le delai autorise.
54// Only works if you are not in safe_mode. / Ne fonctionne que si on est pas en safe_mode.
55
56$err = error_reporting();
57error_reporting(0); // Disable all errors
58//error_reporting(E_ALL);
59@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64
60error_reporting($err);
61
62$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]);
63$setuplang = GETPOST('selectlang', 'aZ09', 3) ? GETPOST('selectlang', 'aZ09', 3) : (empty($argv[2]) ? 'auto' : $argv[2]);
64$langs->setDefaultLang($setuplang);
65
66$langs->loadLangs(array("admin", "install"));
67
68
69// Choice of DBMS
70
71$choix = 0;
72if ($dolibarr_main_db_type == "mysqli") {
73 $choix = 1;
74}
75if ($dolibarr_main_db_type == "pgsql") {
76 $choix = 2;
77}
78if ($dolibarr_main_db_type == "mssql") {
79 $choix = 3;
80}
81if ($dolibarr_main_db_type == "sqlite") {
82 $choix = 4;
83}
84if ($dolibarr_main_db_type == "sqlite3") {
85 $choix = 5;
86}
87//if (empty($choix)) dol_print_error(null,'Database type '.$dolibarr_main_db_type.' not supported into step2.php page');
88
89
90// Now we load forced values from install.forced.php file.
91
92$useforcedwizard = false;
93$forcedfile = "./install.forced.php";
94if ($conffile == "/etc/dolibarr/conf.php") {
95 $forcedfile = "/etc/dolibarr/install.forced.php";
96}
97if (@file_exists($forcedfile)) {
98 $useforcedwizard = true;
99 include_once $forcedfile;
100 // test for travis
101 if (!empty($argv[1]) && $argv[1] == "set") {
102 $action = "set";
103 }
104}
105
106dolibarr_install_syslog("--- step2: entering step2.php page");
107
109'@phan-var-force string $dolibarr_main_db_prefix'; // From configuration file or install/inc.php
110
111
112/*
113 * Actions
114 */
115
116// None
117
118
119/*
120 * View
121 */
122
123pHeader($langs->trans("DolibarrSetup").' - '.$langs->trans("CreateDatabaseObjects"), "step4");
124
125// Test if we can run a first install process
126if (!is_writable($conffile)) {
127 print $langs->trans("ConfFileIsNotWritable", $conffiletoshow);
128 pFooter(1, $setuplang, 'jscheckparam');
129 exit;
130}
131
132if ($action == "set") { // Test on permission not required. Already managed by test in inc.php
133 print '<h3><img class="valignmiddle inline-block paddingright" src="../public/theme/common/database.svg" width="20" alt="Database"> '.$langs->trans("Database").'</h3>';
134
135 print '<table cellspacing="0" style="padding: 4px 4px 4px 0" border="0" width="100%">';
136 $error = 0;
137
138 $db = getDoliDBInstance($conf->db->type, $conf->db->host, (string) $conf->db->user, (string) $conf->db->pass, (string) $conf->db->name, (int) $conf->db->port);
139
140 if ($db->connected) {
141 print "<tr><td>";
142 print $langs->trans("ServerConnection")." : ".$conf->db->host.'</td><td>'.img_picto('OK', 'tick').'</td></tr>';
143 $ok = 1;
144 } else {
145 print "<tr><td>Failed to connect to server : ".$conf->db->host.'</td><td>'.img_picto('Error', 'warning', 'class="error"').'</td></tr>';
146 }
147
148 if ($ok) {
149 if ($db->database_selected) {
150 dolibarr_install_syslog("step2: successful connection to database: ".$conf->db->name);
151 } else {
152 dolibarr_install_syslog("step2: failed connection to database :".$conf->db->name, LOG_ERR);
153 print "<tr><td>Failed to select database ".$conf->db->name.'</td><td>'.img_picto('Error', 'warning', 'class="error"').'</td></tr>';
154 $ok = 0;
155 }
156 }
157
158
159 $versionarray = array();
160 // Display version / Affiche version
161 if ($ok) {
162 $version = $db->getVersion();
163 $versionarray = $db->getVersionArray();
164 print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
165 print '<td>'.$version.'</td></tr>';
166 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
167
168 print '<tr><td>'.$langs->trans("DatabaseName").'</td>';
169 print '<td>'.$db->database_name.'</td></tr>';
170 //print '<td class="right">'.join('.',$versionarray).'</td></tr>';
171 }
172
173 $requestnb = 0;
174
175 // To disable some code, so you can call step2 with url like
176 // http://localhost/dolibarrnew/install/step2.php?action=set&token='.newToken().'&createtables=0&createkeys=0&createfunctions=0&createdata=llx_20_c_departements
177 $createtables = GETPOSTISSET('createtables') ? GETPOST('createtables') : 1;
178 $createkeys = GETPOSTISSET('createkeys') ? GETPOST('createkeys') : 1;
179 $createfunctions = GETPOSTISSET('createfunctions') ? GETPOST('createfunction') : 1;
180 $createdata = GETPOSTISSET('createdata') ? GETPOST('createdata') : 1;
181
182
183 // To say that SQL we pass to query are already escaped for mysql, so we need to unescape them
184 if (property_exists($db, 'unescapeslashquot')) {
185 $db->unescapeslashquot = true; // @phan-suppress-current-line PhanUndeclaredProperty
186 }
187
188 /**************************************************************************************
189 *
190 * Load files tables/*.sql (not the *.key.sql). Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
191 * To do before the files *.key.sql
192 *
193 ***************************************************************************************/
194 if ($ok && $createtables) {
195 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
196 $dir = "mysql/tables/";
197
198 $ok = 0;
199 $handle = opendir($dir);
200 dolibarr_install_syslog("step2: open tables directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
201 $tablefound = 0;
202 $tabledata = array();
203 if (is_resource($handle)) {
204 while (($file = readdir($handle)) !== false) {
205 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
206 $tablefound++;
207 $tabledata[] = $file;
208 }
209 }
210 closedir($handle);
211 }
212
213 // Sort list of sql files on alphabetical order (load order is important)
214 sort($tabledata);
215 foreach ($tabledata as $file) {
216 $name = substr($file, 0, dol_strlen($file) - 4);
217 $buffer = '';
218 $fp = fopen($dir.$file, "r");
219 if ($fp) {
220 while (!feof($fp)) {
221 $buf = fgets($fp, 4096);
222 if (substr($buf, 0, 2) != '--') {
223 $buf = preg_replace('/--(.+)*/', '', $buf);
224 $buffer .= $buf;
225 }
226 }
227 fclose($fp);
228
229 $buffer = trim($buffer);
230 if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') { // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
231 $buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
232 } else {
233 // Keyword ENGINE is MySQL-specific, so scrub it for
234 // other database types (mssql, pgsql)
235 $buffer = preg_replace('/type=innodb/i', '', $buffer);
236 $buffer = preg_replace('/ENGINE=innodb/i', '', $buffer);
237 }
238
239 // Replace the prefix tables
240 if ($dolibarr_main_db_prefix != 'llx_') {
241 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
242 }
243
244 //print "<tr><td>Creation of table $name/td>";
245 $requestnb++;
246
247 dolibarr_install_syslog("step2: request: ".$buffer);
248 $resql = $db->query($buffer, 0, 'dml');
249 if ($resql) {
250 // print "<td>OK request ==== $buffer</td></tr>";
251 $db->free($resql);
252 } else {
253 if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
254 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS') {
255 //print "<td>already existing</td></tr>";
256 } else {
257 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
258 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' <br>Executed query : '.$db->lastquery;
259 print "\n</td>";
260 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
261 $error++;
262 }
263 }
264 } else {
265 print "<tr><td>".$langs->trans("CreateTableAndPrimaryKey", $name);
266 print "</td>";
267 print '<td><span class="error">'.$langs->trans("Error").' Failed to open file '.$dir.$file.'</span></td></tr>';
268 $error++;
269 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
270 }
271 }
272
273 if ($tablefound) {
274 if ($error == 0) {
275 print '<tr><td>';
276 print $langs->trans("TablesAndPrimaryKeysCreation").'</td><td>'.img_picto('OK', 'tick').'</td></tr>';
277 $ok = 1;
278 }
279 } else {
280 print '<tr><td>'.$langs->trans("ErrorFailedToFindSomeFiles", $dir).'</td><td>'.img_picto('Error', 'warning', 'class="error"').'</td></tr>';
281 dolibarr_install_syslog("step2: failed to find files to create database in directory ".$dir, LOG_ERR);
282 }
283 }
284
285
286 /***************************************************************************************
287 *
288 * Load files tables/*.key.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
289 * To do after the files *.sql
290 *
291 ***************************************************************************************/
292 if ($ok && $createkeys && $db !== null) {
293 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
294 $dir = "mysql/tables/";
295
296 $okkeys = 0;
297 $handle = opendir($dir);
298 dolibarr_install_syslog("step2: open keys directory ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
299 $tablefound = 0;
300 $tabledata = array();
301 if (is_resource($handle)) {
302 while (($file = readdir($handle)) !== false) {
303 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) {
304 $tablefound++;
305 $tabledata[] = $file;
306 }
307 }
308 closedir($handle);
309 }
310
311 // Sort list of sql files on alphabetical order (load order is important)
312 sort($tabledata);
313 foreach ($tabledata as $file) {
314 $name = substr($file, 0, dol_strlen($file) - 4);
315 //print "<tr><td>Creation of table $name</td>";
316 $buffer = '';
317 $fp = fopen($dir.$file, "r");
318 if ($fp) {
319 while (!feof($fp)) {
320 $buf = fgets($fp, 4096);
321
322 // Special case of lines allowed for some versions only
323 // MySQL
324 if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
325 $versioncommande = explode('.', $reg[1]);
326 //var_dump($versioncommande);
327 //var_dump($versionarray);
328 if (count($versioncommande) && count($versionarray)
329 && versioncompare($versioncommande, $versionarray) <= 0) {
330 // Version qualified, delete SQL comments
331 $buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
332 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
333 }
334 }
335 // PGSQL
336 if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
337 $versioncommande = explode('.', $reg[1]);
338 //var_dump($versioncommande);
339 //var_dump($versionarray);
340 if (count($versioncommande) && count($versionarray)
341 && versioncompare($versioncommande, $versionarray) <= 0) {
342 // Version qualified, delete SQL comments
343 $buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
344 //print "Ligne $i qualifiee par version: ".$buf.'<br>';
345 }
346 }
347
348 // Add line if no comment
349 if (!preg_match('/^--/i', $buf)) {
350 $buffer .= $buf;
351 }
352 }
353 fclose($fp);
354
355 // If several requests, we loop on each
356 $listesql = explode(';', $buffer);
357 foreach ($listesql as $req) {
358 $buffer = trim($req);
359 if ($buffer) {
360 // Replace the prefix tables
361 if ($dolibarr_main_db_prefix != 'llx_') {
362 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
363 }
364
365 //print "<tr><td>Creation of keys and table index $name: '$buffer'</td>";
366 $requestnb++;
367
368 dolibarr_install_syslog("step2: request: ".$buffer);
369 $resql = $db->query($buffer, 0, 'dml');
370 if ($resql) {
371 //print "<td>OK request ==== $buffer</td></tr>";
372 $db->free($resql);
373 } else {
374 if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
375 $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
376 $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
377 $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
378 preg_match('/duplicate key name/i', $db->error())) {
379 //print "<td>Deja existante</td></tr>";
380 $key_exists = 1;
381 } else {
382 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
383 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
384 print "\n</td>";
385 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
386 $error++;
387 }
388 }
389 }
390 }
391 } else {
392 print "<tr><td>".$langs->trans("CreateOtherKeysForTable", $name);
393 print "</td>";
394 print '<td><span class="error">'.$langs->trans("Error")." Failed to open file ".$dir.$file."</span></td></tr>";
395 $error++;
396 dolibarr_install_syslog("step2: failed to open file ".$dir.$file, LOG_ERR);
397 }
398 }
399
400 if ($tablefound && $error == 0) {
401 print '<tr><td>';
402 print $langs->trans("OtherKeysCreation").'</td><td>'.img_picto('OK', 'tick').'</td></tr>';
403 $okkeys = 1;
404 }
405 }
406
407
408 /***************************************************************************************
409 *
410 * Load the file 'functions.sql'
411 *
412 ***************************************************************************************/
413 if ($ok && $createfunctions) {
414 // For this file, we use a directory according to database type
415 $dir = null;
416 if ($choix == 1) {
417 $dir = "mysql/functions/";
418 } elseif ($choix == 2) {
419 $dir = "pgsql/functions/";
420 } elseif ($choix == 3) {
421 $dir = "mssql/functions/";
422 } elseif ($choix == 4) {
423 $dir = "sqlite3/functions/";
424 }
425
426 // Creation of data
427 $file = "functions.sql";
428 if ($dir !== null && file_exists($dir.$file)) {
429 $fp = fopen($dir.$file, "r");
430 dolibarr_install_syslog("step2: open function file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
431 $buffer = '';
432 if ($fp) {
433 while (!feof($fp)) {
434 $buf = fgets($fp, 4096);
435 if (substr($buf, 0, 2) != '--') {
436 $buffer .= $buf."§";
437 }
438 }
439 fclose($fp);
440 }
441 //$buffer=preg_replace('/;\';/',";'§",$buffer);
442
443 // If several requests, we loop on each of them
444 $listesql = explode('§', $buffer);
445 foreach ($listesql as $buffer) {
446 $buffer = trim($buffer);
447 if ($buffer) {
448 // Replace the prefix in table names
449 if ($dolibarr_main_db_prefix != 'llx_') {
450 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
451 }
452 dolibarr_install_syslog("step2: request: ".$buffer);
453 print "<!-- Insert line : ".$buffer."<br>-->\n";
454 $resql = $db->query($buffer, 0, 'dml');
455 if ($resql) {
456 $ok = 1;
457 $db->free($resql);
458 } else {
459 if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS'
460 || $db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS') {
461 //print "Insert line : ".$buffer."<br>\n";
462 } else {
463 $ok = 0;
464
465 print "<tr><td>".$langs->trans("FunctionsCreation");
466 print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
467 print "\n</td>";
468 print '<td><span class="error">'.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().'</span></td></tr>';
469 $error++;
470 }
471 }
472 }
473 }
474
475 print "<tr><td>".$langs->trans("FunctionsCreation")."</td>";
476 if ($ok) {
477 print '<td>'.img_picto('OK', 'tick').'</td></tr>';
478 } else {
479 print '<td>'.img_picto('Error', 'warning', 'class="error"').'</td></tr>';
480 $ok = 1;
481 }
482 }
483 }
484
485
486 /***************************************************************************************
487 *
488 * Load files data/*.sql. Files with '-xxx' in name are excluded (they will be loaded during activation of module 'xxx').
489 *
490 ***************************************************************************************/
491 if ($ok && $createdata) {
492 // We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
493 $dir = "mysql/data/";
494
495 // Insert data
496 $handle = opendir($dir);
497 dolibarr_install_syslog("step2: open directory data ".$dir." handle=".(is_bool($handle) ? json_encode($handle) : $handle));
498 $tablefound = 0;
499 $tabledata = array();
500 if (is_resource($handle)) {
501 while (($file = readdir($handle)) !== false) {
502 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\-/', $file)) {
503 if (preg_match('/^llx_accounting_account_/', $file)) {
504 continue; // We discard data file of chart of account. This will be loaded when a chart is selected.
505 }
506
507 //print 'x'.$file.'-'.$createdata.'<br>';
508 if (is_numeric($createdata) || preg_match('/'.preg_quote($createdata).'/i', $file)) { // @phpstan-ignore argument.invalidPregQuote
509 $tablefound++;
510 $tabledata[] = $file;
511 }
512 }
513 }
514 closedir($handle);
515 }
516
517 // Sort list of data files on alphabetical order (load order is important)
518 sort($tabledata);
519 foreach ($tabledata as $file) {
520 $name = substr($file, 0, dol_strlen($file) - 4);
521 $fp = fopen($dir.$file, "r");
522 dolibarr_install_syslog("step2: open data file ".$dir.$file." handle=".(is_bool($fp) ? json_encode($fp) : $fp));
523 if ($fp) {
524 $arrayofrequests = array();
525 $linefound = 0;
526 $linegroup = 0;
527 $sizeofgroup = 1; // Grouping request to have 1 query for several requests does not works with mysql, so we use 1.
528
529 // Load all requests
530 while (!feof($fp)) {
531 $buffer = fgets($fp, 4096);
532 $buffer = trim($buffer);
533 if ($buffer) {
534 if (substr($buffer, 0, 2) == '--') {
535 continue;
536 }
537
538 if ($linefound && ($linefound % $sizeofgroup) == 0) {
539 $linegroup++;
540 }
541 if (empty($arrayofrequests[$linegroup])) {
542 $arrayofrequests[$linegroup] = $buffer;
543 } else {
544 $arrayofrequests[$linegroup] .= " ".$buffer;
545 }
546
547 $linefound++;
548 }
549 }
550 fclose($fp);
551
552 dolibarr_install_syslog("step2: found ".$linefound." records, defined ".count($arrayofrequests)." group(s).");
553
554 $okallfile = 1;
555 $db->begin();
556
557 // We loop on each requests of file
558 foreach ($arrayofrequests as $buffer) {
559 // Replace the tables prefixes
560 if ($dolibarr_main_db_prefix != 'llx_') {
561 $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
562 }
563
564 // Replace __ENTITY__ tag with 1 (master entity), this is only for dictionaries.
565 $buffer = preg_replace('/__ENTITY__/i', '1', $buffer);
566
567 //dolibarr_install_syslog("step2: request: " . $buffer);
568 $resql = $db->query($buffer, 1);
569 if ($resql) {
570 //$db->free($resql); // Not required as request we launch here does not return memory needs.
571 } else {
572 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
573 //print "<tr><td>Insert line : $buffer</td><td>";
574 } else {
575 $ok = 0;
576 $okallfile = 0;
577 print '<span class="error">'.$langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."</span><br>";
578 }
579 }
580 }
581
582 if ($okallfile) {
583 $db->commit();
584 } else {
585 $db->rollback();
586 }
587 }
588 }
589
590 print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
591 if ($ok) {
592 print '<td>'.img_picto('OK', 'tick').'</td></tr>';
593 } else {
594 print '<td>'.img_picto('Error', 'warning', 'class="error"').'</td></tr>';
595 $ok = 1; // Data loading are not blocking errors
596 }
597 }
598 print '</table>';
599} else {
600 print 'Parameter action=set not defined';
601}
602
603
604$ret = 0;
605if (!$ok && isset($argv[1])) {
606 $ret = 1;
607}
608dolibarr_install_syslog("Exit ".$ret);
609
610dolibarr_install_syslog("- step2: end");
611
612
613// Force here a value we need after because master.inc.php is not loaded into step2.
614// This code must be similar with the one into main.inc.php
615
616$conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id); // Unique id of instance
617
618$hash_unique_id = getHashUniqueIdOfRegistration('sha256');
619
620$out = '<br>';
621$out .= '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> ';
622$out .= '<label for="dolibarrpingno" class="opacitymedium">'.$langs->trans("MakeAnonymousPing").'</label>';
623
624$out .= '<!-- Add js script to manage the uncheck of option to not send the ping -->';
625$out .= '<script type="text/javascript">';
626$out .= 'jQuery(document).ready(function(){';
627$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
628$out .= ' jQuery("#dolibarrpingno").click(function() {';
629$out .= ' if (! $(this).is(\':checked\')) {';
630$out .= ' console.log("We uncheck anonymous ping");';
631$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=1; path=/"'."\n";
632$out .= ' } else {'."\n";
633$out .= ' console.log("We check anonymous ping");';
634$out .= ' document.cookie = "DOLINSTALLNOPING_'.$hash_unique_id.'=0; path=/"'."\n";
635$out .= ' }'."\n";
636$out .= ' });';
637$out .= '});';
638$out .= '</script>';
639
640print $out;
641
642pFooter($ok ? 0 : 1, $setuplang);
643
644if (isset($db) && is_object($db)) {
645 $db->close();
646}
647
648// Return code if ran from command line
649if ($ret) {
650 exit($ret);
651}
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
Definition admin.lib.php:72
getHashUniqueIdOfRegistration($algo='sha256')
Return a hash unique identifier of the registration (used to identify the registration of instance wi...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
$conffile
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)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
Definition inc.php:541
pFooter($nonext=0, $setuplang='', $jscheckfunction='', $withpleasewait=0, $morehtml='')
Print HTML footer of install pages.
Definition inc.php:635
dolibarr_install_syslog($message, $level=LOG_DEBUG)
Log function for install pages.
Definition inc.php:699