]> git.p6c8.net - selfforum.git/blob - selfforum-cgi/user/fo_delete.pl
Added template and configuration for fo_delete.pl. [Christian Kruse]
[selfforum.git] / selfforum-cgi / user / fo_delete.pl
1 #!/usr/bin/perl -w
2
3 ################################################################################
4 # #
5 # File: user/admin/fo_delete.pl #
6 # #
7 # Authors: Christian Kruse <ckruse@wwwtech.de> #
8 # #
9 # Description: display the forum main file to delete msgs #
10 # #
11 ################################################################################
12
13 use strict;
14 use vars qw(
15 $Bin
16 $Shared
17 $Script
18 $Config
19 );
20
21 BEGIN {
22 my $null = $0; $null =~ s/\\/\//g if uc $^O eq 'WIN32'; # for win :-(
23 $Bin = ($null =~ /^(.*)\/.*$/)? $1 : '.';
24 $Shared = "$Bin/../shared";
25 $Config = "$Bin/../../cgi-config";
26 $Script = ($null =~ /^.*\/(.*)$/)? $1 : $null;
27 }
28
29 # setting umask, remove or comment it, if you don't need
30 #
31 umask 006;
32
33 use lib "$Shared";
34 use CGI::Carp qw(fatalsToBrowser);
35
36 use Conf;
37 use Conf::Admin;
38 use Template::Delete;
39 use Template::Posting;
40
41 use Posting::Admin;
42 use Encode::Plain; $Encode::Plain::utf8 = 1;
43 use Posting::_lib qw(
44 parse_xml_file
45 get_message_node
46 get_message_header
47 long_hr_time
48 );
49
50 use CGI qw(
51 param
52 header
53 );
54
55 ################################################################################
56 #
57 # Version check
58 #
59 # last modified:
60 # $Date$ (GMT)
61 # by $Author$
62 #
63 sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
64
65 print header(
66 -type => 'text/html',
67 -expires => 'now'
68 );
69
70 my $conf = read_script_conf($Config, $Shared, $Script);
71
72 my $show = $conf->{show};
73 my $show_forum = $show->{Forum};
74
75 my $forum_file = $conf->{files}->{forum};
76
77 # check on closed forum
78 #
79 my $main = new Lock($forum_file);
80 if ($main->masterlocked) {
81
82 my $template = new Template $show_forum->{templateFile};
83
84 $template->printscrap (
85 $show_forum->{assign}->{errorDoc},
86 { $show_forum->{assign}->{errorText} => $template->insert($show_forum->{assign}->{'notAvailable'}) }
87 );
88 }
89
90 else {
91 my $cgi = $show->{assign}->{cgi};
92 my $tree = $show->{assign}->{thread};
93
94 my $adminDefault = read_admin_conf($conf->{files}->{adminDefault});
95
96 my ($tid, $mid, $cmd) = (param($cgi->{thread}), param($cgi->{posting}), param('c'));
97
98 if(defined $cmd and defined $mid and defined $tid) {
99 if($cmd eq 'd') {
100 unless(hide_posting($forum_file,$conf->{files}->{messagePath},{'thread' => $tid, 'posting' => $mid})) {
101 my $template = new Template $show_forum->{templateFile};
102 $template->printscrap(
103 $show_forum->{assign}->{errorDoc},
104 { $show_forum->{assign}->{errorText} => $template->insert($show_forum->{assign}->{deleteFailed}) }
105 );
106 }
107 else {
108 my $template = new Template $show_forum->{templateFile};
109 my $xmlfile = parse_xml_file($conf->{files}->{messagePath}.'/t'.$tid.'.xml');
110 my $mnode = get_message_node($xmlfile,'t'.$tid,'m'.$mid);
111 my $infos = get_message_header($mnode);
112 my $ip = $mnode->getAttribute('ip');
113
114 $template->printscrap(
115 $show_forum->{assign}->{deletedDoc},{
116 $show_forum->{assign}->{tid} => $tid,
117 $show_forum->{assign}->{mid} => $mid,
118 $show->{assign}->{thread}->{cat} => plain($infos->{category}),
119 $show->{assign}->{thread}->{subject} => plain($infos->{subject}),
120 $show->{assign}->{thread}->{time} => plain(long_hr_time($infos->{time})),
121 $show->{assign}->{thread}->{name} => plain($infos->{name}),
122 $show->{Posting}->{assign}->{email} => plain($infos->{email}),
123 $show_forum->{assign}->{ip} => plain($ip)
124 }
125 );
126
127 exit 0;
128 }
129 } elsif($cmd eq 'w') {
130 unless(recover_posting($forum_file,$conf->{files}->{messagePath},{'thread' => $tid, 'posting' => $mid})) {
131 my $template = new Template $show_forum->{templateFile};
132 $template->printscrap(
133 $show_forum->{assign}->{errorDoc},
134 { $show_forum->{assign}->{errorText} => $template->insert($show_forum->{assign}->{recoverFailed}) }
135 );
136 } else {
137 print_forum_as_HTML (
138 $forum_file,
139 $show_forum->{templateFile}, {
140 showDeleted => 1,
141 assign => $show_forum->{assign},
142 adminDefault => $adminDefault,
143 cgi => $cgi,
144 tree => $tree
145 }
146 );
147 }
148 }
149 }
150 elsif (defined ($tid) and defined ($mid)) {
151 my $show_posting = $show->{Posting};
152
153 print_posting_as_HTML (
154 $conf->{files}->{messagePath},
155 $show_posting->{templateFile}, {
156 assign => $show_posting->{assign},
157 thread => $tid,
158 posting => $mid,
159 adminDefault => $adminDefault,
160 messages => $conf->{template}->{messages},
161 form => $show_posting->{form},
162 cgi => $cgi,
163 tree => $tree,
164 firsttime => 1,
165 cachepath => $conf->{files}->{cachePath},
166 showDeleted => 1
167 }
168 );
169 }
170
171 else {
172 print_forum_as_HTML (
173 $forum_file,
174 $show_forum->{templateFile}, {
175 showDeleted => 1,
176 assign => $show_forum->{assign},
177 adminDefault => $adminDefault,
178 cgi => $cgi,
179 tree => $tree
180 }
181 );
182 }
183 }
184
185
186 #
187 #
188 ### end of fo_view.pl ##########################################################

patrick-canterino.de