getCronToken() ) { die('Bad token'); } $activeJobsRepository = new AsyncJobs(Db::getInstance()); $activeJobs = $activeJobsRepository->getRunningJobs(); $now = strtotime('now'); $cacheTime = AsyncJobs::TIME_SYNC_JOBS; foreach ($activeJobs as $job) { if ((strtotime($job['last_sync']) + $cacheTime) > $now) { continue; } $fs = new \FreshMail\Freshmail($job['api_token']); $aj = new AsyncJob($job['id_freshmail_async_job']); $fs->pingAsyncJobStatus($aj); } set_time_limit(0); foreach ( $activeJobsRepository->getSuccessJobs() as $readyJob ){ $fs = new \FreshMail\Freshmail($readyJob['api_token']); $file = $fs->getFileFromJob($readyJob['id_job']); \FreshMail\Service\AsyncJobService::updateJobFilename($readyJob['id_job'], $file); (new \FreshMail\Repository\Subscribers(Db::getInstance()))->deleteByList($readyJob['hash_list']); \FreshMail\Tools::importSubscribersFromCsv($readyJob['hash_list'], $file); \FreshMail\Service\AsyncJobService::setJobAsFinished($readyJob['id_job']); }