F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Load.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Load.pm
############################################################################### ###############################################################################
# Load.pl                                                                     # # Load.pm                                                                     #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$loadplver = 'YaBB 2.5.2 $Revision: 1.0 $'; $loadpmver = 'YaBB 2.6.12 $Revision: 1710 $';
   
sub LoadBoardControl { sub LoadBoardControl {
   my ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $dummy, $dummy, $dummy, $cnttotals);     $binboard = q{}; 
   $binboard = "";     $annboard = q{}; 
   $annboard = "";  
   
   fopen(FORUMCONTROL, "$boardsdir/forum.control") || &fatal_error('cannot_open', "$boardsdir/forum.control", 1);  
   my @boardcontrols = <FORUMCONTROL>;  
   fclose(FORUMCONTROL);  
   $maxboards = $#boardcontrols;  
   
   foreach my $boardline (@boardcontrols) {  
       $boardline =~ s/[\r\n]//g; # Built in chomp  
   
       ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $cntmembergroups, $cntann, $cntrbin, $cntattperms, $cntminageperms, $cntmaxageperms, $cntgenderperms) = split(/\|/, $boardline);  
       ## create a global boards array  
       push(@allboards, $cntboard);  
   
       $cntdescription =~ s/\&/\&amp;/g;  
   
       %{ $uid . $cntboard } = (  
           'cat'          => $cntcat,  
           'description'  => $cntdescription,  
           'pic'          => $cntpic,  
           'mods'         => $cntmods,  
           'modgroups'    => $cntmodgroups,  
           'topicperms'   => $cnttopicperms,  
           'replyperms'   => $cntreplyperms,  
           'pollperms'    => $cntpollperms,  
           'zero'         => $cntzero,  
           'membergroups' => $cntmembergroups,  
           'ann'          => $cntann,  
           'rbin'         => $cntrbin,  
           'attperms'     => $cntattperms,  
           'minageperms'  => $cntminageperms,  
           'maxageperms'  => $cntmaxageperms,  
           'genderperms'  => $cntgenderperms,);  
       if ($cntann == 1)  { $annboard = $cntboard; }  
       if ($cntrbin == 1) { $binboard = $cntboard; }  
   }  
}  
   
sub LoadIMs {  
   return if ($iamguest || $PM_level == 0 || ($maintenance && !$iamadmin) || ($PM_level == 2 && (!$iamadmin && !$iamgmod && !$iammod)) || ($PM_level == 3 && (!$iamadmin && !$iamgmod)));  
   
   &buildIMS($username, 'load') unless exists ${$username}{'PMmnum'};     fopen( FORUMCONTROL, "$boardsdir/forum.control" ) 
       or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 );
   my $imnewtext;     my @boardcontrols = <FORUMCONTROL>; 
   if (${$username}{'PMimnewcount'} == 1) { $imnewtext = qq~<a href="$scripturl?action=imshow;caller=1;id=-1">1 $load_txt{'155'}</a>~; }     fclose(FORUMCONTROL); 
   elsif (!${$username}{'PMimnewcount'}) { $imnewtext = $load_txt{'nonew'}; }     $maxboards = $#boardcontrols; 
   else { $imnewtext = qq~<a href="$scripturl?action=imshow;caller=1;id=-1">${$username}{'PMimnewcount'} $load_txt{'154'}</a>~; }  
     foreach my $boardline (@boardcontrols) {
         $boardline =~ s/[\r\n]//gxsm;    # Built in chomp
         my (
             $cntcat,         $cntboard,        $cntpic,
             $cntdescription, $cntmods,         $cntmodgroups,
             $cnttopicperms,  $cntreplyperms,   $cntpollperms,
             $cntzero,        $cntmembergroups, $cntann,
             $cntrbin,        $cntattperms,     $cntminageperms,
             $cntmaxageperms, $cntgenderperms,  $cntcanpost,
             $cntparent,      $rules,           $rulestitle,
             $rulesdesc,      $rulescollapse,   $brdpasswr,
             $brdpassw,       $cntbdrss,
             ## Mod Hook 1 ##
         ) = split /\|/xsm, $boardline;
         ## create a global boards array
         push @allboards, $cntboard;
   
         $cntdescription =~ s/\&\ /\&amp; /gxsm;
         if ( substr( $cntmods, 0, 2 ) eq ', ' ) {
             substr( $cntmods, 0, 2 ) = q{};
         }
         if ( substr( $cntmodgroups, 0, 2 ) eq ', ' ) {
             substr( $cntmodgroups, 0, 2 ) = q{};
         }
   
   if (${$username}{'PMmnum'} == 1) { $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'471'}</a>, $imnewtext~; }         %{ $uid . $cntboard } = ( 
   elsif (!${$username}{'PMmnum'} && !${$username}{'PMimnewcount'}) { $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>~; }             'cat'           => $cntcat, 
   else { $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>, $imnewtext~; }             'description'   => $cntdescription, 
             'pic'           => $cntpic,
             'mods'          => $cntmods,
             'modgroups'     => $cntmodgroups,
             'topicperms'    => $cnttopicperms,
             'replyperms'    => $cntreplyperms,
             'pollperms'     => $cntpollperms,
             'zero'          => $cntzero,
             'membergroups'  => $cntmembergroups,
             'ann'           => $cntann,
             'rbin'          => $cntrbin,
             'attperms'      => $cntattperms,
             'minageperms'   => $cntminageperms,
             'maxageperms'   => $cntmaxageperms,
             'genderperms'   => $cntgenderperms,
             'canpost'       => $cntcanpost,
             'parent'        => $cntparent,
             'rules'         => $rules,
             'rulestitle'    => $rulestitle,
             'rulesdesc'     => $rulesdesc,
             'rulescollapse' => $rulescollapse,
             'brdpasswr'     => $brdpasswr,
             'brdpassw'      => $brdpassw,
             'brdrss'        => $cntbdrss,
              ## Mod Hook 2 ##
         );
         if ( $cntann == 1 )  { $annboard = $cntboard; }
         if ( $cntrbin == 1 ) { $binboard = $cntboard; }
     }
     return;
  }
   
   if (!$user_ip && $iamadmin) { $yyim .= qq~<br /><b>$load_txt{'773'}</b>~; }  sub LoadIMs { 
     return
       if ( $iamguest
         || $PM_level == 0
         || ( $maintenance   && !$iamadmin )
         || ( $PM_level == 2 && ( !$staff ) )
         || ( $PM_level == 4 && ( !$iamadmin && !$iamgmod && !$iamfmod ) )
         || ( $PM_level == 3 && ( !$iamadmin && !$iamgmod ) ) );
   
     if ( !exists ${$username}{'PMmnum'} ) { buildIMS( $username, 'load' ); }
   
     my $imnewtext;
     if ( ${$username}{'PMimnewcount'} == 1 ) {
         $imnewtext =
  qq~<a href="$scripturl?action=imshow;caller=1;id=-1">1 $load_txt{'155'}</a>~;
     }
     elsif ( !${$username}{'PMimnewcount'} ) { $imnewtext = $load_txt{'nonew'}; }
     else {
         $imnewtext =
  qq~<a href="$scripturl?action=imshow;caller=1;id=-1">${$username}{'PMimnewcount'} $load_txt{'154'}</a>~;
     }
   
     if ( ${$username}{'PMmnum'} == 1 ) {
         if ( ${$username}{'PMimnewcount'} == 1 ) {
           $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'155b'}</a>~;
         }
         else {
           $yyim =
  qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'471'}</a>, $imnewtext~;
         }
     }
     elsif ( !${$username}{'PMmnum'} && !${$username}{'PMimnewcount'} ) {
         $yyim =
  qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>~;
     }
     elsif ( ${$username}{'PMmnum'} == ${$username}{'PMimnewcount'} ) {
         $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'154b'}</a>~;
     }
     else {
          $yyim =
  qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>, $imnewtext~;
     }
   
     if ( !$user_ip && $iamadmin ) {
         $yyim .= qq~<br /><b>$load_txt{'773'}</b>~;
     }
     return;
} }
   
