| ############################################################################### |
| ############################################################################### |
| # ModifyMessage.pl # |
| # ModifyMessage.pm # |
| |
| # $Date: 01.05.16 $ # |
| ############################################################################### |
| ############################################################################### |
| # YaBB: Yet another Bulletin Board # |
| # YaBB: Yet another Bulletin Board # |
| # Open-Source Community Software for Webmasters # |
| # Open-Source Community Software for Webmasters # |
| # Version: YaBB 2.5.2 # |
| # Version: YaBB 2.6.12 # |
| # Packaged: October 21, 2012 # |
| # Packaged: January 5, 2016 # |
| # Distributed by: http://www.yabbforum.com # |
| # Distributed by: http://www.yabbforum.com # |
| # =========================================================================== # |
| # =========================================================================== # |
| # Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved. # |
| # Software by: The YaBB Development Team # |
| # Software by: The YaBB Development Team # |
| # with assistance from the YaBB community. # |
| # with assistance from the YaBB community. # |
| ############################################################################### |
| ############################################################################### |
| |
| our $VERSION = '2.6.12'; |
| |
| use CGI::Carp qw(fatalsToBrowser); |
| |
| |
| $modifymessageplver = 'YaBB 2.5.2 $Revision: 1.1 $'; |
| $modifymessagepmver = 'YaBB 2.6.12 $Revision: 1710 $'; |
| if ($action eq 'detailedversion') { return 1; } |
| if ( $action eq 'detailedversion' ) { return 1; } |
| |
| |
| if (!$post_txt_loaded) { |
| if ( !$post_txt_loaded ) { |
| &LoadLanguage('Post'); |
| LoadLanguage('Post'); |
| $post_txt_loaded = 1; |
| $post_txt_loaded = 1; |
| } |
| } |
| &LoadLanguage('FA'); |
| LoadLanguage('FA'); |
| require "$sourcedir/SpamCheck.pl"; |
| LoadLanguage('Display'); |
| |
| |
| |
| get_micon(); |
| |
| get_template('Post'); |
| |
| |
| |
| require Sources::SpamCheck; |
| |
| if ( $iamadmin || $iamgmod ) { $MaxMessLen = $AdMaxMessLen; } |
| $set_subjectMaxLength ||= 50; |
| $set_subjectMaxLength ||= 50; |
| |
| |
| sub ModifyMessage { |
| sub ModifyMessage { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| if ($currentboard eq '') { &fatal_error("no_access"); } |
| if ( $currentboard eq q{} ) { fatal_error('no_access'); } |
| |
| |
| my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate, $msubject, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb); |
| my ( $mattach, $mip, $mmessage, $mns, $mlm, $mlmb ); |
| $threadid = $INFO{'thread'}; |
| $threadid = $INFO{'thread'}; |
| $postid = $INFO{'message'}; |
| $postid = $INFO{'message'}; |
| |
| |
| my ($filetype_info, $filesize_info, $extensions); |
| my ( $filetype_info, $filesize_info, $extensions ); |
| $extensions = join(" ", @ext); |
| $extensions = join q{ }, @ext; |
| $filetype_info = $checkext == 1 ? qq~$fatxt{'2'} $extensions~ : qq~$fatxt{'2'} $fatxt{'4'}~; |
| $filetype_info = |
| $filesize_info = $limit != 0 ? qq~$fatxt{'3'} $limit KB~ : qq~$fatxt{'3'} $fatxt{'5'}~; |
| $checkext == 1 |
| |
| ? qq~$fatxt{'2'} $extensions~ |
| ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $yyThreadLine); |
| : qq~$fatxt{'2'} $fatxt{'4'}~; |
| |
| $limit ||= 0; |
| $postthread = 2; |
| $filesize_info = |
| |
| $limit != 0 ? qq~$fatxt{'3'} $limit KB~ : qq~$fatxt{'3'} $fatxt{'5'}~; |
| if ($mstate =~ /l/i) { |
| |
| my $icanbypass = &checkUserLockBypass if $bypass_lock_perm; |
| my ( |
| if (!$icanbypass) { &fatal_error("topic_locked"); } |
| $mnum, $msub, $mname, $memail, $mdate, |
| } elsif (!$iamadmin && !$iamgmod && !$iammod && $tlnomodflag && $date > $mdate + ($tlnomodtime * 3600 * 24)) { |
| $mreplies, $musername, $micon, $mstate |
| &fatal_error("time_locked","$tlnomodtime$timelocktxt{'02'}"); |
| ) = split /\|/xsm, $yyThreadLine; |
| } |
| |
| if ($postid eq "Poll") { |
| $postthread = 2; |
| unless (-e "$datadir/$threadid.poll") { &fatal_error("not_allowed"); } |
| |
| |
| if ( $mstate =~ /l/ism ) { |
| fopen(FILE, "$datadir/$threadid.poll"); |
| if ($bypass_lock_perm) { $icanbypass = checkUserLockBypass(); } |
| my @poll_data = <FILE>; |
| if ( !$icanbypass ) { fatal_error('topic_locked'); } |
| fclose(FILE); |
| } |
| chomp(@poll_data); |
| elsif ( !$staff |
| ($poll_question, $poll_locked, $poll_uname, $poll_name, $poll_email, $poll_date, $guest_vote, $hide_results, $multi_choice, $poll_mod, $poll_modname, $poll_comment, $vote_limit, $pie_radius, $pie_legends, $poll_end) = split(/\|/, $poll_data[0]); |
| && $tlnomodflag |
| &ToChars($poll_question); |
| && $date > $mdate + ( $tlnomodtime * 3600 * 24 ) ) |
| &ToChars($poll_comment); |
| { |
| |
| fatal_error( 'time_locked', "$tlnomodtime$timelocktxt{'02'}" ); |
| for (my $i = 1; $i < @poll_data; $i++) { |
| } |
| ($votes[$i], $options[$i], $slicecolor[$i], $split[$i]) = split(/\|/, $poll_data[$i]); |
| if ( $postid eq 'Poll' ) { |
| &ToChars($options[$i]); |
| if ( !-e "$datadir/$threadid.poll" ) { fatal_error('not_allowed'); } |
| } |
| |
| |
| fopen( FILE, "$datadir/$threadid.poll" ); |
| unless ($poll_uname eq $username || $iammod || $iamadmin || $iamgmod) { &fatal_error("not_allowed"); } |
| my @poll_data = <FILE>; |
| |
| fclose(FILE); |
| $poll_comment =~ s~<br \/>~\n~g; |
| chomp @poll_data; |
| $poll_comment =~ s~<br>~\n~g; |
| ( |
| $pollthread = 2; |
| $poll_question, $poll_locked, $poll_uname, $poll_name, |
| $settofield = "question"; |
| $poll_email, $poll_date, $guest_vote, $hide_results, |
| $icon = 'poll_mod'; |
| $multi_choice, $poll_mod, $poll_modname, $poll_comment, |
| |
| $vote_limit, $pie_radius, $pie_legends, $poll_end |
| } else { |
| ) = split /\|/xsm, $poll_data[0]; |
| unless (ref($thread_arrayref{$threadid})) { |
| ToChars($poll_question); |
| fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1); |
| ToChars($poll_comment); |
| @{$thread_arrayref{$threadid}} = <FILE>; |
| |
| fclose(FILE); |
| for my $i ( 1 .. $#poll_data ) { |
| } |
| ( $votes[$i], $options[$i], $slicecolor[$i], $split[$i] ) = |
| ($sub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $mlm, $mlmb, $mfn) = split(/\|/, ${$thread_arrayref{$threadid}}[$postid]); |
| split /\|/xsm, $poll_data[$i]; |
| chomp $mfn; |
| ToChars( $options[$i] ); |
| |
| } |
| if ((${$uid.$username}{'regtime'} > $mdate || $musername ne $username) && !($iammod || $iamadmin || $iamgmod)) { |
| |
| &fatal_error("change_not_allowed"); |
| if ( $poll_uname ne $username && !$staff ) { |
| } |
| fatal_error('not_allowed'); |
| |
| } |
| $lastmod = $mlm ? &timeformat($mlm) : '-'; |
| |
| $nscheck = $mns ? ' checked' : ''; |
| $poll_comment =~ s/<br \/>/\n/gsm; |
| |
| $poll_comment =~ s/<br>/\n/gxsm; |
| $lastmod = qq~ |
| $pollthread = 2; |
| <tr> |
| $settofield = 'question'; |
| <td valign="top" width="23%"><span class="text1"><b>$post_txt{'211'}:</b></span></td> |
| $icon = 'poll_mod'; |
| <td><span class="text1">$lastmod</span></td> |
| |
| </tr> |
| } |
| ~; |
| else { |
| $icon = $micon; |
| if ( !ref $thread_arrayref{$threadid} ) { |
| if ($icon eq "xx") { $ic1 = " selected=\"selected\" "; } |
| fopen( FILE, "$datadir/$threadid.txt" ) |
| elsif ($icon eq "thumbup") { $ic2 = " selected=\"selected\" "; } |
| or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); |
| elsif ($icon eq "thumbdown") { $ic3 = " selected=\"selected\" "; } |
| @{ $thread_arrayref{$threadid} } = <FILE>; |
| elsif ($icon eq "exclamation") { $ic4 = " selected=\"selected\" "; } |
| fclose(FILE); |
| elsif ($icon eq "question") { $ic5 = " selected=\"selected\" "; } |
| } |
| elsif ($icon eq "lamp") { $ic6 = " selected=\"selected\" "; } |
| ( |
| elsif ($icon eq "smiley") { $ic7 = " selected=\"selected\" "; } |
| $sub, $mname, $memail, $mdate, $musername, |
| elsif ($icon eq "angry") { $ic8 = " selected=\"selected\" "; } |
| $micon, $mattach, $mip, $message, $mns, |
| elsif ($icon eq "cheesy") { $ic9 = " selected=\"selected\" "; } |
| $mlm, $mlmb, $mfn |
| elsif ($icon eq "grin") { $ic10 = " selected=\"selected\" "; } |
| ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[$postid]; |
| elsif ($icon eq "sad") { $ic11 = " selected=\"selected\" "; } |
| chomp $mfn; |
| elsif ($icon eq "wink") { $ic12 = " selected=\"selected\" "; } |
| |
| $message =~ s~<br \/>~\n~ig; |
| if ( |
| $message =~ s~<br>~\n~ig; |
| ( |
| $message =~ s/ \ \ \ /\t/ig; |
| ${ $uid . $username }{'regtime'} > $mdate |
| $settofield = "message"; |
| || $musername ne $username |
| } |
| ) |
| if ($ENV{'HTTP_USER_AGENT'} =~ /(MSIE) (\d)/) { |
| && !$staff |
| if($2 >= 7.0) { $iecopycheck = ""; } else { $iecopycheck = qq~checked="checked"~; } |
| ) |
| } |
| { |
| $submittxt = $post_txt{'10'}; |
| fatal_error('change_not_allowed'); |
| $destination = 'modify2'; |
| } |
| $is_preview = 0; |
| |
| $post = 'postmodify'; |
| $lastmod_a = $mlm ? timeformat($mlm) : q{-}; |
| $preview = 'previewmodify'; |
| $nscheck = $mns ? ' checked' : q{}; |
| require "$sourcedir/Post.pl"; |
| |
| $yytitle = $post_txt{'66'}; |
| $lastmod = $mypost_lastmod; |
| $mename = $mname; |
| $lastmod =~ s/{yabb lastmod_a}/$lastmod_a/sm; |
| &Postpage; |
| |
| &template; |
| $icon = $micon; |
| |
| $message =~ s/<br \/>/\n/igsm; |
| |
| $message =~ s/<br>/\n/igxsm; |
| |
| $message =~ s/ \ \ \ /\t/igsm; |
| |
| $settofield = 'message'; |
| |
| if ( $message =~ s/\[reason\](.+?)\[\/reason\]//isgm ) { $reason = $1; } |
| |
| } |
| |
| $submittxt = $post_txt{'10'}; |
| |
| $destination = 'modify2'; |
| |
| $post = 'postmodify'; |
| |
| require Sources::Post; |
| |
| $yytitle = $post_txt{'66'}; |
| |
| $mename = $mname; |
| |
| $thismusername = $musername; |
| |
| $tmpmdate = $mdate; |
| |
| Postpage(); |
| |
| template(); |
| |
| return; |
| } |
| } |
| |
| |
| sub ModifyMessage2 { |
| sub ModifyMessage2 { |
| if ($iamguest) { &fatal_error("members_only"); } |
| if ($iamguest) { fatal_error('members_only'); } |
| |
| |
| if ($FORM{'previewmodify'}) { |
| if ( $FORM{'previewmodify'} ) { |
| $mename = qq~$FORM{'mename'}~; |
| $mename = qq~$FORM{'mename'}~; |
| require "$sourcedir/Post.pl"; |
| $tmpmdate = qq~$FORM{'tmpmdate'}~; |
| &Preview; |
| $thismusername = qq~$FORM{'thismusername'}~; |
| } |
| require Sources::Post; |
| |
| Preview(); |
| # the post is to be deleted... |
| } |
| if ($INFO{'d'} == 1) { |
| |
| $threadid = $FORM{'thread'}; |
| # the post is to be deleted... |
| $postid = $FORM{'id'}; |
| if ( $INFO{'d'} == 1 ) { |
| |
| $threadid = $FORM{'thread'}; |
| if ($postid eq "Poll") { |
| $postid = $FORM{'id'}; |
| # showcase poll start |
| |
| # Look for a showcase.poll file to unlink. |
| if ( $postid eq 'Poll' ) { |
| if (-e "$datadir/showcase.poll") { |
| |
| fopen (FILE, "$datadir/showcase.poll"); |
| # showcase poll start |
| if ($threadid == <FILE>) { |
| # Look for a showcase.poll file to unlink. |
| fclose (FILE); |
| if ( -e "$datadir/showcase.poll" ) { |
| unlink ("$datadir/showcase.poll"); |
| fopen( FILE, "$datadir/showcase.poll" ); |
| } else { |
| if ( $threadid == <FILE> ) { |
| fclose (FILE); |
| fclose(FILE); |
| } |
| unlink "$datadir/showcase.poll"; |
| } |
| } |
| # showcase poll end |
| else { |
| unlink("$datadir/$threadid.poll"); |
| fclose(FILE); |
| unlink("$datadir/$threadid.polled"); |
| } |
| $yySetLocation = qq~$scripturl?num=$threadid~; |
| } |
| &redirectexit; |
| |
| |
| # showcase poll end |
| } else { |
| unlink "$datadir/$threadid.poll"; |
| unless (ref($thread_arrayref{$threadid})) { |
| unlink "$datadir/$threadid.polled"; |
| fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1); |
| $yySetLocation = qq~$scripturl?num=$threadid~; |
| @{$thread_arrayref{$threadid}} = <FILE>; |
| redirectexit(); |
| fclose(FILE); |
| } |
| } |
| else { |
| $msgcnt = @{$thread_arrayref{$threadid}}; |
| if ( !ref $thread_arrayref{$threadid} ) { |
| |
| fopen( FILE, "$datadir/$threadid.txt" ) |
| # Make sure the user is allowed to edit this post. |
| or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); |
| if ($postid >= 0 && $postid < $msgcnt) { |
| @{ $thread_arrayref{$threadid} } = <FILE>; |
| ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $mfn) = split(/\|/, ${$thread_arrayref{$threadid}}[$postid]); |
| fclose(FILE); |
| chomp $mfn; |
| } |
| if (${$uid.$username}{'regdate'} > $mdate || (!$iamadmin && !$iamgmod && !$iammod && $musername ne $username) || !$sessionvalid) { &fatal_error("delete_not_allowed"); } |
| $msgcnt = @{ $thread_arrayref{$threadid} }; |
| if (!$iamadmin && !$iamgmod && !$iammod && $tlnodelflag && $date > $mdate + ($tlnodeltime * 3600 * 24)) { &fatal_error("time_locked","$tlnodeltime$timelocktxt{'02a'}"); } |
| |
| } else { |
| # Make sure the user is allowed to edit this post. |
| &fatal_error("bad_postnumber",$postid); |
| if ( $postid >= 0 && $postid < $msgcnt ) { |
| } |
| ( |
| $iamposter = ($musername eq $username && $msgcnt == 1) ? 1 : 0; |
| $msub, $mname, $memail, $mdate, $musername, |
| $FORM{"del$postid"} = 1; |
| $micon, $mattach, $mip, $mmessage, $mns, |
| &MultiDel; |
| $mlm, $mlmb, $mfn |
| } |
| ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[$postid]; |
| } |
| chomp $mfn; |
| |
| if ( |
| my ($threadid, $postid, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, @threads, $tmpa, $tmpb, $newlastposttime, $newlastposter, $lastpostid, $views, $name, $email, $subject, $message, $ns,); |
| ${ $uid . $username }{'regdate'} > $mdate |
| |
| || ( !$staff |
| $threadid = $FORM{'threadid'}; |
| && $musername ne $username ) |
| $postid = $FORM{'postid'}; |
| || !$sessionvalid |
| $pollthread = $FORM{'pollthread'}; |
| ) |
| |
| { |
| if ($pollthread) { |
| fatal_error('delete_not_allowed'); |
| $maxpq ||= 60; |
| } |
| $maxpo ||= 50; |
| if ( !$staff |
| $maxpc ||= 0; |
| && $tlnodelflag |
| $numpolloptions ||= 8; |
| && $date > $mdate + ( $tlnodeltime * 3600 * 24 ) ) |
| $vote_limit ||= 0; |
| { |
| |
| fatal_error( 'time_locked', |
| unless (-e "$datadir/$threadid.poll") { &fatal_error("not_allowed"); } |
| "$tlnodeltime$timelocktxt{'02a'}" ); |
| |
| } |
| fopen(FILE, "$datadir/$threadid.poll"); |
| } |
| my @poll_data = <FILE>; |
| else { |
| fclose(FILE); |
| fatal_error( 'bad_postnumber', $postid ); |
| chomp($poll_data); |
| } |
| ($poll_question, $poll_locked, $poll_uname, $poll_name, $poll_email, $poll_date, $guest_vote, $hide_results, $multi_choice, $poll_mod, $poll_modname, $poll_comment, $vote_limit, $pie_radius, $pie_legends, $poll_end) = split(/\|/, $poll_data[0]); |
| $iamposter = ( $musername eq $username && $msgcnt == 1 ) ? 1 : 0; |
| |
| $FORM{"del$postid"} = 1; |
| unless ($poll_uname eq $username || $iammod || $iamadmin || $iamgmod) { &fatal_error("not_allowed"); } |
| MultiDel(); |
| |
| } |
| my $numcount = 0; |
| } |
| unless ($FORM{"question"}) { &fatal_error("no_question"); } |
| |
| $FORM{"question"} =~ s/\ / /g; |
| my ( |
| my $testspaces = $FORM{"question"}; |
| $threadid, $postid, $msub, $mname, $memail, $mdate, |
| $testspaces =~ s/[\r\n\ ]//g; |
| $musername, $micon, $mattach, $mip, $mmessage, $mns, |
| $testspaces =~ s/\ //g; |
| $mlm, $mlmb, $tnum, $tsub, $tname, $temail, |
| $testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g; |
| $tdate, $treplies, $tusername, $ticon, $tstate, $name, |
| $testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g; |
| $email, $subject, $message, $ns, |
| $testspaces =~ s/\[.*?\]//g; |
| ); |
| if (length($testspaces) == 0 && length($FORM{"question"}) > 0) { fatal_error("useless_post","$testspaces"); } |
| |
| |
| $threadid = $FORM{'threadid'}; |
| $poll_question = $FORM{"question"}; |
| $postid = $FORM{'postid'}; |
| &FromChars($poll_question); |
| $pollthread = $FORM{'pollthread'}; |
| $convertstr = $poll_question; |
| |
| $convertcut = $maxpq; |
| if ($pollthread) { |
| &CountChars; |
| $maxpq ||= 60; |
| $poll_question = $convertstr; |
| $maxpo ||= 50; |
| if ($cliped) { &fatal_error("error_occurred","$post_polltxt{'40'} $post_polltxt{'34a'} $maxpq $post_polltxt{'34b'} $post_polltxt{'36'}"); } |
| $maxpc ||= 0; |
| &ToHTML($poll_question); |
| $numpolloptions ||= 8; |
| |
| $vote_limit ||= 0; |
| $guest_vote = $FORM{'guest_vote'} || 0; |
| |
| $hide_results = $FORM{'hide_results'} || 0; |
| if ( !-e "$datadir/$threadid.poll" ) { fatal_error('not_allowed'); } |
| $multi_choice = $FORM{'multi_choice'} || 0; |
| |
| $poll_comment = $FORM{'poll_comment'} || ""; |
| fopen( FILE, "$datadir/$threadid.poll" ); |
| $vote_limit = $FORM{'vote_limit'} || 0; |
| my @poll_data = <FILE>; |
| $pie_legends = $FORM{'pie_legends'} || 0; |
| fclose(FILE); |
| $pie_radius = $FORM{'pie_radius'} || 100; |
| chomp $poll_data; |
| $poll_end_days = $FORM{'poll_end_days'}; |
| ( |
| $poll_end_min = $FORM{'poll_end_min'}; |
| $poll_question, $poll_locked, $poll_uname, $poll_name, |
| |
| $poll_email, $poll_date, $guest_vote, $hide_results, |
| if ($pie_radius =~ /\D/) { $pie_radius = 100; } |
| $multi_choice, $poll_mod, $poll_modname, $poll_comment, |
| if ($pie_radius < 100) { $pie_radius = 100; } |
| $vote_limit, $pie_radius, $pie_legends, $poll_end |
| if ($pie_radius > 200) { $pie_radius = 200; } |
| ) = split /\|/xsm, $poll_data[0]; |
| |
| |
| if ($vote_limit =~ /\D/) { $vote_limit = 0; &fatal_error("only_numbers_allowed","$post_polltxt{'62'}"); } |
| if ( $poll_uname ne $username && !$staff ) { |
| |
| fatal_error('not_allowed'); |
| &FromChars($poll_comment); |
| } |
| $convertstr = $poll_comment; |
| |
| $convertcut = $maxpc; |
| my $numcount = 0; |
| &CountChars; |
| if ( !$FORM{'question'} ) { fatal_error('no_question'); } |
| $poll_comment = $convertstr; |
| $FORM{'question'} =~ s/\ / /gxsm; |
| if ($cliped) { &fatal_error("error_occurred","$post_polltxt{'57'} $post_polltxt{'34a'} $maxpc $post_polltxt{'34b'} $post_polltxt{'36'}"); } |
| my $testspaces = $FORM{'question'}; |
| &ToHTML($poll_comment); |
| $testspaces = regex_1($testspaces); |
| $poll_comment =~ s~\n~<br />~g; |
| if ( length($testspaces) == 0 && length( $FORM{'question'} ) > 0 ) { |
| $poll_comment =~ s~\r~~g; |
| fatal_error( 'useless_post', "$testspaces" ); |
| |
| } |
| $poll_end_days = '' if !$poll_end_days || $poll_end_days =~ /\D/; |
| |
| $poll_end_min = '' if !$poll_end_min || $poll_end_min =~ /\D/; |
| $poll_question = $FORM{'question'}; |
| my $poll_end = $poll_end_days * 86400 if $poll_end_days; |
| FromChars($poll_question); |
| $poll_end += $poll_end_min * 60 if $poll_end_min; |
| $convertstr = $poll_question; |
| $poll_end += $date if $poll_end; |
| $convertcut = $maxpq; |
| |
| CountChars(); |
| my @new_poll_data; |
| $poll_question = $convertstr; |
| push @new_poll_data, qq~$poll_question|$poll_locked|$poll_uname|$poll_name|$poll_email|$poll_date|$guest_vote|$hide_results|$multi_choice|$date|$username|$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n~; |
| if ($cliped) { |
| |
| fatal_error( 'error_occurred', |
| for ($i = 1; $i <= $numpolloptions; $i++) { |
| "$post_polltxt{'40'} $post_polltxt{'34a'} $maxpq $post_polltxt{'34b'} $post_polltxt{'36'}" |
| ($votes, undef) = split(/\|/, $poll_data[$i], 2); |
| ); |
| if (!$votes) { $votes = "0"; } |
| } |
| if ($FORM{"option$i"}) { |
| ToHTML($poll_question); |
| $FORM{"option$i"} =~ s/\ / /g; |
| |
| my $testspaces = $FORM{"option$i"}; |
| $guest_vote = $FORM{'guest_vote'} || 0; |
| $testspaces =~ s/[\r\n\ ]//g; |
| $hide_results = $FORM{'hide_results'} || 0; |
| $testspaces =~ s/\ //g; |
| $multi_choice = $FORM{'multi_choice'} || 0; |
| $testspaces =~ s~\[table\].*?\[tr\].*?\[td\]~~g; |
| $poll_comment = $FORM{'poll_comment'} || q{}; |
| $testspaces =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g; |
| $vote_limit = $FORM{'vote_limit'} || 0; |
| $testspaces =~ s/\[.*?\]//g; |
| $pie_legends = $FORM{'pie_legends'} || 0; |
| if (!length($testspaces)) { fatal_error("useless_post","$testspaces"); } |
| $pie_radius = $FORM{'pie_radius'} || 100; |
| |
| $poll_end_days = $FORM{'poll_end_days'}; |
| &FromChars($FORM{"option$i"}); |
| $poll_end_min = $FORM{'poll_end_min'}; |
| $convertstr = $FORM{"option$i"}; |
| |
| $convertcut = $maxpo; |
| if ( $pie_radius =~ /\D/xsm ) { $pie_radius = 100; } |
| &CountChars; |
| if ( $pie_radius < 100 ) { $pie_radius = 100; } |
| $FORM{"option$i"} = $convertstr; |
| if ( $pie_radius > 200 ) { $pie_radius = 200; } |
| if ($cliped) { &fatal_error("error_occurred","$post_polltxt{'7'} $i $post_polltxt{'34a'} $maxpo $post_polltxt{'34b'} $post_polltxt{'36'}"); } |
| |
| |
| if ( $vote_limit =~ /\D/xsm ) { |
| &ToHTML($FORM{"option$i"}); |
| $vote_limit = 0; |
| $numcount++; |
| fatal_error( 'only_numbers_allowed', "$post_polltxt{'62'}" ); |
| push @new_poll_data, qq~$votes|$FORM{"option$i"}|$FORM{"slicecol$i"}|$FORM{"split$i"}\n~; |
| } |
| } |
| |
| } |
| FromChars($poll_comment); |
| if ($numcount < 2) { &fatal_error("no_options"); } |
| $convertstr = $poll_comment; |
| |
| $convertcut = $maxpc; |
| # showcase poll start |
| CountChars(); |
| if ($iamadmin || $iamgmod) { |
| $poll_comment = $convertstr; |
| my $scthreadid; |
| if ($cliped) { |
| if (-e "$datadir/showcase.poll") { |
| fatal_error( 'error_occurred', |
| fopen (FILE, "$datadir/showcase.poll"); |
| "$post_polltxt{'57'} $post_polltxt{'34a'} $maxpc $post_polltxt{'34b'} $post_polltxt{'36'}" |
| $scthreadid = <FILE>; |
| ); |
| fclose (FILE); |
| } |
| } |
| ToHTML($poll_comment); |
| if ($threadid == $scthreadid && !$FORM{'scpoll'}) { |
| $poll_comment =~ s/\n/<br \/>/gxsm; |
| unlink("$datadir/showcase.poll"); |
| $poll_comment =~ s/\r//gxsm; |
| } elsif ($FORM{'scpoll'}) { |
| |
| fopen (SCFILE, ">$datadir/showcase.poll"); |
| if ( !$poll_end_days || $poll_end_days =~ /\D/xsm ) { |
| print SCFILE $threadid; |
| $poll_end_days = q{}; |
| fclose (SCFILE); |
| } |
| } |
| if ( !$poll_end_min || $poll_end_min =~ /\D/xsm ) { |
| } |
| $poll_end_min = q{}; |
| # showcase poll end |
| } |
| |
| my $poll_end = q{}; |
| fopen(POLL, ">$datadir/$threadid.poll"); |
| if ($poll_end_days) { $poll_end = $poll_end_days * 86400; } |
| print POLL @new_poll_data; |
| if ($poll_end_min) { $poll_end += $poll_end_min * 60; } |
| fclose(POLL); |
| if ($poll_end) { $poll_end += $date; } |
| |
| |
| $yySetLocation = qq~$scripturl?num=$threadid~; |
| my @new_poll_data; |
| |
| push @new_poll_data, |
| &redirectexit; |
| qq~$poll_question|$poll_locked|$poll_uname|$poll_name|$poll_email|$poll_date|$guest_vote|$hide_results|$multi_choice|$date|$username|$poll_comment|$vote_limit|$pie_radius|$pie_legends|$poll_end\n~; |
| } |
| |
| |
| for my $i ( 1 .. $numpolloptions ) { |
| unless (ref($thread_arrayref{$threadid})) { |
| ( $votes, undef ) = split /\|/xsm, $poll_data[$i], 2; |
| fopen(FILE, "$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt", 1); |
| if ( !$votes ) { $votes = 0; } |
| @{$thread_arrayref{$threadid}} = <FILE>; |
| if ( $FORM{"option$i"} ) { |
| fclose(FILE); |
| $FORM{"option$i"} =~ s/\ / /gxsm; |
| } |
| $testspaces = $FORM{"option$i"}; |
| |
| $testspaces = regex_1($testspaces); |
| # Make sure the user is allowed to edit this post. |
| if ( !length $testspaces ) { |
| if ($postid >= 0 && $postid < @{$thread_arrayref{$threadid}}) { |
| fatal_error( 'useless_post', "$testspaces" ); |
| ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $mfn) = split(/\|/, ${$thread_arrayref{$threadid}}[$postid]); |
| } |
| chomp $mfn; |
| |
| unless ((${$uid.$username}{'regdate'} < $mdate && $musername eq $username) || $iammod || $iamadmin || $iamgmod) { |
| FromChars( $FORM{"option$i"} ); |
| &fatal_error("change_not_allowed"); |
| $convertstr = $FORM{"option$i"}; |
| } |
| $convertcut = $maxpo; |
| } else { |
| CountChars(); |
| &fatal_error("bad_postnumber","$postid"); |
| $FORM{"option$i"} = $convertstr; |
| } |
| if ($cliped) { |
| |
| fatal_error( 'error_occurred', |
| ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split(/\|/, $yyThreadLine); |
| "$post_polltxt{'7'} $i $post_polltxt{'34a'} $maxpo $post_polltxt{'34b'} $post_polltxt{'36'}" |
| |
| ); |
| $postthread = 2 if $postid; |
| } |
| |
| |
| # the post is to be modified... |
| ToHTML( $FORM{"option$i"} ); |
| $name = $FORM{'name'}; |
| $numcount++; |
| $email = $FORM{'email'}; |
| push @new_poll_data, |
| $subject = $FORM{'subject'}; |
| qq~$votes|$FORM{"option$i"}|$FORM{"slicecol$i"}|$FORM{"split$i"}\n~; |
| $message = $FORM{'message'}; |
| } |
| $icon = $FORM{'icon'}; |
| } |
| $ns = $FORM{'ns'}; |
| if ( $numcount < 2 ) { fatal_error('no_options'); } |
| $notify = $FORM{'notify'}; |
| |
| $thestatus = $FORM{'topicstatus'}; |
| # showcase poll start |
| $thestatus =~ s/\, //g; |
| if ( $iamadmin || $iamgmod || $iamfmod ) { |
| &CheckIcon; |
| my $scthreadid; |
| |
| if ( -e "$datadir/showcase.poll" ) { |
| &fatal_error("no_message") unless ($message); |
| fopen( FILE, "$datadir/showcase.poll" ); |
| |
| $scthreadid = <FILE>; |
| $spamdetected = &spamcheck("$subject $message"); |
| fclose(FILE); |
| if (!${$uid.$FORM{$username}}{'spamcount'}) { ${$uid.$FORM{$username}}{'spamcount'} = 0; } |
| } |
| $postspeed = $date - $posttime; |
| if ( $threadid == $scthreadid && !$FORM{'scpoll'} ) { |
| if (!$iamadmin && !$iamgmod && !$iammod){ |
| unlink "$datadir/showcase.poll"; |
| if (($speedpostdetection && $postspeed < $min_post_speed) || $spamdetected == 1) { |
| } |
| ${$uid.$username}{'spamcount'}++; |
| elsif ( $FORM{'scpoll'} ) { |
| ${$uid.$username}{'spamtime'} = $date; |
| fopen( SCFILE, ">$datadir/showcase.poll" ); |
| &UserAccount($username,"update"); |
| print {SCFILE} $threadid or croak "$croak{'print'}SCFILE"; |
| $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'}; |
| fclose(SCFILE); |
| if ($spamdetected == 1){ &fatal_error("tsc_alert"); } else { &fatal_error("speed_alert"); } |
| } |
| } |
| } |
| } |
| |
| |
| # showcase poll end |
| my $mess_len = $message; |
| |
| $mess_len =~ s/[\r\n ]//ig; |
| fopen( POLL, ">$datadir/$threadid.poll" ); |
| $mess_len =~ s/&#\d{3,}?\;/X/ig; |
| print {POLL} @new_poll_data or croak "$croak{'print'} POLL"; |
| if (length($mess_len) > $MaxMessLen) { |
| fclose(POLL); |
| require "$sourcedir/Post.pl"; |
| |
| &Preview($post_txt{'536'} . " " . (length($mess_len) - $MaxMessLen) . " " . $post_txt{'537'}); |
| $yySetLocation = qq~$scripturl?num=$threadid~; |
| } |
| |
| undef $mess_len; |
| redirectexit(); |
| |
| } |
| &FromChars($subject); |
| |
| $convertstr = $subject; |
| if ( !ref $thread_arrayref{$threadid} ) { |
| $convertcut = $set_subjectMaxLength + ($subject =~ /^Re: / ? 4 : 0); |
| fopen( FILE, "$datadir/$threadid.txt" ) |
| &CountChars; |
| or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); |
| $subject = $convertstr; |
| @{ $thread_arrayref{$threadid} } = <FILE>; |
| &ToHTML($subject); |
| fclose(FILE); |
| |
| } |
| &ToHTML($name); |
| |
| $email =~ s/\|//g; |
| # Make sure the user is allowed to edit this post. |
| &ToHTML($email); |
| if ( $postid >= 0 && $postid < @{ $thread_arrayref{$threadid} } ) { |
| &fatal_error("no_subject") unless ($subject && $subject !~ m~\A[\s_.,]+\Z~); |
| ( |
| my $testmessage = $message; |
| $msub, $mname, $memail, $mdate, $musername, |
| &ToChars($testmessage); |
| $micon, $mattach, $mip, $mmessage, $mns, |
| $testmessage =~ s/[\r\n\ ]//g; |
| $mlm, $mlmb, $mfn |
| $testmessage =~ s/\ //g; |
| ) = split /\|/xsm, ${ $thread_arrayref{$threadid} }[$postid]; |
| $testmessage =~ s~\[table\].*?\[tr\].*?\[td\]~~g; |
| chomp $mfn; |
| $testmessage =~ s~\[/td\].*?\[/tr\].*?\[/table\]~~g; |
| if ( |
| $testmessage =~ s/\[.*?\]//g; |
| ( |
| if ($testmessage eq "" && $message ne "" && $pollthread != 2) { fatal_error("useless_post","$testmessage"); } |
| ${ $uid . $username }{'regdate'} >= $mdate |
| |
| || $musername ne $username |
| if (!$minlinkpost){ $minlinkpost = 0 ;} |
| ) |
| if (${$uid.$username}{'postcount'} < $minlinkpost && !$iamadmin && !$iamgmod && !$iammod && !$iamguest) { |
| && !$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"); |
| { |
| } |
| fatal_error('change_not_allowed'); |
| } |
| } |
| |
| } |
| &FromChars($message); |
| else { |
| $message =~ s/\cM//g; |
| fatal_error( 'bad_postnumber', "$postid" ); |
| $message =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; |
| } |
| $message =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; |
| |
| $message =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; |
| ( |
| &ToHTML($message); |
| $tnum, $tsub, $tname, $temail, $tdate, |
| $message =~ s/\t/ \ \ \ /g; |
| $treplies, $tusername, $ticon, $tstate |
| $message =~ s~\n~<br />~g; |
| ) = split /\|/xsm, $yyThreadLine; |
| if ($postid == 0) { |
| |
| $tsub = $subject; |
| if ($postid) { $postthread = 2; } |
| $ticon = $icon; |
| |
| } |
| # the post is to be modified... |
| |
| $name = $FORM{'name'}; |
| if ($tstate =~ /l/i) { |
| $email = $FORM{'email'}; |
| my $icanbypass = &checkUserLockBypass if $bypass_lock_perm; |
| $subject = $FORM{'subject'}; |
| if (!$icanbypass) { &fatal_error('topic_locked');} |
| $message = $FORM{'message'}; |
| } |
| $icon = $FORM{'icon'}; |
| if ($iammod || $iamgmod || $iamadmin) { |
| $ns = $FORM{'ns'}; |
| $thestatus =~ s/0//g; |
| $notify = $FORM{'notify'}; |
| $tstate = $tstate =~ /a/i ? "0a$thestatus" : "0$thestatus"; |
| $thestatus = $FORM{'topicstatus'}; |
| &MessageTotals("load", $tnum); |
| $thestatus =~ s/\, //gsm; |
| ${$tnum}{'threadstatus'} = $tstate; |
| CheckIcon(); |
| &MessageTotals("update", $tnum); |
| |
| } |
| if ( $FORM{'reason'} ) { |
| |
| $reason = $FORM{'reason'}; |
| $yyThreadLine = qq~$tnum|$tsub|$tname|$temail|$tdate|$treplies|$tusername|$ticon|$tstate~; |
| $reason = qq~\[reason\]$reason\[\/reason\]~; |
| |
| $message = qq~$message$reason~; |
| if ($mip =~ /$user_ip/) { $useredit_ip = $mip; } |
| } |
| else { $useredit_ip = "$mip $user_ip"; } |
| |
| |
| if ( !$message ) { fatal_error('no_message'); } |
| my (@attachments,%post_attach,%del_filename); |
| |
| fopen(ATM, "+<$vardir/attachments.txt"); |
| $spamdetected = spamcheck("$subject $message"); |
| seek ATM, 0, 0; |
| if ( !${ $uid . $FORM{$username} }{'spamcount'} ) { |
| while (<ATM>) { |
| ${ $uid . $FORM{$username} }{'spamcount'} = 0; |
| $_ =~ /^(\d+)\|(\d+)\|.+\|(.+)\|\d+\s+/; |
| } |
| $del_filename{$3}++; |
| $postspeed = $date - $posttime; |
| if ($threadid == $1 && $postid == $2) { |
| if ( !$staff ) { |
| $post_attach{$3} = $_; |
| if ( ( $speedpostdetection && $postspeed < $min_post_speed ) |
| } else { |
| || $spamdetected == 1 ) |
| push(@attachments, $_); |
| { |
| } |
| ${ $uid . $username }{'spamcount'}++; |
| } |
| ${ $uid . $username }{'spamtime'} = $date; |
| |
| UserAccount( $username, 'update' ); |
| my ($file,$fixfile,@filelist,@newfilelist,@attachmentsfile); |
| $spam_hits_left_count = |
| for (my $y = 1; $y <= $allowattach; ++$y) { |
| $post_speed_count - ${ $uid . $username }{'spamcount'}; |
| $file = $CGI_query->upload("file$y") if $CGI_query; |
| if ( $spamdetected == 1 ) { fatal_error('tsc_alert'); } |
| if ($file && ($FORM{"w_file$y"} eq "attachnew" || !exists $FORM{"w_file$y"})) { |
| else { fatal_error('speed_alert'); } |
| $fixfile = $file; |
| } |
| $fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/; |
| } |
| $fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/g; # replace all inappropriate with the "_" character. |
| |
| |
| my $mess_len = $message; |
| # replace . with _ in the filename except for the extension |
| $mess_len =~ s/[\r\n ]//igsm; |
| my $fixname = $fixfile; |
| $mess_len =~ s/&\x23\d{3,}?\;/X/igxsm; |
| $fixname =~ s/(.+)(\..+?)$/$1/; |
| if ( length($mess_len) > $MaxMessLen ) { |
| my $fixext = $2; |
| require Sources::Post; |
| |
| Preview($post_txt{'536'} . q{ } |
| my $spamdetected = &spamcheck("$fixname"); |
| . ( length($mess_len) - $MaxMessLen ) . q{ } |
| if (!$iamadmin && !$iamgmod && !$iammod){ |
| . $post_txt{'537'} ); |
| if ($spamdetected == 1) { |
| } |
| ${$uid.$username}{'spamcount'}++; |
| undef $mess_len; |
| ${$uid.$username}{'spamtime'} = $date; |
| |
| &UserAccount($username,"update"); |
| FromChars($subject); |
| $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'}; |
| $convertstr = $subject; |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| $convertcut = $set_subjectMaxLength + ( $subject =~ /^Re: /sm ? 4 : 0 ); |
| &fatal_error("tsc_alert"); |
| CountChars(); |
| } |
| $subject = $convertstr; |
| } |
| ToHTML($subject); |
| if ($use_guardian && $string_on) { |
| |
| @bannedstrings = split(/\|/, $banned_strings); |
| ToHTML($name); |
| foreach (@bannedstrings) { |
| $email =~ s/\|//gxsm; |
| chomp $_; |
| ToHTML($email); |
| if ($fixname =~ m/$_/i) { &fatal_error("attach_name_blocked","($_)"); } |
| if ( !$subject || $subject =~ m{\A[\s_.,]+\Z}xsm ) { |
| } |
| fatal_error('no_subject'); |
| } |
| } |
| $fixext =~ s/\.(pl|pm|cgi|php)/._$1/i; |
| my $testmessage = $message; |
| $fixname =~ s/\./_/g; |
| ToChars($testmessage); |
| $fixfile = qq~$fixname$fixext~; |
| $testmessage = regex_1($testmessage); |
| |
| |
| unlink(qq~$uploaddir/$FORM{"w_filename$y"}~) if $FORM{"w_filename$y"}; |
| if ( $testmessage eq q{} && $message ne q{} && $pollthread != 2 ) { |
| if (!$overwrite) { $fixfile = &check_existence($uploaddir, $fixfile); } |
| fatal_error( 'useless_post', "$testmessage" ); |
| elsif ($overwrite == 2 && -e "$uploaddir/$fixfile") { |
| } |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| |
| &fatal_error("file_overwrite"); |
| if ( !$minlinkpost ) { $minlinkpost = 0; } |
| } |
| if ( ${ $uid . $username }{'postcount'} < $minlinkpost |
| |
| && !$staff |
| my $match = 0; |
| && !$iamguest ) |
| if (!$checkext) { $match = 1; } |
| { |
| else { |
| if ( $message =~ m{http:\/\/}xsm |
| foreach $ext (@ext) { |
| || $message =~ m{https:\/\/}xsm |
| if (grep /$ext$/i, $fixfile) { $match = 1; last; } |
| || $message =~ m{ftp:\/\/}xsm |
| } |
| || $message =~ m{www.}xsm |
| } |
| || $message =~ m{ftp.}xsm =~ m{\[url}xsm |
| if ($match) { |
| || $message =~ m{\[link}xsm |
| unless ($allowattach && (($allowguestattach == 0 && $username ne 'Guest') || $allowguestattach == 1)) { |
| || $message =~ m{\[img}xsm |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| || $message =~ m{\[ftp}xsm ) |
| &fatal_error("no_perm_att"); |
| { |
| } |
| fatal_error('no_links_allowed'); |
| } else { |
| } |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| } |
| require "$sourcedir/Post.pl"; |
| |
| &Preview("$fixfile $fatxt{'20'} @ext"); |
| FromChars($message); |
| } |
| $message = regex_2($message); |
| |
| ToHTML($message); |
| my ($size,$buffer,$filesize,$file_buffer); |
| $message = regex_3($message); |
| while ($size = read($file, $buffer, 512)) { $filesize += $size; $file_buffer .= $buffer; } |
| if ( $postid == 0 ) { |
| if ($limit && $filesize > (1024 * $limit)) { |
| $tsub = $subject; |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| $ticon = $icon; |
| require "$sourcedir/Post.pl"; |
| } |
| &Preview("$fatxt{'21'} $fixfile (" . int($filesize / 1024) . " KB) $fatxt{'21b'} " . $limit); |
| |
| } |
| if ( $tstate =~ /l/ism ) { |
| if ($dirlimit) { |
| if ($bypass_lock_perm) { $icanbypass = checkUserLockBypass(); } |
| my $dirsize = &dirsize($uploaddir); |
| if ( !$icanbypass ) { fatal_error('topic_locked'); } |
| if ($filesize > ((1024 * $dirlimit) - $dirsize)) { |
| } |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| if ($staff) { |
| require "$sourcedir/Post.pl"; |
| $thestatus =~ s/0//gxsm; |
| &Preview("$fatxt{'22'} $fixfile (" . (int($filesize / 1024) - $dirlimit + int($dirsize / 1024)) . " KB) $fatxt{'22b'}"); |
| $tstate = $tstate =~ /a/ism ? "0a$thestatus" : "0$thestatus"; |
| } |
| MessageTotals( 'load', $tnum ); |
| } |
| ${$tnum}{'threadstatus'} = $tstate; |
| |
| MessageTotals( 'update', $tnum ); |
| # 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 |
| $yyThreadLine = |
| print NEWFILE $file_buffer; # write new file on HD |
| qq~$tnum|$tsub|$tname|$temail|$tdate|$treplies|$tusername|$ticon|$tstate~; |
| fclose(NEWFILE); |
| |
| |
| if ( $mip =~ /$user_ip/sm ) { $useredit_ip = $mip; } |
| } else { # return the server's error message if the new file could not be created |
| else { $useredit_ip = "$mip $user_ip"; } |
| foreach (@newfilelist) { unlink("$uploaddir/$_"); } |
| |
| &fatal_error("file_not_open","$uploaddir"); |
| my ( @attachments, %post_attach, %del_filename ); |
| } |
| fopen( ATM, "+<$vardir/attachments.txt" ); |
| |
| seek ATM, 0, 0; |
| # check if file has actually been uploaded, by checking the file has a size |
| while (<ATM>) { |
| my $filesizekb = -s "$uploaddir/$fixfile"; |
| if ( $_ =~ /^(\d+)\|(\d+)\|.+\|(.+)\|\d+\s+/sm ) { |
| unless ($filesizekb) { |
| $del_filename{$3}++; |
| foreach (qw("@newfilelist" $fixfile)) { unlink("$uploaddir/$_"); } |
| if ( $threadid == $1 && $postid == $2 ) { |
| &fatal_error("file_not_uploaded",$fixfile); |
| $post_attach{$3} = $_; |
| } |
| } |
| $filesizekb = int($filesizekb / 1024); |
| else { |
| |
| push @attachments, $_; |
| if ($fixfile =~ /\.(jpg|gif|png|jpeg)$/i) { |
| } |
| my $okatt = 1; |
| } |
| if ($fixfile =~ /gif$/i) { |
| } |
| my $header; |
| |
| fopen(ATTFILE, "$uploaddir/$fixfile"); |
| my ( $file, $fixfile, @filelist, @newfilelist, $fixext ); |
| read(ATTFILE, $header, 10); |
| |
| my $giftest; |
| for my $y ( 1 .. $allowattach ) { |
| ($giftest, undef, undef, undef, undef, undef) = unpack("a3a3C4", $header); |
| if ($CGI_query) { $file = $CGI_query->upload("file$y"); } |
| fclose(ATTFILE); |
| if ( $file |
| if ($giftest ne "GIF") { $okatt = 0; } |
| && ( $FORM{"w_file$y"} eq 'attachnew' || !exists $FORM{"w_file$y"} ) |
| } |
| ) |
| fopen(ATTFILE, "$uploaddir/$fixfile"); |
| { |
| while ( read(ATTFILE, $buffer, 1024) ) { |
| $fixfile = $file; |
| if ($buffer =~ /<(html|script|body)/ig) { $okatt = 0; last; } |
| $fixfile =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/gsm; |
| } |
| if ( $fixfile =~ /[^0-9A-Za-z\+\-\.:_]/gsm ) |
| fclose(ATTFILE); |
| { |
| if(!$okatt) { # delete the file as it contains illegal code |
| # Transliteration |
| foreach (qw("@newfilelist" $fixfile)) { unlink("$uploaddir/$_"); } |
| my $x = 0; |
| &fatal_error("file_not_uploaded","$fixfile <= illegal code inside image file!"); |
| foreach ( @uploadtranlist ) |
| } |
| { |
| } |
| $fixfile =~ s/$_/$ISO_8859_1[$x]/gxsm; |
| |
| $x++; |
| push(@newfilelist, $fixfile); |
| } |
| push(@filelist, $fixfile); |
| |
| push(@attachments, qq~$threadid|$postid|$subject|$mname|$currentboard|$filesizekb|$date|$fixfile|0\n~); |
| # END Transliteration. Thanks to "Velocity" for this contribution. |
| |
| $fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/gsm; |
| } elsif ($FORM{"w_filename$y"}) { |
| } |
| if ($FORM{"w_file$y"} eq "attachdel") { |
| |
| unlink(qq~$uploaddir/$FORM{"w_filename$y"}~) if $del_filename{$FORM{"w_filename$y"}} == 1; |
| # replace . with _ in the filename except for the extension |
| $del_filename{$FORM{"w_filename$y"}}--; |
| my $fixname = $fixfile; |
| } elsif ($FORM{"w_file$y"} eq "attachold") { |
| if ( $fixname =~ s/(.+)(\..+?)$/$1/sm ) { |
| push(@filelist, $FORM{"w_filename$y"}); |
| $fixext = $2; |
| push(@attachments, $post_attach{$FORM{"w_filename$y"}}); |
| } |
| } |
| |
| } |
| my $spamdetected = spamcheck("$fixname"); |
| } |
| if ( !$staff ) { |
| # Print attachments.txt |
| if ( $spamdetected == 1 ) { |
| truncate ATM, 0; |
| ${ $uid . $username }{'spamcount'}++; |
| seek ATM, 0, 0; |
| ${ $uid . $username }{'spamtime'} = $date; |
| print ATM sort { (split /\|/,$a)[6] <=> (split /\|/,$b)[6] } @attachments; |
| UserAccount( $username, 'update' ); |
| fclose(ATM); |
| $spam_hits_left_count = |
| |
| $post_speed_count - ${ $uid . $username }{'spamcount'}; |
| # Create the list of files |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| $fixfile = join(",", @filelist); |
| fatal_error('tsc_alert'); |
| |
| } |
| ${$thread_arrayref{$threadid}}[$postid] = qq~$subject|$mname|$memail|$mdate|$musername|$icon|0|$useredit_ip|$message|$ns|$date|$username|$fixfile\n~; |
| } |
| fopen(FILE, ">$datadir/$threadid.txt") || &fatal_error("cannot_open","$datadir/$threadid.txt",1); |
| if ( $use_guardian && $string_on ) { |
| print FILE @{$thread_arrayref{$threadid}}; |
| @bannedstrings = split /\|/xsm, $banned_strings; |
| fclose(FILE); |
| foreach (@bannedstrings) { |
| |
| chomp $_; |
| if ($postid == 0 || $iammod || $iamgmod || $iamadmin) { |
| if ( $fixname =~ m/$_/ism ) { |
| # Save the current board. icon, status or subject may have changed -> update board info |
| fatal_error( 'attach_name_blocked', "($_)" ); |
| fopen(BOARD, "+<$boardsdir/$currentboard.txt") || &fatal_error("cannot_open","$boardsdir/$currentboard.txt",1); |
| } |
| my @board = <BOARD>; |
| } |
| for (my $a = 0; $a < @board; $a++) { |
| } |
| if ($board[$a] =~ m~\A$threadid\|~o) { $board[$a] = "$yyThreadLine\n"; last; } |
| $fixext =~ s/\.(pl|pm|cgi|php)/._$1/ism; |
| } |
| $fixname =~ s/\./_/gxsm; |
| truncate BOARD, 0; |
| $fixfile = qq~$fixname$fixext~; |
| seek BOARD, 0, 0; |
| |
| print BOARD @board; |
| if ( $FORM{"w_filename$y"} ) { |
| fclose(BOARD); |
| unlink qq~$uploaddir/$FORM{"w_filename$y"}~; |
| |
| } |
| &BoardSetLastInfo($currentboard,\@board); |
| if ( !$overwrite ) { |
| |
| $fixfile = check_existence( $uploaddir, $fixfile ); |
| } elsif ($postid == $#{$thread_arrayref{$threadid}}) { |
| } |
| # maybe last message changed subject and/or icon -> update board info |
| elsif ( $overwrite == 2 && -e "$uploaddir/$fixfile" ) { |
| fopen(BOARD, "$boardsdir/$currentboard.txt") || &fatal_error('cannot_open', "$boardsdir/$currentboard.txt", 1); |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| my @board = <BOARD>; |
| fatal_error(file_overwrite); |
| fclose(BOARD); |
| } |
| &BoardSetLastInfo($currentboard,\@board); |
| |
| } |
| my $match = 0; |
| |
| if ( !$checkext ) { $match = 1; } |
| require "$sourcedir/Notify.pl"; |
| else { |
| if ($notify) { |
| foreach my $ext (@ext) { |
| &ManageThreadNotify("add", $threadid, $username, ${$uid.$username}{'language'}, 1, 1); |
| if ( grep { /$ext$/ism } $fixfile ) { |
| } else { |
| $match = 1; |
| &ManageThreadNotify("delete", $threadid, $username); |
| last; |
| } |
| } |
| |
| } |
| if (${$uid.$username}{'postlayout'} ne "$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}") { |
| } |
| ${$uid.$username}{'postlayout'} = "$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}"; |
| if ($match) { |
| &UserAccount($username, "update"); |
| if ( |
| } |
| !$allowattach |
| |
| || ( ( $allowguestattach != 0 || $username eq 'Guest' ) |
| my $start = !$ttsreverse ? (int($postid / $maxmessagedisplay) * $maxmessagedisplay) : $treplies - (int(($treplies - $postid) / $maxmessagedisplay) * $maxmessagedisplay); |
| && $allowguestattach != 1 ) |
| $yySetLocation = qq~$scripturl?num=$threadid/$start#$postid~; |
| ) |
| &redirectexit; |
| { |
| |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| |
| fatal_error('no_perm_att'); |
| |
| } |
| |
| } |
| |
| else { |
| |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| |
| require Sources::Post; |
| |
| Preview("$fixfile $fatxt{'20'} @ext"); |
| |
| } |
| |
| |
| |
| my ( $size, $buffer, $filesize, $file_buffer ); |
| |
| while ( $size = read $file, $buffer, 512 ) { |
| |
| $filesize += $size; |
| |
| $file_buffer .= $buffer; |
| |
| } |
| |
| $limit ||= 0; |
| |
| if ( $limit > 0 && $filesize > ( 1024 * $limit ) ) { |
| |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| |
| fatal_error( q{}, |
| |
| "$fatxt{'21'} $fixfile (" |
| |
| . int( $filesize / 1024 ) |
| |
| . " KB) $fatxt{'21b'} " |
| |
| . $limit ); |
| |
| } |
| |
| $dirlimit ||= 0; |
| |
| if ($dirlimit > 0) { |
| |
| my $dirsize = dirsize($uploaddir); |
| |
| if ( $filesize > ( ( 1024 * $dirlimit ) - $dirsize ) ) { |
| |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| |
| fatal_error( |
| |
| q{}, |
| |
| "$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 |
| |
| or croak "$croak{'print'} NEWFILE"; # write new file on HD |
| |
| fclose(NEWFILE); |
| |
| |
| |
| } |
| |
| else |
| |
| { # return the server's error message if the new file could not be created |
| |
| foreach (@newfilelist) { unlink "$uploaddir/$_"; } |
| |
| fatal_error( 'file_not_open', "$uploaddir" ); |
| |
| } |
| |
| |
| |
| # check if file has actually been uploaded, by checking the file has a size |
| |
| my $filesizekb = -s "$uploaddir/$fixfile"; |
| |
| if ( !$filesizekb ) { |
| |
| foreach (qw("@newfilelist" $fixfile)) { |
| |
| unlink "$uploaddir/$_"; |
| |
| } |
| |
| fatal_error( 'file_not_uploaded', $fixfile ); |
| |
| } |
| |
| $filesizekb = int( $filesizekb / 1024 ); |
| |
| |
| |
| if ( $fixfile =~ /\.(jpg|gif|png|jpeg)$/ixsm ) { |
| |
| my $okatt = 1; |
| |
| if ( $fixfile =~ /gif$/ism ) { |
| |
| my $header; |
| |
| fopen( ATTFILE, "$uploaddir/$fixfile" ); |
| |
| 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" ); |
| |
| while ( read ATTFILE, $buffer, 1024 ) { |
| |
| if ( $buffer =~ /<(html|script|body)/igsm ) { |
| |
| $okatt = 0; |
| |
| last; |
| |
| } |
| |
| } |
| |
| fclose(ATTFILE); |
| |
| if ( !$okatt ) { # delete the file as it contains illegal code |
| |
| foreach (qw("@newfilelist" $fixfile)) { |
| |
| unlink "$uploaddir/$_"; |
| |
| } |
| |
| fatal_error( 'file_not_uploaded', |
| |
| "$fixfile <= illegal code inside image file!" ); |
| |
| } |
| |
| } |
| |
| |
| |
| push @newfilelist, $fixfile; |
| |
| push @filelist, $fixfile; |
| |
| push @attachments, |
| |
| qq~$threadid|$postid|$subject|$mname|$currentboard|$filesizekb|$date|$fixfile|0\n~; |
| |
| |
| |
| } |
| |
| elsif ( $FORM{"w_filename$y"} ) { |
| |
| if ( $FORM{"w_file$y"} eq 'attachdel' ) { |
| |
| if ( $del_filename{ $FORM{"w_filename$y"} } == 1 ) { |
| |
| unlink qq~$uploaddir/$FORM{"w_filename$y"}~; |
| |
| } |
| |
| $del_filename{ $FORM{"w_filename$y"} }--; |
| |
| } |
| |
| elsif ( $FORM{"w_file$y"} eq 'attachold' ) { |
| |
| push @filelist, $FORM{"w_filename$y"}; |
| |
| push @attachments, $post_attach{ $FORM{"w_filename$y"} }; |
| |
| } |
| |
| } |
| |
| } |
| |
| |
| |
| # Print attachments.txt |
| |
| truncate ATM, 0; |
| |
| seek ATM, 0, 0; |
| |
| print {ATM} sort { ( split /\|/xsm, $a )[6] <=> ( split /\|/xsm, $b )[6] } |
| |
| @attachments |
| |
| or croak "$croak{'print'} ATM"; |
| |
| fclose(ATM); |
| |
| |
| |
| # Create the list of files |
| |
| $fixfile = join q{,}, @filelist; |
| |
| |
| |
| ${ $thread_arrayref{$threadid} }[$postid] = |
| |
| qq~$subject|$mname|$memail|$mdate|$musername|$icon|0|$useredit_ip|$message|$ns|$date|$username|$fixfile\n~; |
| |
| fopen( FILE, ">$datadir/$threadid.txt" ) |
| |
| or fatal_error( 'cannot_open', "$datadir/$threadid.txt", 1 ); |
| |
| print {FILE} @{ $thread_arrayref{$threadid} } |
| |
| or croak "$croak{'print'} FILE"; |
| |
| fclose(FILE); |
| |
| |
| |
| if ( $postid == 0 || $staff ) { |
| |
| |
| |
| # Save the current board. icon, status or subject may have changed -> update board info |
| |
| fopen( BOARD, "+<$boardsdir/$currentboard.txt" ) |
| |
| or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); |
| |
| my @board = <BOARD>; |
| |
| for my $c ( 0 .. $#board ) { |
| |
| if ( $board[$c] =~ m{\A$threadid\|}osm ) { |
| |
| $board[$c] = "$yyThreadLine\n"; |
| |
| last; |
| |
| } |
| |
| } |
| |
| truncate BOARD, 0; |
| |
| seek BOARD, 0, 0; |
| |
| print {BOARD} @board or croak "$croak{'print'} BOARD"; |
| |
| fclose(BOARD); |
| |
| |
| |
| BoardSetLastInfo( $currentboard, \@board ); |
| |
| |
| |
| } |
| |
| elsif ( $postid == $#{ $thread_arrayref{$threadid} } ) { |
| |
| |
| |
| # maybe last message changed subject and/or icon -> update board info |
| |
| fopen( BOARD, "$boardsdir/$currentboard.txt" ) |
| |
| or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); |
| |
| my @board = <BOARD>; |
| |
| fclose(BOARD); |
| |
| BoardSetLastInfo( $currentboard, \@board ); |
| |
| } |
| |
| |
| |
| require Sources::Notify; |
| |
| if ($notify) { |
| |
| ManageThreadNotify( 'add', $threadid, $username, |
| |
| ${ $uid . $username }{'language'}, |
| |
| 1, 1 ); |
| |
| } |
| |
| else { |
| |
| ManageThreadNotify( 'delete', $threadid, $username ); |
| |
| } |
| |
| |
| |
| if ( ${ $uid . $username }{'postlayout'} ne |
| |
| "$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}" |
| |
| ) |
| |
| { |
| |
| ${ $uid . $username }{'postlayout'} = |
| |
| "$FORM{'messageheight'}|$FORM{'messagewidth'}|$FORM{'txtsize'}|$FORM{'col_row'}"; |
| |
| UserAccount( $username, 'update' ); |
| |
| } |
| |
| |
| |
| $maxmessagedisplay ||= 10; |
| |
| my $start = |
| |
| !$ttsreverse |
| |
| ? ( int( $postid / $maxmessagedisplay ) * $maxmessagedisplay ) |
| |
| : $treplies - |
| |
| ( |
| |
| int( ( $treplies - $postid ) / $maxmessagedisplay ) * |
| |
| $maxmessagedisplay ); |
| |
| my $rts = $FORM{'return_to'}; |
| |
| if ( $rts == 3 ) { |
| |
| $yySetLocation = qq~$scripturl~; |
| |
| } |
| |
| elsif ( $rts == 2 ) { |
| |
| $yySetLocation = qq~$scripturl?board=$currentboard~; |
| |
| } |
| |
| else { |
| |
| $yySetLocation = qq~$scripturl?num=$threadid/$start#$postid~; |
| |
| } |
| |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| sub MultiDel { # deletes singel- or multi-Posts |
| sub MultiDel { # deletes single- or multi-Posts |
| $thread = $INFO{'thread'}; |
| $thread = $INFO{'thread'}; |
| |
| |
| unless (ref($thread_arrayref{$thread})) { |
| if ( !ref $thread_arrayref{$thread} ) { |
| fopen(FILE, "$datadir/$thread.txt") || &fatal_error("cannot_open","$datadir/$thread.txt",1); |
| fopen( FILE, "$datadir/$thread.txt" ) |
| @{$thread_arrayref{$thread}} = <FILE>; |
| or fatal_error( 'cannot_open', "$datadir/$thread.txt", 1 ); |
| fclose(FILE); |
| @{ $thread_arrayref{$thread} } = <FILE>; |
| } |
| fclose(FILE); |
| my @messages = @{$thread_arrayref{$thread}}; |
| } |
| |
| my @messages = @{ $thread_arrayref{$thread} }; |
| # check all checkboxes, delete posts if checkbox is ticked |
| |
| my $kill = 0; |
| # check all checkboxes, delete posts if checkbox is ticked |
| my $postid; |
| my $kill = 0; |
| for ($count = $#messages; $count >= 0; $count--) { |
| my $postid; |
| if ($FORM{"del$count"} ne '') { |
| foreach my $count ( reverse 0 .. $#messages ) { |
| chomp $messages[$count]; |
| if ( $FORM{"del$count"} ne q{} ) { |
| @message = split(/\|/, $messages[$count]); |
| chomp $messages[$count]; |
| $musername = $message[4]; |
| @message = split /\|/xsm, $messages[$count]; |
| |
| $musername = $message[4]; |
| # Checks that the user is actually allowed to access multidel |
| |
| if (${$uid.$username}{'regdate'} > $message[3] || (!$iamadmin && !$iamgmod && !$iammod && $musername ne $username) || !$sessionvalid) { &fatal_error("delete_not_allowed"); } |
| # Checks that the user is actually allowed to access multidel |
| if (!$iamadmin && !$iamgmod && !$iammod && $tlnodelflag && $date > $message[3] + ($tlnodeltime * 3600 * 24)) { &fatal_error("time_locked","$tlnodeltime$timelocktxt{'02a'}"); } |
| if ( |
| |
| ${ $uid . $username }{'regdate'} > $message[3] |
| if ($message[12]) { # delete post attachments |
| || ( !$staff |
| require "$admindir/Attachments.pl"; |
| && $musername ne $username ) |
| my %remattach; |
| || !$sessionvalid |
| $message[12] =~ s/,/|/g; |
| ) |
| $remattach{$thread} = $message[12]; |
| { |
| &RemoveAttachments(\%remattach); |
| fatal_error('delete_not_allowed'); |
| } |
| } |
| |
| if ( !$staff |
| splice(@messages, $count, 1); |
| && $tlnodelflag |
| $kill++; |
| && $date > $message[3] + ( $tlnodeltime * 3600 * 24 ) ) |
| $postid = $count if $kill == 1; |
| { |
| |
| fatal_error( 'time_locked', "$tlnodeltime$timelocktxt{'02a'}" ); |
| # decrease members post count if not in a zero post count board |
| } |
| unless (${$uid.$currentboard}{'zero'} || $musername eq 'Guest' || $message[6] eq 'no_postcount') { |
| |
| if (!${$uid.$musername}{'password'}) { |
| if ( $message[12] ) { # delete post attachments |
| &LoadUser($musername); |
| require Admin::Attachments; |
| } |
| my %remattach; |
| if (${$uid.$musername}{'postcount'} > 0) { |
| $message[12] =~ s/,/|/gxsm; |
| ${$uid.$musername}{'postcount'}--; |
| $remattach{$thread} = $message[12]; |
| &UserAccount($musername, "update"); |
| RemoveAttachments( \%remattach ); |
| } |
| } |
| if (${$uid.$musername}{'position'}) { |
| |
| $grp_after = qq~${$uid.$musername}{'position'}~; |
| splice @messages, $count, 1; |
| } else { |
| $kill++; |
| foreach $postamount (sort { $b <=> $a } keys %Post) { |
| if ( $kill == 1 ) { $postid = $count; } |
| if (${$uid.$musername}{'postcount'} > $postamount) { |
| |
| ($grp_after, undef) = split(/\|/, $Post{$postamount}, 2); |
| # decrease members post count if not in a zero post count board |
| last; |
| if ( !${ $uid . $currentboard }{'zero'} |
| } |
| && $musername ne 'Guest' |
| } |
| && $message[6] ne 'no_postcount' ) |
| } |
| { |
| &ManageMemberinfo("update", $musername, '', '', $grp_after, ${$uid.$musername}{'postcount'}); |
| if ( !${ $uid . $musername }{'password'} ) { |
| |
| LoadUser($musername); |
| my ($md,$mu,$mdmu); |
| } |
| foreach (reverse @messages) { |
| if ( ${ $uid . $musername }{'postcount'} > 0 ) { |
| (undef, undef, undef, $md, $mu, undef) = split(/\|/, $_, 6); |
| ${ $uid . $musername }{'postcount'}--; |
| if ($mu eq $musername) { $mdmu = $md; last; } |
| UserAccount( $musername, 'update' ); |
| } |
| } |
| &Recent_Write("decr", $thread, $musername, $mdmu); |
| if ( ${ $uid . $musername }{'position'} ) { |
| } |
| $grp_after = qq~${$uid.$musername}{'position'}~; |
| } |
| } |
| } |
| else { |
| |
| foreach |
| if (!@messages) { |
| my $postamount ( reverse sort { $a <=> $b } keys %Post ) |
| # all post was deleted, call removethread |
| { |
| require "$sourcedir/Favorites.pl"; |
| if ( ${ $uid . $musername }{'postcount'} > $postamount ) |
| $INFO{'ref'} = "delete"; |
| { |
| &RemFav($thread); |
| ( $grp_after, undef ) = |
| |
| split /\|/xsm, $Post{$postamount}, 2; |
| require "$sourcedir/RemoveTopic.pl"; |
| last; |
| $iamposter = ($message[4] eq $username) ? 1 : 0; |
| } |
| &DeleteThread($thread); |
| } |
| } |
| } |
| @{$thread_arrayref{$thread}} = @messages; |
| ManageMemberinfo( 'update', $musername, q{}, q{}, $grp_after, |
| |
| ${ $uid . $musername }{'postcount'} ); |
| # if thread has not been deleted: update thread, update message index details ... |
| |
| fopen(FILE, ">$datadir/$thread.txt") || &fatal_error("cannot_open","$datadir/$thread.txt",1); |
| my ( $md, $mu, $mdmu ); |
| print FILE @{$thread_arrayref{$thread}}; |
| foreach ( reverse @messages ) { |
| fclose(FILE); |
| ( undef, undef, undef, $md, $mu, undef ) = split /\|/xsm, |
| |
| $_, 6; |
| my @firstmessage = split(/\|/, ${$thread_arrayref{$thread}}[0]); |
| if ( $mu eq $musername ) { $mdmu = $md; last; } |
| my @lastmessage = split(/\|/, ${$thread_arrayref{$thread}}[$#{$thread_arrayref{$thread}}]); |
| } |
| |
| Recent_Write( 'decr', $thread, $musername, $mdmu ); |
| # update the current thread |
| } |
| &MessageTotals("load", $thread); |
| } |
| ${$thread}{'replies'} = $#{$thread_arrayref{$thread}}; |
| } |
| ${$thread}{'lastposter'} = $lastmessage[4] eq "Guest" ? qq~Guest-$lastmessage[1]~ : $lastmessage[4]; |
| |
| &MessageTotals("update", $thread); |
| if ( !@messages ) { |
| |
| |
| # update the current board. |
| # all post was deleted, call removethread |
| &BoardTotals("load", $currentboard); |
| require Sources::Favorites; |
| ${$uid.$currentboard}{'messagecount'} -= $kill; |
| $INFO{'ref'} = 'delete'; |
| # &BoardTotals("update", ...) is done later in &BoardSetLastInfo |
| RemFav($thread); |
| |
| |
| my $threadline = ''; |
| require Sources::RemoveTopic; |
| fopen(BOARDFILE, "+<$boardsdir/$currentboard.txt") || &fatal_error("cannot_open","$boardsdir/$currentboard.txt",1); |
| $iamposter = ( $message[4] eq $username ) ? 1 : 0; |
| my @buffer = <BOARDFILE>; |
| DeleteThread($thread); |
| |
| } |
| my $a; |
| @{ $thread_arrayref{$thread} } = @messages; |
| for ($a = 0; $a < @buffer; $a++) { |
| |
| if ($buffer[$a] =~ /^$thread\|/) { |
| # if thread has not been deleted: update thread, update message index details ... |
| $threadline = $buffer[$a]; |
| fopen( FILE, ">$datadir/$thread.txt" ) |
| splice(@buffer, $a, 1); |
| or fatal_error( 'cannot_open', "$datadir/$thread.txt", 1 ); |
| last; |
| print {FILE} @{ $thread_arrayref{$thread} } or croak "$croak{'print'} FILE"; |
| } |
| fclose(FILE); |
| } |
| |
| |
| my @firstmessage = split /\|/xsm, ${ $thread_arrayref{$thread} }[0]; |
| chomp $threadline; |
| my @lastmessage = split /\|/xsm, |
| my @newthreadline = split(/\|/, $threadline); |
| ${ $thread_arrayref{$thread} }[ $#{ $thread_arrayref{$thread} } ]; |
| $newthreadline[1] = $firstmessage[0]; # subject of first message |
| |
| $newthreadline[7] = $firstmessage[5]; # icon of first message |
| # update the current thread |
| $newthreadline[4] = $lastmessage[3]; # date of last message |
| MessageTotals( 'load', $thread ); |
| $newthreadline[5] = ${$thread}{'replies'}; # replay number |
| ${$thread}{'replies'} = $#{ $thread_arrayref{$thread} }; |
| |
| ${$thread}{'lastposter'} = |
| my $inserted = 0; |
| $lastmessage[4] eq 'Guest' ? qq~Guest-$lastmessage[1]~ : $lastmessage[4]; |
| for ($a = 0; $a < @buffer; $a++) { |
| MessageTotals( 'update', $thread ); |
| if ((split(/\|/, $buffer[$a], 6))[4] < $newthreadline[4]) { |
| |
| splice(@buffer,$a,0,join("|", @newthreadline) . "\n"); |
| # update the current board. |
| $inserted = 1; |
| BoardTotals( 'load', $currentboard ); |
| last; |
| ${ $uid . $currentboard }{'messagecount'} -= $kill; |
| } |
| |
| } |
| # &BoardTotals("update", ...) is done later in &BoardSetLastInfo |
| if (!$inserted) { push(@buffer, join("|", @newthreadline) . "\n"); } |
| |
| |
| my $threadline = q{}; |
| truncate BOARDFILE, 0; |
| fopen( BOARDFILE, "+<$boardsdir/$currentboard.txt" ) |
| seek BOARDFILE, 0, 0; |
| or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); |
| print BOARDFILE @buffer; |
| my @buffer = <BOARDFILE>; |
| fclose(BOARDFILE); |
| |
| |
| for my $c ( 0 .. $#buffer ) { |
| &BoardSetLastInfo($currentboard,\@buffer); |
| if ( $buffer[$c] =~ /^$thread\|/xsm ) { |
| |
| $threadline = $buffer[$c]; |
| $postid = $postid > ${$thread}{'replies'} ? ${$thread}{'replies'} : ($postid - 1); |
| splice @buffer, $c, 1; |
| my $start = !$ttsreverse ? (int($postid / $maxmessagedisplay) * $maxmessagedisplay) : ${$thread}{'replies'} - (int((${$thread}{'replies'} - $postid) / $maxmessagedisplay) * $maxmessagedisplay); |
| last; |
| $yySetLocation = qq~$scripturl?num=$thread/$start#$postid~; |
| } |
| |
| } |
| |
| |
| |
| chomp $threadline; |
| |
| my @newthreadline = split /\|/xsm, $threadline; |
| |
| $newthreadline[1] = $firstmessage[0]; # subject of first message |
| |
| $newthreadline[7] = $firstmessage[5]; # icon of first message |
| |
| $newthreadline[4] = $lastmessage[3]; # date of last message |
| |
| $newthreadline[5] = ${$thread}{'replies'}; # replay number |
| |
| |
| |
| my $inserted = 0; |
| |
| for my $c ( 0 .. $#buffer ) { |
| |
| if ( ( split /\|/xsm, $buffer[$a], 6 )[4] < $newthreadline[4] ) { |
| |
| splice @buffer, $c, 0, join( q{|}, @newthreadline ) . "\n"; |
| |
| $inserted = 1; |
| |
| last; |
| |
| } |
| |
| } |
| |
| if ( !$inserted ) { push @buffer, join( q{|}, @newthreadline ) . "\n"; } |
| |
| |
| |
| truncate BOARDFILE, 0; |
| |
| seek BOARDFILE, 0, 0; |
| |
| print {BOARDFILE} @buffer or croak "$croak{'print'} BOARD"; |
| |
| fclose(BOARDFILE); |
| |
| |
| |
| BoardSetLastInfo( $currentboard, \@buffer ); |
| |
| |
| |
| $postid = |
| |
| $postid > ${$thread}{'replies'} ? ${$thread}{'replies'} : ( $postid - 1 ); |
| |
| |
| |
| $maxmessagedisplay ||= 10; |
| |
| my $start = |
| |
| !$ttsreverse |
| |
| ? ( int( $postid / $maxmessagedisplay ) * $maxmessagedisplay ) |
| |
| : ${$thread}{'replies'} - |
| |
| ( |
| |
| int( ( ${$thread}{'replies'} - $postid ) / $maxmessagedisplay ) * |
| |
| $maxmessagedisplay ); |
| |
| $yySetLocation = qq~$scripturl?num=$thread/$start#$postid~; |
| |
| |
| &redirectexit; |
| redirectexit(); |
| |
| return; |
| } |
| } |
| |
| |
| 1; |
| 1; |
| |
| |