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) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $tmpname))) {
734 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
740 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
742 $sql .=
$db->encrypt($name);
743 $sql .=
", ".$db->encrypt($newvalue);
744 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".
$db->escape($note).
"', ".((int) $entity).
")";
748 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
749 $resql =
$db->query($sql);
754 $conf->global->$name = $value;
775 global $langs, $form;
777 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
778 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
784 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' => $mode]);
785 if ($nbmodulesnotautoenabled <
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
787 $head[$h][1] = $langs->trans(
"AvailableModules");
788 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
791 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
793 $head[$h][2] =
'modules';
796 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'marketplace']);
797 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
798 $head[$h][2] =
'marketplace';
801 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'deploy']);
802 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
803 $head[$h][2] =
'deploy';
806 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'mode' =>
'develop']);
807 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
808 $head[$h][2] =
'develop';
821 global $langs,
$conf;
825 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'other']);
826 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
827 $head[$h][2] =
'other';
830 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'template']);
831 $head[$h][1] = $langs->trans(
"SkinAndColors");
832 $head[$h][2] =
'template';
835 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'dashboard']);
836 $head[$h][1] = $langs->trans(
"Dashboard");
837 $head[$h][2] =
'dashboard';
840 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'login']);
841 $head[$h][1] = $langs->trans(
"LoginPage");
842 $head[$h][2] =
'login';
845 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/ihm.php', [
'mode' =>
'css']);
846 $head[$h][1] = $langs->trans(
"CSSPage");
847 $head[$h][2] =
'css';
877 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_other.php");
878 $head[$h][1] = $langs->trans(
"Miscellaneous");
879 $head[$h][2] =
'misc';
882 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_captcha.php");
883 $head[$h][1] = $langs->trans(
"Captcha");
884 $head[$h][2] =
'captcha';
887 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security.php");
888 $head[$h][1] = $langs->trans(
"Passwords");
889 $head[$h][2] =
'passwords';
892 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_file.php");
893 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"UploadName").
' | '.$langs->trans(
"Download").
')';
894 $head[$h][2] =
'file';
904 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/proxy.php");
905 $head[$h][1] = $langs->trans(
"ExternalAccess");
906 $head[$h][2] =
'proxy';
909 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/events.php");
910 $head[$h][1] = $langs->trans(
"Audit");
911 $head[$h][2] =
'audit';
914 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/openid_connect.php");
915 $head[$h][1] = $langs->trans(
"OpenIDconnectSetup");
916 $head[$h][2] =
'openid';
922 $sql =
"SELECT COUNT(r.id) as nb";
923 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
924 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
925 $sql .=
" AND entity = ".((int)
$conf->entity);
926 $sql .=
" AND bydefault = 1";
928 $sql .=
" AND r.perms NOT LIKE '%_advance'";
930 $resql =
$db->query($sql);
932 $obj =
$db->fetch_object($resql);
941 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/perms.php");
942 $head[$h][1] = $langs->trans(
"DefaultRights");
944 $head[$h][1] .= (!
getDolGlobalString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
946 $head[$h][2] =
'default';
950 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
"/admin/security_headers_http.php");
951 $head[$h][1] = $langs->trans(
"MainHttpSecurityHeaders");
952 $head[$h][2] =
'headers_http';
966 global $langs,
$conf;
973 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'desc']);
974 $head[$h][1] = $langs->trans(
"Description");
975 $head[$h][2] =
'desc';
978 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'feature']);
979 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
980 $head[$h][2] =
'feature';
983 if (
$object->isCoreOrExternalModule() ==
'external') {
984 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/modulehelp.php', [
'id' =>
$object->id,
'mode' =>
'changelog']);
985 $head[$h][1] = $langs->trans(
"ChangeLog");
986 $head[$h][2] =
'changelog';
1004 global $langs,
$conf;
1008 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'searchkey']);
1009 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
1010 $head[$h][2] =
'searchkey';
1013 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/translation.php', [
'mode' =>
'overwrite']);
1014 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1015 $head[$h][2] =
'overwrite';
1034 global $langs,
$conf;
1038 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
1039 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
1040 $head[$h][2] =
'createform';
1043 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
1044 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
1045 $head[$h][2] =
'filters';
1048 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
1049 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
1050 $head[$h][2] =
'sortorder';
1053 if (!empty(
$conf->use_javascript_ajax)) {
1054 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
1055 $head[$h][1] = $langs->trans(
"DefaultFocus");
1056 $head[$h][2] =
'focus';
1059 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
1060 $head[$h][1] = $langs->trans(
"DefaultMandatory");
1061 $head[$h][2] =
'mandatory';
1086 global
$conf, $php_session_save_handler;
1088 $arrayofSessions = array();
1090 if (!empty($php_session_save_handler) && $php_session_save_handler ==
'db') {
1091 require_once DOL_DOCUMENT_ROOT.
'/core/lib/phpsessionin'.$php_session_save_handler.
'.lib.php';
1096 $iniPath = ini_get(
"session.save_path");
1098 $sessPath = $iniPath;
1101 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1105 while (($file = @readdir($dh)) !==
false) {
1106 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1107 $fullpath = $sessPath.$file;
1108 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1109 $sessValues = file_get_contents($fullpath);
1115 if (preg_match(
'/dol_login/i', $sessValues) &&
1116 (preg_match(
'/dol_entity\|i:'.
$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.
$conf->entity.
'"/i', $sessValues)) &&
1117 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1118 $tmp = explode(
'_', $file);
1121 $arrayofSessions[$idsess][
"login"] =
'';
1122 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([^"]+)"/i', $sessValues, $regs);
1124 $arrayofSessions[$idsess][
"login"] = (
string) $regs[1];
1126 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1127 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1128 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1129 $arrayofSessions[$idsess][
"user_agent"] =
null;
1130 $arrayofSessions[$idsess][
"remote_ip"] =
null;
1131 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1139 return $arrayofSessions;
1152 $sessPath = ini_get(
"session.save_path").
"/";
1153 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1159 while (($file = @readdir($dh)) !==
false) {
1160 if ($file !=
"." && $file !=
"..") {
1161 $fullpath = $sessPath.$file;
1162 if (!@is_dir($fullpath)) {
1163 $sessValues = file_get_contents($fullpath);
1165 if (preg_match(
'/dol_login/i', $sessValues) &&
1166 (preg_match(
'/dol_entity\|i:('.
$conf->entity.
')/', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"('.
$conf->entity.
')"/i', $sessValues)) &&
1167 preg_match(
'/dol_company\|s:([0-9]+):"(' .
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1168 $tmp = explode(
'_', $file);
1171 if ($idsess != $mysessionid) {
1172 $res = @unlink($fullpath);
1202function activateModule($value, $withdeps = 1, $noconfverification = 0, $options =
'')
1209 if (empty($value)) {
1210 $ret[
'errors'] = array(
'ErrorBadParameter');
1214 $ret = array(
'nbmodules' => 0,
'errors' => array(),
'nbperms' => 0);
1216 $modFile = $modName.
".class.php";
1223 foreach ($modulesdir as $dir) {
1224 if (file_exists($dir.$modFile)) {
1225 $found = @include_once $dir.$modFile;
1232 $objMod =
new $modName(
$db);
1233 '@phan-var-force DolibarrModules $objMod';
1238 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1240 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1246 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1249 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1254 if (!empty($objMod->need_javascript_ajax) && empty(
$conf->use_javascript_ajax)) {
1255 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1258 $const_name = $objMod->const_name;
1259 if ($noconfverification == 0) {
1265 $result = $objMod->init($options);
1268 $ret[
'errors'][] = $objMod->error;
1271 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1274 foreach ($objMod->depends as $key => $modulestringorarray) {
1276 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) &&
$mysoc->country_code && !preg_match(
'/^'.
$mysoc->country_code.
'/', $key)) {
1277 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".
$mysoc->country_code);
1281 if (!is_array($modulestringorarray)) {
1282 $modulestringorarray = array($modulestringorarray);
1285 foreach ($modulestringorarray as $modulestring) {
1288 $resarray = array();
1289 foreach ($modulesdir as $dir) {
1290 if (file_exists($dir.$modulestring.
".class.php")) {
1291 $resarray = activateModule($modulestring, 1, 0, $options);
1292 if (empty($resarray[
'errors'])) {
1295 $activateerr = implode(
', ', $resarray[
'errors']);
1296 foreach ($resarray[
'errors'] as $errorMessage) {
1305 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1306 $ret[
'nbperms'] += $resarray[
'nbperms'];
1309 $ret[
'errors'][] = $activateerr;
1311 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring, $objMod->name).
'<br>'.$langs->trans(
'activateModuleDependNotSatisfied2', $modulestring, $objMod->name);
1317 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1319 $num = count($objMod->conflictwith);
1320 for ($i = 0; $i < $num; $i++) {
1321 foreach ($modulesdir as $dir) {
1322 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1323 unActivateModule($objMod->conflictwith[$i], 0);
1331 if (!count($ret[
'errors'])) {
1332 $ret[
'nbmodules']++;
1333 $ret[
'nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0);
1348function unActivateModule($value, $requiredby = 1, $options =
'')
1352 dol_syslog(
"unActivateModule value=".$value, LOG_INFO);
1355 if (empty($value)) {
1356 return 'ErrorBadParameter';
1361 $modFile = $modName.
".class.php";
1368 foreach ($modulesdir as $dir) {
1369 if (file_exists($dir.$modFile)) {
1370 $found = @include_once $dir.$modFile;
1378 $objMod =
new $modName(
$db);
1379 '@phan-var-force DolibarrModules $objMod';
1382 $result = $objMod->remove($options);
1384 $ret = $objMod->error;
1389 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1391 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1392 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1393 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1394 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1395 $genericMod->remove(
'');
1399 if (!$ret && $requiredby && isset($objMod) && is_object($objMod) && is_array($objMod->requiredby)) {
1400 $countrb = count($objMod->requiredby);
1401 for ($i = 0; $i < $countrb; $i++) {
1403 unActivateModule($objMod->requiredby[$i], $requiredby, $options);
1429function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1433 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionary tables", LOG_DEBUG, 1);
1440 foreach ($modulesdir as $dir) {
1443 dol_syslog(
"Scan directory ".$dir.
" for modules");
1445 if (is_resource($handle)) {
1446 while (($file = readdir($handle)) !==
false) {
1448 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1449 $modName = substr($file, 0,
dol_strlen($file) - 10);
1452 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1453 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1456 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1457 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1461 include_once $dir.$file;
1462 $objMod =
new $modName(
$db);
1463 '@phan-var-force DolibarrModules $objMod';
1466 if ($objMod->numero > 0) {
1467 $j = $objMod->numero;
1472 $modulequalified = 1;
1475 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1477 $modulequalified = 0;
1480 $modulequalified = 0;
1484 $modulequalified = 0;
1487 if ($modulequalified) {
1489 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1490 foreach ($objMod->langfiles as $langfile) {
1491 $langs->load($langfile);
1498 if (empty($objMod->dictionaries) && !empty($objMod->{
"dictionnaries"})) {
1500 $objMod->dictionaries = $objMod->{
"dictionnaries"};
1504 if (!empty($objMod->dictionaries)) {
1506 $nbtabname = $nbtablib = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = $nbtabsql = 0;
1507 $tabnamerelwithkey = array();
1508 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1509 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1511 $taborder[] = max($taborder) + 1;
1513 $tabnamerelwithkey[$key] = $val;
1514 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1516 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1517 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1520 $tabcomplete[$tmptablename][
'lib'] = $val;
1522 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1523 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1526 $tabcomplete[$tmptablename][
'sql'] = $val;
1528 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1529 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1531 $tabsqlsort[] = $val;
1532 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1534 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1535 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1538 $tabcomplete[$tmptablename][
'field'] = $val;
1540 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1541 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1543 $tabfieldvalue[] = $val;
1544 $tabcomplete[$tmptablename][
'value'] = $val;
1546 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1547 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1548 $nbtabfieldinsert++;
1549 $tabfieldinsert[] = $val;
1550 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1552 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1553 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1555 $tabrowid[] = (int) $val;
1556 $tabcomplete[$tmptablename][
'rowid'] = (int) $val;
1558 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1559 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1562 $tabcomplete[$tmptablename][
'cond'] = $val;
1564 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1565 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1566 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1569 $tabcomplete[$tmptablename][
'help'] = $val;
1572 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1573 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1574 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1576 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1580 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1581 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1591 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1598 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1613function activateModulesRequiredByCountry($country_code)
1619 foreach ($modulesdir as $dir) {
1621 dol_syslog(
"Scan directory ".$dir.
" for modules");
1623 if (is_resource($handle)) {
1624 while (($file = readdir($handle)) !==
false) {
1625 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1626 $modName = substr($file, 0,
dol_strlen($file) - 10);
1629 if ($modName ===
'modFournisseur' &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1630 dol_syslog(
"Module modFournisseur skipped because MAIN_USE_NEW_SUPPLIERMOD is enabled", LOG_DEBUG);
1633 if (in_array($modName, [
'modSupplierInvoice',
'modSupplierOrder']) && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) {
1634 dol_syslog(
"Module ".$modName.
" skipped because MAIN_USE_NEW_SUPPLIERMOD is disabled", LOG_DEBUG);
1638 include_once $dir.$file;
1639 $objMod =
new $modName(
$db);
1640 '@phan-var-force DolibarrModules $objMod';
1643 $modulequalified = 1;
1646 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1648 if ($objMod->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
1649 $modulequalified = 0;
1651 if ($objMod->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
1652 $modulequalified = 0;
1655 $modulequalified = 0;
1658 if ($modulequalified) {
1660 if (isset($objMod->automatic_activation[$country_code])) {
1661 activateModule($modName, 1, 0);
1663 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1666 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1673 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1686function complete_elementList_with_modules(&$elementList)
1688 global
$db, $modules,
$conf, $langs;
1691 $filename = array();
1700 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1704 foreach ($modulesdir as $dir) {
1707 dol_syslog(
"Scan directory ".$dir.
" for modules");
1709 if (is_resource($handle)) {
1710 while (($file = readdir($handle)) !==
false) {
1712 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1713 $modName = substr($file, 0,
dol_strlen($file) - 10);
1716 include_once $dir.$file;
1717 $objMod =
new $modName(
$db);
1720 if ($objMod->numero > 0) {
1721 $j = $objMod->numero;
1726 $modulequalified = 1;
1729 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1731 $modulequalified = 0;
1734 $modulequalified = 0;
1738 $modulequalified = 0;
1741 if ($modulequalified) {
1743 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1744 foreach ($objMod->langfiles as $langfile) {
1745 $langs->load($langfile);
1749 $modules[$i] = $objMod;
1750 $filename[$i] = $modName;
1751 $orders[$i] = $objMod->family.
"_".$j;
1755 if (!empty($objMod->module_parts[
'contactelement'])) {
1756 if (is_array($objMod->module_parts[
'contactelement'])) {
1757 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1758 $elementList[$elem] = $langs->trans($title);
1761 $elementList[$objMod->name] = $langs->trans($objMod->name);
1768 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1775 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1797 global $_Avery_Labels;
1801 print
'<div class="div-table-responsive-no-min">';
1802 print
'<table class="noborder centpercent">';
1803 print
'<tr class="liste_titre">';
1804 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1807 $text = $langs->trans($text);
1808 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1813 foreach ($tableau as $key => $const) {
1816 if (is_array($const)) {
1817 $type = $const[
'type'];
1818 $label = $const[
'label'];
1827 $sql .=
", ".$db->decrypt(
'name').
" as name";
1828 $sql .=
", ".$db->decrypt(
'value').
" as value";
1831 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1832 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".
$db->escape($const).
"'";
1833 $sql .=
" AND entity IN (0, ".((int)
$conf->entity).
")";
1834 $sql .=
" ORDER BY name ASC, entity DESC";
1835 $result =
$db->query($sql);
1840 $obj =
$db->fetch_object($result);
1843 $obj = (object) array(
'rowid' =>
'',
'name' => $const,
'value' =>
'',
'type' => $type,
'note' =>
'');
1846 print
'<tr class="oddeven">';
1850 print
'<input type="hidden" name="rowid[]" value="'.$obj->rowid.
'">';
1851 print
'<input type="hidden" name="constname[]" value="'.$const.
'">';
1852 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1853 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1856 $tmparray = explode(
':', $obj->type);
1857 if (!empty($tmparray[1])) {
1858 $picto = preg_replace(
'/_send$/',
'', $tmparray[1]);
1860 print
img_picto(
'', $picto,
'class="pictofixedwidth"');
1862 if (!empty($tableau[$key][
'tooltip'])) {
1863 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1865 print($label ? $label : $langs->trans(
'Desc'.$const));
1868 if ($const ==
'ADHERENT_MAILMAN_URL') {
1869 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1871 print
'<div id="example1" class="hidden">';
1872 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';
1874 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1875 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1876 print
'<div id="example2" class="hidden">';
1877 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';
1880 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1881 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1882 print
'<div id="example3" class="hidden">';
1883 print
'mymailmanlist<br>';
1884 print
'mymailmanlist1,mymailmanlist2<br>';
1885 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1887 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1891 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1892 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1898 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1901 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1902 $arrayoflabels = array();
1903 foreach (array_keys($_Avery_Labels) as $codecards) {
1904 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1906 print $form->selectarray(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1907 print
'<input type="hidden" name="consttype" value="yesno">';
1908 print
'<input type="hidden" name="constnote[]" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1912 print
'<input type="hidden" name="consttype'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1913 print
'<input type="hidden" name="constnote'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1914 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1915 print
'<textarea class="flat" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" cols="50" rows="5" wrap="soft">'.
"\n";
1917 print
"</textarea>\n";
1918 } elseif ($obj->type ==
'html') {
1919 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1920 $doleditor =
new DolEditor(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false,
isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1921 $doleditor->Create();
1922 } elseif ($obj->type ==
'yesno') {
1923 print $form->selectyesno(
'constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]'), $obj->value, 1,
false, 0, 1);
1924 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1925 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1928 $tmp = explode(
':', $obj->type);
1930 $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1932 $arrayofmessagename = array();
1933 if (is_array($formmail->lines_model)) {
1934 foreach ($formmail->lines_model as $modelmail) {
1936 if (!empty($arrayofmessagename[$modelmail->label])) {
1937 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1940 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1944 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1946 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>';
1947 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1948 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1950 print
'<input type="text" class="flat minwidth300" name="constvalue'.($strictw3c == 3 ?
'_'.$const :
'[]').
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1973 $text = $langs->transnoentitiesnoconv(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1977 if (!empty($modules)) {
1979 foreach ($tmpmodules as $module) {
1980 $moduleconst = $module->const_name;
1981 $modulename = strtolower($module->name);
1985 if (!in_array($modulename, $listofmodules)) {
1997 $tmptext = $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
1998 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1999 $text .= $langs->transnoentitiesnoconv(
'Module'.$module->numero.
'Name');
2001 $text .= $langs->transnoentitiesnoconv($module->name);
2025 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
2026 $sql .=
" VALUES ('".$db->escape($name).
"','".
$db->escape($type).
"',".((int)
$conf->entity).
", ";
2027 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
2028 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
2031 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
2032 $resql =
$db->query($sql);
2056 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
2057 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
2058 $sql .=
" AND type = '".$db->escape($type).
"'";
2059 $sql .=
" AND entity = ".((int)
$conf->entity);
2061 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
2062 $resql =
$db->query($sql);
2083 $phpinfostring = ob_get_contents();
2086 $info_arr = array();
2087 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
2089 foreach ($info_lines as $line) {
2092 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
2094 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2095 $info_arr[trim($cat)][trim($val[1])] = $val[2];
2096 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
2097 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2110 global $langs,
$conf;
2115 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2116 $head[$h][1] = $langs->trans(
"MyOrganization");
2117 $head[$h][2] =
'company';
2120 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2121 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2122 $head[$h][2] =
'socialnetworks';
2125 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2126 $head[$h][1] = $langs->trans(
"OpeningHours");
2127 $head[$h][2] =
'openinghours';
2130 $head[$h][0] = DOL_URL_ROOT.
"/admin/subcontractors.php";
2131 $head[$h][1] = $langs->trans(
"Subcontractors");
2132 $head[$h][2] =
'subcontractors';
2149 global $langs,
$conf, $user;
2154 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2155 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2156 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2157 $head[$h][2] =
'common';
2161 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2162 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2163 $head[$h][2] =
'common_emailing';
2168 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2169 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2170 $head[$h][2] =
'common_ticket';
2174 if (!
getDolGlobalString(
'MAIN_MAIL_HIDE_CUSTOM_SENDING_METHOD_FOR_PASSWORD_RESET')) {
2175 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_passwordreset.php";
2176 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"PasswordReset"));
2177 $head[$h][2] =
'common_passwordreset';
2183 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2184 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2185 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2186 $head[$h][2] =
'senderprofiles';
2190 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2191 $head[$h][1] = $langs->trans(
"EMailTemplates");
2192 $head[$h][2] =
'templates';
2195 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2196 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2197 $head[$h][2] =
'common_ingoing';
2214 "child-src" => array(
"label" =>
"child-src",
"data-directivetype" =>
"fetch"),
2215 "connect-src" => array(
"label" =>
"connect-src",
"data-directivetype" =>
"fetch"),
2216 "default-src" => array(
"label" =>
"default-src",
"data-directivetype" =>
"fetch"),
2217 "fenced-frame-src" => array(
"label" =>
"fenced-frame-src",
"data-directivetype" =>
"fetch"),
2218 "font-src" => array(
"label" =>
"font-src",
"data-directivetype" =>
"fetch"),
2219 "frame-src" => array(
"label" =>
"frame-src",
"data-directivetype" =>
"fetch"),
2220 "img-src" => array(
"label" =>
"img-src",
"data-directivetype" =>
"fetch"),
2221 "manifest-src" => array(
"label" =>
"manifest-src",
"data-directivetype" =>
"fetch"),
2222 "media-src" => array(
"label" =>
"media-src",
"data-directivetype" =>
"fetch"),
2223 "object-src" => array(
"label" =>
"object-src",
"data-directivetype" =>
"fetch"),
2224 "prefetch-src" => array(
"label" =>
"prefetch-src",
"data-directivetype" =>
"fetch"),
2225 "script-src" => array(
"label" =>
"script-src",
"data-directivetype" =>
"fetch"),
2226 "script-src-elem" => array(
"label" =>
"script-src-elem",
"data-directivetype" =>
"fetch"),
2227 "script-src-attr" => array(
"label" =>
"script-src-attr",
"data-directivetype" =>
"fetch"),
2228 "style-src" => array(
"label" =>
"style-src",
"data-directivetype" =>
"fetch"),
2229 "style-src-elem" => array(
"label" =>
"style-src-elem",
"data-directivetype" =>
"fetch"),
2230 "style-src-attr" => array(
"label" =>
"style-src-attr",
"data-directivetype" =>
"fetch"),
2231 "worker-src" => array(
"label" =>
"worker-src",
"data-directivetype" =>
"fetch"),
2233 "base-uri" => array(
"label" =>
"base-uri",
"data-directivetype" =>
"document"),
2234 "sandbox" => array(
"label" =>
"sandbox",
"data-directivetype" =>
"document"),
2236 "form-action" => array(
"label" =>
"form-action",
"data-directivetype" =>
"navigation"),
2237 "frame-ancestors" => array(
"label" =>
"frame-ancestors",
"data-directivetype" =>
"navigation"),
2239 "report-to" => array(
"label" =>
"report-to",
"data-directivetype" =>
"reporting"),
2241 "require-trusted-types-for" => array(
"label" =>
"require-trusted-types-for",
"data-directivetype" =>
"require-trusted-types-for"),
2242 "trusted-types" => array(
"label" =>
"trusted-types",
"data-directivetype" =>
"trusted-types"),
2243 "upgrade-insecure-requests" => array(
"label" =>
"upgrade-insecure-requests",
"data-directivetype" =>
"none"),
2257 "*" => array(
"label" =>
"*",
"data-sourcetype" =>
"select"),
2258 "blob" => array(
"label" =>
"blob:",
"data-sourcetype" =>
"blob"),
2259 "data" => array(
"label" =>
"data:",
"data-sourcetype" =>
"data"),
2260 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2261 "unsafe-eval" => array(
"label" =>
"unsafe-eval",
"data-sourcetype" =>
"quoted"),
2262 "wasm-unsafe-eval" => array(
"label" =>
"wasm-unsafe-eval",
"data-sourcetype" =>
"quoted"),
2263 "unsafe-inline" => array(
"label" =>
"unsafe-inline",
"data-sourcetype" =>
"quoted"),
2264 "unsafe-hashes" => array(
"label" =>
"unsafe-hashes",
"data-sourcetype" =>
"quoted"),
2265 "inline-speculation-rules" => array(
"label" =>
"inline-speculation-rules",
"data-sourcetype" =>
"quoted"),
2266 "strict-dynamic" => array(
"label" =>
"strict-dynamic",
"data-sourcetype" =>
"quoted"),
2267 "report-sample" => array(
"label" =>
"report-sample",
"data-sourcetype" =>
"quoted"),
2268 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2269 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2272 "document" => array(
2273 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2274 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2275 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2276 "scheme-source" => array(
"label" =>
"scheme-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2279 "navigation" => array(
2280 "none" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2281 "self" => array(
"label" =>
"self",
"data-sourcetype" =>
"quoted"),
2282 "host-source" => array(
"label" =>
"host-source (*.mydomain.com)",
"data-sourcetype" =>
"input"),
2283 "scheme-source" => array(
"label" =>
"scheme-source",
"data-sourcetype" =>
"input"),
2286 "reporting" => array(
2287 "report-to" => array(
"label" =>
"report-to",
"data-sourcetype" =>
"input"),
2290 "require-trusted-types-for" => array(
2291 "script" => array(
"label" =>
"script",
"data-sourcetype" =>
"select"),
2293 "trusted-types" => array(
2294 "policyName" => array(
"label" =>
"policyName",
"data-sourcetype" =>
"input"),
2295 "none" => array(
"label" =>
"none",
"data-sourcetype" =>
"quoted"),
2296 "allow-duplicates" => array(
"label" =>
"allow-duplicates",
"data-sourcetype" =>
"quoted"),
2309 $forceCSPArr = array();
2311 $sourceCSPArrflatten = array();
2314 foreach ($sourceCSPArr as $key => $arr) {
2315 $sourceCSPArrflatten = array_merge($sourceCSPArrflatten, array_keys($arr));
2318 $forceCSP = preg_replace(
'/;base64,/',
"__semicolumnbase64__", $forceCSP);
2319 $securitypolicies = explode(
";", $forceCSP);
2322 foreach ($securitypolicies as $key => $securitypolicy) {
2323 if ($securitypolicy ==
"") {
2326 $securitypolicy = preg_replace(
'/__semicolumnbase64__/',
";base64,", $securitypolicy);
2327 $securitypolicyarr = explode(
" ", $securitypolicy);
2328 $directive = array_shift($securitypolicyarr);
2330 while ($directive ==
"") {
2331 $directive = array_shift($securitypolicyarr);
2333 if (empty($directive)) {
2336 $sources = $securitypolicyarr;
2337 if (empty($sources)) {
2338 $forceCSPArr[$directive] = array();
2341 foreach ($sources as $key2 => $source) {
2342 $source = str_replace(
"'",
"", $source);
2343 if (empty($source)) {
2346 if (empty($forceCSPArr[$directive])) {
2347 $forceCSPArr[$directive] = array($source);
2349 $forceCSPArr[$directive][] = $source;
2354 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.
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.
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.
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.
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)
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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
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)