log_error("voucher XMLRPC sync data {$url}:{$port}."); $msg = new XML_RPC_Message('pfsense.exec_php', $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass']); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { $error = "A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} (pfsense.exec_php)."; log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Communications error occurred", ""); $input_errors[] = $error; } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, "250"); $error = "An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("CaptivePortalVoucherSync", $error, "Error code received", ""); $input_errors[] = $error; } else { log_error("The Captive Portal voucher database has been synchronized with {$url}:{$port} (pfsense.exec_php)."); } if (!$input_errors) { $toreturn = XML_RPC_Decode($resp->value()); if (!is_array($toreturn)) { if ($toreturn == "Authentication failed") { $input_errors[] = "Could not synchronize the voucher database: Authentication Failed."; } } else { // If we received back the voucher roll and other information then store it. if ($toreturn['voucher']['roll']) { $newvoucher['roll'] = $toreturn['voucher']['roll']; }
log_error(sprintf(gettext("voucher XMLRPC sync data %s:%d"), $url, $port)); $msg = new XML_RPC_Message('pfsense.exec_php', $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials($newvoucher['vouchersyncusername'], $newvoucher['vouchersyncpass']); $resp = $cli->send($msg, "250"); if (!is_object($resp)) { $error = sprintf(gettext("A communications error occurred while attempting CaptivePortalVoucherSync XMLRPC sync with %s:%d (pfsense.exec_php)."), $url, $port); log_error($error); file_notice("CaptivePortalVoucherSync", $error, gettext("Communications error occurred"), ""); $input_errors[] = $error; } elseif ($resp->faultCode()) { $cli->setDebug(1); $resp = $cli->send($msg, "250"); $error = sprintf(gettext("An error code was received while attempting CaptivePortalVoucherSync XMLRPC sync with %s:%d - Code %d: %s"), $url, $port, $resp->faultCode(), $resp->faultString()); log_error($error); file_notice("CaptivePortalVoucherSync", $error, gettext("Error code received"), ""); $input_errors[] = $error; } else { log_error(sprintf(gettext("The Captive Portal voucher database has been synchronized with %s:%d (pfsense.exec_php)."), $url, $port)); } if (!$input_errors) { $toreturn = XML_RPC_Decode($resp->value()); if (!is_array($toreturn)) { if ($toreturn == "Authentication failed") { $input_errors[] = gettext("Could not synchronize the voucher database: Authentication Failed."); } } else { // If we received back the voucher roll and other information then store it. if ($toreturn['voucher']['roll']) { $newvoucher['roll'] = $toreturn['voucher']['roll']; }
// For each mirror, check the mirror status, notify if changed foreach ($mirror_list as $mirror) { if (is_array($previous_mirror_status[$mirror])) { // Notify if the status changed if ($mirror_status[$mirror]['status'] != $previous_mirror_status[$mirror]['status']) { $notices[] = sprintf(gettext("Mirror %s status changed from %s to %s."), $mirror, $previous_mirror_status[$mirror]['status'], $mirror_status[$mirror]['status']); } // Notify if the drive count changed if (count($mirror_status[$mirror]['components']) != count($previous_mirror_status[$mirror]['components'])) { // Notify if the consumer count changed. $notices[] = sprintf(gettext("Mirror %s consumer count changed from %d to %d."), $mirror, count($previous_mirror_status[$mirror]['components']), count($mirror_status[$mirror]['components'])); } if (strtoupper($mirror_status[$mirror]['status']) == "DEGRADED") { // Check the drive status as it may be different. asort($mirror_status[$mirror]['components']); asort($previous_mirror_status[$mirror]['components']); if ($mirror_status[$mirror]['components'] != $previous_mirror_status[$mirror]['components']) { $notices[] = sprintf(gettext("Mirror %s drive status changed. Old: (%s) New: (%s)"), $mirror, implode(", ", $previous_mirror_status[$mirror]['components']), implode(", ", $mirror_status[$mirror]['components'])); } } } } } } if (count($notices)) { file_notice("gmirror", implode("\n ", $notices), "GEOM Mirror Status Change", 1); } // Write out current status if changed if ($mirror_status != $previous_mirror_status) { file_put_contents($status_file, serialize($mirror_status)); }
function read_lists() { global $config, $g; $group_type = array(); $dir = "/usr/local/etc/dansguardian/lists"; #read dansguardian lists dirs $groups = array("phraselists", "blacklists", "whitelists"); #assigns know list files $types = array('domains', 'urls', 'banned', 'weighted', 'exception', 'expression'); #clean previous xml config for dansguardian lists foreach ($config['installedpackages'] as $key => $values) { if (preg_match("/dansguardian(phrase|black|white)lists/", $key)) { unset($config['installedpackages'][$key]); } } #find lists foreach ($groups as $group) { if (is_dir("{$dir}/{$group}/")) { #read dir content and find lists $lists = scandir("{$dir}/{$group}/"); foreach ($lists as $list) { if (!preg_match("/^\\./", $list) && is_dir("{$dir}/{$group}/{$list}/")) { $category = scandir("{$dir}/{$group}/{$list}/"); foreach ($category as $file) { if (!preg_match("/^\\./", $file)) { #assign list to array $type = split("_", $file); if (preg_match("/(\\w+)/", $type[0], $matches)) { } $xml_type = $matches[1]; if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] == "both" && $group == "blacklists") { $config['installedpackages']['dansguardianwhitelists' . $xml_type]['config'][] = array("descr" => "{$list} {$file}", "list" => $list, "file" => "{$dir}/{$group}/{$list}/{$file}"); } $config['installedpackages']['dansguardian' . $group . $xml_type]['config'][] = array("descr" => "{$list} {$file}", "list" => $list, "file" => "{$dir}/{$group}/{$list}/{$file}"); } } } } } } conf_mount_rw(); $files = array("site", "url"); foreach ($files as $edit_xml) { $edit_file = file_get_contents("/usr/local/pkg/dansguardian_" . $edit_xml . "_acl.xml"); if (count($config['installedpackages']['dansguardianblacklistsdomains']['config']) > 18) { $edit_file = preg_replace('/size.6/', 'size>20', $edit_file); if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] == "both") { $edit_file = preg_replace('/size.5/', 'size>19', $edit_file); } } else { $edit_file = preg_replace('/size.20/', 'size>6', $edit_file); } if ($config['installedpackages']['dansguardianblacklist']['config'][0]["liston"] != "both") { $edit_file = preg_replace('/size.19/', 'size>5', $edit_file); } file_put_contents("/usr/local/pkg/dansguardian_" . $edit_xml . "_acl.xml", $edit_file, LOCK_EX); } file_notice("Dansguardian - Blacklist applied, check site and URL access lists for categories", ""); #foreach($config['installedpackages'] as $key => $values) # if (preg_match("/dansguardian(phrase|black|white)lists/",$key)) # print "$key\n"; write_config(); }
function snort_do_xmlrpc_sync() { return; /* need to fix the bug which whipes out carp sync settings, etc */ global $config, $g; $syncxmlrpc = $config['installedpackages']['snort']['config'][0]['syncxmlrpc']; /* option enabled? */ if (!$syncxmlrpc) { return; } $carp =& $config['installedpackages']['carpsettings']['config'][0]; $password = $carp['password']; if (!$carp['synchronizetoip']) { return; } log_error("[SNORT] snort_xmlrpc_sync.php is starting."); $xmlrpc_sync_neighbor = $carp['synchronizetoip']; if ($config['system']['webgui']['protocol'] != "") { $synchronizetoip = $config['system']['webgui']['protocol']; $synchronizetoip .= "://"; } $port = $config['system']['webgui']['port']; /* if port is empty lets rely on the protocol selection */ if ($port == "") { if ($config['system']['webgui']['protocol'] == "http") { $port = "80"; } else { $port = "443"; } } $synchronizetoip .= $carp['synchronizetoip']; /* xml will hold the sections to sync */ $xml = array(); $xml['installedpackages']['snort'] =& $config['installedpackages']['snort']; $xml['installedpackages']['snortwhitelist'] =& $config['installedpackages']['snortwhitelist']; /* assemble xmlrpc payload */ $params = array(XML_RPC_encode($password), XML_RPC_encode($xml)); /* set a few variables needed for sync code borrowed from filter.inc */ $url = $synchronizetoip; $method = 'pfsense.restore_config_section'; /* Sync! */ log_error("Beginning Snort XMLRPC sync to {$url}:{$port}."); $msg = new XML_RPC_Message($method, $params); $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port); $cli->setCredentials('admin', $password); if ($g['debug']) { $cli->setDebug(1); } /* send our XMLRPC message and timeout after 240 seconds */ $resp = $cli->send($msg, "999"); if (!$resp) { $error = "A communications error occured while attempting Snort XMLRPC sync with {$url}:{$port}."; log_error($error); file_notice("sync_settings", $error, "Snort Settings Sync", ""); } elseif ($resp->faultCode()) { $error = "An error code was received while attempting Snort XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString(); log_error($error); file_notice("sync_settings", $error, "Snort Settings Sync", ""); } else { log_error("Snort XMLRPC sync successfully completed with {$url}:{$port}."); } log_error("[SNORT] snort_xmlrpc_sync.php is ending."); }