0); protected $taskTypeCode = TaskTypeCodesCodes::ZONECHECKER; public function mainDescription() { return 'Zone Checker'; } //TODO: do czego to służy? kopia synchronizatora public function main($params) { $diff = TimeDiffHelper::diff(GlobalSettingHelper::getSetting(GlobalSettingEnum::CRON_SYNC_LAST_RUN)?:'1991-12-19'); $cron_sync_run_each = GlobalSettingHelper::getSetting(GlobalSettingEnum::CRON_SYNC_RUN_EACH?:5); if(!$this->isReadyToRun( $cron_sync_run_each )) { return true; } $last_id = GlobalSettingHelper::getSetting(GlobalSettingEnum::CRON_SYNC_LAST_ID)?:0; $zones_per_run = GlobalSettingHelper::getSetting(GlobalSettingEnum::CRON_SYNC_ZONES_PER_RUN); $zones_per_run<1?$zones_per_run=1:''; $rep = $this->getZonesRepoWithIDGreaterThan($last_id,$zones_per_run); $count_filtered = $rep->count(); foreach($rep->get() as $zone) { try { $server = $zone->getServer(); $nameservers = $server->getNameservers(); $ns_records = $zone->getModule()->getRecords('NS'); foreach($nameservers as $nameserver) { if(!empty($nameserver->name) || !empty($nameserver->ip)) { $value = empty($nameserver->name)?$nameserver->ip:$nameserver->name; foreach($ns_records as $record) { if($record->rdata->__toString() == $value) continue 2; } $zone->getModule()->terminateZone(); } } } catch (\Exception $e) { } } if($count_filtered < $zones_per_run) $last_id = 0; GlobalSettingHelper::setSetting(GlobalSettingEnum::CRON_SYNC_LAST_ID, $last_id); } private function getZonesRepoWithIDGreaterThan($id, $zones_per_run) { $rep = new main\models\custom\zone\Repository(); $rep->setFilter(0, array( 'customQuery' => 'id > :last_id ', 'params' => array('last_id' => $id) )); $rep->limit($zones_per_run); return $rep; } }