Server IP : 195.201.23.43 / Your IP : 3.148.109.137 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/virtualmin-htpasswd/ |
Upload File : |
# Common functions for simple protected directory management use strict; use warnings; no warnings qw(redefine); our (%text); BEGIN { push(@INC, ".."); }; eval "use WebminCore;"; &init_config(); &foreign_require("htaccess-htpasswd", "htaccess-lib.pl"); &foreign_require("virtual-server", "virtual-server-lib.pl"); &foreign_require("apache", "apache-lib.pl"); # can_directory(dir, [&domain]) # Returns 1 if the current user can edit protection in the given directory sub can_directory { my ($dir, $d) = @_; if ($d) { # Just check specific domain return &is_under_directory($d->{'home'}, $dir); } else { # Check all of his domains my @doms = grep { &virtual_server::can_edit_domain($_) } &virtual_server::list_domains(); foreach my $dd (@doms) { return 1 if (&is_under_directory($dd->{'home'}, $dir)); } return 0; } } # remove_public_html(dir, &domain) # Returns a path relative to public_html, for display. If under cgi-bin, # path is relative to home. If under another domain's public_html dir, path # is relative to that. sub remove_public_html { my ($dir, $dom) = @_; my $hdir = &virtual_server::public_html_dir($dom); if ($hdir) { # Take relative to public_html or cgi-bin dir if ($hdir eq $dir) { return "<i>$text{'index_hdir'}</i>"; } my $cdir = &virtual_server::cgi_bin_dir($dom); if ($dir =~ /^\Q$hdir\E\/(.*)$/) { return $1; } elsif ($dir =~ /^\Q$cdir\E\/(.*)$/) { return $1." (CGI)"; } elsif ($dir =~ /^\Q$dom->{'home'}\E\/domains\/([^\/]+)/) { # Under a sub-server my $sd = &virtual_server::get_domain_by("dom", $1); if ($sd) { my $rv = &remove_public_html($dir, $sd); if ($rv) { return $rv." (".$sd->{'dom'}.")"; } } } # Not under either .. return full path return $dir; } else { # Take relative to home my $hdir = $dom->{'home'}; $dir =~ s/^\Q$hdir\E\///; return $dir; } } # empty_file(filename) # Returns true if a file contains no non-whitespace lines sub empty_file { my ($file) = @_; my $lref = &read_file_lines($file, 1); foreach my $l (@$lref) { return 0 if ($l =~ /\S/); } return 1; } 1;Private