Add button to un-protect without deleting
authorJamie Cameron <jcameron@webmin.com>
Thu, 14 May 2009 21:12:40 +0000 (21:12 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 14 May 2009 21:12:40 +0000 (21:12 +0000)
htaccess-htpasswd/CHANGELOG
htaccess-htpasswd/delete.cgi
htaccess-htpasswd/index.cgi
htaccess-htpasswd/lang/en
htaccess-htpasswd/save_dir.cgi
htaccess-htpasswd/search.cgi

index 4cba723..1f0991b 100644 (file)
@@ -22,3 +22,5 @@ Fixed a bug that prevented a groups file from being added to an existing directo
 Added a button to link to the Apache module (if accessible) for editing all settings in the .htaccess file.
 ---- Changes since 1.450 ----
 Added a Module Config option to set permissions on created .htaccess and .htpasswd files, which defaults to 644.
+---- Changes since 1.480 ----
+Added a button to remove protection from multiple directories, without removing the .htaccess file.
index 02afc83..ea5cfe1 100755 (executable)
@@ -16,12 +16,25 @@ foreach $d (@d) {
        if ($dir) {
                $htaccess = "$dir->[0]/$config{'htaccess'}";
                &can_access_dir($htaccess) || &error($text{'dir_ecannot'});
-               &unlink_logged($htaccess);
-               &unlink_logged($dir->[1]) if (!-d $dir->[1]);
-               &unlink_logged($dir->[4]) if ($dir->[4] && !-d $dir->[4]);
+               if ($in{'remove'}) {
+                       # Block away the whole file
+                       &unlink_logged($htaccess);
+                       &unlink_logged($dir->[1])
+                               if (!-d $dir->[1]);
+                       &unlink_logged($dir->[4])
+                               if ($dir->[4] && !-d $dir->[4]);
+                       }
+               else {
+                       # Take the authentication directives out of .htaccess
+                       $conf = &foreign_call($apachemod,
+                                             "get_htaccess_config", $htaccess);
+                       &foreign_call($apachemod, "save_directive",
+                                     "require", [ ], $conf, $conf);
+                       }
                @dirs = grep { $_ ne $dir } @dirs;
                }
        }
+&flush_file_lines();
 
 # Save directory list
 &save_directories(\@dirs);
index 3306e55..6f4d0d3 100755 (executable)
@@ -143,7 +143,8 @@ if (@dirs) {
        print &ui_columns_end();
        if ($can_create) {
                print &ui_links_row(\@links);
-               print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
+               print &ui_form_end([ [ "delete", $text{'index_delete'} ],
+                                    [ "remove", $text{'index_remove'} ] ]);
                }
        }
 else {
index b42afd3..0d4098f 100644 (file)
@@ -15,6 +15,7 @@ index_sha1=SHA1 encryption is enabled in the module configuration, but the $1 Pe
 index_digest2=Digest encryption is enabled in the module configuration, but the $1 command or $2 Perl module needed for it is not installed.
 index_cpan=<a href='$1'>Click here</a> to download and install it now.
 index_delete=Un-Protect Selected Directories
+index_remove=Un-Protect and Remove Files
 
 dir_title1=Add Protected Directory
 dir_title2=Edit Protected Directory
index c596814..7826081 100755 (executable)
@@ -63,14 +63,13 @@ if ($in{'delete'} || $in{'remove'}) {
                &unlink_logged($htaccess);
                &unlink_logged($currfile) if ($currfile && !-d $currfile);
                &unlink_logged($currgfile) if ($currgfile && !-d $currgfile);
-               @dirs = grep { $_ ne $dir } @dirs;
                }
        else {
-               # Take the authentication directives out of the .htaccess
-               @dirs = grep { $_ ne $dir } @dirs;
+               # Take the authentication directives out of .htaccess
                &foreign_call($apachemod, "save_directive",
                              "require", [ ], $conf, $conf);
                }
+       @dirs = grep { $_ ne $dir } @dirs;
        }
 else {
        # Validate inputs
index 5163165..510193d 100755 (executable)
@@ -37,7 +37,9 @@ while($f = <FIND>) {
                $conf = &foreign_call($apachemod, "get_htaccess_config", $f);
                $currfile = &foreign_call($apachemod, "find_directive",
                                          "AuthUserFile", $conf, 1);
-               if ($currfile) {
+               $require = &foreign_call($apachemod, "find_directive",
+                                        "require", $conf, 1);
+               if ($currfile && $require) {
                        print &text('search_found', "<tt>$f</tt>",
                                    "<tt>$currfile</tt>"),"<br>\n";
                        local $d = $f;