[r1419]: branches / 2.6 / cgi-bin / yabb2 / Admin / AntispamQuestions.pm  Maximize  Restore  History

Download this file

403 lines (355 with data), 18.1 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
###############################################################################
# AntispamQuestions.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';
$antispamquestionspmver = 'YaBB 2.6.0 $Revision: 1419 $';
if ( $action eq 'detailedversion' ) { return 1; }
my $questions_language = $FORM{'questions_language'} || $INFO{'questions_language'} || $lang;
sub SpamQuestions {
is_admin_or_gmod();
if ($en_spam_questions) { $chk_spam_question = q~ checked="checked"~; }
if ($spam_questions_send) { $chk_spam_question_send = q~ checked="checked"~; }
if ($spam_questions_gp) { $chk_spam_question_gp = q~ checked="checked"~; }
opendir LNGDIR, $langdir;
my @lfilesanddirs = readdir LNGDIR;
closedir LNGDIR;
foreach my $fld (sort {lc($a) cmp lc $b} @lfilesanddirs) {
if (-e "$langdir/$fld/Main.lng") {
my $displang = $fld;
$displang =~ s/(.+?)\_(.+?)$/$1 ($2)/gism;
if ($questions_language eq $fld) { $drawnldirs .= qq~<option value="$fld" selected="selected">$displang</option>~; }
else { $drawnldirs .= qq~<option value="$fld">$displang</option>~; }
}
}
if (-e "$langdir/$questions_language/spam.questions") {
fopen(SPAMQUESTIONS, "<$langdir/$questions_language/spam.questions") || fatal_error('cannot_open',"$langdir/$questions_language/spam.questions", 1);
@spam_questions = <SPAMQUESTIONS>;
fclose(SPAMQUESTIONS);
}
$total_questions = @spam_questions || 0;
if ($total_questions) {
$header_row = q~ colspan="5"~;
$show_questions =
qq~<tr class="catbg">
<td><b>$spam_question_txt{'question'}</b></td>
<td><b>$spam_question_txt{'answer'}</b></td>
<td><b>$spam_question_txt{'image'}</b></td>
<td><b>$admin_txt{'edit'}</b></td>
<td><b>$admin_txt{'delete'}</b></td>
</tr>~;
foreach my $question ( sort { $a <=> $b } @spam_questions ) {
chomp $question;
( $spam_question_id, $spam_question, $spam_answer, undef, $spam_image ) = split /\|/xsm,
$question;
$spam_image = $spam_image ? qq~<a href="$yyhtml_root/Templates/Forum/default/$spam_image" target="_blank">$spam_image</a>~ : $spam_question_txt{'na'};
$show_questions .= qq~<tr class="windowbg2">
<td>$spam_question</td>
<td>$spam_answer</td>
<td>$spam_image</td>
<td>
<form action="$adminurl?action=spam_questions_edit" method="post">
<input type="hidden" name="spam_question_id" value="$spam_question_id" />
<input class="button" type="submit" value="$admin_txt{'edit'}" />
<input type="hidden" name="questions_language" value="$questions_language" />
</form>
</td>
<td>
<form action="$adminurl?action=spam_questions_delete" method="post">
<input type="hidden" name="spam_question_id" value="$spam_question_id" />
<input class="button" type="submit" value="$admin_txt{'delete'}" onclick="return confirm('$spam_question_txt{'confirm'}');"/>
<input type="hidden" name="questions_language" value="$questions_language" />
</form>
</td>
</tr>~;
}
}
else {
$header_row = q~ colspan="5"~;
$show_questions = qq~<tr class="windowbg2">
<td colspan="5">$spam_question_txt{'no_questions'}</td>
</tr>~;
}
$yymain = qq~
<form action="$adminurl?action=spam_questions2" method="post">
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell" style="margin-bottom: .5em;">
<col span="2" style="width: 50%" />
<tr>
<th class="titlebg" colspan="2">$admin_img{'prefimg'} $spam_question_txt{'question_settings'}</th>
</tr><tr class="windowbg2 vtop">
<td><label for="en_spam_questions">$spam_question_txt{'enable_question'}</label></td>
<td><input type="checkbox" name="en_spam_questions" id="en_spam_questions" value="1"$chk_spam_question /></td>
</tr><tr class="windowbg2 vtop">
<td><label for="spam_questions_send">$spam_question_txt{'enable_question_send'}</label></td>
<td><input type="checkbox" name="spam_questions_send" id="spam_questions_send" value="1"$chk_spam_question_send /></td>
</tr><tr class="windowbg2 vtop">
<td><label for="spam_questions_gp">$spam_question_txt{'enable_question_gp'}</label></td>
<td><input type="checkbox" name="spam_questions_gp" id="spam_questions_gp" value="1"$chk_spam_question_gp /></td>
</tr>
</table>
</div>
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell" style="margin-bottom: .5em;">
<tr>
<th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
</tr><tr>
<td class="catbg center">
<input class="button" type="submit" value="$admin_txt{'10'}" />
<input type="hidden" name="questions_language" value="$questions_language" />
</td>
</tr>
</table>
</div>
</form>
<div class="bordercolor rightboxdiv" style="margin-bottom: .5em;">
<table class="border-space pad-cell">
<col span="2" style="width: 30%;" />
<col span="1" style="width: 26%;" />
<col span="2" style="width: 7%" />
<tr>
<th class="titlebg"$header_row>$admin_img{'prefimg'} $spam_question_txt{'questions'} ($total_questions)
<div style="display: inline; float: right;">
<form action="$adminurl?action=spam_questions" method="post" enctype="application/x-www-form-urlencoded">
<select name="questions_language" id="questions_language" size="1">
$drawnldirs
</select>
<input type="submit" value="$admin_txt{'462'}" class="button" />
</form>
</div>
</th>
</tr>
$show_questions
</table>
</div>
<form action="$adminurl?action=spam_questions_add" method="post" enctype="multipart/form-data" accept-charset="$yymycharset">
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell" style="margin-bottom: .5em;">
<col style="width: 25%" />
<col style="width: 75%" />
<tr>
<th class="titlebg" colspan="2">$admin_img{'prefimg'} $spam_question_txt{'new_question'}</th>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_question">$spam_question_txt{'question'}:</label></td>
<td><input type="text" name="spam_question" id="spam_question" size="60" maxlength="100" /></td>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_answer">$spam_question_txt{'answer'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'answer_desc'}</span></label></td>
<td><input type="text" name="spam_answer" id="spam_answer" size="60" maxlength="50" /></td>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_case">$spam_question_txt{'case_sensitive'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'case_sensitive_desc'}</span></label></td>
<td><input type="checkbox" name="spam_case" id="spam_case" value="1" /></td>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_image">$spam_question_txt{'image'} $spam_question_txt{'optional'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'image_desc'}</span></label></td>
<td><input type="file" name="spam_image" id="spam_image" size="35" /> <span class="cursor small bold" title="$admin_txt{'remove_file'}" onclick="document.getElementById('spam_image').value='';">X</span></td>
</tr>
</table>
</div>
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell" style="margin-bottom: .5em;">
<tr>
<th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
</tr><tr>
<td class="catbg center">
<input class="button" type="submit" value="$spam_question_txt{'add_question'}" />
<input type="hidden" name="questions_language" value="$questions_language" />
</td>
</tr>
</table>
</div>
</form>
~;
$yytitle = $admintxt{'a3_sub6'};
$action_area = 'spam_questions';
AdminTemplate();
exit;
}
sub SpamQuestions2 {
is_admin_or_gmod();
$en_spam_questions = $FORM{'en_spam_questions'} || '0';
$spam_questions_send = $FORM{'spam_questions_send'} || '0';
$spam_questions_gp = $FORM{'spam_questions_gp'} || '0';
require Admin::NewSettings;
SaveSettingsTo('Settings.pm');
if ( $action eq 'spam_questions2' ) {
$yySetLocation = qq~$adminurl?action=spam_questions;questions_language=$FORM{'questions_language'}~;
redirectexit();
}
return;
}
sub SpamQuestionsAdd {
is_admin_or_gmod();
$spam_question = $FORM{'spam_question'};
$spam_answer = $FORM{'spam_answer'};
$spam_case = $FORM{'spam_case'} || '0';
if ( $spam_question eq q{} ) {
fatal_error( 'invalid_value', "$spam_question_txt{'question'}" );
}
if ( $spam_answer eq q{} ) {
fatal_error( 'invalid_value', "$spam_question_txt{'answer'}" );
}
$spam_image = UploadFile('spam_image', 'Templates/Forum/default', 'png jpg jpeg gif', '250', '0');
fopen( SPAMQUESTIONS, ">>$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
print {SPAMQUESTIONS} "$date|$spam_question|$spam_answer|$spam_case|$spam_image\n"
or croak "$croak{'print'} SPAMQUESTIONS";
fclose(SPAMQUESTIONS);
if ( $action eq 'spam_questions_add' ) {
$yySetLocation = qq~$adminurl?action=spam_questions;questions_language=$FORM{'questions_language'}~;
redirectexit();
}
return;
}
sub SpamQuestionsEdit {
is_admin_or_gmod();
$id = $FORM{'spam_question_id'};
my $question_edit = q{};
fopen( SPAMQUESTIONS, "<$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
@spam_questions = <SPAMQUESTIONS>;
fclose(SPAMQUESTIONS);
foreach my $question (@spam_questions) {
chomp $question;
if ( $question =~ /$id/xsm ) {
$question_edit = $question;
last;
}
}
( $spam_question_id, $spam_question, $spam_answer, $spam_case, $spam_image ) = split /\|/xsm,
$question_edit;
if ($spam_case) { $chk_spam_case = q~ checked="checked"~; }
my $spam_image_value = q{};
if ( $spam_image ) {
$spam_image_value = qq~<div class="small bold">$admin_txt{'current_img'}: <a href="$yyhtml_root/Templates/Forum/default/$spam_image" target="_blank">$spam_image</a><br /><input type="checkbox" name="del_spam_image" id="del_spam_image" value="1" /> <label for="del_spam_image">$admin_txt{'remove_img'}</label></div>~;
}
$yymain = qq~
<form action="$adminurl?action=spam_questions_edit2" method="post" enctype="multipart/form-data" accept-charset="$yymycharset">
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell" style="margin-bottom: .5em;">
<col style="width: 25%" />
<col style="width: 75%" />
<tr>
<th class="titlebg" colspan="2">$admin_img{'prefimg'} $spam_question_txt{'edit_question'}</th>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_question">$spam_question_txt{'question'}:</label></td>
<td><input type="text" name="spam_question" id="spam_question" size="60" maxlength="100" value="$spam_question" /></td>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_answer">$spam_question_txt{'answer'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'answer_desc'}</span></label></td>
<td><input type="text" name="spam_answer" id="spam_answer" size="60" maxlength="50" value="$spam_answer" /><input type="hidden" name="spam_question_id" id="spam_question_id" value="$spam_question_id" /></td>
</tr><tr class="windowbg2 vtop bold">
<td><label for="spam_case">$spam_question_txt{'case_sensitive'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'case_sensitive_desc'}</span></label></td>
<td><input type="checkbox" name="spam_case" id="spam_case" value="1"$chk_spam_case /></td>
</tr />
<tr class="windowbg2 vtop bold">
<td><label for="spam_image">$spam_question_txt{'image'} $spam_question_txt{'optional'}:<br /><span class="small" style="font-weight: normal;">$spam_question_txt{'image_desc'}</span></label></td>
<td><input type="file" name="spam_image" id="spam_image" size="35" /><input type="hidden" name="cur_spam_image" value="$spam_image" /> <span class="cursor small bold" title="$admin_txt{'remove_file'}" onclick="document.getElementById('spam_image').value='';">X</span>$spam_image_value</td>
</tr>
</table>
</div>
<div class="bordercolor rightboxdiv">
<table class="border-space pad-cell">
<tr>
<th class="titlebg">$admin_img{'prefimg'} $admin_txt{'10'}</th>
</tr><tr>
<td class="catbg center">
<input class="button" type="submit" value="$admin_txt{'10'} $spam_question_txt{'question'}" />&nbsp;<input type="button" class="button" value="$admin_txt{'cancel'}" onclick="location.href='$adminurl?action=spam_questions;questions_language=$FORM{'questions_language'}';" />
<input type="hidden" name="questions_language" value="$questions_language" />
</td>
</tr>
</table>
</div>
</form>~;
$yytitle = $admintxt{'a3_sub6'};
AdminTemplate();
exit;
}
sub SpamQuestionsEdit2 {
is_admin_or_gmod();
$spam_question_id = $FORM{'spam_question_id'};
$spam_question = $FORM{'spam_question'};
$spam_answer = $FORM{'spam_answer'};
$spam_case = $FORM{'spam_case'} || '0';
$spam_image = $FORM{'spam_image'};
$cur_spam_image = $FORM{'cur_spam_image'};
$del_spam_image = $FORM{'del_spam_image'};
if ( $spam_question eq q{} ) {
fatal_error( 'invalid_value', "$spam_question_txt{'question'}" );
}
if ( $spam_answer eq q{} ) {
fatal_error( 'invalid_value', "$spam_question_txt{'answer'}" );
}
if ( $spam_image ne q{} ) {
$spam_image = UploadFile('spam_image', 'Templates/Forum/default', 'png jpg jpeg gif', '250', '0');
unlink "$htmldir/Templates/Forum/default/$cur_spam_image";
}
else {
$spam_image = $cur_spam_image;
}
if ( $del_spam_image ) {
unlink "$htmldir/Templates/Forum/default/$cur_spam_image";
$spam_image = q{};
}
fopen( SPAMQUESTIONS, "<$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
@spam_questions = <SPAMQUESTIONS>;
fclose(SPAMQUESTIONS);
@question = grep { !/$spam_question_id/xsm } @spam_questions;
push @question, "$spam_question_id|$spam_question|$spam_answer|$spam_case|$spam_image";
$question = join q{}, @question;
fopen( SPAMQUESTIONS, ">$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
print {SPAMQUESTIONS} "$question\n" or croak "$croak{'print'} SPAMQUESTIONS";
fclose(SPAMQUESTIONS);
if ( $action eq 'spam_questions_edit2' ) {
$yySetLocation = qq~$adminurl?action=spam_questions;questions_language=$FORM{'questions_language'}~;
redirectexit();
}
return;
}
sub SpamQuestionsDelete {
is_admin_or_gmod();
fopen( SPAMQUESTIONS, "<$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
@spam_questions = <SPAMQUESTIONS>;
fclose(SPAMQUESTIONS);
fopen( SPAMQUESTIONS, ">$langdir/$questions_language/spam.questions" )
|| fatal_error( 'cannot_open', "$langdir/$questions_language/spam.questions",
1 );
print {SPAMQUESTIONS}
grep { !/$FORM{'spam_question_id'}/xsm } @spam_questions
or croak "$croak{'print'} SPAMQUESTIONS";
fclose(SPAMQUESTIONS);
foreach my $spam_image (@spam_questions) {
chomp $spam_image;
if ( $spam_image =~ /$FORM{'spam_question_id'}/xsm ) {
$spam_image_delete = $spam_image;
last;
}
}
( undef, undef, undef, undef, $spam_image ) = split /\|/xsm,
$spam_image_delete;
if ( $spam_image ) {
unlink "$htmldir/Templates/Forum/default/$spam_image";
}
if ( $action eq 'spam_questions_delete' ) {
$yySetLocation = qq~$adminurl?action=spam_questions;questions_language=$FORM{'questions_language'}~;
redirectexit();
}
return;
}
1;

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

Sign up for the SourceForge newsletter:





No, thanks