#!/usr/bin/perl #####Это рабочий файл postings.cgi c прикрученным хаком голосования ############################################################# # Ikonboard v2.1 # Copyright 2001 Ikonboard.com - All Rights Reserved # Ikonboard is a trademark of Ikonboard.com # # Software Distributed by: Ikonboard.com # Visit us online at http://www.ikonboard.com # Email us on boards@ikonboard.com # # All files written by Matthew Mecham ############################################################# use CGI::Carp "fatalsToBrowser"; # Output errors to browser use CGI qw(:standard); # Saves loads of work $CGI::POST_MAX=1024 * 150; # limit post data $CGI::DISABLE_UPLOADS = 1; # Disable uploads eval { ($0 =~ m,(.*)/[^/]+,) and unshift (@INC, "$1"); ($0 =~ m,(.*)\\[^\\]+,) and unshift (@INC, "$1"); require "ikon.lib"; # Require ikonboard () require "data/progs.cgi"; # Require prog names require "data/boardinfo.cgi";# Require board info require "data/styles.cgi"; # Require styles info }; if ($@) { print header('text/html; charset=windows-1251'); print start_html(-title=>"$ibtxt{'0025'}"); print "$ibtxt{'0026'} $@\n$ibtxt{'0027'}"; print end_html; exit; } $|++; # Unbuffer the output #################--- Begin the program ---################### $thisprog = "postings.cgi"; $query = new CGI; &checkVALIDITY; $cookiepath = $query->url(-absolute=>1); $cookiepath =~ s/$thisprog//sg; for ('forum','topic','membername','password','action','postno', 'notify','deletepost','previewfirst','intopictitle','intopicdescription', 'inpost','inshowemoticons','inshowsignature','checked','movetoid','leavemessage') { next unless defined $_; next if $_ eq 'SEND_MAIL'; $tp = $query->param($_); $tp = &cleaninput("$tp"); ${$_} = $tp; } $inforum = $forum; $intopic = $topic; $inmembername = $membername; $inpassword = $password; $inpostno = $postno; $innotify = $notify; $indeletepost = $deletepost; $inleavemessage= $leavemessage; $currenttime = time; # Begin Program if ($inshowemoticons ne "yes") { $inshowemoticons eq "no"; } if ($innotify ne "yes") { $innotify eq "no"; } if ($checked eq "yes") { $namecookie = cookie(-name => "amembernamecookie", -value => "$inmembername", -path => "$cookiepath", -expires => "+30d"); $passcookie = cookie(-name => "apasswordcookie", -value => "$inpassword", -path => "$cookiepath", -expires => "+30d"); print header(-cookie=>[$namecookie, $passcookie]); } else { print header('text/html; charset=windows-1251'); } if (($inforum) && ($inforum !~ /^[0-9]+$/)) { &error("$ibtxt{'0901'}&$ibtxt{'0501'}."); } if (($intopic ) && ($intopic !~ /^[0-9]+$/)) { &error("$ibtxt{'0901'}&$ibtxt{'0501'}."); } if (($inpostno) && ($inpostno !~ /^[0-9]+$/)) { &error("$ibtxt{'0901'}&$ibtxt{'0501'}."); } if (($movetoid) && ($movetoid !~ /^[0-9]+$/)) { &error("$ibtxt{'0901'}&$ibtxt{'0501'}."); } if (! $inmembername) { $inmembername = cookie("amembernamecookie"); } if (! $inpassword) { $inpassword = cookie("apasswordcookie"); } if ($inmembername eq "") { $inmembername = "$ibtxt{'0043'}"; } else { &getmemberstime("$inmembername"); } # Begin Program my %Mode = ( 'edit' => \&editform, 'lock' => \&lockthread, 'unlock' => \&unlockthread, 'delete' => \&deletethread, 'movetopic' => \&movetopic, 'edittopic' => \&edit_topic_title ); if($Mode{$action}) { $Mode{$action}->(); } elsif ($action eq "processedit" && $indeletepost eq "yes") { &deletepost; } elsif ($action eq "processedit" && $previewfirst eq "no") { &processedit; } elsif ($action eq "processedit" && $previewfirst eq "yes") { &editform; } else { &error("$ibtxt{'0901'}&$ibtxt{'1401'}"); } &output( -Title => $boardname, -ToPrint => $output, -Version => $versionnumber ); ############# subs sub edit_topic_title { &getmember("$inmembername"); &moderator; $cleartoedit = "no"; &mischeader("Editing Topic Title"); #-------------------------- # Get the old topic details # Ensuring we have an old_ prefix for the original data; my $file = "$ikondir" . "forum$inforum/$intopic.pl"; open (ENT, $file); flock ENT, 1; $in = ; close (ENT); # Old title Old description ($topicid, $old_topictitle, $old_topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$in); if (($membercode eq "ad") && ($inpassword eq $password)) { $cleartoedit = "yes"; } if (($inmembmod eq "yes") && ($inpassword eq $password)) { $cleartoedit = "yes"; } unless ($cleartoedit eq "yes") { $cleartoedit = "no"; } if ($cleartoedit eq "no" && $checked eq "yes") { &error("Editing Topic Title&You are not the forum moderator or board administrator or your password was incorrect"); } if (($cleartoedit eq "yes") && ($checked eq "yes")) { # # Do we have any data? # unless ($intopictitle) { &error("Editing Topic Title&You must enter a topic title!"); } $filetoread = "$ikondir" . "forum$inforum/$intopic.thd"; open DOOR, "$filetoread" or die "Yo, sup: $!"; flock (DOOR, 2); @file = ; close DOOR; # it's draughty my @edits = split (/\|/, $file[0]); $edits[1] = $intopictitle; $file[0] = join "|", @edits; open (DOOR, ">$filetoread") or die $!; flock (DOOR, 2); print DOOR @file; close DOOR; open(FILE, ">$file"); flock(FILE, 2); # New Title # New Description print FILE "$intopic|$intopictitle|$intopicdescription|$threadstate|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate"; close(FILE); rebuildLIST(-Forum=>"$inforum"); $output .= qq~
Thread Edited
Status:
~; } # end if clear to edit else { $inmembername =~ s/\_/ /g; $output .= qq~
Please enter your details to enable moderation mode [ Edit Topic Title ]
$ibtxt{'0306'}   $ibtxt{'1417'}
$ibtxt{'0307'}   $ibtxt{'2411'}
$ibtxt{'1415'}
$ibtxt{'1416'}
~; } } # end edit topic sub movetopic { &getmember("$inmembername"); &moderator; $cleartomove = "no"; &mischeader("$ibtxt{'1501'}"); if (($membercode eq "ad") && ($inpassword eq $password)) { $cleartomove = "yes"; } if (($inmembmod eq "yes") && ($inpassword eq $password)) { $cleartomove = "yes"; } unless ($cleartomove eq "yes") { $cleartomove = "no"; } if ($cleartomove eq "no" && $checked eq "yes") { &error("$ibtxt{'1502'}&$ibtxt{'0504'}"); } if (($cleartomove eq "yes") && ($checked eq "yes") && ($movetoid)) { ### Get a new thread number. $dirtoopen = "$ikondir" . "forum$movetoid"; opendir (DIR, "$dirtoopen"); @numberdata = readdir(DIR); closedir (DIR); if ($movetoid == $inforum) { &error("$ibtxt{'1502'}&$ibtxt{'1506'} \!"); } @sorteddirdata = grep(/thd/,@numberdata); @sorteddirdata = sort numerically(@sorteddirdata); @sorteddirdata = reverse(@sorteddirdata); $highestno = @sorteddirdata[0]; $highestno =~ s/.thd//; $newthreadnumber = $highestno + 1; $currenttime = time; ### Get the old forum name $filetoopen = "$ikondir" . "data/allforums.cgi"; open(FILE, "$filetoopen"); flock FILE, 1; @forums = ; close(FILE); foreach $forumline (@forums) { #start foreach @forums ($tempno, $trash) = split(/\|/,$forumline); if ($inforum eq $tempno) { ($trash, $trash, $trash, $oldforumname, $trash) = split(/\|/,$forumline); } } ### Get the new forum name foreach $forumline (@forums) { #start foreach @forums ($tempno, $trash) = split(/\|/,$forumline); if ($movetoid eq $tempno) { ($trash, $trash, $trash, $newforumname, $trash) = split(/\|/,$forumline); } } unless ($inleavemessage eq "no") { $inpost = qq~#Moderation Mode

