#!/usr/bin/perl
-# ====================================================
-# Autor: n.d.p. / 2001-01-23
-# lm : n.d.p. / 2001-01-25
-# ====================================================
-# Funktion:
-# Entgegennahme von Postings und
-# Darstellung der "Neue Nachricht"-Seite
-# ====================================================
+################################################################################
+# #
+# File: user/fo_posting.pl #
+# #
+# Authors: André Malo <nd@o3media.de>, 2001-01-25 #
+# #
+# Description: Accept new postings, display "Neue Nachricht" page #
+# #
+################################################################################
use strict;
use vars qw($Bin $Shared $Script %subhash $httpurl $flocked);
use Template::Posting;
use CGI qw(param header);
-
use XML::DOM;
print header (-type => 'text/html');
our $formmust = $show_posting -> {form} -> {must};
our $formdata = $show_posting -> {form} -> {data};
our $formact = $show_posting -> {form} -> {action};
-our $template = new Template "$Bin/".$show_posting -> {templateFile};
+our $template = new Template $show_posting -> {templateFile};
our $pars = {};
our ($failed, %dparam, $threads, $last_thread, $last_message, $ftid, $fmid, $flocked);
-sub forum_filename () {$conf -> {wwwRoot} . $conf -> {files} -> {forum};}
-sub message_path () {$conf -> {wwwRoot} . $conf -> {files} -> {messagePath};}
+sub forum_filename () {$conf -> {files} -> {forum};}
+sub message_path () {$conf -> {files} -> {messagePath};}
################################
# end of main / Funktionen
# ====================================================
-################################
-# sub check_reply_dupe
-#
-# Reply moeglich?
-# Doppelposting?
-################################
+### check_reply_dupe () ########################################################
+#
+# Reply moeglich? Doppelposting?
+#
+# Params: -none-
+# Return: Dupe check result
+# 'Dupe' - Posting is a dupe
+# Nothing - ok.
+#
sub check_reply_dupe () {
my $stat;
if ($stat == 0) {
# ueberlastet oder so
violent_unlock_file (forum_filename);
- return 'Occupied';}
-
- else {
- return 'masterLock';}}
-
- else {
+ return 'Occupied';
+ } else {
+ return 'masterLock';
+ }
+ } else {
my ($i, %msg, %unids);
$flocked = 1;
- ($threads, $last_thread, $last_message, my $unids) = get_all_threads (forum_filename, 1, 0);
+ ($threads, $last_thread, $last_message, undef, my $unids) = get_all_threads (forum_filename, 1, 0);
($ftid,$fmid) = split /;/,$dparam{$formdata -> {followUp} -> {name}},2;
# Thread existiert nicht
# nur nicht geloeschte Messages beachten
for ($i=0; $i < @{$threads -> {$ftid}}; $i++) {
if ($threads -> {$ftid} -> [$i] -> {deleted}) {
- $+=$threads -> {$ftid} -> [$i] -> {answers};}
+ $i+=$threads -> {$ftid} -> [$i] -> {answers};}
else {
$msg{$threads -> {$ftid} -> [$i] -> {mid}}=$i;}}
if (exists($dparam{$formdata -> {followUp} -> {name}})) {
return 'noReply' unless (exists($msg{$fmid}));}
- %unids = map {$_ => 1} @{$threads -> {$ftid} -> [$msg{$fmid}] -> {unids}};}
-
- else {
- %unids = map {$_ => 1} @$unids;}
+ %unids = map {$_ => 1} @{$threads -> {$ftid} -> [$msg{$fmid}] -> {unids}};
+ } else {
+ %unids = map {$_ => 1} @$unids;
+ }
# jetzt endlich
- return 'Dupe' if (exists ($unids{$dparam{$formdata -> {uniqueID} -> {name}}}));}
+ return 'Dupe' if (exists ($unids{$dparam{$formdata -> {uniqueID} -> {name}}}));
+ }
return;
}
$thx -> {category} => plain ($dparam {$formdata -> {posterCategory} -> {name}}),
$thx -> {home} => plain ($dparam {$formdata -> {posterURL} -> {name}}),
$thx -> {image} => plain ($dparam {$formdata -> {posterImage} -> {name}}),
- $thx -> {subject} => plain ($dparam {$formdata -> {posterSubject} -> {name}})})};}
+ $thx -> {subject} => plain ($dparam {$formdata -> {posterSubject} -> {name}})})};
+ }
return;
}
################################
sub fetch_subject () {
- unless (exists ($dparam{$formdata -> {posterCategory} -> {name}}) and
- exists ($dparam{$formdata -> {posterSubject} -> {name}})) {
+ my %must = map {$_ => 1} @{$formmust -> {exists $dparam{$formdata -> {followUp} -> {name}}?'reply':'new'}};
+
+ if ( ($must{posterCategory} and not exists ($dparam{$formdata -> {posterCategory} -> {name}})) or
+ ($must{posterSubject} and not exists ($dparam{$formdata -> {posterSubject} -> {name}})))
+ {
my $filename = message_path.'t'.$ftid.'.xml';
- if (lock_file ($filename)) {
+ if (-f $filename and lock_file ($filename))
+ {
my $xml = new XML::DOM::Parser -> parsefile ($filename);
violent_unlock_file($filename) unless unlock_file ($filename);
my $header = get_message_header ($mnode);
$dparam{$formdata -> {posterCategory} -> {name}} = $header -> {category};
- $dparam{$formdata -> {posterSubject} -> {name}} = $header -> {subject};}}
+ $dparam{$formdata -> {posterSubject} -> {name}} = $header -> {subject};
+ }
+ }
}
################################
# ===
$failed=1;
foreach (@{$formmust -> {$gotKeys {$formdata -> {followUp} -> {name}}?'reply':'new'}}) {
- return 'missingKey' unless ($gotKeys {$formdata -> {$_} -> {name}});}
+ return 'missingKey' unless ($gotKeys {$formdata -> {$_} -> {name}});
+ }
# 3
# ===
foreach (param) {
$failed = $name {$_};
- return 'unexpectedKey' unless (exists ($name {$_}));}
+ return 'unexpectedKey' unless (exists ($name {$_}));
+ }
# 4
# ===