summaryrefslogtreecommitdiffstats
path: root/lib/exilog_util.pm
diff options
context:
space:
mode:
authorTom Kistner <tom@duncanthrax.net>2008-12-04 11:24:17 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-12-12 23:18:56 +0100
commitf8a8bc98f9a77d24e0fce2abd73c9512bcf26f2d (patch)
tree84af841fdb450b60d54e590ec02b9ddb0e671cba /lib/exilog_util.pm
parenta35e1469841bfbc7e58b66dcefb108993bc4b494 (diff)
downloadexilog-f8a8bc98f9a77d24e0fce2abd73c9512bcf26f2d.zip
exilog-f8a8bc98f9a77d24e0fce2abd73c9512bcf26f2d.tar.gz
exilog-f8a8bc98f9a77d24e0fce2abd73c9512bcf26f2d.tar.bz2
Forward unreleased changes
- IPv6 address parsing - Some queue management - Better SQL quoting - More misc stuff Signed-off-by: Tom Kistner <tom@duncanthrax.net>
Diffstat (limited to 'lib/exilog_util.pm')
-rw-r--r--lib/exilog_util.pm40
1 files changed, 38 insertions, 2 deletions
diff --git a/lib/exilog_util.pm b/lib/exilog_util.pm
index c50e679..2823bf2 100644
--- a/lib/exilog_util.pm
+++ b/lib/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') {