X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/408b8a7b8262c7808c79bba94f09026a9db2ac04..f91793544f0d5c7f978e5cf6214d9882d7c4db7c:/selfforum-cgi/shared/Posting/_lib.pm diff --git a/selfforum-cgi/shared/Posting/_lib.pm b/selfforum-cgi/shared/Posting/_lib.pm index 4ca1514..83439c5 100644 --- a/selfforum-cgi/shared/Posting/_lib.pm +++ b/selfforum-cgi/shared/Posting/_lib.pm @@ -4,8 +4,8 @@ package Posting::_lib; # # # File: shared/Posting/_lib.pm # # # -# Authors: André Malo , 2001-06-11 # -# Frank Schoenmann , 2001-06-04 # +# Authors: André Malo # +# Frank Schönmann # # # # Description: Message access interface, time format routines # # # @@ -14,19 +14,22 @@ package Posting::_lib; use strict; use vars qw( @EXPORT_OK - $VERSION ); use Encode::Plain; $Encode::Plain::utf8 = 1; -use Time::German; +use Time::German qw(localtime); use XML::DOM; ################################################################################ # # Version check # -$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +# last modified: +# $Date$ (GMT) +# by $Author$ +# +sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'} ################################################################################ # @@ -37,6 +40,8 @@ use constant SORT_DESCENT => 1; use constant KEEP_DELETED => 1; use constant KILL_DELETED => 0; +use constant FORUM_DTD => 'http://selfforum.sourceforge.net/dtd/forum.dtd'; + use base qw(Exporter); @EXPORT_OK = qw( get_message_header @@ -132,7 +137,7 @@ sub create_message ($$) { # create a XML::DOM::Document object of a thread containing one posting # # Params: hash reference -# (dtd, thread, msg, body, ip, name, email, home, +# (thread, msg, body, ip, name, email, home, # image, category, subject, time) # # Return: XML::DOM::Document object @@ -153,7 +158,7 @@ sub create_new_thread ($) { # set doctype # - my $dtd = $xml -> createDocumentType ('Forum' => $par -> {dtd}); + my $dtd = $xml -> createDocumentType ('Forum' => FORUM_DTD); $xml -> setDoctype ($dtd); # create root element 'Forum' @@ -399,7 +404,8 @@ sub sort_thread ($$) { for (@smsg) { ++$z; splice @smsg,$z,0,@{$mhash{$_ -> {mid}}} if ($_ -> {answers}); - delete $_ -> {kids};} + delete $_ -> {kids}; + } # return \@smsg; @@ -465,13 +471,13 @@ sub get_all_threads ($$;$) { close(FILE) or return; if (wantarray) { - ($dtd) = $xml =~ //; + $dtd = FORUM_DTD; ($last_thread) = map {/(\d+)/} $xml =~ /]*>/; ($last_message) = map {/(\d+)/} $xml =~ /]*>/; } my $reg_msg = qr~(?: - |]*>\s* + |]*>\s*
[^<]*(?:<(?!Name>)[^<]*)* ([^<]+)[^<]*(?:<(?!Category>)[^<]*)* ([^<]*)\s* @@ -491,7 +497,7 @@ sub get_all_threads ($$;$) { push @stack,$cmno if (defined $cmno); push @msg, { mid => $1, - unid => $2, + unid => (defined $2) ? $2 : '', deleted => $3 || 0, archive => $4 || 0, name => $5, @@ -507,11 +513,11 @@ sub get_all_threads ($$;$) { if (defined $cmno) { push @{$msg[$cmno] -> {kids}} => $#msg; - push @{$msg[$cmno] -> {unids}} => $2; + push @{$msg[$cmno] -> {unids}} => (defined $2) ? $2 : '#'; } else { - push @unids => $2; + push @unids => (defined $2) ? $2 : ''; } $msg[$_] -> {answers}++ for (@stack); @@ -527,7 +533,7 @@ sub get_all_threads ($$;$) { { push @msg, { mid => $1, - unid => $2, + unid => (defined $2) ? $2 : '', deleted => $3 || 0, archive => $4 || 0, name => $5, @@ -543,12 +549,12 @@ sub get_all_threads ($$;$) { if (defined $cmno) { push @{$msg[$cmno] -> {kids}} => $#msg; - push @{$msg[$cmno] -> {unids}} => $2; + push @{$msg[$cmno] -> {unids}} => (defined $2) ? $2 : ''; $msg[$cmno] -> {answers}++; } else { - push @unids => $2; + push @unids => (defined $2) ? $2 : ''; } $msg[$_] -> {answers}++ for (@stack); @@ -588,9 +594,9 @@ sub create_forum_xml_string ($$) { my ($level, $thread, $msg); my $xml = - ''."\n" - . ' {dtd}.'">'."\n" - . ''; + ''."\n" + . ''."\n" + . ''; for $thread (sort {$b <=> $a} keys %$threads) { $xml .= ''; @@ -602,7 +608,7 @@ sub create_forum_xml_string ($$) { $level = $msg -> {level}; $xml .= ' {unid}) ?' unid="'.$msg -> {unid}.'"':'') . (($msg -> {deleted})?' invisible="1"':'') . (($msg -> {archive})?' archive="1"':'') . '>' @@ -683,26 +689,26 @@ sub month($) { } sub hr_time ($) { - my (undef, $min, $hour, $day, $mon, $year) = germantime (shift); + my (undef, $min, $hour, $day, $mon, $year) = localtime (shift); sprintf ('%02d. %s %04d, %02d:%02d Uhr', $day, month($mon+1), $year+1900, $hour, $min); } sub short_hr_time ($) { - my (undef, $min, $hour, $day, $mon, $year) = germantime (shift); + my (undef, $min, $hour, $day, $mon, $year) = localtime (shift); sprintf ('%02d. %02d. %04d, %02d:%02d Uhr', $day, $mon+1, $year+1900, $hour, $min); } sub long_hr_time ($) { my @wday = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag); - my ($sek, $min, $hour, $day, $mon, $year, $wday) = germantime (shift); + my ($sek, $min, $hour, $day, $mon, $year, $wday) = localtime (shift); sprintf ('%s, %02d. %s %04d, %02d:%02d:%02d Uhr', $wday[$wday], $day, month($mon+1), $year+1900, $hour, $min, $sek); } sub very_short_hr_time($) { - my (undef, $min, $hour, $day, $mon, $year) = germantime (shift); + my (undef, $min, $hour, $day, $mon, $year) = localtime (shift); sprintf ('%02d. %02d. %04d', $day, $mon+1, $year+1900); }