Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Random News Mod (Baby mod) (Read 584 times)
CLAN Admin
Full Member
***
Offline



Posts: 176
Location: london
Joined: Sep 17th, 2002
Random News Mod (Baby mod)
Sep 17th, 2002 at 4:15pm
Print Post  
I posted this modification long time ago(Aug 4, 2002) to yabbforum. In case anyone is intrested, there it is:

http://www.yabbforum.com/community/?board=graph_temp;action=display;num=10284654...


This is a simple modification
Open BoardIndex.pl
Around line 80-84 (I have made a lot of modifications so it may be somewhere else)

After
fopen(FILE, "$vardir/news.txt");
@newsmessages = <FILE>;
fclose(FILE);

insert:

# randomizing news      
   sub fisher_yates_shuffle {
       my $deck = shift;  # $deck is a reference to an array
       my $i = @$deck;
       while ($i--) {
           my $j = int rand ($i+1);
           @$deck[$i,$j] = @$deck[$j,$i];
       }
   }

# shuffle newsmassages

   fisher_yates_shuffle( \@newsmessages );


 

that is before:
for($i=0; $i < @newsmessages; $i++)




The shuffle script itself belongs to fisher Yates. This way, on every reload of the page, newsfader starts with a random news and displays in random order.


Smiley

ps. My apologies for the post if it has already been done before.
« Last Edit: Dec 11th, 2002 at 2:23pm by CLAN Admin »  

© AZ aka CLAN admin aka Guardian
AZbb :: AZ Bulletin Board has arrived
Simple guide: Apache and PHP installation on Windows
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint