+# Params: 1. Pattern
+# 2. String
+#
+# Return: Status code (Boolean)
+
+sub dos_wildcard_match($$)
+{
+ my ($pattern,$string) = @_;
+
+ return 1 if($pattern eq '*');
+
+ # The following part is stolen from File::DosGlob
+
+ # escape regex metachars but not glob chars
+ $pattern =~ s:([].+^\-\${}[|]):\\$1:g;
+ # and convert DOS-style wildcards to regex
+ $pattern =~ s/\*/.*/g;
+ $pattern =~ s/\?/.?/g;
+
+ return ($string =~ m|^$pattern$|is);
+}
+
+# encode_html()
+#
+# Encode HTML control characters (< > " &)
+#
+# Params: String to encode
+#
+# Return: Encoded string
+
+sub encode_html($)
+{
+ my $string = shift;
+
+ $string =~ s/&/&/g;
+ $string =~ s/</</g;
+ $string =~ s/>/>/g;
+ $string =~ s/"/"/g;
+
+ return $string;
+}
+
+# equal_url()
+#
+# Create URL equal to a file or directory
+#
+# Params: 1. HTTP root
+# 2. Relative path
+#
+# Return: Formatted link (String)
+
+sub equal_url($$)
+{
+ my ($root,$path) = @_;
+ my $url;
+
+ $root =~ s!/+$!!;
+ $path =~ s!^/+!!;
+ $url = $root.'/'.$path;
+
+ return $url;
+}
+
+# file_name()
+#
+# Return the last part of a path
+#
+# Params: Path
+#
+# Return: Last part of the path
+
+sub file_name($)
+{
+ my $path = shift;
+ $path =~ tr!\\!/!;
+
+ unless($path =~ m!^/+$! || ($^O eq 'MSWin32' && $path =~ m!^[a-z]:/+$!i))
+ {
+ $path =~ s!/+$!!;
+ $path = substr($path,rindex($path,'/')+1);
+ }
+
+ return $path;
+}
+
+# is_forbidden_file()
+#
+# Check if a file is in the list of forbidden files
+#
+# Params: 1. Array Reference containing the list
+# 2. Filename to check
+#
+# Return: Status code (Boolean)
+
+sub is_forbidden_file($$)
+{
+ my ($list,$file) = @_;
+ $file =~ s!/+$!!g;
+
+ foreach my $entry(@$list)
+ {
+ return 1 if($file eq $entry);
+ return 1 if(index($file,$entry.'/') == 0);
+ }
+
+ return;
+}
+
+# mode_string()
+#
+# Convert a file mode number into a human readable string (rwxr-x-r-x)
+# (also supports SetUID, SetGID and Sticky Bit)
+#
+# Params: File mode number
+#
+# Return: Human readable mode string
+
+sub mode_string($)
+{
+ my $mode = shift;
+ my $string = '';
+
+ # User
+
+ $string = ($mode & 00400) ? 'r' : '-';
+ $string .= ($mode & 00200) ? 'w' : '-';
+ $string .= ($mode & 00100) ? (($mode & 04000) ? 's' : 'x') :
+ ($mode & 04000) ? 'S' : '-';
+
+ # Group
+
+ $string .= ($mode & 00040) ? 'r' : '-';
+ $string .= ($mode & 00020) ? 'w' : '-';
+ $string .= ($mode & 00010) ? (($mode & 02000) ? 's' : 'x') :
+ ($mode & 02000) ? 'S' : '-';
+
+ # Other
+
+ $string .= ($mode & 00004) ? 'r' : '-';
+ $string .= ($mode & 00002) ? 'w' : '-';
+ $string .= ($mode & 00001) ? (($mode & 01000) ? 't' : 'x') :
+ ($mode & 01000) ? 'T' : '-';
+
+ return $string;
+}
+
+# multi_string()
+#
+# Create a Hash Reference containing three forms of a string
+#
+# Params: String
+#
+# Return: Hash Reference:
+# normal => Normal form of the string
+# html => HTML encoded form (see encode_html())
+# url => URL encoded form
+
+sub multi_string($)
+{
+ my $string = shift;
+ my %multi;
+
+ $multi{'normal'} = $string;
+ $multi{'html'} = encode_html($string);
+ $multi{'url'} = escape($string);
+
+ return \%multi;
+}
+
+# upper_path()