mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Add script to delete old logs
This commit is contained in:
parent
eeb74c3257
commit
a228f0888b
2 changed files with 74 additions and 0 deletions
66
common/scripts/clean_old_logs.php
Normal file
66
common/scripts/clean_old_logs.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This script deletes old logs from the database.
|
||||
*
|
||||
* Rhymix produces various logs that can increase the size of the database
|
||||
* unnecessarily if not cleaned. This script removes old logs.
|
||||
*/
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
// Delete logs older than this number of days.
|
||||
$days = 30;
|
||||
|
||||
// Initialize the exit status.
|
||||
$exit_status = 0;
|
||||
|
||||
// Delete advanced mailer mail logs.
|
||||
$args = new stdClass;
|
||||
$args->regdate = date('YmdHis', time() - ($days * 86400));
|
||||
$output = executeQuery('advanced_mailer.deleteMailLogs', $args);
|
||||
if ($output->toBool())
|
||||
{
|
||||
echo "Successfully deleted all mail logs older than $days days.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error while deleting mail logs older than $days days.\n";
|
||||
echo $output->getMessage() . "\n";
|
||||
$exit_status = 11;
|
||||
}
|
||||
|
||||
// Delete advanced mailer SMS logs.
|
||||
$args = new stdClass;
|
||||
$args->regdate = date('YmdHis', time() - ($days * 86400));
|
||||
$output = executeQuery('advanced_mailer.deleteSMSLogs', $args);
|
||||
if ($output->toBool())
|
||||
{
|
||||
echo "Successfully deleted all SMS logs older than $days days.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error while deleting SMS logs older than $days days.\n";
|
||||
echo $output->getMessage() . "\n";
|
||||
$exit_status = 12;
|
||||
}
|
||||
|
||||
// Delete spamfilter logs.
|
||||
$args = new stdClass;
|
||||
$args->regdate = date('YmdHis', time() - ($days * 86400));
|
||||
$output = executeQuery('spamfilter.deleteLog', $args);
|
||||
if ($output->toBool())
|
||||
{
|
||||
echo "Successfully deleted all spamfilter logs older than $days days.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error while deleting spamfilter logs older than $days days.\n";
|
||||
echo $output->getMessage() . "\n";
|
||||
$exit_status = 12;
|
||||
}
|
||||
|
||||
// Set the exit status if there were any errors.
|
||||
if ($exit_status != 0)
|
||||
{
|
||||
exit($exit_status);
|
||||
}
|
||||
8
modules/spamfilter/queries/deleteLog.xml
Normal file
8
modules/spamfilter/queries/deleteLog.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="deleteLog" action="delete">
|
||||
<tables>
|
||||
<table name="spamfilter_log" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="less" column="regdate" var="regdate" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue