31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43 if (isset($versionarray[0])) {
44 $string = $versionarray[0];
46 if (isset($versionarray[1])) {
47 $string .=
'.'.$versionarray[1];
49 if (isset($versionarray[2])) {
50 $string .=
'.'.$versionarray[2];
76 $count1 = count($versionarray1);
77 $count2 = count($versionarray2);
78 $maxcount = max($count1, $count2);
79 while ($level < $maxcount) {
80 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
81 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
82 if (preg_match(
'/alpha|dev/i', $operande1)) {
85 if (preg_match(
'/alpha|dev/i', $operande2)) {
88 if (preg_match(
'/beta$/i', $operande1)) {
91 if (preg_match(
'/beta$/i', $operande2)) {
94 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
97 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
100 if (preg_match(
'/rc$/i', $operande1)) {
103 if (preg_match(
'/rc$/i', $operande2)) {
106 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
109 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
114 if ($operande1 < $operande2) {
118 if ($operande1 > $operande2) {
136 return explode(
'.', PHP_VERSION);
147 return preg_split(
'/[\-\.]/', DOL_VERSION);
174function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
178 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
180 if (!is_numeric($linelengthlimit)) {
181 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
192 $versionarray =
$db->getVersionArray();
196 $fp = fopen($sqlfile,
"r");
200 if ($linelengthlimit > 0) {
201 $buf = fgets($fp, $linelengthlimit);
208 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
212 if (!empty($reg[1])) {
213 if (!preg_match(
'/'.preg_quote($reg[1],
'/').
'/i',
$db->type)) {
220 if (!empty($reg[2])) {
221 if (is_numeric($reg[2])) {
222 $versionrequest = explode(
'.', $reg[2]);
223 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
227 $dbcollation = strtoupper(preg_replace(
'/_/',
'',
$conf->db->dolibarr_main_db_collation));
228 if (empty(
$conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
237 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
243 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
244 if (empty($nocommentremoval)) {
245 $buf = preg_replace(
'/([,;ERLT05\)])\s+--\s.*$/i',
'\1', $buf);
246 $buf = preg_replace(
'/([,;ERLT05\)])\s+--$/i',
'\1', $buf);
251 $buffer .= trim($buf);
256 if (preg_match(
'/;\s*$/', $buffer)) {
260 $arraysql[$i] = $buffer;
268 $arraysql[$i] = $buffer;
272 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
276 $listofmaxrowid = array();
277 foreach ($arraysql as $i => $sql) {
281 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
283 if (!isset($listofmaxrowid[$table])) {
285 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
286 $resql =
$db->query($sqlgetrowid);
288 $obj =
$db->fetch_object($resql);
289 $listofmaxrowid[$table] = $obj->max;
290 if (empty($listofmaxrowid[$table])) {
291 $listofmaxrowid[$table] = 0;
295 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
296 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
304 $from =
'__+MAX_'.$table.
'__';
305 $to =
'+'.$listofmaxrowid[$table];
306 $newsql = str_replace($from, $to, $newsql);
307 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
309 $arraysql[$i] = $newsql;
312 if ($offsetforchartofaccount > 0) {
318 $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);
319 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
321 $arraysql[$i] = $newsql;
330 $listofinsertedrowid = array();
331 $keyforsqlfile = md5($sqlfile);
332 foreach ($arraysql as $i => $sql) {
335 if ($onlysqltoimportwebsite) {
336 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
339 $l = strlen($newsql);
344 $char = $newsql[$is];
351 } elseif (empty($quoteopen)) {
352 $newsqlclean .= $char;
356 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
362 if (preg_match(
'/^--/', $newsqlclean)) {
364 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
366 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
374 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
384 $errorphpcheck =
checkPHPCode($extractphpold, $extractphp);
385 if ($errorphpcheck) {
389 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains PHP code and checking this code returns errorphpcheck='.$errorphpcheck.'", LOG_WARNING);
399 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
400 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
406 if (MAIN_DB_PREFIX !=
'llx_') {
407 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
410 if (!empty($handler)) {
411 $sql = preg_replace(
'/__HANDLER__/i',
"'".
$db->escape($handler).
"'", $sql);
414 if (!empty($database)) {
415 $sql = preg_replace(
'/__DATABASE__/i',
$db->escape($database), $sql);
418 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? ((
int) $entity) : (
string) ((
int)
$conf->entity)), $sql);
422 print
'<tr class="trforrunsql'.$keyforsqlfile.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
424 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
428 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
429 $num = count($reg[0]);
431 for ($j = 0; $j < $num; $j++) {
433 $to =
$db->encrypt($reg[1][$j]);
434 $newsql = str_replace($from, $to, $newsql);
440 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
441 $num = count($reg[0]);
443 for ($j = 0; $j < $num; $j++) {
445 $to =
$db->decrypt($reg[1][$j]);
446 $newsql = str_replace($from, $to, $newsql);
452 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
454 if (empty($listofinsertedrowid[$cursor])) {
456 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
457 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
464 $from =
'__'.$cursor.
'__';
465 $to = $listofinsertedrowid[$cursor];
466 $newsql = str_replace($from, $to, $newsql);
471 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
474 $result =
$db->query($newsql, $usesavepoint);
477 print
'<!-- Result = OK -->'.
"\n";
480 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
484 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
485 $insertedrowid =
$db->last_insert_id($table);
486 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
487 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
490 $errno =
$db->errno();
492 print
'<!-- Result = '.$errno.
' -->'.
"\n";
497 'DB_ERROR_TABLE_ALREADY_EXISTS',
498 'DB_ERROR_COLUMN_ALREADY_EXISTS',
499 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
500 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
501 'DB_ERROR_RECORD_ALREADY_EXISTS',
502 'DB_ERROR_NOSUCHTABLE',
503 'DB_ERROR_NOSUCHFIELD',
504 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
505 'DB_ERROR_NO_INDEX_TO_DROP',
506 'DB_ERROR_CANNOT_CREATE',
507 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
508 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
515 if (preg_match(
'/^\s*ALTER\s+TABLE\s+[^\s]+_categorie_mo\s.*REFERENCES\s+[^\s(]+_mrp_mo\s*\(/i', $newsql)) {
516 $okerrors[] =
'DB_ERROR_CANNOT_ADD_FOREIGN_KEY_CONSTRAINT';
519 if ($okerror ==
'none') {
524 if (!in_array($errno, $okerrors)) {
526 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
527 print
'<div class="error">'.$langs->trans(
"Error").
" ".
$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".
$db->error().
"</div>";
528 print
'</td></tr>'.
"\n";
530 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".
$db->errno().
" ".$newsql.
"<br>".
$db->error(), LOG_ERR);
538 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
539 print
'<td class="right">';
541 print
'<span class="ok">'.$langs->trans(
"Success").
'</span>';
543 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
547 print
'<script type="text/javascript">
548 jQuery(document).ready(function() {
549 function init_trrunsql'.$keyforsqlfile.
'()
551 console.log("toggle .trforrunsql'.$keyforsqlfile.
'");
552 jQuery(".trforrunsql'.$keyforsqlfile.
'").toggle();
554 init_trrunsql'.$keyforsqlfile.
'();
555 jQuery(".trforrunsqlshowhide'.$keyforsqlfile.
'").click(function() {
556 init_trrunsql'.$keyforsqlfile.
'();
560 if (count($arraysql)) {
561 print
' - <a class="reposition trforrunsqlshowhide'.$keyforsqlfile.
' reposition" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
563 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
567 print
'</td></tr>'.
"\n";
592 global
$conf, $hookmanager;
595 dol_print_error(
null,
'Error call dolibar_del_const with parameter name empty');
598 if (! is_object($hookmanager)) {
599 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
608 $reshook = $hookmanager->executeHooks(
'dolibarrDelConst', $parameters);
613 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
614 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".
$db->escape((
string) $name).
"'";
615 if (is_numeric($name)) {
616 $sql .=
" OR rowid = ".((int) $name);
620 $sql .=
" AND entity = ".((int) $entity);
623 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
624 $resql =
$db->query($sql);
626 $conf->global->$name =
'';
650 $sql =
"SELECT ".$db->sanitize(
$db->decrypt(
'value')).
" as value";
651 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
652 $sql .=
" WHERE name = '".$db->escape(
$db->encrypt($name, 0)).
"'";
653 $sql .=
" AND entity = ".((int) $entity);
655 $resql =
$db->query($sql);
657 $obj =
$db->fetch_object($resql);
659 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
683 global
$conf, $hookmanager;
691 dol_print_error(
$db,
"Error: Call to function dolibarr_set_const with wrong parameters");
694 if (! is_object($hookmanager)) {
695 require_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
705 'visible' => $visible,
710 $reshook = $hookmanager->executeHooks(
'dolibarrSetConst', $parameters);
719 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
720 $sql .=
" WHERE name = ".$db->encrypt($name);
722 $sql .=
" AND entity = ".((int) $entity);
725 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
726 $resql =
$db->query($sql);
728 if (strcmp($value,
'')) {
729 $tmpname = preg_replace(
'/(_TEST|_PROD)$/',
'', $name);
730 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name)
731 && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_TOKEN|_REFRESH)$/', $tmpname))) {
735 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
741 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
743 $sql .=
$db->encrypt($name);
744 $sql .=
", ".$db->encrypt($newvalue);
745 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".
$db->escape($note).
"', ".((int) $entity).
")";
749 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
750 $resql =
$db->query($sql);
755 $conf->global->$name = $value;
776 global $langs, $form;
778 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
779 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
785 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
786 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
788 $head[$h][1] = $langs->trans(
"AvailableModules");
789 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
792 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
794 $head[$h][2] =
'modules';
797 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
798 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
799 $head[$h][2] =
'marketplace';
802 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
803 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
804 $head[$h][2] =
'deploy';
807 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
808 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
809 $head[$h][2] =
'develop';
822 global $langs,
$conf;
826 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
827 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
828 $head[$h][2] =
'other';
831 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
832 $head[$h][1] = $langs->trans(
"SkinAndColors");
833 $head[$h][2] =
'template';
836 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
837 $head[$h][1] = $langs->trans(
"Dashboard");
838 $head[$h][2] =
'dashboard';
841 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
842 $head[$h][1] = $langs->trans(
"LoginPage");
843 $head[$h][2] =
'login';
846 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
847 $head[$h][1] = $langs->trans(
"CSSPage");
848 $head[$h][2] =
'css';
878 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
879 $head[$h][1] = $langs->trans(
"Miscellaneous");
880 $head[$h][2] =
'misc';
883 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
884 $head[$h][1] = $langs->trans(
"Captcha");
885 $head[$h][2] =
'captcha';
888 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
889 $head[$h][1] = $langs->trans(
"Passwords");
890 $head[$h][2] =
'passwords';
893 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
894 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
895 $head[$h][2] =
'file';
905 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
906 $head[$h][1] = $langs->trans(
"ExternalAccess");
907 $head[$h][2] =
'proxy';
910 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
911 $head[$h][1] = $langs->trans(
"Audit");
912 $head[$h][2] =
'audit';
915 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
916 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
917 $head[$h][2] =
'openid';
923 $sql =
"SELECT COUNT(r.id) as nb";
924 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
925 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
926 $sql .=
" AND entity = ".((int)
$conf->entity);
927 $sql .=
" AND bydefault = 1";
929 $sql .=
" AND r.perms NOT LIKE '%_advance'";
931 $resql =
$db->query($sql);
933 $obj =
$db->fetch_object($resql);
942 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
943 $head[$h][1] = $langs->trans(
"DefaultRights");
945 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
947 $head[$h][2] =
'default';
951 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
952 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
953 $head[$h][2] =
'headers_http';
967 global $langs,
$conf;
974 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
975 $head[$h][1] = $langs->trans(
"Description");
976 $head[$h][2] =
'desc';
979 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
980 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
981 $head[$h][2] =
'feature';
984 if (
$object->isCoreOrExternalModule() ==
'external') {
985 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
986 $head[$h][1] = $langs->trans(
"ChangeLog");
987 $head[$h][2] =
'changelog';
1005 global $langs,
$conf;
1009 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1010 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1011 $head[$h][2] =
'searchkey';
1014 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1015 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1016 $head[$h][2] =
'overwrite';
1035 global $langs,
$conf;
1039 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1040 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1041 $head[$h][2] =
'createform';
1044 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1045 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1046 $head[$h][2] =
'filters';
1049 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1050 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1051 $head[$h][2] =
'sortorder';
1054 if (!empty(
$conf->use_javascript_ajax)) {
1055 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1056 $head[$h][1] = $langs->trans(
"DefaultFocus");
1057 $head[$h][2] =
'focus';
1060 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1061 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1062 $head[$h][2] =
'mandatory';
1087 global
$conf, $php_session_save_handler;
1089 $arrayofSessions = array();
1091 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1092 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1097 $iniPath = ini_get(
"session.save_path");
1099 $sessPath = $iniPath;
1102 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1106 while (($file = @readdir($dh)) !==
false) {
1107 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1108 $fullpath = $sessPath.$file;
1109 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1110 $sessValues = file_get_contents($fullpath);
1116 if (preg_match(
'/dol_login/i', $sessValues) &&
1117 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1118 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1119 $tmp = explode(
'_', $file);
1122 $arrayofSessions[$idsess][
"login"] =
'';
1123 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1125 $arrayofSessions[$idsess][
"login"] = (
string) $regs[1];
1127 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1128 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1129 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1130 $arrayofSessions[$idsess][
"user_agent"] =
null;
1131 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1132 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1140 return $arrayofSessions;
1153 $sessPath = ini_get(
"session.save_path").
"/";
1154 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1160 while (($file = @readdir($dh)) !==
false) {
1161 if ($file !=
"." && $file !=
"..") {
1162 $fullpath = $sessPath.$file;
1163 if (!@is_dir($fullpath)) {
1164 $sessValues = file_get_contents($fullpath);
1166 if (preg_match(
'/dol_login/i', $sessValues) &&
1167 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1168 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1169 $tmp = explode(
'_', $file);
1172 if ($idsess != $mysessionid) {
1173 $res = @unlink($fullpath);
1203function activateModule($value, $withdeps = 1, $noconfverification = 0, $options =
'')
1210 if (empty($value)) {
1211 $ret[
'errors'] = array(
'ErrorBadParameter');
1215 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1217 $modFile = $modName.
".class.php";
1224 foreach ($modulesdir as $dir) {
1225 if (file_exists($dir.$modFile)) {
1226 $found = @include_once $dir.$modFile;
1233 $objMod =
new $modName(
$db);
1234 '@phan-var-force DolibarrModules $objMod';
1239 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1241 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1247 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1250 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1255 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1256 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1259 $const_name = $objMod->const_name;
1260 if ($noconfverification == 0) {
1266 $result = $objMod->init($options);
1269 $ret[
'errors'][] = $objMod->error;
1272 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1275 foreach ($objMod->depends as $key => $modulestringorarray) {
1277 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1278 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1282 if (!is_array($modulestringorarray)) {
1283 $modulestringorarray = array($modulestringorarray);
1286 foreach ($modulestringorarray as $modulestring) {
1289 $resarray = array();
1290 foreach ($modulesdir as $dir) {
1291 if (file_exists($dir.$modulestring.
".class.php")) {
1292 $resarray = activateModule($modulestring, 1, 0, $options);
1293 if (empty($resarray[
'errors'])) {
1296 $activateerr = implode(
', ', $resarray[
'errors']);
1297 foreach ($resarray[
'errors'] as $errorMessage) {
1306 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1307 $ret[
'nbperms'] += $resarray[
'nbperms'];
1310 $ret[
'errors'][] = $activateerr;
1312 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1318 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1320 $num = count($objMod->conflictwith);
1321 for ($i = 0; $i < $num; $i++) {
1322 foreach ($modulesdir as $dir) {
1323 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1324 unActivateModule($objMod->conflictwith[$i], 0);
1332 if (!count($ret[
'errors'])) {
1333 $ret[
'nbmodules']++;
1334 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1349function unActivateModule($value, $requiredby = 1, $options =
'')
1353 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1356 if (empty($value)) {
1357 return 'ErrorBadParameter';
1362 $modFile = $modName.
".class.php";
1369 foreach ($modulesdir as $dir) {
1370 if (file_exists($dir.$modFile)) {
1371 $found = @include_once $dir.$modFile;
1379 $objMod =
new $modName(
$db);
1380 '@phan-var-force DolibarrModules $objMod';
1383 $result = $objMod->remove($options);
1385 $ret = $objMod->error;
1390 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1392 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1393 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1394 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1395 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1396 $genericMod->remove(
'');
1400 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1401 $countrb = count($objMod->requiredby);
1402 for ($i = 0; $i < $countrb; $i++) {
1404 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1430function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1434 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1441 foreach ($modulesdir as $dir) {
1444 dol_syslog(
"Scan directory ".$dir.
" for modules");
1446 if (is_resource($handle)) {
1447 while (($file = readdir($handle)) !==
false) {
1449 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1450 $modName = substr($file, 0,
dol_strlen($file) - 10);
1453 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1454 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1457 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1458 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1462 include_once $dir.$file;
1463 $objMod =
new $modName(
$db);
1464 '@phan-var-force DolibarrModules $objMod';
1467 if ($objMod->numero > 0) {
1468 $j = $objMod->numero;
1473 $modulequalified = 1;
1476 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1478 $modulequalified = 0;
1481 $modulequalified = 0;
1485 $modulequalified = 0;
1488 if ($modulequalified) {
1490 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1491 foreach ($objMod->langfiles as $langfile) {
1492 $langs->load($langfile);
1499 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1501 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1505 if (!empty($objMod->dictionaries)) {
1507 $nbtabname = $nbtablib = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = $nbtabsql = 0;
1508 $tabnamerelwithkey = array();
1509 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1510 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1512 $taborder[] = max($taborder) + 1;
1514 $tabnamerelwithkey[$key] = $val;
1515 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1517 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1518 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1521 $tabcomplete[$tmptablename][
'lib'] = $val;
1523 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1524 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1527 $tabcomplete[$tmptablename][
'sql'] = $val;
1529 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1530 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1532 $tabsqlsort[] = $val;
1533 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1535 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1536 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1539 $tabcomplete[$tmptablename][
'field'] = $val;
1541 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1542 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1544 $tabfieldvalue[] = $val;
1545 $tabcomplete[$tmptablename][
'value'] = $val;
1547 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1548 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1549 $nbtabfieldinsert++;
1550 $tabfieldinsert[] = $val;
1551 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1553 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1554 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1556 $tabrowid[] = (int) $val;
1557 $tabcomplete[$tmptablename][
'rowid'] = (int) $val;
1559 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1560 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1563 $tabcomplete[$tmptablename][
'cond'] = $val;
1565 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1566 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1567 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1570 $tabcomplete[$tmptablename][
'help'] = $val;
1573 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1574 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1575 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1577 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1581 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1582 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1592 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1599 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1614function activateModulesRequiredByCountry($country_code)
1620 foreach ($modulesdir as $dir) {
1622 dol_syslog(
"Scan directory ".$dir.
" for modules");
1624 if (is_resource($handle)) {
1625 while (($file = readdir($handle)) !==
false) {
1626 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1627 $modName = substr($file, 0,
dol_strlen($file) - 10);
1630 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1631 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1634 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1635 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1639 include_once $dir.$file;
1640 $objMod =
new $modName(
$db);
1641 '@phan-var-force DolibarrModules $objMod';
1644 $modulequalified = 1;
1647 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1649 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1650 $modulequalified = 0;
1652 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1653 $modulequalified = 0;
1656 $modulequalified = 0;
1659 if ($modulequalified) {
1661 if (isset($objMod->automatic_activation[$country_code])) {
1662 activateModule($modName, 1, 0);
1664 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1667 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1674 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1687function complete_elementList_with_modules(&$elementList)
1689 global
$db, $modules,
$conf, $langs;
1692 $filename = array();
1701 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1705 foreach ($modulesdir as $dir) {
1708 dol_syslog(
"Scan directory ".$dir.
" for modules");
1710 if (is_resource($handle)) {
1711 while (($file = readdir($handle)) !==
false) {
1713 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1714 $modName = substr($file, 0,
dol_strlen($file) - 10);
1717 include_once $dir.$file;
1718 $objMod =
new $modName(
$db);
1721 if ($objMod->numero > 0) {
1722 $j = $objMod->numero;
1727 $modulequalified = 1;
1730 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1732 $modulequalified = 0;
1735 $modulequalified = 0;
1739 $modulequalified = 0;
1742 if ($modulequalified) {
1744 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1745 foreach ($objMod->langfiles as $langfile) {
1746 $langs->load($langfile);
1750 $modules[$i] = $objMod;
1751 $filename[$i] = $modName;
1752 $orders[$i] = $objMod->family.
"_".$j;
1756 if (!empty($objMod->module_parts[
'contactelement'])) {
1757 if (is_array($objMod->module_parts[
'contactelement'])) {
1758 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1759 $elementList[$elem] = $langs->trans($title);
1762 $elementList[$objMod->name] = $langs->trans($objMod->name);
1769 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1776 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1798 global $_Avery_Labels;
1802 print
'<div class="div-table-responsive-no-min">';
1803 print
'<table class="noborder centpercent">';
1804 print
'<tr class="liste_titre">';
1805 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1808 $text = $langs->trans($text);
1809 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1814 foreach ($tableau as $key => $const) {
1817 if (is_array($const)) {
1818 $type = $const[
'type'];
1819 $label = $const[
'label'];
1828 $sql .=
", ".$db->decrypt(
'name').
" as name";
1829 $sql .=
", ".$db->decrypt(
'value').
" as value";
1832 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1833 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".
$db->escape($const).
"'";
1834 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
1835 $sql .=
" ORDER BY name ASC, entity DESC";
1836 $result =
$db->query($sql);
1841 $obj =
$db->fetch_object($result);
1844 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1847 print
'<tr class="oddeven">';
1851 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1852 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1853 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1854 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1857 $tmparray = explode(
':', $obj->type);
1858 if (!empty($tmparray[1])) {
1859 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1861 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1863 if (!empty($tableau[$key][
'tooltip'])) {
1864 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1866 print($label ? $label : $langs->trans(
'Desc'.$const));
1869 if ($const ==
'ADHERENT_MAILMAN_URL') {
1870 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1872 print
'<div id="example1" class="hidden">';
1873 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';
1875 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1876 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1877 print
'<div id="example2" class="hidden">';
1878 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';
1881 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1882 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1883 print
'<div id="example3" class="hidden">';
1884 print
'mymailmanlist<br>';
1885 print
'mymailmanlist1,mymailmanlist2<br>';
1886 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1888 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1892 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1893 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1899 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1902 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1903 $arrayoflabels = array();
1904 foreach (array_keys($_Avery_Labels) as $codecards) {
1905 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1907 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1908 print
'<input type="hidden" name="consttype" value="yesno">';
1909 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1913 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1914 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1915 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1916 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1918 print
"</textarea>\n";
1919 } elseif ($obj->type ==
'html') {
1920 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1921 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1922 $doleditor->Create();
1923 } elseif ($obj->type ==
'yesno') {
1924 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1925 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1926 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1929 $tmp = explode(
':', $obj->type);
1931 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1933 $arrayofmessagename = array();
1934 if (is_array($formmail->lines_model)) {
1935 foreach ($formmail->lines_model as $modelmail) {
1937 if (!empty($arrayofmessagename[$modelmail->label])) {
1938 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1941 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1945 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1947 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>';
1948 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1949 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1951 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1974 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1978 if (!empty($modules)) {
1980 foreach ($tmpmodules as $module) {
1981 $moduleconst = $module->const_name;
1982 $modulename = strtolower($module->name);
1986 if (!in_array($modulename, $listofmodules)) {
1998 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1999 if ($tmptext !=
'Module'.$module->numero.
'Name') {
2000 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
2002 $text .= $langs->transnoentitiesnoconv($module->name);
2026 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2027 $sql .=
" VALUES ('".$db->escape($name).
"','".
$db->escape($type).
"',".((int)
$conf->entity).
", ";
2028 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2029 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2032 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2033 $resql =
$db->query($sql);
2057 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2058 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2059 $sql .=
" AND type = '".$db->escape($type).
"'";
2060 $sql .=
" AND entity = ".((int)
$conf->entity);
2062 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2063 $resql =
$db->query($sql);
2084 $phpinfostring = ob_get_contents();
2087 $info_arr = array();
2088 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2090 foreach ($info_lines as $line) {
2093 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2095 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2096 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2097 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2098 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2111 global $langs,
$conf;
2116 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2117 $head[$h][1] = $langs->trans(
"MyOrganization");
2118 $head[$h][2] =
'company';
2121 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2122 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2123 $head[$h][2] =
'socialnetworks';
2126 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2127 $head[$h][1] = $langs->trans(
"OpeningHours");
2128 $head[$h][2] =
'openinghours';
2131 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2132 $head[$h][1] = $langs->trans(
"Subcontractors");
2133 $head[$h][2] =
'subcontractors';
2150 global $langs,
$conf, $user;
2155 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2156 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2157 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2158 $head[$h][2] =
'common';
2162 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2163 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2164 $head[$h][2] =
'common_emailing';
2169 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2170 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2171 $head[$h][2] =
'common_ticket';
2175 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2176 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2177 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2178 $head[$h][2] =
'common_passwordreset';
2184 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2185 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2186 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2187 $head[$h][2] =
'senderprofiles';
2191 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2192 $head[$h][1] = $langs->trans(
"EMailTemplates");
2193 $head[$h][2] =
'templates';
2196 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2197 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2198 $head[$h][2] =
'common_ingoing';
2215 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2216 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2217 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2218 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2219 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2220 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2221 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2222 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2223 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2224 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2225 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2226 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2227 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2228 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2229 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2230 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2231 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2232 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2234 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2235 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2237 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2238 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2240 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2242 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2243 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2244 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2258 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2259 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2260 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2261 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2262 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2263 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2264 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2265 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2266 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2267 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2268 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2269 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2270 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2273 "document" => array(
2274 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2275 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2276 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2277 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2280 "navigation" => array(
2281 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2282 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2283 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2284 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2287 "reporting" => array(
2288 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2291 "require-trusted-types-for" => array(
2292 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2294 "trusted-types" => array(
2295 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2296 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2297 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2310 $forceCSPArr = array();
2312 $sourceCSPArrflatten = array();
2315 foreach ($sourceCSPArr as $key => $arr) {
2316 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2319 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2320 $securitypolicies = explode(
";", $forceCSP);
2323 foreach ($securitypolicies as $key => $securitypolicy) {
2324 if ($securitypolicy ==
"") {
2327 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2328 $securitypolicyarr = explode(
" ", $securitypolicy);
2329 $directive = array_shift($securitypolicyarr);
2331 while ($directive ==
"") {
2332 $directive = array_shift($securitypolicyarr);
2334 if (empty($directive)) {
2337 $sources = $securitypolicyarr;
2338 if (empty($sources)) {
2339 $forceCSPArr[$directive] = array();
2342 foreach ($sources as $key2 => $source) {
2343 $source = str_replace(
"'",
"", $source);
2344 if (empty($source)) {
2347 if (empty($forceCSPArr[$directive])) {
2348 $forceCSPArr[$directive] = array($source);
2350 $forceCSPArr[$directive][] = $source;
2355 return $forceCSPArr;
if(! $sortfield) if(! $sortorder) $object
versiontostring($versionarray)
Return a version in a string from a version into an array.
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)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
dolListSessions()
List sessions in db.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.
dolEncrypt($chain, $key='', $ciphering='', $forceseed='', $obfuscationmode='dolcrypt')
Encode a string with a symmetric encryption.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)