Yes, same here. And I think understanding existing perl code and using the parts you want to use in your own new mod isn't easy at all. So I would say we both are no master coders but it's enough for the one or other cool mod
.
By the way, here's the sub that would need to be altered to work with your mod... it's from my ModifyMessage.pl and part of the multidel mod. But since I may have altered the code it's better if you have a look at that code instead of the original code.
No haste - if you find time
.
sub MultiDel {
$yySetLocation = qq~$cgi;action=display;num=$INFO{'thread'};start=$INFO{'start'}~;
$mkill = 0;
$topickill = 0;
fopen(FILE, "$datadir/$INFO{'thread'}.txt", 1) || &fatal_error("$txt{'23'} $INFO{'thread'}.txt");
@mess = <FILE>;
fclose(FILE);
$count = $#mess;
$tnum = $INFO{'thread'};
fopen(AMV, "$vardir/attachments.txt");
my @attachments = <AMV>;
fclose(AMV);
# Find thread position in message index
fopen(FILE, "$boardsdir/$currentboard.txt");
@threads = <FILE>;
fclose(FILE);
$tmpcount = 0;
$threadpos = '';
foreach $curentry (@threads) {
($tmpa, $dummy) = split(/\|/, $curentry);
if($INFO{'thread'} eq $tmpa) { $threadpos = $tmpcount; }
$tmpcount++;
}
# check all checkboxes, delete posts if checkbox is ticked
while (0 <= $count) {
if ($FORM{"del$count"} ne '' && $threadpos ne ''){
($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb, $msf, $mfn) = split( /\|/, $mess[$count] );
chomp $mfn;
if(-e("$upload_dir/$mfn")) {
$attachpos = $#attachments;
while (0 <= $attachpos) {
my ($amthreadid, $amreplies, $amthreadsub, $amposter, $amcurrentboard, $amkb, $amdate, $amfn) = split(/\|/,$attachments[$attachpos]);
chomp $amfn;
if($tnum eq $amthreadid) {
if($amreplies eq $count) {
splice(@attachments, $attachpos, 1);
} elsif ($amreplies > $count) {
$amreplies--;
$attachments[$attachpos] = \n";
}
}
$attachpos--;
}
unlink("$upload_dir/$mfn");
}
if ($mess[1] eq '' || $mess[1] eq "\n"){
# if this is the only post, delete the files
unlink("$datadir/$tnum.txt");
unlink("$datadir/$tnum.mail");
unlink("$datadir/$tnum.data");
unlink("$datadir/$tnum.poll");
unlink("$datadir/$tnum.polled");
unlink("$datadir/$tnum.polll");
splice(@threads, $threadpos, 1);
$topickill = 1;
$yySetLocation = qq~$cgi~;
} else {
# if this is not the only post, delete post
splice(@mess, $count, 1);
$mkill++;
}
}
$count--;
}
# if thread has not been deleted from message index, update message index details
($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split( /\|/, $mess[$#mess]);
if ($topickill != 1 && $threadpos ne ''){
($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split( /\|/, $threads[$threadpos] );
$treplies = $treplies - $mkill;
$threads[$threadpos] = qq~$tnum|$tsub|$tname|$temail|$mdate|$treplies|$tusername|$ticon|$tstate~;
# Save updated posts
fopen(FILE, ">$datadir/$INFO{'thread'}.txt", 1) || &fatal_error("$txt{'23'} $threadid.txt");
print FILE @mess;
fclose(FILE);
# Update last poster information
if( -e "$datadir/$INFO{'thread'}.data" ) {
fopen(FILE, "$datadir/$INFO{'thread'}.data");
$tmpa = <FILE>;
fclose(FILE);
($views,$dummy) = split(/\|/, $tmpa);
fopen(FILE, "+>$datadir/$INFO{'thread'}.data");
print FILE qq~$views|$musername~;
fclose(FILE);
}
}
# Save updated attachments file
fopen(FILE, ">$vardir/attachments.txt", 1) || &fatal_error("$txt{'23'} $threadid.txt");
foreach $row(@attachments) {
chomp $row;
print FILE qq~$row\n~;
}
fclose(FILE);
# Save updated message index
fopen(FILE, ">$boardsdir/$currentboard.txt", 1) || &fatal_error("$txt{'23'} $currentboard.txt");
print FILE @threads;
fclose(FILE);
# update board index details
($latestnum, $dummy) = split( /\|/, $threads[0] );
fopen(FILE, "$datadir/$latestnum.txt", 1) || &fatal_error("$txt{'23'} $latestnum.txt");
@mess = <FILE>;
fclose(FILE);
($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mmessage, $mns, $mlm, $mlmb) = split( /\|/, $mess[$#mess]);
my( $threadcount, $messagecount, $lastposttime, $lastposter ) = &BoardCountGet($currentboard);
$messagecount = $messagecount - $mkill;
if( $topickill == 1) {
--$threadcount;
--$messagecount;
}
&BoardCountSet( $currentboard, $threadcount, $messagecount, $mdate, $musername );
&redirectexit;
}