diff --git a/app/Console/Command/PremiumPurgeCommand.php b/app/Console/Command/PremiumPurgeCommand.php new file mode 100644 index 0000000..d3aac91 --- /dev/null +++ b/app/Console/Command/PremiumPurgeCommand.php @@ -0,0 +1,46 @@ + + */ +class PremiumPurgeCommand extends Command +{ + /** + * A quick description of this command. + * @return string. + */ + public function brief() + { + return 'Purge expired premium.'; + } + + /** + * Purge expired premium subs. + */ + public function execute() + { + $expiredPremium = DB::table('premium') + ->where('premium_expire', '<', time()) + ->get(['user_id']); + + foreach ($expiredPremium as $premium) { + DB::table('premium') + ->where('user_id', $premium->user_id) + ->delete(); + + User::construct($premium->user_id) + ->isPremium(); + } + } +} diff --git a/app/Console/Command/SessionPurgeCommand.php b/app/Console/Command/SessionPurgeCommand.php new file mode 100644 index 0000000..5c99358 --- /dev/null +++ b/app/Console/Command/SessionPurgeCommand.php @@ -0,0 +1,38 @@ + + */ +class SessionPurgeCommand extends Command +{ + /** + * A quick description of this command. + * @return string. + */ + public function brief() + { + return 'Purge expired sessions.'; + } + + /** + * Purges sessions. + */ + public function execute() + { + DB::table('sessions') + ->where('session_expire', '<', time()) + ->where('session_remember', '!=', 1) + ->delete(); + } +} diff --git a/cron.php b/cron.php deleted file mode 100644 index 494b3dd..0000000 --- a/cron.php +++ /dev/null @@ -1,39 +0,0 @@ -where('session_expire', '<', time()) - ->where('session_remember', '!=', 1) - ->delete(); - -// Delete notifications that are older than a month but not unread -DB::table('notifications') - ->where('alert_timestamp', '<', (time() - 109500)) - ->where('alert_read', 1) - ->delete(); - -// Get expired premium accounts -$expiredPremium = DB::table('premium') - ->where('premium_expire', '<', time()) - ->get(['user_id']); - -foreach ($expiredPremium as $premium) { - DB::table('premium') - ->where('user_id', $premium->user_id) - ->delete(); - - User::construct($premium->user_id) - ->isPremium(); -} diff --git a/sakura.php b/sakura.php index 0c18821..4314a41 100644 --- a/sakura.php +++ b/sakura.php @@ -7,7 +7,7 @@ namespace Sakura; // Define version and root path -define('SAKURA_VERSION', 20160804); +define('SAKURA_VERSION', 20160913); define('ROOT', __DIR__ . '/'); // CLI mode