###############################################################################
# Post.pl #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 3.0 Beta #
# Packaged: October 05, 2010 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
$postplver = 'YaBB 3.0 Beta $Revision: 350 $';
if ($action eq 'detailedversion') { return 1; }
&LoadLanguage('Post');
&LoadLanguage('Display');
&LoadLanguage('FA');
&LoadLanguage('UserSelect');
require "$sourcedir/Notify.pl";
require "$sourcedir/SpamCheck.pl";
use utf8; # this file contains UTF-8 characters
if ($iamguest && $gpvalid_en && ($enable_guestposting || $PMenableGuestButton|| $PMAlertButtonGuests)) {
require "$sourcedir/Decoder.pl";
}
$set_subjectMaxLength ||= 50;
&LoadCensorList;
sub Post {
if ($iamguest && $enable_guestposting == 0) { &fatal_error("not_logged_in"); }
if (!$staff && $speedpostdetection && ${$uid.$username}{'spamcount'} >= $post_speed_count) {
$detention_time = ${$uid.$username}{'spamtime'} + $spd_detention_time;
if($date <= $detention_time){
$detention_left = $detention_time - $date;
&fatal_error("speedpostban");
} else {
${$uid.$username}{'spamcount'} = 0;
&UserAccount($username,"update");
}
}
if ($currentboard eq '' && !$iamguest) { &fatal_error("no_access"); }
my ($filetype_info, $filesize_info);
my ($subtitle, $x, $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msubject, $mreplyno, $mip, $mmessage, $mns);
my $quotemsg = $INFO{'quote'};
$threadid = $INFO{'num'};
($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);
## only if bypass switched on
if ($mstate =~ /l/i) { &fatal_error('topic_locked') unless ($bypass_lock_perm && &checkUserLockBypass) }
#if ($mstate =~ /a/i && !$iamadmin && !$iamgmod) { &fatal_error('no_access'); }
# Determine category
$curcat = ${$uid.$currentboard}{'cat'};
&BoardTotals("load", $currentboard);
# Figure out the name of the category
&get_forum_master;
($cat, $catperms) = split(/\|/, $catinfo{$curcat});
&ToChars($cat);
$pollthread = 0;
$postthread = 0;
$INFO{'title'} =~ tr/+/ /;
if ($INFO{'title'} eq 'CreatePoll') { $pollthread = 1; $t_title = $post_polltxt{'1a'}; }
elsif ($INFO{'title'} eq 'AddPoll') { $pollthread = 2; $t_title = $post_polltxt{'2a'}; }
elsif ($INFO{'title'} eq 'PostReply') { $postthread = 2; $t_title = $display_txt{'116'}; }
else { $postthread = 1; $t_title = $post_txt{'33'}; }
if ($FORM{'title'} eq 'PostReply') { $postthread = 2;}
if ($pollthread == 2 && $useraddpoll == 0) { &fatal_error("no_access"); }
$name_field = $iamguest ? qq~
$post_txt{'68'}:
~
: qq~~;
$email_field = $iamguest ? qq~
$post_txt{'69'}:
~
: qq~~;
if ($iamguest && $gpvalid_en) {
&validation_code;
$verification_field = $verification eq ''
? qq~
$floodtxt{'1'}:
$showcheck$floodtxt{'casewarning'}
$floodtxt{'3'}:
~
: qq~~;
}
$sub = '';
$settofield = 'subject';
if ($threadid ne '') {
unless (ref($thread_arrayref{$threadid})) {
@{$thread_arrayref{$threadid}} = &read_DBorFILE(0,'',$datadir,$threadid,'txt');
}
if ($quotemsg ne '') {
($msubject, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[$quotemsg]);
$message = $mmessage;
$message =~ s~~\n~ig;
$message =~ s/ \ \ \ /\t/ig;
if (!$nestedquotes) {
$message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\]\n{0,1}~\n~isg;
}
$mname ||= $musername || $post_txt{'470'};
my $hidename = $musername;
$hidename = $mname if $musername eq 'Guest';
$hidename = &cloak($hidename) if $do_scramble_id;
$usernames_life_quote{$hidename} = $mname; # for display names in Quotes in LivePreview
my $maxlengthofquote = $MaxMessLen - length(qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~) - 3;
my $mess_len = $message;
&ToChars($mess_len);
$mess_len =~ s/[\r\n ]//ig;
$mess_len =~ s/\d{3,}?\;/X/ig;
if (length $mess_len >= $maxlengthofquote) {
&LoadLanguage('Error');
&alertbox($error_txt{'quote_too_long'});
$message = substr($message, 0, $maxlengthofquote) . '...';
}
undef $mess_len;
$message = qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;
if ($mns eq 'NS') { $nscheck = qq~ checked="checked"~; }
} else {
($msubject, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[0]);
}
$msubject =~ s/\bre:\s+//ig;
$sub = "Re: $msubject";
$settofield = 'message';
}
if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {
if ($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }
}
$submittxt = "$post_txt{'105'}";
$destination = "post2";
$icon = "xx";
$is_preview = 0;
$post = "post";
$prevmain = "";
$preview = "preview";
$yytitle = "$t_title" unless $Quick_Post;
&Postpage;
&doshowthread unless $Quick_Post;
if (%usernames_life_quote) { # for display names in Quotes in LivePreview
$yymain .= qq~
\n~;
}
&template;
}
## post message page
sub Postpage {
my $extra;
my ($filetype_info, $filesize_info, $extensions);
$extensions = join(" ", @ext);
$filetype_info = $checkext == 1 ? qq~$fatxt{'2'} $extensions~ : qq~$fatxt{'2'} $fatxt{'4'}~;
$filesize_info = $limit != 0 ? qq~$fatxt{'3'} $limit KB~ : qq~$fatxt{'3'} $fatxt{'5'}~;
$normalquot = $post_txt{'599'};
$simpelquot = $post_txt{'601'};
$simpelcode = $post_txt{'602'};
$edittext = $post_txt{'603'};
if (!$fontsizemax) { $fontsizemax = 72; }
if (!$fontsizemin) { $fontsizemin = 6; }
if ($postid eq 'Poll') { $sub = "$post_txt{'66a'}"; }
$message =~ s~<\/~\<\;/~isg;
&ToChars($message);
$message = &Censor($message);
&ToChars($sub);
$sub = &Censor($sub);
if ($action eq "modify" || $action eq "modify2") {
$displayname = qq~$mename~;
} else {
$displayname = ${$uid.$username}{'realname'};
}
require "$sourcedir/ContextHelp.pl";
&ContextScript("post");
$yymain .= $ctmain;
# this defines what the top area of the post box will look like: option 1 ) IM area
# option 2) all other post areas
# im stuff now separate
if ($postid ne 'Poll' && $destination ne 'modalert2' && $destination ne 'guestpm2') {
$extra = qq~
$post_txt{'71'}:
$post_txt{'281'}
$post_txt{'282'}
$post_txt{'283'}
$post_txt{'284'}
$post_txt{'285'}
$post_txt{'286'}
$post_txt{'287'}
$post_txt{'288'}
$post_txt{'289'}
$post_txt{'290'}
$post_txt{'291'}
$post_txt{'292'}
~;
if ($iamguest && $threadid ne '') { $settofield = "name"; }
}
if ($pollthread && $iamguest) { $guest_vote = 1; }
if ($pollthread == 2) { $settofield = "question"; }
# this defines if the notify on reply is shown or not.
if ($iamguest || $destination eq "modalert2" || $destination eq "guestpm2") {
$notification = '';
} else {
# check if you are already being notified and if so we check the checkbox.
# if the mail file exists then we have to check it otherwise we continue on
my $notify = "";
my $hasnotify = 0;
$notifytext = qq~$post_txt{'750'}~;
if (!$FORM{'notify'} && !exists $FORM{'hasnotify'}) {
&ManageThreadNotify("load", $threadid);
if (exists $thethread{$username}) {
$notify = qq~ checked="checked"~;
$hasnotify = 1;
}
undef %thethread;
&ManageBoardNotify("load", $currentboard);
if (exists $theboard{$username} && (split(/\|/, $theboard{$username}))[1] == 2) {
$notify = qq~ disabled="disabled" checked="checked"~;
$hasnotify = 2;
$notifytext = qq~$post_txt{'132'}~;
}
undef %theboard;
} else {
$notify = qq~ checked="checked"~ if $FORM{'notify'} eq 'x';
$hasnotify = $FORM{'hasnotify'};
if ($hasnotify == 2) {
$notify = qq~ disabled="disabled" checked="checked"~;
$notifytext = qq~$post_txt{'132'}~;
}
}
if ($postid ne 'Poll') {
$notification = qq~
$post_txt{'131'}:
$notifytext
~;
}
}
#add to favorites checkbox code
$favoriteadd = '';
if (!$iamguest && $currentboard ne $annboard && $destination ne 'modalert2') {
$favoritetext = $post_txt{'notfav'};
require "$sourcedir/Favorites.pl";
$nofav = &IsFav($threadid, '', 1);
if ($FORM{'favorite'}) {
$favorite = qq~ checked="checked"~;
}
if (!$nofav) {
$favorite = qq~ disabled="disabled" checked="checked"~;
$favoritetext = $post_txt{'alreadyfav'};
$hasfavorite = 1;
} elsif ($nofav == 2){
$favorite = qq~ disabled="disabled"~;
$favoritetext = $post_txt{'maximumfav'};
}
$favoriteadd = qq~
$post_txt{'favorite'}:
$favoritetext
~;
}
if (!$sub) { $subtitle = "$post_txt{'33'} "; }
else { $subtitle = "$sub "; }
# this is shown every post page except the IM area.
if ($destination ne 'modalert2' && $destination ne 'guestpm2' && !$Quick_Post) {
if ($threadid) {
$threadlink = qq~$subtitle ~;
} else {
$threadlink = "$subtitle";
}
&ToChars($boardname);
&ToChars($cat);
$yynavigation = qq~› $cat › $boardname › $t_title ( $threadlink )~;
} elsif (!$Quick_Post) {
$yynavigation = qq~› $t_title~;
}
#this is the end of the upper area of the post page.
$yymain .= qq~
~;
# if this is an IM from the admin or to groups declare where it goes.
if ($INFO{'adminim'} || $INFO{'action'} eq "imgroups") {
$yymain .= qq~
~;
if ($speedpostdetection){
$yymain .= qq~
~;
}
if($postid ne 'Poll') {
$yymain .= qq~
~;
}
if ($postid ne 'Poll' && $post ne 'imsend' && $staff) {
$yymain .= qq~
~;
}
if ($action eq "modify" || $action eq "modify2") {
$displayname = qq~$mename~;
} else {
$displayname = ${$uid.$username}{'realname'};
}
require "$templatesdir/$usedisplay/Display.template";
foreach (@months) { $jsmonths .= qq~'$_',~; }
$jsmonths =~ s~\,\Z~~;
$jstimeselected = ${$uid.$username}{'timeselect'} || $timeselected;
if($postid ne 'Poll') {
$yymain .= qq~
~;
}
if ($INFO{'popup'}) {
&print_output_header;
$output = qq~
$yyinlinestyle
$yymain
~;
$output =~ s~~ ~g;
&print_HTML_output_and_finish;
}
}
## preview message
sub Preview {
my $error = $_[0];
&ToHTML($error);
# allows the following HTML-tags in error messages:
$error =~ s/<br( \/)>/ /ig;
$error =~ s/<(\/?)b>/<$1b>/ig;
$maxpq ||= 60;
$maxpo ||= 50;
$maxpc ||= 0;
$numpolloptions ||= 8;
$vote_limit ||= 0;
$pie_radius ||= 100;
for (my $i = 1; $i <= $numpolloptions; $i++) {
$options[$i] = $FORM{"option$i"};
&FromChars($options[$i]);
$convertstr = $options[$i];
$convertcut = $maxpo;
&CountChars;
$options[$i] = $convertstr;
&ToHTML($options[$i]);
&ToChars($options[$i]);
$slicecolor[$i] = $FORM{"slicecol$i"};
$split[$i] = $FORM{"split$i"};
}
$guest_vote = $FORM{'guest_vote'};
$hide_results = $FORM{'hide_results'};
$multi_choice = $FORM{'multi_choice'};
$poll_comment = $FORM{'poll_comment'};
$vote_limit = $FORM{'vote_limit'};
$pie_legends = $FORM{'pie_legends'};
$pie_radius = $FORM{'pie_radius'};
$poll_end_days = $FORM{'poll_end_days'};
$poll_end_min = $FORM{'poll_end_min'};
$poll_end_days = '' if !$poll_end_days || $poll_end_days =~ /\D/;
$poll_end_min = '' if !$poll_end_min || $poll_end_min =~ /\D/;
if ($pie_radius =~ /\D/) { $pie_radius = 100; }
if ($pie_radius < 100) { $pie_radius = 100; }
if ($pie_radius > 200) { $pie_radius = 200; }
$pollthread = $FORM{'pollthread'} || 0;
$poll_question = $FORM{'question'};
&FromChars($poll_question);
$convertstr = $poll_question;
$convertcut = $maxpq;
&CountChars;
$poll_question = $convertstr;
&ToHTML($poll_question);
&ToChars($poll_question);
&FromChars($poll_comment);
$convertstr = $poll_comment;
$convertcut = $maxpc;
&CountChars;
$poll_comment = $convertstr;
&ToHTML($poll_comment);
&ToChars($poll_comment);
$name = $FORM{'name'};
$email = $FORM{'email'};
$sub = $FORM{'subject'};
$FORM{'message'} =~ s~\r~~g;
$message = $FORM{'message'};
$icon = $FORM{'icon'};
$ns = $FORM{'ns'};
$threadid = $FORM{'threadid'};
$postid = $FORM{'postid'};
$thestatus = $FORM{'topicstatus'};
$isBMess = $FORM{'isBMess'};
if (!$iamguest && ${$uid.$username}{'postlayout'} ne qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~) {
${$uid.$username}{'postlayout'} = qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~;
&UserAccount($username, "update");
}
$postthread = 2 if $threadid;
$sub =~ s/[\r\n]//g;
my $testsub = $sub;
$testsub =~ s/ |\ //g;
if ($sub && !$testsub && $pollthread != 2) { $error = $post_txt{'77'}; }
&FromChars($sub);
$convertstr = $sub;
$convertcut = $set_subjectMaxLength + ($sub =~ /^Re: / ? 4 : 0);
&CountChars;
$sub = $convertstr;
&ToHTML($sub);
$csubject = $sub;
&ToChars($csubject);
$csubject = &Censor($csubject);
my $testmessage = $message;
$testmessage =~ s/[\r\n\ ]//g;
$testmessage =~ s/\ //g;
$testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testmessage =~ s/\[.*?\]//g;
if ($testmessage eq "" && $message ne "" && $pollthread != 2) { fatal_error("useless_post","$testmessage"); }
&FromChars($message);
&ToHTML($message);
my $mess = $message;
$message =~ s/\cM//g;
$message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;
$message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;
$message =~ s/\t/ \ \ \ /g;
$message =~ s/\n/ /g;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;
&CheckIcon;
if ($icon eq "xx") { $ic1 = " selected=\"selected\" "; }
elsif ($icon eq "thumbup") { $ic2 = " selected=\"selected\" "; }
elsif ($icon eq "thumbdown") { $ic3 = " selected=\"selected\" "; }
elsif ($icon eq "exclamation") { $ic4 = " selected=\"selected\" "; }
elsif ($icon eq "no_postcount") { $ic4 = " selected=\"selected\" "; }
elsif ($icon eq "question") { $ic5 = " selected=\"selected\" "; }
elsif ($icon eq "lamp") { $ic6 = " selected=\"selected\" "; }
elsif ($icon eq "smiley") { $ic7 = " selected=\"selected\" "; }
elsif ($icon eq "angry") { $ic8 = " selected=\"selected\" "; }
elsif ($icon eq "cheesy") { $ic9 = " selected=\"selected\" "; }
elsif ($icon eq "grin") { $ic10 = " selected=\"selected\" "; }
elsif ($icon eq "sad") { $ic11 = " selected=\"selected\" "; }
elsif ($icon eq "wink") { $ic12 = " selected=\"selected\" "; }
if ($FORM{'status'} eq 'c') { $icon = 'confidential'; }
elsif ($FORM{'status'} eq 'u') { $icon = 'urgent'; }
elsif ($FORM{'status'} eq 's') { $icon = 'standard'; }
$name_field = $iamguest ? qq~
$post_txt{'68'}:
~
: qq~~;
$email_field = $iamguest ? qq~
$post_txt{'69'}:
~
: qq~~;
if ($iamguest && $gpvalid_en) {
$usename = substr($date,1,length($date)-4);
$sesname = substr($date,0,length($date)-4);
$verification = $FORM{'verification'};
$sessionid = $FORM{'sessionid'};
$verification_field = $verification ne ''
? qq~
$floodtxt{'3'}:
$verification
~
: '';
}
if ($FORM{'ns'} eq 'NS') { $nscheck = qq~ checked="checked"~; }
if ($FORM{'iecopy'}) { $iecopycheck = qq~ checked="checked"~; }
if ($iamguest) {
$name .= "($post_txt{'772'})";
}
if ($action eq 'modify2') {
$displayname = $FORM{'mename'};
} else {
$displayname = ${$uid.$username}{'realname'};
}
&wrap;
($message, undef) = &Split_Splice_Move($message,$threadid);
if ($enable_ubbc) {
if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }
&DoUBBC;
}
&wrap2;
if ($FORM{'previewmodify'} || $FORM{'postmodify'}) {
$submittxt = $post_txt{'10'};
$is_preview = 1;
$post = 'postmodify';
$preview = 'previewmodify';
$destination = 'modify2';
} elsif (!$FORM{'previewim'} && $INFO{'action'} ne 'modalert2' && $INFO{'action'} ne 'guestpm2') {
$destination = 'post2';
$submittxt = $post_txt{'105'};
$is_preview = 1;
$post = 'post';
$preview = 'preview';
}
if ($INFO{'action'} eq 'imgroups') { $destination = 'imgroups'; }
if ($INFO{'action'} eq 'modalert2') {
$t_title = $post_txt{'alertmod'};
$destination = 'modalert2';
$submittxt = $post_txt{'148'};
$is_preview = 1;
$post = 'modalert';
$preview = 'preview';
$yytitle = $post_txt{'alertmod'};
}
if ($INFO{'action'} eq 'guestpm2') {
$t_title = $post_txt{'sendmessguest'};
$destination = 'guestpm2';
$submittxt = $post_txt{'148'};
$is_preview = 1;
$post = 'guestpm';
$preview = 'preview';
$yytitle = $post_txt{'sendmessguest'};
}
require "$templatesdir/$usedisplay/Display.template";
&ToChars($message);
$message = &Censor($message);
$prevmain .= qq~
$csubject
\n~;
if ($error) {
&LoadLanguage('Error');
$prevmain .= qq~
$error_txt{'error_occurred'}
\n~;
}
$message = $mess;
if ($error) { $csubject = $error; }
if ($img_greybox) {
$yyinlinestyle .= qq~ \n~;
$yyjavascript .= qq~
var GB_ROOT_DIR = "$yyhtml_root/greybox/";
// -->
\n~;
}
&template;
}
}
sub Post2 {
if ($iamguest && $enable_guestposting == 0) { &fatal_error("not_logged_in"); }
#if ($currentboard eq $annboard && !$iamadmin && !$iamgmod) { &fatal_error('not_allowed'); }
if (!$staff && $speedpostdetection && ${$uid.$username}{'spamcount'} >= $post_speed_count) {
$detention_time = ${$uid.$username}{'spamtime'} + $spd_detention_time;
if($date <= $detention_time){
$detention_left = $detention_time - $date;
&fatal_error("speedpostban");
} else {
${$uid.$username}{'spamcount'} = 0;
&UserAccount($username,"update");
}
}
if ($iamguest && $gpvalid_en) {
&validation_check($FORM{'verification'});
}
my ($email, $ns, $notify, $hasnotify, $i, $membername, $testname, @reserve, @reservecfg, $matchword, $matchcase, $matchuser, $matchname, $namecheck, $reserved, $reservecheck, $mnum, $msub, $mname, $memail, $mdate, $musername, $micon, $mstate, $pageindex, $tempname);
&BoardTotals("load", $currentboard);
# If poster is a Guest then evaluate the legality of name and email
if (!${$uid.$username}{'email'}) {
$FORM{'name'} =~ s/\A\s+//;
$FORM{'name'} =~ s/\s+\Z//;
&Preview($post_txt{'75'}) unless ($FORM{'name'} ne '' && $FORM{'name'} ne '_' && $FORM{'name'} ne ' ');
&Preview($post_txt{'568'}) if (length($FORM{'name'}) > 25);
&Preview("$post_txt{'76'}") if ($FORM{'email'} eq '');
&Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($FORM{'email'} !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);
&Preview("$post_txt{'500'}") if (($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($FORM{'email'} !~ /^.+@\[?(\w|[-.])+\.([a-zA-Z]{2,4}|[0-9]{1,4})\]?$/));
}
# Get the form values
$name = $FORM{'name'};
$email = $FORM{'email'};
$subject = $FORM{'subject'};
$message = $FORM{'message'};
$icon = $FORM{'icon'};
$ns = $FORM{'ns'};
$ann = $FORM{'ann'};
$threadid = $FORM{'threadid'};
if ($threadid =~ /\D/) { &fatal_error("only_numbers_allowed"); }
$pollthread = $FORM{'pollthread'} || 0;
$posttime = $FORM{'post_entry_time'};
$notify = $FORM{'notify'};
$hasnotify = $FORM{'hasnotify'};
$favorite = $FORM{'favorite'};
$thestatus = $FORM{'topicstatus'};
$thestatus =~ s/\, //g;
chomp $thestatus;
# Check if poster isn't using a distilled email domain
&email_domain_check($email);
my $spamdetected = &spamcheck("$name $subject $message");
if (!${$uid.$FORM{$username}}{'spamcount'}) { ${$uid.$FORM{$username}}{'spamcount'} = 0; }
$postspeed = $date - $posttime;
if (!$staff){
if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {
${$uid.$username}{'spamcount'}++;
${$uid.$username}{'spamtime'} = $date;
&UserAccount($username,"update");
$spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};
if($spamdetected == 1){ &fatal_error("tsc_alert"); } else { &fatal_error("speed_alert"); }
}
}
# Permission checks for posting.
if (!$threadid) {
# Check for ability to post new threads
unless (&AccessCheck($currentboard, 1) eq 'granted' || $pollthread) { &fatal_error('no_perm_post'); }
} else {
# Check for ability to reply to threads
unless (&AccessCheck($currentboard, 2) eq 'granted' || $pollthread) { &fatal_error('no_perm_reply'); }
$postthread = 2;
}
if ($pollthread) {
# Check for ability to post polls
unless (&AccessCheck($currentboard, 3) eq 'granted') { &fatal_error('no_perm_poll'); }
}
for (my $y = 1; $y <= $allowattach; ++$y) {
if ($CGI_query && $CGI_query->upload("file$y")) {
# Check once for ability to post attachments
unless (&AccessCheck($currentboard, 4) eq 'granted') { &fatal_error('no_perm_att'); }
last;
}
}
# End Permission Checks
## clean name and email - remove | from name and turn any _ to spaces fro amil
if ($name && $email) {
&ToHTML($name);
$email =~ s/\|//g;
&ToHTML($email);
$tempname = $name;
$name =~ s/\_/ /g;
}
# Fixes a bug with posting hexed characters.
$name =~ s~amp;~~g;
&Preview($post_txt{'75'}) unless ($username || $name);
&Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);
&Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);
&Preview($post_txt{'78'}) unless ($message);
# Check Message Length Precisely
my $mess_len = $message;
$mess_len =~ s/[\r\n ]//ig;
$mess_len =~ s/\d{3,}?\;/X/ig;
if (length($mess_len) > $MaxMessLen) {
&Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});
}
undef $mess_len;
if ($FORM{'preview'}) { &Preview; }
&spam_protection;
$subject =~ s/[\r\n]//g;
my $testsub = $subject;
$testsub =~ s/ |\ //g;
if ($testsub eq "" && $pollthread != 2) { fatal_error("useless_post","$testsub"); }
my $testmessage = $message;
$testmessage =~ s/[\r\n\ ]//g;
$testmessage =~ s/\ //g;
$testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testmessage =~ s/\[.*?\]//g;
if ($testmessage eq "" && $message ne "" && $pollthread != 2) { fatal_error("useless_post","$testmessage"); }
if (!$minlinkpost){ $minlinkpost = 0 ;}
if (${$uid.$username}{'postcount'} < $minlinkpost && !$staff) {
if ($message =~ m~http:\/\/~ || $message =~ m~https:\/\/~ || $message =~ m~ftp:\/\/~ || $message =~ m~www.~ || $message =~ m~ftp.~ =~ m~\[url~ || $message=~ m~\[link~ || $message=~ m~\[img~ || $message=~ m~\[ftp~) {
&fatal_error("no_links_allowed");
}
}
&FromChars($subject);
$convertstr = $subject;
$convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);
&CountChars;
$subject = $convertstr;
&ToHTML($subject);
$doadsubject = $subject;
$message =~ s/\cM//g;
$message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;
$message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;
&FromChars($message);
&ToHTML($message);
$message =~ s~\t~ \ \ \ ~g;
$message =~ s~\n~ ~g;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;
&CheckIcon;
if (!$use_MySQL) { &delete_DBorFILE("$datadir/.txt"); }
if (!$iamguest) {
# If not guest, get name and email.
$name = ${$uid.$username}{'realname'};
$email = ${$uid.$username}{'email'};
} else {
# If user is Guest, then make sure the chosen name and email
# is not reserved or used by a member.
if (lc $name eq lc &MemberIndex("check_exist", $name)) { &fatal_error("guest_taken","($name)"); }
if (lc $email eq lc &MemberIndex("check_exist", $email)) { &fatal_error("guest_taken","($email)"); }
}
my @poll_data;
if ($pollthread) {
$maxpq ||= 60;
$maxpo ||= 50;
$maxpc ||= 0;
$numpolloptions ||= 8;
my $numcount = 0;
my $testspaces = $FORM{"question"};
$testspaces =~ s/[\r\n\ ]//g;
$testspaces =~ s/\ //g;
$testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testspaces =~ s/\[.*?\]//g;
if (length($testspaces) == 0 && length($FORM{"question"}) > 0) { fatal_error("useless_post","$testspaces"); }
&FromChars($FORM{'question'});
$convertstr = $FORM{'question'};
$convertcut = $maxpq;
&CountChars;
$FORM{'question'} = $convertstr;
if ($cliped) { &Preview("$post_polltxt{'40'} $post_polltxt{'34a'} $maxpq $post_polltxt{'34b'} $post_polltxt{'36'}"); }
unless ($FORM{"question"}) { &Preview("$post_polltxt{'37'}"); }
&ToHTML($FORM{'question'});
$guest_vote = $FORM{'guest_vote'} || 0;
$hide_results = $FORM{'hide_results'} || 0;
$multi_choice = $FORM{'multi_choice'} || 0;
$poll_comment = $FORM{'poll_comment'} || "";
$vote_limit = $FORM{'vote_limit'} || 0;
$pie_legends = $FORM{'pie_legends'} || 0;
$pie_radius = $FORM{'pie_radius'} || 100;
$poll_end_days = $FORM{'poll_end_days'};
$poll_end_min = $FORM{'poll_end_min'};
if ($pie_radius =~ /\D/) { $pie_radius = 100; }
if ($pie_radius < 100) { $pie_radius = 100; }
if ($pie_radius > 200) { $pie_radius = 200; }
if ($vote_limit =~ /\D/) { $vote_limit = 0; &Preview("$post_polltxt{'62'}"); }
&FromChars($poll_comment);
$convertstr = $poll_comment;
$convertcut = $maxpc;
&CountChars;
$poll_comment = $convertstr;
if ($cliped) { &Preview("$post_polltxt{'57'} $post_polltxt{'34a'} $maxpc $post_polltxt{'34b'} $post_polltxt{'36'}"); }
&ToHTML($poll_comment);
$poll_comment =~ s~\n~ ~g;
$poll_comment =~ s~\r~~g;
$poll_end_days = '' if !$poll_end_days || $poll_end_days =~ /\D/;
$poll_end_min = '' if !$poll_end_min || $poll_end_min =~ /\D/;
my $poll_end = $poll_end_days * 86400 if $poll_end_days;
$poll_end += $poll_end_min * 60 if $poll_end_min;
$poll_end += $date if $poll_end;
push(@poll_data, qq~$FORM{"question"}|0|$username|$name|$email|$date|$guest_vote|$hide_results|$multi_choice|||$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n~);
for ($i = 1; $i <= $numpolloptions; $i++) {
if ($FORM{"option$i"}) {
$FORM{"option$i"} =~ s/\ / /g;
my $testspaces = $FORM{"option$i"};
$testspaces =~ s/[\r\n\ ]//g;
$testspaces =~ s/\ //g;
$testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testspaces =~ s/\[.*?\]//g;
if (length($testspaces) == 0 && length($FORM{"option$i"}) > 0) { fatal_error("useless_post","$testspaces"); }
&FromChars($FORM{"option$i"});
$convertstr = $FORM{"option$i"};
$convertcut = $maxpo;
&CountChars;
$FORM{"option$i"} = $convertstr;
if ($cliped) { &Preview("$post_polltxt{'7'} $i $post_polltxt{'34a'} $maxpo $post_polltxt{'34b'} $post_polltxt{'36'}"); }
&ToHTML($FORM{"option$i"});
$numcount++;
$split[$i] = $FORM{"split$i"} ? 1 : 0;
push(@poll_data, qq~0|$FORM{"option$i"}|$FORM{"slicecol$i"}|$split[$i]\n~);
}
}
if ($numcount < 2) { &Preview("$post_polltxt{'38'}"); }
}
my ($file,$fixfile,@filelist,%filesizekb);
for (my $y = 1; $y <= $allowattach; ++$y) {
$file = $CGI_query->upload("file$y") if $CGI_query;
if ($file) {
$fixfile = $file;
$fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
if ($fixfile =~ /[^0-9A-Za-z\+\-\.:_]/) { # replace all inappropriate characters
# Transliteration
my @ISO_8859_1 = qw(A B V G D E JO ZH Z I J K L M N O P R S T U F H C CH SH SHH _ Y _ JE JU JA a b v g d e jo zh z i j k l m n o p r s t u f h c ch sh shh _ y _ je ju ja);
my $x = 0;
foreach (qw(À Á Â Ã Ä Å ¨ Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å ¸ æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ)) {
$fixfile =~ s/$_/$ISO_8859_1[$x]/ig;
$x++;
}
# END Transliteration. Thanks to "Velocity" for this contribution.
$fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/g;
}
# replace . with _ in the filename except for the extension
my $fixname = $fixfile;
$fixname =~ s/(.+)(\..+?)$/$1/;
my $fixext = $2;
my $spamdetected = &spamcheck("$fixname");
if (!$staff){
if ($spamdetected == 1) {
${$uid.$username}{'spamcount'}++;
${$uid.$username}{'spamtime'} = $date;
&UserAccount($username,"update");
$spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("tsc_alert");
}
}
$fixext =~ s/\.(pl|pm|cgi|php)/._$1/i;
$fixname =~ s/\.(?!tar$)/_/g;
$fixfile = qq~$fixname$fixext~;
if (!$overwrite) { $fixfile = &check_existence($uploaddir, $fixfile); }
elsif ($overwrite == 2 && &checkfor_DBorFILE("$uploaddir/$fixfile")) {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("file_overwrite");
}
my $match = 0;
if (!$checkext) { $match = 1; }
else {
foreach $ext (@ext) {
if (grep /$ext$/i, $fixfile) { $match = 1; last; }
}
}
if ($match) {
unless ($allowattach && (($allowguestattach == 0 && !$iamguest) || $allowguestattach == 1)) {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("no_perm_att");
}
} else {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&Preview("$fixfile $fatxt{'20'} @ext");
}
my ($size,$buffer,$filesize,$file_buffer);
while ($size = read($file, $buffer, 512)) { $filesize += $size; $file_buffer .= $buffer; }
if ($limit && $filesize > (1024 * $limit)) {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&Preview("$fatxt{'21'} $fixfile (" . int($filesize / 1024) . " KB) $fatxt{'21b'} " . $limit);
}
if ($dirlimit) {
my $dirsize = &dirsize($uploaddir);
if ($filesize > ((1024 * $dirlimit) - $dirsize)) {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&Preview("$fatxt{'22'} $fixfile (" . (int($filesize / 1024) - $dirlimit + int($dirsize / 1024)) . " KB) $fatxt{'22b'}");
}
}
# create a new file on the server using the formatted ( new instance ) filename
if (fopen(NEWFILE, ">$uploaddir/$fixfile")) {
binmode NEWFILE; # needed for operating systems (OS) Windows, ignored by Linux
print NEWFILE $file_buffer; # write new file on HD
fclose(NEWFILE);
} else { # return the server's error message if the new file could not be created
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("file_not_open","$uploaddir");
}
# check if file has actually been uploaded, by checking the file has a size
$filesizekb{$fixfile} = -s "$uploaddir/$fixfile";
unless ($filesizekb{$fixfile}) {
foreach (qw("@filelist" $fixfile)) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("file_not_uploaded",$fixfile);
}
$filesizekb{$fixfile} = int($filesizekb{$fixfile} / 1024);
if ($fixfile =~ /\.(jpg|gif|png|jpeg)$/i) {
my $okatt = 1;
if ($fixfile =~ /gif$/i) {
my $header;
fopen(ATTFILE, "$uploaddir/$fixfile");
binmode ATTFILE;
read(ATTFILE, $header, 10);
my $giftest;
($giftest, undef, undef, undef, undef, undef) = unpack("a3a3C4", $header);
fclose(ATTFILE);
if ($giftest ne "GIF") { $okatt = 0; }
}
fopen(ATTFILE, "$uploaddir/$fixfile");
binmode ATTFILE;
while ( read(ATTFILE, $buffer, 1024) ) {
if ($buffer =~ /<(html|script|body)/ig) { $okatt = 0; last; }
}
fclose(ATTFILE);
if(!$okatt) { # delete the file as it contains illegal code
foreach (qw("@filelist" $fixfile)) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error("file_not_uploaded","$fixfile <= illegal code inside image file!");
}
}
push(@filelist, $fixfile);
}
}
#Create the list of files
$fixfile = join(",", @filelist);
# make sure attachment filenames aren't too long
if (length("$fixfile") > 500) {
foreach (@filelist) { &delete_DBorFILE("$uploaddir/$_"); }
&fatal_error('filename_too_long', "$fixfile");
}
# If no thread specified, this is a new thread.
# Find a valid random ID for it.
if ($threadid eq '') {
$newthreadid = &getnewid;
} else {
$newthreadid = '';
}
# This is only for update, when comming from YaBB lower or equal version 2.2.3
# I think it can be deleted around version 2.4.0 without causing mayor issues (deti).
if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }
# End update workaround
# set announcement flag according to status of current board
if ($newthreadid) {
$mreplies = 0;
if ($iammod || $iamgmod || $iamadmin) { $mstate = $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus"; }
else { $mstate = "0"; }
# This is a new thread. Save it.
my @buffer = &read_DBorFILE(0,FILE,$boardsdir,$currentboard,'txt');
&write_DBorFILE(0,FILE,$boardsdir,$currentboard,'txt',(qq~$newthreadid|$subject|$name|$email|$date|$mreplies|$username|$icon|$mstate\n~,@buffer));
&write_DBorFILE(0,'',$datadir,$newthreadid,'txt',(qq~$subject|$name|$email|$date|$username|$icon|0|$user_ip|$message|$ns|||$fixfile\n~));
if (@filelist) {
my @temp = &read_DBorFILE(0,AMP,$vardir,'attachments','txt');
foreach $fixfile (@filelist) {
push(@temp, qq~$newthreadid|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~);
}
&write_DBorFILE(0,AMP,$vardir,'attachments','txt',@temp);
}
## write the ctb file for the new thread
${$newthreadid}{'board'} = $currentboard;
${$newthreadid}{'replies'} = 0;
${$newthreadid}{'views'} = 0;
${$newthreadid}{'lastposter'} = $iamguest ? "Guest-$name" : $username;
${$newthreadid}{'lastpostdate'} = $newthreadid;
${$newthreadid}{'threadstatus'} = $mstate;
&MessageTotals("update", $newthreadid);
if ($pollthread) { # Save Poll data of new thread AFTER ctb is created (for SQL)!!!
if (($iamadmin || $iamgmod) && $FORM{'scpoll'}) { # Save ShowcasePoll
&write_DBorFILE(1,'',$datadir,'poll','showcase',($newthreadid));
}
&write_DBorFILE(1,'',$datadir,$newthreadid,'poll',@poll_data);
}
if (($enable_notifications == 1 || $enable_notifications == 3) && &checkfor_DBorFILE("$boardsdir/$currentboard.mail")) {
&ToChars($subject);
$subject = &Censor($subject);
&NewNotify($newthreadid, $subject);
}
} else {
# This is an existing thread.
($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);
if ($mstate =~ /l/i) { # locked thread
unless (!$bypass_lock_perm || &checkUserLockBypass) { &fatal_error('topic_locked'); }
}
if ($staff) { $mstate = $currentboard eq $annboard ? "0a$thestatus" : "0$thestatus"; } # Leave the status as is if the user isn't allowed to change it
# ctb START
# Load the current .ctb info but don't close the file befor saving the changed data
# or you can get wrong .ctb files if two users save at the exact same moment.
# Therfore we can't use &MessageTotals("load", $threadid); her.
# File locking should be enabled in AdminCenter!
# Changes here on @tag must also be done in System.pl -> sub MessageTotals -> my @tag = ...
# and in Subs.pl in the SQL/File management block: my %db_table = (...
my @tag = qw(board replies views lastposter lastpostdate threadstatus repliers);
my $i = 0;
foreach (&read_DBorFILE(0,'UPDATE_CTB',$datadir,$threadid,'ctb')) {
if ($use_MySQL) { ${$threadid}{$tag[$i]} = $_; $i++; }
else { if ($_ =~ /^'(.*?)',"(.*?)"/) { ${$threadid}{$1} = $2; } }
}
${$threadid}{'mysql'} = ($use_MySQL && ${$threadid}{'lastpostdate'}) ? 1 : 0;
# Check if thread has moved. And do necessary access check
if (${$threadid}{'board'} ne $currentboard) {
if (&AccessCheck(${$threadid}{'board'}, 2) ne "granted") {
if ($use_MySQL) {
# no need to write back to DB
&mysql_process(0,'do',"UNLOCK TABLES");
} else {
@tag = map { qq~'$_',"${$threadid}{$_}"\n~ } @tag;
unshift(@tag, "### ThreadID: $threadid ###\n\n");
&write_DBorFILE(0,'UPDATE_CTB',$datadir,$threadid,'ctb',@tag);
}
&fatal_error("no_perm_reply");
}
# Thread has moved, but we can still post
# the current board is now the new board.
$currentboard = ${$threadid}{'board'};
}
# update the ctb file for the existing thread with number of replies and lastposter
${$threadid}{'board'} = $currentboard;
${$threadid}{'replies'}++;
${$threadid}{'lastposter'} = $iamguest ? "Guest-$name" : $username;
${$threadid}{'lastpostdate'} = $date;
${$threadid}{'threadstatus'} = $mstate;
if ($use_MySQL) {
@tag = map { ${$threadid}{$_} } @tag;
} else {
@tag = map { qq~'$_',"${$threadid}{$_}"\n~ } @tag;
unshift(@tag, "### ThreadID: $threadid ###\n\n");
}
&write_DBorFILE(${$threadid}{'mysql'},'UPDATE_CTB',$datadir,$threadid,'ctb',@tag);
# ctb END
$mreplies = ${$threadid}{'replies'};
if ($pollthread) { # Save new Poll data
if (($iamadmin || $iamgmod) && $FORM{'scpoll'}) { # Save ShowcasePoll
&write_DBorFILE(1,'',$datadir,'poll','showcase',($threadid));
}
&write_DBorFILE(1,'',$datadir,$threadid,'poll',@poll_data);
}
my @buffer = &read_DBorFILE(0,BOARDFILE,$boardsdir,$currentboard,'txt');
for ($i = 0; $i < @buffer; $i++) {
if ($buffer[$i] =~ m~\A$mnum\|~o) { $buffer[$i] = ""; last; }
}
&write_DBorFILE(0,BOARDFILE,$boardsdir,$currentboard,'txt',(qq~$mnum|$msub|$mname|$memail|$date|$mreplies|$musername|$micon|$mstate\n~,@buffer));
&write_DBorFILE(0,'',$datadir,$threadid,'txt',(@{$thread_arrayref{$threadid}},qq~$subject|$name|$email|$date|$username|$icon|~ . scalar(@{$thread_arrayref{$threadid}}) . qq~|$user_ip|$message|$ns|||$fixfile\n~));
if (@filelist) {
my @temp = &read_DBorFILE(0,AMP,$vardir,'attachments','txt');
foreach $fixfile (@filelist) {
push(@temp, qq~$mnum|$mreplies|$subject|$name|$currentboard|$filesizekb{$fixfile}|$date|$fixfile|0\n~);
}
&write_DBorFILE(0,AMP,$vardir,'attachments','txt',@temp);
}
&ToChars($subject);
$subject = &Censor($subject);
&ReplyNotify($threadid, $subject, $mreplies) if ($enable_notifications == 1 || $enable_notifications == 3);
} # end else
if (!$iamguest) {
${$uid.$username}{'postlayout'} = qq~$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}~;
# Increment post count and lastpost date for the member.
# Check whether zeropost board
if (!${$uid.$currentboard}{'zero'}) {
${$uid.$username}{'postcount'}++;
if (${$uid.$username}{'position'}) {
$grp_after = qq~${$uid.$username}{'position'}~;
} else {
foreach $postamount (sort { $b <=> $a } keys %Post) {
if (${$uid.$username}{'postcount'} >= $postamount) {
($title, undef) = split(/\|/, $Post{$postamount}, 2);
$grp_after = $title;
last;
}
}
}
&ManageMemberinfo("update", $username, '', '', '', $grp_after, ${$uid.$username}{'postcount'});
}
&UserAccount($username, "update", "lastpost+lastonline");
}
# The thread ID, regardless of whether it's a new thread or not.
$thread = $newthreadid || $threadid;
# Let's figure out what page number to show
$pageindex = int($mreplies / $maxmessagedisplay);
$start = $pageindex * $maxmessagedisplay;
${$uid.$currentboard}{'messagecount'}++;
unless ($FORM{'threadid'}) {
${$uid.$currentboard}{'threadcount'}++;
++$threadcount;
}
$myname = $iamguest ? qq~Guest-$name~ : $username;
${$uid.$currentboard}{'lastposttime'} = $date;
${$uid.$currentboard}{'lastposter'} = $myname;
${$uid.$currentboard}{'lastpostid'} = $thread;
${$uid.$currentboard}{'lastreply'} = $mreplies;
${$uid.$currentboard}{'lastsubject'} = $doadsubject;
${$uid.$currentboard}{'lasttopicstate'} = $mstate;
${$uid.$currentboard}{'lasticon'} = $icon;
&BoardTotals("update", $currentboard);
if(!$iamguest) { &Recent_Write("incr", $thread, $username, $date); }
if ($favorite && !$hasfavorite) {
require "$sourcedir/Favorites.pl";
&AddFav($thread, $mreplies, 1);
}
if ($notify && !$hasnotify) {
&ManageThreadNotify("add", $thread, $username, ${$uid.$username}{'language'}, 1, 1);
} elsif (!$notify && $hasnotify == 1) {
&ManageThreadNotify("delete", $thread, $username);
}
if ($currentboard eq $annboard) {
$yySetLocation = qq~$scripturl?virboard=$FORM{'virboard'};num=$thread/$start#$mreplies~;
} else {
$yySetLocation = qq~$scripturl?num=$thread/$start#$mreplies~;
}
&redirectexit;
}
# We load all the notification strings from a given language and store them in memory
sub LoadNotifyMessages {
my $languages = shift;
my $currentlang = $language;
${$languages}{$currentlang} = 1; # Load the current language too
foreach my $lang (keys %{$languages}) {
next if $notifystrings{$lang}{'boardnewtopicnotificationemail'}; # next if allready loaded
$language = $lang;
&LoadLanguage('Email');
$notifystrings{$lang} = {
'boardnewtopicnotificationemail' => $boardnewtopicnotificationemail,
'boardnotificationemail' => $boardnotificationemail,
'topicnotificationemail' => $topicnotificationemail,
};
&LoadLanguage('Notify');
$notifysubjects{$lang} = {
'118' => $notify_txt{'118'},
'136' => $notify_txt{'136'},
};
$notifycharset{$lang} = {
'emailcharset' => $emailcharset,
};
}
$language = $currentlang;
}
sub NewNotify {
my $thisthread = $_[0];
my $thissubject = $_[1];
my $boardname;
($boardname, undef) = split(/\|/, $board{$currentboard}, 2);
&ToChars($boardname);
$thissubject .= " ($boardname)";
$thissubject =~ s/<.*?>//g;
&FromHTML($thissubject);
require "$sourcedir/Mailer.pl";
&ManageMemberinfo("load");
&ManageBoardNotify("load", $currentboard);
my %languages;
foreach (keys %theboard) {
$languages{(split(/\|/, $theboard{$_}, 2))[0]} = 1;
}
&LoadNotifyMessages(\%languages);
while (my($curuser, $value) = each(%theboard)) {
my ($curlang, undef) = split(/\|/, $value, 2);
if ($curuser ne $username) {
&LoadUser($curuser);
if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {
(undef, undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 4);
&sendmail($curmail, "$notifysubjects{$curlang}{'136'}: $thissubject", &template_email($notifystrings{$curlang}{'boardnewtopicnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread}), '', $notifycharset{$curlang}{'emailcharset'});
}
undef %{$uid.$curuser};
}
}
undef %theboard;
undef %memberinf;
}
sub ReplyNotify {
my $thisthread = $_[0];
my $thissubject = $_[1];
my $page = qq~$_[2]#$_[2]~;
my $boardname;
($boardname, undef) = split(/\|/, $board{$currentboard}, 2);
&ToChars($boardname);
$thissubject .= " ($boardname)";
$thissubject =~ s/<.*?>//g;
&FromHTML($thissubject);
require "$sourcedir/Mailer.pl";
my %mailsent;
&ManageMemberinfo("load");
if (&checkfor_DBorFILE("$boardsdir/$currentboard.mail")) {
&ManageBoardNotify("load", $currentboard);
my %languages;
foreach (keys %theboard) {
$languages{(split(/\|/, $theboard{$_}, 2))[0]} = 1;
}
&LoadNotifyMessages(\%languages);
while (my($curuser, $value) = each(%theboard)) {
my($curlang, $notify_type, undef) = split(/\|/, $value);
if ($curuser ne $username && $notify_type == 2) {
&LoadUser($curuser);
if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {
(undef, undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 4);
&sendmail($curmail, "$notifysubjects{$curlang}{'136'}: $thissubject", &template_email($notifystrings{$curlang}{'boardnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread, 'start' => $page}), '', $notifycharset{$curlang}{'emailcharset'});
$mailsent{$curuser} = 1;
}
undef %{$uid.$curuser};
}
}
undef %theboard;
}
if (&checkfor_DBorFILE("$datadir/$thisthread.mail")) {
&ManageThreadNotify("load", $thisthread);
my %languages;
foreach (keys %thethread) {
$languages{(split(/\|/, $thethread{$_}, 2))[0]} = 1;
}
&LoadNotifyMessages(\%languages);
while (my($curuser, $value) = each(%thethread)) {
my($curlang, $notify_type, $hasviewed) = split(/\|/, $value);
if ($curuser ne $username && !exists $mailsent{$curuser} && $hasviewed) {
&LoadUser($curuser);
if (${$uid.$curuser}{'notify_me'} == 1 || ${$uid.$curuser}{'notify_me'} == 3) {
(undef, undef, $curmail, undef) = split(/\|/, $memberinf{$curuser}, 4);
&sendmail($curmail, "$notifysubjects{$curlang}{'118'}: $thissubject", &template_email($notifystrings{$curlang}{'topicnotificationemail'}, {'subject' => $thissubject, 'num' => $thisthread, 'start' => $page}), '', $notifycharset{$curlang}{'emailcharset'});
$thethread{$curuser} = qq~$curlang|$notify_type|0~;
}
undef %{$uid.$curuser};
}
}
&ManageThreadNotify("save", $thisthread);
}
undef %memberinf;
}
sub doshowthread {
my ($line, $tempname, $tempdate, $temppost,$amounter);
if ($INFO{'start'}) { $INFO{'start'} = "/$INFO{'start'}"; }
unless (ref($thread_arrayref{$threadid}) || !$threadid) {
@{$thread_arrayref{$threadid}} = &read_DBorFILE(0,'',$datadir,$threadid,'txt');
}
my @messages = @{$thread_arrayref{$threadid}};
if (@messages) {
if (@messages < $cutamount) { $cutamount = @messages; }
$yymain .= qq~
~;
$showall = $post_cutts{'3'};
if (@messages => $cutamount && $showpageall) {
$showall .= qq~ $post_cutts{'3a'} $post_cutts{'4'} $post_cutts{'5'} ~;
}
if ($INFO{'showall'} ne '' || $cutamount eq 'all') {
$origcutamount = $cutamount;
$cutamount = $pidtxt{'01'};
$showall = qq~$post_cutts{'3'} $post_cutts{'3a'} $post_cutts{'4'} $post_cutts{'6'} ~;
}
$yymain .= qq~
$post_txt{'468'} - $post_cutts{'2'} $cutamount $showall
~;
if ($tsreverse == 1) { @messages = reverse(@messages); }
if ($INFO{'showall'} ne '' || $cutamount eq "all") { $cutamount = 1000; }
for ($amounter = 0; $amounter < $cutamount; $amounter++) {
(undef, $temprname, undef, $tempdate, $tempname, undef, undef, undef, $message, $ns) = split(/\|/, $messages[$amounter]);
$messagedate = $tempdate;
$tempdate = &timeformat($tempdate);
$parseflash = 0;
if ($tempname ne 'Guest' && &checkfor_DBorFILE("$memberdir/$tempname.vars")) { &LoadUser($tempname); }
if (${$uid.$tempname}{'regtime'}) {
$registrationdate = ${$uid.$tempname}{'regtime'};
} else {
$registrationdate = int(time);
}
if (${$uid.$tempname}{'regdate'} && $messagedate > $registrationdate) {
$displaynamelink = qq~${$uid.$tempname}{'realname'} ~;
} elsif ($tempname !~ m~Guest~ && $messagedate < $registrationdate) {
$displaynamelink = qq~$tempname - $display_txt{'470a'}~;
} else {
$displaynamelink = $temprname;
}
$usernames_life_quote{$useraccount{$tempname}} = ${$uid.$tempname}{'realname'}; # for display names in Quotes in LivePreview
my $quickmessage = $message;
$quickmessage =~ s/<(br|p).*?>/\\r\\n/ig;
$quickmessage =~ s/'/\\'/g;
my $quote_mname = $useraccount{$tempname};
$quote_mname =~ s/'/\\'/g;
my $quote_msg_id = $tsreverse == 1 ? (@messages - $amounter -1) : $amounter;
&wrap;
($message, undef) = &Split_Splice_Move($message,$threadid);
if ($enable_ubbc) {
if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }
$displayname = ${$uid.$tempname}{'realname'};
&DoUBBC;
}
&wrap2;
&ToChars($message);
$message = &Censor($message);
unless ($message eq '') {
$yymain .= qq~
$post_txt{'279'}: $displaynamelink~ . ($enable_markquote ? qq~ $img{'mquote'} ~ : '') . (($enable_quickjump && length($quickmessage) <= $quick_quotelength) ? qq~$menusep$img{'quote'} ~ : '') . qq~
$post_txt{'280'}: $tempdate
$message
~;
}
}
$yymain .= "
\n";
} else {
$yymain .= "";
}
}
## Guest can send a PM to FA
## this is a hybrid broadcast message, with fixed audience of FA
## and some guest posting elements in, where id/email are required.
sub sendGuestPM {
if (!$iamguest) { $yySetLocation = $scripturl; &redirectexit; }
if (!$PMenableGuestButton) { &fatal_error('no_access'); }
if ($PMenableBm_level == 0) { &fatal_error('no_access'); }
$INFO{'title'} = 'PostReply';
$postthread = 2;
$name_field = qq~
$post_txt{'68'}:
~;
$email_field = qq~
$post_txt{'69'}:
~;
if ($gpvalid_en) {
&validation_code;
$verification_field = $verification eq ''
? qq~
$floodtxt{'1'}:
$showcheck$floodtxt{'casewarning'}
$floodtxt{'3'}:
~
: qq~~;
}
$sub = '';
$settofield = 'subject';
if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {
if ($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }
}
$t_title = $post_txt{'sendmessguest'};
$submittxt = $post_txt{'148'};
$destination = 'guestpm2';
$icon = 'exclamation';
$is_preview = 0;
$post = 'guestpm';
$prevmain = '';
$preview = 'preview';
$yytitle = $post_txt{'sendmessguest'};
&Postpage;
&template;
}
sub sendGuestPM2 {
if (!$iamguest) { $yySetLocation = $scripturl; &redirectexit; }
if (!$PMenableGuestButton) { &fatal_error('no_access'); }
if ($PMenableBm_level == 0) { &fatal_error('no_access'); }
if ($gpvalid_en) {
&validation_check($FORM{'verification'});
}
# Poster is a Guest then evaluate the legality of name and email
$FORM{'name'} =~ s/\A\s+//;
$FORM{'name'} =~ s/\s+\Z//;
&Preview($post_txt{'75'}) unless ($FORM{'name'} ne '' && $FORM{'name'} ne '_' && $FORM{'name'} ne ' ');
&Preview($post_txt{'568'}) if (length($FORM{'name'}) > 25);
&Preview($post_txt{'76'}) if ($FORM{'email'} eq '');
&Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($FORM{'email'} !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);
&Preview($post_txt{'500'}) if (($FORM{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($FORM{'email'} !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));
# Get the form values
$name = $FORM{'name'};
$email = $FORM{'email'};
$subject = $FORM{'subject'};
$message = $FORM{'message'};
$ns = $FORM{'ns'};
$threadid = $FORM{'threadid'};
$posttime = $FORM{'post_entry_time'};
if ($threadid =~ /\D/) { &fatal_error("only_numbers_allowed"); }
# Check if poster isn't using a distilled email domain
&email_domain_check($email);
my $spamdetected = &spamcheck("$name $subject $message");
${$uid.$username}{'spamcount'} = 0;
$postspeed = $date - $posttime;
if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {
${$uid.$username}{'spamcount'}++;
$spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};
if ($spamdetected == 1) { &fatal_error('tsc_alert'); } else { &fatal_error('speed_alert'); }
}
## clean name and email - remove | from name and turn any _ to spaces fro amil
if ($name && $email) {
&ToHTML($name);
$tempname = $name;
$name =~ s/\_/ /g;
$email =~ s/\|//g;
&ToHTML($email);
}
# Fixes a bug with posting hexed characters.
$name =~ s~amp;~~g;
&Preview($post_txt{'75'}) unless ($username || $name);
&Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);
&Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);
&Preview($post_txt{'78'}) unless ($message);
# Check Message Length Precisely
my $mess_len = $message;
$mess_len =~ s/[\r\n ]//ig;
$mess_len =~ s/\d{3,}?\;/X/ig;
if (length($mess_len) > $MaxMessLen) {
&Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});
}
undef $mess_len;
if ($FORM{'preview'}) { &Preview; }
&spam_protection;
my $testsub = $subject;
$testsub =~ s/[\r\n\ ]|\ //g;
if ($testsub eq '') { fatal_error('useless_post', $testsub); }
my $testmessage = $message;
$testmessage =~ s/[\r\n\ ]//g;
$testmessage =~ s/\ //g;
$testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testmessage =~ s/\[.*?\]//g;
if ($testmessage eq '' && $message ne '') { fatal_error('useless_post', $testmessage); }
$subject =~ s/[\r\n]//g;
&FromChars($subject);
$convertstr = $subject;
$convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);
&CountChars;
$subject = $convertstr;
&ToHTML($subject);
$message =~ s/\cM//g;
$message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;
$message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;
&FromChars($message);
&ToHTML($message);
$message =~ s~\t~ \ \ \ ~g;
$message =~ s~\n~ ~g;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;
&CheckIcon;
if (-e ("$datadir/.txt")) { &delete_DBorFILE("$datadir/.txt"); }
# User is Guest, then make sure the chosen name and email is not reserved or used by a member
if (lc $name eq lc &MemberIndex('check_exist', $name)) { &fatal_error('guest_taken', "($name)"); }
if (lc $email eq lc &MemberIndex('check_exist', $email)) { &fatal_error('guest_taken', "($email)"); }
# Find a valid random ID for it
$newthreadid = &getnewid;
# Encode spaces in name, to avoid confusing bm
$name =~ s/ /%20/g;
$mreplies = 0;
# set announcement flag according to status of current board
@bmessages = &read_DBorFILE(1,'',$memberdir,'broadcast','messages');
# new format: #messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|
# subject|date|message|(parentmid)|(reply#)|ip|
# messagestatus|flags|storefolder|attachment
&write_DBorFILE(0,'',$memberdir,'broadcast','messages',("$newthreadid|$name $email|admin|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|g|||\n",@bmessages));
undef @bmessages;
# The thread ID, regardless of whether it's a new thread or not
$thread = $newthreadid || $threadid;
$yySetLocation = $scripturl;
&redirectexit;
}
sub modAlert {
if ($iamguest && !$PMAlertButtonGuests) { &fatal_error('not_logged_in'); }
if (!$iamguest && !$PMenableAlertButton) { &fatal_error('no_access'); }
if ($currentboard eq '' && !$iamguest) { &fatal_error('no_access'); }
if (!$PM_level) { &fatal_error('no_access'); }
my $quotemsg = $INFO{'quote'};
$postid = $INFO{'quote'};
$threadid = $INFO{'num'};
my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine);
# Determine category
$curcat = ${$uid.$currentboard}{'cat'};
&BoardTotals("load", $currentboard);
# Figure out the name of the category
&get_forum_master;
($cat, $catperms) = split(/\|/, $catinfo{$curcat});
&ToChars($cat);
$INFO{'title'} =~ tr/+/ /;
$postthread = 2;
$name_field = $iamguest ? qq~
$post_txt{'68'}:
~ : '';
$email_field = $iamguest ? qq~
$post_txt{'69'}:
~ : '';
if ($iamguest && $gpvalid_en) {
&validation_code;
$verification_field = $verification eq '' ? qq~
$floodtxt{'1'}:
$showcheck$floodtxt{'casewarning'}
$floodtxt{'3'}:
~ : '';
}
$sub = '';
$settofield = 'subject';
if ($threadid ne '') {
unless (ref($thread_arrayref{$threadid})) {
@{$thread_arrayref{$threadid}} = &read_DBorFILE(0,'',$datadir,$threadid,'txt');
}
if ($quotemsg ne '') {
($msubject, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[$quotemsg]);
$message = $mmessage;
$message =~ s~~\n~ig;
$message =~ s/ \ \ \ /\t/ig;
if (!$nestedquotes) {
$message =~ s~\n{0,1}\[quote([^\]]*)\](.*?)\[/quote([^\]]*)\]\n{0,1}~\n~isg;
}
$mname ||= $musername || $post_txt{'470'};
my $hidename = $musername;
$hidename = $mname if $musername eq 'Guest';
$hidename = &cloak($hidename) if $do_scramble_id;
my $maxlengthofquote = $MaxMessLen - length(qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]\[/quote\]\n~) - 3;
if (length $message >= $maxlengthofquote) {
require "$sourcedir/System.pl";
&LoadLanguage('Error'); &alertbox($error_txt{'quote_too_long'});
$message = substr($message, 0, $maxlengthofquote) . '...';
}
$message = qq~[quote author=$hidename link=$threadid/$quotemsg#$quotemsg date=$mdate\]$message\[/quote\]\n~;
$msubject =~ s/\bre:\s+//ig;
if ($mns eq 'NS') { $nscheck = 'checked'; }
} else {
($msubject, $mname, $memail, $mdate, $musername, $micon, $mreplyno, $mip, $mmessage, $mns) = split(/\|/, ${$thread_arrayref{$threadid}}[0]);
$msubject =~ s/\bre:\s+//ig;
}
$sub = "Re: $msubject";
$settofield = 'message';
}
if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) {
if($2 >= 7.0) { $iecopycheck = ''; } else { $iecopycheck = qq~ checked="checked"~; }
}
$t_title = $post_txt{'alertmod'};
$submittxt = $post_txt{'148'};
$destination = 'modalert2';
$icon = 'exclamation';
$is_preview = 0;
$post = 'modalert';
$prevmain = '';
$preview = 'preview';
$yytitle = $post_txt{'alertmod'};
&Postpage;
&template;
}
sub modAlert2 {
if ($iamguest && !$PMAlertButtonGuests) { &fatal_error('not_logged_in'); }
if (!$iamguest && !$PMenableAlertButton) { &fatal_error('no_access'); }
if (!$PM_level) { &fatal_error('no_access'); }
if ($iamguest && $gpvalid_en) {
&validation_check($FORM{'verification'});
}
# Get the form values
$name = $FORM{'name'};
$email = $FORM{'email'};
$subject = $FORM{'subject'};
$message = $FORM{'message'};
$ns = $FORM{'ns'};
$threadid = $FORM{'threadid'};
$postid = $FORM{'postid'};
$posttime = $FORM{'post_entry_time'};
if ($threadid =~ /\D/) { &fatal_error('only_numbers_allowed'); }
if ($iamguest) {
$name =~ s/\A\s+//;
$name =~ s/\s+\Z//;
&Preview($post_txt{'75'}) unless ($name ne '' && $name ne '_' && $name ne ' ');
&Preview($post_txt{'568'}) if (length($name) > 25);
&Preview($post_txt{'76'}) if ($email eq '');
&Preview("$post_txt{'240'} $post_txt{'69'} $post_txt{'241'}") if ($email !~ /[\w\-\.\+]+\@[\w\-\.\+]+\.(\w{2,4}$)/);
&Preview($post_txt{'500'}) if (($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($email !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/));
## clean name and email - remove | from name and turn any _ to spaces fro amil
&ToHTML($name);
$tempname = $name;
$name =~ s/_/ /g;
$email =~ s/\|//g;
&ToHTML($email);
# Fixes a bug with posting hexed characters
$name =~ s~amp;~~g;
# If user is Guest, then make sure the chosen name and email is not reserved or used by a member
if (lc $name eq lc &MemberIndex('check_exist', $name)) { &fatal_error('guest_taken',"($name)"); }
if (lc $email eq lc &MemberIndex('check_exist', $email)) { &fatal_error('guest_taken',"($email)"); }
# Encode spaces in name, to avoid confusing!
$name =~ s/ /%20/g;
$name .= qq~ $email~;
} else {
$name = $username;
}
# Check if poster isn't using a distilled email domain
&email_domain_check($email);
my $spamdetected = &spamcheck("$name $subject $message");
if (!${$uid.$FORM{$username}}{'spamcount'}) { ${$uid.$FORM{$username}}{'spamcount'} = 0; }
$postspeed = $date - $posttime;
if (!$staff){
if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) {
${$uid.$username}{'spamcount'}++;
${$uid.$username}{'spamtime'} = $date;
&UserAccount($username,"update");
$spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};
if ($spamdetected == 1){ &fatal_error('tsc_alert'); } else { &fatal_error('speed_alert'); }
}
}
&Preview($post_txt{'75'}) unless ($username || $name);
&Preview($post_txt{'76'}) unless (${$uid.$username}{'email'} || $email);
&Preview($post_txt{'77'}) unless ($subject && $subject !~ m~\A[\s_.,]+\Z~);
&Preview($post_txt{'78'}) unless ($message);
# Check Message Length Precisely
my $mess_len = $message;
$mess_len =~ s/[\r\n ]//ig;
$mess_len =~ s/\d{3,}?\;/X/ig;
if (length($mess_len) > $MaxMessLen) {
&Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'});
}
undef $mess_len;
if ($FORM{'preview'}) { &Preview; }
&spam_protection;
$subject =~ s/[\r\n]//g;
my $tstsubject = $subject;
my $testsub = $subject;
$testsub =~ s/ |\ //g;
if ($testsub eq '') { fatal_error('useless_post', $testsub); }
my $testmessage = $message;
$testmessage =~ s/[\r\n\ ]//g;
$testmessage =~ s/\ //g;
$testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g;
$testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g;
$testmessage =~ s/\[.*?\]//g;
if ($testmessage eq '' && $message ne '') { fatal_error('useless_post', $testmessage); }
&FromChars($subject);
$convertstr = $subject;
$convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0);
&CountChars;
$subject = $convertstr;
&ToHTML($subject);
$message =~ s/\cM//g;
$message =~ s~\[([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[$1$2\]~g;
$message =~ s~\[/([^\]\[]{0,30})\n([^\]\[]{0,30})\]~\[/$1$2\]~g;
&FromChars($message);
&ToHTML($message);
$message =~ s~\t~ \ \ \ ~g;
$message =~ s~\n~ ~g;
$message =~ s/([\000-\x09\x0b\x0c\x0e-\x1f\x7f])/\x0d/g;
if (-e ("$datadir/.txt")) { &delete_DBorFILE("$datadir/.txt"); }
# Find a valid random ID for it
$newthreadid = &getnewid;
# This is only for update, when comming from YaBB lower or equal version 2.2.3
# I think it can be deleted around version 2.4.0 without causing mayor issues (deti).
if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }
# End update workaround
my $x;
my $mods = ${$uid.$currentboard}{'mods'};
my $modgrps = ${$uid.$currentboard}{'modgroups'};
$modgrps =~ s/, /,/g; # because modgroups are saved with ' ' and this MyCenter.pl does not understand ;-)
# If no BM is allowed and no mods is assigned => send the "AlertMod" to admin
if (!$PMenableBm_level && !$mods) {
$mods = $mods ? $mods : 'admin';
# If BM is allowed and no mods and no moderator group is assigned => send the "AlertMod" to admin and gmods via BM
} elsif ($PMenableBm_level && !$mods && !$modgrps) {
$modgrps = $PMenableBm_level == 3 ? "admins" : "admins,gmods";
}
# Check if there is at least one user in the moderator group
# if not and no mod is assigned too => send the "AlertMod" to admin via PM
if ($PMenableBm_level && $modgrps) {
if ($modgrps =~ /admins|gmods|mods/) { $x = 1; }
else {
&ManageMemberinfo("load");
manageinfo: foreach (keys %memberinf) {
map { if ($_ && $modgrps =~ /\b$_\b/) { $x = 1; last manageinfo; } } split(/,/, (split(/\|/, $memberinf{$_}, 7))[5]);
}
$mods = 'admin' if !$x && !$mods;
}
}
if ($mods) {
managemods: foreach my $toBoardMod (split(/, ?/, $mods)) {
chomp $toBoardMod;
# Send notification (Will only work if Admin has allowed the Email Notification)
&LoadUser($toBoardMod);
if (${$uid.$toBoardMod}{'notify_me'} > 1 && $enable_notifications > 1 && ${$uid.$toBoardMod}{'email'} ne '') {
require "$sourcedir/Mailer.pl";
$language = ${$uid.$toBoardMod}{'language'};
&LoadLanguage('Email');
&LoadLanguage('Notify');
&LoadLanguage('InstantMessage');
my $msubject = $tstsubject ? $tstsubject : $inmes_txt{'767'};
&ToChars($msubject);
my $chmessage = $message;
&ToChars($chmessage);
$chmessage =~ s~\[b\](.*?)\[/b\]~*$1*~isg;
$chmessage =~ s~\[i\](.*?)\[/i\]~/$1/~isg;
$chmessage =~ s~\[u\](.*?)\[/u\]~_$1_~isg;
$chmessage =~ s~\[.*?\]~~g;
$chmessage =~ s~~\n~ig;
$chmessage = &template_email($privatemessagenotificationemail, {'date' => &timeformat($date), 'subject' => $msubject, 'sender' => ${$uid.$username}{'realname'}, 'message' => $chmessage});
&sendmail(${$uid.$toBoardMod}{'email'}, $notify_txt{'145'}, $chmessage, '', $emailcharset);
} elsif ($PMenableBm_level && $x) {
&ManageMemberinfo("load");
map { if ($_ && $modgrps =~ /\b$_\b/) { next managemods; } } split(/,/, (split(/\|/, $memberinf{$toBoardMod}, 7))[5]);
}
# Send message to user
my @inmessages = &read_DBorFILE(0,'',$memberdir,$toBoardMod,'msg');
# new format: messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|
# subject|date|message|(parentmid)|(reply#)|ip|
# messagestatus|flags|storefolder|attachment
&write_DBorFILE(0,'',$memberdir,$toBoardMod,'msg',("$newthreadid|$name|$toBoardMod|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|a|u||\n", @inmessages));
}
}
if ($PMenableBm_level && $x) {
# set announcement flag according to status of current board
my @inmessages = &read_DBorFILE(0,'',$memberdir,'broadcast','messages');
# new format: #messageid|from user|touser(s)|(ccuser(s))|(bccuser(s))|
# subject|date|message|(parentmid)|(reply#)|ip|
# messagestatus|flags|storefolder|attachment
&write_DBorFILE(0,'',$memberdir,'broadcast','messages',("$newthreadid|$name|$modgrps|||$subject|$date|$message|$newthreadid|0|$ENV{'REMOTE_ADDR'}|ab|||\n",@inmessages));
}
$yySetLocation = qq~$scripturl?num=$threadid/$postid#$postid~;
&redirectexit;
}
1;