Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) Recycle Bin (Read 13230 times)
Valtiel
God Member
*****
Offline


Copy & paste coder

Posts: 873
Joined: Sep 5th, 2003
Gender: Male
Re: Recycle Bin
Reply #15 - May 14th, 2006 at 4:11pm
Print Post  
Ok, that was easy... you do not tell the script what $date2 should be. So I simply added the line above "&calcdifference" to your code and it works:

Code
Select All
	for ($a = 0; $a < @messages; $a++) {
		($id, $dummy, $dummy, $dummy, $date1) = split(/\|/, $messages[$a]);
		$date2 = $date;
		&calcdifference; 



I wonder how the code in your board knows that it should use $date for $date2 without having that line?

But I now added the following line to my &calcdifference sub:

Code
Select All
	if ($date2 eq "") { $date2 = $date; } 



Perhaps the original sub uses similar code and so it works for you.
  

Proud copy & paste coder Grin
Admin @ Silent Hill Forum
Back to top
WWW  
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Recycle Bin
Reply #16 - May 14th, 2006 at 7:17pm
Print Post  
Glad thats sorted - added that code to mine aswell, just in case Grin

Just goes to show that it was my first mod to write Grin Grin

Will update the attachment at some point if ok with you Wink
  
Back to top
WWW  
IP Logged
 
Valtiel
God Member
*****
Offline


Copy & paste coder

Posts: 873
Joined: Sep 5th, 2003
Gender: Male
Re: Recycle Bin
Reply #17 - May 14th, 2006 at 7:25pm
Print Post  
It's very good for a first mod! I couldn't do it, I guess. I did many mods on my forum, but I always have to compare to existing code and sometimes puzzle my code together taking a code part from here and a code part from there... it's like building a new car out of 10 old ones  Grin .
  

Proud copy & paste coder Grin
Admin @ Silent Hill Forum
Back to top
WWW  
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Recycle Bin
Reply #18 - May 14th, 2006 at 7:35pm
Print Post  
Very similar to what i do TBH!

I look over similar code, and work from there - I like the learning curve it gives.

I always look at other coding I have done days or weeks later and see ways I could have done it better.

Im not a master coder, but like things to work well, and look clean and concise.
  
Back to top
WWW  
IP Logged
 
Valtiel
God Member
*****
Offline


Copy & paste coder

Posts: 873
Joined: Sep 5th, 2003
Gender: Male
Re: Recycle Bin
Reply #19 - May 14th, 2006 at 7:40pm
Print Post  
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  Grin .

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 Wink .

Code
Select All
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;
} 

  

Proud copy & paste coder Grin
Admin @ Silent Hill Forum
Back to top
WWW  
IP Logged
 
Valtiel
God Member
*****
Offline


Copy & paste coder

Posts: 873
Joined: Sep 5th, 2003
Gender: Male
Re: Recycle Bin
Reply #20 - May 21st, 2006 at 1:21pm
Print Post  
There's still something wrong with emptying recycle bin. I deleted all threads older than 2 days - the list showed 1 removed thread. But more than 100 threads got deleted from recycle bin! Last time I did that, ALL threads in recycle bin were deleted  ???
  

Proud copy & paste coder Grin
Admin @ Silent Hill Forum
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint