Page Index Toggle Pages: 1 2 3 [4]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Compliance Rules for Y2 mods (Read 2150 times)
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #45 - May 2nd, 2006 at 6:12pm
Print Post  
Thanks - It clicked a little while later Smiley


How do you use the update board subroutine??

i want to add a variable to each board which will be used each time the board is displayed.  I can't quite see how to add this new variable.  How do you add one, and how do you make sure it will not conflict with another mod which also adds a new variable??

Edited:
wrong button..sorry Wink
« Last Edit: May 3rd, 2006 at 6:26pm by Spikecity »  
Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #46 - May 3rd, 2006 at 6:26pm
Print Post  
All board variables are identified by a tag found in System.pl by this definition:

my @tags = qw(board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon);

It's polite not to change this line, as this kills compatibility for the next mod, but to push a new variable into this array by using:

push (@tags,"new_var_id");

on the next line.

Once the board is updated the variable gets rewritten to the board data and the hash variable which holds this variable is globally available as:

${$uid.$board}{'new_var_id'}

Where $board can be different, depending on which script you are in.

So if you do something like this:

&BoardTotals("load",$board);
${$uid.$board}{'new_var_id'} = "peanut butter";
&BoardTotals("update",$board);


The value "peanut butter" becomes globally available in

${$uid.$board}{'new_var_id'}

whenever the board is loaded with

&BoardTotals("load",$board);
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #47 - May 4th, 2006 at 5:54pm
Print Post  
I must be going mad!

I have added the:

push (@tags,"new_var_id");

to both instances it appears in the &BoardTotals sub (update and load).

I have then used this code to add a variable:

&BoardTotals("load",$board);
${$uid.$board}{'new_var_id'} = "peanut butter";
&BoardTotals("update",$board);


I then use this code to recall it:

&BoardTotals("load",$board);
${$uid.$board}{'new_var_id'}


It doesn't work for me?

I can change the variable in the last bit of code to "lastposter" and it recalls this fine.  I can also open forum.totals, and the new variable exists on the end of the line for the board I am saving it for.  It will just not recall the variable when using the code, even when the board is loaded.

Any obvious error or thing to check??



I have changed $board to "tempboard" which is actually the name of the board.
  
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: Compliance Rules for Y2 mods
Reply #48 - May 5th, 2006 at 5:01pm
Print Post  
I have been trying to find the problem, and have narrowed it down to this:

This code is from the subroutine &BoardTotals, and is the part that is used for the "load" of board data.

