本文整理汇总了PHP中unlink_if_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP unlink_if_exists函数的具体用法?PHP unlink_if_exists怎么用?PHP unlink_if_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unlink_if_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_blacklist
function fetch_blacklist()
{
global $config, $g;
$url = $config['installedpackages']['dansguardianblacklist']['config'][0]['url'];
if (is_url($url)) {
conf_mount_rw();
print "file download start..";
unlink_if_exists("/usr/local/etc/dansguardian/lists/blacklist.tgz");
exec("/usr/bin/fetch -o /usr/local/etc/dansguardian/lists/blacklist.tgz " . escapeshellarg($url));
chdir("/usr/local/etc/dansguardian/lists");
if (is_dir("blacklists.old")) {
exec('rm -rf /usr/local/etc/dansguardian/lists/blacklists.old');
}
rename("blacklists", "blacklists.old");
exec('/usr/bin/tar -xvzf /usr/local/etc/dansguardian/lists/blacklist.tgz 2>&1', $output, $return);
if (preg_match("/x\\W+(\\w+)/", $output[0], $matches)) {
if ($matches[1] != "blacklists") {
rename("./" . $matches[1], "blacklists");
}
read_lists();
} else {
file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated", "");
}
} else {
file_notice("Dansguardian - Blacklist url is invalid.", "");
}
}
示例2: fetch_blacklist
function fetch_blacklist($log_notice = true, $install_process = false)
{
global $config, $g;
if (is_array($config['installedpackages']['dansguardianblacklist']) && is_array($config['installedpackages']['dansguardianblacklist']['config'])) {
$url = $config['installedpackages']['dansguardianblacklist']['config'][0]['url'];
$uw = "Found a previouns install, checking Blacklist config...";
} else {
$uw = "Found a clean install, reading default access lists...";
}
conf_mount_rw();
if ($install_process == true) {
update_output_window($uw);
}
if (isset($url) && is_url($url)) {
if ($log_notice == true) {
print "file download start..";
unlink_if_exists("/usr/local/pkg/blacklist.tgz");
exec("/usr/bin/fetch -o /usr/local/pkg/blacklist.tgz " . escapeshellarg($url), $output, $return);
} else {
#install process
if (file_exists("/usr/local/pkg/blacklist.tgz")) {
update_output_window("Found previous blacklist database, skipping download...");
$return = 0;
} else {
update_output_window("Fetching blacklist");
download_file_with_progress_bar($url, "/usr/local/pkg/blacklist.tgz");
if (file_exists("/usr/local/pkg/blacklist.tgz")) {
$return = 0;
}
}
}
if ($return == 0) {
chdir(DANSGUARDIAN_DIR . "/etc/dansguardian/lists");
if (is_dir("blacklists.old")) {
exec('rm -rf ' . DANSGUARDIAN_DIR . '/etc/dansguardian/lists/blacklists.old');
}
rename("blacklists", "blacklists.old");
exec('/usr/bin/tar -xvzf /usr/local/pkg/blacklist.tgz 2>&1', $output, $return);
if (preg_match("/x\\W+(\\w+)/", $output[1], $matches)) {
if ($matches[1] != "blacklists") {
rename("./" . $matches[1], "blacklists");
}
read_lists($log_notice);
} else {
file_notice("Dansguardian - Could not determine Blacklist extract dir. Categories not updated", "");
}
} else {
file_notice("Dansguardian - Could not fetch blacklists from url", "");
}
} else {
if ($install_process == true) {
read_lists(false, $uw);
} elseif (!empty($url)) {
file_notice("Dansguardian - Blacklist url is invalid.", "");
}
}
}
示例3: crypt_data
function crypt_data($val, $pass, $opt)
{
$file = tempnam("/tmp", "php-encrypt");
file_put_contents("{$file}.dec", $val);
exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in {$file}.dec -out {$file}.enc -k " . escapeshellarg($pass));
if (file_exists("{$file}.enc")) {
$result = file_get_contents("{$file}.enc");
} else {
$result = "";
log_error("Failed to encrypt/decrypt data!");
}
unlink_if_exists($file);
unlink_if_exists("{$file}.dec");
unlink_if_exists("{$file}.enc");
return $result;
}
示例4: htmlspecialchars
$domain = htmlspecialchars($_POST['domain']);
$domainparse = str_replace('.', '\\.', $domain);
$pfb['dsupp'] =& $config['installedpackages']['pfblockerngdnsblsettings']['config'][0]['suppression'];
// Collect existing suppression list
$dnssupp_ex = collectsuppression();
// Query for domain in Unbound DNSBL file.
$dnsbl_query = exec("/usr/bin/grep -Hm1 ' \"{$domain} 60 IN A' {$pfb['dnsbl_file']}.conf");
// Save new suppress domain to suppress list.
if (empty($dnsbl_query)) {
$savemsg = gettext("Domain: [ {$domain} ] does not exist in the Unbound Resolver DNSBL");
exec("/usr/local/sbin/unbound-control -c {$pfb['dnsbldir']}/unbound.conf flush {$domain}.");
} else {
// Remove domain from Unbound resolver pfb_dnsbl.conf file
exec("{$pfb['sed']} -i '' '/ \"{$domain} 60 IN A/d' {$pfb['dnsbl_file']}.conf");
$cache_dumpfile = '/var/tmp/unbound_cache';
unlink_if_exists("{$cache_dumpfile}");
$chroot_cmd = "chroot -u unbound -g unbound / /usr/local/sbin/unbound-control -c {$g['unbound_chroot_path']}/unbound.conf";
exec("{$chroot_cmd} dump_cache > {$cache_dumpfile}");
exec("{$chroot_cmd} reload");
if (file_exists($cache_dumpfile) && filesize($cache_dumpfile) > 0) {
exec("{$chroot_cmd} load_cache < {$cache_dumpfile}");
}
exec("/usr/local/sbin/unbound-control -c {$pfb['dnsbldir']}/unbound.conf flush {$domain}");
if (!in_array($domain, $dnssupp_ex)) {
$dnssupp_ex[] = $domain;
$dnssupp_new = base64_encode(implode("\n", $dnssupp_ex));
$pfb['dsupp'] = "{$dnssupp_new}";
write_config("pfBlockerNG: Added {$domain} to DNSBL suppress list");
}
$savemsg = gettext("Removed Domain: [ {$domain} ] from Unbound Resolver DNSBL. You may need to flush your browsers DNS Cache");
}
示例5: begin_install
function begin_install()
{
global $g, $savemsg;
if (file_exists("/tmp/install_complete")) {
return;
}
unlink_if_exists("/tmp/install_complete");
update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."), $disk));
start_installation();
}
示例6: unlink_if_exists
// Delete any leftover suricata PID files in /var/run
unlink_if_exists("{$g['varrun_path']}/suricata_*.pid");
}
// Hard kill any running Barnyard2 processes
if (is_process_running("barnyard")) {
killbyname("barnyard2");
sleep(2);
// Delete any leftover barnyard2 PID files in /var/run
unlink_if_exists("{$g['varrun_path']}/barnyard2_*.pid");
}
// Set flag for post-install in progress
$g['suricata_postinstall'] = true;
// Mount file system read/write so we can modify some files
conf_mount_rw();
// Remove any previously installed script since we rebuild it
unlink_if_exists("{$rcdir}suricata.sh");
// Create the top-tier log directory
safe_mkdir(SURICATALOGDIR);
// Create the IP Rep and SID Mods lists directory
safe_mkdir(SURICATA_SID_MODS_PATH);
safe_mkdir(SURICATA_IPREP_PATH);
// Make sure config variable is an array
if (!is_array($config['installedpackages']['suricata']['config'][0])) {
$config['installedpackages']['suricata']['config'][0] = array();
}
// Download the latest GeoIP DB updates and create cron task if the feature is not disabled
if ($config['installedpackages']['suricata']['config'][0]['autogeoipupdate'] != 'off') {
log_error(gettext("[Suricata] Installing free GeoIP country database files..."));
include "/usr/local/pkg/suricata/suricata_geoipupdate.php";
install_cron_job("/usr/bin/nice -n20 /usr/local/bin/php -f /usr/local/pkg/suricata/suricata_geoipupdate.php", TRUE, 0, 0, 8, "*", "*", "root");
}
示例7: defCmdT
defCmdT("last 1000 NTP log entries", "/usr/local/sbin/clog /var/log/ntpd.log 2>&1 | tail -n 1000");
defCmdT("last 1000 OpenVPN log entries", "/usr/local/sbin/clog /var/log/openvpn.log 2>&1 | tail -n 1000");
defCmdT("last 1000 Captive Portal auth log entries", "/usr/local/sbin/clog /var/log/portalauth.log 2>&1 | tail -n 1000");
defCmdT("last 1000 PPP log entries", "/usr/local/sbin/clog /var/log/poes.log 2>&1 | tail -n 1000");
defCmdT("last 1000 relayd log entries", "/usr/local/sbin/clog /var/log/relayd.log 2>&1 | tail -n 1000");
defCmdT("last 1000 resolver log entries", "/usr/local/sbin/clog /var/log/resolver.log 2>&1 | tail -n 1000");
defCmdT("last 1000 routing log entries", "/usr/local/sbin/clog /var/log/routing.log 2>&1 | tail -n 1000");
defCmdT("last 1000 wireless log entries", "/usr/local/sbin/clog /var/log/wireless.log 2>&1 | tail -n 1000");
if (file_exists("/tmp/PHP_errors.log")) {
defCmdT("PHP Error Log", "/bin/cat /tmp/PHP_errors.log");
}
defCmdT("System Message Buffer", "/sbin/dmesg -a");
defCmdT("System Message Buffer (Boot)", "/bin/cat /var/log/dmesg.boot");
defCmdT("sysctl values", "/sbin/sysctl -a");
defCmdT("Kernel Environment", "/bin/kenv");
defCmdT("Installed OS Packages", "/usr/sbin/pkg info");
exec("/bin/date", $dateOutput, $dateStatus);
$currentDate = $dateOutput[0];
$pgtitle = array("{$g['product_name']}", "Status");
include "head.inc";
print_info_box(gettext("Make sure all sensitive information is removed! (Passwords, etc.) before posting " . "information from this page in public places (like mailing lists).") . '<br />' . gettext("Common password fields in config.xml have been automatically redacted.") . '<br />' . gettext("When the page has finished loading, the output will be stored in {$output_file}. It may be downloaded via scp or ") . "<a href=\"/exec.php?dlPath={$output_file}\">" . gettext("Diagnostics > Command Prompt.") . '</a>');
listCmds();
execCmds();
print gettext("Saving output to archive...");
if (is_dir($output_path)) {
mwexec("/usr/bin/tar czpf " . escapeshellarg($output_file) . " -C " . escapeshellarg(dirname($output_path)) . " " . escapeshellarg(basename($output_path)));
unlink_if_exists("{$output_path}/*");
@rmdir($output_path);
}
print gettext("Done.");
include "foot.inc";
示例8: sprintf
$input_errors[] = $vertical_bar_err_text;
}
} else {
$final_address_details[] = sprintf(gettext("Entry added %s"), date('r'));
}
}
} else {
if ($_POST['type'] == "url" || $_POST['type'] == "url_ports") {
$desc_fmt_err_found = false;
/* item is a url type */
for ($x = 0; $x < $max_alias_addresses - 1; $x++) {
$_POST['address' . $x] = trim($_POST['address' . $x]);
if ($_POST['address' . $x]) {
/* fetch down and add in */
$temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
unlink_if_exists($temp_filename);
$verify_ssl = isset($config['system']['checkaliasesurlcert']);
mkdir($temp_filename);
download_file($_POST['address' . $x], $temp_filename . "/aliases", $verify_ssl);
/* if the item is tar gzipped then extract */
if (stristr($_POST['address' . $x], ".tgz")) {
process_alias_tgz($temp_filename);
} else {
if (stristr($_POST['address' . $x], ".zip")) {
process_alias_unzip($temp_filename);
}
}
if (!isset($alias['aliasurl'])) {
$alias['aliasurl'] = array();
}
$alias['aliasurl'][] = $_POST['address' . $x];
示例9: write_config
exit;
}
if ($_POST['apply']) {
write_config();
$retval = 0;
/* Setup pf rules since the user may have changed the optimization value */
$retval = filter_configure();
$savemsg = get_std_save_message($retval);
if (stristr($retval, "error") != true) {
$savemsg = get_std_save_message($retval);
} else {
$savemsg = $retval;
}
/* reset rrd queues */
unlink_if_exists("/var/db/rrd/*queuedrops.rrd");
unlink_if_exists("/var/db/rrd/*queues.rrd");
enable_rrd_graphing();
clear_subsystem_dirty('shaper');
}
$pgtitle = array(gettext("Firewall"), gettext("Traffic Shaper"), gettext("Wizards"));
$shortcut_section = "trafficshaper";
$wizards = array(gettext("Multiple Lan/Wan") => "traffic_shaper_wizard_multi_all.xml", gettext("Dedicated Links") => "traffic_shaper_wizard_dedicated.xml");
include "head.inc";
if ($input_errors) {
print_input_errors($input_errors);
}
$tab_array = array();
$tab_array[] = array(gettext("By Interface"), false, "firewall_shaper.php");
$tab_array[] = array(gettext("By Queue"), false, "firewall_shaper_queues.php");
$tab_array[] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php");
$tab_array[] = array(gettext("Wizards"), true, "firewall_shaper_wizards.php");
示例10: update_status
@copy("{$tmpfname}/{$emergingthreats_filename_md5}", "{$suricatadir}{$emergingthreats_filename_md5}");
}
if ($pkg_interface != "console") {
update_status(gettext("Extraction of {$et_name} rules completed..."));
update_output_window(gettext("Installation of {$et_name} rules completed..."));
}
error_log(gettext("\tInstallation of {$et_name} rules completed.\n"), 3, SURICATA_RULES_UPD_LOGFILE);
rmdir_recursive("{$tmpfname}/emerging");
}
}
/* Untar Snort rules file to tmp */
if ($snortdownload == 'on') {
if (file_exists("{$tmpfname}/{$snort_filename}")) {
/* Remove the old Snort rules files */
$vrt_prefix = VRT_FILE_PREFIX;
unlink_if_exists("{$suricatadir}rules/{$vrt_prefix}*.rules");
if ($pkg_interface != "console") {
update_status(gettext("Extracting Snort VRT rules..."));
update_output_window(gettext("Installing Sourcefire VRT rules..."));
}
error_log(gettext("\tExtracting and installing Snort VRT rules...\n"), 3, SURICATA_RULES_UPD_LOGFILE);
/* extract snort.org rules and add prefix to all snort.org files */
safe_mkdir("{$tmpfname}/snortrules");
exec("/usr/bin/tar xzf {$tmpfname}/{$snort_filename} -C {$tmpfname}/snortrules rules/");
$files = glob("{$tmpfname}/snortrules/rules/*.rules");
foreach ($files as $file) {
$newfile = basename($file);
@copy($file, "{$suricatadir}rules/" . VRT_FILE_PREFIX . "{$newfile}");
}
/* IP lists */
$files = glob("{$tmpfname}/snortrules/rules/*.txt");
示例11: elseif
}
} elseif ($openappid_detectors == 'on') {
/**************************************************************************************/
/* Only updated OpenAppID detectors, so do not need to rebuild all interface rules. */
/* Restart snort if running, and not in post-install, so as to pick up the detectors. */
/**************************************************************************************/
if (!$g['snort_postinstall'] && is_service_running("snort") && count($config['installedpackages']['snortglobal']['rule']) > 0) {
if ($pkg_interface != "console") {
update_status(gettext('Restarting Snort to activate the new OpenAppID detectors...'));
update_output_window(gettext("Please wait ... restarting Snort will take some time..."));
}
error_log(gettext("\tRestarting Snort to activate the new OpenAppID detectors...\n"), 3, SNORT_RULES_UPD_LOGFILE);
touch("{$g['varrun_path']}/snort_pkg_starting.lck");
snort_restart_all_interfaces(TRUE);
sleep(2);
unlink_if_exists("{$g['varrun_path']}/snort_pkg_starting.lck");
if ($pkg_interface != "console") {
update_output_window(gettext("Snort has restarted with your new set of OpenAppID detectors..."));
}
log_error(gettext("[Snort] Snort has restarted with your new set of OpenAppID detectors..."));
error_log(gettext("\tSnort has restarted with your new set of OpenAppID detectors.\n"), 3, SNORT_RULES_UPD_LOGFILE);
} else {
if ($pkg_interface != "console") {
update_output_window(gettext("The rules update task is complete..."));
}
}
}
/* remove $tmpfname files */
if (is_dir("{$tmpfname}")) {
rmdir_recursive($tmpfname);
}
示例12: thebrig_populate
if (!$input_errors) {
// We have specified a new location for thebrig's installation, and it's valid, and we don't already have
// a jail at the old location. Call thebrig_populate, which will move all the web stuff and create the
// directory tree
// Also add startup command when thebrig completly installed
thebrig_populate($pconfig['rootfolder'], $config['thebrig']['rootfolder']);
$config['thebrig']['rootfolder'] = $pconfig['rootfolder'];
// Store the newly specified folder in the XML config
$config['thebrig']['template'] = $pconfig['template'];
$config['thebrig']['basejail']['folder'] = $pconfig['basejail'];
$langfile = file("ext/thebrig/lang.inc");
$version_1 = preg_split("/VERSION_NBR, 'v/", $langfile[1]);
$config['thebrig']['version'] = 0 + substr($version_1[1], 0, 3);
write_config();
// Write the config to disk
unlink_if_exists("/tmp/thebrig.tmp");
// Whatever we did, we did it successfully
$retval = 0;
$savemsg = get_std_save_message($retval);
}
// end of no input errors
}
// end of POST
// Display the page title, based on the constants defined in lang.inc
$pgtitle = array(_THEBRIG_EXTN, _THEBRIG_TITLE, _THEBRIG_BASIC_CONFIG, _THEBRIG_VERSION_NBR);
// Uses the global fbegin include
include "fbegin.inc";
// This will evaluate if there were any input errors from prior to the user clicking "save"
if ($input_errors) {
print_input_errors($input_errors);
} elseif ($savemsg) {
示例13: move_uploaded_file
}
}
return FALSE;
}
if (isset($_POST['upload'])) {
if ($_FILES["iprep_fileup"]["error"] == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["iprep_fileup"]["tmp_name"];
$name = $_FILES["iprep_fileup"]["name"];
move_uploaded_file($tmp_name, "{$iprep_path}{$name}");
} else {
$input_errors[] = gettext("Failed to upload file {$_FILES["iprep_fileup"]["name"]}");
}
}
if (isset($_POST['iplist_delete']) && isset($_POST['iplist_fname'])) {
if (!snort_is_iplist_active($_POST['iplist_fname'])) {
unlink_if_exists("{$iprep_path}{$_POST['iplist_fname']}");
} else {
$input_errors[] = gettext("This IP List is currently assigned as a Whitelist or Blackist for an interface and cannot be deleted.");
}
}
if (isset($_POST['iplist_edit']) && isset($_POST['iplist_fname'])) {
$file = $iprep_path . basename($_POST['iplist_fname']);
$data = file_get_contents($file);
if ($data !== FALSE) {
$iplist_data = htmlspecialchars($data);
$iplist_edit_style = "display: table-row-group;";
$iplist_name = basename($_POST['iplist_fname']);
unset($data);
} else {
$input_errors[] = gettext("An error occurred reading the file.");
}
示例14: unset
$a_nat[$id]['ips_policy_enable'] = 'off';
unset($a_nat[$id]['ips_policy']);
}
$enabled_items = "";
if (is_array($_POST['toenable'])) {
$enabled_items = implode("||", $_POST['toenable']);
} else {
$enabled_items = $_POST['toenable'];
}
$a_nat[$id]['rulesets'] = $enabled_items;
if ($_POST['autoflowbits'] == "on") {
$a_nat[$id]['autoflowbitrules'] = 'on';
} else {
$a_nat[$id]['autoflowbitrules'] = 'off';
if (file_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}")) {
unlink_if_exists("{$snortdir}/snort_{$snort_uuid}_{$if_real}/rules/{$flowbit_rules_file}");
}
}
write_config("Snort pkg: save enabled rule categories for {$a_nat[$id]['interface']}.");
/*************************************************/
/* Update the snort conf file and rebuild the */
/* rules for this interface. */
/*************************************************/
$rebuild_rules = true;
conf_mount_rw();
snort_generate_conf($a_nat[$id]);
conf_mount_ro();
$rebuild_rules = false;
/* Soft-restart Snort to live-load new rules */
snort_reload_config($a_nat[$id]);
$pconfig = $_POST;
示例15: date
require_once "/etc/inc/filter.inc";
require_once "/etc/inc/config.inc";
$hour = date('H');
$pfbdir = '/usr/local/pkg/pfblocker';
$updates = 0;
$cron = array('01hour' => 1, '04hours' => 4, '12hours' => 12, 'EveryDay' => 23);
if ($config['installedpackages']['pfblockerlists']['config'] != "") {
foreach ($config['installedpackages']['pfblockerlists']['config'] as $list) {
if (is_array($list['row'])) {
foreach ($list['row'] as $row) {
if ($row['url'] != "" && $hour > 0) {
$md5_url = md5($row['url']);
$update_hour = array_key_exists($list['cron'], $cron) ? $cron[$list['cron']] : 25;
if ($row['url'] && $hour % $update_hour == 0) {
print $update_hour . " " . $pfbdir . '/' . $md5_url . '.txt' . "\n";
unlink_if_exists($pfbdir . '/' . $md5_url . '.txt');
$updates++;
}
}
}
}
}
}
if ($updates > 0) {
include "/usr/local/pkg/pfblocker.inc";
sync_package_pfblocker("cron");
}
}
function pfblocker_get_countries()
{
$files = array("Africa" => "/usr/local/pkg/Africa_cidr.txt", "Asia" => "/usr/local/pkg/Asia_cidr.txt", "Europe" => "/usr/local/pkg/Europe_cidr.txt", "North America" => "/usr/local/pkg/North_America_cidr.txt", "Oceania" => "/usr/local/pkg/Oceania_cidr.txt", "South America" => "/usr/local/pkg/South_America_cidr.txt");