mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Add icon for manually editing the squid config files https://github.com/webmin/webmin/issues/242
This commit is contained in:
BIN
gray-theme/squid/images/manual.gif
Executable file
BIN
gray-theme/squid/images/manual.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -3,7 +3,7 @@ require 'squid-lib.pl';
|
||||
@accopts = ('portsnets', 'othercaches', 'musage', 'logging', 'copts',
|
||||
'hprogs', 'actrl', 'admopts', 'proxyauth', 'miscopt', 'cms',
|
||||
'rebuild', 'calamaris', 'delay', 'headeracc', 'refresh', 'cachemgr',
|
||||
'authparam', 'iptables');
|
||||
'authparam', 'iptables', 'manual');
|
||||
|
||||
# acl_security_form(&options)
|
||||
# Output HTML for editing security options for the squid module
|
||||
|
||||
@@ -8,23 +8,7 @@ do 'squid-lib.pl';
|
||||
# Returns files and directories that can be backed up
|
||||
sub backup_config_files
|
||||
{
|
||||
# Add main config file
|
||||
my @rv = ( $config{'squid_conf'} );
|
||||
|
||||
# Add users file
|
||||
my $conf = &get_config();
|
||||
my $file = &get_auth_file($conf);
|
||||
push(@rv, $file) if ($file);
|
||||
|
||||
# Add files from ACLs
|
||||
my @acl = &find_config("acl", $conf);
|
||||
foreach my $a (@acl) {
|
||||
if ($a->{'values'}->[2] =~ /^"(.*)"$/ || $a->{'values'}->[3] =~ /^"(.*)"$/) {
|
||||
push(@rv, $1);
|
||||
}
|
||||
}
|
||||
|
||||
return &unique(@rv);
|
||||
return &get_all_config_files();
|
||||
}
|
||||
|
||||
# pre_backup(&files)
|
||||
|
||||
32
squid/edit_manual.cgi
Executable file
32
squid/edit_manual.cgi
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Show a form for editing a mapping file
|
||||
|
||||
require './squid-lib.pl';
|
||||
&ReadParse();
|
||||
$access{'manual'} || &error($text{'manual_ecannot'});
|
||||
&ui_print_header(undef, $text{'manual_title'}, "");
|
||||
|
||||
# Find all the config files
|
||||
@files = &get_all_config_files();
|
||||
$file = $in{'file'} || $files[0];
|
||||
if (@files > 1) {
|
||||
# Show form to select
|
||||
print &ui_form_start("edit_manual.cgi");
|
||||
print $text{'manual_file'},"\n";
|
||||
print &ui_select("file", $file, [ map { [ $_ ] } @files ]),"\n";
|
||||
print &ui_submit($text{'manual_change'});
|
||||
print &ui_form_end(),"<p>\n";
|
||||
}
|
||||
|
||||
# Show the file contents
|
||||
$data = &read_file_contents($file);
|
||||
print &ui_form_start("save_manual.cgi", "form-data");
|
||||
print &ui_hidden("file", $file);
|
||||
print &text('manual_editing', "<tt>$file</tt>"),"<br>\n";
|
||||
print &ui_table_start();
|
||||
print &ui_table_row(undef, &ui_textarea("data", $data, 20, 80), 2);
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ "save", $text{'save'} ] ] );
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
BIN
squid/images/manual.gif
Normal file
BIN
squid/images/manual.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 478 B |
@@ -37,6 +37,15 @@ index_restart=Apply Configuration
|
||||
index_restartdesc=Click this button to activate the current Squid configuration.
|
||||
index_iptables=Port Redirection Setup
|
||||
index_squid=Squid Proxy Server
|
||||
index_manual=Edit Configuration Files
|
||||
|
||||
manual_title=Edit Configuration Files
|
||||
manual_file=Select a config file to edit:
|
||||
manual_change=Change
|
||||
manual_editing=Use the text box below to manually edit the configs in $1. Be careful, as no syntax or validity checking will be done.
|
||||
manual_err=Failed to save config file
|
||||
manual_efile=Invalid config filename!
|
||||
manual_ecannot=You are not allowed to manually edit config files
|
||||
|
||||
buttsave=Save
|
||||
buttdel=Delete
|
||||
|
||||
18
squid/save_manual.cgi
Executable file
18
squid/save_manual.cgi
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Update a manually edited config file
|
||||
|
||||
require './squid-lib.pl';
|
||||
&ReadParseMime();
|
||||
&error_setup($text{'manual_err'});
|
||||
$access{'manual'} || &error($text{'manual_ecannot'});
|
||||
@files = &get_all_config_files();
|
||||
&indexof($in{'file'}, @files) >= 0 || &error($text{'manual_efile'});
|
||||
|
||||
# Save the data
|
||||
$in{'data'} =~ s/\r//g;
|
||||
&open_lock_tempfile(FILE, ">$in{'file'}");
|
||||
&print_tempfile(FILE, $in{'data'});
|
||||
&close_tempfile(FILE);
|
||||
|
||||
&webmin_log("manual", undef, $in{'file'});
|
||||
&redirect("");
|
||||
@@ -608,5 +608,28 @@ sub list_cachemgr_actions
|
||||
return ("5min" ,"60min" ,"asndb" ,"authenticator" ,"cbdata" ,"client_list" ,"comm_incoming" ,"config" ,"counters" ,"delay" ,"digest_stats" ,"dns" ,"events" ,"filedescriptors" ,"fqdncache" ,"histograms" ,"http_headers" ,"info" ,"io" ,"ipcache" ,"mem" ,"menu" ,"netdb" ,"non_peers" ,"objects" ,"offline_toggle" ,"pconn" ,"peer_select" ,"redirector" ,"refresh" ,"server_list" ,"shutdown" ,"store_digest" ,"storedir" ,"utilization" ,"via_headers" ,"vm_objects");
|
||||
}
|
||||
|
||||
# get_all_config_files()
|
||||
# Returns all files from the Squid config
|
||||
sub get_all_config_files
|
||||
{
|
||||
# Add main config file
|
||||
my @rv = ( $config{'squid_conf'} );
|
||||
|
||||
# Add users file
|
||||
my $conf = &get_config();
|
||||
my $file = &get_auth_file($conf);
|
||||
push(@rv, $file) if ($file);
|
||||
|
||||
# Add files from ACLs
|
||||
my @acl = &find_config("acl", $conf);
|
||||
foreach my $a (@acl) {
|
||||
if ($a->{'values'}->[2] =~ /^"(.*)"$/ || $a->{'values'}->[3] =~ /^"(.*)"$/) {
|
||||
push(@rv, $1);
|
||||
}
|
||||
}
|
||||
|
||||
return &unique(@rv);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user