dolibarr  17.0.4
listevents.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
5  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31 
32 if (!$user->admin) {
34 }
35 
36 $action = GETPOST('action', 'aZ09');
37 $confirm = GETPOST('confirm', 'alpha');
38 
39 // Security check
40 if ($user->socid > 0) {
41  $action = '';
42  $socid = $user->socid;
43 }
44 
45 // Load translation files required by the page
46 $langs->loadLangs(array("companies", "admin", "users", "other","withdrawals"));
47 
48 // Load variable for pagination
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 if (empty($page) || $page == -1) {
54  $page = 0;
55 } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortfield) {
60  $sortfield = "dateevent";
61 }
62 if (!$sortorder) {
63  $sortorder = "DESC";
64 }
65 
66 $search_code = GETPOST("search_code", "alpha");
67 $search_ip = GETPOST("search_ip", "alpha");
68 $search_user = GETPOST("search_user", "alpha");
69 $search_desc = GETPOST("search_desc", "alpha");
70 $search_ua = GETPOST("search_ua", "restricthtml");
71 $search_prefix_session = GETPOST("search_prefix_session", "restricthtml");
72 $optioncss = GETPOST("optioncss", "aZ"); // Option for the css output (always '' except when 'print')
73 
74 $now = dol_now();
75 $nowarray = dol_getdate($now);
76 
77 if (GETPOST("date_startmonth", 'int') > 0) {
78  $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth", 'int'), GETPOST("date_startday", 'int'), GETPOST("date_startyear", 'int'), 'tzuserrel');
79 } else {
80  $date_start = '';
81 }
82 if (GETPOST("date_endmonth", 'int') > 0) {
83  $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');
84 } else {
85  $date_end = '';
86 }
87 
88 // checks:if date_start>date_end then date_end=date_start + 24 hours
89 if ($date_start !== '' && $date_end !== '' && $date_start > $date_end) {
90  $date_end = $date_start + 86400;
91 }
92 
93 
94 if (!GETPOSTISSET('pageplusoneold') && !GETPOSTISSET('page') && $date_start === '') { // We define date_start and date_end
95  $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], 'tzuserrel');
96 }
97 if (!GETPOSTISSET('pageplusoneold') && !GETPOSTISSET('page') && $date_end === '') {
98  $date_end = dol_get_last_day($nowarray['year'], $nowarray['mon'], 'tzuserrel');
99 }
100 
101 // Set $date_startmonth...
102 $date_startday = '';
103 $date_startmonth = '';
104 $date_startyear = '';
105 $date_endday = '';
106 $date_endmonth = '';
107 $date_endyear = '';
108 if ($date_start !== '') {
109  $tmp = dol_getdate($date_start);
110  $date_startday = $tmp['mday'];
111  $date_startmonth = $tmp['mon'];
112  $date_startyear = $tmp['year'];
113 }
114 if ($date_end !== '') {
115  $tmp = dol_getdate($date_end);
116  $date_endday = $tmp['mday'];
117  $date_endmonth = $tmp['mon'];
118  $date_endyear = $tmp['year'];
119 }
120 
121 // Add prefix session
122 $arrayfields = array(
123  'e.prefix_session' => array(
124  'label'=>'UserAgent',
125  'checked'=>(empty($conf->global->AUDIT_ENABLE_PREFIX_SESSION) ? 0 : 1),
126  'enabled'=>(empty($conf->global->AUDIT_ENABLE_PREFIX_SESSION) ? 0 : 1),
127  'position'=>110
128  )
129 );
130 
131 
132 /*
133  * Actions
134  */
135 
136 $now = dol_now();
137 
138 // Purge search criteria
139 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
140  $date_start = '';
141  $date_end = '';
142  $date_startday = '';
143  $date_endday = '';
144  $date_startmonth = '';
145  $date_endmonth = '';
146  $date_startyear = '';
147  $date_endyear = '';
148  $search_code = '';
149  $search_ip = '';
150  $search_user = '';
151  $search_desc = '';
152  $search_ua = '';
153  $search_prefix_session = '';
154 }
155 
156 // Purge audit events
157 if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) {
158  $error = 0;
159 
160  $db->begin();
161  $securityevents = new Events($db);
162 
163  // Delete events
164  $sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
165  $sql .= " WHERE entity = ".$conf->entity;
166 
167  dol_syslog("listevents purge", LOG_DEBUG);
168  $resql = $db->query($sql);
169  if (!$resql) {
170  $error++;
171  setEventMessages($db->lasterror(), null, 'errors');
172  }
173 
174  // Add event purge
175  $text = $langs->trans("SecurityEventsPurged");
176  $securityevent = new Events($db);
177  $securityevent->type = 'SECURITY_EVENTS_PURGE';
178  $securityevent->dateevent = $now;
179  $securityevent->description = $text;
180 
181  $result = $securityevent->create($user);
182  if ($result > 0) {
183  $db->commit();
184  dol_syslog($text, LOG_WARNING);
185  } else {
186  $error++;
187  dol_syslog($securityevent->error, LOG_ERR);
188  $db->rollback();
189  }
190 }
191 
192 
193 /*
194  * View
195  */
196 
197 $title = $langs->trans("Audit");
198 llxHeader('', $title);
199 
200 $form = new Form($db);
201 
202 $userstatic = new User($db);
203 $usefilter = 0;
204 
205 $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
206 $sql .= " e.fk_user, e.description, e.prefix_session,";
207 $sql .= " u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as status";
208 $sql .= " FROM ".MAIN_DB_PREFIX."events as e";
209 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
210 $sql .= " WHERE e.entity IN (".getEntity('event').")";
211 if ($date_start !== '') {
212  $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'";
213 }
214 if ($date_end !== '' ) {
215  $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'";
216 }
217 if ($search_code) {
218  $usefilter++; $sql .= natural_search("e.type", $search_code, 0);
219 }
220 if ($search_ip) {
221  $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0);
222 }
223 if ($search_user) {
224  $usefilter++; $sql .= natural_search("u.login", $search_user, 0);
225 }
226 if ($search_desc) {
227  $usefilter++; $sql .= natural_search("e.description", $search_desc, 0);
228 }
229 if ($search_ua) {
230  $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0);
231 }
232 if ($search_prefix_session) {
233  $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0);
234 }
235 $sql .= $db->order($sortfield, $sortorder);
236 
237 // Count total nb of records
238 $nbtotalofrecords = '';
239 /*if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
240 {
241  $result = $db->query($sql);
242  $nbtotalofrecords = $db->num_rows($result);
243  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
244  {
245  $page = 0;
246  $offset = 0;
247  }
248 }*/
249 
250 $sql .= $db->plimit($limit + 1, $offset);
251 
252 $result = $db->query($sql);
253 if ($result) {
254  $num = $db->num_rows($result);
255  $i = 0;
256 
257  $param = '';
258  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
259  $param .= '&contextpage='.urlencode($contextpage);
260  }
261  if ($limit > 0 && $limit != $conf->liste_limit) {
262  $param .= '&limit='.urlencode($limit);
263  }
264  if ($optioncss != '') {
265  $param .= '&optioncss='.urlencode($optioncss);
266  }
267  if ($search_code) {
268  $param .= '&search_code='.urlencode($search_code);
269  }
270  if ($search_ip) {
271  $param .= '&search_ip='.urlencode($search_ip);
272  }
273  if ($search_user) {
274  $param .= '&search_user='.urlencode($search_user);
275  }
276  if ($search_desc) {
277  $param .= '&search_desc='.urlencode($search_desc);
278  }
279  if ($search_ua) {
280  $param .= '&search_ua='.urlencode($search_ua);
281  }
282  if ($search_prefix_session) {
283  $param .= '&search_prefix_session='.urlencode($search_prefix_session);
284  }
285  if ($date_startmonth) {
286  $param .= "&date_startmonth=".urlencode($date_startmonth);
287  }
288  if ($date_startday) {
289  $param .= "&date_startday=".urlencode($date_startday);
290  }
291  if ($date_startyear) {
292  $param .= "&date_startyear=".urlencode($date_startyear);
293  }
294  if ($date_endmonth) {
295  $param .= "&date_endmonth=".urlencode($date_endmonth);
296  }
297  if ($date_endday) {
298  $param .= "&date_endday=".urlencode($date_endday);
299  }
300  if ($date_endyear) {
301  $param .= "&date_endyear=".urlencode($date_endyear);
302  }
303 
304  $center = '';
305  if ($num) {
306  $center = '<a class="butActionDelete small" href="'.$_SERVER["PHP_SELF"].'?action=purge">'.$langs->trans("Purge").'</a>';
307  }
308 
309  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
310  print '<input type="hidden" name="token" value="'.newToken().'">';
311 
312  print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit);
313 
314  if ($action == 'purge') {
315  $formquestion = array();
316  print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'), 'confirm_purge', $formquestion, 'no', 1);
317  }
318 
319  // Check some parameters
320  // TODO Add a tab with this and other information
321  /*
322  global $dolibarr_main_prod, $dolibarr_nocsrfcheck;
323  if (empty($dolibarr_main_prod)) {
324  print $langs->trans("Warning").' dolibarr_main_prod = '.$dolibarr_main_prod;
325  print ' '.img_warning($langs->trans('SwitchThisForABetterSecurity', 1)).'<br>';
326  }
327  if (!empty($dolibarr_nocsrfcheck)) {
328  print $langs->trans("Warning").' dolibarr_nocsrfcheck = '.$dolibarr_nocsrfcheck;
329  print ' '.img_warning($langs->trans('SwitchThisForABetterSecurity', 0)).'<br>';
330  }
331  */
332 
333  print '<div class="div-table-responsive">';
334  print '<table class="liste centpercent">';
335 
336  // Fields title search
337  print '<tr class="liste_titre">';
338 
339  print '<td class="liste_titre" width="15%">';
340  print $form->selectDate($date_start === '' ? -1 : $date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
341  print $form->selectDate($date_end === '' ? -1 : $date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
342  print '</td>';
343 
344  print '<td class="liste_titre left">';
345  print '<input class="flat maxwidth100" type="text" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
346  print '</td>';
347 
348  // IP
349  print '<td class="liste_titre left">';
350  print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.dol_escape_htmltag($search_ip).'">';
351  print '</td>';
352 
353  print '<td class="liste_titre left">';
354  print '<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
355  print '</td>';
356 
357  print '<td class="liste_titre left">';
358  //print '<input class="flat maxwidth100" type="text" size="10" name="search_desc" value="'.$search_desc.'">';
359  print '</td>';
360 
361  if (!empty($arrayfields['e.user_agent']['checked'])) {
362  print '<td class="liste_titre left">';
363  print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.dol_escape_htmltag($search_ua).'">';
364  print '</td>';
365  }
366 
367  if (!empty($arrayfields['e.prefix_session']['checked'])) {
368  print '<td class="liste_titre left">';
369  print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.dol_escape_htmltag($search_prefix_session).'">';
370  print '</td>';
371  }
372 
373  print '<td class="liste_titre maxwidthsearch">';
374  $searchpicto = $form->showFilterAndCheckAddButtons(0);
375  print $searchpicto;
376  print '</td>';
377 
378  print "</tr>\n";
379 
380 
381  print '<tr class="liste_titre">';
382  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "e.dateevent", "", $param, '', $sortfield, $sortorder);
383  print_liste_field_titre("Code", $_SERVER["PHP_SELF"], "e.type", "", $param, '', $sortfield, $sortorder);
384  print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder);
385  print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder);
386  print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder);
387  if (!empty($arrayfields['e.user_agent']['checked'])) {
388  print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder);
389  }
390  if (!empty($arrayfields['e.prefix_session']['checked'])) {
391  print_liste_field_titre("SuffixSessionName", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder);
392  }
394  print "</tr>\n";
395 
396  while ($i < min($num, $limit)) {
397  $obj = $db->fetch_object($result);
398 
399  print '<tr class="oddeven">';
400 
401  // Date
402  print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S', 'tzuserrel').'</td>';
403 
404  // Code
405  print '<td>'.$obj->type.'</td>';
406 
407  // IP
408  print '<td class="nowrap">';
409  print dol_print_ip($obj->ip);
410  print '</td>';
411 
412  // Login
413  print '<td class="nowrap">';
414  if ($obj->fk_user) {
415  $userstatic->id = $obj->fk_user;
416  $userstatic->login = $obj->login;
417  $userstatic->admin = $obj->admin;
418  $userstatic->entity = $obj->entity;
419  $userstatic->status = $obj->status;
420 
421  print $userstatic->getLoginUrl(1);
422  if (isModEnabled('multicompany') && $userstatic->admin && !$userstatic->entity) {
423  print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"');
424  } elseif ($userstatic->admin) {
425  print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
426  }
427  } else {
428  print '&nbsp;';
429  }
430  print '</td>';
431 
432  // Description
433  print '<td>';
434  $text = $langs->trans($obj->description);
435  $reg = array();
436  if (preg_match('/\‍((.*)\‍)(.*)/i', $obj->description, $reg)) {
437  $val = explode(',', $reg[1]);
438  $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] : '');
439  if (!empty($reg[2])) {
440  $text .= $reg[2];
441  }
442  }
443  print dol_escape_htmltag($text);
444  print '</td>';
445 
446  if (!empty($arrayfields['e.user_agent']['checked'])) {
447  // User agent
448  print '<td>';
449  print $obj->user_agent;
450  print '</td>';
451  }
452 
453  if (!empty($arrayfields['e.prefix_session']['checked'])) {
454  // User agent
455  print '<td>';
456  print $obj->prefix_session;
457  print '</td>';
458  }
459 
460  // More informations
461  print '<td class="right">';
462  $htmltext = '<b>'.$langs->trans("UserAgent").'</b>: '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
463  $htmltext .= '<br><b>'.$langs->trans("SuffixSessionName").' (DOLSESSID_...)</b>: '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
464  print $form->textwithpicto('', $htmltext);
465  print '</td>';
466 
467  print "</tr>\n";
468  $i++;
469  }
470 
471  if ($num == 0) {
472  if ($usefilter) {
473  print '<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoEventFoundWithCriteria").'</span></td></tr>';
474  } else {
475  print '<tr><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoEventOrNoAuditSetup").'</span></td></tr>';
476  }
477  }
478  print "</table>";
479  print "</div>";
480 
481  print "</form>";
482  $db->free($result);
483 } else {
484  dol_print_error($db);
485 }
486 
487 // End of page
488 llxFooter();
489 $db->close();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Events class.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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...
Definition: date.lib.php:621
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:575
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:594
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.