30require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
42 if (isset($versionarray[0])) {
43 $string = $versionarray[0];
45 if (isset($versionarray[1])) {
46 $string .=
'.'.$versionarray[1];
48 if (isset($versionarray[2])) {
49 $string .=
'.'.$versionarray[2];
75 $count1 = count($versionarray1);
76 $count2 = count($versionarray2);
77 $maxcount = max($count1, $count2);
78 while ($level < $maxcount) {
79 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
80 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
81 if (preg_match(
'/alpha|dev/i', $operande1)) {
84 if (preg_match(
'/alpha|dev/i', $operande2)) {
87 if (preg_match(
'/beta$/i', $operande1)) {
90 if (preg_match(
'/beta$/i', $operande2)) {
93 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
96 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
99 if (preg_match(
'/rc$/i', $operande1)) {
102 if (preg_match(
'/rc$/i', $operande2)) {
105 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
108 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
113 if ($operande1 < $operande2) {
117 if ($operande1 > $operande2) {
135 return explode(
'.', PHP_VERSION);
146 return preg_split(
'/[\-\.]/', DOL_VERSION);
173function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
175 global $db, $conf, $langs;
177 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
179 if (!is_numeric($linelengthlimit)) {
180 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
191 $versionarray = $db->getVersionArray();
195 $fp = fopen($sqlfile,
"r");
199 if ($linelengthlimit > 0) {
200 $buf = fgets($fp, $linelengthlimit);
207 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
211 if (!empty($reg[1])) {
212 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i', $db->type)) {
219 if (!empty($reg[2])) {
220 if (is_numeric($reg[2])) {
221 $versionrequest = explode(
'.', $reg[2]);
224 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
228 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
231 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
241 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
247 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
248 if (empty($nocommentremoval)) {
249 $buf = preg_replace(
'/([,;ERLT0\)])\s+--.*$/i',
'\1', $buf);
254 $buffer .= trim($buf);
259 if (preg_match(
'/;\s*$/', $buffer)) {
263 $arraysql[$i] = $buffer;
271 $arraysql[$i] = $buffer;
275 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
279 $listofmaxrowid = array();
280 foreach ($arraysql as $i => $sql) {
284 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
286 if (!isset($listofmaxrowid[$table])) {
288 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
289 $resql = $db->query($sqlgetrowid);
291 $obj = $db->fetch_object($resql);
292 $listofmaxrowid[$table] = $obj->max;
293 if (empty($listofmaxrowid[$table])) {
294 $listofmaxrowid[$table] = 0;
298 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
299 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
307 $from =
'__+MAX_'.$table.
'__';
308 $to =
'+'.$listofmaxrowid[$table];
309 $newsql = str_replace($from, $to, $newsql);
310 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
312 $arraysql[$i] = $newsql;
315 if ($offsetforchartofaccount > 0) {
321 $newsql = preg_replace(
'/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims',
'VALUES (__ENTITY__, \1 + '.((
int) $offsetforchartofaccount).
', \2, \3 + '.((
int) $offsetforchartofaccount), $newsql);
322 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
324 $arraysql[$i] = $newsql;
333 $listofinsertedrowid = array();
334 $keyforsql = md5($sqlfile);
335 foreach ($arraysql as $i => $sql) {
338 if ($onlysqltoimportwebsite) {
339 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
342 $l = strlen($newsql);
347 $char = $newsql[$is];
354 } elseif (empty($quoteopen)) {
355 $newsqlclean .= $char;
359 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
365 if (preg_match(
'/^--/', $newsqlclean)) {
367 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
369 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
377 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
387 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
388 if ($errorphpcheck) {
392 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
402 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
403 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
409 if (MAIN_DB_PREFIX !=
'llx_') {
410 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
413 if (!empty($handler)) {
414 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
417 if (!empty($database)) {
418 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
421 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql);
425 print
'<tr class="trforrunsql'.$keyforsql.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
427 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
431 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
432 $num = count($reg[0]);
434 for ($j = 0; $j < $num; $j++) {
436 $to = $db->encrypt($reg[1][$j]);
437 $newsql = str_replace($from, $to, $newsql);
443 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
444 $num = count($reg[0]);
446 for ($j = 0; $j < $num; $j++) {
448 $to = $db->decrypt($reg[1][$j]);
449 $newsql = str_replace($from, $to, $newsql);
455 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
457 if (empty($listofinsertedrowid[$cursor])) {
459 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
460 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
467 $from =
'__'.$cursor.
'__';
468 $to = $listofinsertedrowid[$cursor];
469 $newsql = str_replace($from, $to, $newsql);
474 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
477 $result = $db->query($newsql, $usesavepoint);
480 print
'<!-- Result = OK -->'.
"\n";
483 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
487 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
488 $insertedrowid = $db->last_insert_id($table);
489 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
490 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
493 $errno = $db->errno();
495 print
'<!-- Result = '.$errno.
' -->'.
"\n";
500 'DB_ERROR_TABLE_ALREADY_EXISTS',
501 'DB_ERROR_COLUMN_ALREADY_EXISTS',
502 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
503 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
504 'DB_ERROR_RECORD_ALREADY_EXISTS',
505 'DB_ERROR_NOSUCHTABLE',
506 'DB_ERROR_NOSUCHFIELD',
507 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
508 'DB_ERROR_NO_INDEX_TO_DROP',
509 'DB_ERROR_CANNOT_CREATE',
510 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
511 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
514 if ($okerror ==
'none') {
519 if (!in_array($errno, $okerrors)) {
521 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
522 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
523 print
'</td></tr>'.
"\n";
525 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
533 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
534 print
'<td class="right">';
536 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
538 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
542 print
'<script type="text/javascript">
543 jQuery(document).ready(function() {
544 function init_trrunsql'.$keyforsql.
'()
546 console.log("toggle .trforrunsql'.$keyforsql.
'");
547 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
549 init_trrunsql'.$keyforsql.
'();
550 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
551 init_trrunsql'.$keyforsql.
'();
555 if (count($arraysql)) {
556 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
558 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
562 print
'</td></tr>'.
"\n";
587 global $conf, $hookmanager;
590 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
593 if (! is_object($hookmanager)) {
594 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
603 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
608 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
609 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape((
string) $name).
"'";
610 if (is_numeric($name)) {
611 $sql .=
" OR rowid = ".((int) $name);
615 $sql .=
" AND entity = ".((int) $entity);
618 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
619 $resql = $db->query($sql);
621 $conf->global->$name =
'';
643 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
644 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
645 $sql .=
" WHERE name = ".$db->encrypt($name);
646 $sql .=
" AND entity = ".((int) $entity);
648 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
649 $resql = $db->query($sql);
651 $obj = $db->fetch_object($resql);
653 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
675function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
677 global $conf, $hookmanager;
681 $value = (string) $value;
685 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters");
688 if (! is_object($hookmanager)) {
689 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
693 $value = (string) $value;
699 'visible' => $visible,
704 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
713 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
714 $sql .=
" WHERE name = ".$db->encrypt($name);
716 $sql .=
" AND entity = ".((int) $entity);
719 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
720 $resql = $db->query($sql);
722 if (strcmp($value,
'')) {
723 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
728 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
734 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
736 $sql .= $db->encrypt($name);
737 $sql .=
", ".$db->encrypt($newvalue);
738 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
742 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
743 $resql = $db->query($sql);
748 $conf->global->$name = $value;
769 global $langs, $form;
771 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
772 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
778 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
779 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
781 $head[$h][1] = $langs->trans(
"AvailableModules");
782 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
785 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
787 $head[$h][2] =
'modules';
790 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
791 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
792 $head[$h][2] =
'marketplace';
795 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
796 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
797 $head[$h][2] =
'deploy';
800 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
801 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
802 $head[$h][2] =
'develop';
815 global $langs, $conf;
819 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
820 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
821 $head[$h][2] =
'other';
824 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
825 $head[$h][1] = $langs->trans(
"SkinAndColors");
826 $head[$h][2] =
'template';
829 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
830 $head[$h][1] = $langs->trans(
"Dashboard");
831 $head[$h][2] =
'dashboard';
834 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
835 $head[$h][1] = $langs->trans(
"LoginPage");
836 $head[$h][2] =
'login';
839 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
840 $head[$h][1] = $langs->trans(
"CSSPage");
841 $head[$h][2] =
'css';
867 global $db, $langs, $conf;
871 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
872 $head[$h][1] = $langs->trans(
"Miscellaneous");
873 $head[$h][2] =
'misc';
876 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
877 $head[$h][1] = $langs->trans(
"Captcha");
878 $head[$h][2] =
'captcha';
881 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
882 $head[$h][1] = $langs->trans(
"Passwords");
883 $head[$h][2] =
'passwords';
886 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
887 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
888 $head[$h][2] =
'file';
898 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
899 $head[$h][1] = $langs->trans(
"ExternalAccess");
900 $head[$h][2] =
'proxy';
903 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
904 $head[$h][1] = $langs->trans(
"Audit");
905 $head[$h][2] =
'audit';
908 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
909 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
910 $head[$h][2] =
'openid';
916 $sql =
"SELECT COUNT(r.id) as nb";
917 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
918 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
919 $sql .=
" AND entity = ".((int) $conf->entity);
920 $sql .=
" AND bydefault = 1";
922 $sql .=
" AND r.perms NOT LIKE '%_advance'";
924 $resql = $db->query($sql);
926 $obj = $db->fetch_object($resql);
935 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
936 $head[$h][1] = $langs->trans(
"DefaultRights");
938 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
940 $head[$h][2] =
'default';
944 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
945 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
946 $head[$h][2] =
'headers_http';
960 global $langs, $conf;
967 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
968 $head[$h][1] = $langs->trans(
"Description");
969 $head[$h][2] =
'desc';
972 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
973 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
974 $head[$h][2] =
'feature';
977 if (
$object->isCoreOrExternalModule() ==
'external') {
978 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
979 $head[$h][1] = $langs->trans(
"ChangeLog");
980 $head[$h][2] =
'changelog';
998 global $langs, $conf;
1002 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1003 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1004 $head[$h][2] =
'searchkey';
1007 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1008 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1009 $head[$h][2] =
'overwrite';
1028 global $langs, $conf;
1032 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1033 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1034 $head[$h][2] =
'createform';
1037 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1038 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1039 $head[$h][2] =
'filters';
1042 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1043 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1044 $head[$h][2] =
'sortorder';
1047 if (!empty($conf->use_javascript_ajax)) {
1048 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1049 $head[$h][1] = $langs->trans(
"DefaultFocus");
1050 $head[$h][2] =
'focus';
1053 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1054 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1055 $head[$h][2] =
'mandatory';
1080 global $conf, $php_session_save_handler;
1082 $arrayofSessions = array();
1084 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1085 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1090 $iniPath = ini_get(
"session.save_path");
1092 $sessPath = $iniPath;
1095 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1099 while (($file = @readdir($dh)) !==
false) {
1100 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1101 $fullpath = $sessPath.$file;
1102 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1103 $sessValues = file_get_contents($fullpath);
1109 if (preg_match(
'/dol_login/i', $sessValues) &&
1110 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1111 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1112 $tmp = explode(
'_', $file);
1115 $arrayofSessions[$idsess][
"login"] =
'';
1116 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1118 $arrayofSessions[$idsess][
"login"] = (string) $regs[1];
1120 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1121 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1122 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1123 $arrayofSessions[$idsess][
"user_agent"] =
null;
1124 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1125 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1133 return $arrayofSessions;
1146 $sessPath = ini_get(
"session.save_path").
"/";
1147 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1153 while (($file = @readdir($dh)) !==
false) {
1154 if ($file !=
"." && $file !=
"..") {
1155 $fullpath = $sessPath.$file;
1156 if (!@is_dir($fullpath)) {
1157 $sessValues = file_get_contents($fullpath);
1159 if (preg_match(
'/dol_login/i', $sessValues) &&
1160 (preg_match(
'/dol_entity\|i:('.$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues)) &&
1161 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1162 $tmp = explode(
'_', $file);
1165 if ($idsess != $mysessionid) {
1166 $res = @unlink($fullpath);
1195function activateModule($value, $withdeps = 1, $noconfverification = 0)
1197 global $db, $langs, $conf,
$mysoc;
1202 if (empty($value)) {
1203 $ret[
'errors'] = array(
'ErrorBadParameter');
1207 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1209 $modFile = $modName.
".class.php";
1216 foreach ($modulesdir as $dir) {
1217 if (file_exists($dir.$modFile)) {
1218 $found = @include_once $dir.$modFile;
1225 $objMod =
new $modName($db);
1226 '@phan-var-force DolibarrModules $objMod';
1231 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1233 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1239 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1242 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1247 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1248 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1251 $const_name = $objMod->const_name;
1252 if ($noconfverification == 0) {
1258 $result = $objMod->init();
1261 $ret[
'errors'][] = $objMod->error;
1264 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1267 foreach ($objMod->depends as $key => $modulestringorarray) {
1269 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1270 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1274 if (!is_array($modulestringorarray)) {
1275 $modulestringorarray = array($modulestringorarray);
1278 foreach ($modulestringorarray as $modulestring) {
1281 foreach ($modulesdir as $dir) {
1282 if (file_exists($dir.$modulestring.
".class.php")) {
1283 $resarray = activateModule($modulestring);
1284 if (empty($resarray[
'errors'])) {
1287 $activateerr = implode(
', ', $resarray[
'errors']);
1288 foreach ($resarray[
'errors'] as $errorMessage) {
1297 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1298 $ret[
'nbperms'] += $resarray[
'nbperms'];
1301 $ret[
'errors'][] = $activateerr;
1303 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1309 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1311 $num = count($objMod->conflictwith);
1312 for ($i = 0; $i < $num; $i++) {
1313 foreach ($modulesdir as $dir) {
1314 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1315 unActivateModule($objMod->conflictwith[$i], 0);
1323 if (!count($ret[
'errors'])) {
1324 $ret[
'nbmodules']++;
1325 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1340function unActivateModule($value, $requiredby = 1, $options =
'')
1344 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1347 if (empty($value)) {
1348 return 'ErrorBadParameter';
1353 $modFile = $modName.
".class.php";
1360 foreach ($modulesdir as $dir) {
1361 if (file_exists($dir.$modFile)) {
1362 $found = @include_once $dir.$modFile;
1370 $objMod =
new $modName($db);
1371 '@phan-var-force DolibarrModules $objMod';
1374 $result = $objMod->remove($options);
1376 $ret = $objMod->error;
1381 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1383 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1384 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1385 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1386 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1387 $genericMod->remove(
'');
1391 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1392 $countrb = count($objMod->requiredby);
1393 for ($i = 0; $i < $countrb; $i++) {
1395 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1421function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1425 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1432 foreach ($modulesdir as $dir) {
1435 dol_syslog(
"Scan directory ".$dir.
" for modules");
1437 if (is_resource($handle)) {
1438 while (($file = readdir($handle)) !==
false) {
1440 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1441 $modName = substr($file, 0,
dol_strlen($file) - 10);
1444 include_once $dir.$file;
1445 $objMod =
new $modName($db);
1446 '@phan-var-force DolibarrModules $objMod';
1449 if ($objMod->numero > 0) {
1450 $j = $objMod->numero;
1455 $modulequalified = 1;
1458 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1460 $modulequalified = 0;
1463 $modulequalified = 0;
1467 $modulequalified = 0;
1470 if ($modulequalified) {
1472 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1473 foreach ($objMod->langfiles as $langfile) {
1474 $langs->load($langfile);
1481 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1483 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1487 if (!empty($objMod->dictionaries)) {
1489 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1490 $tabnamerelwithkey = array();
1491 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1492 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1494 $taborder[] = max($taborder) + 1;
1496 $tabnamerelwithkey[$key] = $val;
1497 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1499 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1500 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1503 $tabcomplete[$tmptablename][
'lib'] = $val;
1505 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1506 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1509 $tabcomplete[$tmptablename][
'sql'] = $val;
1511 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1512 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1514 $tabsqlsort[] = $val;
1515 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1517 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1518 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1521 $tabcomplete[$tmptablename][
'field'] = $val;
1523 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1524 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1526 $tabfieldvalue[] = $val;
1527 $tabcomplete[$tmptablename][
'value'] = $val;
1529 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1530 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1531 $nbtabfieldinsert++;
1532 $tabfieldinsert[] = $val;
1533 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1535 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1536 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1539 $tabcomplete[$tmptablename][
'rowid'] = $val;
1541 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1542 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1545 $tabcomplete[$tmptablename][
'cond'] = $val;
1547 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1548 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1549 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1552 $tabcomplete[$tmptablename][
'help'] = $val;
1555 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1556 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1557 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1559 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1563 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1564 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1574 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1581 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1596function activateModulesRequiredByCountry($country_code)
1602 foreach ($modulesdir as $dir) {
1604 dol_syslog(
"Scan directory ".$dir.
" for modules");
1606 if (is_resource($handle)) {
1607 while (($file = readdir($handle)) !==
false) {
1608 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1609 $modName = substr($file, 0,
dol_strlen($file) - 10);
1612 include_once $dir.$file;
1613 $objMod =
new $modName($db);
1614 '@phan-var-force DolibarrModules $objMod';
1617 $modulequalified = 1;
1620 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1622 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1623 $modulequalified = 0;
1625 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1626 $modulequalified = 0;
1629 $modulequalified = 0;
1632 if ($modulequalified) {
1634 if (isset($objMod->automatic_activation[$country_code])) {
1635 activateModule($modName);
1637 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1640 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1647 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1660function complete_elementList_with_modules(&$elementList)
1662 global $db, $modules, $conf, $langs;
1665 $filename = array();
1674 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1678 foreach ($modulesdir as $dir) {
1681 dol_syslog(
"Scan directory ".$dir.
" for modules");
1683 if (is_resource($handle)) {
1684 while (($file = readdir($handle)) !==
false) {
1686 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1687 $modName = substr($file, 0,
dol_strlen($file) - 10);
1690 include_once $dir.$file;
1691 $objMod =
new $modName($db);
1694 if ($objMod->numero > 0) {
1695 $j = $objMod->numero;
1700 $modulequalified = 1;
1703 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1705 $modulequalified = 0;
1708 $modulequalified = 0;
1712 $modulequalified = 0;
1715 if ($modulequalified) {
1717 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1718 foreach ($objMod->langfiles as $langfile) {
1719 $langs->load($langfile);
1723 $modules[$i] = $objMod;
1724 $filename[$i] = $modName;
1725 $orders[$i] = $objMod->family.
"_".$j;
1729 if (!empty($objMod->module_parts[
'contactelement'])) {
1730 if (is_array($objMod->module_parts[
'contactelement'])) {
1731 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1732 $elementList[$elem] = $langs->trans($title);
1735 $elementList[$objMod->name] = $langs->trans($objMod->name);
1742 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1749 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1770 global $db, $langs, $conf, $user;
1771 global $_Avery_Labels;
1773 $form =
new Form($db);
1775 print
'<div class="div-table-responsive-no-min">';
1776 print
'<table class="noborder centpercent">';
1777 print
'<tr class="liste_titre">';
1778 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1781 $text = $langs->trans($text);
1782 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1787 foreach ($tableau as $key => $const) {
1790 if (is_array($const)) {
1791 $type = $const[
'type'];
1792 $label = $const[
'label'];
1801 $sql .=
", ".$db->decrypt(
'name').
" as name";
1802 $sql .=
", ".$db->decrypt(
'value').
" as value";
1805 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1806 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1807 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1808 $sql .=
" ORDER BY name ASC, entity DESC";
1809 $result = $db->query($sql);
1814 $obj = $db->fetch_object($result);
1817 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1820 print
'<tr class="oddeven">';
1824 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1825 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1826 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1827 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1830 $tmparray = explode(
':', $obj->type);
1831 if (!empty($tmparray[1])) {
1832 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1834 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1836 if (!empty($tableau[$key][
'tooltip'])) {
1837 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1839 print($label ? $label : $langs->trans(
'Desc'.$const));
1842 if ($const ==
'ADHERENT_MAILMAN_URL') {
1843 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1845 print
'<div id="example1" class="hidden">';
1846 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0';
1848 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1849 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1850 print
'<div id="example2" class="hidden">';
1851 print
'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/remove?unsubscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&send_unsub_ack_to_this_batch=0&send_unsub_notifications_to_list_owner=0';
1854 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1855 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1856 print
'<div id="example3" class="hidden">';
1857 print
'mymailmanlist<br>';
1858 print
'mymailmanlist1,mymailmanlist2<br>';
1859 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1861 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1865 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1866 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1872 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1875 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1876 $arrayoflabels = array();
1877 foreach (array_keys($_Avery_Labels) as $codecards) {
1878 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1880 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1881 print
'<input type="hidden" name="consttype" value="yesno">';
1882 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1886 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1887 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1888 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1889 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1891 print
"</textarea>\n";
1892 } elseif ($obj->type ==
'html') {
1893 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1894 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1895 $doleditor->Create();
1896 } elseif ($obj->type ==
'yesno') {
1897 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1898 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1899 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1902 $tmp = explode(
':', $obj->type);
1904 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1906 $arrayofmessagename = array();
1907 if (is_array($formmail->lines_model)) {
1908 foreach ($formmail->lines_model as $modelmail) {
1910 if (!empty($arrayofmessagename[$modelmail->label])) {
1911 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1914 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1918 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1920 print
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/mails_templates.php', [
'action' =>
'create',
'type_template' => $tmp[1],
'backtopage' =>
dolBuildUrl($_SERVER[
"PHP_SELF"])]).
'">'.
img_picto(
'',
'add').
'</a>';
1921 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1922 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1924 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1947 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1951 if (!empty($modules)) {
1953 foreach ($tmpmodules as $module) {
1954 $moduleconst = $module->const_name;
1955 $modulename = strtolower($module->name);
1959 if (!in_array($modulename, $listofmodules)) {
1971 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1972 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1973 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1975 $text .= $langs->transnoentitiesnoconv($module->name);
1999 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2000 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
2001 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2002 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2005 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2006 $resql = $db->query($sql);
2030 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2031 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2032 $sql .=
" AND type = '".$db->escape($type).
"'";
2033 $sql .=
" AND entity = ".((int) $conf->entity);
2035 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2036 $resql = $db->query($sql);
2057 $phpinfostring = ob_get_contents();
2060 $info_arr = array();
2061 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2063 foreach ($info_lines as $line) {
2066 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2068 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2069 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2070 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2071 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2084 global $langs, $conf;
2089 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2090 $head[$h][1] = $langs->trans(
"MyOrganization");
2091 $head[$h][2] =
'company';
2094 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2095 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2096 $head[$h][2] =
'socialnetworks';
2099 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2100 $head[$h][1] = $langs->trans(
"OpeningHours");
2101 $head[$h][2] =
'openinghours';
2104 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2105 $head[$h][1] = $langs->trans(
"Subcontractors");
2106 $head[$h][2] =
'subcontractors';
2123 global $langs, $conf, $user;
2128 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2129 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2130 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2131 $head[$h][2] =
'common';
2135 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2136 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2137 $head[$h][2] =
'common_emailing';
2142 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2143 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2144 $head[$h][2] =
'common_ticket';
2148 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2149 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2150 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2151 $head[$h][2] =
'common_passwordreset';
2157 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2158 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2159 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2160 $head[$h][2] =
'senderprofiles';
2164 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2165 $head[$h][1] = $langs->trans(
"EMailTemplates");
2166 $head[$h][2] =
'templates';
2169 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2170 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2171 $head[$h][2] =
'common_ingoing';
2188 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2189 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2190 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2191 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2192 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2193 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2194 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2195 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2196 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2197 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2198 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2199 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2200 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2201 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2202 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2203 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2204 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2205 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2207 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2208 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2210 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2211 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2213 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2215 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2216 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2217 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2231 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2232 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2233 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2234 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2235 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2236 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2237 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2238 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2239 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2240 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2241 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2242 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2243 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2246 "document" => array(
2247 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2248 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2249 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2250 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2253 "navigation" => array(
2254 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2255 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2256 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2257 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2260 "reporting" => array(
2261 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2264 "require-trusted-types-for" => array(
2265 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2267 "trusted-types" => array(
2268 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2269 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2270 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2283 $forceCSPArr = array();
2285 $sourceCSPArrflatten = array();
2288 foreach ($sourceCSPArr as $key => $arr) {
2289 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2292 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2293 $securitypolicies = explode(
";", $forceCSP);
2296 foreach ($securitypolicies as $key => $securitypolicy) {
2297 if ($securitypolicy ==
"") {
2300 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2301 $securitypolicyarr = explode(
" ", $securitypolicy);
2302 $directive = array_shift($securitypolicyarr);
2304 while ($directive ==
"") {
2305 $directive = array_shift($securitypolicyarr);
2307 if (empty($directive)) {
2310 $sources = $securitypolicyarr;
2311 if (empty($sources)) {
2312 $forceCSPArr[$directive] = array();
2315 foreach ($sources as $key2 => $source) {
2316 $source = str_replace(
"'",
"", $source);
2317 if (empty($source)) {
2320 if (empty($forceCSPArr[$directive])) {
2321 $forceCSPArr[$directive] = array($source);
2323 $forceCSPArr[$directive][] = $source;
2328 return $forceCSPArr;
if(! $sortfield) if(! $sortorder) $object
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
security_prepare_head()
Prepare array with list of tabs.
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
form_constantes($tableau, $strictw3c=2, $helptext='', $text='')
Show array with constants to edit.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
purgeSessions($mysessionid)
Purge existing sessions.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
versiondolibarrarray()
Return version Dolibarr.
delDocumentModel($name, $type)
Delete document model used by doc generator.
showModulesExludedForExternal($modules)
Show array with constants to edit.
versionphparray()
Return version PHP.
ihm_prepare_head()
Prepare array with list of tabs.
versioncompare($versionarray1, $versionarray2)
Compare 2 versions (stored into 2 arrays), to know if a version (a,b,c) is lower than (x,...
modulehelp_prepare_head($object)
Prepare array with list of tabs.
listOfSessions()
Return list of session.
phpinfo_array()
Return the php_info into an array.
dolibarr_get_const($db, $name, $entity=1)
Get the value of a setup constant from database.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
GetContentPolicySources()
Prepare array of sources for HTTP headers.
GetContentPolicyToArray($forceCSP)
Transform a Content Security Policy to an array.
email_admin_prepare_head()
Return array head with list of tabs to view object information.
translation_prepare_head()
Prepare array with list of tabs.
company_admin_prepare_head()
Return array head with list of tabs to view object information.
defaultvalues_prepare_head()
Prepare array with list of tabs.
GetContentPolicyDirectives()
Prepare array of directives for HTTP headers.
Class to manage a WYSIWYG editor.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
dolListSessions()
List sessions in db.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='')
Encode a string with a symmetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)