+# devedit_reload()
+#
+# Create a HTTP redirection header to load Dev-Editor
+# with some other parameters
+#
+# Params: Hash Reference (will be merged to a query string)
+# (optional)
+#
+# Return: HTTP redirection header (Scalar Reference)
+
+sub devedit_reload(;$)
+{
+ my $params = shift;
+
+ # Detect the protocol (simple HTTP or SSL encrypted HTTP)
+ # and check if the server listens on the default port
+
+ my $protocol = '';
+ my $port = '';
+
+ if(https)
+ {
+ # SSL encrypted HTTP (HTTPS)
+
+ $protocol = 'https';
+ $port = ':'.$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 443);
+ }
+ else
+ {
+ # Simple HTTP
+
+ $protocol = 'http';
+ $port = ':'.$ENV{'SERVER_PORT'} if($ENV{'SERVER_PORT'} != 80);
+ }
+
+ # The following code is grabbed from Template::_query of
+ # Andre Malo's selfforum (http://sourceforge.net/projects/selfforum/)
+ # and modified by Patrick Canterino
+
+ my $query = '';
+
+ if(ref($params) eq 'HASH')
+ {
+ $query = '?'.join ('&' =>
+ map {
+ (ref)
+ ? map{escape ($_).'='.escape ($params -> {$_})} @{$params -> {$_}}
+ : escape ($_).'='.escape ($params -> {$_})
+ } keys %$params
+ );
+ }
+
+ # Create the redirection header
+
+ my $header = redirect($protocol.'://'.virtual_host.$port.$ENV{'SCRIPT_NAME'}.$query);
+
+ return \$header;
+}
+
+# dos_wildcard_match()
+#
+# Check if a string matches against a DOS-style wildcard
+#
+# Params: 1. Pattern
+# 2. String
+#
+# Return: Status code (Boolean)
+
+sub dos_wildcard_match($$)
+{
+ my ($pattern,$string) = @_;
+
+ # 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;
+}
+