28require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
40 if (isset($versionarray[0])) {
41 $string = $versionarray[0];
43 if (isset($versionarray[1])) {
44 $string .=
'.'.$versionarray[1];
46 if (isset($versionarray[2])) {
47 $string .=
'.'.$versionarray[2];
71 $count1 = count($versionarray1);
72 $count2 = count($versionarray2);
73 $maxcount = max($count1, $count2);
74 while ($level < $maxcount) {
75 $operande1 = isset($versionarray1[$level]) ? $versionarray1[$level] : 0;
76 $operande2 = isset($versionarray2[$level]) ? $versionarray2[$level] : 0;
77 if (preg_match(
'/alpha|dev/i', $operande1)) {
80 if (preg_match(
'/alpha|dev/i', $operande2)) {
83 if (preg_match(
'/beta$/i', $operande1)) {
86 if (preg_match(
'/beta$/i', $operande2)) {
89 if (preg_match(
'/beta([0-9])+/i', $operande1)) {
92 if (preg_match(
'/beta([0-9])+/i', $operande2)) {
95 if (preg_match(
'/rc$/i', $operande1)) {
98 if (preg_match(
'/rc$/i', $operande2)) {
101 if (preg_match(
'/rc([0-9])+/i', $operande1)) {
104 if (preg_match(
'/rc([0-9])+/i', $operande2)) {
109 if ($operande1 < $operande2) {
113 if ($operande1 > $operande2) {
131 return explode(
'.', PHP_VERSION);
142 return explode(
'.', DOL_VERSION);
169function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler =
'', $okerror =
'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0, $database =
'')
171 global $db, $conf, $langs, $user;
173 dol_syslog(
"Admin.lib::run_sql run sql file ".$sqlfile.
" silent=".$silent.
" entity=".$entity.
" usesavepoint=".$usesavepoint.
" handler=".$handler.
" okerror=".$okerror, LOG_DEBUG);
175 if (!is_numeric($linelengthlimit)) {
176 dol_syslog(
"Admin.lib::run_sql param linelengthlimit is not a numeric", LOG_ERR);
187 $versionarray = $db->getVersionArray();
189 $fp = fopen($sqlfile,
"r");
193 if ($linelengthlimit > 0) {
194 $buf = fgets($fp, $linelengthlimit);
201 if (preg_match(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i', $buf, $reg)) {
205 if (!empty($reg[1])) {
206 if (!preg_match(
'/'.preg_quote($reg[1]).
'/i', $db->type)) {
213 if (!empty($reg[2])) {
214 if (is_numeric($reg[2])) {
215 $versionrequest = explode(
'.', $reg[2]);
218 if (!count($versionrequest) || !count($versionarray) ||
versioncompare($versionrequest, $versionarray) > 0) {
223 $dbcollation = strtoupper(preg_replace(
'/_/',
'', $conf->db->dolibarr_main_db_collation));
226 if (empty($conf->db->dolibarr_main_db_collation) || ($reg[2] != $dbcollation)) {
236 $buf = preg_replace(
'/^--\sV(MYSQL|PGSQL)([^\s]*)/i',
'', $buf);
242 if ($nocommentremoval || !preg_match(
'/^\s*--/', $buf)) {
243 if (empty($nocommentremoval)) {
244 $buf = preg_replace(
'/([,;ERLT\)])\s*--.*$/i',
'\1', $buf);
246 if ($buffer) $buffer .=
' ';
247 $buffer .= trim($buf);
252 if (preg_match(
'/;/', $buffer)) {
255 $arraysql[$i] = $buffer;
263 $arraysql[$i] = $buffer;
267 dol_syslog(
"Admin.lib::run_sql failed to open file ".$sqlfile, LOG_ERR);
271 $listofmaxrowid = array();
272 foreach ($arraysql as $i => $sql) {
276 while (preg_match(
'/__\+MAX_([A-Za-z0-9_]+)__/i', $newsql, $reg)) {
278 if (!isset($listofmaxrowid[$table])) {
280 $sqlgetrowid =
'SELECT MAX(rowid) as max from '.preg_replace(
'/^llx_/', MAIN_DB_PREFIX, $table);
281 $resql = $db->query($sqlgetrowid);
283 $obj = $db->fetch_object($resql);
284 $listofmaxrowid[$table] = $obj->max;
285 if (empty($listofmaxrowid[$table])) {
286 $listofmaxrowid[$table] = 0;
290 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
291 print
'<div class="error">'.$langs->trans(
"Failed to get max rowid for ".$table).
"</div>";
299 $from =
'__+MAX_'.$table.
'__';
300 $to =
'+'.$listofmaxrowid[$table];
301 $newsql = str_replace($from, $to, $newsql);
302 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1).
' (replacing '.$from.
' to '.$to.
')', LOG_DEBUG);
304 $arraysql[$i] = $newsql;
307 if ($offsetforchartofaccount > 0) {
313 $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);
314 $newsql = preg_replace(
'/([,\s])0 \+ '.((
int) $offsetforchartofaccount).
'/ims',
'\1 0', $newsql);
316 $arraysql[$i] = $newsql;
325 $listofinsertedrowid = array();
326 $keyforsql = md5($sqlfile);
327 foreach ($arraysql as $i => $sql) {
330 if ($onlysqltoimportwebsite) {
331 $newsql = str_replace(array(
"\'"),
'__BACKSLASHQUOTE__', $sql);
334 $l = strlen($newsql);
339 $char = $newsql[$is];
346 } elseif (empty($quoteopen)) {
347 $newsqlclean .= $char;
351 $newsqlclean = str_replace(array(
"null"),
'__000__', $newsqlclean);
357 if (preg_match(
'/^--/', $newsqlclean)) {
359 } elseif (preg_match(
'/^UPDATE llx_website SET \w+ = \d+\+\d+ WHERE rowid = \d+;$/', $newsqlclean)) {
361 } elseif (preg_match(
'/^INSERT INTO llx_website_page\([a-z0-9_\s,]+\) VALUES\([0-9_\s,\+]+\);$/', $newsqlclean)) {
369 if (preg_match(
'/^UPDATE llx_website SET \w+ = \'[a-zA-Z,\s]*\' WHERE rowid = \d+;$/', $sql)) {
378 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" contains non allowed instructions.", LOG_WARNING);
379 dol_syslog(
'$newsqlclean='.$newsqlclean, LOG_DEBUG);
385 if (MAIN_DB_PREFIX !=
'llx_') {
386 $sql = preg_replace(
'/llx_/i', MAIN_DB_PREFIX, $sql);
389 if (!empty($handler)) {
390 $sql = preg_replace(
'/__HANDLER__/i',
"'".$db->escape($handler).
"'", $sql);
393 if (!empty($database)) {
394 $sql = preg_replace(
'/__DATABASE__/i', $db->escape($database), $sql);
397 $newsql = preg_replace(
'/__ENTITY__/i', (!empty($entity) ? $entity : $conf->entity), $sql);
401 print
'<tr class="trforrunsql'.$keyforsql.
'"><td class="tdtop opacitymedium"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>'.$langs->trans(
"Request").
' '.($i + 1).
" sql='".
dol_htmlentities($newsql, ENT_NOQUOTES).
"'</td></tr>\n";
403 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1), LOG_DEBUG);
407 if (preg_match_all(
'/__ENCRYPT\(\'([^\']+)\'\)__/i', $newsql, $reg)) {
408 $num = count($reg[0]);
410 for ($j = 0; $j < $num; $j++) {
412 $to = $db->encrypt($reg[1][$j]);
413 $newsql = str_replace($from, $to, $newsql);
419 if (preg_match_all(
'/__DECRYPT\(\'([A-Za-z0-9_]+)\'\)__/i', $newsql, $reg)) {
420 $num = count($reg[0]);
422 for ($j = 0; $j < $num; $j++) {
424 $to = $db->decrypt($reg[1][$j]);
425 $newsql = str_replace($from, $to, $newsql);
431 while (preg_match(
'/__([0-9]+)__/', $newsql, $reg)) {
433 if (empty($listofinsertedrowid[$cursor])) {
435 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
436 print
'<div class="error">'.$langs->trans(
"FileIsNotCorrect").
"</div>";
443 $from =
'__'.$cursor.
'__';
444 $to = $listofinsertedrowid[$cursor];
445 $newsql = str_replace($from, $to, $newsql);
450 dol_syslog(
'Admin.lib::run_sql New Request '.($i + 1), LOG_DEBUG);
453 $result = $db->query($newsql, $usesavepoint);
456 print
'<!-- Result = OK -->'.
"\n";
459 if (preg_replace(
'/insert into ([^\s]+)/i', $newsql, $reg)) {
463 $table = preg_replace(
'/([^a-zA-Z_]+)/i',
'', $reg[1]);
464 $insertedrowid = $db->last_insert_id($table);
465 $listofinsertedrowid[$cursorinsert] = $insertedrowid;
466 dol_syslog(
'Admin.lib::run_sql Insert nb '.$cursorinsert.
', done in table '.$table.
', rowid is '.$listofinsertedrowid[$cursorinsert], LOG_DEBUG);
470 $errno = $db->errno();
472 print
'<!-- Result = '.$errno.
' -->'.
"\n";
477 'DB_ERROR_TABLE_ALREADY_EXISTS',
478 'DB_ERROR_COLUMN_ALREADY_EXISTS',
479 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
480 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS',
481 'DB_ERROR_RECORD_ALREADY_EXISTS',
482 'DB_ERROR_NOSUCHTABLE',
483 'DB_ERROR_NOSUCHFIELD',
484 'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
485 'DB_ERROR_NO_INDEX_TO_DROP',
486 'DB_ERROR_CANNOT_CREATE',
487 'DB_ERROR_CANT_DROP_PRIMARY_KEY',
488 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS',
491 if ($okerror ==
'none') {
496 if (!in_array($errno, $okerrors)) {
498 print
'<tr><td class="tdtop"'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'>';
499 print
'<div class="error">'.$langs->trans(
"Error").
" ".$db->errno().
" (Req ".($i + 1).
"): ".$newsql.
"<br>".$db->error().
"</div>";
500 print
'</td></tr>'.
"\n";
502 dol_syslog(
'Admin.lib::run_sql Request '.($i + 1).
" Error ".$db->errno().
" ".$newsql.
"<br>".$db->error(), LOG_ERR);
510 print
'<tr><td>'.$langs->trans(
"ProcessMigrateScript").
'</td>';
511 print
'<td class="right">';
513 print
'<span class="ok">'.$langs->trans(
"OK").
'</span>';
515 print
'<span class="error">'.$langs->trans(
"Error").
'</span>';
519 print
'<script type="text/javascript">
520 jQuery(document).ready(function() {
521 function init_trrunsql'.$keyforsql.
'()
523 console.log("toggle .trforrunsql'.$keyforsql.
'");
524 jQuery(".trforrunsql'.$keyforsql.
'").toggle();
526 init_trrunsql'.$keyforsql.
'();
527 jQuery(".trforrunsqlshowhide'.$keyforsql.
'").click(function() {
528 init_trrunsql'.$keyforsql.
'();
532 if (count($arraysql)) {
533 print
' - <a class="trforrunsqlshowhide'.$keyforsql.
'" href="#" title="'.($langs->trans(
"ShowHideTheNRequests", count($arraysql))).
'">'.$langs->trans(
"ShowHideDetails").
'</a>';
535 print
' - <span class="opacitymedium">'.$langs->trans(
"ScriptIsEmpty").
'</span>';
539 print
'</td></tr>'.
"\n";
567 dol_print_error(
'',
'Error call dolibar_del_const with parameter name empty');
571 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
572 $sql .=
" WHERE (".$db->decrypt(
'name').
" = '".$db->escape($name).
"'";
573 if (is_numeric($name)) {
574 $sql .=
" OR rowid = ".((int) $name);
578 $sql .=
" AND entity = ".((int) $entity);
581 dol_syslog(
"admin.lib::dolibarr_del_const", LOG_DEBUG);
582 $resql = $db->query($sql);
584 $conf->global->$name =
'';
606 $sql =
"SELECT ".$db->decrypt(
'value').
" as value";
607 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
608 $sql .=
" WHERE name = ".$db->encrypt($name);
609 $sql .=
" AND entity = ".((int) $entity);
611 dol_syslog(
"admin.lib::dolibarr_get_const", LOG_DEBUG);
612 $resql = $db->query($sql);
614 $obj = $db->fetch_object($resql);
616 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
638function dolibarr_set_const($db, $name, $value, $type =
'chaine', $visible = 0, $note =
'', $entity = 1)
647 dol_print_error($db,
"Error: Call to function dolibarr_set_const with wrong parameters", LOG_ERR);
655 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"const";
656 $sql .=
" WHERE name = ".$db->encrypt($name);
658 $sql .=
" AND entity = ".((int) $entity);
661 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
662 $resql = $db->query($sql);
664 if (strcmp($value,
'')) {
665 if (!preg_match(
'/^(MAIN_LOGEVENTS|MAIN_AGENDA_ACTIONAUTO)/', $name) && (preg_match(
'/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
670 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
676 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"const(name, value, type, visible, note, entity)";
678 $sql .= $db->encrypt($name);
679 $sql .=
", ".$db->encrypt($newvalue);
680 $sql .=
", '".$db->escape($type).
"', ".((int) $visible).
", '".$db->escape($note).
"', ".((int) $entity).
")";
684 dol_syslog(
"admin.lib::dolibarr_set_const", LOG_DEBUG);
685 $resql = $db->query($sql);
690 $conf->global->$name = $value;
693 $error = $db->lasterror();
712 global $langs, $conf, $user, $form;
714 $desc = $langs->trans(
"ModulesDesc",
'{picto}');
715 $desc = str_replace(
'{picto}',
img_picto(
'',
'switch_off'), $desc);
719 $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ?
'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT;
720 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=".$mode;
721 if ($nbmodulesnotautoenabled <=
getDolGlobalInt(
'MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) {
723 $head[$h][1] = $langs->trans(
"AvailableModules");
724 $head[$h][1] .= $form->textwithpicto(
'', $langs->trans(
"YouMustEnableOneModule").
'.<br><br><span class="opacitymedium">'.$desc.
'</span>', 1,
'warning');
727 $head[$h][1] = $langs->trans(
"AvailableModules").
'<span class="badge marginleftonly">'.$nbofactivatedmodules.
' / '.$nboftotalmodules.
'</span>';
729 $head[$h][2] =
'modules';
732 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=marketplace";
733 $head[$h][1] = $langs->trans(
"ModulesMarketPlaces");
734 $head[$h][2] =
'marketplace';
737 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=deploy";
738 $head[$h][1] = $langs->trans(
"AddExtensionThemeModuleOrOther");
739 $head[$h][2] =
'deploy';
742 $head[$h][0] = DOL_URL_ROOT.
"/admin/modules.php?mode=develop";
743 $head[$h][1] = $langs->trans(
"ModulesDevelopYourModule");
744 $head[$h][2] =
'develop';
757 global $langs, $conf, $user;
761 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=other";
762 $head[$h][1] = $langs->trans(
"LanguageAndPresentation");
763 $head[$h][2] =
'other';
766 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=template";
767 $head[$h][1] = $langs->trans(
"SkinAndColors");
768 $head[$h][2] =
'template';
771 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=dashboard";
772 $head[$h][1] = $langs->trans(
"Dashboard");
773 $head[$h][2] =
'dashboard';
776 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=login";
777 $head[$h][1] = $langs->trans(
"LoginPage");
778 $head[$h][2] =
'login';
781 $head[$h][0] = DOL_URL_ROOT.
"/admin/ihm.php?mode=css";
782 $head[$h][1] = $langs->trans(
"CSSPage");
783 $head[$h][2] =
'css';
802 global $db, $langs, $conf, $user;
806 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_other.php";
807 $head[$h][1] = $langs->trans(
"Miscellaneous");
808 $head[$h][2] =
'misc';
811 $head[$h][0] = DOL_URL_ROOT.
"/admin/security.php";
812 $head[$h][1] = $langs->trans(
"Passwords");
813 $head[$h][2] =
'passwords';
816 $head[$h][0] = DOL_URL_ROOT.
"/admin/security_file.php";
817 $head[$h][1] = $langs->trans(
"Files").
' ('.$langs->trans(
"Upload").
')';
818 $head[$h][2] =
'file';
828 $head[$h][0] = DOL_URL_ROOT.
"/admin/proxy.php";
829 $head[$h][1] = $langs->trans(
"ExternalAccess");
830 $head[$h][2] =
'proxy';
833 $head[$h][0] = DOL_URL_ROOT.
"/admin/events.php";
834 $head[$h][1] = $langs->trans(
"Audit");
835 $head[$h][2] =
'audit';
841 $sql =
"SELECT COUNT(r.id) as nb";
842 $sql .=
" FROM ".MAIN_DB_PREFIX.
"rights_def as r";
843 $sql .=
" WHERE r.libelle NOT LIKE 'tou%'";
844 $sql .=
" AND entity = ".((int) $conf->entity);
845 $sql .=
" AND bydefault = 1";
846 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
847 $sql .=
" AND r.perms NOT LIKE '%_advance'";
849 $resql = $db->query($sql);
851 $obj = $db->fetch_object($resql);
859 $head[$h][0] = DOL_URL_ROOT.
"/admin/perms.php";
860 $head[$h][1] = $langs->trans(
"DefaultRights");
862 $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ?
'<span class="badge marginleftonlyshort">'.$nbPerms.
'</span>' :
'');
864 $head[$h][2] =
'default';
877 global $langs, $conf, $user;
882 $object->id = $object->numero;
884 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=desc';
885 $head[$h][1] = $langs->trans(
"Description");
886 $head[$h][2] =
'desc';
889 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=feature';
890 $head[$h][1] = $langs->trans(
"TechnicalServicesProvided");
891 $head[$h][2] =
'feature';
894 if ($object->isCoreOrExternalModule() ==
'external') {
895 $head[$h][0] = DOL_URL_ROOT.
"/admin/modulehelp.php?id=".$object->id.
'&mode=changelog';
896 $head[$h][1] = $langs->trans(
"ChangeLog");
897 $head[$h][2] =
'changelog';
915 global $langs, $conf, $user;
919 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=searchkey";
920 $head[$h][1] = $langs->trans(
"TranslationKeySearch");
921 $head[$h][2] =
'searchkey';
924 $head[$h][0] = DOL_URL_ROOT.
"/admin/translation.php?mode=overwrite";
925 $head[$h][1] =
'<span class="valignmiddle">'.$langs->trans(
"TranslationOverwriteKey").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
926 $head[$h][2] =
'overwrite';
945 global $langs, $conf, $user;
949 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=createform";
950 $head[$h][1] = $langs->trans(
"DefaultCreateForm");
951 $head[$h][2] =
'createform';
954 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=filters";
955 $head[$h][1] = $langs->trans(
"DefaultSearchFilters");
956 $head[$h][2] =
'filters';
959 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=sortorder";
960 $head[$h][1] = $langs->trans(
"DefaultSortOrder");
961 $head[$h][2] =
'sortorder';
964 if (!empty($conf->use_javascript_ajax)) {
965 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=focus";
966 $head[$h][1] = $langs->trans(
"DefaultFocus");
967 $head[$h][2] =
'focus';
970 $head[$h][0] = DOL_URL_ROOT.
"/admin/defaultvalues.php?mode=mandatory";
971 $head[$h][1] = $langs->trans(
"DefaultMandatory");
972 $head[$h][2] =
'mandatory';
999 $arrayofSessions = array();
1002 $iniPath = ini_get(
"session.save_path");
1004 $sessPath = $iniPath;
1007 dol_syslog(
'admin.lib:listOfSessions sessPath='.$sessPath);
1011 while (($file = @readdir($dh)) !==
false) {
1012 if (preg_match(
'/^sess_/i', $file) && $file !=
"." && $file !=
"..") {
1013 $fullpath = $sessPath.$file;
1014 if (!@is_dir($fullpath) && is_readable($fullpath)) {
1015 $sessValues = file_get_contents($fullpath);
1021 if (preg_match(
'/dol_login/i', $sessValues) &&
1022 (preg_match(
'/dol_entity\|i:'.$conf->entity.
';/i', $sessValues) || preg_match(
'/dol_entity\|s:([0-9]+):"'.$conf->entity.
'"/i', $sessValues)) &&
1023 preg_match(
'/dol_company\|s:([0-9]+):"('.
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM').
')"/i', $sessValues)) {
1024 $tmp = explode(
'_', $file);
1027 $loginfound = preg_match(
'/dol_login\|s:[0-9]+:"([A-Za-z0-9]+)"/i', $sessValues, $regs);
1029 $arrayofSessions[$idsess][
"login"] = $regs[1];
1031 $arrayofSessions[$idsess][
"age"] = time() - filectime($fullpath);
1032 $arrayofSessions[$idsess][
"creation"] = filectime($fullpath);
1033 $arrayofSessions[$idsess][
"modification"] = filemtime($fullpath);
1034 $arrayofSessions[$idsess][
"raw"] = $sessValues;
1042 return $arrayofSessions;
1055 $sessPath = ini_get(
"session.save_path").
"/";
1056 dol_syslog(
'admin.lib:purgeSessions mysessionid='.$mysessionid.
' sessPath='.$sessPath);
1062 while (($file = @readdir($dh)) !==
false) {
1063 if ($file !=
"." && $file !=
"..") {
1064 $fullpath = $sessPath.$file;
1065 if (!@is_dir($fullpath)) {
1066 $sessValues = file_get_contents($fullpath);
1068 if (preg_match(
'/dol_login/i', $sessValues) &&
1069 preg_match(
'/dol_entity\|s:([0-9]+):"('.$conf->entity.
')"/i', $sessValues) &&
1070 preg_match(
'/dol_company\|s:([0-9]+):"('.$conf->global->MAIN_INFO_SOCIETE_NOM.
')"/i', $sessValues)) {
1071 $tmp = explode(
'_', $file);
1074 if ($idsess != $mysessionid) {
1075 $res = @unlink($fullpath);
1106 global $db, $langs, $conf, $mysoc;
1111 if (empty($value)) {
1112 $ret[
'errors'][] =
'ErrorBadParameter';
1116 $ret = array(
'nbmodules'=>0,
'errors'=>array(),
'nbperms'=>0);
1118 $modFile = $modName.
".class.php";
1125 foreach ($modulesdir as $dir) {
1126 if (file_exists($dir.$modFile)) {
1127 $found = @include_once $dir.$modFile;
1134 $objMod =
new $modName($db);
1138 $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
1140 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequirePHPVersion",
versiontostring($vermin));
1146 $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
1149 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireDolibarrVersion",
versiontostring($vermin));
1154 if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
1155 $ret[
'errors'][] = $langs->trans(
"ErrorModuleRequireJavascript");
1159 $const_name = $objMod->const_name;
1160 if ($noconfverification == 0) {
1161 if (!empty($conf->global->$const_name)) {
1166 $result = $objMod->init();
1169 $ret[
'errors'][] = $objMod->error;
1172 if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
1175 foreach ($objMod->depends as $key => $modulestringorarray) {
1177 if ((!is_numeric($key)) && !preg_match(
'/^always/', $key) && $mysoc->country_code && !preg_match(
'/^'.$mysoc->country_code.
'/', $key)) {
1178 dol_syslog(
"We are not concerned by dependency with key=".$key.
" because our country is ".$mysoc->country_code);
1182 if (!is_array($modulestringorarray)) {
1183 $modulestringorarray = array($modulestringorarray);
1186 foreach ($modulestringorarray as $modulestring) {
1189 foreach ($modulesdir as $dir) {
1190 if (file_exists($dir.$modulestring.
".class.php")) {
1192 if (empty($resarray[
'errors'])) {
1195 $activateerr = join(
', ', $resarray[
'errors']);
1196 foreach ($resarray[
'errors'] as $errorMessage) {
1205 $ret[
'nbmodules'] += $resarray[
'nbmodules'];
1206 $ret[
'nbperms'] += $resarray[
'nbperms'];
1209 $ret[
'errors'][] = $activateerr;
1211 $ret[
'errors'][] = $langs->trans(
'activateModuleDependNotSatisfied', $objMod->name, $modulestring);
1217 if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
1219 $num = count($objMod->conflictwith);
1220 for ($i = 0; $i < $num; $i++) {
1221 foreach ($modulesdir as $dir) {
1222 if (file_exists($dir.$objMod->conflictwith[$i].
".class.php")) {
1231 if (!count($ret[
'errors'])) {
1232 $ret[
'nbmodules']++;
1233 $ret[
'nbperms'] += (is_array($objMod->rights)?count($objMod->rights):0);
1249 global $db, $modules, $conf;
1252 if (empty($value)) {
1253 return 'ErrorBadParameter';
1258 $modFile = $modName.
".class.php";
1265 foreach ($modulesdir as $dir) {
1266 if (file_exists($dir.$modFile)) {
1267 $found = @include_once $dir.$modFile;
1275 $objMod =
new $modName($db);
1276 $result = $objMod->remove();
1278 $ret = $objMod->error;
1284 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
1286 $genericMod->name = preg_replace(
'/^mod/i',
'', $modName);
1287 $genericMod->rights_class = strtolower(preg_replace(
'/^mod/i',
'', $modName));
1288 $genericMod->const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', $modName));
1289 dol_syslog(
"modules::unActivateModule Failed to find module file, we use generic function with name ".$modName);
1290 $genericMod->remove(
'');
1294 if (!$ret && $requiredby && is_object($objMod) && is_array($objMod->requiredby)) {
1295 $countrb = count($objMod->requiredby);
1296 for ($i = 0; $i < $countrb; $i++) {
1324function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
1326 global $db, $modules, $conf, $langs;
1328 dol_syslog(
"complete_dictionary_with_modules Search external modules to complete the list of dictionnary tables", LOG_DEBUG, 1);
1335 foreach ($modulesdir as $dir) {
1338 dol_syslog(
"Scan directory ".$dir.
" for modules");
1340 if (is_resource($handle)) {
1341 while (($file = readdir($handle)) !==
false) {
1343 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1344 $modName = substr($file, 0,
dol_strlen($file) - 10);
1347 include_once $dir.$file;
1348 $objMod =
new $modName($db);
1350 if ($objMod->numero > 0) {
1351 $j = $objMod->numero;
1356 $modulequalified = 1;
1359 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1361 $modulequalified = 0;
1364 $modulequalified = 0;
1368 $modulequalified = 0;
1371 if ($modulequalified) {
1373 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1374 foreach ($objMod->langfiles as $langfile) {
1375 $langs->load($langfile);
1380 if (empty($objMod->dictionaries) && !empty($objMod->dictionnaries)) {
1381 $objMod->dictionaries = $objMod->dictionnaries;
1384 if (!empty($objMod->dictionaries)) {
1386 $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0;
1387 $tabnamerelwithkey = array();
1388 foreach ($objMod->dictionaries[
'tabname'] as $key => $val) {
1389 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $val);
1391 $taborder[] = max($taborder) + 1;
1393 $tabnamerelwithkey[$key] = $val;
1394 $tabcomplete[$tmptablename][
'picto'] = $objMod->picto;
1396 foreach ($objMod->dictionaries[
'tablib'] as $key => $val) {
1397 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1400 $tabcomplete[$tmptablename][
'lib'] = $val;
1402 foreach ($objMod->dictionaries[
'tabsql'] as $key => $val) {
1403 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1406 $tabcomplete[$tmptablename][
'sql'] = $val;
1408 foreach ($objMod->dictionaries[
'tabsqlsort'] as $key => $val) {
1409 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1411 $tabsqlsort[] = $val;
1412 $tabcomplete[$tmptablename][
'sqlsort'] = $val;
1414 foreach ($objMod->dictionaries[
'tabfield'] as $key => $val) {
1415 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1418 $tabcomplete[$tmptablename][
'field'] = $val;
1420 foreach ($objMod->dictionaries[
'tabfieldvalue'] as $key => $val) {
1421 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1423 $tabfieldvalue[] = $val;
1424 $tabcomplete[$tmptablename][
'value'] = $val;
1426 foreach ($objMod->dictionaries[
'tabfieldinsert'] as $key => $val) {
1427 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1428 $nbtabfieldinsert++;
1429 $tabfieldinsert[] = $val;
1430 $tabcomplete[$tmptablename][
'fieldinsert'] = $val;
1432 foreach ($objMod->dictionaries[
'tabrowid'] as $key => $val) {
1433 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1436 $tabcomplete[$tmptablename][
'rowid'] = $val;
1438 foreach ($objMod->dictionaries[
'tabcond'] as $key => $val) {
1439 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1442 $tabcomplete[$tmptablename][
'rowid'] = $val;
1444 if (!empty($objMod->dictionaries[
'tabhelp'])) {
1445 foreach ($objMod->dictionaries[
'tabhelp'] as $key => $val) {
1446 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1449 $tabcomplete[$tmptablename][
'help'] = $val;
1452 if (!empty($objMod->dictionaries[
'tabfieldcheck'])) {
1453 foreach ($objMod->dictionaries[
'tabfieldcheck'] as $key => $val) {
1454 $tmptablename = preg_replace(
'/'.MAIN_DB_PREFIX.
'/',
'', $tabnamerelwithkey[$key]);
1456 $tabcomplete[$tmptablename][
'fieldcheck'] = $val;
1460 if ($nbtabname != $nbtablib || $nbtablib != $nbtabsql || $nbtabsql != $nbtabsqlsort) {
1461 print
'Error in descriptor of module '.$const_name.
'. Array ->dictionaries has not same number of record for key "tabname", "tablib", "tabsql" and "tabsqlsort"';
1471 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1478 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1495 global $db, $conf, $langs;
1499 foreach ($modulesdir as $dir) {
1501 dol_syslog(
"Scan directory ".$dir.
" for modules");
1503 if (is_resource($handle)) {
1504 while (($file = readdir($handle)) !==
false) {
1505 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1506 $modName = substr($file, 0,
dol_strlen($file) - 10);
1509 include_once $dir.$file;
1510 $objMod =
new $modName($db);
1512 $modulequalified = 1;
1515 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1517 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
1518 $modulequalified = 0;
1520 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
1521 $modulequalified = 0;
1523 if (!empty($conf->global->$const_name)) {
1524 $modulequalified = 0;
1527 if ($modulequalified) {
1529 if (isset($objMod->automatic_activation) && is_array($objMod->automatic_activation) && isset($objMod->automatic_activation[$country_code])) {
1532 setEventMessages($objMod->automatic_activation[$country_code],
null,
'warnings');
1535 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1542 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1557 global $db, $modules, $conf, $langs;
1560 $filename = array();
1569 dol_syslog(
"complete_elementList_with_modules Search external modules to complete the list of contact element", LOG_DEBUG, 1);
1573 foreach ($modulesdir as $dir) {
1576 dol_syslog(
"Scan directory ".$dir.
" for modules");
1578 if (is_resource($handle)) {
1579 while (($file = readdir($handle)) !==
false) {
1581 if (is_readable($dir.$file) && substr($file, 0, 3) ==
'mod' && substr($file,
dol_strlen($file) - 10) ==
'.class.php') {
1582 $modName = substr($file, 0,
dol_strlen($file) - 10);
1585 include_once $dir.$file;
1586 $objMod =
new $modName($db);
1588 if ($objMod->numero > 0) {
1589 $j = $objMod->numero;
1594 $modulequalified = 1;
1597 $const_name =
'MAIN_MODULE_'.strtoupper(preg_replace(
'/^mod/i',
'', get_class($objMod)));
1598 if ($objMod->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 &&
getDolGlobalString($const_name)) {
1599 $modulequalified = 0;
1601 if ($objMod->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 &&
getDolGlobalString($const_name)) {
1602 $modulequalified = 0;
1605 if (empty($conf->global->$const_name)) {
1606 $modulequalified = 0;
1609 if ($modulequalified) {
1611 if (isset($objMod->langfiles) && is_array($objMod->langfiles)) {
1612 foreach ($objMod->langfiles as $langfile) {
1613 $langs->load($langfile);
1617 $modules[$i] = $objMod;
1618 $filename[$i] = $modName;
1619 $orders[$i] = $objMod->family.
"_".$j;
1623 if (!empty($objMod->module_parts[
'contactelement'])) {
1624 if (is_array($objMod->module_parts[
'contactelement'])) {
1625 foreach ($objMod->module_parts[
'contactelement'] as $elem => $title) {
1626 $elementList[$elem] = $langs->trans($title);
1629 $elementList[$objMod->name] = $langs->trans($objMod->name);
1636 dol_syslog(
"Module ".get_class($objMod).
" not qualified");
1643 dol_syslog(
"htdocs/admin/modules.php: Failed to open directory ".$dir.
". See permission and open_basedir option.", LOG_WARNING);
1664 global $db, $langs, $conf, $user;
1665 global $_Avery_Labels;
1667 $form =
new Form($db);
1669 if (empty($strictw3c)) {
1670 dol_syslog(
"Warning: Function form_constantes is calle with parameter strictw3c = 0, this is deprecated. Value must be 2 now.", LOG_DEBUG);
1672 if (!empty($strictw3c) && $strictw3c == 1) {
1673 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1674 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1675 print
'<input type="hidden" name="action" value="updateall">';
1678 print
'<div class="div-table-responsive-no-min">';
1679 print
'<table class="noborder centpercent">';
1680 print
'<tr class="liste_titre">';
1681 print
'<td class="">'.$langs->trans(
"Description").
'</td>';
1683 $text = $langs->trans($text);
1684 print $form->textwithpicto($text, $helptext, 1,
'help',
'', 0, 2,
'idhelptext');
1686 if (empty($strictw3c)) {
1687 print
'<td class="center" width="80">'.$langs->trans(
"Action").
'</td>';
1692 foreach ($tableau as $key => $const) {
1695 if (is_numeric($key)) {
1698 if (is_array($const)) {
1699 $type = $const[
'type'];
1700 $label = $const[
'label'];
1710 $sql .=
", ".$db->decrypt(
'name').
" as name";
1711 $sql .=
", ".$db->decrypt(
'value').
" as value";
1714 $sql .=
" FROM ".MAIN_DB_PREFIX.
"const";
1715 $sql .=
" WHERE ".$db->decrypt(
'name').
" = '".$db->escape($const).
"'";
1716 $sql .=
" AND entity IN (0, ".$conf->entity.
")";
1717 $sql .=
" ORDER BY name ASC, entity DESC";
1718 $result = $db->query($sql);
1722 $obj = $db->fetch_object($result);
1725 $obj = (object) array(
'rowid'=>
'',
'name'=>$const,
'value'=>
'',
'type'=>$type,
'note'=>
'');
1728 if (empty($strictw3c)) {
1729 print
"\n".
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1730 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1731 print
'<input type="hidden" name="page_y" value="'.newToken().
'">';
1734 print
'<tr class="oddeven">';
1738 if (empty($strictw3c)) {
1739 print
'<input type="hidden" name="action" value="update">';
1741 print
'<input type="hidden" name="rowid'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$obj->rowid.
'">';
1742 print
'<input type="hidden" name="constname'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.$const.
'">';
1743 print
'<input type="hidden" name="constnote_'.$obj->name.
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1744 print
'<input type="hidden" name="consttype_'.$obj->name.
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1745 if (!empty($tableau[$key][
'tooltip'])) {
1746 print $form->textwithpicto($label ? $label : $langs->trans(
'Desc'.$const), $tableau[$key][
'tooltip']);
1748 print ($label ? $label : $langs->trans(
'Desc'.$const));
1751 if ($const ==
'ADHERENT_MAILMAN_URL') {
1752 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick1">'.
img_down().
'</a><br>';
1754 print
'<div id="example1" class="hidden">';
1755 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';
1757 } elseif ($const ==
'ADHERENT_MAILMAN_UNSUB_URL') {
1758 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick2">'.
img_down().
'</a><br>';
1759 print
'<div id="example2" class="hidden">';
1760 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';
1763 } elseif ($const ==
'ADHERENT_MAILMAN_LISTS') {
1764 print
'. '.$langs->trans(
"Example").
': <a href="#" id="exampleclick3">'.
img_down().
'</a><br>';
1765 print
'<div id="example3" class="hidden">';
1766 print
'mymailmanlist<br>';
1767 print
'mymailmanlist1,mymailmanlist2<br>';
1768 print
'TYPE:Type1:mymailmanlist1,TYPE:Type2:mymailmanlist2<br>';
1769 if (isModEnabled(
'categorie')) {
1770 print
'CATEG:Categ1:mymailmanlist1,CATEG:Categ2:mymailmanlist2<br>';
1774 } elseif (in_array($const, [
'ADHERENT_MAIL_FROM',
'ADHERENT_CC_MAIL_FROM'])) {
1775 print
' '.img_help(1, $langs->trans(
"EMailHelpMsgSPFDKIM"));
1781 if ($const ==
'ADHERENT_CARD_TYPE' || $const ==
'ADHERENT_ETIQUETTE_TYPE') {
1784 require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
1785 $arrayoflabels = array();
1786 foreach (array_keys($_Avery_Labels) as $codecards) {
1787 $arrayoflabels[$codecards] = $_Avery_Labels[$codecards][
'name'];
1789 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayoflabels, ($obj->value ? $obj->value :
'CARD'), 1, 0, 0);
1790 print
'<input type="hidden" name="consttype" value="yesno">';
1791 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' :
'[]').
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1795 print
'<input type="hidden" name="consttype'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.($obj->type ? $obj->type :
'string').
'">';
1796 print
'<input type="hidden" name="constnote'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.nl2br(
dol_escape_htmltag($obj->note)).
'">';
1797 if ($obj->type ==
'textarea' || in_array($const, array(
'ADHERENT_CARD_TEXT',
'ADHERENT_CARD_TEXT_RIGHT',
'ADHERENT_ETIQUETTE_TEXT'))) {
1798 print
'<textarea class="flat" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" cols="50" rows="5" wrap="soft">'.
"\n";
1800 print
"</textarea>\n";
1801 } elseif ($obj->type ==
'html') {
1802 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1803 $doleditor =
new DolEditor(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value,
'', 160,
'dolibarr_notes',
'',
false,
false, isModEnabled(
'fckeditor'), ROWS_5,
'90%');
1804 $doleditor->Create();
1805 } elseif ($obj->type ==
'yesno') {
1806 print $form->selectyesno(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $obj->value, 1);
1807 } elseif (preg_match(
'/emailtemplate/', $obj->type)) {
1808 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
1811 $tmp = explode(
':', $obj->type);
1813 $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user,
null, -1);
1815 $arrayofmessagename = array();
1816 if (is_array($formmail->lines_model)) {
1817 foreach ($formmail->lines_model as $modelmail) {
1820 if (!empty($arrayofmessagename[$modelmail->label])) {
1821 $moreonlabel =
' <span class="opacitymedium">('.$langs->trans(
"SeveralLangugeVariatFound").
')</span>';
1824 $arrayofmessagename[$modelmail->label.
':'.$tmp[1]] = $langs->trans(preg_replace(
'/\(|\)/',
'', $modelmail->label)).$moreonlabel;
1829 print $form->selectarray(
'constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')), $arrayofmessagename, $obj->value.
':'.$tmp[1],
'None', 0, 0,
'', 0, 0, 0,
'',
'', 1);
1830 } elseif (preg_match(
'/MAIL_FROM$/i', $const)) {
1831 print
img_picto(
'',
'email',
'class="pictofixedwidth"').
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1833 print
'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ?
'' : ($strictw3c == 3 ?
'_'.$const :
'[]')).
'" value="'.
dol_escape_htmltag($obj->value).
'">';
1839 if (empty($strictw3c)) {
1840 print
'<td class="center">';
1841 print
'<input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update">';
1847 if (empty($strictw3c)) {
1855 if (!empty($strictw3c) && $strictw3c == 1) {
1856 print
'<div align="center"><input type="submit" class="button small reposition" value="'.$langs->trans(
"Update").
'" name="update"></div>';
1870 global $conf, $langs;
1872 $text = $langs->trans(
"OnlyFollowingModulesAreOpenedToExternalUsers");
1873 $listofmodules = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
1876 if (!empty($modules)) {
1878 foreach ($tmpmodules as $module) {
1879 $moduleconst = $module->const_name;
1880 $modulename = strtolower($module->name);
1884 if (!in_array($modulename, $listofmodules)) {
1896 $tmptext = $langs->trans(
'Module'.$module->numero.
'Name');
1897 if ($tmptext !=
'Module'.$module->numero.
'Name') {
1898 $text .= $langs->trans(
'Module'.$module->numero.
'Name');
1900 $text .= $langs->trans($module->name);
1924 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity, libelle, description)";
1925 $sql .=
" VALUES ('".$db->escape($name).
"','".$db->escape($type).
"',".((int) $conf->entity).
", ";
1926 $sql .= ($label ?
"'".$db->escape($label).
"'" :
'null').
", ";
1927 $sql .= (!empty($description) ?
"'".$db->escape($description).
"'" :
"null");
1930 dol_syslog(
"admin.lib::addDocumentModel", LOG_DEBUG);
1931 $resql = $db->query($sql);
1955 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"document_model";
1956 $sql .=
" WHERE nom = '".$db->escape($name).
"'";
1957 $sql .=
" AND type = '".$db->escape($type).
"'";
1958 $sql .=
" AND entity = ".((int) $conf->entity);
1960 dol_syslog(
"admin.lib::delDocumentModel", LOG_DEBUG);
1961 $resql = $db->query($sql);
1982 $phpinfostring = ob_get_contents();
1985 $info_arr = array();
1986 $info_lines = explode(
"\n", strip_tags($phpinfostring,
"<tr><td><h2>"));
1988 foreach ($info_lines as $line) {
1991 preg_match(
"~<h2>(.*)</h2>~", $line, $title) ? $cat = $title[1] :
null;
1993 if (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1994 $info_arr[trim($cat)][trim($val[1])] = $val[2];
1995 } elseif (preg_match(
"~<tr><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td><td[^>]+>([^<]*)</td></tr>~", $line, $val)) {
1996 $info_arr[trim($cat)][trim($val[1])] = array(
"local" => $val[2],
"master" => $val[3]);
2009 global $langs, $conf;
2014 $head[$h][0] = DOL_URL_ROOT.
"/admin/company.php";
2015 $head[$h][1] = $langs->trans(
"Company");
2016 $head[$h][2] =
'company';
2019 $head[$h][0] = DOL_URL_ROOT.
"/admin/openinghours.php";
2020 $head[$h][1] = $langs->trans(
"OpeningHours");
2021 $head[$h][2] =
'openinghours';
2024 $head[$h][0] = DOL_URL_ROOT.
"/admin/accountant.php";
2025 $head[$h][1] = $langs->trans(
"Accountant");
2026 $head[$h][2] =
'accountant';
2029 $head[$h][0] = DOL_URL_ROOT.
"/admin/company_socialnetworks.php";
2030 $head[$h][1] = $langs->trans(
"SocialNetworksInformation");
2031 $head[$h][2] =
'socialnetworks';
2048 global $langs, $conf, $user;
2053 if (!empty($user->admin) && (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates')) {
2054 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails.php";
2055 $head[$h][1] = $langs->trans(
"OutGoingEmailSetup");
2056 $head[$h][2] =
'common';
2059 if (isModEnabled(
'mailing')) {
2060 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_emailing.php";
2061 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"EMailing"));
2062 $head[$h][2] =
'common_emailing';
2066 if (isModEnabled(
'ticket')) {
2067 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ticket.php";
2068 $head[$h][1] = $langs->trans(
"OutGoingEmailSetupForEmailing", $langs->transnoentitiesnoconv(
"Ticket"));
2069 $head[$h][2] =
'common_ticket';
2075 if (empty($_SESSION[
'leftmenu']) || $_SESSION[
'leftmenu'] !=
'email_templates') {
2076 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_senderprofile_list.php";
2077 $head[$h][1] = $langs->trans(
"EmailSenderProfiles");
2078 $head[$h][2] =
'senderprofiles';
2082 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_templates.php";
2083 $head[$h][1] = $langs->trans(
"EMailTemplates");
2084 $head[$h][2] =
'templates';
2087 $head[$h][0] = DOL_URL_ROOT.
"/admin/mails_ingoing.php";
2088 $head[$h][1] = $langs->trans(
"InGoingEmailSetup", $langs->transnoentitiesnoconv(
"EMailing"));
2089 $head[$h][2] =
'common_ingoing';
versiontostring($versionarray)
Renvoi une version en chaine depuis une version en tableau.
security_prepare_head()
Prepare array with list of tabs.
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
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.
unActivateModule($value, $requiredby=1)
Disable a module.
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)
Add external modules to list of dictionaries.
versiondolibarrarray()
Return version Dolibarr.
activateModulesRequiredByCountry($country_code)
Activate external modules mandatory when country is country_code.
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).
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.
form_constantes($tableau, $strictw3c=0, $helptext='', $text='Value')
Show array with constants to edit.
modules_prepare_head($nbofactivatedmodules, $nboftotalmodules, $nbmodulesnotautoenabled)
Prepare array with list of tabs.
complete_elementList_with_modules(&$elementList)
Search external modules to complete the list of contact element.
email_admin_prepare_head()
Return array head with list of tabs to view object informations.
translation_prepare_head()
Prepare array with list of tabs.
company_admin_prepare_head()
Return array head with list of tabs to view object informations.
defaultvalues_prepare_head()
Prepare array with list of tabs.
Class to manage a WYSIWYG editor.
dolGetModulesDirs($subdir='')
Return list of modules directories.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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...
dolEncrypt($chain, $key='', $ciphering='AES-256-CTR', $forceseed='')
Encode a string with a symetric encryption.
dolDecrypt($chain, $key='')
Decode a string with a symetric encryption.