26if (php_sapi_name() ===
'cli') {
27 if (!defined(
'NOLOGIN')) {
31if (!defined(
'NOTOKENRENEWAL')) {
32 define(
'NOTOKENRENEWAL', 1);
34if (!defined(
'NOREQUIREMENU')) {
35 define(
'NOREQUIREMENU', 1);
37if (!defined(
'NOREQUIREHTML')) {
38 define(
'NOREQUIREHTML', 1);
41require __DIR__ .
'/../../main.inc.php';
46if (php_sapi_name() !==
'cli') {
50 if (empty($user->admin)) {
58 $limitDate =
dol_now() - ($retention * 86400);
65 $sql =
"DELETE FROM " . MAIN_DB_PREFIX .
"ai_request_log";
66 $sql .=
" WHERE date_request < '" .
$db->idate($limitDate) .
"'";
67 $sql .=
" AND entity IN (" .
getEntity(
'airequestlog') .
")";
68 $sql .=
" LIMIT " . ((int) $chunkSize);
70 $resql =
$db->query($sql);
73 print
"ERROR: " .
$db->lasterror() .
"\n";
77 $rowsAffected =
$db->affected_rows($resql);
78 $totalDeleted += $rowsAffected;
81 if ($rowsAffected < 1) {
90 print
"OK: Purged {$totalDeleted} log(s) older than {$retention} days.\n";
dol_now($mode='gmt')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.