Code
Select All
if (@updateboards) {
  if ($job eq "load") {
    fopen(FORUMTOTALS, "$boardsdir/forum.totals");
    @lines = <FORUMTOTALS>;
    fclose(FORUMTOTALS);
    my @tags = qw(board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon);
###########################
push(@tags,"test");
###########################
    foreach $line (@lines) {
      chomp $line;
      (@boardvars) = split(/\|/, $line);
      foreach $updateboard (@updateboards) {
        chomp $updateboard;
        if ($boardvars[0] eq $updateboard && exists($board{ $boardvars[0] })) {
          $loadedboards++;
###################
&fatal_error($#tags);
###################
          for ($cnt = 1; $cnt < $#tags; $cnt++) {
             ${$uid.$updateboard}{ $tags[$cnt] } = $boardvars[$cnt];
          }
        }
      }
    }
  } 



As you can see, I have added my tag by pushing, and have also added a fatal_error($#tags);

This should theroretically return a value of 10 (9 tags plus my new tag)??  It doesnt, it returns a value of 9 - missing my tag.

Any ideas why this may be happening - I am beginning to feel foolish - I just can't seem to see the problem - The variable saves fine, and I see it in the forum.totals file.  I can also see the variable if I &fatal_error the $line in the code, and also if I fatal_error $boardvars[0] to [9] I can see it.

Embarrassed
???
Embarrassed
  
Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #49 - May 10th, 2006 at 8:42am
Print Post  
Check if the new variable is actually written in the file and also make sure that on the place where you recall this variable the $board var is not called $....board (where the ..... can be anything depending on where you are).
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #50 - May 10th, 2006 at 5:30pm
Print Post  
I really must be going nuts.

I have even tried using the boardname directly, instead of $board.

I can see the variable written in the file.

I can recall the variable inside the sub in system.pl by using $boardvars[9]

I know my recall is correctly written, as if I change the tag 'variable' part from my new variable to a standard one like 'lastposter', it gives me that variable.

Where am I going wrong?  I have even replaced system.pl with a fresh copy, and put my recall script in several locations - currently at the start of display.pl, and I am putting the variable into the fatal_error subroutine so it shows when viewing a board straightaway.

I would be really greatful if someone else could try to write a new variable to file and recall it, just to prove it works!!  Any mods used this method of writting variables yet??

Thanks - pulling hair out Grin
  
Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #51 - May 10th, 2006 at 5:51pm
Print Post  
Martin_W wrote on May 10th, 2006 at 5:30pm:
I would be really greatful if someone else could try to write a new variable to file and recall it, just to prove it works!!  Any mods used this method of writting variables yet??

Thanks - pulling hair out Grin

Martin,

It must be some slight oversight as this is the way to add/write and retrieve extra vars to the system files.
A mod which uses the same trick is the XFire mod (it only adds to the user.vars file but the principle is the same.)
Basically all board and user variables are saved in hashes which in general look like ${$uid.$user_identifier_var}{'var_tag'} and ${$uid.$board_identifier_var}{'var_tag'} and this works throughout the board.
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #52 - May 11th, 2006 at 6:30am
Print Post  
I do appreciate that I may be missing something, but I am fully able to get it working for the users var - I am currently using that and it works fine.  It just seems to be when I try it for a board.

Feel free to tell me to sod off, but please could you look over the below and see if anything stands out as incorrect?


System.pl
Code
Select All
###############################################################################
# System.pl                                                                   #
###############################################################################
# YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.1                                                    #
# Released:       November 8, 2005                                            #
# Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== #
# Copyright (c) 2000-2005 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by: The YaBB Development Team                                      #
#              with assistance from the YaBB community.                       #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #
#               Your source for web hosting, web design, and domains.         #
###############################################################################

$systemplver = 'YaBB 2.1 $Revision: 1.2 $';

sub BoardTotals {
	my ($job, @updateboards) = @_;
	my ($testboard, $line, @lines, $updateboard, @boardvars, $tag, $cnt);
	if (!@updateboards) { @updateboards = @allboards; }
	if ($job eq "convert") {
		fopen(FORUMTOTALS, ">>$boardsdir/forum.totals");
		foreach $testboard (@allboards) {
			chomp $testboard;
			fopen(BOARDTTL, "$boardsdir/$testboard.ttl");
			$line = <BOARDTTL>;
			fclose(BOARDTTL);
			chomp $line;
			print FORUMTOTALS "$testboard|$line|\n";
			unlink "$boardsdir/$testboard.ttl";
		}
		fclose(FORUMTOTALS);
	}
	if (@updateboards) {
		if ($job eq "load") {
			fopen(FORUMTOTALS, "$boardsdir/forum.totals");
			@lines = <FORUMTOTALS>;
			fclose(FORUMTOTALS);
			my @tags = qw(board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon);
###################
push(@tags,"test");
###################
			foreach $line (@lines) {
				chomp $line;
				(@boardvars) = split(/\|/, $line);
				foreach $updateboard (@updateboards) {
					chomp $updateboard;
					if ($boardvars[0] eq $updateboard && exists($board{ $boardvars[0] })) {
						$loadedboards++;
						for ($cnt = 1; $cnt < $#tags; $cnt++) {
							${$uid.$updateboard}{ $tags[$cnt] } = $boardvars[$cnt];
						}
					}
				}
			}
		}
		if ($job eq "update") {
			fopen(FORUMTOTALS, "+<$boardsdir/forum.totals");
			seek FORUMTOTALS, 0, 0;
			@lines = <FORUMTOTALS>;
			truncate FORUMTOTALS, 0;
			seek FORUMTOTALS, 0, 0;
			my @tags = qw(board threadcount messagecount lastposttime lastposter lastpostid lastreply lastsubject lasticon);
###################
push(@tags,"test");
###################
			print FORUMTOTALS "$updateboards[0]|";
			for ($cnt = 1; $cnt <= $#tags; $cnt++) {
				print FORUMTOTALS ${$uid.$updateboards[0]}{ $tags[$cnt] };
				if ($cnt < $#tags) { print FORUMTOTALS "|"; }
			}
			print FORUMTOTALS "\n";
			foreach $line (@lines) {
				chomp $line;
				(@boardvars) = split(/\|/, $line);
				if ($boardvars[0] ne $updateboards[0] && exists($board{ $boardvars[0] })) {
					print FORUMTOTALS "$line\n";
					$loadedboards++;
				}
			}
			fclose(FORUMTOTALS);
		}
		if ($job eq "delete") {
			fopen(FORUMTOTALS, "$boardsdir/forum.totals");
			seek FORUMTOTALS, 0, 0;
			@lines = <FORUMTOTALS>;
			truncate FORUMTOTALS, 0;
			seek FORUMTOTALS, 0, 0;
			foreach $line (@lines) {
				chomp $line;
				(@boardvars) = split(/\|/, $line);
				if ($boardvars[0] ne $updateboards[0] && exists($board{ $boardvars[0] })) {
					print FORUMTOTALS "$line\n";
					$loadedboards++;
				}
			}
			fclose(FORUMTOTALS);
		}
		if ($job eq "add") {
			fopen(FORUMTOTALS, "$boardsdir/forum.totals");
			seek FORUMTOTALS, 0, 0;
			@lines = <FORUMTOTALS>;
			truncate FORUMTOTALS, 0;
			seek FORUMTOTALS, 0, 0;
			print FORUMTOTALS "$updateboards[0]|0|0|N/A|N/A||||\n";
			print FORUMTOTALS @lines;
			fclose(FORUMTOTALS);
		}
	}
} 




Write New Var
Code
Select All
sub Display {







$board=$currentboard;
&BoardTotals("load",$board);
${$uid.$board}{'test'} = "appleade";
&BoardTotals("update",$board); 





Forum.Totals
Code
Select All
openelectrical|4|9|1146765872|admin|1146765873|0|teeererer|xx|appleade
info|2|2|1121214036|Squirrelman|1121236137|0|Tropical Fish Forum|thumbup|appleade
just_talk|2|6|1126887432|Martin|1122732119|4|Re: Hello|xx|appleade
comp_probs|4|11|1146773005|admin|1146773005|0|gh|xx|appleade
humour|7|7|1128261547|admin|1128261547|0|Just found this........always makes me laugh!|laugh|appleade
removed|0|0|N/A|N/A||||
paint|0|0|N/A|N/A||||
build|0|0|N/A|N/A||||
lounge|1|2|1128093958|admin|1121005102|1|Re: Welcome To The Lounge|xx
intrude|0|0|N/A|N/A||||
admin|2|6|1128189381|admin|1128189344|2|Re: Testing quotes|xx
Recycle_Bin|0|0|N/A|N/A||||
mods|0|0|N/A|N/A||||
carpentry|0|0|N/A|N/A||||
plumbing|0|0|N/A|N/A|||| 




Recall Var (DOESNT WORK)
Code
Select All
$board=$currentboard;
&BoardTotals("load",$board);
######${$uid.$board}{'test'} = "appleade";
######&BoardTotals("update",$board);
&fatal_error("Test New Var Should Appear Below <br> ${$uid.$board}{'test'} <br> ${$uid.$board}{'lastposter'}"); 



The fatal_error above shows the "Test new var should.... and then an empty line, and then the last poster of the board.


Sorry to be a pain - I really am stumpted - I can usually have sorted my self out by now!
  
Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #53 - May 11th, 2006 at 7:15pm
Print Post  
On the recall bit, are you sure the variable $board is still filled ? (add the separate vars to the fatal to see if they exist, because if the are empty somehow you are calling vapour instead of your newly created variable.

There seems to be nothing wrong with your code as far as I can tell as long as the variable in the recall is actually defined as $board and not $readboard or something.

Try loading the board like &BoardTotals("load", $currentboard); or &BoardTotals("load", $curboard); and then see if ${$uid.$currentboard}{'test'} or ${$uid.$curboard}{'test'} are there.
(Just peek how the other board variables in that particular script are defined after the board is loaded.
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #54 - May 11th, 2006 at 8:23pm
Print Post  
Thanks for the patients!  $board always displays as the current board when I fatal error it.

Been out this evening for a meal/drink, so will look closer again when my mind is acive!

Thanks for the help.
  
Back to top
WWW  
IP Logged
 
Spikecity
God Member
*****
Offline


Beer anyone ?

Posts: 2630
Location: New York
Joined: Apr 16th, 2002
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #55 - May 11th, 2006 at 8:53pm
Print Post  
Martin_W wrote on May 11th, 2006 at 8:23pm:
Thanks for the patients!  $board always displays as the current board when I fatal error it.

Been out this evening for a meal/drink, so will look closer again when my mind is acive!

Thanks for the help.

Anytime.... keep me posted... I know what a blind spot can be after coding three years on this project.

And sometimes a good meal and a glass of whatever you like clears your mind.
  

Nothing to add here Smiley
Back to top
 
IP Logged
 
Martin_W
Senior Member
****
Offline


I love YaBB 1G - SP1.2!

Posts: 463
Location: Devon
Joined: Jun 22nd, 2005
Gender: Male
Re: Compliance Rules for Y2 mods
Reply #56 - May 12th, 2006 at 5:59am
Print Post  
Thanks for the encouragement!

I have used fatal_error to prove $board is the currentboard.
If i dont load the board first, I can't recall any vars from that board.
If I load the board, I can recall the vars, except mine.
I can see my var in the file, it writes and updates.
If I fatal error inside system.pl, I can see my variable right up until the $cnt loop at the end of the load part.  It doesn't get put into the ${$uid.$board} bit.  The $cnt goes right through all vars and stops before my  new one!

I really am lost by this - My hands are up Grin
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1 2 3 [4] 
Send TopicPrint