X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/9218fb0859abdc5a09758bed809b26902ae179d6..f91793544f0d5c7f978e5cf6214d9882d7c4db7c:/selfforum-cgi/shared/Posting/_lib.pm?ds=inline diff --git a/selfforum-cgi/shared/Posting/_lib.pm b/selfforum-cgi/shared/Posting/_lib.pm index 1f6de85..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"':'') . '>'