sub LoadCensorList { sub LoadCensorList {
   if ($#censored > 0 || -s "$langdir/$language/censor.txt" < 3 || !-e "$langdir/$language/censor.txt") { return; }     opendir DIR, $langdir; 
   fopen(CENSOR, "$langdir/$language/censor.txt") || &fatal_error("cannot_open","$langdir/$language/censor.txt", 1);     my @langDir = readdir DIR; 
   while (chomp($buffer = <CENSOR>)) {     closedir DIR; 
       $buffer =~ s/\r(?=\n*)//g;     @lang = (); 
       if ($buffer =~ m/\~/) {     foreach my $langitems ( sort { lc($a) cmp lc $b } @langDir ) { 
           ($tmpa, $tmpb) = split(/\~/, $buffer);         chomp $langitems; 
           $tmpc = 0;         if (   ( $langitems ne q{.} ) 
       } else {             && ( $langitems ne q{..} ) 
           ($tmpa, $tmpb) = split(/=/, $buffer);             && ( $langitems ne q{.htaccess} ) 
           $tmpc = 1;             && ( $langitems ne q{index.html} ) ) 
       }         { 
       push(@censored, [$tmpa, $tmpb, $tmpc]);             push @lang, $langitems; 
   }        }
   fclose(CENSOR);     } 
   
     if ( $#censored > 0 ) {
         return;
     }
     elsif (
         scalar @lang == 1
         && ( ( -s "$langdir/$language/censor.txt" ) < 3
             || !-e "$langdir/$language/censor.txt" )
       )
     {
         return;
     }
     for my $langd (@lang) {
         if ( -e "$langdir/$langd/censor.txt" ) {
             fopen( CENSOR, "$langdir/$langd/censor.txt" );
             while ( chomp( $buffer = <CENSOR> ) ) {
                 $buffer =~ s/\r(?=\n*)//gxsm;
                 if ( $buffer =~ m/\~/sm ) {
                     ( $tmpa, $tmpb ) = split /\~/xsm, $buffer;
                     $tmpc = 0;
                 }
                 else {
                     ( $tmpa, $tmpb ) = split /=/xsm, $buffer;
                     $tmpc = 1;
                 }
                 push @censored, [ $tmpa, $tmpb, $tmpc ];
             }
             fclose(CENSOR);
         }
     }
     return;
} }
   
sub LoadUserSettings { sub LoadUserSettings {
   &LoadBoardControl;     LoadBoardControl(); 
   $iamguest = $username eq 'Guest' ? 1 : 0;    $iamguest = $username eq 'Guest' ? 1 : 0;
   if ($username ne 'Guest') {    if ( $username ne 'Guest' ) {
       &LoadUser($username);         LoadUser($username); 
       if (!$maintenance || ${$uid.$username}{'position'} eq 'Administrator') {         if ( !$maintenance 
           $iammod = &is_moderator($username);             || ${ $uid . $username }{'position'} eq 'Administrator' ) 
           if (${$uid.$username}{'position'} eq 'Administrator' || ${$uid.$username}{'position'} eq 'Global Moderator' || $iammod) { $staff = 1; }         { 
           else { $staff = 0; }             $iammod = is_moderator($username); 
           $sessionvalid = 1;             if (   ${ $uid . $username }{'position'} eq 'Administrator' 
           if ($sessions == 1 && $staff == 1) {                 || ${ $uid . $username }{'position'} eq 'Global Moderator' 
               $cursession = &encode_password($user_ip);                 || ${ $uid . $username }{'position'} eq 'Mid Moderator' 
               chomp $cursession;                 || $iammod ) 
               if (${$uid.$username}{'session'} ne $cursession || ${$uid.$username}{'session'} ne $cookiesession) { $sessionvalid = 0; }             { 
           }                 $staff = 1; 
           $spass = ${$uid.$username}{'password'};             } 
             else { $staff = 0; }
           # Make sure that if the password doesn't match you get FULLY Logged out             $sessionvalid = 1; 
           if ($spass && $spass ne $password && $action ne 'logout') {            if ( $sessions == 1 && $staff == 1 ) {
               $yySetLocation = $guestaccess ? qq~$scripturl~ : qq~$scripturl?action=login~;                 $cursession = encode_password($user_ip); 
               &UpdateCookie("delete");                 chomp $cursession; 
               &redirectexit;                 if (   ${ $uid . $username }{'session'} ne $cursession 
           }                     || ${ $uid . $username }{'session'} ne $cookiesession ) 
                 {
           $iamadmin  = (${$uid.$username}{'position'} eq 'Administrator' && $sessionvalid == 1) ? 1 : 0;                    $sessionvalid = 0;
           $iamgmod   = (${$uid.$username}{'position'} eq 'Global Moderator' && $sessionvalid == 1) ? 1 : 0;                 } 
           if ($sessionvalid == 1) { ${$uid.$username}{'session'} = $cursession; }            }
           &CalcAge($username, "calc");             $spass = ${ $uid . $username }{'password'}; 
           # Set the order how Topic summaries are displayed  
           $ttsreverse = ${$uid.$username}{'reversetopic'} if !$adminscreen && $ttsureverse;          # Make sure that if the password doesn't match you get FULLY Logged out 
           return;             if ( $spass && $spass ne $password && $action ne 'logout' ) { 
       }                 $yySetLocation = 
   }                   $guestaccess ? qq~$scripturl~ : qq~$scripturl?action=login~; 
                 UpdateCookie('delete');
   &FormatUserName('');                 redirectexit(); 
   &UpdateCookie("delete");             } 
   $username           = 'Guest';  
   $iamguest           = '1';             $iamadmin = 
   $iamadmin           = '';               ( ${ $uid . $username }{'position'} eq 'Administrator' 
   $iamgmod            = '';                   && $sessionvalid == 1 ) ? 1 : 0; 
   $password           = '';             $iamgmod = 
   $ENV{'HTTP_COOKIE'} = '';               ( ${ $uid . $username }{'position'} eq 'Global Moderator' 
   $yyim               = '';                   && $sessionvalid == 1 ) ? 1 : 0; 
   $yyuname            = '';             $iamfmod = 
               ( ${ $uid . $username }{'position'} eq 'Mid Moderator' 
                   && $sessionvalid == 1 ) ? 1 : 0;
             if ( $sessionvalid == 1 ) {
                 ${ $uid . $username }{'session'} = $cursession;
             }
             CalcAge( $username, 'calc' );
   
             # Set the order how Topic summaries are displayed
             if ( !$adminscreen && $ttsureverse ) {
                 $ttsreverse = ${ $uid . $username }{'reversetopic'};
             }
             return;
         }
     }
   
     FormatUserName(q{});
     UpdateCookie('delete');
     $username = 'Guest';
     $iamguest = '1';
     $iamadmin = q{};
     $iamgmod  = q{};
     $iamfmod  = q{};
     $password = q{};
     local $ENV{'HTTP_COOKIE'} = q{};
     $yyim    = q{};
     $yyuname = q{};
     return;
} }
   
sub FormatUserName { sub FormatUserName {
   my $user = $_[0];     my ($user) = @_; 
   return if $useraccount{$user};    return if $useraccount{$user};
   $useraccount{$user} = $do_scramble_id ? &cloak($user) : $user;    $useraccount{$user} = $do_scramble_id ? cloak($user) : $user;
     return;
} }
   
sub LoadUser { sub LoadUser {
   my ($user,$userextension) = @_;    my ( $user, $userextension, $tst ) = @_;
   return 1 if exists ${$uid.$user}{'realname'};     return 1 if exists ${ $uid . $user }{'realname'}; 
   return 0 if $user eq '' || $user eq 'Guest';    return 0 if $user eq q{} || $user eq 'Guest';
   
   if (!$userextension){ $userextension = 'vars'; }     if ( !$userextension ) { 
   if (($regtype == 1 || $regtype == 2) && -e "$memberdir/$user.pre") { $userextension = 'pre'; }     if ( ( $regtype == 1 || $regtype == 2 ) && -e "$memberdir/$user.pre" ) { 
   elsif ($regtype == 1 && -e "$memberdir/$user.wait") { $userextension = 'wait'; }         $userextension = 'pre'; 
     }
   if (-e "$memberdir/$user.$userextension") {    elsif ( $regtype == 1 && -e "$memberdir/$user.wait" ) {
       if ($user ne $username) {         $userextension = 'wait'; 
           fopen(LOADUSER, "$memberdir/$user.$userextension") || &fatal_error('cannot_open', "$memberdir/$user.$userextension", 1);     } 
           my @settings = <LOADUSER>;         else { $userextension = 'vars';} 
           fclose(LOADUSER);     } 
           foreach (@settings) { if ($_ =~ /'(.*?)',"(.*?)"/) { ${$uid.$user}{$1} = $2; } }  
       } else {     if ( !-e "$memberdir/$user.$userextension" ) { return 0; }   # user not found 
           fopen(LOADUSER, "+<$memberdir/$user.$userextension") || &fatal_error('cannot_open', "$memberdir/$user.$userextension", 1);     else { 
           my @settings = <LOADUSER>;         if ( $user ne $username ) { 
           for (my $i = 0; $i < @settings; $i++) {             fopen( LOADUSER, "$memberdir/$user.$userextension" ) 
               if ($settings[$i] =~ /'(.*?)',"(.*?)"/) {               or fatal_error( 'cannot_open', "$memberdir/$user.$userextension load 2 $tst", 
                   ${$uid.$user}{$1} = $2;                 1 ); 
                   if($1 eq 'lastonline' && $INFO{'action'} ne "login2") {             my @settings = <LOADUSER>; 
                       ${$uid.$user}{$1} = $date;             fclose(LOADUSER); 
                       $settings[$i] = qq~'lastonline',"$date"\n~;             foreach (@settings) { 
                   }                 if ( $_ =~ /'(.*?)',"(.*?)"/xsm ) { 
               }                     ${ $uid . $user }{$1} = $2; 
           }                }
           seek LOADUSER, 0, 0;             } 
           truncate LOADUSER, 0;         } 
           print LOADUSER @settings;         else { 
           fclose(LOADUSER);             fopen( LOADUSER, "<$memberdir/$user.$userextension" ) 
       }               or fatal_error( 'cannot_open', 
                 "$memberdir/$user.$userextension load 1 $tst", 1 );
           &ToChars(${$uid.$user}{'realname'});             my @settings = <LOADUSER>; 
       &FormatUserName($user);             fclose(LOADUSER); 
       &LoadMiniUser($user);             for my $i ( 0 .. $#settings ) { 
                 if ( $settings[$i] =~ /'(.*?)',"(.*?)"/xsm ) {
                     ${ $uid . $user }{$1} = $2;
                     if (   $1 eq 'lastonline' 
                         && $INFO{'action'} ne 'login2' 
                         && !${ $uid . $user }{'stealth'} )
                     {
                         ${ $uid . $user }{$1} = $date;
                         $settings[$i] = qq~'lastonline',"$date"\n~;
                     }
                 }
             }
             if ( scalar @settings != 0 ) {
                 fopen( LOADUSER, ">$memberdir/$user.$userextension" )
                   or fatal_error( 'cannot_open',
                     "$memberdir/$user.$userextension load 3 $tst", 1 );
                 print {LOADUSER} @settings or croak "$croak{'print'} LOADUSER";
                 fclose(LOADUSER);
             }
             else {
                 fatal_error( 'missingvars', "$memberdir/$user.$userextension",
                     1 );
             }
         }
   
       return 1;         ToChars( ${ $uid . $user }{'realname'} ); 
   }         FormatUserName($user); 
         LoadMiniUser($user);
   
   return 0; # user not found         return 1; 
     }
} }
   
sub is_moderator { sub is_moderator {
   my $user = $_[0];     my ( $user, $brd ) = @_; 
   my @checkboards;    my @checkboards;
   if ($_[1]) { @checkboards = ($_[1]); }    if   ($brd) { @checkboards = ($brd); }
   else { @checkboards = @allboards; }    else        { @checkboards = @allboards; }
   
   foreach (@checkboards) {    foreach (@checkboards) {
       # check if user is in the moderator list  
       foreach (split(/, ?/, ${$uid.$_}{'mods'})) {         # check if user is in the moderator list 
           if ($_ eq $user) { return 1; }         foreach ( split /, ?/sm, ${ $uid . $_ }{'mods'} ) { 
       }            if ( $_ eq $user ) { return 1; }
         }
       # check if user is member of a moderatorgroup  
       foreach my $testline (split(/, /, ${$uid.$_}{'modgroups'})) {         # check if user is member of a moderatorgroup 
           if ($testline eq ${$uid.$user}{'position'}) { return 1; }         foreach my $testline ( split /, /sm, ${ $uid . $_ }{'modgroups'} ) { 
             if ( $testline eq ${ $uid . $user }{'position'} ) { return 1; }
           foreach (split(/,/, ${$uid.$user}{'addgroups'})) {  
               if ($testline eq $_) { return 1; }             foreach ( split /,/xsm, ${ $uid . $user }{'addgroups'} ) { 
           }                if ( $testline eq $_ ) { return 1; }
       }            }
   }        }
   return 0;     } 
     return 0;
  }
   
  sub is_moderator_b {
     my ($user) = @_;
     $mybrds = q{ };
   
     foreach my $i (@allboards) {
   
         # check if user is in the moderator list
         foreach ( split /, ?/sm, ${ $uid . $i }{'mods'} ) {
             if ( $_ eq $user ) {
                 get_forum_master();
                 ( $boardname, $boardperms, $boardview ) =
                   split /\|/xsm, $board{$i};
                 $mybrds .= qq~$boardname<br />~;
                 return 1;
             }
         }
     }
   
     return 0;
} }
   
sub KillModerator { sub KillModerator {
   my $killmod = $_[0];     my ($killmod) = @_; 
   my ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $dummy, $dummy, $dummy, $cnttotals, @boardcontrol);     my ( @boardcontrol, @newmods, @boardline ); 
   fopen(FORUMCONTROL, "+<$boardsdir/forum.control") || &fatal_error('cannot_open', "$boardsdir/forum.control", 1);     fopen( FORUMCONTROL, "<$boardsdir/forum.control" ) 
   @oldcontrols = <FORUMCONTROL>;       or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 
     @oldcontrols = <FORUMCONTROL>;
   my @newmods;     fclose(FORUMCONTROL); 
   foreach $boardline (@oldcontrols) {  
       chomp $boardline;     for my $boardline (@oldcontrols) { 
       if ($boardline ne "") {         chomp $boardline; 
           @newmods = ();         if ( $boardline ne q{} ) { 
           ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $cntpassword, $cnttotals, $cntattperms, $spare, $cntminageperms, $cntmaxageperms, $cntgenderperms) = split(/\|/, $boardline);             @newmods = (); 
           foreach (split(/, /, $cntmods)) {             @boardline = split /\|/xsm, $boardline; 
               if ($killmod ne $_) { push(@newmods, $_); }             foreach ( split /, /sm, $boardline[4] ) { 
           }                if ( $killmod ne $_ ) { push @newmods, $_; }
           $cntmods = join(", ", @newmods);             } 
           push(@boardcontrol, "$cntcat|$cntboard|$cntpic|$cntdescription|$cntmods|$cntmodgroups|$cnttopicperms|$cntreplyperms|$cntpollperms|$cntzero|$cntpassword|$cnttotals|$cntattperms|$spare|$cntminageperms|$cntmaxageperms|$cntgenderperms\n");             $boardline[4] = join q{, }, @newmods; 
       }             $newboardline = join q{|}, @boardline; 
   }             push @boardcontrol, $newboardline . "\n"; 
   seek FORUMCONTROL, 0, 0;         } 
   truncate FORUMCONTROL, 0;     } 
   @boardcontrol = &undupe(@boardcontrol);     @boardcontrol = undupe(@boardcontrol); 
   print FORUMCONTROL @boardcontrol;     fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) 
   fclose(FORUMCONTROL);       or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 
     print {FORUMCONTROL} @boardcontrol or croak "$croak{'print'} FORUMCONTROL";
     fclose(FORUMCONTROL);
     return;
} }
   
sub KillModeratorGroup { sub KillModeratorGroup {
   my $killmod = $_[0];     my ($killmod) = @_; 
   my ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $dummy, $dummy, $dummy, $cnttotals, @boardcontrol);     my ( @boardcontrol, @newmods, @boardline ); 
   fopen(FORUMCONTROL, "+<$boardsdir/forum.control") || &fatal_error('cannot_open', "$boardsdir/forum.control", 1);     fopen( FORUMCONTROL, "<$boardsdir/forum.control" ) 
   @oldcontrols = <FORUMCONTROL>;       or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 
     @oldcontrols = <FORUMCONTROL>;
   my @newmods;     fclose(FORUMCONTROL); 
   foreach $boardline (@oldcontrols) {  
       chomp $boardline;     foreach my $boardline (@oldcontrols) { 
       if ($boardline ne "") {         chomp $boardline; 
           @newmods = ();         if ( $boardline ne q{} ) { 
           ($cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $cntpassword, $cnttotals, $cntattperms, $spare, $cntminageperms, $cntmaxageperms, $cntgenderperms) = split(/\|/, $boardline);             @newmods = (); 
           foreach (split(/, /, $cntmodgroups)) {             @boardline = split /\|/xsm, $boardline; 
               if ($killmod ne $_) { push(@newmods, $_); }             foreach ( split /, /sm, $boardline[5] ) { 
           }                if ( $killmod ne $_ ) { push @newmods, $_; }
           $cntmodgroups = join(", ", @newmods);             } 
           push(@boardcontrol, "$cntcat|$cntboard|$cntpic|$cntdescription|$cntmods|$cntmodgroups|$cnttopicperms|$cntreplyperms|$cntpollperms|$cntzero|$cntpassword|$cnttotals|$cntattperms|$spare|$cntminageperms|$cntmaxageperms|$cntgenderperms\n");             $boardline[5] = join q{, }, @newmods; 
       }             $newboardline = join q{|}, @boardline; 
   }             push @boardcontrol, $newboardline . "\n"; 
   seek FORUMCONTROL, 0, 0;         } 
   truncate FORUMCONTROL, 0;     } 
   @boardcontrol = &undupe(@boardcontrol);     @boardcontrol = undupe(@boardcontrol); 
   print FORUMCONTROL @boardcontrol;     fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) 
   fclose(FORUMCONTROL);       or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 
     print {FORUMCONTROL} @boardcontrol or croak "$croak{'print'} FORUMCONTROL";
     fclose(FORUMCONTROL);
     return;
} }
   
