⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 save_cache.cgi

📁 Unix下基于Web的管理工具
💻 CGI
字号:
#!/usr/local/bin/perl# save_cache.cgi# Save cache and request optionsrequire './squid-lib.pl';&ReadParse();$conf = &get_config();$whatfailed = "Failed to save cache options";if ($in{'cache_dir_def'}) {	&save_directive($conf, "cache_dir", [ ]);	}else {	for($i=0; defined($dir = $in{"cache_dir_$i"}); $i++) {		if ($squid_version < 2) {			next if (!$dir);			&check_error(\&check_dir, $dir);			push(@chd, { 'name' => 'cache_dir',				     'values' => [ $dir ] });			}		else {			$lv1 = $in{"cache_lv1_$i"}; $lv2 = $in{"cache_lv2_$i"};			$size = $in{"cache_size_$i"};			next if (!$dir && !$lv1 && !$lv2 && !$size);			&check_error(\&check_dir, $dir);			&check_error(\&check_dirsize, $size);			&check_error(\&check_dircount, $lv1);			&check_error(\&check_dircount, $lv2);			push(@chd, { 'name' => 'cache_dir',				     'values' => [ $dir, $size, $lv1, $lv2 ] });			}		}	if (!@chd) {		&error("You must enter at least one cache directory");		}	&save_directive($conf, "cache_dir", \@chd);	}if ($squid_version < 2) {	&save_opt("swap_level1_dirs", \&check_dircount, $conf);	&save_opt("swap_level2_dirs", \&check_dircount, $conf);	&save_opt("store_avg_object_size", \&check_objsize, $conf);	}else {	&save_opt_bytes("store_avg_object_size", $conf);	}&save_opt("store_objects_per_bucket", \&check_bucket, $conf);if ($squid_version < 2) {	&save_list("cache_stoplist", undef, $conf);	&save_list("cache_stoplist_pattern", undef, $conf);	}@noch = split(/\0/, $in{'no_cache'});if (@noch) {	$nc[0] = { 'name' => 'no_cache',		   'values' => [ "deny", @noch ] };	}&save_directive($conf, "no_cache", \@nc);&save_opt_time("reference_age", $conf);if ($squid_version < 2) {	&save_opt("request_size", \&check_size, $conf);	&save_opt("negative_ttl", \&check_ttl, $conf);	&save_opt("positive_dns_ttl", \&check_dns_ttl, $conf);	&save_opt("negative_dns_ttl", \&check_dns_ttl, $conf);	}else {	&save_opt_bytes("request_size", $conf);	&save_opt_time("negative_ttl", $conf);	&save_opt_time("positive_dns_ttl", $conf);	&save_opt_time("negative_dns_ttl", $conf);	}if ($squid_version < 2) {	&save_opt("connect_timeout", \&check_timeout, $conf);	&save_opt("read_timeout", \&check_timeout, $conf);	&save_opt("client_lifetime", \&check_lifetime, $conf);	&save_opt("shutdown_lifetime", \&check_lifetime, $conf);	}else {	&save_opt_time("connect_timeout", $conf);	&save_opt_time("read_timeout", $conf);	&save_opt_time("siteselect_timeout", $conf);	&save_opt_time("request_timeout", $conf);	&save_opt_time("client_lifetime", $conf);	&save_opt_time("shutdown_lifetime", $conf);	&save_choice("half_closed_clients", "on", $conf);	&save_opt_time("pconn_timeout", $conf);	}if ($squid_version < 2) {	if (!$in{'wais_relay_def'}) {		&check_error(\&check_host, $in{'wais_relay1'});		&check_error(\&check_port, $in{'wais_relay2'});		$wr[0] = { 'name' => 'wais_relay',			   'values' =>  [ $in{'wais_relay1'}, $in{'wais_relay2'} ] };		}	&save_directive($conf, "wais_relay", \@wr);	}else {	&save_opt("wais_relay_host", \&check_host, $conf);	&save_opt("wais_relay_port", \&check_port, $conf);	}&flush_file_lines();&redirect("");sub check_dir{return (-d $_[0]) ? undef : "The cache directory '$_[0]' does not exist";}sub check_size{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid request size";}sub check_ttl{return $_[0] =~ /^\d+$/ ? undef			: "'$_[0]' is not a valid failed request cache time";}sub check_dns_ttl{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid DNS cache time";}sub check_timeout{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid timeout";}sub check_lifetime{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid time";}sub check_dircount{return $_[0] !~ /^\d+$/ ? "'$_[0]' is not a valid number of directories" :       $_[0] < 1 ? "Number of directories must be >= 1" :       $_[0] > 256 ? "Number of directories must be <= 256" : undef;    }sub check_objsize{return $_[0] =~ /^\d+/ ? undef : "'$_[0]' is not a valid object size";}sub check_bucket{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid number of objects";}sub check_dirsize{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid directory size";}sub check_host{return gethostbyname($_[0]) ? undef : "'$_[0]' is not a valid host";}sub check_port{return $_[0] =~ /^\d+$/ ? undef : "'$_[0]' is not a valid port";}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -