28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/events.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/triggers/interface_20_all_Logevents.class.php';
37$action =
GETPOST(
'action',
'aZ09');
38$confirm =
GETPOST(
'confirm',
'alpha');
41if ($user->socid > 0) {
43 $socid = $user->socid;
47$langs->loadLangs(array(
"companies",
"admin",
"users",
"other",
"withdrawals"));
50$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
61 $sortfield =
"e.rowid";
67$search_rowid =
GETPOST(
"search_rowid",
"int");
68$search_code =
GETPOST(
"search_code",
"alpha");
69$search_ip =
GETPOST(
"search_ip",
"alpha");
70$search_user =
GETPOST(
"search_user",
"alpha");
71$search_desc =
GETPOST(
"search_desc",
"alpha");
72$search_ua =
GETPOST(
"search_ua",
"restricthtml");
73$search_prefix_session =
GETPOST(
"search_prefix_session",
"restricthtml");
74$optioncss =
GETPOST(
"optioncss",
"aZ");
79if (
GETPOST(
"date_startmonth",
'int') > 0) {
84if (
GETPOST(
"date_endmonth",
'int') > 0) {
85 $date_end =
dol_get_last_hour(
dol_mktime(23, 59, 59,
GETPOST(
"date_endmonth",
'int'),
GETPOST(
"date_endday",
'int'),
GETPOST(
"date_endyear",
'int'),
'tzuserrel'),
'tzuserrel');
91if ($date_start !==
'' && $date_end !==
'' && $date_start > $date_end) {
92 $date_end = $date_start + 86400;
96if (!GETPOSTISSET(
'pageplusoneold') && !GETPOSTISSET(
'page') && $date_start ===
'') {
97 $date_start =
dol_get_first_day($nowarray[
'year'], $nowarray[
'mon'],
'tzuserrel');
99if (!GETPOSTISSET(
'pageplusoneold') && !GETPOSTISSET(
'page') && $date_end ===
'') {
100 $date_end =
dol_get_last_day($nowarray[
'year'], $nowarray[
'mon'],
'tzuserrel');
105$date_startmonth =
'';
110if ($date_start !==
'') {
112 $date_startday = $tmp[
'mday'];
113 $date_startmonth = $tmp[
'mon'];
114 $date_startyear = $tmp[
'year'];
116if ($date_end !==
'') {
118 $date_endday = $tmp[
'mday'];
119 $date_endmonth = $tmp[
'mon'];
120 $date_endyear = $tmp[
'year'];
125 'e.prefix_session' => array(
126 'label'=>
'UserAgent',
141if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
146 $date_startmonth =
'';
148 $date_startyear =
'';
156 $search_prefix_session =
'';
160if ($action ==
'confirm_purge' && $confirm ==
'yes' && $user->admin) {
164 $securityevents =
new Events($db);
167 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"events";
168 $sql .=
" WHERE entity = ".$conf->entity;
171 $resql = $db->query($sql);
178 $text = $langs->trans(
"SecurityEventsPurged");
179 $securityevent =
new Events($db);
180 $securityevent->type =
'SECURITY_EVENTS_PURGE';
181 $securityevent->dateevent = $now;
182 $securityevent->description = $text;
184 $result = $securityevent->create($user);
200$title = $langs->trans(
"Audit");
203$form =
new Form($db);
205$userstatic =
new User($db);
208$sql =
"SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
209$sql .=
" e.fk_user, e.description, e.prefix_session,";
210$sql .=
" u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as status";
211$sql .=
" FROM ".MAIN_DB_PREFIX.
"events as e";
212$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = e.fk_user";
213$sql .=
" WHERE e.entity IN (".getEntity(
'event').
")";
214if ($date_start !==
'') {
215 $sql .=
" AND e.dateevent >= '".$db->idate($date_start).
"'";
217if ($date_end !==
'') {
218 $sql .=
" AND e.dateevent <= '".$db->idate($date_end).
"'";
244if ($search_prefix_session) {
246 $sql .=
natural_search(
"e.prefix_session", $search_prefix_session, 0);
248$sql .= $db->order($sortfield, $sortorder);
251$nbtotalofrecords =
'';
263$sql .= $db->plimit($limit + 1, $offset);
265$result = $db->query($sql);
267 $num = $db->num_rows($result);
271 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
272 $param .=
'&contextpage='.urlencode($contextpage);
274 if ($limit > 0 && $limit != $conf->liste_limit) {
275 $param .=
'&limit='.((int) $limit);
277 if ($optioncss !=
'') {
278 $param .=
'&optioncss='.urlencode($optioncss);
281 $param .=
'&search_rowid='.urlencode($search_rowid);
284 $param .=
'&search_code='.urlencode($search_code);
287 $param .=
'&search_ip='.urlencode($search_ip);
290 $param .=
'&search_user='.urlencode($search_user);
293 $param .=
'&search_desc='.urlencode($search_desc);
296 $param .=
'&search_ua='.urlencode($search_ua);
298 if ($search_prefix_session) {
299 $param .=
'&search_prefix_session='.urlencode($search_prefix_session);
301 if ($date_startmonth) {
302 $param .=
"&date_startmonth=".urlencode($date_startmonth);
304 if ($date_startday) {
305 $param .=
"&date_startday=".urlencode($date_startday);
307 if ($date_startyear) {
308 $param .=
"&date_startyear=".urlencode($date_startyear);
310 if ($date_endmonth) {
311 $param .=
"&date_endmonth=".urlencode($date_endmonth);
314 $param .=
"&date_endday=".urlencode($date_endday);
317 $param .=
"&date_endyear=".urlencode($date_endyear);
322 $center =
'<a class="butActionDelete small" href="'.$_SERVER[
"PHP_SELF"].
'?action=purge">'.$langs->trans(
"Purge").
'</a>';
325 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
326 print
'<input type="hidden" name="token" value="'.newToken().
'">';
328 print_barre_liste($langs->trans(
"ListOfSecurityEvents"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords,
'setup', 0,
'',
'', $limit);
330 if ($action ==
'purge') {
331 $formquestion = array();
332 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?noparam=noparam', $langs->trans(
'PurgeAuditEvents'), $langs->trans(
'ConfirmPurgeAuditEvents'),
'confirm_purge', $formquestion,
'no', 1);
349 print
'<div class="div-table-responsive">';
350 print
'<table class="liste centpercent">';
353 print
'<tr class="liste_titre">';
357 print
'<td class="liste_titre maxwidthsearch center">';
358 $searchpicto = $form->showFilterAndCheckAddButtons(0);
364 print
'<td class="liste_titre">';
365 print
'<input class="flat maxwidth50" type="text" name="search_rowid" value="'.dol_escape_htmltag($search_rowid).
'">';
369 print
'<td class="liste_titre" width="15%">';
370 print $form->selectDate($date_start ===
'' ? -1 : $date_start,
'date_start', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
371 print $form->selectDate($date_end ===
'' ? -1 : $date_end,
'date_end', 0, 0, 0,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
374 print
'<td class="liste_titre">';
375 print
'<input class="flat maxwidth75" type="text" name="search_code" value="'.dol_escape_htmltag($search_code).
'">';
379 print
'<td class="liste_titre">';
380 print
'<input class="flat maxwidth75" type="text" name="search_ip" value="'.dol_escape_htmltag($search_ip).
'">';
383 print
'<td class="liste_titre">';
384 print
'<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).
'">';
387 print
'<td class="liste_titre">';
391 print
'<td class="liste_titre left">';
392 print
'<input class="flat maxwidth100" type="text" name="search_ua" value="'.dol_escape_htmltag($search_ua).
'">';
395 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
396 print
'<td class="liste_titre left">';
397 print
'<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.dol_escape_htmltag($search_prefix_session).
'">';
403 print
'<td class="liste_titre maxwidthsearch">';
404 $searchpicto = $form->showFilterAndCheckAddButtons(0);
412 print
'<tr class="liste_titre">';
422 print_liste_field_titre(
"Description", $_SERVER[
"PHP_SELF"],
"e.description",
"", $param,
'', $sortfield, $sortorder);
423 print_liste_field_titre(
"UserAgent", $_SERVER[
"PHP_SELF"],
"e.user_agent",
"", $param,
'', $sortfield, $sortorder);
424 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
425 print_liste_field_titre(
"SuffixSessionName", $_SERVER[
"PHP_SELF"],
"e.prefix_session",
"", $param,
'', $sortfield, $sortorder);
433 while ($i < min($num, $limit)) {
434 $obj = $db->fetch_object($result);
436 print
'<tr class="oddeven">';
440 print
'<td class="center">';
441 $htmltext =
'<b>'.$langs->trans(
"UserAgent").
'</b>: '.($obj->user_agent ?
dol_string_nohtmltag($obj->user_agent) : $langs->trans(
"Unknown"));
442 $htmltext .=
'<br><b>'.$langs->trans(
"SuffixSessionName").
' (DOLSESSID_...)</b>: '.($obj->prefix_session ?
dol_string_nohtmltag($obj->prefix_session) : $langs->trans(
"Unknown"));
443 print $form->textwithpicto(
'', $htmltext);
448 print
'<td class="nowrap left">'.dol_escape_htmltag($obj->rowid).
'</td>';
451 print
'<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent),
'%Y-%m-%d %H:%M:%S',
'tzuserrel').
'</td>';
454 print
'<td>'.dol_escape_htmltag($obj->type).
'</td>';
457 print
'<td class="nowraponall">';
462 print
'<td class="tdoverflowmax125">';
463 if ($obj->fk_user > 0) {
464 $userstatic->id = $obj->fk_user;
465 $userstatic->login = $obj->login;
466 $userstatic->admin = $obj->admin;
467 $userstatic->entity = $obj->entity;
468 $userstatic->status = $obj->status;
470 print $userstatic->getLoginUrl(1);
471 if (isModEnabled(
'multicompany') && $userstatic->admin && !$userstatic->entity) {
472 print
img_picto($langs->trans(
"SuperAdministratorDesc"),
'redstar',
'class="valignmiddle paddingleft"');
473 } elseif ($userstatic->admin) {
474 print
img_picto($langs->trans(
"AdministratorDesc"),
'star',
'class="valignmiddle paddingleft"');
482 $text = $langs->trans($obj->description);
485 $val = explode(
' : ', $obj->description);
486 $text = $langs->trans($val[0], isset($val[1]) ? $val[1] :
'', isset($val[2]) ? $val[2] :
'', isset($val[3]) ? $val[3] :
'', isset($val[4]) ? $val[4] :
'');
488 if (preg_match(
'/\((.*)\)(.*)/i', $obj->description, $reg)) {
489 $val = explode(
',', $reg[1]);
490 $text = $langs->trans($val[0], isset($val[1]) ? $val[1] :
'', isset($val[2]) ? $val[2] :
'', isset($val[3]) ? $val[3] :
'', isset($val[4]) ? $val[4] :
'');
491 if (!empty($reg[2])) {
495 print
'<td class="tdoverflowmax400" title="'.dol_escape_htmltag($text).
'">';
500 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->user_agent).
'">';
505 if (!empty($arrayfields[
'e.prefix_session'][
'checked'])) {
506 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->prefix_session).
'">';
513 print
'<td class="right">';
514 $htmltext =
'<b>'.$langs->trans(
"UserAgent").
'</b>: '.($obj->user_agent ?
dol_string_nohtmltag($obj->user_agent) : $langs->trans(
"Unknown"));
515 $htmltext .=
'<br><b>'.$langs->trans(
"SuffixSessionName").
' (DOLSESSID_...)</b>: '.($obj->prefix_session ?
dol_string_nohtmltag($obj->prefix_session) : $langs->trans(
"Unknown"));
516 print $form->textwithpicto(
'', $htmltext);
527 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoEventFoundWithCriteria").
'</span></td></tr>';
529 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoEventOrNoAuditSetup").
'</span></td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static isEventActionTextKey($event_text)
Check if text contains an event action key.
Class to manage Dolibarr users.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_ip($ip, $mode=0)
Return an IP formated to be shown on screen.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.