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