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