From: Jamie C. <jca...@we...> - 2006-11-04 06:14:55
|
Hi Joseph, That's a nice patch, although I'm not totally sure that it belongs in the Apache module in the core Webmin distribution ... mainly because I am working on a new separate module for editing the PHP configuration file, in a user-friendly way. It should be out in a release or two .. - Jamie On 3/Nov/2006 14:00 Fry, Joseph wrote .. > I have developers who need access to view the apache log files, and edit > php.ini on our server. Unfortunately, I cannot give those developers access > to the logs module or the file manager module. So, to meet their need > I modified apache/allmanual_save.cgi and apache/allmanual_form.cgi as follows. > I am not an experienced developer, so I am unfamiliar with submitting patches, > but I felt that this would be a valuable feature to include in future releases, > if anyone is willing to review and improve my code for submittion, I would > appreciate it! > > Essentially, these modifications cause a file in the module's directory > (should be in /etc/ but I didn't take the time to do this) called "editfiles.ini" > to be parsed, and appends any line that is not started with a # or whitespace > to be added to the dropdown list of files to edit. If any line begins > with "ro ", that file is read-only. > > If a file is read-only, the submit button is removed, and the file name > is italicised in the dropdown box. Users will not be able to save a read-only > file. > > The files I started with were from webmin Version 1.300. I am sorry I > do not have a diff file. > > Thank you all for a great product! > > Joe Fry > > ----------------------------------------------------------- > #!/usr/bin/perl > # allmanual_save.cgi > # Save an entire config file > > require './apache-lib.pl'; > &ReadParseMime(); > $access{'types'} eq '*' && $access{'virts'} eq '*' || > &error($text{'manual_ecannot'}); > > $conf = &get_config(); > @files = &unique(map { $_->{'file'} } @$conf); > > $editfiles = &read_file_lines("editfiles.ini"); > foreach $editfile (@$editfiles) { > if ($editfile !~ /^#/ and $editfile !~ /^$|^\s+/) > { > if ($editfile !~ /^ro\s/) > { > push(@files, $editfile); > } > } > } > > &indexof($in{'file'}, @files) >= 0 || &error($text{'manual_efile'}); > > $temp = &transname(); > &execute_command("cp ".quotemeta($in{'file'})." $temp"); > $in{'data'} =~ s/\r//g; > &lock_file($in{'file'}); > &open_tempfile(FILE, ">$in{'file'}"); > &print_tempfile(FILE, $in{'data'}); > &close_tempfile(FILE); > &unlock_file($in{'file'}); > if ($config{'test_manual'}) { > $err = &test_config(); > if ($err) { > &execute_command("mv $temp '$in{'file'}'"); > &error(&text('manual_etest', "<pre>$err</pre>")); > } > } > unlink($temp); > &webmin_log("manual", undef, undef, { 'file' => $in{'file'} }); > &redirect(""); > ------------------------------------------------------------------- > #!/usr/bin/perl > # allmanual_form.cgi > # Display a text box for manually editing directives from one of the files > > require './apache-lib.pl'; > &ReadParse(); > $access{'types'} eq '*' && $access{'virts'} eq '*' || > &error($text{'manual_ecannot'}); > &ui_print_header(undef, $text{'manual_configs'}, ""); > > $conf = &get_config(); > @files = grep { -f $_ } &unique(map { $_->{'file'} } @$conf); > > # ADD FILES TO EDIT OR DISPLAY IN editfiles.ini > > $editfiles = &read_file_lines("editfiles.ini"); > foreach $editfile (@$editfiles) { > if ($editfile !~ /^#/ and $editfile !~ /^$|^\s+/) > { > push(@files, $editfile); > } > } > $in{'file'} = $files[0] if (!$in{'file'}); > print "<form action=allmanual_form.cgi>\n"; > print "<input type=submit value='$text{'manual_file'}'>\n"; > print "<select name=file>\n"; > foreach $f (@files) { > if ($f =~ /^ro\s/) { > $format = "style='font-style: italic'"; > } else { > $format = ""; > } > printf "<option %s %s>%s\n", > $format, $f eq $in{'file'} ? 'selected' : '', $f; > $found++ if ($f eq $in{'file'}); > } > print "</select>Files in italics are Read Only</form>\n"; > $found || &error($text{'manual_efile'}); > > if ($in{'file'} =~ /^ro\s/) > { > print "<form action=allmanual_form.cgi method=post ", > "enctype=multipart/form-data>\n"; > $buttontype = "hidden"; > $filename = $in{'file'}; > $filename =~ s/^ro\s//; > } else { > print "<form action=allmanual_save.cgi method=post ", > "enctype=multipart/form-data>\n"; > $buttontype = "submit"; > $filename = $in{'file'}; > } > print "<input type=hidden name=file value='$in{'file'}'>\n"; > print "<textarea name=data rows=20 cols=80 style='width:100%'>"; > open(FILE, $filename); > while(<FILE>) { print &html_escape($_); } > close(FILE); > print "</textarea><br>\n"; > print "<input type=$buttontype value='$text{'save'}'>\n"; > print "</form>\n"; > > &ui_print_footer("", $text{'index_return'}); > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.430 / Virus Database: 268.13.25/515 - Release Date: 11/3/2006 > 5:15 AM > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > - > Forwarded by the Webmin development list at web...@we... > To remove yourself from this list, go to > http://lists.sourceforge.net/lists/listinfo/webadmin-devel |