[r1416]: branches / 2.6 / cgi-bin / yabb2 / Sources / RemoveTopic.pm  Maximize  Restore  History

Download this file

270 lines (248 with data), 9.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
###############################################################################
# RemoveTopic.pm #
# $Date: 02.20.14 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.6.0 #
# Packaged: February 20, 2014 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.6.0';
$removetopicpmver = 'YaBB 2.6.0 $Revision: 1416 $';
if ( $action eq 'detailedversion' ) { return 1; }
sub RemoveThread {
my $thread = $INFO{'thread'};
if ( $thread =~ /\D/xsm ) { fatal_error('only_numbers_allowed'); }
if ( !$staff && !$iamposter ) {
fatal_error('delete_not_allowed');
}
if ( !$currentboard ) {
MessageTotals( 'load', $thread );
$currentboard = ${$thread}{'board'};
}
my $threadline = q{};
fopen( BOARDFILE, "+<$boardsdir/$currentboard.txt", 1 )
|| fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 );
my @buffer = <BOARDFILE>;
for my $aa ( 0 .. ( @buffer - 1 ) ) {
if ( $buffer[$aa] =~ m{\A$thread\|}xsm ) {
$threadline = $buffer[$aa];
$buffer[$aa] = q{};
last;
}
}
truncate BOARDFILE, 0;
seek BOARDFILE, 0, 0;
print {BOARDFILE} @buffer or croak "$croak{'print'} BOARDFILE";
fclose(BOARDFILE);
if ($threadline) {
if ( !ref $thread_arrayref{$thread} ) {
fopen( FILE, "$datadir/$thread.txt" )
|| fatal_error( 'cannot_open', "$datadir/$thread.txt", 1 );
@{ $thread_arrayref{$thread} } = <FILE>;
fclose(FILE);
}
BoardTotals( 'load', $currentboard );
if ( ( split /\|/xsm, $threadline )[8] !~ /m/sm ) {
${ $uid . $currentboard }{'threadcount'}--;
${ $uid . $currentboard }{'messagecount'} -=
@{ $thread_arrayref{$thread} };
# &BoardTotals("update", ...) is done in &BoardSetLastInfo
}
BoardSetLastInfo( $currentboard, \@buffer );
# remove thread files
unlink "$datadir/$thread.txt";
unlink "$datadir/$thread.ctb";
unlink "$datadir/$thread.mail";
unlink "$datadir/$thread.poll";
unlink "$datadir/$thread.polled";
# remove attachments
require Admin::Attachments;
my %remattach;
$remattach{$thread} = undef;
RemoveAttachments( \%remattach );
}
# remove from Movedthreads.pm only if it's the final thread
# then look backwards to delete the other entries in
# the Moved-Info-row if their files were deleted
*moved_loop = sub {
my $th = shift;
foreach ( keys %moved_file ) {
if ( exists $moved_file{$_}
&& $moved_file{$_} == $th
&& !-e "$datadir/$th.txt" )
{
delete $moved_file{$_};
$save_moved = 1;
moved_loop($_);
}
}
};
if ( eval { require Variables::Movedthreads; 1 } ) {
if ( !$moved_file{$thread} ) {
moved_loop($thread);
if ($save_moved) { save_moved_file(); }
}
}
if ( $INFO{'moveit'} != 1 ) {
$yySetLocation = qq~$scripturl?board=$currentboard~;
redirectexit();
}
return;
}
sub DeleteThread {
my @x = @_;
$delete = $FORM{'thread'} || $INFO{'thread'} || $x[0];
if ( !$currentboard ) {
MessageTotals( 'load', $delete );
$currentboard = ${$delete}{'board'};
}
if ( $FORM{'ref'} eq 'favorites' ) {
$INFO{'ref'} = 'delete';
require Sources::Favorites;
RemFav($delete);
}
if ( ( !$adminbin || ( !$iamadmin && !$iamgmod && !$iamfmod ) )
&& $binboard ne q{}
&& $currentboard ne $binboard )
{
require Sources::MoveSplitSplice;
$INFO{'moveit'} = 1;
$INFO{'board'} = $currentboard;
$INFO{'thread'} = $delete;
$INFO{'oldposts'} = 'all';
$INFO{'leave'} = 2;
$INFO{'newinfo'} = 1;
$INFO{'newboard'} = $binboard;
$INFO{'newthread'} = 'new';
Split_Splice_2();
}
elsif ( $iamadmin || $iamgmod || $iamfmod || $binboard eq q{} ) {
$INFO{'moveit'} = 1;
$INFO{'thread'} = $delete;
RemoveThread();
}
$yySetLocation = qq~$scripturl?board=$currentboard~;
redirectexit();
return;
}
sub Multi {
if ( !$staff ) { fatal_error('not_allowed'); }
require Sources::SetStatus;
require Sources::MoveSplitSplice;
my $mess_loop;
if ( $FORM{'allpost'} =~ m/all/ism ) {
BoardTotals( 'load', $currentboard );
$mess_loop = ${ $uid . $currentboard }{'threadcount'};
}
else {
$mess_loop = $maxdisplay;
}
my $count = 1;
while ( $mess_loop >= $count ) {
my ( $lock, $stick, $move, $delete, $ref, $hide );
if ( $FORM{'multiaction'} eq q{} ) {
$lock = $FORM{"lockadmin$count"};
$stick = $FORM{"stickadmin$count"};
$move = $FORM{"moveadmin$count"};
$delete = $FORM{"deleteadmin$count"};
$hide = $FORM{"hideadmin$count"};
}
elsif ( $FORM{'multiaction'} eq 'lock' ) {
$lock = $FORM{"admin$count"};
}
elsif ( $FORM{'multiaction'} eq 'stick' ) {
$stick = $FORM{"admin$count"};
}
elsif ( $FORM{'multiaction'} eq 'move' ) {
$move = $FORM{"admin$count"};
}
elsif ( $FORM{'multiaction'} eq 'delete' ) {
$delete = $FORM{"admin$count"};
}
elsif ( $FORM{'multiaction'} eq 'hide' ) {
$hide = $FORM{"admin$count"};
}
if ( $FORM{'ref'} eq 'favorites' ) {
$ref = qq~$scripturl?action=favorites~;
}
else {
$ref = qq~$scripturl?board=$currentboard~;
}
if ($lock) {
$INFO{'moveit'} = 1;
$INFO{'thread'} = $lock;
$INFO{'action'} = 'lock';
$INFO{'ref'} = $ref;
SetStatus();
}
if ($stick) {
$INFO{'moveit'} = 1;
$INFO{'thread'} = $stick;
$INFO{'action'} = 'sticky';
$INFO{'ref'} = $ref;
SetStatus();
}
if ($move) {
$INFO{'moveit'} = 1;
$INFO{'board'} = $currentboard;
$INFO{'thread'} = $move;
$INFO{'oldposts'} = 'all';
$INFO{'leave'} = 0;
$INFO{'newinfo'} ||= $FORM{'newinfo'};
$INFO{'newboard'} = $FORM{'toboard'};
$INFO{'newthread'} = 'new';
if ( !$INFO{'newboard'} ) { redirectmove($currentboard); }
else {
Split_Splice_2();
}
}
if ($hide) {
$INFO{'moveit'} = 1;
$INFO{'action'} = 'hide';
$INFO{'thread'} = $hide;
SetStatus();
}
if ($delete) {
if ( !$currentboard ) {
MessageTotals( 'load', $delete );
$currentboard = ${$delete}{'board'};
}
if ( $FORM{'ref'} eq 'favorites' ) {
$INFO{'ref'} = 'delete';
require Sources::Favorites;
RemFav($delete);
}
if ( ( !$adminbin || ( !$iamadmin && !$iamgmod && !$iamfmod ) )
&& $binboard ne q{}
&& $currentboard ne $binboard )
{
$INFO{'moveit'} = 1;
$INFO{'board'} = $currentboard;
$INFO{'thread'} = $delete;
$INFO{'oldposts'} = 'all';
$INFO{'leave'} = 2;
$INFO{'newinfo'} = 1;
$INFO{'newboard'} = $binboard;
$INFO{'newthread'} = 'new';
Split_Splice_2();
}
elsif ( $iamadmin || $iamgmod || $iamfmod || $binboard eq q{} ) {
$INFO{'moveit'} = 1;
$INFO{'thread'} = $delete;
RemoveThread();
}
}
$count++;
}
$yySetLocation = qq~$scripturl?board=$currentboard~;
redirectexit();
return;
}
1;

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks