$cronreal Time remaining to next cron in hours:mins:secs */ $currenthour = date('G'); $currentmin = date('i'); $currentsec = date('s'); $currentdaysec = $currenthour * 3600 + $currentmin * 60 + $currentsec; if ($pfb['interval'] == 1) { if ($currentmin < $pfb['min']) { $cron_hour_next = $currenthour; } else { $cron_hour_next = ($currenthour + 1) % 24; } } elseif ($pfb['interval'] == 24) { $cron_hour_next = $cron_hour_begin = !empty($pfb['24hour']) ?: '00'; } else { // Find next cron hour schedule $crondata = pfb_cron_base_hour(); $cron_hour_begin = 0; $cron_hour_next = ''; if (!empty($crondata)) { foreach ($crondata as $key => $line) { if ($key == 0) { $cron_hour_begin = $line; } if ($line * 3600 + $pfb['min'] * 60 > $currentdaysec) { $cron_hour_next = $line; break; } } } // Roll over to the first cron hour setting if (empty($cron_hour_next)) {
function pfblockerng_sync_cron() { global $config, $pfb, $pfbarr; // Call base hour converter $pfb_sch = pfb_cron_base_hour(); $hour = date('G'); $dow = date('N'); $pfb['update_cron'] = FALSE; $log = " CRON PROCESS START [ NOW ]\n"; pfb_logger("{$log}", 1); $list_type = array('pfblockernglistsv4' => '_v4', 'pfblockernglistsv6' => '_v6', 'pfblockerngdnsbl' => '_v4', 'pfblockerngdnsbleasylist' => '_v4'); foreach ($list_type as $ip_type => $vtype) { if (!empty($config['installedpackages'][$ip_type]['config'])) { foreach ($config['installedpackages'][$ip_type]['config'] as $list) { if (isset($list['row']) && $list['action'] != 'Disabled' && $list['cron'] != 'Never') { foreach ($list['row'] as $row) { if (!empty($row['url']) && $row['state'] != 'Disabled') { if ($vtype == '_v4') { $header = "{$row['header']}"; } else { $header = "{$row['header']}_v6"; } // Determine folder location for alias (return array $pfbarr) pfb_determine_list_detail($list['action'], '', '', ''); $pfbfolder = $pfbarr['folder']; $pfborig = $pfbarr['orig']; // Bypass update if state is defined as 'Hold' and list file exists if ($row['state'] == 'Hold' && file_exists("{$pfbfolder}/{$header}.txt")) { continue; } // Allow cURL SSL downgrade if user configured. $pflex = FALSE; if ($row['state'] == 'Flex') { $pflex = TRUE; } switch ($list['cron']) { case 'EveryDay': if ($hour == $pfb['24hour']) { pfb_update_check($header, $row['url'], $pfbfolder, $pfborig, $pflex, $row['format']); } break; case 'Weekly': if ($hour == $pfb['24hour'] && $dow == $list['dow']) { pfb_update_check($header, $row['url'], $pfbfolder, $pfborig, $pflex, $row['format']); } break; default: if ($pfb['interval'] == '1' || in_array($hour, $pfb_sch)) { pfb_update_check($header, $row['url'], $pfbfolder, $pfborig, $pflex, $row['format']); } break; } } } } } } } // If no lists require updates, check if Continents are configured and update accordingly. if (!$pfb['update_cron']) { foreach ($pfb['continents'] as $continent => $pfb_alias) { if (isset($config['installedpackages']['pfblockerng' . strtolower(str_replace(' ', '', $continent))]['config'])) { $continent_config = $config['installedpackages']['pfblockerng' . strtolower(str_replace(' ', '', $continent))]['config'][0]; if ($continent_config['action'] != 'Disabled') { $pfb['update_cron'] = TRUE; break; } } } } if ($pfb['update_cron']) { sync_package_pfblockerng('cron'); $pfb['update_cron'] = FALSE; } else { sync_package_pfblockerng('noupdates'); $log = "\n No Updates required.\n CRON PROCESS ENDED\n UPDATE PROCESS ENDED\n"; pfb_logger("{$log}", 1); } // Call log mgmt function // If Update GUI 'Manual view' is selected. Last output will be missed. So sleep for 5 secs. sleep(5); pfb_log_mgmt(); }
pfblockerng_get_countries(); // Remove Original Maxmind Database Files @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryCSV.zip"); @unlink_if_exists("{$pfb['dbdir']}/GeoIPCountryWhois.csv"); @unlink_if_exists("{$pfb['dbdir']}/GeoIPv6.csv"); @unlink_if_exists("{$pfb['dbdir']}/country_continent.csv"); } if ($argv[1] == 'uc') { pfblockerng_uc_countries(); } if ($argv[1] == 'gc') { pfblockerng_get_countries(); } if ($argv[1] == 'cron') { // Call Base Hour converter $pfb_sch = pfb_cron_base_hour(); $hour = date('G'); $dow = date('N'); $pfb['update_cron'] = FALSE; $log = " CRON PROCESS START [ NOW ]\n"; pfb_logger("{$log}", "1"); $list_type = array("pfblockernglistsv4" => "_v4", "pfblockernglistsv6" => "_v6"); foreach ($list_type as $ip_type => $vtype) { if ($config['installedpackages'][$ip_type]['config'] != "") { foreach ($config['installedpackages'][$ip_type]['config'] as $list) { if (is_array($list['row']) && $list['action'] != "Disabled") { foreach ($list['row'] as $row) { if ($row['url'] != "" && $row['state'] != "Disabled") { if ($vtype == "_v4") { $header_url = "{$row['header']}"; } else {