mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +09:00
Add some PHP-CLI scripts to be run as cronjobs
This commit is contained in:
parent
30cdf63b77
commit
054191a69d
5 changed files with 203 additions and 0 deletions
37
common/scripts/clean_old_notifications.php
Normal file
37
common/scripts/clean_old_notifications.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This script deletes old notifications.
|
||||
*
|
||||
* Notifications must be dismissed as quickly as possible in order to prevent
|
||||
* the ncenterlite_notify table from becoming too large. For best performance,
|
||||
* you should run this script at least once every few days.
|
||||
*/
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
// Delete notifications older than this number of days.
|
||||
$days = 30;
|
||||
|
||||
// Initialize the exit status.
|
||||
$exit_status = 0;
|
||||
|
||||
// Execute the query.
|
||||
$args = new stdClass;
|
||||
$args->old_date = date('YmdHis', time() - ($days * 86400));
|
||||
$output = executeQuery('ncenterlite.deleteNotifyAll', $args);
|
||||
if ($output->toBool())
|
||||
{
|
||||
echo "Successfully deleted all notifications older than $days days.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error while deleting notifications older than $days days.\n";
|
||||
echo $output->getMessage() . "\n";
|
||||
$exit_status = abs($output->getError());
|
||||
}
|
||||
|
||||
// Set the exit status if there were any errors.
|
||||
if ($exit_status != 0)
|
||||
{
|
||||
exit($exit_status);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue