Recent Users List 1.4 This mod adds a list of the x most recent visitors, optionally with their avatars, to the right of the info centre on the board index. It is intended to add a little colour and sense of community to your board. It works with SP1.1, SP1.2 and SP1.3. You can see examples of the various output styles at: http://www.badpoo.co.uk/ronnie/images/examples/rul_full.gif http://www.badpoo.co.uk/ronnie/images/examples/rul_resized.gif http://www.badpoo.co.uk/ronnie/images/examples/rul_no_avatars.gif http://www.badpoo.co.uk/ronnie/images/examples/rul_options.gif After installing the mod and uploading, you must set the options through the Preferences page. - Number of recent users to show on board index: a setting of 1 would show you the most recent user. A setting of 5 would show you the 5 most recently active users. - Number of rows in Info Centre (not including main Info Centre title row) while not logged in: this option sets the rowspan for the recent users cell in the Info Centre. This is done manually because of the number of mods that affect the Info Centre, making it impossible to hard code the correct rowspan setting for everyone. To work out this value, just count the number of rows in your Info Centre (not including the main "Info Centre" title strip) while not logged in. For example, if you have no mods installed which add rows to the Info Centre, a setting of 6 is correct. - Show avatars in list on board index?: show each user's avatar in the list, or not. - Show times in list on board index?: show the time they were last logged as active in the list, or not. - What should the avatars link to?: the avatars can link to that member's View Profile page, IM Send page or nothing. - Avatar resizing - maximum width in pixels (0 to disable): setting this will use the JavaScript code to resize the avatar's width to the size you specify, while keeping the avatar's height in proportion. This is the most commonly used of the two settings - to resize all the avatars to a set width (for example, 40) while having a proportional height so the images aren't distorted. - Avatar resizing - maximum height in pixels (0 to disable): same as width setting, except it resizes the height. If you set both the width and height setting, all avatars will be forced to those dimensions and will look "wrong" - therefore, it is best to set either the width or height, not both. The following files are edited and need to be uploaded: - english.lng - Sources/BoardIndex.pl - Sources/LogInOut.pl - Sources/AdminEdit.pl CHANGES IN v1.4: - Fixed the Javascript resizing problem! All credit to BHRA Webmaster for his new smart_resize.mod code which seems to have fixed the "1*1 pixel" image problem. - Slightly improved efficiency. FEATURES: - The list outputs the most recent visitor first, descending to the last visitor. - A user will never appear twice in the list - for example, if they're currently fourth in the list then they log in again, they'll zoom to the top of the list and the other entries will be pushed down to make way. - Indicates if the user is online now. - Avatars can be disabled, shown resized to a height/width/height and width you specify or shown at normal size. - Avatars can link to the View Profile or IM Send pages, or not link at all. - Admin option to show times on list. KNOWN PROBLEMS: - On some servers, the lastuseronline.txt file is not automatically created when the mod is first run, as it should be. The resulting problem is that despite the mod seeming to install fine, no users appear in the list. To solve this, manually create a blank text file called "lastuseronline.txt" and upload it to your Variables directory in ASCII mode, then CHMOD it 766. Karma to BHRA Webmaster and his smart_resize.mod code which is used in this mod. Ronnie http://www.badpoo.co.uk/ronnie/pages/yabbmods.shtml Sources/BoardIndex.pl sub BoardIndex { #RECENT USERS LIST MOD START if ($username ne 'Guest' && $action ne 'login2') { require "$sourcedir/LogInOut.pl"; &RecentUsersList; } #RECENT USERS LIST MOD END $curforumurl = $curposlinks ? qq~$mbname~ : $mbname; #RECENT USERS LIST MOD START if ($rul_show_avatars && ($rul_avatar_width || $rul_avatar_height)) { $yymain .= qq~ ~; } #RECENT USERS LIST MOD END } $yymain .= qq~

} #set the correct rowspan for the RECENT USERS LIST main cell $rul_rowspan = ($username eq 'Guest') ? $rul_rowspan : $rul_rowspan - 2; $yymain .= qq~

