# Execute Dev-Editor's commands
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-21
+# Last modified: 2004-12-26
#
use strict;
use POSIX qw(strftime);
use Tool;
-use CGI qw(header);
+use CGI qw(header
+ escape);
+
use HTML::Entities;
use Output;
use Template;
my $dirlist = "";
+ my $filter1 = $data->{'cgi'}->param('filter') || '*'; # The real wildcard
+ my $filter2 = ($filter1 && $filter1 ne '*') ? $filter1 : ''; # Wildcard for output
+
# Create the link to the upper directory
# (only if we are not in the root directory)
foreach my $dir(@$dirs)
{
+ next unless(dos_wildcard_match($filter1,$dir));
+
my $phys_path = $physical."/".$dir;
my $virt_path = encode_entities($virtual.$dir."/");
foreach my $file(@$files)
{
+ next unless(dos_wildcard_match($filter1,$file));
+
my $phys_path = $physical."/".$file;
my $virt_path = encode_entities($virtual.$file);
$tpl->fillin("SCRIPT",$script);
$tpl->fillin("URL",encode_entities(equal_url($config->{'httproot'},$virtual)));
+ $tpl->fillin("FILTER",encode_entities($filter2));
+ $tpl->fillin("FILTER_URL",escape($filter2));
+
$tpl->parse_if_block("dir_writeable",$dir_writeable);
+ $tpl->parse_if_block("filter",$filter2);
}
else
{
#
# Dev-Editor - Module File::Access
#
-# Some simple routines for doing things with files
-# with only one command
+# Some simple routines for doing things with files by
+# using only one command
#
# Author: Patrick Canterino <patrick@patshaping.de>
# Last modified: 2004-12-17
# Some shared sub routines
#
# Author: Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2004-12-16
+# Last modified: 2004-12-25
#
use strict;
@EXPORT = qw(check_path
clean_path
devedit_reload
+ dos_wildcard_match
equal_url
file_name
mode_string
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);
+}
+
# equal_url()
#
# Create URL equal to a file or directory
<table border="0" width="100%">
<tr>
+<td>
+<table border="0">
+<tr>
<form action="{SCRIPT}">
<input type="hidden" name="command" value="show">
-<td>Go to directory/file: <input type="text" name="file" value="{DIR}"> <input type="submit" value="Go!"></td>
+<td>Go to directory/file:</td>
+<td><input type="text" name="file" value="{DIR}"></td>
+<td><input type="submit" value="Go!"></td>
</form>
-<td align="right"><a href="{SCRIPT}?command=about" target="_blank"><i>About Dev-Editor</i></a></td>
+</tr>
+<tr>
+<form action="{SCRIPT}">
+<input type="hidden" name="command" value="show">
+<input type="hidden" name="file" value="{DIR}">
+<td>Filter:</td>
+<td><input type="text" name="filter" value="{FILTER}"></td>
+<td><input type="submit" value="Filter!"></td>
+</form>
+</tr>
+</table>
+</td>
+<td align="right" valign="top"><a href="{SCRIPT}?command=about" target="_blank"><i>About Dev-Editor</i></a></td>
</tr>
</table>
</body>
<tr>
<td align="right" style="white-space:nowrap">[SUBDIR]</td>
<td style="padding-left:15pt;white-space:nowrap;">{DATE}</td>
-<td style="padding-left:15pt;white-space:nowrap;">{IF readable}<a href="{SCRIPT}?command=show&file={DIR}">{DIR_NAME}/</a>{ELSE}<span style="color:#C0C0C0" title="Not accessible">{DIR_NAME}/</span>{ENDIF}</td>
+<td style="padding-left:15pt;white-space:nowrap;">{IF readable}<a href="{SCRIPT}?command=show&file={DIR}{IF filter}&filter={FILTER_URL}{ENDIF}">{DIR_NAME}/</a>{ELSE}<span style="color:#C0C0C0" title="Not accessible">{DIR_NAME}/</span>{ENDIF}</td>
<td style="padding-left:15pt;white-space:nowrap;">({IF dir_writeable}<a href="{SCRIPT}?command=rename&file={DIR}">Rename</a> | <a href="{SCRIPT}?command=remove&file={DIR}">Delete</a> | {ENDIF}{IF users}<a href="{SCRIPT}?command=chprop&file={DIR}">Chmod/Chgrp</a> | {ENDIF}<a href="{URL}" target="_blank">View in Browser</a>)</td>
</tr>
<tr>
<td align="right" style="white-space:nowrap">[SUBDIR]</td>
<td style="padding-left:15pt;white-space:nowrap;">{DATE}</td>
-<td colspan="2" style="padding-left:15pt;white-space:nowrap"><a href="{SCRIPT}?command=show&file={UPPER_DIR}">../</a></td>
+<td colspan="2" style="padding-left:15pt;white-space:nowrap"><a href="{SCRIPT}?command=show&file={UPPER_DIR}{IF filter}&filter={FILTER_URL}{ENDIF}">../</a></td>
</tr>