summaryrefslogtreecommitdiffstats
path: root/exilog_util.pm
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-12-12 23:27:57 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-12-12 23:27:57 +0100
commitf1370d810782a2b4099ff31be83ca312051f9100 (patch)
tree8ead7a9bccf7ba88fbdbf5a6eb0d32a4f287ea5d /exilog_util.pm
parent226ad0a3c764c0606048acf7371b02765eee60d2 (diff)
downloadexilog-f1370d810782a2b4099ff31be83ca312051f9100.zip
exilog-f1370d810782a2b4099ff31be83ca312051f9100.tar.gz
exilog-f1370d810782a2b4099ff31be83ca312051f9100.tar.bz2
fix conflict on merging upstream from Tom Kistner
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'exilog_util.pm')
-rw-r--r--exilog_util.pm40
1 files changed, 38 insertions, 2 deletions
diff --git a/exilog_util.pm b/exilog_util.pm
index c50e679..2823bf2 100644
--- a/exilog_util.pm
+++ b/exilog_util.pm
@@ -29,6 +29,9 @@ BEGIN {
&date_to_stamp
&stamp_to_date
&human_size
+ &dos2rx
+ &dos2sql
+ &png
);
%EXPORT_TAGS = ();
@@ -36,9 +39,42 @@ BEGIN {
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw();
+
+}
+
+sub png {
+ my $image = shift;
+ my $width = shift;
+ my $height = shift;
+ my $title = shift || "";
+
+ return '<img src="'.$image.'" width="'.$width.'" height="'.$height.'" title="'.$title.'" border="0">';
}
+# turns DOS wildcards (* and ?) into regular expressions
+sub dos2rx {
+ my $cand = shift;
+
+ # quote every funky character
+ $cand =~ s/([^A-Za-z0-9 _?*])/\\$1/g;
+
+ $cand =~ s/\?/./g;
+ $cand =~ s/\*/.*?/g;
+
+ return '^'.$cand.'$';
+};
+
+# turns DOS wildcards (* and ?) into SQL wildcards (% and .)
+sub dos2sql {
+ my $cand = shift;
+
+ $cand =~ s/\*/%/g;
+ $cand =~ s/\?/./g;
+
+ return $cand;
+};
+
# checks if scalar is in array
sub ina {
my $aref = shift || [];
@@ -87,7 +123,7 @@ sub date_to_stamp {
$year-=1900;
$month--;
- # This is for parsing timestamps that include GMT offsets
+ # This is for parsing timestamps that include GMT offsets
if (edv($junk)) {
my $hoff = ($junk =~ /[-+](\d\d)\d\d/);
my $moff = ($junk =~ /[-+]\d\d(\d\d)/);
@@ -98,7 +134,7 @@ sub date_to_stamp {
else {
$hour = $hour + $hoff;
$minute = $minute + $moff;
- }
+ }
};
if ($config->{web}->{timestamps} eq 'local') {