$txt{'685'} ~; $yymain .= qq~ $txt{'200'} $txt{'685'} $rul_users_display $rul_txt{'1'} ~; $yymain .= qq~ $txt{'200'} ~; &RecentUsersListShow; $yymain .= qq~ sub MarkAllRead { #RECENT USERS LIST #v1.4 #OUTPUTS A TABLE WITH $rul_users_display ROWS - ONE FOR EACH USER IN THE LIST sub RecentUsersListShow { fopen(FILE, "$vardir/lastuseronline.txt"); @lastusers = ; fclose(FILE); chomp @lastusers; $counter = 1; $yymain .= qq~~; foreach $lastuser_line (@lastusers) { ($last_username, $last_userwhen) = split(/\|/, $lastuser_line); #is this user online now? $online_now = ($users =~ /username=$last_username"/) ? "
$rul_txt{'2'}" : ''; #it should never happen, but a Guest entry might have been stored in the file. this avoids showing it if (fopen(MFILE, "$memberdir/$last_username.dat")) { @memberinfo = ; fclose(MFILE); chomp @memberinfo; $last_userwhen = ($rul_show_time) ? '
' . &timeformat($last_userwhen) : ''; #do we want to show an avatar? if ($rul_show_avatars) { #correct url allowing for custom avatars if ($memberinfo[13] =~ m~\Ahttp://~) { $avatar = $memberinfo[13]; } else { $avatar = $facesurl . '/' . $memberinfo[13]; } #is resizing enabled or shall we just show a plain image tag? #if we're using avatar resizing if ($rul_avatar_width || $rul_avatar_height) { #decide what the avatar link should be if ($rul_avatar_link == 2) { $avatars_cell = qq~
~; } elsif ($rul_avatar_link == 1) { $avatars_cell = qq~~; } else { $avatars_cell = qq~~; } } #else we're not using resizing so just use the normal image tag else { #decide what the avatar link should be if ($rul_avatar_link == 2) { $avatars_cell = qq~~; } elsif ($rul_avatar_link == 1) { $avatars_cell = qq~~; } else { $avatars_cell = qq~~; } } } #else we're not showing avatars, so just show the text counter else { $avatars_cell = qq~~; } #output this row $yymain .= qq~$avatars_cell~; } $counter++; } $yymain .= qq~
$rul_txt{'12'} $memberinfo[1]$rul_txt{'13'} $memberinfo[1]$memberinfo[1]$rul_txt{'12'} $memberinfo[1]$rul_txt{'13'} $memberinfo[1]$memberinfo[1]$counter.
$memberinfo[1]$last_userwhen$online_now
~; }
Sources/LogInOut.pl $yySetCookies1 = cookie(-name => "$cookieusername", -value => "$username", -path => "/", -expires => "$ck{'len'}"); #RECENT USERS LIST MOD START if ($username ne 'Guest') { &RecentUsersList; } #RECENT USERS LIST MOD END $yySetCookies1 = cookie(-name => "$cookieusername", -value => "", -path => "/", -expires => "Thursday, 01-Jan-1970 00:00:00 GMT"); #RECENT USERS LIST MOD START if ($username ne 'Guest') { &RecentUsersList; } #RECENT USERS LIST MOD END sub sharedLogin { #RECENT USERS LIST #v1.4 #ORGANISES AND UPDATES THE lastuseronline.txt FILE CONTAINING THE LAST $rul_users_display USERS ONLINE sub RecentUsersList { #how many users to store on file $rul_users_display = $rul_users_display || 5; $display = $rul_users_display - 1;#to take into account we're dealing with [0] $user_in_file = 0; fopen(LUO, "$vardir/lastuseronline.txt"); @lastusers = ; fclose(LUO); #see if there are redundant entries in the file that we don't currently want with $display #old entries appear after reducing $display e.g. from 7 to 5 - first time this code run after reducing there would be 2 unwanted entries in @lastusers $lastusers_count = scalar(@lastusers) - 1; if ($lastusers_count > $display) { for ($r = $lastusers_count; $r > $display; $r--) { pop(@lastusers); } } #check if this user already has an entry in the log for ($i = $display; $i >= 0; $i--) { ($this_username, $junk) = split(/\|/, $lastusers[$i]); if ($this_username eq $username) { $user_in_file = 1; last; } } #arrange file depending whether this user is already in it if (! $user_in_file) { #shift each of the other entries back for ($z = $display; $z > 0; $z--) { $lastusers[$z] = $lastusers[$z - 1]; } #insert this user at the top of the file $lastusers[0] = qq~$username|$date\n~; } #else they are in the file else { #first, check it's not just [0], which we can replace easily if ($i == 0) { #insert this user at the top of the file $lastusers[0] = qq~$username|$date\n~; } #no, it's not [0], so we've got to shift the others around else { #set that line to be the one above it e.g. [2] is replaced by contents of [1] for ($k = $i; $k > 0; $k--) { $lastusers[$k] = $lastusers[$k - 1]; } #insert this user at the top of the file $lastusers[0] = qq~$username|$date\n~; } } #write to file fopen(LUO, ">$vardir/lastuseronline.txt"); print LUO @lastusers; fclose(LUO); } Sources/AdminEdit.pl $txt{'478'}
$rul_txt{'3'} $rul_txt{'15'} $rul_txt{'4'} $rul_txt{'14'} $rul_txt{'8'} $rul_txt{'7'} $rul_txt{'5'} $rul_txt{'6'}
# figure out what to print if ($rul_users_display eq '') { $rul_users_display = 5; } if ($rul_avatar_width eq '') { $rul_avatar_width = 0; } if ($rul_avatar_height eq '') { $rul_avatar_height = 0; } if ($rul_rowspan eq '') { $rul_rowspan = 6; } if ($rul_show_avatars) { $rul_show_avatars_checked = ' checked'; } if ($rul_show_time) { $rul_show_time_checked = ' checked'; } if ($rul_avatar_link == 2) { $rul_avatar_link_selected2 = ' selected'; } elsif ($rul_avatar_link == 1) { $rul_avatar_link_selected1 = ' selected'; } else { $rul_avatar_link_selected0 = ' selected'; } # Set as 0 or 1 if box was checked or not my $fi; push(@onoff, "rul_show_avatars"); push(@onoff, "rul_show_time"); # If empty fields are submitted, set them to default-values to save yabb from crashing #recent users list settings $rul_avatar_link = $FORM{'rul_avatar_link'} || 0; $rul_avatar_width = $FORM{'rul_avatar_width'} || 0; $rul_avatar_height = $FORM{'rul_avatar_height'} || 0; $rul_rowspan = $FORM{'rul_rowspan'} || 6; $rul_users_display = $FORM{'rul_users_display'} || 5; if ($rul_users_display > 99) { $rul_users_display = 99; } if ($rul_users_display =~ /\D/) { &fatal_error($rul_txt{'16'}); } if ($rul_rowspan =~ /\D/) { &fatal_error($rul_txt{'16'}); } if ($rul_avatar_width =~ /\D/) { &fatal_error($rul_txt{'16'}); } if ($rul_avatar_height =~ /\D/) { &fatal_error($rul_txt{'16'}); } \$timeout = $timeout; # Minimum time between 2 postings from the same IP #RECENT USERS LIST \$rul_show_avatars = $rul_show_avatars; # $rul_txt{'4'} \$rul_show_time = $rul_show_time; # $rul_txt{'14'} \$rul_avatar_link = $rul_avatar_link; # $rul_txt{'8'} \$rul_avatar_width = $rul_avatar_width; # $rul_txt{'5'} \$rul_avatar_height = $rul_avatar_height; # $rul_txt{'6'} \$rul_users_display = $rul_users_display; # $rul_txt{'3'} \$rul_rowspan = $rul_rowspan; # $rul_txt{'15'} english.lng 1; $rul_txt{'1'} = 'Most Recent Visitors'; $rul_txt{'2'} = 'Online now'; $rul_txt{'3'} = 'Number of recent users to show on board index'; $rul_txt{'4'} = 'Show avatars in list on board index?'; $rul_txt{'5'} = 'Avatar resizing - maximum width in pixels (0 to disable)'; $rul_txt{'6'} = 'Avatar resizing - maximum height in pixels (0 to disable)'; $rul_txt{'7'} = 'Note on avatar resizing - it is best to set only one of the following values, normally the width. This allows the avatars to be kept in proportion after being resized. If you set both, the avatar will be forced to that size.'; $rul_txt{'8'} = 'What should the avatars link to?'; $rul_txt{'9'} = 'No link'; $rul_txt{'10'} = 'View profile'; $rul_txt{'11'} = 'IM send'; $rul_txt{'12'} = 'Send Instant Message to'; $rul_txt{'13'} = 'View Profile of'; $rul_txt{'14'} = 'Show times in list on board index?'; $rul_txt{'15'} = 'Number of rows in Info Centre (not including main Info Centre title row) while not logged in'; $rul_txt{'16'} = 'One of the fields entered cannot contain non-numeric characters.';