sub LoadUserDisplay { sub LoadUserDisplay {
   my $user = $_[0];     my ($user) = @_; 
   if (exists ${$uid.$user}{'password'}) {    if ( exists ${ $uid . $user }{'password'} ) {
       if ($yyUDLoaded{$user}) { return 1; }        if ( $yyUDLoaded{$user} ) { return 1; }
   } else {     } 
       &LoadUser($user);     else { 
   }         LoadUser($user); 
   &LoadCensorList;     } 
     LoadCensorList();
   if (!$minlinkweb) { $minlinkweb = 0; }  
   ${$uid.$user}{'weburl'} = (${$uid.$user}{'weburl'} && (${$uid.$user}{'postcount'} >= $minlinkweb || ${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator')) ? qq~<a href="${$uid.$user}{'weburl'}" target="_blank">~ . ($sm ? $img{'website_sm'} : $img{'website'}) . '</a>' : '';     if ( !$minlinkweb ) { $minlinkweb = 0; } 
     ${ $uid . $user }{'weburl'} =
   $displayname = ${$uid.$user}{'realname'};       ( 
   if (${$uid.$user}{'signature'}) {         ${ $uid . $user }{'weburl'} 
       $message = ${$uid.$user}{'signature'};           && ( ${ $uid . $user }{'postcount'} >= $minlinkweb 
             || ${ $uid . $user }{'position'} eq 'Administrator' 
       if ($enable_ubbc) {             || ${ $uid . $user }{'position'} eq 'Mid Moderator' 
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }             || ${ $uid . $user }{'position'} eq 'Global Moderator' ) 
           &DoUBBC(1);       ) 
       }       ? qq~<a href="${$uid.$user}{'weburl'}" target="_blank">~ 
       . ( $sm ? $img{'website_sm'} : $img{'website'} ) . '</a>' 
       &ToChars($message);       : q{}; 
   
       ${$uid.$user}{'signature'} = &Censor($message);     $displayname = ${ $uid . $user }{'realname'}; 
     if ( ${ $uid . $user }{'signature'} ) {
       # use height like code boxes do. Set to 200px at > 15 newlines         $message = ${ $uid . $user }{'signature'}; 
       if (15 < ${$uid.$user}{'signature'} =~ /<br \/>|<tr>/g) {  
           ${$uid.$user}{'signature'} = qq~<div style="float: left; font-size: 10px; font-family: verdana, sans-serif; overflow: auto; max-height: 200px; height: 200px; width: 99%;">${$uid.$user}{'signature'}</div>~;         if ($enable_ubbc) { 
       } else {             enable_yabbc(); 
           ${$uid.$user}{'signature'} = qq~<div style="float: left; font-size: 10px; font-family: verdana, sans-serif; overflow: auto; max-height: 200px; width: 99%;">${$uid.$user}{'signature'}</div>~;             DoUBBC(1); 
       }        }
   }  
         ToChars($message);
   $themsnuser   = $user;  
   $themsnname   = ${$uid.$user}{'realname'};         ${ $uid . $user }{'signature'} = Censor($message); 
   $thegtalkuser = $user;  
   $thegtalkname = ${$uid.$user}{'realname'};         # use height like code boxes do. Set to 200px at > 15 newlines 
         if ( 15 < ${ $uid . $user }{'signature'} =~ /<br \/>|<tr>/gsm ) {
   if ($UseMenuType == 0) {             ${ $uid . $user }{'signature'} = 
       $yimimg = qq~<img src="$imagesdir/yim.gif" alt="${$uid.$user}{'yim'}" title="${$uid.$user}{'yim'}" border="0" />~;               qq~<div class="load_sig">${$uid.$user}{'signature'}</div>~; 
       $aimimg = qq~<img src="$imagesdir/aim.gif" alt="${$uid.$user}{'aim'}" title="${$uid.$user}{'aim'}" border="0" />~;         } 
       $skypeimg = qq~<img src="$imagesdir/skype.gif" alt="${$uid.$user}{'skype'}" title="${$uid.$user}{'skype'}" border="0" />~;         else { 
       $myspaceimg = qq~<img src="$imagesdir/myspace.gif" alt="${$uid.$user}{'myspace'}" title="${$uid.$user}{'myspace'}" border="0" />~;             ${ $uid . $user }{'signature'} = 
       $facebookimg = qq~<img src="$imagesdir/facebook.gif" alt="${$uid.$user}{'facebook'}" title="${$uid.$user}{'facebook'}" border="0" />~;               qq~<div class="load_sig_b">${$uid.$user}{'signature'}</div>~; 
       $msnimg = qq~<img src="$imagesdir/msn.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=setmsn;msnname=$themsnuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false" alt="$themsnname" title="$themsnname" border="0" />~;         } 
       $gtalkimg = qq~<img src="$imagesdir/gtalk2.gif" style="cursor: pointer" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false" alt="$thegtalkname" title="$thegtalkname" border="0" />~;     } 
       $icqimg = qq~<img src="http://web.icq.com/whitepages/online?icq=${$uid.$user}{'icq'}&#38;img=5" alt="${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" border="0" />~;  
   } elsif ($UseMenuType == 1) {  
       $yimimg = qq~<span class="imgwindowbg">YIM</span>~;  
       $aimimg = qq~<span class="imgwindowbg">AIM</span>~;  
       $skypeimg = qq~<span class="imgwindowbg">Skype/VoIP</span>~;  
       $myspaceimg = qq~<span class="imgwindowbg">MySpace</span>~;  
       $facebookimg = qq~<span class="imgwindowbg">Facebook</span>~;  
       $msnimg = qq~<span class="imgwindowbg" style="cursor: pointer" onclick="window.open('$scripturl?action=setmsn;msnname=$themsnuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false">MSN</span>~;  
       $gtalkimg = qq~<span class="imgwindowbg" style="cursor: pointer" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false">GTalk</span>~;  
       $icqimg   = qq~<span class="imgwindowbg">ICQ</span>~;  
   } else {  
       $yimimg = qq~<img src="$yyhtml_root/Buttons/$language/yim.png" alt="${$uid.$user}{'yim'}" title="${$uid.$user}{'yim'}" border="0" />~;  
       $aimimg = qq~<img src="$yyhtml_root/Buttons/$language/aim.png" alt="${$uid.$user}{'aim'}" title="${$uid.$user}{'aim'}" border="0" />~;  
       $skypeimg = qq~<img src="$yyhtml_root/Buttons/$language/skype.png" alt="${$uid.$user}{'skype'}" title="${$uid.$user}{'skype'}" border="0" />~;  
       $myspaceimg = qq~<img src="$yyhtml_root/Buttons/$language/myspace.png" alt="${$uid.$user}{'myspace'}" title="${$uid.$user}{'myspace'}" border="0" />~;  
       $facebookimg = qq~<img src="$yyhtml_root/Buttons/$language/facebook.png" alt="${$uid.$user}{'facebook'}" title="${$uid.$user}{'facebook'}" border="0" />~;  
       $msnimg = qq~<img src="$yyhtml_root/Buttons/$language/msn.png" style="cursor: pointer" onclick="window.open('$scripturl?action=setmsn;msnname=$themsnuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false" alt="$themsnname" title="$themsnname" border="0" />~;  
       $gtalkimg = qq~<img src="$yyhtml_root/Buttons/$language/gtalk.png" style="cursor: pointer" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$thegtalkuser','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false" alt="$thegtalkname" title="$thegtalkname" border="0" />~;  
       $icqimg = qq~<img src="$yyhtml_root/Buttons/$language/icq.png" alt="${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" border="0" />~;  
   }  
   
   $icqad{$user} = $icqad{$user} ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" target="_blank"><img src="$imagesdir/icqadd.gif" alt="${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" border="0" /></a>~ : '';  
   ${$uid.$user}{'icq'} = ${$uid.$user}{'icq'} ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" target="_blank">$icqimg</a>~ : '';  
   ${$uid.$user}{'aim'} = ${$uid.$user}{'aim'} ? qq~<a href="aim:goim?screenname=${$uid.$user}{'aim'}&#38;message=Hi.+Are+you+there?">$aimimg</a>~ : '';  
   ${$uid.$user}{'skype'} = ${$uid.$user}{'skype'} ? qq~<a href="javascript:void(window.open('callto://${$uid.$user}{'skype'}','skype','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'))">$skypeimg</a>~ : '';  
   ${$uid.$user}{'myspace'} = ${$uid.$user}{'myspace'} ? qq~<a href="http://www.myspace.com/${$uid.$user}{'myspace'}" target="_blank">$myspaceimg</a>~ : '';  
   ${$uid.$user}{'facebook'} = ${$uid.$user}{'facebook'} ? qq~<a href="http://www.facebook.com/~ . (${$uid.$user}{'facebook'} !~ /\D/ ? "profile.php?id=" : "") . qq~${$uid.$user}{'facebook'}" target="_blank">$facebookimg</a>~ : '';  
   ${$uid.$user}{'msn'} = ${$uid.$user}{'msn'}   ? $msnimg : '';  
   ${$uid.$user}{'gtalk'} = ${$uid.$user}{'gtalk'} ? $gtalkimg : '';  
   $yimon{$user} = $yimon{$user} ? qq~<img src="http://opi.yahoo.com/online?u=${$uid.$user}{'yim'}&#38;m=g&#38;t=0" border="0" alt="" />~ : '';  
   ${$uid.$user}{'yim'} = ${$uid.$user}{'yim'} ? qq~<a href="http://edit.yahoo.com/config/send_webmesg?.target=${$uid.$user}{'yim'}" target="_blank">$yimimg</a>~ : '';  
   
   if ($showgenderimage && ${$uid.$user}{'gender'}) {  
       ${$uid.$user}{'gender'} = ${$uid.$user}{'gender'} =~ m~Female~i ? 'female' : 'male';  
       ${$uid.$user}{'gender'} = ${$uid.$user}{'gender'} ? qq~$load_txt{'231'}: <img src="$imagesdir/${$uid.$user}{'gender'}.gif" border="0" alt="${$uid.$user}{'gender'}" title="${$uid.$user}{'gender'}" /><br />~ : '';  
   } else {  
       ${$uid.$user}{'gender'} = '';  
   }  
   
   if ($showusertext && ${$uid.$user}{'usertext'}) { # Censor the usertext and wrap it  
       ${$uid.$user}{'usertext'} = &WrapChars(&Censor(${$uid.$user}{'usertext'}),20);  
   } else {  
       ${$uid.$user}{'usertext'} = "";  
   }  
   
   # Create the userpic / avatar html  
   if ($showuserpic && $allowpics) {  
       ${$uid.$user}{'userpic'} ||= 'blank.gif';  
       ${$uid.$user}{'userpic'} = qq~<img src="~ .(${$uid.$user}{'userpic'} =~ m~\A[\s\n]*https?://~i ? ${$uid.$user}{'userpic'} : "$facesurl/${$uid.$user}{'userpic'}") . qq~" name="avatar_img_resize" alt="" border="0" style="display:none" /><br />~;  
   } else {  
       ${$uid.$user}{'userpic'} = '<br />';  
   }  
   
   &LoadMiniUser($user);     $thegtalkuser = $user; 
     $thegtalkname = ${ $uid . $user }{'realname'};
   
   $yyUDLoaded{$user} = 1;     if ( !$UseMenuType ) { 
   return 1;         $UseMenuType = $MenuType; 
     }
   
     get_micon();
   
     $yimimg      = SetImage( 'yim',      $UseMenuType );
     $aimimg      = SetImage( 'aim',      $UseMenuType );
     $skypeimg    = SetImage( 'skype',    $UseMenuType );
     $myspaceimg  = SetImage( 'myspace',  $UseMenuType );
     $facebookimg = SetImage( 'facebook', $UseMenuType );
     $gtalkimg    = SetImage( 'gtalk',    $UseMenuType );
     $icqimg      = SetImage( 'icq',      $UseMenuType );
     $twitterimg  = SetImage( 'twitter',  $UseMenuType );
     $youtubeimg  = SetImage( 'youtube',  $UseMenuType );
   
     $icqad{$user} =
       $icqad{$user}
       ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" target="_blank">$load_con{'icqadd'}</a>~
       : q{};
     $icqad{$user} =~ s/{yabb usericq}/${$uid.$user}{'icq'}/gsm;
   
     ${ $uid . $user }{'icq'} =
       ${ $uid . $user }{'icq'}
       ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" target="_blank">$icqimg</a>~
       : q{};
   
     ${ $uid . $user }{'aim'} =
       ${ $uid . $user }{'aim'}
       ? qq~<a href="aim:goim?screenname=${$uid.$user}{'aim'}&#38;message=Hi.+Are+you+there?">$aimimg</a>~
       : q{};
   
     ${ $uid . $user }{'skype'} =
       ${ $uid . $user }{'skype'}
       ? qq~<a href="javascript:void(window.open('callto://${$uid.$user}{'skype'}','skype','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'))">$skypeimg</a>~
       : q{};
   
     ${ $uid . $user }{'myspace'} =
       ${ $uid . $user }{'myspace'}
       ? qq~<a href="http://www.myspace.com/${$uid.$user}{'myspace'}" target="_blank">$myspaceimg</a>~
       : q{};
   
     ${ $uid . $user }{'facebook'} =
       ${ $uid . $user }{'facebook'}
       ? q~<a href="http://www.facebook.com/~
       . ( ${ $uid . $user }{'facebook'} !~ /\D/xsm ? 'profile.php?id=' : q{} )
       . qq~${$uid.$user}{'facebook'}" target="_blank">$facebookimg</a>~
       : q{};
   
     ${ $uid . $user }{'twitter'} =
       ${ $uid . $user }{'twitter'}
       ? qq~<a href="http://twitter.com/${$uid.$user}{'twitter'}" target="_blank">$twitterimg</a>~
       : q{};
   
     ${ $uid . $user }{'youtube'} =
       ${ $uid . $user }{'youtube'}
       ? qq~<a href="http://www.youtube.com/${$uid.$user}{'youtube'}" target="_blank">$youtubeimg</a>~
       : q{};
   
     ${ $uid . $user }{'gtalk'} = ${ $uid . $user }{'gtalk'} ? $gtalkimg : q{};
   
     $yimon{$user} =
       $yimon{$user}
       ? qq~<img src="http://opi.yahoo.com/online?u=${$uid.$user}{'yim'}&#38;m=g&#38;t=0" alt="" />~
       : q{};
   
     ${ $uid . $user }{'yim'} =
       ${ $uid . $user }{'yim'}
       ? qq~<a href="http://edit.yahoo.com/config/send_webmesg?.target=${$uid.$user}{'yim'}" target="_blank">$yimimg</a>~
       : q{};
   
     if ( $showgenderimage && ${ $uid . $user }{'gender'} ) {
         ${ $uid . $user }{'gender'} =
           ${ $uid . $user }{'gender'} =~ m/Female/ixsm ? 'female' : 'male';
         $genderTitle = ${ $uid . $user }{'gender'};
         ${ $uid . $user }{'gender'} =
           ${ $uid . $user }{'gender'}
           ? qq~$load_txt{'231'}: $load_con{'gender'}<br />~
           : q{};
         ${ $uid . $user }{'gender'} =~ s/{yabb gender}/$genderTitle/sm;
         ${ $uid . $user }{'gender'} =~
           s/{yabb genderTitle}/$load_txt{$genderTitle}/gsm;
     }
     else {
         ${ $uid . $user }{'gender'} = q{};
     }
   
     if ($showzodiac && ${ $uid . $user }{'bday'}) {
         require Sources::EventCalBirthdays;
         my ($user_bdmon, $user_bdday, undef ) = split /\//xsm, ${ $uid . $user }{'bday'} ;
         $zodiac = starsign($user_bdday, $user_bdmon);
         ${ $uid . $user }{'zodiac'} = qq~<span style="vertical-align: middle;">$zodiac_txt{'sign'}:</span> $zodiac<br />~;
     }
     else {
         ${ $uid . $user }{'zodiac'} = q{};
     }
   
     if ( $showusertext && ${ $uid . $user }{'usertext'} )
     {    # Censor the usertext and wrap it
         ${ $uid . $user }{'usertext'} =
           WrapChars( Censor( ${ $uid . $user }{'usertext'} ), 20 );
     }
     else {
         ${ $uid . $user }{'usertext'} = q{};
     }
   
     # Create the userpic / avatar html
     if ( $showuserpic && $allowpics ) {
         ${ $uid . $user }{'userpic'}