This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/cron.php

40 lines
886 B
PHP
Raw Normal View History

<?php
/*
* Sakura Cron Agent
*/
// Declare Namespace
namespace Sakura;
// Define that this page won't require templating
define('SAKURA_NO_TPL', true);
// Include components
2015-12-29 21:52:19 +00:00
require_once 'sakura.php';
// Clean expired sessions
2016-02-25 16:06:29 +00:00
DB::table('sessions')
->where('session_expire', '<', time())
->where('session_remember', '!=', 1)
->delete();
// Delete notifications that are older than a month but not unread
2016-02-25 16:06:29 +00:00
DB::table('notifications')
->where('alert_timestamp', '<', (time() - 109500))
->where('alert_read', 1)
->delete();
// Get expired premium accounts
2016-02-25 16:06:29 +00:00
$expiredPremium = DB::table('premium')
->where('premium_expire', '<', time())
2016-03-27 21:18:57 +00:00
->get(['user_id']);
foreach ($expiredPremium as $premium) {
DB::table('premium')
->where('user_id', $premium->user_id)
->delete();
2016-03-27 21:18:57 +00:00
User::construct($premium->user_id)
->isPremium();
}