1############################################################################### 2# Load.pm # 3# $Date: 12.02.14 $ # 4############################################################################### 5# YaBB: Yet another Bulletin Board # 6# Open-Source Community Software for Webmasters # 7# Version: YaBB 2.6.11 # 8# Packaged: December 2, 2014 # 9# Distributed by: http://www.yabbforum.com # 10# =========================================================================== # 11# Copyright (c) 2000-2014 YaBB (www.yabbforum.com) - All Rights Reserved. # 12# Software by: The YaBB Development Team # 13# with assistance from the YaBB community. # 14############################################################################### 15use CGI::Carp qw(fatalsToBrowser); 16our $VERSION = '2.6.11'; 17 18$loadpmver = 'YaBB 2.6.11 $Revision: 1611 $'; 19 20sub LoadBoardControl { 21 $binboard = q{}; 22 $annboard = q{}; 23 24 fopen( FORUMCONTROL, "$boardsdir/forum.control" ) 25 or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 26 my @boardcontrols = <FORUMCONTROL>; 27 fclose(FORUMCONTROL); 28 $maxboards = $#boardcontrols; 29 30 foreach my $boardline (@boardcontrols) { 31 $boardline =~ s/[\r\n]//gxsm; # Built in chomp 32 my ( 33 $cntcat, $cntboard, $cntpic, 34 $cntdescription, $cntmods, $cntmodgroups, 35 $cnttopicperms, $cntreplyperms, $cntpollperms, 36 $cntzero, $cntmembergroups, $cntann, 37 $cntrbin, $cntattperms, $cntminageperms, 38 $cntmaxageperms, $cntgenderperms, $cntcanpost, 39 $cntparent, $rules, $rulestitle, 40 $rulesdesc, $rulescollapse, $brdpasswr, 41 $brdpassw, $cntbdrss, 42 ## Mod Hook 1 ## 43 ) = split /\|/xsm, $boardline; 44 ## create a global boards array 45 push @allboards, $cntboard; 46 47 $cntdescription =~ s/\&\ /\& /gxsm; 48 if ( substr( $cntmods, 0, 2 ) eq ', ' ) { 49 substr( $cntmods, 0, 2 ) = q{}; 50 } 51 if ( substr( $cntmodgroups, 0, 2 ) eq ', ' ) { 52 substr( $cntmodgroups, 0, 2 ) = q{}; 53 } 54 55 %{ $uid . $cntboard } = ( 56 'cat' => $cntcat, 57 'description' => $cntdescription, 58 'pic' => $cntpic, 59 'mods' => $cntmods, 60 'modgroups' => $cntmodgroups, 61 'topicperms' => $cnttopicperms, 62 'replyperms' => $cntreplyperms, 63 'pollperms' => $cntpollperms, 64 'zero' => $cntzero, 65 'membergroups' => $cntmembergroups, 66 'ann' => $cntann, 67 'rbin' => $cntrbin, 68 'attperms' => $cntattperms, 69 'minageperms' => $cntminageperms, 70 'maxageperms' => $cntmaxageperms, 71 'genderperms' => $cntgenderperms, 72 'canpost' => $cntcanpost, 73 'parent' => $cntparent, 74 'rules' => $rules, 75 'rulestitle' => $rulestitle, 76 'rulesdesc' => $rulesdesc, 77 'rulescollapse' => $rulescollapse, 78 'brdpasswr' => $brdpasswr, 79 'brdpassw' => $brdpassw, 80 'brdrss' => $cntbdrss, 81 ## Mod Hook 2 ## 82 ); 83 if ( $cntann == 1 ) { $annboard = $cntboard; } 84 if ( $cntrbin == 1 ) { $binboard = $cntboard; } 85 } 86 return; 87} 88 89sub LoadIMs { 90 return 91 if ( $iamguest 92 || $PM_level == 0 93 || ( $maintenance && !$iamadmin ) 94 || ( $PM_level == 2 && ( !$staff ) ) 95 || ( $PM_level == 4 && ( !$iamadmin && !$iamgmod && !$iamfmod ) ) 96 || ( $PM_level == 3 && ( !$iamadmin && !$iamgmod ) ) ); 97 98 if ( !exists ${$username}{'PMmnum'} ) { buildIMS( $username, 'load' ); } 99 100 my $imnewtext; 101 if ( ${$username}{'PMimnewcount'} == 1 ) { 102 $imnewtext = 103qq~<a href="$scripturl?action=imshow;caller=1;id=-1">1 $load_txt{'155'}</a>~; 104 } 105 elsif ( !${$username}{'PMimnewcount'} ) { $imnewtext = $load_txt{'nonew'}; } 106 else { 107 $imnewtext = 108qq~<a href="$scripturl?action=imshow;caller=1;id=-1">${$username}{'PMimnewcount'} $load_txt{'154'}</a>~; 109 } 110 111 if ( ${$username}{'PMmnum'} == 1 ) { 112 if ( ${$username}{'PMimnewcount'} == 1 ) { 113 $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'155b'}</a>~; 114 } 115 else { 116 $yyim = 117 qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'471'}</a>, $imnewtext~; 118 } 119 } 120 elsif ( !${$username}{'PMmnum'} && !${$username}{'PMimnewcount'} ) { 121 $yyim = 122 qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>~; 123 } 124 elsif ( ${$username}{'PMmnum'} == ${$username}{'PMimnewcount'} ) { 125 $yyim = qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'154b'}</a>~; 126 } 127 else { 128 $yyim = 129 qq~$load_txt{'152'} <a href="$scripturl?action=im">${$username}{'PMmnum'} $load_txt{'153'}</a>, $imnewtext~; 130 } 131 132 if ( !$user_ip && $iamadmin ) { 133 $yyim .= qq~<br /><b>$load_txt{'773'}</b>~; 134 } 135 return; 136} 137 138sub LoadCensorList { 139 opendir DIR, $langdir; 140 my @langDir = readdir DIR; 141 closedir DIR; 142 @lang = (); 143 foreach my $langitems ( sort { lc($a) cmp lc $b } @langDir ) { 144 chomp $langitems; 145 if ( ( $langitems ne q{.} ) 146 && ( $langitems ne q{..} ) 147 && ( $langitems ne q{.htaccess} ) 148 && ( $langitems ne q{index.html} ) ) 149 { 150 push @lang, $langitems; 151 } 152 } 153 154 if ( $#censored > 0 ) { 155 return; 156 } 157 elsif ( 158 scalar @lang == 1 159 && ( ( -s "$langdir/$language/censor.txt" ) < 3 160 || !-e "$langdir/$language/censor.txt" ) 161 ) 162 { 163 return; 164 } 165 for my $langd (@lang) { 166 if ( -e "$langdir/$langd/censor.txt" ) { 167 fopen( CENSOR, "$langdir/$langd/censor.txt" ); 168 while ( chomp( $buffer = <CENSOR> ) ) { 169 $buffer =~ s/\r(?=\n*)//gxsm; 170 if ( $buffer =~ m/\~/sm ) { 171 ( $tmpa, $tmpb ) = split /\~/xsm, $buffer; 172 $tmpc = 0; 173 } 174 else { 175 ( $tmpa, $tmpb ) = split /=/xsm, $buffer; 176 $tmpc = 1; 177 } 178 push @censored, [ $tmpa, $tmpb, $tmpc ]; 179 } 180 } 181 } 182 fclose(CENSOR); 183 return; 184} 185 186sub LoadUserSettings { 187 LoadBoardControl(); 188 $iamguest = $username eq 'Guest' ? 1 : 0; 189 if ( $username ne 'Guest' ) { 190 LoadUser($username); 191 if ( !$maintenance 192 || ${ $uid . $username }{'position'} eq 'Administrator' ) 193 { 194 $iammod = is_moderator($username); 195 if ( ${ $uid . $username }{'position'} eq 'Administrator' 196 || ${ $uid . $username }{'position'} eq 'Global Moderator' 197 || ${ $uid . $username }{'position'} eq 'Mid Moderator' 198 || $iammod ) 199 { 200 $staff = 1; 201 } 202 else { $staff = 0; } 203 $sessionvalid = 1; 204 if ( $sessions == 1 && $staff == 1 ) { 205 $cursession = encode_password($user_ip); 206 chomp $cursession; 207 if ( ${ $uid . $username }{'session'} ne $cursession 208 || ${ $uid . $username }{'session'} ne $cookiesession ) 209 { 210 $sessionvalid = 0; 211 } 212 } 213 $spass = ${ $uid . $username }{'password'}; 214 215 # Make sure that if the password doesn't match you get FULLY Logged out 216 if ( $spass && $spass ne $password && $action ne 'logout' ) { 217 $yySetLocation = 218 $guestaccess ? qq~$scripturl~ : qq~$scripturl?action=login~; 219 UpdateCookie('delete'); 220 redirectexit(); 221 } 222 223 $iamadmin = 224 ( ${ $uid . $username }{'position'} eq 'Administrator' 225 && $sessionvalid == 1 ) ? 1 : 0; 226 $iamgmod = 227 ( ${ $uid . $username }{'position'} eq 'Global Moderator' 228 && $sessionvalid == 1 ) ? 1 : 0; 229 $iamfmod = 230 ( ${ $uid . $username }{'position'} eq 'Mid Moderator' 231 && $sessionvalid == 1 ) ? 1 : 0; 232 if ( $sessionvalid == 1 ) { 233 ${ $uid . $username }{'session'} = $cursession; 234 } 235 CalcAge( $username, 'calc' ); 236 237 # Set the order how Topic summaries are displayed 238 if ( !$adminscreen && $ttsureverse ) { 239 $ttsreverse = ${ $uid . $username }{'reversetopic'}; 240 } 241 return; 242 } 243 } 244 245 FormatUserName(q{}); 246 UpdateCookie('delete'); 247 $username = 'Guest'; 248 $iamguest = '1'; 249 $iamadmin = q{}; 250 $iamgmod = q{}; 251 $iamfmod = q{}; 252 $password = q{}; 253 local $ENV{'HTTP_COOKIE'} = q{}; 254 $yyim = q{}; 255 $yyuname = q{}; 256 return; 257} 258 259sub FormatUserName { 260 my ($user) = @_; 261 return if $useraccount{$user}; 262 $useraccount{$user} = $do_scramble_id ? cloak($user) : $user; 263 return; 264} 265 266sub LoadUser { 267 my ( $user, $userextension ) = @_; 268 return 1 if exists ${ $uid . $user }{'realname'}; 269 return 0 if $user eq q{} || $user eq 'Guest'; 270 271 if ( !$userextension ) { $userextension = 'vars'; } 272 if ( ( $regtype == 1 || $regtype == 2 ) && -e "$memberdir/$user.pre" ) { 273 $userextension = 'pre'; 274 } 275 elsif ( $regtype == 1 && -e "$memberdir/$user.wait" ) { 276 $userextension = 'wait'; 277 } 278 279 if ( -e "$memberdir/$user.$userextension" ) { 280 if ( $user ne $username ) { 281 fopen( LOADUSER, "$memberdir/$user.$userextension" ) 282 or fatal_error( 'cannot_open', "$memberdir/$user.$userextension", 283 1 ); 284 my @settings = <LOADUSER>; 285 fclose(LOADUSER); 286 foreach (@settings) { 287 if ( $_ =~ /'(.*?)',"(.*?)"/xsm ) { 288 ${ $uid . $user }{$1} = $2; 289 } 290 } 291 } 292 else { 293 fopen( LOADUSER, "<$memberdir/$user.$userextension" ) 294 or fatal_error( 'cannot_open', 295 "$memberdir/$user.$userextension load 1", 1 ); 296 my @settings = <LOADUSER>; 297 fclose(LOADUSER); 298 for my $i ( 0 .. ( @settings - 1 ) ) { 299 if ( $settings[$i] =~ /'(.*?)',"(.*?)"/xsm ) { 300 ${ $uid . $user }{$1} = $2; 301 if ( $1 eq 'lastonline' 302 && $INFO{'action'} ne 'login2' 303 && !${ $uid . $user }{'stealth'} ) 304 { 305 ${ $uid . $user }{$1} = $date; 306 $settings[$i] = qq~'lastonline',"$date"\n~; 307 } 308 } 309 } 310 if ( scalar @settings != 0 ) { 311 fopen( LOADUSER, ">$memberdir/$user.$userextension" ) 312 or fatal_error( 'cannot_open', 313 "$memberdir/$user.$userextension load2", 1 ); 314 print {LOADUSER} @settings or croak "$croak{'print'} LOADUSER"; 315 fclose(LOADUSER); 316 } 317 else { 318 fatal_error( 'missingvars', "$memberdir/$user.$userextension", 319 1 ); 320 } 321 } 322 323 ToChars( ${ $uid . $user }{'realname'} ); 324 FormatUserName($user); 325 LoadMiniUser($user); 326 327 return 1; 328 } 329 330 return 0; # user not found 331} 332 333sub is_moderator { 334 my ( $user, $brd ) = @_; 335 my @checkboards; 336 if ($brd) { @checkboards = ($brd); } 337 else { @checkboards = @allboards; } 338 339 foreach (@checkboards) { 340 341 # check if user is in the moderator list 342 foreach ( split /, ?/sm, ${ $uid . $_ }{'mods'} ) { 343 if ( $_ eq $user ) { return 1; } 344 } 345 346 # check if user is member of a moderatorgroup 347 foreach my $testline ( split /, /sm, ${ $uid . $_ }{'modgroups'} ) { 348 if ( $testline eq ${ $uid . $user }{'position'} ) { return 1; } 349 350 foreach ( split /,/xsm, ${ $uid . $user }{'addgroups'} ) { 351 if ( $testline eq $_ ) { return 1; } 352 } 353 } 354 } 355 return 0; 356} 357 358sub is_moderator_b { 359 my ($user) = @_; 360 $mybrds = q{ }; 361 362 foreach my $i (@allboards) { 363 364 # check if user is in the moderator list 365 foreach ( split /, ?/sm, ${ $uid . $i }{'mods'} ) { 366 if ( $_ eq $user ) { 367 get_forum_master(); 368 ( $boardname, $boardperms, $boardview ) = 369 split /\|/xsm, $board{$i}; 370 371 $mybrds .= qq~$boardname<br />~; 372 return 1; 373 } 374 } 375 } 376 377 return 0; 378} 379 380sub KillModerator { 381 my ($killmod) = @_; 382 my ( @boardcontrol, @newmods, @boardline ); 383 fopen( FORUMCONTROL, "<$boardsdir/forum.control" ) 384 or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 385 @oldcontrols = <FORUMCONTROL>; 386 fclose(FORUMCONTROL); 387 388 for my $boardline (@oldcontrols) { 389 chomp $boardline; 390 if ( $boardline ne q{} ) { 391 @newmods = (); 392 @boardline = split /\|/xsm, $boardline; 393 foreach ( split /, /sm, $boardline[4] ) { 394 if ( $killmod ne $_ ) { push @newmods, $_; } 395 } 396 $boardline[4] = join q{, }, @newmods; 397 $newboardline = join q{|}, @boardline; 398 push @boardcontrol, $newboardline . "\n"; 399 } 400 } 401 @boardcontrol = undupe(@boardcontrol); 402 fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) 403 or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 404 print {FORUMCONTROL} @boardcontrol or croak "$croak{'print'} FORUMCONTROL"; 405 fclose(FORUMCONTROL); 406 return; 407} 408 409sub KillModeratorGroup { 410 my ($killmod) = @_; 411 my ( @boardcontrol, @newmods, @boardline ); 412 fopen( FORUMCONTROL, "<$boardsdir/forum.control" ) 413 or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 414 @oldcontrols = <FORUMCONTROL>; 415 fclose(FORUMCONTROL); 416 417 foreach my $boardline (@oldcontrols) { 418 chomp $boardline; 419 if ( $boardline ne q{} ) { 420 @newmods = (); 421 @boardline = split /\|/xsm, $boardline; 422 foreach ( split /, /sm, $boardline[5] ) { 423 if ( $killmod ne $_ ) { push @newmods, $_; } 424 } 425 $boardline[5] = join q{, }, @newmods; 426 $newboardline = join q{|}, @boardline; 427 push @boardcontrol, $newboardline . "\n"; 428 } 429 } 430 @boardcontrol = undupe(@boardcontrol); 431 fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) 432 or fatal_error( 'cannot_open', "$boardsdir/forum.control", 1 ); 433 print {FORUMCONTROL} @boardcontrol or croak "$croak{'print'} FORUMCONTROL"; 434 fclose(FORUMCONTROL); 435 return; 436} 437 438sub LoadUserDisplay { 439 my ($user) = @_; 440 if ( exists ${ $uid . $user }{'password'} ) { 441 if ( $yyUDLoaded{$user} ) { return 1; } 442 } 443 else { 444 LoadUser($user); 445 } 446 LoadCensorList(); 447 448 if ( !$minlinkweb ) { $minlinkweb = 0; } 449 ${ $uid . $user }{'weburl'} = 450 ( 451 ${ $uid . $user }{'weburl'} 452 && ( ${ $uid . $user }{'postcount'} >= $minlinkweb 453 || ${ $uid . $user }{'position'} eq 'Administrator' 454 || ${ $uid . $user }{'position'} eq 'Mid Moderator' 455 || ${ $uid . $user }{'position'} eq 'Global Moderator' ) 456 ) 457 ? qq~<a href="${$uid.$user}{'weburl'}" target="_blank">~ 458 . ( $sm ? $img{'website_sm'} : $img{'website'} ) . '</a>' 459 : q{}; 460 461 $displayname = ${ $uid . $user }{'realname'}; 462 if ( ${ $uid . $user }{'signature'} ) { 463 $message = ${ $uid . $user }{'signature'}; 464 465 if ($enable_ubbc) { 466 enable_yabbc(); 467 DoUBBC(1); 468 } 469 470 ToChars($message); 471 472 ${ $uid . $user }{'signature'} = Censor($message); 473 474 # use height like code boxes do. Set to 200px at > 15 newlines 475 if ( 15 < ${ $uid . $user }{'signature'} =~ /<br \/>|<tr>/gsm ) { 476 ${ $uid . $user }{'signature'} = 477 qq~<div class="load_sig">${$uid.$user}{'signature'}</div>~; 478 } 479 else { 480 ${ $uid . $user }{'signature'} = 481 qq~<div class="load_sig_b">${$uid.$user}{'signature'}</div>~; 482 } 483 } 484 485 $thegtalkuser = $user; 486 $thegtalkname = ${ $uid . $user }{'realname'}; 487 488 if ( !$UseMenuType ) { 489 $UseMenuType = $MenuType; 490 } 491 492 get_micon(); 493 494 $yimimg = SetImage( 'yim', $UseMenuType ); 495 $aimimg = SetImage( 'aim', $UseMenuType ); 496 $skypeimg = SetImage( 'skype', $UseMenuType ); 497 $myspaceimg = SetImage( 'myspace', $UseMenuType ); 498 $facebookimg = SetImage( 'facebook', $UseMenuType ); 499 $gtalkimg = SetImage( 'gtalk', $UseMenuType ); 500 $icqimg = SetImage( 'icq', $UseMenuType ); 501 $twitterimg = SetImage( 'twitter', $UseMenuType ); 502 $youtubeimg = SetImage( 'youtube', $UseMenuType ); 503 504 $icqad{$user} = 505 $icqad{$user} 506 ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" target="_blank">$load_con{'icqadd'}</a>~ 507 : q{}; 508 $icqad{$user} =~ s/{yabb usericq}/${$uid.$user}{'icq'}/gsm; 509 510 ${ $uid . $user }{'icq'} = 511 ${ $uid . $user }{'icq'} 512 ? qq~<a href="http://web.icq.com/${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" target="_blank">$icqimg</a>~ 513 : q{}; 514 515 ${ $uid . $user }{'aim'} = 516 ${ $uid . $user }{'aim'} 517 ? qq~<a href="aim:goim?screenname=${$uid.$user}{'aim'}&message=Hi.+Are+you+there?">$aimimg</a>~ 518 : q{}; 519 520 ${ $uid . $user }{'skype'} = 521 ${ $uid . $user }{'skype'} 522 ? qq~<a href="javascript:void(window.open('callto://${$uid.$user}{'skype'}','skype','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'))">$skypeimg</a>~ 523 : q{}; 524 525 ${ $uid . $user }{'myspace'} = 526 ${ $uid . $user }{'myspace'} 527 ? qq~<a href="http://www.myspace.com/${$uid.$user}{'myspace'}" target="_blank">$myspaceimg</a>~ 528 : q{}; 529 530 ${ $uid . $user }{'facebook'} = 531 ${ $uid . $user }{'facebook'} 532 ? q~<a href="http://www.facebook.com/~ 533 . ( ${ $uid . $user }{'facebook'} !~ /\D/xsm ? 'profile.php?id=' : q{} ) 534 . qq~${$uid.$user}{'facebook'}" target="_blank">$facebookimg</a>~ 535 : q{}; 536 537 ${ $uid . $user }{'twitter'} = 538 ${ $uid . $user }{'twitter'} 539 ? qq~<a href="http://twitter.com/${$uid.$user}{'twitter'}" target="_blank">$twitterimg</a>~ 540 : q{}; 541 542 ${ $uid . $user }{'youtube'} = 543 ${ $uid . $user }{'youtube'} 544 ? qq~<a href="http://www.youtube.com/${$uid.$user}{'youtube'}" target="_blank">$youtubeimg</a>~ 545 : q{}; 546 547 ${ $uid . $user }{'gtalk'} = ${ $uid . $user }{'gtalk'} ? $gtalkimg : q{}; 548 549 $yimon{$user} = 550 $yimon{$user} 551 ? qq~<img src="http://opi.yahoo.com/online?u=${$uid.$user}{'yim'}&m=g&t=0" alt="" />~ 552 : q{}; 553 554 ${ $uid . $user }{'yim'} = 555 ${ $uid . $user }{'yim'} 556 ? qq~<a href="http://edit.yahoo.com/config/send_webmesg?.target=${$uid.$user}{'yim'}" target="_blank">$yimimg</a>~ 557 : q{}; 558 559 if ( $showgenderimage && ${ $uid . $user }{'gender'} ) { 560 ${ $uid . $user }{'gender'} = 561 ${ $uid . $user }{'gender'} =~ m/Female/ixsm ? 'female' : 'male'; 562 $genderTitle = ${ $uid . $user }{'gender'}; 563 ${ $uid . $user }{'gender'} = 564 ${ $uid . $user }{'gender'} 565 ? qq~$load_txt{'231'}: $load_con{'gender'}<br />~ 566 : q{}; 567 ${ $uid . $user }{'gender'} =~ s/{yabb gender}/$genderTitle/sm; 568 ${ $uid . $user }{'gender'} =~ 569 s/{yabb genderTitle}/$load_txt{$genderTitle}/gsm; 570 } 571 else { 572 ${ $uid . $user }{'gender'} = q{}; 573 } 574 575 if ($showzodiac && ${ $uid . $user }{'bday'}) { 576 require Sources::EventCalBirthdays; 577 my ($user_bdmon, $user_bdday, undef ) = split /\//xsm, ${ $uid . $user }{'bday'} ; 578 $zodiac = starsign($user_bdday, $user_bdmon); 579 ${ $uid . $user }{'zodiac'} = qq~<span style="vertical-align: middle;">$zodiac_txt{'sign'}:</span> $zodiac<br />~; 580 } 581 else { 582 ${ $uid . $user }{'zodiac'} = q{}; 583 } 584 585 if ( $showusertext && ${ $uid . $user }{'usertext'} ) 586 { # Censor the usertext and wrap it 587 ${ $uid . $user }{'usertext'} = 588 WrapChars( Censor( ${ $uid . $user }{'usertext'} ), 20 ); 589 } 590 else { 591 ${ $uid . $user }{'usertext'} = q{}; 592 } 593 594 # Create the userpic / avatar html 595 if ( $showuserpic && $allowpics ) { 596 ${ $uid . $user }{'userpic'} ||= $my_blank_avatar; 597 ${ $uid . $user }{'userpic'} = q~<img src="~ 598 . ( 599 ${ $uid . $user }{'userpic'} =~ m/\A[\s\n]*https?:\/\//ism 600 ? ${ $uid . $user }{'userpic'} 601 : ( $default_avatar 602 && ${ $uid . $user }{'userpic'} eq $my_blank_avatar ) 603 ? "$imagesdir/$default_userpic" 604 : "$facesurl/${$uid.$user}{'userpic'}" 605 ) . q~" id="avatar_img_resize" alt="" style="display:none" />~; 606 if ( !$iamguest ) { 607 ${ $uid . $user }{'userpic'} = 608qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}">${ $uid . $user }{'userpic'}</a>~; 609 } 610 ${ $uid . $user }{'userpic'} .= q~<br />~; 611 } 612 else { 613 ${ $uid . $user }{'userpic'} = q~<br />~; 614 } 615 616 LoadMiniUser($user); 617 618 $yyUDLoaded{$user} = 1; 619 return 1; 620} 621 622sub LoadMiniUser { 623 my ($user) = @_; 624 my $load = q{}; 625 my $key = q{}; 626 $g = 0; 627 my $dg = 0; 628 my $tempgroup; 629 my $bold = 0; 630 631 $tempgroupcheck = ${ $uid . $user }{'position'} || q{}; 632 633 my @memstat = (); 634 if ( exists $Group{$tempgroupcheck} && $tempgroupcheck ne q{} ) { 635 #( 636 # $title, $stars, $starpic, $color, 637 # $noshow, $viewperms, $topicperms, $replyperms, 638 # $pollperms, $attachperms 639 #) 640 @memstat = split /\|/xsm, $Group{$tempgroupcheck}; 641 $temptitle = $memstat[0]; 642 $tempgroup = $Group{$tempgroupcheck}; 643 if ( $memstat[4] == 0 ) { $bold = 1; } 644 $memberunfo{$user} = $tempgroupcheck; 645 } 646 elsif ( $moderators{$user} ) { 647 @memstat = split /\|/xsm, $Group{'Moderator'}; 648 $temptitle = $memstat[0]; 649 $tempgroup = $Group{'Moderator'}; 650 $memberunfo{$user} = $tempgroupcheck; 651 } 652 elsif ( exists $NoPost{$tempgroupcheck} && $tempgroupcheck ne q{} ) { 653 @memstat = split /\|/xsm, $NoPost{$tempgroupcheck}; 654 $temptitle = $memstat[0]; 655 $tempgroup = $NoPost{$tempgroupcheck}; 656 $memberunfo{$user} = $tempgroupcheck; 657 } 658 659 if ( !$tempgroup ) { 660 foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) { 661 if ( ${ $uid . $user }{'postcount'} >= $postamount ) { 662 @memstat = split /\|/xsm, $Post{$postamount}; 663 $tempgroup = $Post{$postamount}; 664 last; 665 } 666 } 667 $memberunfo{$user} = $memstat[0]; 668 } 669 670 if ( $memstat[4] == 1 ) { 671 $temptitle = $memstat[0]; 672 foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) { 673 if ( ${ $uid . $user }{'postcount'} > $postamount ) { 674 @memstat = split /\|/xsm, $Post{$postamount}, 5; 675 last; 676 } 677 } 678 } 679 680 if ( !$tempgroup ) { 681 $temptitle = 'no group'; 682 @memstat = ( q{}, 0, q{}, q{}, 1, q{}, q{}, q{}, q{}, q{} ); 683 } 684 685# The following puts some new has variables in if this user is the user browsing the board 686 if ( $user eq $username ) { 687 if ($tempgroup) { 688 ( 689 undef, undef, undef, undef, 690 undef, $viewperms, $topicperms, $replyperms, 691 $pollperms, $attachperms 692 ) = split /\|/xsm, $tempgroup; 693 } 694 ${ $uid . $user }{'perms'} = 695 "$viewperms|$topicperms|$replyperms|$pollperms|$attachperms"; 696 } 697 698 $userlink = ${ $uid . $user }{'realname'} || $user; 699 $userlink = qq~<b>$userlink</b>~; 700 if ( !$scripturl ) { $scripturl = qq~$boardurl/$yyexec.$yyext~; } 701 if ( $bold != 1 ) { $memberinfo{$user} = qq~$memstat[0]~; } 702 else { $memberinfo{$user} = qq~<b>$memstat[0]</b>~; } 703 704 if ( $memstat[3] ne q{} && !$iamguest ) { 705 $link{$user} = 706qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}" style="color:$memstat[3];">$userlink</a>~; 707 $format{$user} = qq~<span style="color: $memstat[3];">$userlink</span>~; 708 $format_unbold{$user} = 709 qq~<span style="color: $memstat[3];">${$uid.$user}{'realname'}</span>~; 710 $col_title{$user} = 711 qq~<span style="color: $memstat[3];">$memberinfo{$user}</span>~; 712 } 713 elsif ( $iamguest ) { 714 if ( $memstat[3] ne q{} ) { 715 $link{$user} = 716qq~<span style="color:$memstat[3];">$userlink</span>~; 717 $format{$user} = qq~<span style="color: $memstat[3];">$userlink</span>~; 718 $format_unbold{$user} = 719 qq~<span style="color: $memstat[3];">${$uid.$user}{'realname'}</span>~; 720 $col_title{$user} = 721 qq~<span style="color: $memstat[3];">$memberinfo{$user}</span>~; 722 } 723 else { 724 $link{$user} = qq~$userlink~; 725 $format{$user} = qq~$userlink~; 726 $format_unbold{$user} = qq~${$uid.$user}{'realname'}~; 727 $col_title{$user} = qq~$memberinfo{$user}~; 728 } 729 } 730 else { 731 $link{$user} = 732qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}">$userlink</a>~; 733 $format{$user} = qq~$userlink~; 734 $format_unbold{$user} = qq~${$uid.$user}{'realname'}~; 735 $col_title{$user} = qq~$memberinfo{$user}~; 736 } 737 $addmembergroup{$user} = '<br />'; 738 for my $addgrptitle ( split /,/xsm, ${ $uid . $user }{'addgroups'} ) { 739 for my $key ( sort { $a <=> $b } keys %NoPost ) { 740 ( 741 $atitle, undef, undef, undef, 742 $anoshow, $aviewperms, $atopicperms, $areplyperms, 743 $apollperms, $aattachperms 744 ) = split /\|/xsm, $NoPost{$key}; 745 if ( $addgrptitle eq $key && $atitle ne $memstat[0] ) { 746 if ( $user eq $username && !$iamadmin ) { 747 if ( $aviewperms == 1 ) { $viewperms = 1; } 748 if ( $atopicperms == 1 ) { $topicperms = 1; } 749 if ( $areplyperms == 1 ) { $replyperms = 1; } 750 if ( $apollperms == 1 ) { $pollperms = 1; } 751 if ( $aattachperms == 1 ) { $attachperms = 1; } 752 ${ $uid . $user }{'perms'} = 753"$viewperms|$topicperms|$replyperms|$pollperms|$attachperms"; 754 } 755 if ( 756 $anoshow 757 && ( $iamadmin 758 || ( $iamgmod && $gmod_access2{'profileAdmin'} ) ) 759 ) 760 { 761 $addmembergroup{$user} .= qq~($atitle)<br />~; 762 } 763 elsif ( !$anoshow ) { 764 $addmembergroup{$user} .= qq~$atitle<br />~; 765 } 766 } 767 } 768 } 769 $addmembergroup{$user} =~ s/<br \/>\Z//sm; 770 771 if ( $username eq 'Guest' ) { $memberunfo{$user} = 'Guest'; } 772 773 $topicstart{$user} = q{}; 774 $viewnum = q{}; 775 if ( $INFO{'num'} || $FORM{'threadid'} && $user eq $username ) { 776 if ( $INFO{'num'} ) { 777 $viewnum = $INFO{'num'}; 778 } 779 elsif ( $FORM{'threadid'} ) { 780 $viewnum = $FORM{'threadid'}; 781 } 782 if ( $viewnum =~ m{/}xsm ) { 783 ( $viewnum, undef ) = split /\//xsm, $viewnum; 784 } 785 786 # No need to open the message file so many times. 787 # Opening it once is enough to do the access checks. 788 if ( !$topicstarter ) { 789 if ( -e "$datadir/$viewnum.txt" ) { 790 if ( !ref $thread_arrayref{$viewnum} ) { 791 fopen( TOPSTART, "$datadir/$viewnum.txt" ); 792 @{ $thread_arrayref{$viewnum} } = <TOPSTART>; 793 fclose(TOPSTART); 794 } 795 ( undef, undef, undef, undef, $topicstarter, undef ) = 796 split /\|/xsm, ${ $thread_arrayref{$viewnum} }[0], 6; 797 } 798 } 799 800 if ( $user eq $topicstarter ) { $topicstart{$user} = 'Topic Starter'; } 801 } 802 $memberaddgroup{$user} = ${ $uid . $user }{'addgroups'}; 803 804 my $starnum = $memstat[1]; 805 my $memberstartemp = q{}; 806 if ( $memstat[2] !~ /\//xsm ) { $starpic = "$imagesdir/$memstat[2]"; } 807 while ( $starnum-- > 0 ) { 808 $memberstartemp .= qq~<img src="$starpic" alt="*" />~; 809 } 810 $memberstar{$user} = $memberstartemp ? "$memberstartemp<br />" : q{}; 811 return; 812} 813 814sub QuickLinks { 815 my ( $user, $online ) = @_; 816 my $lastonline; 817 if ($iamguest) { 818 return ( $online ? $format_unbold{$user} : $format{$user} ); 819 } 820 821 if ( $iamadmin || $iamgmod || $lastonlineinlink ) { 822 if ( ${ $uid . $user }{'lastonline'} ) { 823 $lastonline = abs( $date - ${ $uid . $user }{'lastonline'} ); 824 my $days = int( $lastonline / 86400 ); 825 my $hours = sprintf '%02d', 826 int( ( $lastonline - ( $days * 86400 ) ) / 3600 ); 827 my $mins = sprintf 828 '%02d', 829 int( 830 ( $lastonline - ( $days * 86400 ) - ( $hours * 3600 ) ) / 60 ); 831 my $secs = sprintf 832 '%02d', 833 ( $lastonline - 834 ( $days * 86400 ) - 835 ( $hours * 3600 ) - 836 ( $mins * 60 ) ); 837 if ( !$mins ) { 838 $lastonline = "00:00:$secs"; 839 } 840 elsif ( !$hours ) { 841 $lastonline = "00:$mins:$secs"; 842 } 843 elsif ( !$days ) { 844 $lastonline = "$hours:$mins:$secs"; 845 } 846 else { 847 $lastonline = "$days $maintxt{'11'} $hours:$mins:$secs"; 848 } 849 $lastonline = 850 qq~ title="$maintxt{'10'} $lastonline $maintxt{'12'}."~; 851 } 852 else { 853 $lastonline = qq~ title="$maintxt{'13'}."~; 854 } 855 } 856 my $quicklinks; 857 if ($usertools) { 858 $qlcount++; 859 my $modcol = is_moderator_b($user); 860 if ( $modcol == 1 ) { 861 @memstats = split /\|/xsm, $Group{'Moderator'}; 862 } 863 my $display = 'display:inline'; 864 if ( $ENV{'HTTP_USER_AGENT'} =~ /opera/ism || $ENV{'HTTP_USER_AGENT'} =~ /firefox/ism ) { 865 $display = 'display:inline-block'; 866 } 867 868 $quicklinks = qq~<div style="position:relative;$display"> 869 <ul id="$useraccount{$user}$qlcount" class="QuickLinks" onmouseover="keepLinks('$useraccount{$user}$qlcount')" onmouseout="TimeClose('$useraccount{$user}$qlcount')"> 870 <li>~ 871 . userOnLineStatus($user) . qq~</li>\n~; 872 if ( $user ne $username ) { 873 $quicklinks .= 874qq~ <li><a href="$scripturl?action=viewprofile;username=$useraccount{$user}">$maintxt{'2'} ${$uid.$user}{'realname'}$maintxt{'3'}</a></li>\n~; 875 CheckUserPM_Level($user); 876 if ( 877 $PM_level == 1 878 || ( $PM_level == 2 && $UserPM_Level{$user} > 1 && $staff ) 879 || ( $PM_level == 3 880 && $UserPM_Level{$user} == 4 881 && ( $iamadmin || $iamgmod || $iamfmod ) ) 882 || ( $PM_level == 4 883 && $UserPM_Level{$user} == 3 884 && ( $iamadmin || $iamgmod ) ) 885 ) 886 { 887 $quicklinks .= 888qq~ <li><a href="$scripturl?action=imsend;to=$useraccount{$user}">$maintxt{'0'} ${$uid.$user}{'realname'}</a></li>\n~; 889 } 890 if ( !${ $uid . $user }{'hidemail'} || $iamadmin ) { 891 $quicklinks .= ' <li>' 892 . enc_eMail( 893 "$maintxt{'1'} ${$uid.$user}{'realname'}", 894 ${ $uid . $user }{'email'}, 895 q{}, q{}, 1 896 ) . "</li>\n"; 897 } 898 899 if ( !%mybuddie ) { loadMyBuddy(); } 900 if ( $buddyListEnabled && !$mybuddie{$user} ) { 901 $quicklinks .= 902qq~ <li><a href="$scripturl?action=addbuddy;name=$useraccount{$user}">$maintxt{'4'} ${$uid.$user}{'realname'} $maintxt{'5'}</a></li>\n~; 903 } 904 905 } 906 else { 907 908 $quicklinks .= 909qq~ <li><a href="$scripturl?action=viewprofile;username=$useraccount{$user}">$maintxt{'6'}</a></li>\n~; 910 } 911 $quicklinks .= 912qq~ </ul><a href="javascript:quickLinks('$useraccount{$user}$qlcount')"$lastonline>~; 913 $quicklinks .= $online ? $format_unbold{$user} : $format{$user}; 914 $quicklinks .= q~</a></div>~; 915 } 916 else { 917 $quicklinks = 918qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$user}"$lastonline>~ 919 . ( $online ? $format_unbold{$user} : $format{$user} ) 920 . q~</a>~; 921 } 922 923 return $quicklinks; 924} 925 926sub LoadTools { 927 my ( $where, @buttons ) = @_; 928 929 # Load Icon+Text for tool drop downs 930 my @tools; 931 932 if ( !%tmpimg ) { %tmpimg = %img; } 933 require Sources::Menu; 934 935 foreach my $i ( 0 .. $#buttons ) { 936 $tools[$i] = SetImage( $buttons[$i], 3 ); 937 } 938 939 foreach my $i ( 0 .. $#tools ) { 940 my ( $img_url, $img_txt ) = split /\|/xsm, $tools[$i]; 941 $tools[$i] = 942qq~[tool=$buttons[$i]]<div class="toolbutton_a" style="background-image: url($img_url)">$img_txt</div>[/tool]~; 943 } 944 945 foreach my $i ( 0 .. $#tools ) { 946 $img{ $buttons[$i] } = $tools[$i]; 947 } 948 return; 949} 950 951sub MakeTools { 952 my ( $counter, $text, $template ) = @_; 953 my $list_item = '</li><li>'; 954 $template = qq~<li>$template</li>~; 955 $template =~ s/\|\|\|/$list_item/gsm; 956 $template =~ s/<li>[\s]*<\/li>//gsm; 957 if ( $MenuType == 1 ) { 958 $template =~ s/\Q$menusep//gsm; 959 } 960 961 my $tools_template = $template 962 ? qq~ 963 <div class="post_tools_a"> 964 <a href="javascript:quickLinks('threadtools$counter')">$text</a> 965 </div> 966 </td> 967 <td class="center bottom" style="padding:0px; width:0"> 968 <div class="right cursor toolbutton_b"> 969 <ul class="post_tools_menu" id="threadtools$counter" onmouseover="keepLinks('threadtools$counter')" onmouseout="TimeClose('threadtools$counter')"> 970 $template 971 </ul> 972 </div> 973 ~ 974 : qq~<div class="post_tools_a">$load_con{'actionslock'}</div></td><td class="center bottom" style="padding:0px; width:0">~; 975 $tools_template =~ s/{yabb actionlock}/$maintxt{'64'}/gsm; 976 977 return $tools_template; 978} 979 980sub LoadCookie { 981 foreach ( split /; /sm, $ENV{'HTTP_COOKIE'} ) { 982 $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C', hex($1))/egxsm; 983 ( $cookie, $value ) = split /=/xsm; 984 $yyCookies{$cookie} = $value; 985 } 986 if ( $yyCookies{$cookiepassword} ) { 987 $password = $yyCookies{$cookiepassword}; 988 $username = $yyCookies{$cookieusername} || 'Guest'; 989 $cookiesession = $yyCookies{$session_id}; 990 } 991 else { 992 $password = q{}; 993 $username = 'Guest'; 994 } 995 if ( $yyCookies{'guestlanguage'} 996 && !$FORM{'guestlang'} 997 && $enable_guestlanguage ) 998 { 999 opendir DIR, $langdir; 1000 my @langDir = readdir DIR; 1001 closedir DIR; 1002 @lang = (); 1003 foreach my $langitems ( sort { lc($a) cmp lc $b } @langDir ) { 1004 chomp $langitems; 1005 if ( ( $langitems ne q{.} ) 1006 && ( $langitems ne q{..} ) 1007 && ( $langitems ne q{.htaccess} ) 1008 && ( $langitems ne q{index.html} ) ) 1009 { 1010 push @lang, $langitems; 1011 } 1012 } 1013 1014 $ccheck = 0; 1015 $clang = q{}; 1016 for my $lng (@lang) { 1017 if ( $yyCookies{'guestlanguage'} eq $lng ) { 1018 $clang = $lng; 1019 $ccheck = 1; 1020 last; 1021 } 1022 } 1023 if ( $ccheck == 1 ) { 1024 $language = $guestLang = $clang; 1025 } 1026 } 1027 return; 1028} 1029 1030sub guestLangcc { 1031 opendir DIR, $langdir; 1032 my @langDir = readdir DIR; 1033 closedir DIR; 1034 @lang = (); 1035 foreach my $langitems ( sort { lc($a) cmp lc $b } @langDir ) { 1036 chomp $langitems; 1037 if ( ( $langitems ne q{.} ) 1038 && ( $langitems ne q{..} ) 1039 && ( $langitems ne q{.htaccess} ) 1040 && ( $langitems ne q{index.html} ) ) 1041 { 1042 push @lang, $langitems; 1043 } 1044 } 1045 return \@lang; 1046} 1047 1048sub UpdateCookie { 1049 my ( $what, $user, $passw, $sessionval, $pathval, $expire ) = @_; 1050 my ( $valid, $expiration ); 1051 if ( $what eq 'delete' ) { 1052 $expiration = 'Thursday, 01-Jan-1970 00:00:00 GMT'; 1053 if ( $pathval eq q{} ) { $pathval = q~/~; } 1054 if ( $iamguest && $FORM{'guestlang'} && $enable_guestlanguage ) { 1055 if ( $FORM{'guestlang'} && !$guestLang ) { 1056 $guestLang = qq~$FORM{'guestlang'}~; 1057 } 1058 $language = qq~$guestLang~; 1059 $cookiepassword = 'guestlanguage'; 1060 $passw = qq~$language~; 1061 $expire = 'persistent'; 1062 } 1063 $valid = 1; 1064 } 1065 elsif ( $what eq 'write' ) { 1066 $expiration = $expire; 1067 if ( $pathval eq q{} ) { $pathval = q~/~; } 1068 $valid = 1; 1069 } 1070 1071 if ($valid) { 1072 if ( $expire eq 'persistent' ) { 1073 $expiration = 'Sunday, 17-Jan-2038 00:00:00 GMT'; 1074 } 1075 $yySetCookies1 = write_cookie( 1076 -name => "$cookieusername", 1077 -value => "$user", 1078 -path => "$pathval", 1079 -expires => "$expiration" 1080 ); 1081 $yySetCookies2 = write_cookie( 1082 -name => "$cookiepassword", 1083 -value => "$passw", 1084 -path => "$pathval", 1085 -expires => "$expiration" 1086 ); 1087 $yySetCookies3 = write_cookie( 1088 -name => "$cookiesession_name", 1089 -value => "$sessionval", 1090 -path => "$pathval", 1091 -expires => "$expiration" 1092 ); 1093 1094 my $adminpass = 'adminpass'; 1095 my $admincookie = "$cookieusername$adminpass"; 1096 if ( $yyCookies{$admincookie} ) { 1097 push @otherCookies, 1098 write_cookie( 1099 -name => "$admincookie", 1100 -value => q{}, 1101 -path => q{/}, 1102 -expires => 'Thursday, 01-Jan-1970 00:00:00 GMT' 1103 ); 1104 $yyCookies{$admincookie} = q{}; 1105 } 1106 1107 foreach my $catid (@categoryorder) { 1108 if ( !$catid ) { next; } 1109 my $boardlist = $cat{$catid}; 1110 my @bdlist = split /\,/xsm, $boardlist; 1111 foreach my $curboard (@bdlist) { 1112 chomp $curboard; 1113 my $tsortcookie = "$cookietsort$curboard$username"; 1114 if ( $yyCookies{$tsortcookie} ) { 1115 push @otherCookies, 1116 write_cookie( 1117 -name => "$tsortcookie", 1118 -value => q{}, 1119 -path => q{/}, 1120 -expires => 'Thursday, 01-Jan-1970 00:00:00 GMT' 1121 ); 1122 $yyCookies{$tsortcookie} = q{}; 1123 } 1124 my $cookiename = "$cookiepassword$curboard$username"; 1125 if ( $yyCookies{$cookiename} ) { 1126 push @otherCookies, 1127 write_cookie( 1128 -name => "$cookiename", 1129 -value => q{}, 1130 -path => q{/}, 1131 -expires => 'Thursday, 01-Jan-1970 00:00:00 GMT' 1132 ); 1133 $yyCookies{$cookiename} = q{}; 1134 } 1135 } 1136 } 1137 } 1138 return; 1139} 1140 1141sub LoadAccess { 1142 $yesaccesses .= "$load_txt{'805'} $load_txt{'806'} $load_txt{'808'}<br />"; 1143 $noaccesses = q{}; 1144 1145 # Reply Check 1146 my $rcaccess = AccessCheck( $currentboard, 2 ) || 0; 1147 if ( $rcaccess eq 'granted' ) { 1148 $yesaccesses .= 1149 "$load_txt{'805'} $load_txt{'806'} $load_txt{'809'}<br />"; 1150 } 1151 else { 1152 $noaccesses .= 1153 "$load_txt{'805'} $load_txt{'807'} $load_txt{'809'}<br />"; 1154 } 1155 1156 # Topic Check 1157 my $tcaccess = AccessCheck( $currentboard, 1 ) || 0; 1158 if ( $tcaccess eq 'granted' ) { 1159 $yesaccesses .= 1160 "$load_txt{'805'} $load_txt{'806'} $load_txt{'810'}<br />"; 1161 } 1162 else { 1163 $noaccesses .= 1164 "$load_txt{'805'} $load_txt{'807'} $load_txt{'810'}<br />"; 1165 } 1166 1167 # Poll Check 1168 my $access = AccessCheck( $currentboard, 3 ) || 0; 1169 if ( $access eq 'granted' ) { 1170 $yesaccesses .= 1171 "$load_txt{'805'} $load_txt{'806'} $load_txt{'811'}<br />"; 1172 } 1173 else { 1174 $noaccesses .= 1175 "$load_txt{'805'} $load_txt{'807'} $load_txt{'811'}<br />"; 1176 } 1177 1178 # Zero Post Check 1179 if ( $username ne 'Guest' ) { 1180 if ( $INFO{'zeropost'} != 1 && $rcaccess eq 'granted' ) { 1181 $yesaccesses .= 1182 "$load_txt{'805'} $load_txt{'806'} $load_txt{'812'}<br />"; 1183 } 1184 else { 1185 $noaccesses .= 1186 "$load_txt{'805'} $load_txt{'807'} $load_txt{'812'}<br />"; 1187 } 1188 } 1189 1190 $accesses = qq~$yesaccesses<br />$noaccesses~; 1191 return $accesses; 1192} 1193 1194sub WhatTemplate { 1195 $found = 0; 1196 while ( ( $curtemplate, $value ) = each %templateset ) { 1197 if ( $curtemplate eq $default_template ) { 1198 $template = $curtemplate; 1199 $found = 1; 1200 } 1201 } 1202 if ( !$found ) { $template = 'Forum default'; } 1203 if ( ${ $uid . $username }{'template'} ne q{} ) { 1204 if ( !exists $templateset{ ${ $uid . $username }{'template'} } ) { 1205 ${ $uid . $username }{'template'} = 'Forum default'; 1206 UserAccount( $username, 'update' ); 1207 } 1208 while ( ( $curtemplate, $value ) = each %templateset ) { 1209 if ( $curtemplate eq ${ $uid . $username }{'template'} ) { 1210 $template = $curtemplate; 1211 } 1212 } 1213 } 1214 ( 1215 $usestyle, $useimages, $usehead, $useboard, 1216 $usemessage, $usedisplay, $usemycenter, $UseMenuType, 1217 $useThreadtools, $usePosttools, 1218 ) = split /\|/xsm, $templateset{$template}; 1219 1220 if ( !-e "$htmldir/Templates/Forum/$usestyle.css" ) { 1221 $usestyle = 'default'; 1222 } 1223 if ( !-e "$templatesdir/$usehead/$usehead.html" ) { $usehead = 'default'; } 1224 if ( !-e "$templatesdir/$useboard/BoardIndex.template" ) { 1225 $useboard = 'default'; 1226 } 1227 if ( !-e "$templatesdir/$usemessage/MessageIndex.template" ) { 1228 $usemessage = 'default'; 1229 } 1230 if ( !-e "$templatesdir/$usedisplay/Display.template" ) { 1231 $usedisplay = 'default'; 1232 } 1233 if ( !-e "$templatesdir/$usemycenter/MyCenter.template" ) { 1234 $usemycenter = 'default'; 1235 } 1236 1237 if ( $UseMenuType eq q{} ) { $UseMenuType = $MenuType; } 1238 if ( $useThreadtools eq q{} ) { $useThreadtools = $threadtools; } 1239 if ( $usePosttools eq q{} ) { $usePosttools = $posttools; } 1240 1241 if ( -d "$htmldir/Templates/Forum/$useimages" ) { 1242 $imagesdir = "$yyhtml_root/Templates/Forum/$useimages"; 1243 } 1244 else { $imagesdir = "$yyhtml_root/Templates/Forum/default"; } 1245 $defaultimagesdir = "$yyhtml_root/Templates/Forum/default"; 1246 1247 $extpagstyle =~ s/$usestyle\///gxsm; 1248 return; 1249} 1250 1251sub WhatLanguage { 1252 if ( ${ $uid . $username }{'language'} ne q{} ) { 1253 $language = ${ $uid . $username }{'language'}; 1254 } 1255 elsif ( $FORM{'guestlang'} && $enable_guestlanguage ) { 1256 $language = $FORM{'guestlang'}; 1257 } 1258 elsif ( $guestLang && $enable_guestlanguage ) { 1259 $language = $guestLang; 1260 } 1261 else { 1262 $language = $lang; 1263 } 1264 1265 LoadLanguage('Main'); 1266 LoadLanguage('Menu'); 1267 1268 if ($adminscreen) { 1269 LoadLanguage('Admin'); 1270 LoadLanguage('FA'); 1271 } 1272 return; 1273} 1274 1275sub buildIMS { 1276 my ( $builduser, $job ) = @_; 1277 my ( $incurr, $inunr, $outcurr, $draftcount, @imstore, $storetotal, 1278 @storefoldersCount, $storeCounts ); 1279 1280 if ($job) { 1281 if ( $job eq 'load' ) { 1282 load_IMS($builduser); 1283 } 1284 else { 1285 update_IMS($builduser); 1286 } 1287 return; 1288 } 1289 1290 ## inbox if it exists, either load and count totals or parse and update format. 1291 if ( -e "$memberdir/$builduser.msg" ) { 1292 fopen( USERMSG, "$memberdir/$builduser.msg" ) 1293 or fatal_error( 'cannot_open', "$memberdir/$builduser.msg", 1 ); 1294 1295 # open inbox 1296 my @messages = <USERMSG>; 1297 fclose(USERMSG); 1298 1299 # test the data for version. 16 elements in new format, no more than 8 in old. 1300 foreach my $message (@messages) { 1301 1302 # If the message is flagged as u(nopened), add to the new count 1303 if ( ( split /\|/xsm, $message )[12] =~ /u/sm ) { $inunr++; } 1304 } 1305 $incurr = @messages; 1306 1307 } 1308 1309 ## do the outbox 1310 if ( -e "$memberdir/$builduser.outbox" ) { 1311 fopen( OUTMESS, "$memberdir/$builduser.outbox" ) 1312 or fatal_error( 'cannot_open', "$memberdir/$builduser.outbox", 1 ); 1313 my @outmessages = <OUTMESS>; 1314 fclose(OUTMESS); 1315 $outcurr = @outmessages; 1316 } 1317 1318 if ( -e "$memberdir/$builduser.imdraft" ) { 1319 fopen( DRAFTMESS, "$memberdir/$builduser.imdraft" ) 1320 or fatal_error( 'cannot_open', "$memberdir/$builduser.imdraft", 1 ); 1321 my @d = <DRAFTMESS>; 1322 fclose(DRAFTMESS); 1323 $draftcount = @d; 1324 } 1325 1326 ## grab the current list of store folders 1327 ## else, create an entry for the two 'default ones' for the in/out status stuff 1328 my $storefolders = ${$builduser}{'PMfolders'} || 'in|out'; 1329 my @currStoreFolders = split /\|/xsm, $storefolders; 1330 if ( -e "$memberdir/$builduser.imstore" ) { 1331 fopen( STOREMESS, "$memberdir/$builduser.imstore" ) 1332 or fatal_error( 'cannot_open', "$memberdir/$builduser.imstore", 1 ); 1333 @imstore = <STOREMESS>; 1334 fclose(STOREMESS); 1335 if (@imstore) { 1336 my ( $storeUpdated, $storeMessLine ) = ( 0, 0 ); 1337 foreach my $message (@imstore) { 1338 my @messLine = split /\|/xsm, $message; 1339 ## look through list for folder name 1340 if ( $messLine[13] eq q{} ) 1341 { # some folder missing within imstore 1342 if ( $messLine[1] ne q{} ) { # 'from' name so inbox 1343 $messLine[13] = 'in'; 1344 } 1345 else { # no 'from' so outbox 1346 $messLine[13] = 'out'; 1347 } 1348 $imstore[$storeMessLine] = join q{|}, @messLine; 1349 $storeUpdated = 1; 1350 } 1351 if ( $storefolders !~ /\b$messLine[13]\b/sm ) { 1352 push @currStoreFolders, $messLine[13]; 1353 $storefolders = join q{|}, @currStoreFolders; 1354 } 1355 $storeMessLine++; 1356 } 1357 if ( $storeUpdated == 1 ) { 1358 fopen( STRMESS, "+>$memberdir/$builduser.imstore" ) 1359 or fatal_error( 'cannot_open', 1360 "$memberdir/$builduser.imstore", 1 ); 1361 print {STRMESS} @imstore or croak "$croak{'print'} STRMESS"; 1362 fclose(STRMESS); 1363 } 1364 $storetotal = @imstore; 1365 $storefolders = join q{|}, @currStoreFolders; 1366 1367 } 1368 else { 1369 unlink "$memberdir/$builduser.imstore"; 1370 } 1371 } 1372 ## run through the messages and count against the folder name 1373 for my $y ( 0 .. ( @currStoreFolders - 1 ) ) { 1374 $storefoldersCount[$y] = 0; 1375 for my $x ( 0 .. ( @imstore - 1 ) ) { 1376 if ( ( split /\|/xsm, $imstore[$x] )[13] eq $currStoreFolders[$y] ) 1377 { 1378 $storefoldersCount[$y]++; 1379 } 1380 } 1381 } 1382 $storeCounts = join q{|}, @storefoldersCount; 1383 1384 LoadBroadcastMessages($builduser); 1385 1386 ${$builduser}{'PMmnum'} = $incurr || 0; 1387 ${$builduser}{'PMimnewcount'} = $inunr || 0; 1388 ${$builduser}{'PMmoutnum'} = $outcurr || 0; 1389 ${$builduser}{'PMdraftnum'} = $draftcount || 0; 1390 ${$builduser}{'PMstorenum'} = $storetotal || 0; 1391 ${$builduser}{'PMfolders'} = $storefolders; 1392 ${$builduser}{'PMfoldersCount'} = $storeCounts || 0; 1393 update_IMS($builduser); 1394 return; 1395} 1396 1397sub update_IMS { 1398 my $builduser = shift; 1399 my @tag = 1400 qw(PMmnum PMimnewcount PMmoutnum PMstorenum PMdraftnum PMfolders PMfoldersCount PMbcRead); 1401 1402 fopen( UPDATE_IMS, ">$memberdir/$builduser.ims", 1 ) 1403 or fatal_error( 'cannot_open', "$memberdir/$builduser.ims", 1 ); 1404 print {UPDATE_IMS} qq~### UserIMS YaBB 2.6.11 Version ###\n\n~ 1405 or croak "$croak{'print'} update IMS"; 1406 for my $cnt ( 0 .. ( @tag - 1 ) ) { 1407 print {UPDATE_IMS} qq~'$tag[$cnt]',"${$builduser}{$tag[$cnt]}"\n~ 1408 or croak "$croak{'print'} update IMS"; 1409 } 1410 fclose(UPDATE_IMS); 1411 return; 1412} 1413 1414sub load_IMS { 1415 my $builduser = shift; 1416 my @ims; 1417 if ( -e "$memberdir/$builduser.ims" ) { 1418 fopen( IMSFILE, "$memberdir/$builduser.ims" ) 1419 or fatal_error( 'cannot_open', "$memberdir/$builduser.ims", 1 ); 1420 @ims = <IMSFILE>; 1421 fclose(IMSFILE); 1422 } 1423 1424 if ( $ims[0] =~ /###/xsm ) { 1425 foreach (@ims) { 1426 if ( $_ =~ /'(.*?)',"(.*?)"/xsm ) { ${$builduser}{$1} = $2; } 1427 } 1428 } 1429 else { 1430 buildIMS( $builduser, q{} ); 1431 } 1432 return; 1433} 1434 1435sub LoadBroadcastMessages { #check broadcast messages 1436 return 1437 if ( $iamguest 1438 || $PM_level == 0 1439 || ( $maintenance && !$iamadmin ) 1440 || ( $PM_level == 2 && ( !$staff ) ) 1441 || ( $PM_level == 3 && ( !$iamadmin && !$iamgmod ) ) 1442 || ( $PM_level == 4 && ( !$iamadmin && !$iamgmod && !$iamfmod ) ) ); 1443 1444 my $builduser = shift; 1445 $BCnewMessage = 0; 1446 $BCCount = 0; 1447 if ( -e "$memberdir/broadcast.messages" ) { 1448 my %PMbcRead; 1449 map { $PMbcRead{$_} = 1; } split /,/xsm, ${$builduser}{'PMbcRead'}; 1450 1451 fopen( BCMESS, "<$memberdir/broadcast.messages" ) 1452 or fatal_error( 'cannot_open', "$memberdir/broadcast.messages", 1 ); 1453 my @bcmessages = <BCMESS>; 1454 fclose(BCMESS); 1455 foreach (@bcmessages) { 1456 my ( $mnum, $mfrom, $mto, undef ) = split /\|/xsm, $_, 4; 1457 if ( $mfrom eq $username ) { $BCCount++; $PMbcRead{$mnum} = 1; } 1458 elsif ( BroadMessageView($mto) ) { 1459 $BCCount++; 1460 if ( exists $PMbcRead{$mnum} ) { $PMbcRead{$mnum} = 1; } 1461 else { $BCnewMessage++; } 1462 } 1463 } 1464 ${$builduser}{'PMbcRead'} = q{}; 1465 foreach ( keys %PMbcRead ) { 1466 if ( $PMbcRead{$_} ) { 1467 ${$builduser}{ 'PMbcRead' . $_ } = 1; 1468 ${$builduser}{'PMbcRead'} .= 1469 ${$builduser}{'PMbcRead'} ? ",$_" : $_; 1470 } 1471 } 1472 } 1473 else { 1474 ${$builduser}{'PMbcRead'} = q{}; 1475 } 1476 return; 1477} 1478 14791; 1480