<?php namespace MailPoet\Cron\Workers; if (!defined('ABSPATH')) exit; use MailPoet\Models\ScheduledTask; use MailPoet\Subscribers\ImportExport\Export\Export; use MailPoetVendor\Carbon\Carbon; class ExportFilesCleanup extends SimpleWorker { const TASK_TYPE = 'export_files_cleanup'; const DELETE_FILES_AFTER_X_DAYS = 1; public function processTaskStrategy(ScheduledTask $task, $timer) { $iterator = new \GlobIterator(Export::getExportPath() . '/' . Export::getFilePrefix() . '*.*'); foreach ($iterator as $file) { if (is_string($file)) { continue; } $name = $file->getPathname(); $created = $file->getMTime(); $now = new Carbon(); if (Carbon::createFromTimestamp((int)$created)->lessThan($now->subDays(self::DELETE_FILES_AFTER_X_DAYS))) { unlink($name); }; } return true; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
KeyCheck | Folder | 0755 |
|
|
SendingQueue | Folder | 0755 |
|
|
StatsNotifications | Folder | 0755 |
|
|
AuthorizedSendingEmailsCheck.php | File | 888 B | 0644 |
|
Beamer.php | File | 1.61 KB | 0644 |
|
Bounce.php | File | 5.69 KB | 0644 |
|
ExportFilesCleanup.php | File | 863 B | 0644 |
|
InactiveSubscribers.php | File | 2.28 KB | 0644 |
|
Scheduler.php | File | 8.62 KB | 0644 |
|
SimpleWorker.php | File | 2.55 KB | 0644 |
|
SubscriberLinkTokens.php | File | 1.06 KB | 0644 |
|
SubscribersCountCacheRecalculation.php | File | 3.31 KB | 0644 |
|
SubscribersEngagementScore.php | File | 2.36 KB | 0644 |
|
SubscribersLastEngagement.php | File | 4.76 KB | 0644 |
|
UnsubscribeTokens.php | File | 1.67 KB | 0644 |
|
WooCommercePastOrders.php | File | 2.37 KB | 0644 |
|
WooCommerceSync.php | File | 1.01 KB | 0644 |
|
WorkersFactory.php | File | 3.96 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|