$inpost

$ibtxt{'1510'}~; $filetoopen = "$ikondir" . "forum$inforum/$intopic.thd"; open(FILE, "$filetoopen"); @allmessages = ; close(FILE); $linetokeep = @allmessages[0]; chomp $linetokeep; ($trash, $topictitle, $trash) = split(/\|/,$linetokeep); foreach $messages (@allmessages) { chomp $messages; $processed_data .= "$messages\n"; } $processed_data .= "$inmembername|$topictitle|Moderation Mode|yes|yes|$currenttime|$inpost"; $filetomake = "$ikondir" . "forum$inforum/$intopic.thd"; open(FILE, ">$filetomake"); flock(FILE, 2); print FILE $processed_data; close(FILE); undef $processed_data; $threadposts = @allmessages; my $file = "$ikondir" . "forum$inforum/$intopic.pl"; open (ENT, $file); flock ENT, 1; $in = ; close (ENT); ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$in); open(FILE, ">$file"); flock(FILE, 2); $threadposts++; print FILE "$intopic|$topictitle|$topicdescription|closed|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate"; (FILE); } # end if inleavemessage eq yes my $file = "$ikondir" . "forum$inforum/$intopic.pl"; open (ENT, $file); flock ENT, 1; $in = ; close (ENT); ($topicid, $topictitle, $topicdescription, $threadstate, $threadposts ,$threadviews, $startedby, $startedpostdate, $lastposter, $lastpostdate) = split(/\|/,$in); my $file = "$ikondir" . "forum$movetoid/$newthreadnumber.pl"; open(FILE, ">$file"); flock(FILE, 2); print FILE "$newthreadnumber|$topictitle|$topicdescription|open|$threadposts|$threadviews|$startedby|$startedpostdate|$lastposter|$lastpostdate"; close(FILE); ### Pick up old forum messages $filetoopen = "$ikondir" . "forum$inforum/$intopic.thd"; open(FILE, "$filetoopen"); @oldforummessages = ; close(FILE); $filetoopen = "$ikondir" . "forum$inforum/$intopic.vote"; $filetoopen = &stripMETA($filetoopen); if (-e $filetoopen) { $vfe = "1"; open(FILE, "$filetoopen"); @allvoters = ; close(FILE); } else { $vfe = "0" } $filetoopen = "$ikondir" . "forum$inforum/$intopic.poll"; if (-e $filetoopen) { $pfe = "1"; open(FILE1,"$filetoopen"); @pollfile = ; close(FILE1); } else { $pfe = "0" } $oldthreadposts = @oldforummessages - 1; ### Print to new forum message file foreach $message (@oldforummessages) { chomp $message; $processed_data .= "$message\n"; } $filetomake = "$ikondir" . "forum$movetoid/$newthreadnumber.thd"; open(FILE, ">$filetomake"); flock(FILE, 2); print FILE $processed_data; close(FILE); undef $processed_data; if ($vfe eq "1") { $filetomake = "$ikondir" . "forum$movetoid/$newthreadnumber.vote"; $filetomake = &stripMETA($filetomake); open(FILE, ">$filetomake"); flock(FILE, 2); foreach $voters (@allvoters) { chomp $voters; print FILE "$voters\n"; } close(FILE); } if ($pfe eq "1") { $filetomake = "$ikondir" . "forum$movetoid/$newthreadnumber.poll"; $filetomake = &stripMETA($filetomake); open(FILE, ">$filetomake"); flock(FILE, 2); print FILE "@pollfile"; close(FILE); } ### Update the post counts and lastposter details. $filetoopen = "$ikondir" . "data/allforums.cgi"; open(FILE, "$filetoopen"); flock FILE, 1; @allforums = ; close(FILE); foreach $forum (@allforums) { #start foreach @forums chomp($forum); ($tempno, $trash) = split(/\|/,$forum); if ($inforum eq $tempno) { ($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic, $pollstate) = split(/\|/,$forum); if ($inleavemessage eq "no") { $threads--; } $currenttime = time; $posts = $posts - $threadposts; $posts++; $processed_data .= "$forumid|$category|$categoryplace|$forumname|$forumdescription|$forummoderator|$htmlstate|$idmbcodestate|$privateforum|$startnewthreads|$lastposter|$lastposttime|$threads|$posts|$forumgraphic|$pollstate\n"; } elsif ($movetoid eq $tempno) { ($forumid, $category, $categoryplace, $forumname, $forumdescription, $forummoderator ,$htmlstate ,$idmbcodestate ,$privateforum, $startnewthreads ,$lastposter ,$lastposttime, $threads, $posts, $forumgraphic, $pollstate) = split(/\|/,$forum); $threads++; $posts = $posts + $threadposts; $posts--; $processed_data .= "$forumid|$category|$categoryplace|$forumname|$forumdescription|$forummoderator|$htmlstate|$idmbcodestate|$privateforum|$startnewthreads|$lastposter|$lastposttime|$threads|$posts|$forumgraphic|$pollstate\n"; } else { $processed_data .= "$forum\n"; } } if (($processed_data eq "") || ($processed_data !~ m!\|!)) { &error("Missing Data&Data as corrupted on the server. Please go back and try again"); } $filetomake = "$ikondir" . "data/allforums.cgi"; open(FILE, ">$filetomake"); flock(FILE, 2); print FILE $processed_data; close(FILE); undef $processed_data; if ($inleavemessage ne "yes") { ### Delete the old listings first delete the old thread file $filetounlink = "$ikondir" . "forum$inforum/$intopic.thd"; unlink $filetounlink; $filetounlink = "$ikondir" . "forum$inforum/$intopic.vote"; unlink $filetounlink; $filetounlink = "$ikondir" . "forum$inforum/$intopic.poll"; unlink $filetounlink; ### Now we have to trash it from the list.cgi $filetounlink = "$ikondir" . "forum$inforum/$intopic.pl"; unlink $filetounlink; } # end unless statement rebuildLIST(-Forum=>"$inforum"); rebuildLIST(-Forum=>"$movetoid"); $output .= qq~
$ibtxt{'1503'}
$ibtxt{'1004'}:
~; $checked = "no"; } # end clear to move if else { $filetoopen = "$ikondir" . "data/allforums.cgi"; open(FILE, "$filetoopen"); flock FILE, 1; @forums = ; close(FILE); $jumphtml .= "

[s]($ibtxt{'1537'} $inmembername $ibtxt{'0010'} $editpostdate)[/s]~; } foreach $postline (@allthreads) { chomp $postline; if ($postcountcheck eq $posttoget) { $processed_data .= "$postermembername|$topictitle|$postipaddress|$inshowemoticons|$inshowsignature|$postdate|$inpost\n"; } else { $processed_data .= "$postline\n"; } $postcountcheck++; } $filetoopen = "$ikondir" . "forum$inforum/$intopic.thd"; open(FILE, ">$filetoopen"); flock(FILE, 2); print FILE $processed_data; close(FILE); undef $processed_data; &mischeader("$ibtxt{'1542'}"); my $gotopage = ($pagestart - $maxthreads); $gotopage = 0 unless $gotopage > 0; $relocurl = "$threadprog?forum=$inforum&topic=$intopic&start=$gotopage"; $output .= qq~
$ibtxt{'1543'}
$ibtxt{'1004'}:
~; } # end if clear to edit else { &error("$ibtxt{'1539'}&$ibtxt{'1540'}"); } } # end routine