X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/ba659b53059e637777865e646f0f2a6fb7f2988e..03e918e15295c454bbcd6aa0e3a0459d99090afe:/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 fea4097..5136b21 100644 --- a/selfforum-cgi/shared/Posting/_lib.pm +++ b/selfforum-cgi/shared/Posting/_lib.pm @@ -2,7 +2,7 @@ # ==================================================== # Autor: n.d.p. / 2001-01-07 -# lm : n.d.p. / 2001-01-08 +# lm : n.d.p. / 2001-02-25 # ==================================================== # Funktion: # * Schnittstellen fuer den Zugriff auf Messages @@ -13,7 +13,8 @@ use strict; package Posting::_lib; -use vars qw(@ISA @EXPORT_OK); +use vars qw(@EXPORT_OK); +use base qw(Exporter); use Encode::Plain; $Encode::Plain::utf8 = 1; @@ -23,8 +24,6 @@ use XML::DOM; # Funktionsexport # ==================================================== -require Exporter; -@ISA = qw(Exporter); @EXPORT_OK = qw(get_message_header get_message_body get_message_node parse_single_thread hr_time short_hr_time long_hr_time get_all_threads @@ -71,14 +70,19 @@ sub get_message_header ($) { # Messagebody auslesen ########################### -sub get_message_body ($$) { - my ($xml,$mid) = @_; +sub get_message_body ($$) +{ + my ($xml, $mid) = @_; my $body; - foreach ($xml -> getElementsByTagName ('ContentList', 1) -> item (0) -> getElementsByTagName ('MessageContent', 0)) { - if ($_ -> getAttribute ('mid') eq $mid) { + foreach ($xml -> getElementsByTagName ('ContentList', 1) -> item (0) -> getElementsByTagName ('MessageContent', 0)) + { + if ($_ -> getAttribute ('mid') eq $mid) + { $body = ($_ -> hasChildNodes)?$_ -> getFirstChild -> getData:''; - last;}} + last; + } + } \$body; } @@ -123,7 +127,8 @@ sub parse_single_thread ($$;$) { ip => $_ -> getAttribute ('ip'), kids => [$_ -> getElementsByTagName ('Message', 0)], answers => $_ -> getElementsByTagName ('Message') -> getLength, - deleted => ($_ -> getAttribute ('flag') eq 'deleted')?1:0, + deleted => $_ -> getAttribute ('invisible'), + archive => $_ -> getAttribute ('archive'), name => plain($header -> {name}), cat => plain($header -> {category} or ''), subject => plain($header -> {subject}), @@ -161,17 +166,19 @@ sub create_message_xml ($$$) { my $message = $xml -> createElement ('Message'); $message -> setAttribute ('id', 'm'.$msg -> {mid}); - $message -> setAttribute ('flag', 'deleted') if ($msg -> {deleted}); + $message -> setAttribute ('invisible', '1') if ($msg -> {deleted}); + $message -> setAttribute ('archive', '1') if ($msg -> {archive}); # Header erzeugen - my $header = $xml -> createElement ('Header'); + my $header = $xml -> createElement ('Header'); # alles inside of 'Header' my $author = $xml -> createElement ('Author'); - my $name = $xml -> createElement ('Name'); - $name -> addText (toUTF8($msg -> {name})); - my $email = $xml -> createElement ('Email'); + my $name = $xml -> createElement ('Name'); + $name -> addText (toUTF8($msg -> {name})); + + my $email = $xml -> createElement ('Email'); my $category = $xml -> createElement ('Category'); $category -> addText (toUTF8($msg -> {cat})); @@ -182,8 +189,8 @@ sub create_message_xml ($$$) { my $date = $xml -> createElement ('Date'); $date -> setAttribute ('longSec', $msg -> {time}); - $author -> appendChild ($name); - $author -> appendChild ($email); + $author -> appendChild ($name); + $author -> appendChild ($email); $header -> appendChild ($author); $header -> appendChild ($category); $header -> appendChild ($subject); @@ -192,7 +199,9 @@ sub create_message_xml ($$$) { if ($msg -> {kids}) { for (@{$msg -> {kids}}) { - $message -> appendChild (&create_message_xml ($xml, $msges, $_));}} + $message -> appendChild (&create_message_xml ($xml, $msges, $_)); + } + } $message; } @@ -288,7 +297,7 @@ sub get_all_threads ($$;$) { ($last_message) = map {/(\d+)/} $xml =~ /]*>/;} my $reg_msg = qr~(?: - |]*>\s* + |]*>\s*
[^<]*(?:<(?!Name>)[^<]*)* ([^<]+)[^<]*(?:<(?!Category>)[^<]*)* ([^<]*)\s* @@ -303,7 +312,7 @@ sub get_all_threads ($$;$) { while ($thread =~ m;$reg_msg;g) { - if (defined($9)) { + if (defined($10)) { push @stack,$cmno if (defined $cmno); push @msg, {}; @@ -322,9 +331,10 @@ sub get_all_threads ($$;$) { $msg[-1] -> {name}, $msg[-1] -> {cat}, $msg[-1] -> {subject}, - $msg[-1] -> {time}) = ($1, $2, $4, $5, $6, $7); + $msg[-1] -> {time}) = ($1, $2, $5, $6, $7, $8); - $msg[-1] -> {deleted} = ($3 eq 'deleted')?1:undef; + $msg[-1] -> {deleted} = $3; + $msg[-1] -> {archive} = $4; $msg[-1] -> {name} =~ s/&/&/g; $msg[-1] -> {cat} =~ s/&/&/g; @@ -335,7 +345,7 @@ sub get_all_threads ($$;$) { $msg[-1] -> {answers} = 0; $msg[-1] -> {level} = $level++;} - elsif (defined ($8)) { + elsif (defined ($9)) { push @msg, {}; if (defined $cmno) { @@ -352,9 +362,10 @@ sub get_all_threads ($$;$) { $msg[-1] -> {name}, $msg[-1] -> {cat}, $msg[-1] -> {subject}, - $msg[-1] -> {time}) = ($1, $2, $4, $5, $6, $7); + $msg[-1] -> {time}) = ($1, $2, $5, $6, $7, $8); - $msg[-1] -> {deleted} = ($3 eq 'deleted')?1:undef; + $msg[-1] -> {deleted} = $3; + $msg[-1] -> {archive} = $4; $msg[-1] -> {name} =~ s/&/&/g; $msg[-1] -> {cat} =~ s/&/&/g; @@ -404,7 +415,8 @@ sub create_forum_xml_string ($$) { $level = $msg -> {level}; $xml .= ' {deleted})?' flag="deleted"':'') + .(($msg -> {deleted})?' invisible="1"':'') + .(($msg -> {archive})?' archive="1"':'') .'>' .'
' .'' @@ -473,8 +485,8 @@ sub save_file ($$) { ########################### sub hr_time ($) { - my @month = qw(Januar Februar M\303\244rz April Mail Juni Juli August September Oktober November Dezember); - # ^^^^^^^^ - UTF8 # + my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mail Juni Juli August September Oktober November Dezember)); + # ^^^^^^^^ - UTF8 # my (undef, $min, $hour, $day, $mon, $year) = localtime ($_[0]); @@ -488,8 +500,8 @@ sub short_hr_time ($) { } sub long_hr_time ($) { - my @month = qw(Januar Februar M\303\244rz April Mail Juni Juli August September Oktober November Dezember); - # ^^^^^^^^ - UTF8 # + my @month = (qw(Januar Februar), "M\303\244rz", qw(April Mail Juni Juli August September Oktober November Dezember)); + # ^^^^^^^^ - UTF8 # my @wday = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag); my ($sek, $min, $hour, $day, $mon, $year, $wday) = localtime ($_[0]);