F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Profile.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Profile.pm
############################################################################### ###############################################################################
# Profile.pl                                                                  # # Profile.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 strict;
  # use warnings;
  no warnings qw(uninitialized once redefine);
  use English qw(-no_match_vars);
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
  $profilepmver = 'YaBB 2.6.12 $Revision: 1710 $';
  if ( $action eq 'detailedversion' ) { return 1; }
   
  LoadLanguage('Profile');
  LoadLanguage('Register');
  require Sources::AddModerators;
  get_micon();
  get_template('MyProfile');
  get_gmod();
   
$profileplver = 'YaBB 2.5.2 $Revision: 1.2 $';  $pm_lev = PMlev(); 
if ($action eq 'detailedversion') { return 1; }  
   
&LoadLanguage('Profile');  
   
if ($iamgmod && -e "$vardir/gmodsettings.txt") { require "$vardir/gmodsettings.txt"; }  
   
# make sure this person has access to this profile # make sure this person has access to this profile
sub PrepareProfile { sub PrepareProfile {
   if ($iamguest) { &fatal_error('no_access'); }    if ($iamguest) { fatal_error('no_access'); }
   
   # If someone registers with a '+' in their name It causes problems.    # If someone registers with a '+' in their name It causes problems.
   # Get's turned into a <space> in the query string Change it back here.    # Get's turned into a <space> in the query string Change it back here.
   # Users who register with spaces get them replaced with _    # Users who register with spaces get them replaced with _
   # So no problem there.    # So no problem there.
   $INFO{'username'} =~ tr/ /+/;    $INFO{'username'} =~ tr/ /+/;
   
   $user = $INFO{'username'};    $user = $INFO{'username'};
   if ($do_scramble_id) { &decloak($user); }    if ($do_scramble_id)    { decloak($user); }
   if ($user =~ m~/~)  { &fatal_error('no_user_slash'); }    if ( $user =~ m{/}sm )  { fatal_error('no_user_slash'); }
   if ($user =~ m~\\~) { &fatal_error('no_user_backslash'); }    if ( $user =~ m{\\}sm ) { fatal_error('no_user_backslash'); }
   
   unless (&LoadUser($user)) { &fatal_error('no_profile_exists'); }    if ( !LoadUser($user) ) { fatal_error('no_profile_exists'); }
   
   if (($user ne $username && !$iamadmin && (!$iamgmod || !$allow_gmod_profile)) ||     if ( 
       ($user eq 'admin' && $username ne 'admin') ||         ( 
       ($iamgmod && ${$uid.$user}{'position'} eq 'Administrator')) { &fatal_error('not_allowed_profile_change'); }                $user ne $username 
             && !$iamadmin
             && ( !$iamgmod || !$allow_gmod_profile )
         )
         || ( $user eq 'admin' && $username ne 'admin' )
         || ( $iamgmod && ${ $uid . $user }{'position'} eq 'Administrator' )
       )
     {
         fatal_error('not_allowed_profile_change');
     }
   
   @menucolors = qw(catbg catbg catbg catbg catbg catbg);    @menucolors = qw(catbg catbg catbg catbg catbg catbg);
     return;
} }
   
# Check that profile-editing session is still valid # Check that profile-editing session is still valid
sub SidCheck { sub SidCheck {
   my $cur_sid = &decloak($INFO{'sid'});     my @x         = @_; 
   my $sid_check = substr($date, 5, 5);     my $cur_sid   = decloak( $INFO{'sid'} ); 
   if ($sid_check <= 600 && $cur_sid >= 99400) { $sid_check += 100000; }     my $sid_check = substr $date, 5, 5; 
     if ( $sid_check <= 600 && $cur_sid >= 99_400 ) { $sid_check += 100_000; }
   $sid_expires = $cur_sid + 600 - $sid_check;  
     $sid_expires = $cur_sid + 600 - $sid_check;
   &ProfileCheck($_[0]) if $sid_expires < 0 || $cur_sid > $sid_check;  
     if ( $sid_expires < 0 || $cur_sid > $sid_check ) { ProfileCheck( $x[0] ); }
     if ( $sid_expires < 60 ) {
         $expsectxt =
           ( $sid_expires == 1 )
           ? $profile_txt{'sid_expires_3'}
           : $profile_txt{'sid_expires_2'};
         $expiretxt = qq~$profile_txt{'sid_expires_1'} $sid_expires $expsectxt~;
     }
     else {
         $expiremin = int( $sid_expires / 60 );
         $expiresec = $sid_expires % 60;
         $expmintxt =
           ( $expiremin == 1 )
           ? $profile_txt{'sid_expires_4'}
           : $profile_txt{'sid_expires_5'};
         $expsectxt =
           ( $expiresec == 1 )
           ? $profile_txt{'sid_expires_3'}
           : $profile_txt{'sid_expires_2'};
         $expiretxt =
  qq~$profile_txt{'sid_expires_1'} $expiremin $expmintxt $expiresec $expsectxt~;
     }
     return;
} }
   
sub ProfileCheck { sub ProfileCheck {
   &PrepareProfile;     my @x = @_; 
     PrepareProfile();
   
   my $sid_descript = $mycenter_profile_txt{siddescript};     my $sid_descript = $mycenter_profile_txt{'siddescript'}; 
   if ($_[0]) {    if ( $x[0] ) {
       $sid_descript = $mycenter_profile_txt{timeoutdescript};         $sid_descript = $mycenter_profile_txt{'timeoutdescript'}; 
       $redirsid = $_[0];         $redirsid     = $x[0]; 
       $yyjavascript .= qq~\nalert("$profile_txt{'897'}");~ if $redirsid =~ s/2$//;         if ( $redirsid =~ s/2$//xsm ) { 
   } else {             $yyjavascript .= qq~\nalert("$profile_txt{'897'}");~; 
       $redirsid = $INFO{'page'} || 'profile';         } 
   }    }
     else {
   $yymain .= qq~         $redirsid = $INFO{'page'} || 'profile'; 
<div class="bordercolor" style="width: 500px; margin-bottom: 8px; margin-left: auto; margin-right: auto;">     } 
<table cellpadding="4" cellspacing="1" border="0" width="100%" align="center">  
   <tr><td class="titlebg" colspan="2"><b>$profile_txt{'901'}</b></td></tr>  
   <tr>  
       <td class="windowbg2" align="center">  
           <label for="passwrd"><span class="small"><br />$sid_descript<br /><br /></span></label>  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" align="center" valign="middle">  
           <form action="$scripturl?action=profileCheck2;username=$useraccount{$user}" method="post" name="confirmform">  
           <input type="hidden" name="redir" value="$redirsid" />  
           <div style="padding-top: 4px;">  
               <div><input type="password" name="passwrd" id="passwrd" size="15" style="width: 150px;" onkeypress="capsLock(event,'cappasswrd')" /></div>  
               <div style="color: red; font-weight: bold; display: none" id="cappasswrd">$profile_txt{'capslock'}</div>  
               <div style="color: red; font-weight: bold; display: none" id="cappasswrd_char">$profile_txt{'wrong_char'}: <span id="cappasswrd_character">&nbsp;</span></div>  
           </div>  
           <div style="padding-top: 8px;">  
               <input type="submit" value="$profile_txt{'900'}" class="button" />  
           </div>  
           </form>  
       </td>  
   </tr>  
</table>  
</div>  
<script type="text/javascript" language="JavaScript">  
<!--  
   document.confirmform.passwrd.focus();  
// -->  
</script>  
~;  
   
   $yynavigation = qq~&rsaquo; $profile_txt{'900'}~;     $yymain .= $myprofile_a; 
   $yytitle = $profile_txt{'900'};     $yymain =~ s/{yabb sid_descript}/$sid_descript/sm; 
   &template;     $yymain =~ 
  s/{yabb prof_act}/$scripturl?action=profileCheck2;username=$useraccount{$user}/sm;
     $yymain =~ s/{yabb redirsid}/$redirsid/sm;
   
     $yynavigation = qq~&rsaquo; $profile_txt{'900'}~;
     $yytitle      = $profile_txt{'900'};
     template();
     return;
} }
   
sub ProfileCheck2 { sub ProfileCheck2 {
   &PrepareProfile;     PrepareProfile(); 
   
     my $password = encode_password( $FORM{'passwrd'} || $INFO{'passwrd'} );
     if ( $user eq $username && $password ne ${ $uid . $username }{'password'} )
     {
         fatal_error('current_password_wrong');
     }
     if ( ( $iamadmin || ( $iamgmod && $allow_gmod_profile ) )
         && $password ne ${ $uid . $username }{'password'} )
     {
         fatal_error('no_admin_password');
     }
   
   my $password = &encode_password($FORM{'passwrd'} || $INFO{'passwrd'});     # Update the sessionID too 
   if ($user eq $username && $password ne ${$uid.$username}{'password'}) {     ${ $uid . $username }{'session'} = encode_password($user_ip); 
       &fatal_error('current_password_wrong');     UserAccount( $username, 'update' ); 
   }  
   if (($iamadmin || ($iamgmod && $allow_gmod_profile)) && $password ne ${$uid.$username}{'password'}) {     # update only this cookie since we don't know when the others will expire 
       &fatal_error('no_admin_password');     $yySetCookies3 = write_cookie( 
   }         -name    => "$cookiesession_name", 
   # Update the sessionID too         -value   => "${$uid.$username}{'session'}", 
   ${$uid.$username}{'session'} = &encode_password($user_ip);         -path    => q{/}, 
   &UserAccount($username, "update");         -expires => 'Sunday, 17-Jan-2038 00:00:00 GMT' 
     );
   # update only this cookie since we don't know when the others will expire  
   $yySetCookies3 = &write_cookie(     # Get a semi-secure SID - only for profile changes 
           -name    => "$cookiesession_name",     # cloak the sid -> no point giving anyone the means. 
           -value   => "${$uid.$username}{'session'}",     $yySetLocation = 
           -path    => "/",         "$scripturl?action=" 
           -expires => "Sunday, 17-Jan-2038 00:00:00 GMT");       . ( $FORM{'redir'} || $INFO{'redir'} || 'profile' ) 
       . ";username=$useraccount{$user};sid=" 
   # Get a semi-secure SID - only for profile changes       . cloak( reverse substr $date, 5, 5 ) 
   # cloak the sid -> no point giving anyone the means.       . ( $INFO{'newpassword'} ? ';newpassword=1' : q{} ); 
   $yySetLocation = "$scripturl?action=" . ($FORM{'redir'} || $INFO{'redir'} || 'profile') . ";username=$useraccount{$user};sid=" . &cloak(reverse(substr($date, 5, 5))) . ($INFO{'newpassword'} ? ";newpassword=1" : "");     redirectexit(); 
   &redirectexit;     return; 
} }
   
sub ProfileMenu { sub ProfileMenu {
   return if $view;    return if $view;
   
   $yymain .= qq~     if ($buddyListEnabled) { 
<table cellspacing="1" cellpadding="4" width="100%" border="0" class="bordercolor">         $bdlist = $myprofie_bdlist; 
   <tr>         $bdlist =~ s/{yabb menucolor3}/$menucolors[3]/sm; 
       <td class="$menucolors[0]" valign="bottom" align="center" width="16%"><span class="small"><b><a href="$scripturl?action=profile;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_txt{79}</a></b></span></td>         $bdlist =~ s/{yabb bduser}/$useraccount{$user}/sm; 
       <td class="$menucolors[1]" valign="bottom" align="center" width="16%"><span class="small"><b><a href="$scripturl?action=profileContacts;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_txt{819}</a></b></span></td>     } 
       <td class="$menucolors[2]" valign="bottom" align="center" width="16%"><span class="small"><b><a href="$scripturl?action=profileOptions;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_txt{818}</a></b></span></td>~;  
     if ( $pm_lev == 1 ) {
   if ($buddyListEnabled){         $pmlevel = $myprofile_pmlevel; 
       $yymain .= qq~         $pmlevel =~ s/{yabb menucolor4}/$menucolors[4]/sm; 
       <td class="$menucolors[3]" valign="bottom" align="center" width="16%"><span class="small"><b><a href="$scripturl?action=profileBuddy;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_buddy_list{'buddylist'}</a></b></span></td>~;         $pmlevel =~ s/{yabb pmuser}/$useraccount{$user}/sm; 
   }    }
     if (
   if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))) {         $iamadmin 
       $yymain .= qq~         || (   $iamgmod 
       <td class="$menucolors[4]" valign="bottom" align="center" width="16%"><span class="small"><b><a href="$scripturl?action=profileIM;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_imtxt{56} $profile_txt{323}</a></b></span></td>~;             && $allow_gmod_profile 
   }             && $gmod_access2{'profileAdmin'} eq 'on' ) 
       )
   if ($iamadmin || ($iamgmod && $allow_gmod_profile && $gmod_access2{'profileAdmin'} eq 'on')) {    {
       $yymain .= qq~         $showadmin = $myprofile_showadmin; 
       <td class="$menucolors[5]" valign="bottom" width="16%" align="center"><span class="small"><b><a href="$scripturl?action=profileAdmin;username=$useraccount{$user};sid=$INFO{'sid'}">$profile_txt{820}</a></b></span></td>~;         $showadmin =~ s/{yabb menucolor5}/$menucolors[5]/sm; 
   }         $showadmin =~ s/{yabb aduser}/$useraccount{$user}/sm; 
   $yymain .= qq~     } 
   </tr>     $yymain .= $myprofile_menu; 
</table>     $yymain =~ s/{yabb menu_user}/$useraccount{$user}/gsm; 
<br />     $yymain =~ s/{yabb sid}/$INFO{'sid'}/gsm; 
~;     $yymain =~ s/{yabb menucolor0}/$menucolors[0]/sm; 
     $yymain =~ s/{yabb menucolor1}/$menucolors[1]/sm;
     $yymain =~ s/{yabb menucolor2}/$menucolors[2]/sm;
     $yymain =~ s/{yabb bdlist}/$bdlist/sm;
     $yymain =~ s/{yabb pmlevel}/$pmlevel/sm;
     $yymain =~ s/{yabb showadmin}/$showadmin/sm;
     return $yymain;
} }
   
sub ModifyProfile { sub ModifyProfile {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
   $menucolors[0] = "titlebg";     $menucolors[0] = 'selected-bg'; 
   &ProfileMenu;     ProfileMenu(); 
   
   if ($iamadmin) {    if ($iamadmin) {
       $confdel_text = qq~$profile_txt{'775'} $profile_txt{'777'} $user $profile_txt{'778'}~;         $confdel_text = 
       if ($user eq $username) {           qq~$profile_txt{'775'} $profile_txt{'777'} $user $profile_txt{'778'}~; 
           $passtext = $profile_txt{'821'};         if ( $user eq $username ) { 
       } else {             $passtext = $profile_txt{'821'}; 
           $passtext = qq~$profile_txt{'2'} $profile_txt{'36'}~;         } 
       }         else { 
   } else {             $passtext = qq~$profile_txt{'2'} $profile_txt{'36'}~; 
       $confdel_text = qq~$profile_txt{'775'} $profile_txt{'776'} $profile_txt{'778'}~;         } 
       $passtext = $profile_txt{'821'};     } 
   }     else { 
         $confdel_text =
   $passtext .= qq~<br /><span class="small" style="font-weight: normal;">$profile_txt{'895'}</span>~;           qq~$profile_txt{'775'} $profile_txt{'776'} $profile_txt{'778'}~; 
         $passtext = $profile_txt{'821'};
   my $scriptAction = qq~profile2~;     } 
   if ($view) {  
       $scriptAction = qq~myprofile2~;     $passtext .= qq~<br /><span class="small norm">$profile_txt{'895'}</span>~; 
       $yytitle = $profile_txt{'editmyprofile'};  
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user)~;     my $scriptAction = q~profile2~; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;     if ($view) { 
   } else {         $scriptAction = q~myprofile2~; 
       $yytitle = $profile_txt{'79'};         $yytitle      = $profile_txt{'editmyprofile'}; 
       $profiletitle = qq~$profile_txt{'79'} ($user)~;        $profiletitle = qq~$profile_txt{'editmyprofile'} ($user)~;
       $yynavigation = qq~&rsaquo; $profiletitle~;         $yynavigation = 
   }  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~; 
     }
   if (${$uid.$user}{'gender'} eq 'Male')   { $GenderMale   = ' selected="selected" '; }     else { 
   if (${$uid.$user}{'gender'} eq 'Female') { $GenderFemale = ' selected="selected" '; }         $yytitle      = $profile_txt{'79'}; 
         $profiletitle = qq~$profile_txt{'79'} ($user)~;
   my $timeorder;         $yynavigation = qq~&rsaquo; $profiletitle~; 
   if(${$uid.$user}{'timeselect'}) {     } 
       if    (${$uid.$user}{'timeselect'} == 6) { $timeorder = 1; }  
       elsif (${$uid.$user}{'timeselect'} == 3) { $timeorder = 1; }     if ( ${ $uid . $user }{'gender'} eq 'Male' ) { 
       elsif (${$uid.$user}{'timeselect'} == 2) { $timeorder = 1; }         $GenderMale = ' selected="selected" '; 
   }    }
   else {    if ( ${ $uid . $user }{'gender'} eq 'Female' ) {
       if ($timeselected == 6) { $timeorder = 1; }         $GenderFemale = ' selected="selected" '; 
       elsif ($timeselected == 3) { $timeorder = 1; }    }
       elsif ($timeselected == 2) { $timeorder = 1; }     CalcAge( $user, 'parse' ); 
   }  
     my ( $editAgeTxt, $editAgeCount, $disableBdayFields, $editGenderTxt,
   &CalcAge($user, "parse");         $editGenderCount, $disableGenderField, $genderField, $bdayFields ); 
   $dayormonthm = qq~<label for="bday1">$profile_txt{'564'}</label><input type="text" name="bday1" id="bday1" size="2" maxlength="2" value="$umonth" /> ~;     $editGenderLimit ||= 0; 
   $dayormonthd = qq~<label for="bday2">$profile_txt{'565'}</label><input type="text" name="bday2" id="bday2" size="2" maxlength="2" value="$uday" /> ~;     if (   $editGenderLimit > 0 
   if ($timeorder) { $dayormonth = $dayormonthd . $dayormonthm; }         && !$iamadmin 
   else { $dayormonth = $dayormonthm . $dayormonthd; }         && ( !$iamgmod || !$allow_gmod_profile ) ) 
   $dayormonth =~ s/for="bday\d"/for="birthday"/o;     { 
   $dayormonth =~ s/id="bday\d"/id="birthday"/o;         if ( $editGenderLimit == 1 && ${ $uid . $user }{'gender'} eq q{} ) { 
             $editGenderTxt = qq~$profile_txt{'gender_edit_1'}~;
   &LoadLanguage('Register');         } 
   $showProfile   .= qq~         elsif ( ${ $uid . $user }{'disablegender'} >= $editGenderLimit ) { 
<form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator">             $editGenderTxt      = qq~$profile_txt{'gender_edit_3'}~; 
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">             $disableGenderField = q~ disabled="disabled"~; 
   <tr>             $genderField        = qq~ 
       <td class="catbg" colspan="2"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b><br /><span class="small">$profile_txt{'698'}</span>~ . ($INFO{'newpassword'} ? $profile_txt{'80'} : "") . qq~</td>  <input type="hidden" name="gender" value="${ $uid . $user }{'gender'}" />~; 
   </tr>         } 
   <tr class="windowbg">         elsif (${ $uid . $user }{'disablegender'} eq q{} 
       <td width="220" align="left"><label for="passwrd1"><b>$profile_txt{81}: </b><br />             && ${ $uid . $user }{'gender'} eq q{} ) 
           <span class="small">$profile_txt{'896'}</span></label>         { 
       </td>             if ( $editGenderCount == 1 ) { 
       <td align="left">                 $editGenderTxt = 
           <div style="float:left;"><input autocomplete="off" type="password" maxlength="30" name="passwrd1" id="passwrd1" size="20" onkeyup="runPassword(this.value);" onkeypress="capsLock(event,'cappasswrd1')" /> &nbsp; </div>  qq~ $profile_txt{'gender_edit_2'} $editGenderLimit $profile_txt{'dob_edit_5'}~; 
           <div style="float:left; width: 150px; height: 20px;">             } 
           <div id="password-strength-meter" style="background: transparent url($imagesdir/empty_bar.gif) repeat-x center left; height: 4px"></div>             else { 
           <div class="pstrength-bar" id="passwrd1_bar" style="border: 1px solid #FFFFFF; height: 4px"></div>                 $editGenderTxt = 
           <div class="pstrength-info" id="passwrd1_text">&nbsp;</div>  qq~ $profile_txt{'gender_edit_2'} $editGenderLimit $profile_txt{'dob_edit_6'}~; 
           </div>             } 
           <div style="clear:left; color: red; font-weight: bold; display: none" id="cappasswrd1">$profile_txt{'capslock'}</div>         } 
           <div style="clear:left; color: red; font-weight: bold; display: none" id="cappasswrd1_char">$profile_txt{'wrong_char'}: <span id="cappasswrd1_character">&nbsp;</span></div>         elsif ( ${ $uid . $user }{'disablegender'} < $editGenderLimit ) { 
       </td>             $editGenderCount = 
   </tr>               $editGenderLimit - ${ $uid . $user }{'disablegender'}; 
   <tr class="windowbg">             if ( $editGenderCount == 1 ) { 
       <td width="220" align="left"><label for="passwrd2"><b>$profile_txt{82}: </b><br />                 $editGenderTxt = 
           <span class="small">$profile_txt{'896'}</span></label>  qq~ $profile_txt{'gender_edit_2'} $editGenderCount $profile_txt{'dob_edit_3'}~; 
       </td>             } 
       <td align="left">             else { 
           <input type="password" maxlength="30" name="passwrd2" id="passwrd2" size="20" onkeypress="capsLock(event,'cappasswrd2')" />                 $editGenderTxt = 
           <div style="color: red; font-weight: bold; display: none" id="cappasswrd2">$profile_txt{'capslock'}</div>  qq~ $profile_txt{'gender_edit_2'} $editGenderCount $profile_txt{'dob_edit_4'}~; 
           <div style="color: red; font-weight: bold; display: none" id="cappasswrd2_char">$profile_txt{'wrong_char'}: <span id="cappasswrd2_character">&nbsp;</span></div>             } 
       </td>         } 
   </tr>         $editGenderTxt = qq~<br /><span class="small">$editGenderTxt</span>~; 
   <tr class="windowbg">     } 
       <td width="220" align="left"><label for="name"><b>$profile_txt{68}: </b><br />~;  
   if ($name_cannot_be_userid) {     $editAgeLimit ||= 0; 
       $showProfile .= qq~     if ( $editAgeLimit > 0 && !$iamadmin && ( !$iamgmod || !$allow_gmod_profile ) ) 
           <span class="small">$profile_txt{'8'}</span></label>~;     { 
   }         if ( $editAgeLimit == 1 && ${ $uid . $user }{'disableage'} eq q{} ) { 
   $showProfile .= qq~             $editAgeTxt = qq~$profile_txt{'dob_edit_1'}~; 
       </td>         } 
       <td align="left"><input type="text" maxlength="30" onchange="checkAvail('$scripturl',this.value,'display')" name="name" id="name" size="30" value="${$uid.$user}{'realname'}" /><div id="displayavailability"></div></td>         elsif ( ${ $uid . $user }{'disableage'} >= $editAgeLimit && ${ $uid . $user }{'bday'} ne q{}) { 
   </tr>             $editAgeTxt        = qq~$profile_txt{'dob_edit_7'}~; 
   <tr class="windowbg">             $disableBdayFields = q~ disabled="disabled"~; 
       <td width="220" align="left"><label for="gender"><b>$profile_txt{231}: </b></label></td>             $bdayFields        = qq~ 
       <td align="left"><select name="gender" id="gender" size="1"><option value=""></option><option value="Male"$GenderMale>$profile_txt{'238'}</option><option value="Female"$GenderFemale>$profile_txt{'239'}</option></select></td>  <input type="hidden" name="bday1" value="$umonth" /> 
   </tr>  <input type="hidden" name="bday2" value="$uday" /> 
   <tr class="windowbg">  <input type="hidden" name="bday3" value="$uyear" />~; 
       <td width="220" align="left"><label for="birthday"><b>$profile_txt{'563'}: </b></label></td>         } 
       <td align="left"><span class="small">$dayormonth<label for="bday3">$profile_txt{'566'}</label><input type="text" name="bday3" id="bday3" size="4" maxlength="4" value="$uyear" /></span></td>         elsif (${ $uid . $user }{'disableage'} eq q{} 
   </tr>             && ${ $uid . $user }{'bday'} eq q{} ) 
   <tr class="windowbg">         { 
       <td width="220" align="left"><label for="location"><b>$profile_txt{'227'}: </b></label></td>             if ( $editAgeCount == 1 ) { 
       <td align="left"><input type="text" maxlength="30" name="location" id="location" size="30" value="${$uid.$user}{'location'}" /></td>                 $editAgeTxt .= 
   </tr>~;  qq~ $profile_txt{'dob_edit_2'} $editAgeLimit $profile_txt{'dob_edit_5'}~; 
             }
   if ($extendedprofiles) {            else {
       require "$sourcedir/ExtendedProfiles.pl";                 $editAgeTxt .= 
       $showProfile .= &ext_editprofile($user, "edit");  qq~ $profile_txt{'dob_edit_2'} $editAgeLimit $profile_txt{'dob_edit_6'}~; 
   }            }
         }
   if ($sessions == 1 && $sessionvalid == 1 && ($iamadmin || $iamgmod || $iammod) && $username eq $user) {        elsif ( ${ $uid . $user }{'disableage'} < $editAgeLimit ) {
       &LoadLanguage('Sessions');             $editAgeCount = $editAgeLimit - ${ $uid . $user }{'disableage'}; 
       require "$sourcedir/Decoder.pl";             if ( $editAgeCount == 1 ) { 
       my $decanswer = &descramble(${$uid.$user}{'sesanswer'}, $user);                 $editAgeTxt .= 
       $questsel = qq~<select name="sesquest" id="sesquest" size="1">\n~;  qq~ $profile_txt{'dob_edit_2'} $editAgeCount $profile_txt{'dob_edit_3'}~; 
       while (($key, $val) = each %sesquest_txt) {             } 
           if (${$uid.$user}{'sesquest'} eq $key && ${$uid.$user}{'sesquest'} ne "") {            else {
               $sessel = qq~ selected="selected"~;                 $editAgeTxt .= 
           } elsif ($key eq "password" && ${$uid.$user}{'sesquest'} eq "") {  qq~ $profile_txt{'dob_edit_2'} $editAgeCount $profile_txt{'dob_edit_4'}~; 
               $sessel = qq~ selected="selected"~;             } 
           } else {         } 
               $sessel = "";         $editAgeTxt = qq~<br /><span class="small">$editAgeTxt</span>~; 
           }    }
           $questsel .= qq~<option value="$key"$sessel>$val</option>\n~;  
       }     my $timeorder; 
       $questsel .= qq~</select>\n~;     my @selist = ( 2, 3, 6, 8 ); 
       $showProfile   .= qq~     if ( ${ $uid . $user }{'timeselect'} ) { 
   <tr>         for my $i (@selist) { 
       <td class="catbg" colspan="2"><img src="$imagesdir/session.gif" alt="" border="0" /> <label for="sesquest"><b>$img_txt{'34a'}</b><br /><span class="small">$session_txt{'9'}<br />$session_txt{'9a'}</span></label></td>             if ( ${ $uid . $user }{'timeselect'} == $i ) { $timeorder = 1; } 
   </tr>         } 
   <tr class="windowbg">     } 
       <td width="220" align="left">$questsel</td>     else { 
       <td align="left"><input type="text" maxlength="30" name="sesanswer" size="20" value="$decanswer" /></td>         for my $i (@selist) { 
   </tr>~;             if ( $timeselected == $i ) { $timeorder = 1; } 
   }        }
   $showProfile .= qq~     } 
   <tr class="catbg">  
       <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" />~;     $selectyear = q{}; 
   if ($self_del_user == 1) {     $seluyear = 
       if ( ( $iamadmin && ( $username ne $user ) ) || ( $username ne 'admin' ) ) {  qq~$profile_txt{'566'}<select name="bday3"$disableBdayFields><option value="">--</option>\n~; 
       $showProfile .=     for my $e ( 1905 .. ( $year - 3 ) ) { 
         $seluyear .=
           qq~<option value="$e" ${isselected($uyear == $e)}>$e</option>\n~;
     }
     $seluyear .= q~</select> ~;
   
     $selectmnth = q{};
     $dayormonthm =
  qq~<label for="bday1">$profile_txt{'564'}</label><select name="bday1" id="bday1"$disableBdayFields><option value="">--</option>\n~;
     for my $bb ( 1 .. 12 ) {
         if   ( $bb < 10 ) { $c = "0$bb"; }
         else              { $c = $bb; }
         $dayormonthm .=
           qq~<option value="$c" ${isselected($umonth == $bb)}>$c</option>\n~;
     }
     $dayormonthm .= q~</select> ~;
   
     $selectday = q{};
     $dayormonthd =
  qq~<label for="bday2">$profile_txt{'565'}</label><select name="bday2" id="bday2"$disableBdayFields><option value="">--</option>\n~;
     for my $aa ( 1 .. 31 ) {
         if   ( $aa < 10 ) { $d = "0$aa"; }
         else              { $d = $aa; }
         $dayormonthd .=
           qq~<option value="$d" ${isselected($uday == $aa)}>$d</option>\n~;
     }
     $dayormonthd .= q~</select> ~;
   
     if   ($timeorder) { $dayormonth = $dayormonthd . $dayormonthm; }
     else              { $dayormonth = $dayormonthm . $dayormonthd; }
     $dayormonth =~ s/for="bday\d"/for="birthday"/oxsm;
     $dayormonth =~ s/id="bday\d"/id="birthday"/oxsm;
   
     $my_newpass  = ( $INFO{'newpassword'} ? $profile_txt{'80'} : q{} );
     $my_passchk  = password_check();
     $my_name_not = q{};
     if ($name_cannot_be_userid) {
         $my_name_not = qq~
                         <span class="small">$profile_txt{'8'}</span></label>~;
     }
     if ( $showage == 1 ) {
         my $checked = q{};
         if ( ${ $uid . $user }{'hideage'} ) { $checked = ' checked="checked"'; }
         $my_showageshow = $myprofile_showage;
         $my_showageshow =~ s/{yabb agechecked}/$checked/sm;
     }
   
     if ($extendedprofiles) {
         require Sources::ExtendedProfiles;
         my $show_ext_prof = ext_editprofile( $user, 'edit' );
         $my_show_ext_prof = $show_ext_prof;
     }
   
     if ( $birthday_on_reg > 1 ) {
         $myrequirebd = qq~ <span class="small">$profile_txt{'563b'}</span>~;
     }
     $showProfile .= qq~
  <form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" accept-charset="$yymycharset">
  $myprofile_edit~;
     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm;
     $showProfile =~ s/{yabb my_newpass}/$my_newpass/sm;
     $showProfile =~ s/{yabb my_passchk}/$my_passchk/sm;
     $showProfile =~ s/{yabb my_name_not}/$my_name_not/sm;
     $showProfile =~ s/{yabb user}/${$uid.$user}{'realname'}/gsm;
     $showProfile =~ s/{yabb editGenderTxt}/$editGenderTxt/sm;
     $showProfile =~ s/{yabb disableGenderField}/$disableGenderField/sm;
     $showProfile =~ s/{yabb GenderMale}/$GenderMale/sm;
     $showProfile =~ s/{yabb GenderFemale}/$GenderFemale/sm;
     $showProfile =~ s/{yabb genderField}/$genderField/sm;
     $showProfile =~ s/{yabb editAgeTxt}/$editAgeTxt/sm;
     $showProfile =~ s/{yabb require_bd}/$myrequirebd/sm;
     $showProfile =~ s/{yabb bdaysel}/$dayormonth$seluyear$bdayFields/sm;
     $showProfile =~ s/{yabb showageshow}/$my_showageshow/sm;
     $showProfile =~ s/{yabb user_location}/${$uid.$user}{'location'}/sm;
     $showProfile =~ s/{yabb my_show_ext_prof}/$my_show_ext_prof/sm;
  ## Mod Hook showProfile1 ##
   
     if (   $sessions == 1
         && $sessionvalid == 1
         && ($staff)
         && $username eq $user )
     {
         LoadLanguage('Sessions');
         my $decanswer = ${ $uid . $user }{'sesanswer'};
         $questsel = qq~<select name="sesquest" id="sesquest" size="1">\n~;
         while ( ( $key, $val ) = each %sesquest_txt ) {
             if (   ${ $uid . $user }{'sesquest'} eq $key
                 && ${ $uid . $user }{'sesquest'} ne q{} )
             {
                 $sessel = q~ selected="selected"~;
             }
             elsif ( $key eq 'password' && ${ $uid . $user }{'sesquest'} eq q{} )
             {
                 $sessel = q~ selected="selected"~;
             }
             else {
                 $sessel = q{};
             }
             $questsel .= qq~<option value="$key"$sessel>$val</option>\n~;
         }
         $questsel .= qq~</select>\n~;
         $showProfile .= $myprofile_session;
         $showProfile =~ s/{yabb questsel}/$questsel/sm;
         $showProfile =~ s/{yabb decanswer}/$decanswer/sm;
         $showProfile =~ s/{yabb sesstext9}/$session_txt{'9'}/sm;
         $showProfile =~ s/{yabb sesstext9a}/$session_txt{'9a'}/sm;
     }
     if ( $self_del_user == 1 ) {
         if (   ( $iamadmin && ( $username ne $user ) )
             || ( $username ne 'admin' ) )
         {
             $show_confdel =
qq~ &nbsp; &nbsp; &nbsp; <input type="submit" name="moda" value="$profile_txt{'89'}" onclick="return confirm('$confdel_text')" class="button" />~; qq~ &nbsp; &nbsp; &nbsp; <input type="submit" name="moda" value="$profile_txt{'89'}" onclick="return confirm('$confdel_text')" class="button" />~;
       }        }
   }    }
   else  {    else {
       if ( $iamadmin &&  $username ne $user ) {        if ( $iamadmin && $username ne $user ) {
       $showProfile .=             $show_confdel = 
qq~ &nbsp; &nbsp; &nbsp; <input type="submit" name="moda" value="$profile_txt{'89'}" onclick="return confirm('$confdel_text')" class="button" />~; qq~ &nbsp; &nbsp; &nbsp; <input type="submit" name="moda" value="$profile_txt{'89'}" onclick="return confirm('$confdel_text')" class="button" />~;
       }        }
   }    }
   $showProfile .= qq~<br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span>     $showProfile .= $myprofile_bottom; 
       </td>     $showProfile =~ s/{yabb show_confdel}/$show_confdel/sm; 
   </tr>     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
</table>  
</form>     if ( !$view ) { 
         $yymain .= $showProfile;
<script language="JavaScript1.2" type="text/javascript">         template(); 
<!--    } 
   // Password_strength_meter start     return; 
   var verdects = new Array("$pwstrengthmeter_txt{'1'}","$pwstrengthmeter_txt{'2'}","$pwstrengthmeter_txt{'3'}","$pwstrengthmeter_txt{'4'}","$pwstrengthmeter_txt{'5'}","$pwstrengthmeter_txt{'6'}","$pwstrengthmeter_txt{'7'}","$pwstrengthmeter_txt{'8'}");  
   var colors = new Array("#8F8F8F","#BF0000","#FF0000","#00A0FF","#33EE00","#339900");  
   var scores = new Array($pwstrengthmeter_scores);  
   var common = new Array($pwstrengthmeter_common);  
   var minchar = $pwstrengthmeter_minchar;  
   
   function runPassword(D) {  
       var nPerc = checkPassword(D);  
       if (nPerc > -199 && nPerc < 0) {  
           strColor = colors[0];  
           strText = verdects[1];  
           strWidth = "5%";  
       } else if (nPerc == -200) {  
           strColor = colors[1];  
           strText = verdects[0];  
           strWidth = "0%";  
       } else if (scores[0] == -1 && scores[1] == -1 && scores[2] == -1 && scores[3] == -1) {  
           strColor = colors[4];  
           strText = verdects[7];  
           strWidth = "100%";  
       } else if (nPerc <= scores[0]) {  
           strColor = colors[1];  
           strText = verdects[2];  
           strWidth = "10%";  
       } else if (nPerc > scores[0] && nPerc <= scores[1]) {  
           strColor = colors[2];  
           strText = verdects[3];  
           strWidth = "25%";  
       } else if (nPerc > scores[1] && nPerc <= scores[2]) {  
           strColor = colors[3];  
           strText = verdects[4];  
           strWidth = "50%";  
       } else if (nPerc > scores[2] && nPerc <= scores[3]) {  
           strColor = colors[4];  
           strText = verdects[5];  
           strWidth = "75%";  
       } else {  
           strColor = colors[5];  
           strText = verdects[6];  
           strWidth = "100%";  
       }  
       document.getElementById("passwrd1_bar").style.width = strWidth;  
       document.getElementById("passwrd1_bar").style.backgroundColor = strColor;  
       document.getElementById("passwrd1_text").style.color = strColor;  
       document.getElementById("passwrd1_text").childNodes[0].nodeValue = strText;  
   }  
   
   function checkPassword(C) {  
       if (C.length == 0 || C.length < minchar) return -100;  
   
       for (var D = 0; D < common.length; D++) {  
           if (C.toLowerCase() == common[D]) return -200;  
       }  
   
       var F = 0;  
       if (C.length >= minchar && C.length <= (minchar+2)) {  
           F = (F + 6)  
       } else if (C.length >= (minchar + 3) && C.length <= (minchar + 4)) {  
           F = (F + 12)  
       } else if (C.length >= (minchar + 5)) {  
           F = (F + 18)  
       }  
   
       if (C.match(/[a-z]/)) {  
           F = (F + 1)  
       }  
       if (C.match(/[A-Z]/)) {  
           F = (F + 5)  
       }  
       if (C.match(/d+/)) {  
           F = (F + 5)  
       }  
       if (C.match(/(.*[0-9].*[0-9].*[0-9])/)) {  
           F = (F + 7)  
       }  
       if (C.match(/.[!,\@,#,\$,\%,^,&,*,?,_,\~]/)) {  
           F = (F + 5)  
       }  
       if (C.match(/(.*[!,\@,#,\$,\%,^,&,*,?,_,\~].*[!,\@,#,\$,\%,^,&,*,?,_,\~])/)) {  
           F = (F + 7)  
       }  
       if (C.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){  
           F = (F + 2)  
       }  
       if (C.match(/([a-zA-Z])/) && C.match(/([0-9])/)) {  
           F = (F + 3)  
       }  
       if (C.match(/([a-zA-Z0-9].*[!,\@,#,\$,\%,^,&,*,?,_,\~])|([!,\@,#,\$,\%,^,&,*,?,_,\~].*[a-zA-Z0-9])/)) {  
           F = (F + 3)  
       }  
       return F;  
   }  
   // Password_strength_meter end  
// -->  
</script>  
~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
} }
   
sub ModifyProfileContacts { sub ModifyProfileContacts {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
     $menucolors[1] = 'selected-bg';
     ProfileMenu();
   
     my $scriptAction = q~profileContacts2~;
     if ($view) {
         $scriptAction = q~myprofileContacts2~;
         $yytitle =
           qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'819'}~;
         $profiletitle =
  qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'819'}~;
         $yynavigation =
  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;
     }
     else {
         $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'819'}~;
         $profiletitle =
           qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'819'}~;
         $yynavigation = qq~&rsaquo; $profiletitle~;
     }
   
     ${ $uid . $user }{'aim'} =~ tr/+/ /;
     ${ $uid . $user }{'yim'} =~ tr/+/ /;
     if ($allow_hide_email) {
         my $checked = q{};
         if ( ${ $uid . $user }{'hidemail'} ) {
             $checked = ' checked="checked"';
         }
         $my_hidemail = $myprofile_hidemail;
         $my_hidemail =~ s/{yabb checked}/$checked/sm;
     }
   
     if ( !$minlinkweb ) { $minlinkweb = 0; }
     if (   ${ $uid . $user }{'postcount'} >= $minlinkweb
         || ${ $uid . $user }{'position'} eq 'Administrator' 
         || ${ $uid . $user }{'position'} eq 'Global Moderator' )
     {
         $my_minlinkweb = $myprofile_minlinkweb;
         $my_minlinkweb =~ s/{yabb my_webtitle}/${$uid.$user}{'webtitle'}/sm;
         $my_minlinkweb =~ s/{yabb my_weburl}/${$uid.$user}{'weburl'}/sm;
     }
     if (
         $pm_lev == 1
         && (
             $enable_MCaway > 2
             || (
                 $enable_MCaway
                 && (   ${ $uid . $user }{'position'} eq 'Administrator' 
                     || ${ $uid . $user }{'position'} eq 'Global Moderator' 
                     || ${ $uid . $user }{'position'} eq 'Mid Moderator' 
                     || is_moderator($user) )
             )
         )
       )
     {
         my $offChecked  = q~ selected="selected"~;
         my $awayChecked = q{};
   
         if ( ${ $uid . $user }{'offlinestatus'} eq 'away' ) {
             $offChecked  = q{};
             $awayChecked = q~ selected="selected"~;
         }
   
         my $awayreply = ${ $uid . $user }{'awayreply'};
         $awayreply =~ s/<br \/>/\n/gsm;
         $my_away = $myprofile_away;
         $my_away .=
  qq~             <textarea name="awayreply" id="awayreply" rows="4" cols="50">$awayreply</textarea><br />~;
         $my_away .= $myprofile_away_b;
         $my_away =~ s/{yabb offChecked}/$offChecked/sm;
         $my_away =~ s/{yabb awayChecked}/$awayChecked/sm;
         $my_away =~ s/{yabb MaxAwayLen}/$MaxAwayLen/gsm;
     }
     if (
         (
                ${ $uid . $user }{'position'} eq 'Administrator' 
             || ${ $uid . $user }{'position'} eq 'Global Moderator' 
         )
         && $enable_MCstatusStealth
       )
     {
         my $stealthChecked = q{};
         if ( ${ $uid . $user }{'stealth'} ) {
             $stealthChecked = ' checked="checked"';
         }
         $my_stealth = $myprofile_stealth;
         $my_stealth =~ s/{yabb stealthChecked}/$stealthChecked/sm;
     }
   
   $menucolors[1] = "titlebg";     if ($extendedprofiles) { 
   &ProfileMenu;         require Sources::ExtendedProfiles; 
         $my_extended .= ext_editprofile( $user, 'contact' );
     }
   
   my $scriptAction = qq~profileContacts2~;     $showProfile .= qq~ 
   if ($view) {  <form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" accept-charset="$yymycharset"> 
       $scriptAction = qq~myprofileContacts2~;  $myprofile_contact 
       $yytitle = qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'819'}~;  ~;
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'819'}~;     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;     $showProfile =~ s/{yabb user_email}/${$uid.$user}{'email'}/sm; 
   } else {     $showProfile =~ s/{yabb my_hidemail}/$my_hidemail/sm; 
       $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'819'}~;     $showProfile =~ s/{yabb my_icq}/${$uid.$user}{'icq'}/sm; 
       $profiletitle = qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'819'}~;     $showProfile =~ s/{yabb my_aim}/${$uid.$user}{'aim'}/sm; 
       $yynavigation = qq~&rsaquo; $profiletitle~;     $showProfile =~ s/{yabb my_yim}/${$uid.$user}{'yim'}/sm; 
   }     $showProfile =~ s/{yabb my_gtalk}/${$uid.$user}{'gtalk'}/sm; 
     $showProfile =~ s/{yabb my_skype}/${$uid.$user}{'skype'}/sm;
   ${$uid.$user}{'aim'} =~ tr/+/ /;     $showProfile =~ s/{yabb my_myspace}/${$uid.$user}{'myspace'}/sm; 
   ${$uid.$user}{'yim'} =~ tr/+/ /;     $showProfile =~ s/{yabb my_facebook}/${$uid.$user}{'facebook'}/sm; 
     $showProfile =~ s/{yabb my_twitter}/${$uid.$user}{'twitter'}/sm;
   $showProfile .= qq~     $showProfile =~ s/{yabb my_youtube}/${$uid.$user}{'youtube'}/sm; 
<form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator">     $showProfile =~ s/{yabb my_minlinkweb}/$my_minlinkweb/sm; 
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">     $showProfile =~ s/{yabb my_away}/$my_away/sm; 
   <tr>     $showProfile =~ s/{yabb my_stealth}/$my_stealth/sm; 
       <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b></td>     $showProfile =~ s/{yabb my_extended}/$my_extended/sm; 
   </tr>     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
   <tr class="windowbg">  
       <td width="320" align="left"><label for="email"><b>$profile_txt{'69'}: </b><br /><span class="small">$profile_txt{'679'} </span></label></td>     if ( !$view ) { 
       <td align="left"><input type="text" maxlength="100" onchange="checkAvail('$scripturl',this.value,'email')" name="email" id="email" size="40" value="${$uid.$user}{'email'}" /><div id="emailavailability"></div></td>         $yymain .= $showProfile; 
   </tr>~;         template(); 
   if ($allow_hide_email) {     } 
       my $checked = '';     return; 
       if (${$uid.$user}{'hidemail'}) { $checked = ' checked="checked"'; }  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="hideemail"><b>$profile_txt{'721'}</b></label></td>  
       <td align="left"><input type="checkbox" name="hideemail" id="hideemail" value="1"$checked /></td>  
   </tr>~;  
   }  
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="icq"><b>$profile_txt{'513'}: </b><br /><span class="small">$profile_txt{'600'}</span></label></td>  
       <td align="left"><input type="text" maxlength="10" name="icq" id="icq" size="40" value="${$uid.$user}{'icq'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="aim"><b>$profile_txt{'603'}: </b><br /><span class="small">$profile_txt{'601'}</span></label></td>  
       <td align="left"><input type="text" maxlength="30" name="aim" id="aim" size="40" value="${$uid.$user}{'aim'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="yim"><b>$profile_txt{'604'}: </b><br /><span class="small">$profile_txt{'602'}</span></label></td>  
       <td align="left"><input type="text" maxlength="30" name="yim" id="yim" size="40" value="${$uid.$user}{'yim'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="msn"><b>$profile_txt{'823'}: </b><br /><span class="small">$profile_txt{'824'}</span></label></td>  
       <td align="left"><input type="text" maxlength="50" name="msn" id="msn" size="40" value="${$uid.$user}{'msn'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="gtalk"><b>$profile_txt{'825'}: </b><br /><span class="small">$profile_txt{'826'}</span></label></td>  
       <td align="left"><input type="text" maxlength="50" name="gtalk" id="gtalk" size="40" value="${$uid.$user}{'gtalk'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="skype"><b>$profile_txt{'827'}: </b><br /><span class="small">$profile_txt{'828'}</span></label></td>  
       <td align="left"><input type="text" maxlength="50" name="skype" id="skype" size="40" value="${$uid.$user}{'skype'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320"><label for="myspace"><b>$profile_txt{'570'}:</b><br /><span class="small">$profile_txt{'571'}</span></label></td>  
       <td align="left"><label for="myspace"><span class="small">$profile_txt{'572'}</span></label><br /><input type="text" maxlength="50" name="myspace" id="myspace" size="40" value="${$uid.$user}{'myspace'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320"><label for="facebook"><b>$profile_txt{'573'}:</b><br /><span class="small">$profile_txt{'574'}</span></label></td>  
       <td align="left"><label for="facebook"><span class="small">$profile_txt{'575'}</span></label><br /><input type="text" maxlength="50" name="facebook" id="facebook" size="40" value="${$uid.$user}{'facebook'}" /></td>  
   </tr>~;  
   if (!$minlinkweb) { $minlinkweb = 0; }  
   if (${$uid.$user}{'postcount'} >= $minlinkweb || ${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator') {  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="webtitle"><b>$profile_txt{'83'}: </b><br /><span class="small">$profile_txt{'598'}</span></label></td>  
       <td align="left"><input type="text" maxlength="30" name="webtitle" id="webtitle" size="40" value="${$uid.$user}{'webtitle'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="weburl"><b>$profile_txt{'84'}: </b><br /><span class="small">$profile_txt{'599'}</span></label></td>  
       <td align="left"><input type="text" name="weburl" id="weburl" size="40" value="${$uid.$user}{'weburl'}" /></td>  
   </tr>~;  
   }  
   
   if (($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))) && ($enable_MCaway > 2 || ($enable_MCaway && (${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator' || &is_moderator($user))))) {  
       my $offChecked = qq~ selected="selected"~;  
       my $awayChecked = '';  
   
       if (${$uid.$user}{'offlinestatus'} eq 'away') {  
           $offChecked = '';  
           $awayChecked = qq~ selected="selected"~;  
       }  
   
       my $awayreply = ${$uid.$user}{'awayreply'};  
       $awayreply =~ s~<br />~\n~g;  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="offlinestatus"><b>$profile_txt{'showstatus'}: </b><br /><span class="small">$profile_txt{'statusexplain'}<br />$profile_txt{'awaydescription'}</span></label></td>  
       <td align="left">  
           <select name="offlinestatus" id="offlinestatus">  
           <option value="offline"$offChecked>$maintxt{'61'}</option>  
           <option value="away"$awayChecked>$maintxt{'away'}</option>  
           </select><br /><br />  
           <label for="awaysubj"><span class="small">$profile_txt{'asubj'}</span></label><br />  
           <input type="text" name="awaysubj" id="awaysubj" size="50" maxlength="50" value="${$uid.$user}{'awaysubj'}" /><br /><br />  
           <label for="awayreply"><span class="small">$profile_txt{'amess'}</span></label><br />  
           <textarea name="awayreply" id="awayreply" rows="4" cols="50">$awayreply</textarea><br />  
   
           <span class="small">$profile_txt{'664a'} <input value="$MaxAwayLen" size="3" name="msgCL" class="windowbg" style="border: 0px; width: 40px; padding: 1px; font-size: 11px;" readonly="readonly" /></span><br />  
           <script type="text/javascript" language="JavaScript">  
           <!--  
               var supportsKeys = false;  
               function tick() {  
                   calcCharLeft(document.forms[0]);  
                   if (!supportsKeys) { timerID = setTimeout("tick()",200); }  
               }  
               function calcCharLeft(sig) {  
                   clipped = false;  
                   maxLength = $MaxAwayLen;  
                   if (document.creator.awayreply.value.length > maxLength) {  
                       document.creator.awayreply.value = document.creator.awayreply.value.substring(0,maxLength);  
                       charleft = 0;  
                       clipped = true;  
                   } else {  
                       charleft = maxLength - document.creator.awayreply.value.length;  
                   }  
                   document.creator.msgCL.value = charleft;  
                   return clipped;  
               }  
               tick();  
           // -->  
           </script>  
       </td>  
   </tr>~;  
   }  
   
   if ((${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator') && $enable_MCstatusStealth) {  
       my $stealthChecked = '';  
       if (${$uid.$user}{'stealth'}) { $stealthChecked = ' checked="checked"'; }  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="stealth"><b>$profile_txt{'stealth'}: </b><br /><span class="small">$profile_txt{'stealthexplain'}</span></label></td>  
       <td align="left"><input type="checkbox" name="stealth" id="stealth" value="1"$stealthChecked /></td>  
   </tr>~;  
   }  
   
   if ($extendedprofiles) {  
       require "$sourcedir/ExtendedProfiles.pl";  
       $showProfile .= &ext_editprofile($user,"contact");  
   }  
   
   $showProfile .= qq~  
   <tr class="catbg">  
       <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" /><br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span></td>  
   </tr>  
</table>  
</form>~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
} }
   
sub ModifyProfileOptions { sub ModifyProfileOptions {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
     $menucolors[2] = 'selected-bg';
     ProfileMenu();
   
     my $scriptAction = q~profileOptions2~;
     if ($view) {
         $scriptAction = q~myprofileOptions2~;
         $yytitle =
           qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'818'}~;
         $profiletitle =
  qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'818'}~;
         $yynavigation =
  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;
     }
     else {
         $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'818'}~;
         $profiletitle =
           qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'818'}~;
         $yynavigation = qq~&rsaquo; $profiletitle~;
     }
   
     if ( $allowpics && $upload_useravatar && $upload_avatargroup ) {
         $upload_useravatar = 0;
         foreach my $av_gr ( split /, /sm, $upload_avatargroup ) {
             if ( $av_gr eq ${ $uid . $user }{'position'} ) {
                 $upload_useravatar = 1;
                 last;
             }
             foreach ( split /,/xsm, ${ $uid . $user }{'addgroups'} ) {
                 if ( $av_gr eq $_ ) { $upload_useravatar = 1; last; }
             }
         }
     }
   
     $my_allow_avatars = (
         ( $allowpics && $upload_useravatar )
         ? q~ enctype="multipart/form-data"~
         : q{}
     );
   
     if ($allowpics) {
         opendir( DIR, $facesdir )
           or fatal_error( 'cannot_open_dir',
             "($facesdir)!<br />$profile_txt{'681'}", 1 );
         @contents = readdir DIR;
         closedir DIR;
         $images = q{};
         foreach my $line ( sort @contents ) {
             ( $name, $extension ) = split /\./xsm, $line;
             $checked = q{};
             if ( $line eq ${ $uid . $user }{'userpic'} ) {
                 $checked = ' selected="selected"';
             }
             if ( ${ $uid . $user }{'userpic'} =~ m{\Ahttps?://}sm
                 && $line eq $my_blank_avatar )
             {
                 $checked = ' selected="selected" ';
             }
             if (   $extension =~ /gif/ism
                 || $extension =~ /jpg/ism
                 || $extension =~ /jpeg/ism
                 || $extension =~ /png/ism )
             {
                 if ( $line eq $my_blank_avatar ) {
                     $images =
  qq~                <option value="$line"$checked>$profile_txt{'422'}</option>\n$images~;
                 }
                 else {
                     $images .=
  qq~                <option value="$line"$checked>$name</option>\n~;
                 }
             }
         }
         my ( $pic, $s, $alt );
         my $tmp = $facesurl;
         if ( $tmp =~ /^(http(s?):\/\/)/xsm ) {
             ( $tmp, $s ) = ( $1, $2 );
         }
         if ( ${ $uid . $user }{'userpic'} =~ m{\Ahttps?://}sm ) {
             $pic     = ${ $uid . $user }{'userpic'};
             $checked = ' checked="checked" ';
             $tmp     = ${ $uid . $user }{'userpic'};
             if ($upload_useravatar) { $alt = $profile_txt{'473'}; }
         }
         else {
             $pic = "$facesurl/${$uid.$user}{'userpic'}";
         }
   
         $avatar_limit ||= 0;
         $my_up_avatar_a = (
             $upload_useravatar
             ? qq~<br />
             $profile_txt{'476'} $avatar_limit KB~
             : q{}
         );
         $my_up_avatar_b = (
             $upload_useravatar
             ? q~<br />
             <br />
             <input type="file" name="file_avatar" size="50" />~
             : q{}
         );
   
         $my_show_avatar = $myprofile_show_avatar_a;
         $my_show_avatar =~ s/{yabb my_up_avatar_a}/$my_up_avatar_a/sm;
         $my_show_avatar =~ s/{yabb my_up_avatar_b}/$my_up_avatar_b/sm;
         $my_show_avatar =~ s/{yabb av_pic}/$pic/sm;
         $my_show_avatar =~ s/{yabb av_alt}/$alt/sm;
         $my_show_avatar =~ s/{yabb av_s}/$s/gsm;
         $my_show_avatar =~ s/{yabb av_tmp}/$tmp/sm;
         $my_show_avatar =~ s/{yabb images}/$images/sm;
         $my_show_avatar =~ s/{yabb checked}/$checked/sm;
     }
   
     $signature = ${ $uid . $user }{'signature'};
     $signature =~ s/<br.*?>/\n/gsm;
   
     if ( $addmemgroup_enabled > 1 && %NoPost ) {
         my ( $addmemgroup, $selsize ) =
           DrawGroups( ${ $uid . $user }{'addgroups'},
             ${ $uid . $user }{'position'}, 0 );
   
         if ( $addmemgroup ) {
             $my_addmemgroup = $myprofile_addmemgroup;
             $my_addmemgroup =~ s/{yabb selsize}/$selsize/sm;
             $my_addmemgroup =~ s/{yabb addmemgroup}/$addmemgroup/sm;
         }
     }
   
     if (   $NewNotificationAlert
         || $enable_notifications == 1
         || $enable_notifications == 3 )
     {
         if ($NewNotificationAlert) {
             $my_notify_a = q~
                         <input type="checkbox" value="1" name="onlinealert" id="onlinealert"~
               . (
                 ${ $uid . $user }{'onlinealert'} ? ' checked="checked"' : q{} )
               . qq~ /> <label for="onlinealert">$profile_txt{'onlinealertexplain'}</label>~;
         }
         if ( $enable_notifications == 1 || $enable_notifications == 3 ) {
             if ($NewNotificationAlert) {
                 $my_notify_b = q~<br />
                         <br />~;
             }
   
             $my_notify_b .= qq~
                         <label for="notify_N">$profile_txt{'326'}</label>?&nbsp;<select name="notify_N" id="notify_N">
                         <option value="0"~
               . (
                 (
                         !${ $uid . $user }{'notify_me'}
                       || ${ $uid . $user }{'notify_me'} == 2
                 ) ? ' selected="selected"' : q{}
               )
               . qq~>$profile_txt{'164'}</option>
                         <option value="1"~
               . (
                 (
                          ${ $uid . $user }{'notify_me'} == 1
                       || ${ $uid . $user }{'notify_me'} == 3
                 ) ? ' selected="selected"' : q{}
               )
               . qq~>$profile_txt{'163'}</option>
                         </select>~;
         }
         $my_notify = $myprofile_notify;
         $my_notify =~ s/{yabb my_notify_a}/$my_notify_a/sm;
         $my_notify =~ s/{yabb my_notify_b}/$my_notify_b/sm;
     }
   
     if ($ttsureverse) {
         if ( !exists( ${ $uid . $user }{'reversetopic'} ) ) {
             ${ $uid . $user }{'reversetopic'} = $ttsreverse;
         }
         $my_reversi =
           ${ $uid . $user }{'reversetopic'} ? q~ checked="checked"~ : q{};
         $my_reverse = $myprofile_reverse;
         $my_reverse =~ s/{yabb my_reversi}/$my_reversi/sm;
     }
   
     my $rts = ${ $uid . $user }{'return_to'};
     for my $rt ( 1 .. 3 ) {
         $return_to_select .=
           $rts == $rt
           ? qq~<option value="$rt" selected="selected">$return_to_txt{$rt}</option>~
           : qq~<option value="$rt">$return_to_txt{$rt}</option>~;
     }
     my $return_to = $myprofile_return_to;
     $return_to =~ s/{yabb return_to_select}/$return_to_select/sm;
   
     my $tmptcnt = 0;
     foreach my $curtemplate (
         sort { $templateset{$a} cmp $templateset{$b} }
         keys %templateset
       )
     {
         $drawndirs .=
  qq~<option value="$curtemplate"${isselected($curtemplate eq ${ $uid . $user }{'template'})}>$curtemplate</option>\n~;
         $tmptcnt++;
     }
   
     my $my_template = q{};
     if ( $tmptcnt > 1 ) {
     $my_template = $myprofile_template;
     $my_template =~ s/{yabb drawndirs}/$drawndirs/sm;
     }
   
     opendir DIR, $langdir;
     my @lfilesanddirs = readdir DIR;
     closedir DIR;
     my $lngcnt = 0;
     foreach my $fld ( sort { lc($a) cmp lc $b } @lfilesanddirs ) {
         if ( -e "$langdir/$fld/Main.lng" ) {
             my $displang = $fld;
             $displang =~ s/(.+?)\_(.+?)$/$1 ($2)/gism;
             $drawnldirs .=
  qq~<option value="$fld" ${isselected(${ $uid . $user }{'language'} eq $fld)}>$displang</option>~;
             $lngcnt++;
         }
     }
   
     my $my_show_lang = q{};
     if ( $lngcnt > 1 ) {
         $my_show_lang = $myprofile_show_lang;
         $my_show_lang =~ s/{yabb drawnldirs}/$drawnldirs/sm;
     }
   
     if ( $user_hide_avatars && $showuserpic && $allowpics )
     {    # checkbox to hide avatars in threads
         $my_show_avatar_opts = $myprofile_show_avatars;
         $my_hide_avatar =
           ${ $uid . $user }{'hide_avatars'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~ s/{yabb user_showavatar}/$my_hide_avatar/sm;
     }
     else { $my_show_avatar_opts = q{}; }
   
     if ( $user_hide_user_text && $showusertext )
     {    # checkbox to hide user-text in threads
         $my_show_avatar_opts .= $myprofile_hide_user_text;
         $my_hide_user_text =
           ${ $uid . $user }{'hide_user_text'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~ s/{yabb hide_user_text}/$my_hide_user_text/sm;
     }
   
     if ($user_hide_img) {    # checkbox to hide images in threads
         $my_show_avatar_opts .= $myprofile_hide_img;
         $my_hide_img =
           ${ $uid . $user }{'hide_img'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~ s/{yabb hide_img}/$my_hide_img/sm;
     }
   
     $allowattach ||= 0;
     if ( $user_hide_attach_img && $allowattach > 0 )
     {                        # checkbox to hide attached images in threads
         $my_show_avatar_opts .= $myprofile_hide_attach_img;
         $my_hide_attach_img =
           ${ $uid . $user }{'hide_attach_img'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~ s/{yabb hide_attach_img}/$my_hide_attach_img/sm;
     }
   
   $menucolors[2] = "titlebg";     if ($user_hide_signat) {    # checkbox to hide signatures in threads 
   &ProfileMenu;         $my_show_avatar_opts .= $myprofile_hide_signat; 
         $my_hide_signat =
           ${ $uid . $user }{'hide_signat'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~ s/{yabb hide_signat}/$my_hide_signat/sm;
     }
   
     if ( $user_hide_smilies_row && !$removenormalsmilies )
     {  # checkbox to hide the row of smilies below the the post-message-inputbox
         $my_show_avatar_opts .= $myprofile_hide_smilies_row;
         $my_hide_smilies_row =
           ${ $uid . $user }{'hide_smilies_row'} ? ' checked="checked"' : q{};
         $my_show_avatar_opts =~
           s/{yabb hide_smilies_row}/$my_hide_smilies_row/sm;
     }
   
     if ($extendedprofiles) {
         require Sources::ExtendedProfiles;
         $my_extprofile = ext_editprofile( $user, 'options' );
     }
   
     my $cnnn = 0;
     for my $i ( 1 .. 5 ) {
         if ( ${ $uid . $user }{'numberformat'} == $i ) {
             $unfsl[$i] = ' selected="selected" ';
             $cnnn++;
         }
         else { $unfsl[$i] = q{}; }
     }
     for my $i ( 1 .. 5 ) {
         if ( $forumnumberformat == $i && $cnnn == 0 ) {
             $unfsl[$i] = ' selected="selected" ';
         }
     }
   
     my $cntm = 0;
     for my $j ( 1 .. 8 ) {
         if ( ${ $uid . $user }{'timeselect'} == $j ) {
             $tsl[$j] = ' selected="selected" ';
             $cntm++;
         }
         else { $tsl[$j] = q{}; }
     }
     for my $j ( 1 .. 8 ) {
         if ( $timeselected == $j && $cntm == 0 ) {
             $tsl[$j] = ' selected="selected" ';
         }
     }
   
     $my_num_option = qq~<option value="1"$unfsl[1]>10987.65</option>
                 <option value="2"$unfsl[2]>10987,65</option>
                 <option value="3"$unfsl[3]>10,987.65</option>
                 <option value="4"$unfsl[4]>10.987,65</option>
                 <option value="5"$unfsl[5]>10 987,65</option>~;
   
     $my_time_option = qq~<option value="1"$tsl[1]>$profile_txt{'480'}</option>
                 <option value="5"$tsl[5]>$profile_txt{'484'}</option>
                 <option value="4"$tsl[4]>$profile_txt{'483'}</option>
                 <option value="8"$tsl[8]>$profile_txt{'483a'}</option>
                 <option value="2"$tsl[2]>$profile_txt{'481'}</option>
                 <option value="3"$tsl[3]>$profile_txt{'482'}</option>
                 <option value="6"$tsl[6]>$profile_txt{'485'}</option>~;
     $my_timeformat = timeformat( $date, 1 );
   
     if ($enabletz) {
         eval {
             require DateTime;
             require DateTime::TimeZone;
         };
         my $user_tz_select = q{};
         $default_tz ||= 'UTC';
         if ( !$EVAL_ERROR ) {
             require DateTime;
             require DateTime::TimeZone;
             LoadLanguage('Countries');
             $mytz = ${ $uid . $user }{'user_tz'} || $default_tz;
             my @mycntry = sort { $countrytime_txt{$a} cmp $countrytime_txt{$b} } keys %countrytime_txt;
             my $myselect = q{};
             if ( $mytz eq 'UTC' ) {
                 $myselect = ' selected="selected"';
             }
             $user_tz_select = q~<br /><select name="user_tz" id="user_tz">~;
             $user_tz_select .= qq~<option value="UTC"$myselect>UTC</option>~;
             for my $i (@mycntry) {
                 {
                     if ( $i eq $mytz ) {
                         $myselect = ' selected="selected"';
                     }
                     else { $myselect = q{}; }
                     $user_tz_select .=
  qq~<option value="$i"$myselect>$countrytime_txt{$i}</option>~;
                 }
             }
             $user_tz_select .= q~</select>~;
         }
         else {
             $mytz = ${ $uid . $user }{'user_tz'} || $default_tz;
             $localopt = q{};
             if ( $mytz eq 'local' ) {
                 $myselectb = ' selected="selected"';
             }
             elsif ( $mytz eq 'UTC' ) {
                 $myselecta = ' selected="selected"';
             }
             if ( $default_tz eq 'local' ) {
                 $localopt =
  qq~\n<option value="local"$myselectb>$profile_txt{'372a'}</option>~;
             }
             $user_tz_select = q~<br /><select name="user_tz" id="user_tz">~;
             $user_tz_select .= qq~<option value="UTC"$myselecta>UTC</option>~;
             $user_tz_select .= $localopt;
             $user_tz_select .= q~</select>~;
         }
         $my_tz = $my_tz_select;
         $my_tz =~ s/{yabb my_user_tz}/$user_tz_select/sm;
   
     }
     else { $my_tz = q{}; }
   
   my $scriptAction = qq~profileOptions2~;     $my_dynamic = 
   if ($view) {       ${ $uid . $user }{'dynamic_clock'} ? ' checked="checked"' : q{}; 
       $scriptAction = qq~myprofileOptions2~;  
       $yytitle = qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'818'}~;     $my_time = $myprofile_time; 
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'818'}~;     $my_time =~ s/{yabb my_num_option}/$my_num_option/sm; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;     $my_time =~ s/{yabb my_time_option}/$my_time_option/sm; 
   } else {     $my_time =~ s/{yabb timeformat}/${$uid.$user}{'timeformat'}/sm; 
       $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'818'}~;     $my_time =~ s/{yabb my_timeformat}/$my_timeformat/sm; 
       $profiletitle = qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'818'}~;     $my_time =~ s/{yabb my_tz_select}/$my_tz/sm; 
       $yynavigation = qq~&rsaquo; $profiletitle~;     $my_time =~ s/{yabb my_dynamic}/$my_dynamic/sm; 
   }  
     $showProfile .= qq~
   if ($allowpics && $upload_useravatar && $upload_avatargroup) {  <form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator"$my_allow_avatars>~; 
       $upload_useravatar = 0;     $showProfile .= $myprofile_options; 
       foreach my $av_gr (split(/, /, $upload_avatargroup)) {     $showProfile .= 
           if ($av_gr eq ${$uid.$user}{'position'}) { $upload_useravatar = 1; last; }  qq~         <textarea name="signature" id="signature" rows="4" cols="30" class="width_100">$signature</textarea><br />~; 
           foreach (split(/,/, ${$uid.$user}{'addgroups'})) {     $showProfile .= $myprofile_options_b; 
               if ($av_gr eq $_) { $upload_useravatar = 1; last; }  
           }     $showProfile =~ s/{yabb usertext}/${$uid.$user}{'usertext'}/sm; 
       }     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm; 
   }     $showProfile =~ s/{yabb my_show_avatar}/$my_show_avatar/sm; 
     $showProfile =~ s/{yabb MaxSigLen}/$MaxSigLen/gsm;
   $showProfile .= qq~     $showProfile =~ s/{yabb my_addmemgroup}/$my_addmemgroup/sm; 
<form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator"~ . (($allowpics && $upload_useravatar) ? qq~ enctype="multipart/form-data"~ : "") . qq~>     $showProfile =~ s/{yabb my_time}/$my_time/sm; 
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">     $showProfile =~ s/{yabb my_notify}/$my_notify/sm; 
   <tr>     $showProfile =~ s/{yabb my_reverse}/$my_reverse/sm; 
       <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b></td>     $showProfile =~ s/{yabb my_return_to}/$return_to/sm; 
   </tr>     $showProfile =~ s/{yabb my_template}/$my_template/sm; 
   <tr class="windowbg">~;     $showProfile =~ s/{yabb my_show_lang}/$my_show_lang/sm; 
     $showProfile =~ s/{yabb my_show_avatar_opts}/$my_show_avatar_opts/sm;
   if ($allowpics) {     $showProfile =~ s/{yabb my_extprofile}/$my_extprofile/sm; 
       opendir(DIR, "$facesdir") || fatal_error("cannot_open_dir","($facesdir)!<br />$profile_txt{'681'}", 1);     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
       @contents = readdir(DIR);  
       closedir(DIR);  ## Mod Hook showProfile_options ## 
       $images = '';  
       foreach $line (sort @contents) {    if ( !$view ) {
           ($name, $extension) = split(/\./, $line);         $yymain .= $showProfile; 
           $checked = '';         template(); 
           if ($line eq ${$uid.$user}{'userpic'}) { $checked = ' selected="selected"'; }    }
           if (${$uid.$user}{'userpic'} =~ m~\Ahttps?://~ && $line eq 'blank.gif') { $checked = ' selected="selected" '; }     return; 
           if ($extension =~ /gif/i || $extension =~ /jpg/i || $extension =~ /jpeg/i || $extension =~ /png/i) {  
               if ($line eq 'blank.gif') {  
                   $images = qq~            <option value="$line"$checked>$profile_txt{'422'}</option>\n$images~;  
               } else {  
                   $images .= qq~            <option value="$line"$checked>$name</option>\n~;  
               }  
           }  
       }  
       my ($pic,$tmp,$s,$alt);  
       $tmp = $facesurl;  
       $tmp =~ /^(http(s?):\/\/)/;  
       ($tmp,$s) = ($1,$2);  
       if (${$uid.$user}{'userpic'} =~ m~\Ahttps?://~) {  
           $pic = ${$uid.$user}{'userpic'};  
           $checked = ' checked="checked" ';  
           $tmp = ${$uid.$user}{'userpic'};  
           $alt = $profile_txt{'473'} if $upload_useravatar;  
       } else {  
           $pic = "$facesurl/${$uid.$user}{'userpic'}";  
       }  
   
       $showProfile .= qq~  
       <td align="left"><label for="userpic"><b>$profile_txt{'229'}:</b></label><br /><span class="small"><label for="userpic">$profile_txt{'474'}</label><label for="userpicpersonalcheck">$profile_txt{'475'}</label>~ . ($upload_useravatar ? qq~<br />  
           $profile_txt{'476'} $avatar_limit KB~ : "") . qq~<br />  
           $profile_txt{'477'}</span></td>  
       <td align="left">  
           <script language="JavaScript1.2" type="text/javascript">  
           <!--  
               function showimage(x) {  
                   if (!document.images) return;  
                   var source;  
                   if (x == 1 && document.getElementsByName('userpicpersonalcheck')[0].checked == true) {  
                       UserPicUrl = document.getElementsByName('userpicpersonal')[0].value;  
                       document.getElementsByName('userpicpersonal')[0].value = 'http$s://';  
                       document.getElementsByName('userpicpersonalcheck')[0].checked = false;  
                   }  
                   if (x == 1) {  
                       source = "$facesurl/"+document.creator.userpic.options[document.creator.userpic.selectedIndex].value;  
                   } else {  
                       document.creator.userpic.options[0].selected = true;  
                       source = document.getElementsByName('userpicpersonal')[0].value;  
                       if (!source || source == 'http$s://') source = "$facesurl/blank.gif";  
                   }  
                   document.images.icons.style.display = 'none';  
                   document.images.icons.width = '';  
                   document.images.icons.height = '';  
                   document.images.icons.src = source;  
                   resize_time = 2;  
                   img_resize_names = new Array ('avatar_img_resize_1');  
                   resize_images();  
               }  
           // -->  
           </script>  
           <select name="userpic" id="userpic" size="6" onchange="showimage(1);">  
           $images  
           </select>&nbsp;&nbsp;<img src="$pic" id="icons" name="avatar_img_resize" alt="$alt" border="0" hspace="15" style="display:none" /><br />  
           <br />  
           <input type="checkbox" name="userpicpersonalcheck" id="userpicpersonalcheck" $checked onclick="if(this.checked==false){UserPicUrl=document.getElementsByName('userpicpersonal')[0].value;document.getElementsByName('userpicpersonal')[0].value='http$s://';}else{document.getElementsByName('userpicpersonal')[0].value=UserPicUrl;}showimage(2);" />&nbsp;<input type="text" name="userpicpersonal" size="40" value="$tmp" onkeyup="document.getElementsByName('userpicpersonalcheck')[0].checked=true;showimage(2);" />~ . ($upload_useravatar ? qq~<br />  
           <br />  
           <input type="file" name="file_avatar" size="50" />~ : "") . qq~  
       </td>  
   </tr>~;  
   }  
   
   $signature = ${$uid.$user}{'signature'};  
   $signature =~ s/<br.*?>/\n/g;  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="usertext"><b>$profile_txt{'228'}: </b></label></td>  
       <td align="left"><input type="text" name="usertext" id="usertext" size="40" value="${$uid.$user}{'usertext'}" maxlength="50" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="signature"><b>$profile_txt{'85'}:</b><br /><span class="small">$profile_txt{'606'}</span></label></td>  
       <td align="left"><textarea name="signature" id="signature" rows="4" cols="30" style="width: 100%">$signature</textarea><br />  
           <span class="small">$profile_txt{'664'} <input value="$MaxSigLen" size="3" name="msgCL" class="windowbg" style="border: 0px; width: 40px; padding: 1px; font-size: 11px;" readonly="readonly" /></span><br /><br />  
           <script type="text/javascript" language="JavaScript">  
           <!--  
               var supportsKeys = false;  
               function tick() {  
                   calcCharLeft(document.forms[0]);  
                   if (!supportsKeys) { timerID = setTimeout("tick()", 1500); }  
               }  
   
               function calcCharLeft(sig) {  
                   clipped = false;  
                   maxLength = $MaxSigLen;  
                   if (document.creator.signature.value.length > maxLength) {  
                       document.creator.signature.value = document.creator.signature.value.substring(0,maxLength);  
                       charleft = 0;  
                       clipped = true;  
                   } else {  
                       charleft = maxLength - document.creator.signature.value.length;  
                   }  
                   document.creator.msgCL.value = charleft;  
                   return clipped;  
               }  
               tick();  
           // -->  
           </script>  
       </td>  
   </tr>~;  
   
   if ($addmemgroup_enabled > 1 && %NoPost) {  
       my ($addmemgroup, $selsize) = &DrawGroups(${$uid.$user}{'addgroups'}, ${$uid.$user}{'position'}, 0);  
   
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="joinmemgroup"><b>$profile_txt{'910'}:</b><br /><span class="small">$profile_txt{'910a'}</span></label></td>  
       <td align="left">  
           <select name="joinmemgroup" id="joinmemgroup" size="$selsize" multiple="multiple">  
           $addmemgroup  
           </select>  
       </td>  
   </tr>~ if $addmemgroup;  
   }  
   
   if    (${$uid.$user}{'numberformat'} == 1) { $unfsl1 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'numberformat'} == 2) { $unfsl2 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'numberformat'} == 3) { $unfsl3 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'numberformat'} == 4) { $unfsl4 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'numberformat'} == 5) { $unfsl5 = ' selected="selected" '; }  
   elsif ($forumnumberformat == 1) { $unfsl1 = ' selected="selected" '; }  
   elsif ($forumnumberformat == 2) { $unfsl2 = ' selected="selected" '; }  
   elsif ($forumnumberformat == 3) { $unfsl3 = ' selected="selected" '; }  
   elsif ($forumnumberformat == 4) { $unfsl4 = ' selected="selected" '; }  
   elsif ($forumnumberformat == 5) { $unfsl5 = ' selected="selected" '; }  
   if    (${$uid.$user}{'timeselect'} == 7) { $tsl7 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 6) { $tsl6 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 5) { $tsl5 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 4) { $tsl4 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 3) { $tsl3 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 2) { $tsl2 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 1) { $tsl1 = ' selected="selected" '; }  
   elsif (${$uid.$user}{'timeselect'} == 8) { $tsl8 = ' selected="selected" '; }  
   elsif ($timeselected == 8) { $tsl8 = ' selected="selected" '; }  
   elsif ($timeselected == 7) { $tsl7 = ' selected="selected" '; }  
   elsif ($timeselected == 6) { $tsl6 = ' selected="selected" '; }  
   elsif ($timeselected == 5) { $tsl5 = ' selected="selected" '; }  
   elsif ($timeselected == 4) { $tsl4 = ' selected="selected" '; }  
   elsif ($timeselected == 3) { $tsl3 = ' selected="selected" '; }  
   elsif ($timeselected == 2) { $tsl2 = ' selected="selected" '; }  
   elsif ($timeselected == 1) { $tsl1 = ' selected="selected" '; }  
   
   my @usertimeoffset = split(/\./, ${$uid.$user}{'timeoffset'});  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="usernumberformat"><b>$profile_txt{'usernumbformat'}:</b></label></td>  
       <td align="left">  
           <select name="usernumberformat" id="usernumberformat" size="1">  
           <option value="1"$unfsl1>10987.65</option>  
           <option value="2"$unfsl2>10987,65</option>  
           <option value="3"$unfsl3>10,987.65</option>  
           <option value="4"$unfsl4>10.987,65</option>  
           <option value="5"$unfsl5>10 987,65</option>  
           </select>  
       </td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="usertimeselect"><b>$profile_txt{'486'}:</b><br />  
           <span class="small">$profile_txt{'479'}</span></label></td>  
       <td align="left">  
           <select name="usertimeselect" id="usertimeselect" size="1">  
           <option value="1"$tsl1>$profile_txt{'480'}</option>  
           <option value="5"$tsl5>$profile_txt{'484'}</option>  
           <option value="4"$tsl4>$profile_txt{'483'}</option>  
           <option value="8"$tsl8>$profile_txt{'483a'}</option>  
           <option value="2"$tsl2>$profile_txt{'481'}</option>  
           <option value="3"$tsl3>$profile_txt{'482'}</option>  
           <option value="6"$tsl6>$profile_txt{'485'}</option>  
           <option value="7"$tsl7>$profile_txt{'480a'}</option>  
           </select>  
       </td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="timeformat"><b>$profile_txt{'486a'}:</b></label></td>  
       <td align="left"><input type="text" name="timeformat" id="timeformat" size="40" value="${$uid.$user}{'timeformat'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="usertimesign"><b>$profile_txt{'371'}:</b><br /><span class="small">$profile_txt{'372'}</span></label></td>  
       <td align="left"><span class="small">$profile_txt{'373'}:<br /><b>~ . &timeformat($date,1) . qq~</b><br /><br /></span><select name="usertimesign" id="usertimesign"><option value="">+</option><option value="-"~ . ($usertimeoffset[0] < 0 ? ' selected="selected"' : '') . qq~>-</option></select>  
           <select name="usertimehour" id="usertimehour">~;  
   for (my $i = 0; 24 > $i; $i++) {  
       $i = sprintf("%02d", $i);  
       $showProfile .= qq~\n            <option value="$i"~ . (($usertimeoffset[0] == $i || $usertimeoffset[0] == -$i) ? ' selected="selected"' : '') . qq~>$i</option>~;  
   }  
   $showProfile .= qq~  
           </select> : <select name="usertimemin">~;  
   for (my $i = 0; 60 > $i; $i++) {  
       my $j = $i / 60;  
       $j = (split(/\./, $j))[1] || 0;  
       $showProfile .= qq~\n            <option value="$j"~ . ($usertimeoffset[1] eq $j ? ' selected="selected"' : '') . qq~>~ . sprintf("%02d", $i) . qq~</option>~;  
   }  
   $showProfile .= qq~  
           </select>  
       </td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="dsttimeoffset"><b>$profile_txt{'519'}</b></label></td>  
       <td align="left"><input type="checkbox" name="dsttimeoffset" id="dsttimeoffset" value="1"~ . (${$uid.$user}{'dsttimeoffset'} ? ' checked="checked"' : '') . qq~ /></td>  
   </tr>  
   <tr class="windowbg">  
       <td align="left"><label for="dynamic_clock"><b>$profile_txt{'520'}</b><br /><span class="small">$profile_txt{'521'}</span></label></td>  
       <td align="left"><input type="checkbox" name="dynamic_clock" id="dynamic_clock" value="1"~ . (${$uid.$user}{'dynamic_clock'} ? ' checked="checked"' : '') . qq~ /></td>  
   </tr>~;  
   
   # This is only for update, when comming from YaBB lower or equal version 2.2.3  
   # I think it can be deleted around version 2.4.0 without causing mayor issues (deti).  
   if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }  
   # End update workaround  
   if ($NewNotificationAlert || $enable_notifications == 1 || $enable_notifications == 3) {  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left" valign="top"><label for="onlinealert"><b>$profile_txt{'onlinealert'}:</b></label></td>  
       <td align="left">~;  
   
       $showProfile .= qq~  
           <input type="checkbox" value="1" name="onlinealert" id="onlinealert"~ . (${$uid.$user}{'onlinealert'} ? ' checked="checked"' : '') . qq~ /> <label for="onlinealert">$profile_txt{'onlinealertexplain'}</label>~ if $NewNotificationAlert;  
   
       if ($enable_notifications == 1 || $enable_notifications == 3) {  
           $showProfile .= qq~<br />  
           <br />~ if $NewNotificationAlert;  
   
           $showProfile .= qq~  
           <label for="notify_N">$profile_txt{'326'}</label>?&nbsp;<select name="notify_N" id="notify_N">  
           <option value="0"~ . ((!${$uid.$user}{'notify_me'} || ${$uid.$user}{'notify_me'} == 2) ? '' : ' selected="selected"') . qq~>$profile_txt{'164'}</option>  
           <option value="1"~ . ((${$uid.$user}{'notify_me'} == 1 || ${$uid.$user}{'notify_me'} == 3) ? ' selected="selected"' : '') . qq~>$profile_txt{'163'}</option>  
           </select>~;  
       }  
   
       $showProfile .= qq~  
       </td>  
   </tr>~;  
   }  
   
   if ($ttsureverse) {  
       ${$uid.$user}{'reversetopic'} = $ttsreverse unless exists(${$uid.$user}{'reversetopic'});  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="reversetopic"><b>$profile_txt{'810'}</b><br /><span class="small">$profile_txt{'811'}</span></label></td>  
       <td align="left" valign="top"><input type="checkbox" name="reversetopic" id="reversetopic"~ . (${$uid.$user}{'reversetopic'} ? qq~ checked="checked"~ : '') . qq~ /></td>  
   </tr>~;  
   }  
   
   foreach my $curtemplate (sort{ $templateset{$a} cmp $templateset{$b} } keys %templateset) {  
       $selected = '';  
       if ($curtemplate eq ${$uid.$user}{'template'}) { $selected = qq~ selected="selected"~; $akttemplate = $curtemplate; }  
       $drawndirs .= qq~<option value="$curtemplate"$selected>$curtemplate</option>\n~;  
   }  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="usertemplate"><b>$profile_txt{'814'}</b><br /><span class="small">$profile_txt{'815'}</span></label></td>  
       <td align="left"><select name="usertemplate" id="usertemplate">$drawndirs</select></td>  
   </tr>~;  
   
   opendir(DIR, $langdir);  
   my @lfilesanddirs = readdir(DIR);  
   close(DIR);  
   foreach my $fld (sort {lc($a) cmp lc($b)} @lfilesanddirs) {  
       if (-e "$langdir/$fld/Main.lng") {  
               my $displang = $fld;  
               $displang =~ s~(.+?)\_(.+?)$~$1 ($2)~gi;  
               if (${$uid.$user}{'language'} eq $fld) { $drawnldirs .= qq~<option value="$fld" selected="selected">$displang</option>~; }  
               else { $drawnldirs .= qq~<option value="$fld">$displang</option>~; }  
       }  
   }  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left"><label for="userlanguage"><b>$profile_txt{'817'}</b><br /><span class="small">$profile_txt{'815'}</span></label></td>  
       <td align="left"><select name="userlanguage" id="userlanguage">$drawnldirs</select></td>  
   </tr>~;  
   
   if ($extendedprofiles) {  
       require "$sourcedir/ExtendedProfiles.pl";  
       $showProfile .= &ext_editprofile($user,"options");  
   }  
   
   $showProfile .= qq~  
   <tr class="catbg">  
       <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" /><br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span></td>  
   </tr>  
</table>  
</form>~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
} }
   
sub ModifyProfileBuddy { sub ModifyProfileBuddy {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
     $menucolors[3] = 'selected-bg';
     ProfileMenu();
   
     my $scriptAction = q~profileBuddy2~;
     if ($view) {
         $scriptAction = q~myprofileBuddy2~;
         $yytitle =
  qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_buddy_list{'buddylist'}~;
         $profiletitle =
  qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_buddy_list{'buddylist'}~;
         $yynavigation =
  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;
     }
     else {
         $yytitle =
           qq~$profile_txt{'79'} &rsaquo; $profile_buddy_list{'buddylist'}~;
         $profiletitle =
  qq~$profile_txt{'79'} ($user) &rsaquo; $profile_buddy_list{'buddylist'}~;
         $yynavigation = qq~&rsaquo; $profiletitle~;
     }
   
     if ( !$yyjavascript ) { $yyjavascript = q{}; }
     $yyjavascript .= qq~
         function imWin() {
                 window.open('$scripturl?action=imlist;sort=mlletter;toid=buddylist','Blist','status=no,height=345,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no');
         }
         // removes a user from the list
         function removeUser(oElement) {
                 var oList = oElement.options;
                 var indexToRemove = oList.selectedIndex;
                 if (oList.length > 1 || (oList.length == 1 && oList[0].value != '0')) {
                         //alert('element [' + oElement.options[indexToRemove].value + ']');
                         if (confirm("$profile_buddy_list{'removealert'}")) {
                                 oElement.remove(indexToRemove);
                         }
                 }
         }
         function selectblNames() {
                 var oList = document.getElementById('buddylist');
                 for (var i = 0; i < oList.options.length; i++) {
                         oList.options[i].selected = true;
                 }
         }
         ~;
   
   $menucolors[3] = "titlebg";     my $buildBuddyList = q{}; 
   &ProfileMenu;     if ( ${ $uid . $user }{'buddylist'} ) { 
         my @buddies = split /\|/xsm, ${ $uid . $user }{'buddylist'};
         chomp @buddies;
         foreach my $buddy (@buddies) {
             LoadUser($buddy);
             if ( ${ $uid . $buddy }{'realname'} ) {
                 $buildBuddyList .=
  qq~<option value="$buddy">${$uid.$buddy}{'realname'}</option>~;
             }
         }
     }
   
   my $scriptAction = qq~profileBuddy2~;     $showProfile .= qq~ 
   if ($view) {  <form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" onsubmit="javascript: selectblNames();">~; 
       $scriptAction = qq~myprofileBuddy2~;     $showProfile .= $myprofile_buddy; 
       $yytitle = qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_buddy_list{'buddylist'}~;  
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_buddy_list{'buddylist'}~;     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;     $showProfile =~ s/{yabb buildBuddyList}/$buildBuddyList/sm; 
   } else {     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
       $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_buddy_list{'buddylist'}~;  
       $profiletitle = qq~$profile_txt{'79'} ($user) &rsaquo; $profile_buddy_list{'buddylist'}~;     if ( !$view ) { 
       $yynavigation = qq~&rsaquo; $profiletitle~;         $yymain .= $showProfile; 
   }         template(); 
     }
   if (!$yyjavascript) { $yyjavascript = ''; }     return; 
   $yyjavascript .= qq~  
   function imWin() {  
       window.open('$scripturl?action=imlist;sort=mlletter;toid=buddylist','Blist','status=no,height=345,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no');  
   }  
   // removes a user from the list  
   function removeUser(oElement) {  
       var oList = oElement.options;  
       var indexToRemove = oList.selectedIndex;  
       if (oList.length > 1 || (oList.length == 1 && oList[0].value != '0')) {  
           //alert('element [' + oElement.options[indexToRemove].value + ']');  
           if (confirm("$profile_buddy_list{'removealert'}")) {  
               oElement.remove(indexToRemove);  
           }  
       }  
   }  
   function selectblNames() {  
       var oList = document.getElementById('buddylist');  
       for (var i = 0; i < oList.options.length; i++) {  
           oList.options[i].selected = true;  
       }  
   }  
   ~;  
   
   $showProfile .= qq~  
<form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" onsubmit="javascript: selectblNames();">  
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">  
   <tr>  
       <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b></td>  
   </tr>~;  
   
   my $buildBuddyList = '';  
   if(${$uid.$user}{'buddylist'}) {  
       my @buddies = split(/\|/, ${$uid.$user}{'buddylist'});  
       chomp @buddies;  
       foreach my $buddy (@buddies) {  
           &LoadUser($buddy);  
           $buildBuddyList .= qq~<option value="$buddy">${$uid.$buddy}{'realname'}</option>~ if ${$uid.$buddy}{'realname'};  
       }  
   }  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><b>$profile_buddy_list{'buddylist'}</b><br /><span class="small">$profile_buddy_list{'explain'}</span></td>  
       <td align="left"><select name="buddylist" id="buddylist" multiple="multiple" size="3" style="width: 250px; height: 150px;" ondblclick="removeUser(this);">$buildBuddyList</select>  
       <br /><span class="small"><a href="javascript: void(0);" onclick="imWin();">$profile_buddy_list{'add'}</a></span>  
       </td>  
   </tr>  
   ~;  
   
   $showProfile .= qq~<tr class="catbg">  
           <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" /><br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span></td>  
       </tr>  
   </table>  
</form>~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
} }
   
sub ModifyProfileIM { sub ModifyProfileIM {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
     $menucolors[4] = 'selected-bg';
     ProfileMenu();
   
     $yyjavascript .= qq~
         function imWin() {
                 window.open('$scripturl?action=imlist;sort=mlletter;toid=ignore','Ilist','status=no,height=345,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no');
         }
         // removes a user from the list
         function removeUser(oElement) {
                 var oList = oElement.options;
                 var indexToRemove = oList.selectedIndex;
                 if (oList.length > 1 || (oList.length == 1 && oList[0].value != '0')) {
                         //alert('element [' + oElement.options[indexToRemove].value + ']');
                         if (confirm("$profile_buddy_list{'removealert'}")) {
                                 oElement.remove(indexToRemove);
                         }
                 }
         }
         function selectINames()        {
                 var oList = document.getElementById('ignore');
                 for (var i = 0; i < oList.options.length; i++) {
                         oList.options[i].selected = true;
                         }
                 }
         ~;
   
     my $scriptAction = q~profileIM2~;
     if ($view) {
         $scriptAction = q~myprofileIM2~;
         $yytitle =
           qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_imtxt{'38'}~;
         $profiletitle =
  qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_imtxt{'38'}~;
         $yynavigation =
  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;
     }
     else {
         $yytitle = qq~$profile_txt{79} &rsaquo; $profile_imtxt{'38'}~;
         $profiletitle =
           qq~$profile_txt{79} ($user) &rsaquo; $profile_imtxt{'38'}~;
         $yynavigation = qq~&rsaquo; $profiletitle~;
     }
     my $ignoreallChecked = q{};
     if ( ${ $uid . $user }{'im_ignorelist'} eq q{*} ) {
         $ignoreallChecked = ' checked="checked"';
     }
     if (   ${ $uid . $user }{'im_ignorelist'}
         && ${ $uid . $user }{'im_ignorelist'} ne q{*} )
     {
         my @ignoreList = split /\|/xsm, ${ $uid . $user }{'im_ignorelist'};
         chomp @ignoreList;
         foreach my $ignoreName (@ignoreList) {
             LoadUser($ignoreName);
             my $ignoreUser;
             if ( ${ $uid . $ignoreName }{'realname'} ) {
                 $ignoreUser = ${ $uid . $ignoreName }{'realname'};
             }
             else { $ignoreUser = $ignoreName; }
             $ignoreName = cloak($ignoreName);
             $my_ignore .=
  qq~\n                        <option value="$ignoreName">$ignoreUser</option>~;
         }
     }
   
     if ( $enable_notifications > 1 ) {
         $my_PM_notifyme =
           ${ $uid . $user }{'notify_me'} < 2 ? ' selected="selected"' : q{};
         $my_PM_notifyme_2 =
           ${ $uid . $user }{'notify_me'} > 1 ? ' selected="selected"' : q{};
   
         $my_PMnotify = $myprofile_PMnotify;
         $my_PMnotify =~ s/{yabb my_PM_notifyme}/$my_PM_notifyme/sm;
         $my_PMnotify =~ s/{yabb my_PM_notifyme_2}/$my_PM_notifyme_2/sm;
     }
   
   $menucolors[4] = "titlebg";     if ( ${ $uid . $user }{'im_popup'} ) { 
   &ProfileMenu;         $enable_userimpopup = ' checked="checked"'; 
     }
     if ( ${ $uid . $user }{'im_imspop'} ) {
         $popup_userim = 'checked="checked"';
     }
     my $pmviewMessChecked;
     if ( ${ $uid . $user }{'pmviewMess'} ) {
         $pmviewMessChecked = ' checked="checked"';
     }
     if ($extendedprofiles) {
         require Sources::ExtendedProfiles;
         $my_extprofile .= ext_editprofile( $user, 'im' );
     }
   
   $yyjavascript .= qq~    $showProfile .= qq~
   function imWin() {  <form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" onsubmit="javascript:selectINames();" >~; 
       window.open('$scripturl?action=imlist;sort=mlletter;toid=ignore','Ilist','status=no,height=345,width=464,menubar=no,toolbar=no,top=50,left=50,scrollbars=no');     $showProfile .= $myprofile_PMpref; 
   }  
   // removes a user from the list     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm; 
   function removeUser(oElement) {     $showProfile =~ s/{yabb my_ignore}/$my_ignore/sm; 
       var oList = oElement.options;     $showProfile =~ s/{yabb enable_userimpopup}/$enable_userimpopup/sm; 
       var indexToRemove = oList.selectedIndex;     $showProfile =~ s/{yabb popup_userim}/$popup_userim/sm; 
       if (oList.length > 1 || (oList.length == 1 && oList[0].value != '0')) {     $showProfile =~ s/{yabb pmviewMessChecked}/$pmviewMessChecked/sm; 
           //alert('element [' + oElement.options[indexToRemove].value + ']');     $showProfile =~ s/{yabb my_extprofile}/$my_extprofile/sm; 
           if (confirm("$profile_buddy_list{'removealert'}")) {     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
               oElement.remove(indexToRemove);     $showProfile =~ s/{yabb my_PMnotify}/$my_PMnotify/sm; 
           }  
       }     if ( !$view ) { 
   }         $yymain .= $showProfile; 
   function selectINames()    {         template(); 
       var oList = document.getElementById('ignore');     } 
       for (var i = 0; i < oList.options.length; i++) {     return; 
           oList.options[i].selected = true;  
           }  
       }  
   ~;  
   
   my $scriptAction = qq~profileIM2~;  
   if ($view) {  
       $scriptAction = qq~myprofileIM2~;  
       $yytitle = qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_imtxt{'38'}~;  
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_imtxt{'38'}~;  
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;  
   } else {  
       $yytitle = qq~$profile_txt{79} &rsaquo; $profile_imtxt{'38'}~;  
       $profiletitle = qq~$profile_txt{79} ($user) &rsaquo; $profile_imtxt{'38'}~;  
       $yynavigation = qq~&rsaquo; $profiletitle~;  
   }  
   
   $showProfile .= qq~  
<form action="$scripturl?action=$scriptAction;username=$useraccount{$INFO{'username'}};sid=$INFO{'sid'}" method="post" name="creator" onsubmit="javascript:selectINames();" >  
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">  
   <tr>  
       <td colspan="2" class="catbg" align="left"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" valign="top" align="left"><b>$profile_txt{'325'}:</b><br /><span class="small">$profile_txt{'ignoreexplain'}</span></td>  
       <td align="left">  
           <select name="ignore" id="ignore" size="4" multiple="multiple" style="width:250px;" ondblclick="removeUser(this);" >~;  
   
   my $ignoreallChecked = "";  
   if (${$uid.$user}{'im_ignorelist'} eq "*") { $ignoreallChecked = ' checked="checked"'; }  
   if (${$uid.$user}{'im_ignorelist'} && ${$uid.$user}{'im_ignorelist'} ne "*") {  
       my @ignoreList = split('\|', ${$uid.$user}{'im_ignorelist'});  
       chomp @ignoreList;  
       foreach my $ignoreName (@ignoreList) {  
           &LoadUser($ignoreName);  
           my $ignoreUser;  
           if(${$uid.$ignoreName}{'realname'}) {$ignoreUser = ${$uid.$ignoreName}{'realname'};}  
           else {$ignoreUser = $ignoreName;}  
           $ignoreName = &cloak($ignoreName);  
           $showProfile .= qq~\n            <option value="$ignoreName">$ignoreUser</option>~;  
       }  
   }  
   $showProfile .= qq~  
           </select>  
           <br />  
           <input type="checkbox" name="ignoreall" id="ignoreall" $ignoreallChecked /> <label for="ignoreall">$profile_txt{'ignoreall'}</label><br />  
           <span class="small"><a href="javascript:void(0);" onclick="imWin();">$profile_txt{'ignorelistadd'}</a></span>  
       </td>  
   </tr>~;  
   
   # This is only for update, when comming from YaBB lower or equal version 2.2.3  
   # I think it can be deleted around version 2.4.0 without causing mayor issues (deti).  
   if ($enable_notifications eq '') { $enable_notifications = $enable_notification ? 3 : 0; }  
   # End update workaround  
   
   if ($enable_notifications > 1) {  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td align="left" valign="top"><label for="notify_PM"><b>$profile_txt{'327'}:</b></label></td>  
       <td align="left">  
           <select name="notify_PM" id="notify_PM">  
           <option value="0"~ . (${$uid.$user}{'notify_me'} < 2 ? '' : ' selected="selected"') . qq~>$profile_txt{'164'}</option>  
           <option value="1"~ . (${$uid.$user}{'notify_me'} > 1 ? ' selected="selected"' : '') . qq~>$profile_txt{'163'}</option>  
           </select>  
       </td>  
   </tr>~;  
   }  
   
   if (${$uid.$user}{'im_popup'})  { $enable_userimpopup = ' checked="checked"'; }  
   if (${$uid.$user}{'im_imspop'}) { $popup_userim = 'checked="checked"'; }  
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="userpopup"><b>$profile_imtxt{'05'}</b></label></td>  
       <td align="left"><input type="checkbox" name="userpopup" id="userpopup" value="1"$enable_userimpopup /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="popupims"><b>$profile_imtxt{'53'}</b></label></td>  
       <td align="left"><input type="checkbox" name="popupims" id="popupims" value="1"$popup_userim /></td>  
   </tr>~;  
   if($enable_PMcontrols || $enable_PMprev) {  
       my $pmmessprevChecked;  
       if (${$uid.$user}{'pmmessprev'}) { $pmmessprevChecked = ' checked="checked"'; }  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="pmmessprev"><b>$profile_txt{'enabprev'}: </b><br /><span class="small">$profile_txt{'prevexplain'}</span></label></td>  
       <td align="left"><input type="checkbox" name="pmmessprev" id="pmmessprev" value="1"$pmmessprevChecked /></td>  
   </tr>~;  
   }  
   if($enable_PMcontrols || $enable_PMviewMess) {  
       my $pmviewMessChecked;  
       if (${$uid.$user}{'pmviewMess'}) { $pmviewMessChecked = ' checked="checked"'; }  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="pmviewMess"><b>$profile_txt{'viewmess'}: </b><br /><span class="small">$profile_txt{'viewmessexplain'}</span></label></td>  
       <td align="left"><input type="checkbox" name="pmviewMess" id="pmviewMess" value="1"$pmviewMessChecked /></td>  
   </tr>~;  
   }  
   if ($enable_PMcontrols || $enable_PMActprev) {  
       my $pmactprevChecked;  
       if (${$uid.$user}{'pmactprev'}) { $pmactprevChecked = ' checked="checked"'; }  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="pmactprev"><b>$profile_txt{'actprev'}: </b><br /><span class="small">$profile_txt{'actprevexplain'}</span></label></td>  
       <td align="left"><input type="checkbox" name="pmactprev" id="pmactprev" value="1"$pmactprevChecked /></td>  
   </tr>~;  
   }  
   
   if ($extendedprofiles) {  
       require "$sourcedir/ExtendedProfiles.pl";  
       $showProfile .= &ext_editprofile($user,"im");  
   }  
   
   $showProfile .= qq~  
   <tr class="catbg">  
       <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" /><br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span></td>  
   </tr>  
</table>  
</form>~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
} }
   
sub ModifyProfileAdmin { sub ModifyProfileAdmin {
   &is_admin_or_gmod;     is_admin_or_gmod(); 
     SidCheck($action);
     PrepareProfile();
   
     $menucolors[5] = 'selected-bg';
     ProfileMenu();
   
     my @grps = sort keys %Group;
     my @memstat = ();
     $mygrp = 0;
     for ( @grps ) {
         if ( ${ $uid . $user }{'position'} eq $_ ) {
             @memstat = split /\|/xsm, $Group{$_};
             $tt = $memstat[0];
             $mygrp = 1;
         }
     }
     if ( $mygrp != 1) {
         if ( ${ $uid . $user }{'position'} ) {
         $ttgrp = ${ $uid . $user }{'position'};
         ( $tt, undef ) = split /\|/xsm, $NoPost{$ttgrp}, 2;
         }
         else { $tt = ${ $uid . $user }{'position'}; }
     }
   
   &SidCheck($action);     $regreason = ${ $uid . $user }{'regreason'}; 
   &PrepareProfile;     $regreason =~ s/<br \/>/\n/gsm; 
   
   $menucolors[5] = "titlebg";     my ( $tta, $selsize ); 
   &ProfileMenu;     if (%NoPost) { 
         ( $tta, $selsize ) =
           DrawGroups( ${ $uid . $user }{'addgroups'}, q{}, 1 );
     }
   
   ($MemStatAdmin, $MemStarNumAdmin, $MemStarPicAdmin, $MemTypeColAdmin) = split(/\|/, $Group{"Administrator"});     $userlastlogin = timeformat( ${ $uid . $user }{'lastonline'} ); 
   ($MemStatGMod,  $MemStarNumGMod,  $MemStarPicGMod,  $MemTypeColGMod)  = split(/\|/, $Group{"Global Moderator"});     $userlastpost  = timeformat( ${ $uid . $user }{'lastpost'} ); 
   ($MemStatMod,   $MemStarNumMod,   $MemStarPicMod,   $MemTypeColMod)   = split(/\|/, $Group{"Moderator"});     $userlastim    = timeformat( ${ $uid . $user }{'lastim'} ); 
     if ( $userlastlogin eq q{} ) { $userlastlogin = $profile_txt{'470'}; }
   if    (${$uid.$user}{'position'} eq 'Administrator') { $tt = $MemStatAdmin; }    if ( $userlastpost eq q{} )  { $userlastpost  = $profile_txt{'470'}; }
   elsif (${$uid.$user}{'position'} eq 'Global Moderator') { $tt = $MemStatGMod; }    if ( $userlastim eq q{} )    { $userlastim    = $profile_txt{'470'}; }
   elsif (${$uid.$user}{'position'}) { $ttgrp = ${$uid.$user}{'position'}; ($tt, undef) = split(/\|/, $NoPost{$ttgrp}, 2); }  
   else { $tt = ${$uid.$user}{'position'}; }     my $scriptAction = q~profileAdmin2~; 
     if ($view) {
   $regreason = ${$uid.$user}{'regreason'};         $scriptAction = q~myprofileAdmin2~; 
   $regreason =~ s~<br \/>~\n~g;         $yytitle = 
           qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'820'}~;
   my ($tta, $selsize);         $profiletitle = 
   if (%NoPost) {  qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'820'}~; 
       ($tta, $selsize) = &DrawGroups(${$uid.$user}{'addgroups'}, '', 1);         $yynavigation = 
   }  qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~; 
     }
   $userlastlogin = &timeformat(${$uid.$user}{'lastonline'});     else { 
   $userlastpost  = &timeformat(${$uid.$user}{'lastpost'});         $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'820'}~; 
   $userlastim    = &timeformat(${$uid.$user}{'lastim'});         $profiletitle = 
   if ($userlastlogin eq '') { $userlastlogin = $profile_txt{'470'}; }           qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'820'}~; 
   if ($userlastpost eq '') { $userlastpost = $profile_txt{'470'}; }         $yynavigation = qq~&rsaquo; $profiletitle~; 
   if ($userlastim eq '') { $userlastim = $profile_txt{'470'}; }    }
     if ( $iamadmin ) {
   my $scriptAction = qq~profileAdmin2~;         for ( @grps ) { 
   if ($view) {             @memstat = split /\|/xsm, $Group{$_}; 
       $scriptAction = qq~myprofileAdmin2~;             if ( $_ ne 'Moderator' ) { 
       $yytitle = qq~$profile_txt{'editmyprofile'} &rsaquo; $profile_txt{'820'}~;                 $my_group .= 
       $profiletitle = qq~$profile_txt{'editmyprofile'} ($user) &rsaquo; $profile_txt{'820'}~;  qq~\n                        <option value="$_">$memstat[0]</option>~; 
       $yynavigation = qq~&rsaquo; <a href="$scripturl?action=mycenter" class="nav">$img_txt{'mycenter'}</a> &rsaquo; $profiletitle~;             } 
   } else {         } 
       $yytitle = qq~$profile_txt{'79'} &rsaquo; $profile_txt{'820'}~;     } 
       $profiletitle = qq~$profile_txt{'79'} ($user) &rsaquo; $profile_txt{'820'}~;  
       $yynavigation = qq~&rsaquo; $profiletitle~;  
   }  
   
   $showProfile .= qq~  
<form action="$scripturl?action=$scriptAction;username=$useraccount{$user};sid=$INFO{'sid'}" method="post" name="creator">  
<table cellspacing="1" cellpadding="4" width="100%" align="center" class="bordercolor" border="0">  
   <tr>  
       <td colspan="2" class="catbg"><img src="$imagesdir/profile.gif" alt="" border="0" /> <b>$profiletitle</b><input type="hidden" name="username" value="$INFO{'username'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="settings6"><b>$profile_txt{'21'}: </b></label></td>  
       <td align="left"><input type="text" name="settings6" id="settings6" size="4" value="${$uid.$user}{'postcount'}" /></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="settings7"><b>$profile_txt{'87'}: </b><br /><span class="small">$profile_txt{'87c'}</span></label></td>  
       <td align="left">  
           <select name="settings7" id="settings7">  
           <option value="${$uid.$user}{'position'}">$tt</option>  
           <option value="${$uid.$user}{'position'}">---------------</option>  
           <option value=""></option>~;  
   
   unless ($iamgmod) {  
       ($title, $stars, $starpic, $color) = split(/\|/, $Group{"Administrator"});  
       $showProfile .= qq~\n            <option value="Administrator">$title</option>~;  
       ($title, $stars, $starpic, $color) = split(/\|/, $Group{"Global Moderator"});  
       $showProfile .= qq~\n            <option value="Global Moderator">$title</option>~;  
   }  
   
   my $z = 0;  
   foreach (@nopostorder) {  
       ($title, $stars, $starpic, $color, undef) = split(/\|/, $NoPost{$_}, 5);  
       $showProfile .= qq~<option value="$_">$title</option>~;  
       $z++;  
   }  
   
   $showProfile .= qq~  
           </select>  
       </td>  
   </tr>~;  
   
   if ($tta ne "") {  
       $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left" valign="top"><label for="addgroup"><b>$profile_txt{'87a'}: </b><br /><span class="small">$profile_txt{'87b'}</span></label></td>  
       <td align="left">  
           <select name="addgroup" id="addgroup" size="$selsize" multiple="multiple">  
           $tta  
           </select>  
       </td>  
   </tr>~;  
   }  
   
   ($dr_secund, $dr_minute, $dr_hour, $dr_day, $dr_month, $dr_year, undef, undef, undef) = localtime(${$uid.$user}{'regtime'} ? ${$uid.$user}{'regtime'} : $forumstart);  
   $dr_month++;  
   
   if ($dr_month > 12) { $dr_month = 12; } ## month cannot be above 12!  
   if ($dr_month < 1) { $dr_month = 1; } ## neither can it be less than 1  
   if ($dr_day > 31) { $dr_day = 31; }  ## day of month over 31  
   if ($dr_day < 1) { $dr_day = 1; }  
   if (length($dr_year) > 2) { $dr_year = substr($dr_year , length($dr_year) - 2, 2); }  
   if ($dr_year < 90 && $dr_year > 50) { $dr_year = 90; } ## a year over 50 is taken to be 1990  
   if ($dr_year > 20 && $dr_year < 51) { $dr_year = 20; } ## a year 50 or lower is taken to be 2020  
   if ($dr_hour > 23) { $dr_hour = 23; }  
   if ($dr_minute > 59) { $dr_minute = 59; }  
   if ($dr_secund > 59) { $dr_secund = 59; }  
   
   $sel_day = qq~  
           <select name="dr_day">\n~;  
   for($i = 1; $i <= 31; $i++) {  
       $day_val = sprintf("%02d", $i);  
       if($dr_day == $i) {  
           $sel_day .= qq~            <option value="$day_val" selected="selected">$i</option>\n~;  
       } else {  
           $sel_day .= qq~            <option value="$day_val">$i</option>\n~;  
       }  
   }  
   $sel_day .= qq~            </select>\n~;  
   
   $sel_month = qq~  
           <select name="dr_month">\n~;  
   for($i = 0; $i < 12; $i++) {  
       $z = $i+1;  
       $month_val = sprintf("%02d", $z);  
       if ($dr_month == $z) {  
           $sel_month .= qq~            <option value="$month_val" selected="selected">$months[$i]</option>\n~;  
       } else {  
           $sel_month .= qq~            <option value="$month_val">$months[$i]</option>\n~;  
       }  
   }  
   $sel_month .= qq~            </select>\n~;  
   
   $sel_year = qq~  
           <select name="dr_year">\n~;  
   for (my $i = 1990; $i <= $year; $i++) {  
       my $year_val = substr($i,2,2);  
       if ($dr_year == $year_val) {  
           $sel_year .= qq~            <option value="$year_val" selected="selected">$i</option>\n~;  
       } else {  
           $sel_year .= qq~            <option value="$year_val">$i</option>\n~;  
       }  
   }  
   $sel_year .= qq~            </select>~;  
   
   $time_sel = ${$uid.$username}{'timeselect'};  
   if($time_sel == 1 || $time_sel == 4 || $time_sel == 5) { $all_date = qq~$sel_month $sel_day $sel_year~; }  
   else { $all_date = qq~$sel_day $sel_month $sel_year~; }  
   $all_date =~ s/<select name/<select id="dr_day_month" name/o;  
   
   $sel_hour = qq~\n  
           <select name="dr_hour">\n~;  
   for($i = 0; $i <= 23; $i++) {  
       my $hour_val = sprintf("%02d", $i);  
       if($dr_hour == $i) {  
           $sel_hour .= qq~            <option value="$hour_val" selected="selected">$hour_val</option>\n~;  
       } else {  
           $sel_hour .= qq~            <option value="$hour_val">$hour_val</option>\n~;  
       }  
   }  
   $sel_hour .= qq~            </select>\n~;  
   
   $sel_minute = qq~  
           <select name="dr_minute">\n~;  
   for($i = 0; $i <= 59; $i++) {  
       $minute_val = sprintf("%02d", $i);  
       if($dr_minute == $i) {  
           $sel_minute .= qq~            <option value="$minute_val" selected="selected">$minute_val</option>\n~;  
       } else {  
           $sel_minute .= qq~            <option value="$minute_val">$minute_val</option>\n~;  
       }  
   }  
   $sel_minute .= qq~            </select>~;  
   
   $showProfile .= qq~  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="dr_day_month"><b>$profile_txt{'233'}:</b></label></td>  
       <td align="left" valign="middle">  
           $all_date $maintxt{'107'} $sel_hour $sel_minute <small>(server <b>localtime</b>)</small>  
           <input type="hidden" value="$dr_secund" name="dr_secund" />  
       </td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><label for="regreason"><b>$profile_txt{'234'}:</b></label></td>  
       <td align="left" valign="middle"><textarea rows="4" cols="50" name="regreason" id="regreason">$regreason</textarea></td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><b>$profile_amv_txt{'9'}: </b></td>  
       <td align="left">$userlastlogin</td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><b>$profile_amv_txt{'10'}: </b></td>  
       <td align="left">$userlastpost</td>  
   </tr>  
   <tr class="windowbg">  
       <td width="320" align="left"><b>$profile_amv_txt{'11'}: </b><br /><br /></td>  
       <td align="left">$userlastim<br /><br /></td>  
   </tr>~;  
   
   if ($extendedprofiles) {  
       require "$sourcedir/ExtendedProfiles.pl";  
       $showProfile .= &ext_editprofile($user,"admin");  
   }  
   
   $showProfile .= qq~  
   <tr class="catbg">  
       <td height="50" valign="middle" align="center" colspan="2"><input type="submit" name="moda" value="$profile_txt{'88'}" class="button" /><br /><span class="small">$profile_txt{'sid_expires_1'} $sid_expires $profile_txt{'sid_expires_2'}</span></td>  
   </tr>  
</table>  
</form>~;  
   
   if (!$view) {  
       $yymain .= $showProfile;  
       &template;  
   }  
}  
   
sub ModifyProfile2 {     my $z = 0; 
   &SidCheck($action);     for (@nopostorder) { 
   &PrepareProfile;         @memstat = split /\|/xsm, 
           $NoPost{$_}, 5;
         $my_group .= qq~<option value="$_">$memstat[0]</option>~;
         $z++;
     }
   
   my (%member, $key, $value);     if ( $tta ne q{} ) { 
   while (($key, $value) = each(%FORM)) {         $my_tta = $myprofile_tta; 
       $value =~ s~\A\s+~~;         $my_tta =~ s/{yabb selsize}/$selsize/sm; 
       $value =~ s~\s+\Z~~;         $my_tta =~ s/{yabb tta}/$tta/sm; 
       $value =~ s~[\n\r]~~g;     } 
       $member{$key} = $value;  
   }  
   $member{'username'} = $user;  
   
   if ($member{'moda'} eq $profile_txt{'88'}) {  
       if ($sessions == 1 && $sessionvalid == 1 && ($iamadmin || $iamgmod) && $username eq $user) {  
           if ($member{'sesquest'} eq "password") { $member{'sesanswer'} = ''; }  
           elsif ($member{'sesanswer'} eq '') { &fatal_error('no_secret_answer'); }  
       }  
   
       if ($member{'passwrd1'} || $member{'passwrd2'}) {  
           &fatal_error("password_mismatch","$member{'username'}") if ($member{'passwrd1'} ne $member{'passwrd2'});  
           &fatal_error("no_password","$member{'username'}") if ($member{'passwrd1'} eq '');  
           &fatal_error("invalid_character","$profile_txt{'36'} $profile_txt{'241'}") if ($member{'passwrd1'} =~ /[^\s\w!\@#\$\%\^&\*\(\)\+\|`~\-=\\:;'",\.\/\?\[\]\{\}]/);  
           &fatal_error("password_is_userid") if ($member{'username'} eq $member{'passwrd1'});  
       }  
   
       if ($member{'bday1'} ne "" || $member{'bday2'} ne "" || $member{'bday3'} ne "") {  
           &fatal_error("invalid_birthdate","($member{'bday1'}/$member{'bday2'}/$member{'bday3'})") if ($member{'bday1'} !~ /^[0-9]+$/ || $member{'bday2'} !~ /^[0-9]+$/ || $member{'bday3'} !~ /^[0-9]+$/ || length($member{'bday3'}) < 4);  
           &fatal_error("invalid_birthdate","($member{'bday1'}/$member{'bday2'}/$member{'bday3'})") if ($member{'bday1'} < 1 || $member{'bday1'} > 12 || $member{'bday2'} < 1 || $member{'bday2'} > 31 || $member{'bday3'} < 1901 || $member{'bday3'} > $year - 5);  
       }  
       $member{'bday1'} =~ s/[^0-9]//g;  
       $member{'bday2'} =~ s/[^0-9]//g;  
       $member{'bday3'} =~ s/[^0-9]//g;  
       if ($member{'bday1'}) { $member{'bday'} = "$member{'bday1'}/$member{'bday2'}/$member{'bday3'}"; }  
       else { $member{'bday'} = ''; }  
   
   
       if ($extendedprofiles) { # run this before you start to save something!  
           require "$sourcedir/ExtendedProfiles.pl";  
           my $error = &ext_validate_submition($username,$user);  
           if ($error ne "") { &fatal_error("extended_profiles_validation",$error); }  
           &ext_saveprofile($user);  
       }  
   
   
       if (${$uid.$user}{'realname'} ne $member{'name'}) {  
           $member{'name'} =~ s~\t+~\ ~g;  
           if ($member{'name'} eq '') { &fatal_error("no_name"); }  
           if ($name_cannot_be_userid && lc $member{'name'} eq lc $member{'username'}) { &fatal_error('name_is_userid'); }  
   
           &LoadCensorList;  
           if (&Censor($member{'name'}) ne $member{'name'}) { &fatal_error("name_censored", &CheckCensor("$member{'name'}")); }  
   
           if (${$uid.$user}{'password'} eq &encode_password($member{'name'})) { &fatal_error("password_is_userid"); }  
   
           &FromChars($member{'name'});  
           $convertstr = $member{'name'};  
           $convertcut = 30;  
           &CountChars;  
           $member{'name'} = $convertstr;  
           &fatal_error("name_too_long") if $cliped;  
           &fatal_error("invalid_character","$profile_txt{'68'} $profile_txt{'241re'}") if $member{'name'} =~ /[^ \w\x80-\xFF\[\]\(\)#\%\+,\-\|\.:=\?\@\^]/;  
   
           &ToHTML($member{'name'});  
           if ($user ne "admin") {  
               # Check to see if name is reserved  
               fopen(FILE, "$vardir/reservecfg.txt") || &fatal_error("cannot_open","$vardir/reservecfg.txt", 1);  
               my @reservecfg = <FILE>;  
               fclose(FILE);  
               chomp(@reservecfg);  
               my $matchword = $reservecfg[0] eq 'checked';  
               my $matchcase = $reservecfg[1] eq 'checked';  
               my $matchname = $reservecfg[3] eq 'checked';  
               my $namecheck = $matchcase eq 'checked' ? $member{'name'} : lc $member{'name'};  
   
               fopen(FILE, "$vardir/reserve.txt") || &fatal_error("cannot_open","$vardir/reserve.txt", 1);  
               my @reserve = <FILE>;  
               fclose(FILE);  
               foreach my $reserved (@reserve) {  
                   chomp $reserved;  
                   my $reservecheck = $matchcase ? $reserved : lc $reserved;  
                   if ($matchname) {  
                       if ($matchword) {  
                           if ($namecheck eq $reservecheck) { &fatal_error('id_reserved',"$reserved"); }  
                       } else {  
                           if ($namecheck =~ $reservecheck) { &fatal_error('id_reserved',"$reserved"); }  
                       }  
                   }  
               }  
           }  
   
       if ((lc &MemberIndex("check_exist", $member{'name'}) eq lc $member{'name'}) && (lc $member{'name'} ne lc ${$uid.$user}{'realname'}) && (lc $member{'name'} ne lc $member{'username'})) { &fatal_error('name_taken',"($member{'name'})"); }  
   
           # rewrite attachments.txt with new username  
           fopen(ATM, "+<$vardir/attachments.txt", 1) || &fatal_error("cannot_open","$vardir/attachments.txt");  
           seek ATM, 0, 0;  
           my @attachments = <ATM>;  
           truncate ATM, 0;  
           seek ATM, 0, 0;  
           for (my $i = 0; $i < @attachments; $i++) {  
               $attachments[$i] =~ s/^(\d+\|\d+\|.*?)\|(.*?)\|/ ($2 eq ${$uid.$user}{'realname'} ? "$1|$member{'name'}|" : "$1|$2|") /e;  
           }  
           print ATM @attachments;  
           fclose(ATM);  
   
           #Since we havenot encountered a fatal error, time to rewrite our memberlist.  
           &ManageMemberinfo("update", $user, $member{'name'});  
       }  
   
       &ToHTML($member{'gender'});  
       &FromChars($member{'location'});  
       &ToHTML($member{'location'});  
       &ToChars($member{'location'});  
       &ToHTML($member{'bday'});  
       &FromChars($member{'sesquest'});  
       &ToHTML($member{'sesquest'});  
       &ToChars($member{'sesquest'});  
   
   
       # Time to print the changes to the username.vars file  
       if ($member{'passwrd1'}) { ${$uid.$user}{'password'} = &encode_password($member{'passwrd1'}); }  
       ${$uid.$user}{'realname'} = $member{'name'};  
       ${$uid.$user}{'gender'} = $member{'gender'};  
       ${$uid.$user}{'location'} = $member{'location'};  
       ${$uid.$user}{'bday'} = $member{'bday'};  
       ${$uid.$user}{'sesquest'} = $member{'sesquest'};  
   
       require "$sourcedir/Decoder.pl";  
       ${$uid.$user}{'sesanswer'} = &scramble($member{'sesanswer'}, $user);  
       ${$uid.$username}{'session'} = &encode_password($user_ip);  
   
       &UserAccount($user, "update");  
   
       &UpdateCookie("write", $user, ${$uid.$user}{'password'}, ${$uid.$user}{'session'}, "/", "") if $member{'passwrd1'} && $username eq $user;  
   
       my $scriptAction = $view ? 'myprofileContacts' : 'profileContacts';  
       $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$member{'username'}};sid=$INFO{'sid'}~;  
   
   } elsif ($member{'moda'} eq $profile_txt{'89'}) {  
       &fatal_error("cannot_kill_admin") if ($member{'username'} eq 'admin');  
   
       # For security, remove username from mod position  
       &KillModerator($member{'username'});  
   
       $noteuser = $iamadmin ? $member{'username'} : $user;  
   
       unlink("$memberdir/$noteuser.dat");  
       unlink("$memberdir/$noteuser.vars");  
       unlink("$memberdir/$noteuser.ims");  
       unlink("$memberdir/$noteuser.msg");  
       unlink("$memberdir/$noteuser.log");  
       unlink("$memberdir/$noteuser.rlog");  
       unlink("$memberdir/$noteuser.outbox");  
       unlink("$memberdir/$noteuser.imstore");  
       unlink("$memberdir/$noteuser.imdraft");  
       unlink("$facesdir/UserAvatars/$1") if ${$uid.$user}{'userpic'} && ${$uid.$user}{'userpic'} =~ /$facesurl\/UserAvatars\/(.+)/;  
   
       &MemberIndex("remove", $noteuser);  
   
       if (!$iamadmin) {  
           &UpdateCookie("delete");  
           $username = 'Guest';  
           $iamguest = 1;  
           $iamadmin = '';  
           $iamgmod = '';  
           $password = '';  
           $yyim = '';  
           $ENV{'HTTP_COOKIE'} = '';  
           $yyuname = '';  
       }  
       $yySetLocation = $scripturl;  
   
   } else {  
       &fatal_error('not_allowed');  
   }  
   
   &redirectexit;     ( 
}         $dr_secund, $dr_minute, $dr_hour, $dr_day, $dr_month, 
         $dr_year,   undef,      undef,    undef
       )
       = gmtime(
           ${ $uid . $user }{'regtime'}
         ? ${ $uid . $user }{'regtime'}
         : $forumstart
       );
     $dr_month++;
   
     if ( $dr_month > 12 ) { $dr_month = 12; }   ## month cannot be above 12!
     if ( $dr_month < 1 )  { $dr_month = 1; }    ## neither can it be less than 1
     if ( $dr_day > 31 )   { $dr_day   = 31; }   ## day of month over 31
     if ( $dr_day < 1 )    { $dr_day   = 1; }
     if ( length($dr_year) > 2 ) {
         $dr_year = substr $dr_year, length($dr_year) - 2, 2;
     }
     if ( $dr_year < 90 && $dr_year > 50 ) {
         $dr_year = 90;
     }    ## a year over 50 is taken to be 1990
     if ( $dr_year > 20 && $dr_year < 51 ) {
         $dr_year = 20;
     }    ## a year 50 or lower is taken to be 2020
     if ( $dr_hour > 23 )   { $dr_hour   = 23; }
     if ( $dr_minute > 59 ) { $dr_minute = 59; }
     if ( $dr_secund > 59 ) { $dr_secund = 59; }
   
     $sel_day = qq~
             <select name="dr_day">\n~;
     for my $i ( 1 .. 31 ) {
         $day_val = sprintf '%02d', $i;
         if ( $dr_day == $i ) {
             $sel_day .=
  qq~                <option value="$day_val" selected="selected">$i</option>\n~;
         }
         else {
             $sel_day .=
               qq~                <option value="$day_val">$i</option>\n~;
         }
     }
     $sel_day .= qq~            </select>\n~;
   
sub ModifyProfileContacts2 {     $sel_month = qq~ 
   &SidCheck($action);             <select name="dr_month">\n~; 
   &PrepareProfile;     for my $i ( 0 .. 11 ) { 
         $z = $i + 1;
         $month_val = sprintf '%02d', $z;
         if ( $dr_month == $z ) {
             $sel_month .=
  qq~                <option value="$month_val" selected="selected">$months[$i]</option>\n~;
         }
         else {
             $sel_month .=
  qq~                <option value="$month_val">$months[$i]</option>\n~;
         }
     }
     $sel_month .= qq~            </select>\n~;
   
   my (%member, $key, $value, $newpassemail, $tempname, $stealth);     $sel_year = qq~ 
   while (($key, $value) = each(%FORM)) {             <select name="dr_year">\n~; 
       $value =~ s~\A\s+~~;     for my $i ( 1990 .. $year ) { 
       $value =~ s~\s+\Z~~;         my $year_val = substr $i, 2, 2; 
       $value =~ s~\r~~g;         if ( $dr_year == $year_val ) { 
       $value =~ s~\n~~g if $key ne 'awayreply';             $sel_year .= 
       $member{$key} = $value;  qq~                <option value="$year_val" selected="selected">$i</option>\n~; 
   }        }
   $member{'username'} = $user;         else { 
             $sel_year .=
   &fatal_error("not_allowed") if $member{'moda'} ne $profile_txt{'88'};               qq~                <option value="$year_val">$i</option>\n~; 
         }
   if ($emailnewpass && lc $member{'email'} ne lc ${$uid.$user}{'email'} && !$iamadmin) {     } 
       srand();     $sel_year .= q~            </select>~; 
       $member{'passwrd1'} = int(rand(100));  
       $member{'passwrd1'} =~ tr/0123456789/ymifxupbck/;  
       $_ = int(rand(77));  
       $_ =~ tr/0123456789/q8dv7w4jm3/;  
       $member{'passwrd1'} .= $_;  
       $_ = int(rand(89));  
       $_ =~ tr/0123456789/y6uivpkcxw/;  
       $member{'passwrd1'} .= $_;  
       $_ = int(rand(188));  
       $_ =~ tr/0123456789/poiuytrewq/;  
       $member{'passwrd1'} .= $_;  
       $_ = int(rand(65));  
       $_ =~ tr/0123456789/lkjhgfdaut/;  
       $member{'passwrd1'} .= $_;  
       ${$uid.$user}{'password'} = &encode_password($member{'passwrd1'});  
       $newpassemail = 1;  
   }  
   
   &fatal_error("no_email") if $member{'email'} eq '';  
   &fatal_error("invalid_character","$profile_txt{'69'} $profile_txt{'241e'}") if $member{'email'} !~ /^[\w\-\.\+]+\@[\w\-\.\+]+\.\w{2,4}$/;  
   &fatal_error("invalid_email") if ($member{'email'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/) || ($member{'email'} !~ /^.+@\[?(\w|[-.])+\.[a-zA-Z]{2,4}|[0-9]{1,4}\]?$/);  
   &LoadCensorList;  
   if (&Censor($member{'email'}) ne $member{'email'}) { &fatal_error("censor2", &CheckCensor("$member{'email'}")); }  
   
   $member{'icq'} =~ s/[^0-9]//g;  
   $member{'aim'} =~ s/ /\+/g;  
   $member{'yim'} =~ s/ /\+/g;  
   $member{'msn'} =~ s/ /\+/g;  
   
   &ToHTML($member{'email'});  
   &ToHTML($member{'icq'});  
   &ToHTML($member{'aim'});  
   &ToHTML($member{'yim'});  
   &ToHTML($member{'msn'});  
   &ToHTML($member{'gtalk'});  
   &ToHTML($member{'skype'});  
   &ToHTML($member{'myspace'});  
   &ToHTML($member{'facebook'});  
   &ToHTML($member{'weburl'});  
   &FromChars($member{'webtitle'});  
   &ToHTML($member{'webtitle'});  
   &ToChars($member{'webtitle'});  
   &ToHTML($member{'offlinestatus'});  
   &FromChars($member{'awaysubj'});  
   &ToHTML($member{'awaysubj'});  
   &ToChars($member{'awaysubj'});  
   
   &FromChars($member{'awayreply'});  
   &ToHTML($member{'awayreply'});  
   $member{'awayreply'} =~ s~\n~<br />~g;  
   $convertstr = $member{'awayreply'};  
   $convertcut = $MaxAwayLen;  
   &CountChars;  
   $member{'awayreply'} = $convertstr;  
   &ToChars($member{'awayreply'});  
   
   if ($extendedprofiles) { # run this before you start to save something!  
       require "$sourcedir/ExtendedProfiles.pl";  
       my $error = &ext_validate_submition($username,$user);  
       if ($error ne "") { &fatal_error("extended_profiles_validation",$error); }  
       &ext_saveprofile($user);  
   }  
   
   # Check to see if email is already taken  
   if (lc ${$uid.$user}{'email'} ne lc $member{'email'}) {  
       $testemail = lc $member{'email'};  
       my $is_existing = &MemberIndex("check_exist", "$testemail");  
       if (lc $is_existing eq $testemail) { &fatal_error("email_taken","($member{'email'})"); }  
   
       # Since we haven't encountered a fatal error, time to rewrite our memberlist a little.  
       &ManageMemberinfo("update", $user, '', $member{'email'});  
   }  
   ## if enabled but not set, default offline status to 'offline'  
   if ($enable_MCaway && $member{'offlinestatus'} eq '') { $member{'offlinestatus'} = 'offline'; }  
   
   # if user is switching 'away' to 'off/on', clean out the away-sent list  
   if ($FORM{'offlinestatus'} eq 'offline') { ${$uid.$user}{'awayreplysent'} = ''; }  
   
   # Time to print the changes to the username.vars file  
   ${$uid.$user}{'email'} = $member{'email'};  
   ${$uid.$user}{'hidemail'} = $member{'hideemail'} ? 1 : 0;  
   ${$uid.$user}{'icq'} = $member{'icq'};  
   ${$uid.$user}{'aim'} = $member{'aim'};  
   ${$uid.$user}{'yim'} = $member{'yim'};  
   ${$uid.$user}{'msn'} = $member{'msn'};  
   ${$uid.$user}{'gtalk'} = $member{'gtalk'};  
   ${$uid.$user}{'skype'} = $member{'skype'};  
   ${$uid.$user}{'myspace'} = $member{'myspace'};  
   ${$uid.$user}{'facebook'} = $member{'facebook'};  
   ${$uid.$user}{'webtitle'} = $member{'webtitle'};  
   ${$uid.$user}{'weburl'} = (($member{'weburl'} && $member{'weburl'} !~ m~\Ahttps?://~) ? "http://" : "") . $member{'weburl'};  
   ${$uid.$user}{'offlinestatus'} = $member{'offlinestatus'};  
   ${$uid.$user}{'awaysubj'} = $member{'awaysubj'};  
   ${$uid.$user}{'awayreply'} = $member{'awayreply'};  
   ${$uid.$user}{'stealth'} = (${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator') ? $member{'stealth'} : "";  
   
   &UserAccount($user, "update");  
   
   if ($emailnewpass && $newpassemail == 1) {  
       &RemoveUserOnline($user); # Remove user from online log  
   
       if ($username eq $user) {  
           &UpdateCookie("delete");  
           $username = 'Guest';  
           $iamguest = 1;  
           $iamadmin = '';  
           $iamgmod = '';  
           $password = '';  
           $yyim = '';  
           $ENV{'HTTP_COOKIE'} = '';  
           $yyuname = '';  
       }  
       &FormatUserName($member{'username'});  
       require "$sourcedir/Mailer.pl";  
       my $scriptAction = $view ? 'myprofile' : 'profile';  
       &sendmail($member{'email'}, qq~$profile_txt{'700'} $mbname~, "$profile_txt{'733'} $member{'passwrd1'} $profile_txt{'734'} $member{'username'}.\n\n$profile_txt{'701'} $scripturl?action=$scriptAction;username=$useraccount{$member{'username'}}\n\n$profile_txt{'130'}");  
       require "$sourcedir/LogInOut.pl";  
       $sharedLogin_title = "$profile_txt{'34'}: $user";  
       $sharedLogin_text = $profile_txt{'638'};  
       $shared_login = &sharedLogin;  
       $yymain .= $shared_login;  
       $yytitle = $profile_txt{'245'};  
       &template;  
   }  
   
   my $scriptAction = $view ? 'myprofileOptions' : 'profileOptions';  
   $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$member{'username'}};sid=$INFO{'sid'}~;  
   &redirectexit;  
}  
   
sub ModifyProfileOptions2 {     $time_sel = ${ $uid . $username }{'timeselect'}; 
   &SidCheck($action);     if ( $time_sel == 1 || $time_sel == 4 || $time_sel == 5 ) { 
   &PrepareProfile;         $all_date = qq~$sel_month $sel_day $sel_year~; 
     }
     else { $all_date = qq~$sel_day $sel_month $sel_year~; }
     $all_date =~ s/<select name/<select id="dr_day_month" name/osm;
   
   my (%member, $key, $value, $tempname);     $sel_hour = qq~ 
   while (($key, $value) = each(%FORM)) {             <select name="dr_hour">\n~; 
       $value =~ s~\A\s+~~;     for my $i ( 0 .. 23 ) { 
       $value =~ s~\s+\Z~~;         my $hour_val = sprintf '%02d', $i; 
       $value =~ s~\r~~g;         if ( $dr_hour == $i ) { 
       $value =~ s~\n~~g if $key ne 'signature';             $sel_hour .= 
       $member{$key} = $value;  qq~                        <option value="$hour_val" selected="selected">$hour_val</option>\n~; 
   }        }
   $member{'username'} = $user;         else { 
             $sel_hour .=
   &fatal_error("not_allowed") if $member{'moda'} ne $profile_txt{'88'};  qq~                        <option value="$hour_val">$hour_val</option>\n~; 
         }
   if (!$minlinksig){ $minlinksig = 0 ;}     } 
   if (${$uid.$user}{'postcount'} < $minlinksig && !$iamadmin && !$iamgmod) {     $sel_hour .= qq~                        </select>\n~; 
       if ($member{'signature'} =~ m~http:\/\/~ || $member{'signature'} =~ m~https:\/\/~ || $member{'signature'} =~ m~ftp:\/\/~ || $member{'signature'} =~ m~www.~ || $member{'signature'} =~ m~ftp.~ =~ m~\[url~ || $member{'signature'} =~ m~\[link~ || $member{'signature'} =~ m~\[img~ || $member{'signature'} =~ m~\[ftp~) {  
           &fatal_error("no_siglinks_allowed");  
       }  
   }  
   &FromChars($member{'usertext'});  
   $convertstr = $member{'usertext'};  
   $convertcut = 51;  
   &CountChars;  
   $member{'usertext'} = $convertstr;  
   &ToHTML($member{'usertext'});  
   &ToChars($member{'usertext'});  
   
   if ($allowpics) {  
       opendir(DIR, "$facesdir") || fatal_error("cannot_open_dir","($facesdir)!<br \/>$profile_txt{'681'}", 1);  
       closedir(DIR);  
   }  
   
   if ($allowpics && $upload_useravatar && $upload_avatargroup) {  
       $upload_useravatar = 0;  
       foreach my $av_gr (split(/, /, $upload_avatargroup)) {  
           if ($av_gr eq ${$uid.$user}{'position'}) { $upload_useravatar = 1; last; }  
           foreach (split(/,/, ${$uid.$user}{'addgroups'})) {  
               if ($av_gr eq $_) { $upload_useravatar = 1; last; }  
           }  
       }  
   }  
   
   my $file = $CGI_query->upload("file_avatar") if $CGI_query;  
   if ($allowpics && $upload_useravatar && $file) {  
       if ($file !~ /\.(gif|png|jpe?g)$/i) {  
           &LoadLanguage('FA');  
           &fatal_error('file_not_uploaded',"$file $fatxt{'20'} gif png jpeg jpg");  
       }  
       my $ext = $1;  
       my $fixfile = ${$uid.$user}{'realname'};  
       if ($fixfile =~ /[^0-9A-Za-z\+\-\.:_]/) { # replace all inappropriate characters  
           # Transliteration  
           my @ISO_8859_1 = qw(A B V G D E JO ZH Z I J K L M N O P R S T U F H C CH SH SHH _ Y _ JE JU JA a b v g d e jo zh z i j k l m n o p r s t u f h c ch sh shh _ y _ je ju ja);  
           my $x = 0;  
           foreach (qw(À Á Â Ã Ä Å ¨ Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å ¸ æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ)) {  
                $fixfile =~ s/$_/$ISO_8859_1[$x]/ig;  
                $x++;  
           }  
           # END Transliteration. Thanks to "Velocity" for this contribution.  
           $fixfile =~ s/[^0-9A-Za-z\+\-\.:_]/_/g;  
       }  
       $fixfile .= ".$ext";  
   
       require "$sourcedir/SpamCheck.pl";  
       my $spamdetected = &spamcheck("$fixfile");  
       if (!$iamadmin && !$iamgmod && !$iammod){  
           if ($spamdetected == 1) {  
               ${$uid.$username}{'spamcount'}++;  
               ${$uid.$username}{'spamtime'} = $date;  
               &UserAccount($username,"update");  
               $spam_hits_left_count = $post_speed_count - ${$uid.$username}{'spamcount'};  
               &fatal_error("tsc_alert");  
           }  
       }  
   
       my ($size,$buffer,$filesize,$file_buffer);  
       while ($size = read($file, $buffer, 512)) { $filesize += $size; $file_buffer .= $buffer; }  
       if ($avatar_limit && $filesize > (1024 * $avatar_limit)) {  
           &LoadLanguage('FA');  
           &fatal_error('file_not_uploaded',"$fatxt{'21'} $file (" . int($filesize / 1024) . " KB) $fatxt{'21b'} " . $avatar_limit);  
       }  
       if ($avatar_dirlimit) {  
           my $dirsize = &dirsize("$facesdir/UserAvatars");  
           if ($filesize > ((1024 * $avatar_dirlimit) - $dirsize)) {  
               &LoadLanguage('FA');  
               &fatal_error('file_not_uploaded',"$fatxt{'22'} $file (" . (int($filesize / 1024) - $avatar_dirlimit + int($dirsize / 1024)) . " KB) $fatxt{'22b'}");  
           }  
       }  
   
       unlink("$facesdir/UserAvatars/$1") if ${$uid.$user}{'userpic'} =~ /$facesurl\/UserAvatars\/(.+)/;  
       $fixfile = &check_existence("$facesdir/UserAvatars", $fixfile);  
   
       # create a new file on the server using the formatted ( new instance ) filename  
       if (fopen(NEWFILE, ">$facesdir/UserAvatars/$fixfile")) {  
           binmode NEWFILE; # needed for operating systems (OS) Windows, ignored by Linux  
           print NEWFILE $file_buffer; # write new file on HD  
           fclose(NEWFILE);  
   
       } else { # return the server's error message if the new file could not be created  
           &fatal_error("file_not_open","$facesdir/UserAvatars");  
       }  
   
       # check if file has actually been uploaded, by checking the file has a size  
       unless (-s "$facesdir/UserAvatars/$fixfile") {  
           &fatal_error("file_not_uploaded",$fixfile);  
       }  
   
       my $illegal;  
       if ($fixfile =~ /gif$/i) {  
           my $header;  
           fopen(ATTFILE, "$facesdir/UserAvatars/$fixfile");  
           read(ATTFILE, $header, 10);  
           my $giftest;  
           ($giftest, undef, undef, undef, undef, undef) = unpack("a3a3C4", $header);  
           fclose(ATTFILE);  
           if ($giftest ne "GIF") { $illegal = $giftest; }  
       }  
       fopen(ATTFILE, "$facesdir/UserAvatars/$fixfile");  
       while ( read(ATTFILE, $buffer, 1024) ) {  
           if ($buffer =~ /<(html|script|body)/ig) { $illegal = $1; last; }  
       }  
       fclose(ATTFILE);  
       if ($illegal) { # delete the file as it contains illegal code  
           unlink("$facesdir/UserAvatars/$fixfile");  
           &ToHTML($illegal);  
           &fatal_error("file_not_uploaded","$fixfile <= illegal code ($illegal) inside image file!");  
       }  
   
       $member{'userpic'} = "$facesurl/UserAvatars/$fixfile";  
   
   } elsif ($member{'userpicpersonalcheck'} && ($member{'userpicpersonal'} =~ /\.gif\Z/i || $member{'userpicpersonal'} =~ /\.jpe?g\Z/i || $member{'userpicpersonal'} =~ /\.png\Z/i)) {  
       $member{'userpic'} = $member{'userpicpersonal'};  
   }  
   if ($member{'userpic'} eq "" || !$allowpics) { $member{'userpic'} = "blank.gif"; }  
   &fatal_error("invalid_character","$profile_txt{'592'}") if $member{'userpic'} !~ m^\A[0-9a-zA-Z_\.\#\%\-\:\+\?\$\&\~\.\,\@/]+\Z^;  
   unlink("$facesdir/UserAvatars/$1") if $member{'userpic'} ne ${$uid.$user}{'userpic'} && ${$uid.$user}{'userpic'} =~ /$facesurl\/UserAvatars\/(.+)/;  
   
   if ($member{'usertemplate'} ne '' && !$templateset{$member{'usertemplate'}}) { &fatal_error('invalid_template'); }  
   if ($member{'usertemplate'} eq '') { $member{'usertemplate'} = $template; }  
   if ($member{'userlanguage'} ne '' && !-e "$langdir/$member{'userlanguage'}/Main.lng") { &fatal_error('invalid_language'); }  
   if ($member{'userlanguage'} eq '') { $member{'userlanguage'} = $language; }  
   
   if ($extendedprofiles) { # run this before you start to save something!  
       require "$sourcedir/ExtendedProfiles.pl";  
       my $error = &ext_validate_submition($username,$user);  
       if ($error ne "") { &fatal_error("extended_profiles_validation",$error); }  
       &ext_saveprofile($user);  
   }  
   
   if ($member{'usertimesign'} !~ /^-?$/ || $member{'usertimehour'} !~ /^\d+$/ || $member{'usertimemin'} !~ /^\d+$/) { &fatal_error("invalid_time_offset","$member{'usertimesign'}$member{'usertimehour'}.$member{'usertimemin'}"); }  
   
   # update notifications if users language is changed  
   if (${$uid.$user}{'language'} ne "$member{'userlanguage'}") {  
       require "$sourcedir/Notify.pl";  
       &updateLanguage($user, $member{'userlanguage'});  
   }  
   
   if ($addmemgroup_enabled > 1) {  
       my %groups;  
       map { $groups{$_} = 2; } split(/,/, ${$uid.$user}{'addgroups'});  
       map { $groups{$_} = 1; } split(/, /, $member{'joinmemgroup'});  
       my @nopostmember;  
       foreach (keys %NoPost) {  
           next if ${$uid.$user}{'position'} eq $_;  
           if ($groups{$_} == 1 && (split /\|/, $NoPost{$_})[10]) { push(@nopostmember, $_); }  
           elsif ($groups{$_} == 2 && !(split /\|/, $NoPost{$_})[10]) { push(@nopostmember, $_); }  
       }  
       $member{'joinmemgroup'} = join(',', @nopostmember);  
       if ($member{'joinmemgroup'} eq '') { $member{'joinmemgroup'} = "###blank###"; }  
       if ($member{'joinmemgroup'} ne ${$uid.$user}{'addgroups'}) {  
           &ManageMemberinfo("update", $user, '', '', '', '', $member{'joinmemgroup'});  
       }  
       if ($member{'joinmemgroup'} eq "###blank###") { $member{'joinmemgroup'} = ''; }  
       ${$uid.$user}{'addgroups'} = $member{'joinmemgroup'};  
   }  
   
   &FromChars($member{'signature'});  
   &ToHTML($member{'signature'});  
   $member{'signature'} =~ s~\n~<br />~g;  
   $convertstr = $member{'signature'};  
   $convertcut = $MaxSigLen;  
   &CountChars;  
   $member{'signature'} = $convertstr;  
   &ToChars($member{'signature'});  
   
   &ToHTML($member{'userpic'});  
   &ToHTML($member{'usertemplate'});  
   &ToHTML($member{'userlanguage'});  
   &ToHTML($member{'timeformat'});  
   
   # Time to print the changes to the username.vars file  
   ${$uid.$user}{'usertext'} = $member{'usertext'};  
   ${$uid.$user}{'userpic'} = $member{'userpic'};  
   ${$uid.$user}{'signature'} = $member{'signature'};  
   ${$uid.$user}{'timeoffset'} = "$member{'usertimesign'}$member{'usertimehour'}.$member{'usertimemin'}";  
   ${$uid.$user}{'onlinealert'} = $member{'onlinealert'} ? 1 : 0;  
   ${$uid.$user}{'notify_me'} = $member{'notify_N'} ? ((!${$uid.$user}{'notify_me'} || ${$uid.$user}{'notify_me'} == 1) ? 1 : 3) : ((${$uid.$user}{'notify_me'} == 2 || ${$uid.$user}{'notify_me'} == 3) ? 2 : 0);  
   ${$uid.$user}{'reversetopic'} = $member{'reversetopic'} ? 1 : 0;  
   ${$uid.$user}{'dsttimeoffset'} = $member{'dsttimeoffset'} ? 1 : 0;  
   ${$uid.$user}{'dynamic_clock'} = $member{'dynamic_clock'} ? 1 : 0;  
   ${$uid.$user}{'timeselect'} = int($member{'usertimeselect'});  
   ${$uid.$user}{'template'} = $member{'usertemplate'};  
   ${$uid.$user}{'language'} = $member{'userlanguage'};  
   ${$uid.$user}{'timeformat'} = $member{'timeformat'};  
   ${$uid.$user}{'numberformat'} = int($member{'usernumberformat'});  
   
   &UserAccount($user, "update");  
   
   my $scriptAction;  
   if ($iamadmin || ($iamgmod && $allow_gmod_profile && $gmod_access2{'profileAdmin'} eq 'on')) {  
       $scriptAction = qq~profileAdmin~;  
   } else {  
       $scriptAction = qq~viewprofile~;  
   }  
   if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))) {  
       $scriptAction = qq~profileIM~;  
   }  
   if ($buddyListEnabled) {  
       $scriptAction = qq~profileBuddy~;  
   }  
   if ($view) { $scriptAction = qq~my$scriptAction~; }  
   $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$member{'username'}};sid=$INFO{'sid'}~;  
   &redirectexit;  
}  
   
sub ModifyProfileBuddy2 {     $sel_minute = qq~ 
   &SidCheck($action);                         <select name="dr_minute">\n~; 
   &PrepareProfile;     for my $i ( 0 .. 59 ) { 
         $minute_val = sprintf '%02d', $i;
         if ( $dr_minute == $i ) {
             $sel_minute .=
  qq~                        <option value="$minute_val" selected="selected">$minute_val</option>\n~;
         }
         else {
             $sel_minute .=
  qq~                        <option value="$minute_val">$minute_val</option>\n~;
         }
     }
     $sel_minute .= q~                        </select>~;
   
     if ($extendedprofiles) {
         require Sources::ExtendedProfiles;
         $my_extprofile .= ext_editprofile( $user, 'admin' );
     }
   
   my (%member, $key, $value, $tempname);     $myprofile_userinfo = 
   while (($key, $value) = each(%FORM)) {       qq~<input type="hidden" name="username" value="$INFO{'username'}" />~; 
       $value =~ s~\A\s+~~;     $showProfile .= qq~ 
       $value =~ s~\s+\Z~~;  <form action="$scripturl?action=$scriptAction;username=$useraccount{$user};sid=$INFO{'sid'}" method="post" name="creator">~; 
       $value =~ s~[\n\r]~~g;     $showProfile .= $myprofile_admin_a; 
       $member{$key} = $value;     AddModerators(); 
   }     $showProfile .= $myprofile_admin_b; 
   $member{'username'} = $user;     $showProfile .= 
  qq~<textarea rows="4" cols="50" name="regreason" id="regreason">$regreason</textarea>~;
   &fatal_error("not_allowed") if $member{'moda'} ne $profile_txt{'88'};     $showProfile .= $myprofile_admin_bb; 
   
   if ($member{'buddylist'}) {     $showProfile =~ s/{yabb profiletitle}/$profiletitle/sm; 
       my @buddies = split(/\,/, $member{'buddylist'});     $showProfile =~ s/{yabb myprofile_userinfo}/$myprofile_userinfo/sm; 
       chomp(@buddies);     $showProfile =~ s/{yabb postcount}/${$uid.$user}{'postcount'}/sm; 
       $member{'buddylist'} = '';     $showProfile =~ s/{yabb position}/${$uid.$user}{'position'}/gsm; 
       foreach my $cloakedBuddy (@buddies) {     $showProfile =~ s/{yabb tt}/$tt/sm; 
           $cloakedBuddy =~ s/^ //;     $showProfile =~ s/{yabb my_tta}/$my_tta/sm; 
           $cloakedBuddy = &decloak($cloakedBuddy);     $showProfile =~ s/{yabb my_group}/$my_group/sm; 
           &ToHTML($cloakedBuddy);     $showProfile =~ s/{yabb all_date}/$all_date/sm; 
           $member{'buddylist'} = qq~$member{'buddylist'}\|$cloakedBuddy~;     $showProfile =~ s/{yabb sel_hour}/$sel_hour/sm; 
       }     $showProfile =~ s/{yabb sel_minute}/$sel_minute/sm; 
       $member{'buddylist'} =~ s/^\|//;     $showProfile =~ s/{yabb dr_secund}/$dr_secund/sm; 
   }     $showProfile =~ s/{yabb regreason}/$regreason/sm; 
   ${$uid.$user}{'buddylist'} = $member{'buddylist'};     $showProfile =~ s/{yabb userlastlogin}/$userlastlogin/sm; 
   &UserAccount($user, "update");     $showProfile =~ s/{yabb userlastpost}/$userlastpost/sm; 
     $showProfile =~ s/{yabb userlastim}/$userlastim/sm;
   my $scriptAction;     $showProfile =~ s/{yabb my_extprofile}/$my_extprofile/sm; 
   if ($iamadmin || ($iamgmod && $allow_gmod_profile && $gmod_access2{'profileAdmin'} eq 'on')) {     $showProfile =~ s/{yabb sid_expires}/$expiretxt/sm; 
       $scriptAction = qq~profileAdmin~;  
   } else {  ## Mod Hook showProfile_admin ## 
       $scriptAction = qq~viewprofile~;  
   }     if ( !$view ) { 
   if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))) {         $yymain .= $showProfile; 
       $scriptAction = qq~profileIM~;         template(); 
   }    }
   if ($view) { $scriptAction = qq~my$scriptAction~; }     return; 
   $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$member{'username'}};sid=$INFO{'sid'}~;  
   &redirectexit;  
} }
   
sub ModifyProfileIM2 { sub ModifyProfile2 {
   &SidCheck($action);     SidCheck($action); 
   &PrepareProfile;     PrepareProfile(); 
   
   my (%member, $key, $value, $ignorelist);     my ( %member, $key, $value ); 
   while (($key, $value) = each(%FORM)) {    while ( ( $key, $value ) = each %FORM ) {
       $value =~ s~\A\s+~~;         $value =~ s/\A\s+//sm; 
       $value =~ s~\s+\Z~~;         $value =~ s/\s+\Z//sm; 
       $value =~ s~[\n\r]~~g if $key ne 'ignore';         $value =~ s/[\n\r]//gxsm; 
       $member{$key} = $value;        $member{$key} = $value;
   }    }
   $member{'username'} = $user;    $member{'username'} = $user;
   
   &fatal_error("not_allowed") if $member{'moda'} ne $profile_txt{'88'};  
   
   if (!$member{'ignoreall'}) {  
       my @ignoreList = split(/\,/, $member{'ignore'});  
       chomp (@ignoreList);  
       foreach my $cloakedIgnore (@ignoreList)    {  
           $cloakedIgnore =~s/\A //;  
           $cloakedIgnore =~s/ \Z//;  
           $cloakedIgnore = &decloak($cloakedIgnore);  
           &ToHTML ($cloakedIgnore);  
           $ignorelist .= qq~\|$cloakedIgnore~;  
       }  
       $ignorelist =~ s~\A\|~~;  
   } else {  
       $ignorelist = '*';  
   }  
   
   # Time to print the changes to the username.vars file  
   ${$uid.$user}{'im_ignorelist'} = $ignorelist;  
   ${$uid.$user}{'notify_me'} = $member{'notify_PM'} ? ((!${$uid.$user}{'notify_me'} || ${$uid.$user}{'notify_me'} == 2) ? 2 : 3) : ((${$uid.$user}{'notify_me'} == 1 || ${$uid.$user}{'notify_me'} == 3) ? 1 : 0);  
   ${$uid.$user}{'im_popup'} = $member{'userpopup'} ? 1 : 0;  
   ${$uid.$user}{'im_imspop'} = $member{'popupims'} ? 1 : 0;  
   ${$uid.$user}{'pmactprev'} = $member{'pmactprev'} ? 1 : 0;  
   ${$uid.$user}{'pmmessprev'} = $member{'pmmessprev'} ? 1 : 0;  
   ${$uid.$user}{'pmviewMess'} = $member{'pmviewMess'} ? 1 : 0;  
   
   if ($extendedprofiles) { # run this before you start to save something!  
       require "$sourcedir/ExtendedProfiles.pl";  
       my $error = &ext_validate_submition($username,$user);  
       if ($error ne "") { &fatal_error("extended_profiles_validation",$error); }  
       &ext_saveprofile($user);  
   }  
   &UserAccount($user, "update");  
   
   my $scriptAction = qq~viewprofile~;  
   if ($iamadmin || ($iamgmod && $allow_gmod_profile && $gmod_access2{'profileAdmin'} eq 'on')) {  
       $scriptAction = qq~profileAdmin~;  
   }  
   if ($view) { $scriptAction = qq~my$scriptAction~; }  
   $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$member{'username'}};sid=$INFO{'sid'}~;  
   &redirectexit;  
}  
   
sub ModifyProfileAdmin2 {    if ( $member{'moda'} eq $profile_txt{'88'} ) {
   &is_admin_or_gmod;         if (   $sessions == 1 
             && $sessionvalid == 1
             && ( $iamadmin || $iamgmod )
             && $username eq $user )
         {
             if ( $member{'sesquest'} eq 'password' ) {
                 $member{'sesanswer'} = q{};
             }
             elsif ( $member{'sesanswer'} eq q{} ) {
                 fatal_error('no_secret_answer');
             }
         }
   
   &SidCheck($action);         if ( $member{'passwrd1'} || $member{'passwrd2'} ) { 
   &PrepareProfile;             if ( $member{'passwrd1'} ne $member{'passwrd2'} ) { 
                 fatal_error( 'password_mismatch', "$member{'username'}" );
             }
             if ( $member{'passwrd1'} eq q{} ) {
                 fatal_error( 'no_password', "$member{'username'}" );
             }
             if ( $member{'passwrd1'} =~
                 /[^\s\w!\@#\$\%\^&\*\(\)\+\|`~\-=\\:;'",\.\/\?\[\]\{\}]/xsm )
             {
                 fatal_error( 'invalid_character',
                     "$profile_txt{'36'} $profile_txt{'241'}" );
             }
             if ( $member{'username'} eq $member{'passwrd1'} ) {
                 fatal_error('password_is_userid');
             }
         }
   
   my (%member, $key, $value);         if (   ${ $uid . $user }{'gender'} 
   while (($key, $value) = each(%FORM)) {             && $editGenderLimit 
       $value =~ s~\A\s+~~;             && ${ $uid . $user }{'disablegender'} >= $editGenderLimit 
       $value =~ s~\s+\Z~~;             && !$iamadmin 
       $value =~ s~[\n\r]~~g if $key ne 'regreason';             && ( !$iamgmod || !$allow_gmod_profile ) ) 
       $member{$key} = $value;         { 
   }             if ( $member{'gender'} ne ${ $uid . $user }{'gender'} ) { 
   $member{'username'} = $user;                 fatal_error('not_allowed_gender_edit'); 
             }
   &fatal_error("cannot_kill_admin") if $member{'moda'} ne $profile_txt{'88'};         } 
   
   if (!$iamadmin && ($member{'settings7'} eq "Administrator" || $member{'settings7'} eq "Global Moderator")) {  
       $member{'settings7'} = ${$uid.$user}{'position'};  
   }  
   
   if ($member{'settings6'} eq '') { $member{'settings6'} = 0; }  
   if ($member{'settings6'} !~ /\A[0-9]+\Z/) { &fatal_error('invalid_postcount'); }  
   &fatal_error('cannot_regroup_admin') if $member{'username'} eq 'admin' && $member{'settings7'} ne 'Administrator';  
   
   $dr_month  = $member{'dr_month'};  
   $dr_day    = $member{'dr_day'};  
   $dr_year   = $member{'dr_year'};  
   $dr_hour   = $member{'dr_hour'};  
   $dr_minute = $member{'dr_minute'};  
   $dr_secund = $member{'dr_secund'};  
   
   if ($dr_month == 4 || $dr_month == 6 || $dr_month == 9 || $dr_month == 11) {  
       $max_days = 30;  
   } elsif ($dr_month == 2 && $dr_year % 4 == 0) {  
       $max_days = 29;  
   } elsif ($dr_month == 2 && $dr_year % 4 != 0) {  
       $max_days = 28;  
   } else {  
       $max_days = 31;  
   }  
   if ($dr_day > $max_days) { $dr_day = $max_days; }  
   
   $member{'dr'} = qq~$dr_month/$dr_day/$dr_year $maintxt{'107'} $dr_hour:$dr_minute:$dr_secund~;  
   
   if ($member{'settings6'} != ${$uid.$user}{'postcount'} || $member{'settings7'} ne ${$uid.$user}{'position'}) {  
       if ($member{'settings7'}) {  
           $grp_after = qq~$member{'settings7'}~;  
       } else {  
           foreach $postamount (sort { $b <=> $a } keys %Post) {  
               if ($member{'settings6'} >= $postamount) {  
                   ($title, undef) = split(/\|/, $Post{$postamount}, 2);  
                   $grp_after = $title;  
                   last;  
               }  
           }  
       }  
       &ManageMemberinfo("update", $user, '', '', $grp_after, $member{'settings6'});  
   }  
   
   my %groups;  
   map { $groups{$_} = 1; } split(/, /, $member{'addgroup'});  
   my @nopostmember;  
   foreach (keys %NoPost) {  
       next if $member{'settings7'} eq $_;  
       push(@nopostmember, $_) if $groups{$_};  
   }  
   $member{'addgroup'} = join(',', @nopostmember);  
   if ($member{'addgroup'} eq '') { $member{'addgroup'} = "###blank###"; }  
   if ($member{'addgroup'} ne ${$uid.$user}{'addgroups'}) {  
       &ManageMemberinfo("update", $user, '', '', '', '', $member{'addgroup'});  
   }  
   if ($member{'addgroup'} eq "###blank###") { $member{'addgroup'} = ''; }  
   ${$uid.$user}{'addgroups'} = $member{'addgroup'};  
   
   if ($member{'dr'} ne ${$uid.$user}{'regdate'}) {  
       $newreg = &stringtotime($member{'dr'});  
       $newreg = sprintf("%010d", $newreg);  
       &ManageMemberlist("update", $user, $newreg);  
       ${$uid.$user}{'regtime'} = $newreg;  
   }  
   
   if (!$iamadmin) { $member{'dr'} = ${$uid.$user}{'regdate'}; }  
   &FromChars($member{'regreason'});  
   &ToHTML($member{'regreason'});  
   &ToChars($member{'regreason'});  
   $member{'regreason'} =~ s~[\n\r]{1,2}~<br />~g;  
   ${$uid.$user}{'regreason'} = $member{'regreason'};  
   ${$uid.$user}{'postcount'} = $member{'settings6'};  
   ${$uid.$user}{'position'}  = $member{'settings7'};  
   ${$uid.$user}{'regdate'}   = $member{'dr'};  
   ${$uid.$user}{'stealth'}   = "" if ${$uid.$user}{'position'} ne 'Administrator' && ${$uid.$user}{'position'} ne 'Global Moderator';  
   
   if ($extendedprofiles) { # run this before you start to save something!  
       require "$sourcedir/ExtendedProfiles.pl";  
       my $error = &ext_validate_submition($username,$user);  
       if ($error ne "") { &fatal_error("extended_profiles_validation",$error); }  
       &ext_saveprofile($user);  
   }  
   &UserAccount($user, "update");  
   
   my $scriptAction = $view ? 'myviewprofile' : 'viewprofile';  
   $yySetLocation = qq~$scripturl?action=$scriptAction;username=$useraccount{$user}~;  
   &redirectexit;  
}  
   
sub ViewProfile {         if (   ${ $uid . $user }{'bday'} 
   if ($iamguest) { &fatal_error('members_only'); }             && $editAgeLimit 
             && ${ $uid . $user }{'disableage'} >= $editAgeLimit
             && !$iamadmin
             && ( !$iamgmod || !$allow_gmod_profile ) )
         {
             ( $user_birth_month, $user_birth_day, $user_birth_year ) =
               split /\//xsm, ${ $uid . $user }{'bday'};
             if (   $member{'bday1'} != $user_birth_month
                 || $member{'bday2'} != $user_birth_day
                 || $member{'bday3'} != $user_birth_year )
             {
                 fatal_error('not_allowed_birthdate_change');
             }
         }
   
   # If someone registers with a '+' in their name It causes problems.         if ( ( $birthday_on_reg > 1 && !$iamadmin && ( !$iamgmod || !$allow_gmod_profile ) ) && ( $member{'bday1'} eq q{} || $member{'bday2'} eq q{} || $member{'bday3'} eq q{} ) ) 
   # Get's turned into a <space> in the query string Change it back here.         { 
   # Users who register with spaces get them replaced with _             fatal_error( 'invalid_birthdate', "($member{'bday1'}/$member{'bday2'}/$member{'bday3'})" ); 
   # So no problem there.         } 
   $INFO{'username'} =~ tr/ /+/;          elsif ( $member{'bday1'} ne q{} || $member{'bday2'} ne q{} || $member{'bday3'} ne q{} ) { 
             if ( $member{'bday1'} !~ /^[0-9]+$/xsm || $member{'bday2'} !~ /^[0-9]+$/xsm || $member{'bday3'} !~ /^[0-9]+$/xsm || length( $member{'bday3'} ) < 4 ) {
   $user = $INFO{'username'};                 fatal_error( 'invalid_birthdate', 
   if ($do_scramble_id) { &decloak($user); }                     "($member{'bday1'}/$member{'bday2'}/$member{'bday3'})" ); 
   if ($user =~ m~/~)  { &fatal_error('no_user_slash'); }            }
   if ($user =~ m~\\~) { &fatal_error('no_user_backslash'); }             elsif (   $member{'bday1'} < 1 
                 || $member{'bday1'} > 12
   unless (&LoadUser($user)) { &fatal_error('no_profile_exists'); }                 || $member{'bday2'} < 1 
   &LoadMiniUser($user) if $user eq $username;                 || $member{'bday2'} > 31 
                 || $member{'bday3'} < 1901
   my ($memberinfo, $modify, $email, $gender, $avstyle, $pic);                 || $member{'bday3'} > $year - 5 ) 
   my ($pic_row, $buddybutton, $row_addgrp, $row_gender, $row_age, $row_location, $row_icq, $row_aim, $row_yim, $row_msn, $row_gtalk, $row_skype, $row_myspace, $row_facebook, $row_email, $row_website, $row_signature, $showusertext);             { 
                 fatal_error( 'invalid_birthdate',
   # Convert forum start date to string, if there is no date set,                     "($member{'bday1'}/$member{'bday2'}/$member{'bday3'})" ); 
   # Defaults to 1st Jan, 2005             } 
   $forumstart = $forumstart ? &stringtotime($forumstart) : "1104537600";         } 
         $member{'bday1'} =~ s/[^0-9]//gxsm;
   $memsettingsd[9] = ${$uid.$user}{'aim'};         $member{'bday2'} =~ s/[^0-9]//gxsm; 
   $memsettingsd[9] =~ tr/+/ /;         $member{'bday3'} =~ s/[^0-9]//gxsm; 
   $memsettingsd[10] = ${$uid.$user}{'yim'};         if ( $member{'bday1'} ) { 
   $memsettingsd[10] =~ tr/+/ /;             $member{'bday'} = 
               "$member{'bday1'}/$member{'bday2'}/$member{'bday3'}";
   if (${$uid.$user}{'regtime'}) {         } 
       $dr = &timeformat(${$uid.$user}{'regtime'});         else { $member{'bday'} = q{}; } 
   } else {  
       $dr = $profile_txt{'470'};  
   }  
   
   &CalcAge($user, "calc");   # How old is he/she?  
   &CalcAge($user, "isbday"); # is it the bday?  
   if ($isbday) { $isbday = qq~<img src="$imagesdir/bdaycake.gif" width="40" />~; }  
   
   ## only show the 'modify' button if not using 'my center' or admin/gmod viewing  
   $modify = (!$view && ($user ne "admin" || $username eq "admin") && ($iamadmin || ($iamgmod && $allow_gmod_profile && ${$uid.$user}{'position'} ne "Administrator"))) ? qq~<a href="$scripturl?action=profileCheck;username=$useraccount{$user}">$img{'modify'}</a>~ : "&nbsp;";  
   
   if ($allowpics) {  
       if (${$uid.$user}{'userpic'} eq "blank.gif") {  
           $pic = qq~<img src="$imagesdir/nn.gif" name="avatar_img_resize" alt="" border="0" style="display:none" />~;  
       } elsif (${$uid.$user}{'userpic'} =~ /^https?:\/\//) {  
           $pic = qq~<img src="${$uid.$user}{'userpic'}" name="avatar_img_resize" alt="" border="0" style="display:none" />~;  
       } else {  
           $pic = qq~<img src="$facesurl/${$uid.$user}{'userpic'}" name="avatar_img_resize" alt="" border="0" style="display:none" />~;  
       }  
       $pic_row = qq~<div style="float: left; width: 20%; text-align: center; padding: 5px 5px 5px 0px;">  
           $pic  
           </div>~;  
   }  
   
   if ($buddyListEnabled && $user ne $username) {  
       &loadMyBuddy;  
       $buddybutton = "<br />" . ($mybuddie{$user} ? qq~<img src="$imagesdir/buddylist.gif" border="0" align="middle" alt="$display_txt{'isbuddy'}" /> $display_txt{'isbuddy'}~ : qq~<a href="$scripturl?action=addbuddy;name=$useraccount{$user}">$img{'addbuddy'}</a>~);  
   }  
   
   # Hide empty profile fields from display  
   if ($addmembergroup{$user}) {  
       $showaddgr = $addmembergroup{$user};  
       $showaddgr =~ s/<br \/>/\, /g;  
       $showaddgr =~ s/\A, //;  
       $showaddgr =~ s/, \Z//;  
       $row_addgrp .= qq~<br /><span class="small">$showaddgr</span>~;  
   }  
   if (${$uid.$user}{'gender'}) {  
       if (${$uid.$user}{'gender'} eq 'Male') { $gender = $profile_txt{'238'}; }  
       elsif (${$uid.$user}{'gender'} eq 'Female') { $gender = $profile_txt{'239'}; }  
       $row_gender = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'231'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           $gender  
           </div>~;  
   }  
   if ($age) {  
       $row_age = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'420'}:</b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           $age &nbsp; $isbday  
           </div>~;  
   }  
   if (${$uid.$user}{'location'}) {  
       $row_location = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'227'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           ${$uid.$user}{'location'}  
           </div>~;  
   }  
   if (${$uid.$user}{'icq'} && ${$uid.$user}{'icq'} !~ m/\D/) {  
       $row_icq .= qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'513'}:</b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <a href="http://web.icq.com/${$uid.$user}{'icq'}" title="${$uid.$user}{'icq'}" target="_blank">  
           <img src="http://web.icq.com/whitepages/online?icq=${$uid.$user}{'icq'}&#38;img=5" alt="${$uid.$user}{'icq'}" border="0" style="vertical-align: middle;" /> ${$uid.$user}{'icq'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'aim'}) {  
       $row_aim = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'603'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <a href="aim:goim?screenname=${$uid.$user}{'aim'}&#38;message=Hi,+are+you+there?">  
           <img src="$imagesdir/aim.gif" alt="${$uid.$user}{'aim'}" border="0" style="vertical-align: middle;" /> $memsettingsd[9]</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'yim'}) {  
       $row_yim = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'604'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="http://opi.yahoo.com/online?u=${$uid.$user}{'yim'}&#38;m=g&#38;t=0" border="0" alt="${$uid.$user}{'yim'}" style="vertical-align: middle;" />  
           <a href="http://edit.yahoo.com/config/send_webmesg?.target=${$uid.$user}{'yim'}" target="_blank"> $memsettingsd[10]</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'msn'}) {  
       $row_msn = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'823'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="$imagesdir/msn.gif" alt="" border="0" style="vertical-align: middle;" />  
           <a href="#" onclick="window.open('$scripturl?action=setmsn;msnname=$user','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false">$profile_txt{'823'} ${$uid.$user}{'realname'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'gtalk'}) {  
       $row_gtalk = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'825'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="$imagesdir/gtalk2.gif" alt="" border="0" style="vertical-align: middle;" />  
           <a href="#" onclick="window.open('$scripturl?action=setgtalk;gtalkname=$user','','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'); return false">$profile_txt{'825'} ${$uid.$user}{'realname'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'skype'}) {  
       $row_skype = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px;  padding-bottom: 5px;">  
           <b>$profile_txt{'827'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="$imagesdir/skype.gif" alt="" border="0" style="vertical-align: middle;" />  
           <a href="javascript:void(window.open('callto://${$uid.$user}{'skype'}','skype','height=80,width=340,menubar=no,toolbar=no,scrollbars=no'))">$profile_txt{'827'} ${$uid.$user}{'realname'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'myspace'}) {  
       $row_myspace = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px;  padding-bottom: 5px;">  
           <b>$profile_txt{'570'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="$imagesdir/myspace.gif" alt="" border="0" style="vertical-align: middle;" />  
           <a href="http://www.myspace.com/${$uid.$user}{'myspace'}" target="_blank">$profile_txt{'570'} ${$uid.$user}{'realname'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'facebook'}) {  
       $row_facebook = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px;  padding-bottom: 5px;">  
           <b>$profile_txt{'573'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <img src="$imagesdir/facebook.gif" alt="" border="0" style="vertical-align: middle;" />  
           <a href="http://www.facebook.com/~ . (${$uid.$user}{'facebook'} !~ /\D/ ? "profile.php?id=" : "") . qq~${$uid.$user}{'facebook'}" target="_blank"> ${$uid.$user}{'facebook'}</a>  
           </div>~;  
   }  
   if (!${$uid.$user}{'hidemail'} || $iamadmin || !$allow_hide_email || $view) {  
       my $rowEmail = '';  
       if ($view) {  
           if (!${$uid.$user}{'hidemail'}) {  
               $rowEmail = $profile_txt{'showingemail'};  
           } else {  
               my ($admtitle, undef) = split(/\|/, $Group{'Administrator'}, 2);  
               $rowEmail = qq~$profile_txt{'notshowingemail'} $admtitle$profile_txt{'notshowingemailend'}~;  
           }  
       } else {  
           $rowEmail = &enc_eMail("$profile_txt{'889'} ${$uid.$user}{'realname'}",${$uid.$user}{'email'},'','');  
       }  
   
       $row_email = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'69'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           $rowEmail  
           </div>~;  
   }  
   if (!$minlinkweb) { $minlinkweb = 0; }  
   if (${$uid.$user}{'weburl'} && ${$uid.$user}{'webtitle'} && (${$uid.$user}{'postcount'} >= $minlinkweb || ${$uid.$user}{'position'} eq 'Administrator' || ${$uid.$user}{'position'} eq 'Global Moderator')) {  
       $row_website = qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'96'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <a href="${$uid.$user}{'weburl'}" target="_blank">${$uid.$user}{'webtitle'}</a>  
           </div>~;  
   }  
   if (${$uid.$user}{'signature'}) {  
       # do some ubbc on the signature to display in the view profile area  
       $message     = ${$uid.$user}{'signature'};  
       $displayname = ${$uid.$user}{'realname'};  
   
       if ($enable_ubbc) {  
           if (!$yyYaBBCloaded) { require "$sourcedir/YaBBC.pl"; }  
           &DoUBBC(1);  
       }  
   
       &ToChars($message);  
   
       # Censor the signature.  
       &LoadCensorList;  
       $message = &Censor($message);  
   
       $row_signature = qq~  
   <tr>  
       <td class="catbg" align="left">  
           <img src="$imagesdir/profile.gif" alt="" border="0" style="vertical-align: middle;" />&nbsp;  
           <span class="text1"><b>$profile_txt{'85'}</b></span>  
       </td>  
   </tr>  
   <tr>  
       <td align="left" class="windowbg2">  
           <div style="float: left; width: 100%; padding-top: 8px; padding-bottom: 8px; overflow: auto;">  
           $message  
           </div>  
       </td>  
   </tr>~;  
   
       if ($img_greybox) {  
           $yyinlinestyle .= qq~<link href="$yyhtml_root/greybox/gb_styles.css" rel="stylesheet" type="text/css" />\n~;  
           $yyjavascript .= qq~  
var GB_ROOT_DIR = "$yyhtml_root/greybox/";  
// -->  
</script>  
<script type="text/javascript" src="$yyhtml_root/AJS.js"></script>  
<script type="text/javascript" src="$yyhtml_root/AJS_fx.js"></script>  
<script type="text/javascript" src="$yyhtml_root/greybox/gb_scripts.js"></script>  
<script type="text/javascript">  
<!--~;  
       }  
   }  
   
   # End empty field checking  
   
   # Just maths below...  
   $post_count = ${$uid.$user}{'postcount'};  
   if (!$post_count) { $post_count = 0 }  
   
   $string_regdate = &stringtotime(${$uid.$user}{'regdate'});  
   $string_curdate = $date;  
   
   #if ($string_regdate < $forumstart) { $string_regdate = $forumstart }  
   if ($string_curdate < $forumstart) { $string_curdate = $forumstart }  
   
   $member_for_days = int(($string_curdate - $string_regdate) / 86400);  
   
   if ($member_for_days < 1) { $tmpmember_for_days = 1; }  
   else { $tmpmember_for_days = $member_for_days; }  
   $post_per_day = sprintf("%.2f", ($post_count / $tmpmember_for_days));  
   $member_for_days = &NumberFormat($member_for_days);  
   $post_per_day = &NumberFormat($post_per_day);  
   $post_count = &NumberFormat($post_count);  
   
   # End statistics.  
   if (${$uid.$user}{'usertext'}) {  
       # Censor the usertext and wrap it  
       &LoadCensorList;  
       $showusertext = &WrapChars(&Censor(${$uid.$user}{'usertext'}),20);  
   }  
   
   $showProfile .= qq~  
<table border="0" cellpadding="8" cellspacing="1" class="bordercolor" align="center" width="100%">~;  
   if (!$view) {  
       $yynavigation = qq~&rsaquo; $profile_txt{'92'}~;  
       $showProfile .= qq~  
   <tr>  
       <td class="titlebg" width="100%" align="left">  
           <div class="text1" style="float: left; width: 100%;">~;  
           if ($iamadmin || $iamgmod) {  
               $showProfile .= qq~  
           <img src="$imagesdir/profile.gif" alt="" border="0" style="vertical-align: middle;" />&nbsp; <b>$profile_txt{'35'}: $INFO{'username'}</b>~;  
           } else {  
               $showProfile .= qq~  
           <img src="$imagesdir/profile.gif" alt="" border="0" style="vertical-align: middle;" />&nbsp; <b>$profile_txt{'68'}: ${$uid.$INFO{'username'}}{'realname'}</b>~;  
           }  
           $showProfile .= qq~  
           </div>  
       </td>  
   </tr>~;  
   }  
   $showProfile .= qq~  
   <tr>  
       <td class="windowbg" valign="middle">  
           $pic_row  
           <div style="float: left; width: 60%; padding-top: 5px;  padding-bottom: 5px;">  
           <span style="font-size: 18px;">${$uid.$user}{'realname'}</span><br />  
           $col_title{$user}  
           $row_addgrp<br />  
           $memberstar{$user}  
           ~ . &userOnLineStatus($user) . qq~<br />  
           <span class="small">$showusertext</span>  
           <span class="small">$buddybutton</span>  
           </div>  
           <div style="float: right; width: 19%; text-align: right;">  
           $modify  
           </div>  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" align="left" valign="top">  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'21'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$post_count<br />$post_per_day</b> $profile_txt{'893'}  
           </div>  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'233'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           $dr<br /><b>$member_for_days</b> $profile_txt{'894'}  
           </div>  
       </td>  
   </tr>~;  
   
   if ($row_gender || $row_age || $row_location) {  
       $showProfile .= qq~  
   <tr>  
       <td class="windowbg2" align="left" valign="top">  
           $row_gender  
           $row_age  
           $row_location  
       </td>  
   </tr>~;  
   }  
   
   if ($extendedprofiles) {  
       require "$sourcedir/ExtendedProfiles.pl";  
       $showProfile .= &ext_viewprofile($user);  
   }  
   
   $showProfile .= qq~  
   <tr>  
       <td class="catbg" align="left">  
           <img src="$imagesdir/profile.gif" alt="" border="0" style="vertical-align: middle;" />&nbsp;  
           <span class="text1"><b>$profile_txt{'819'}</b></span>  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" align="left">~;  
   
   &CheckUserPM_Level($user);  
   if (!$view && $user ne $username && ($PM_level == 1 || ($PM_level == 2 && $UserPM_Level{$user} > 1 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && $UserPM_Level{$user} == 3 && ($iamadmin || $iamgmod)))) {  
       $showProfile .= qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;">  
           <b>$profile_txt{'144'}: </b>  
           </div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">  
           <a href="$scripturl?action=imsend;to=$useraccount{$user}">$profile_txt{'688'} ${$uid.$user}{'realname'}</a>  
           </div>~;  
   }  
   
   $showProfile .= qq~  
           $row_email  
           $row_website  
           $row_aim  
           $row_msn  
           $row_skype  
           $row_yim  
           $row_gtalk  
           $row_myspace  
           $row_facebook  
           $row_icq  
       </td>  
   </tr>~;  
   
   $userlastlogin = &timeformat(${$uid.$user}{'lastonline'});  
   $userlastpost = &timeformat(${$uid.$user}{'lastpost'});  
   $userlastim = &timeformat(${$uid.$user}{'lastim'});  
   if ($userlastlogin eq "") { $userlastlogin = "$profile_txt{'470'}"; }  
   if ($userlastpost  eq "") { $userlastpost  = "$profile_txt{'470'}"; }  
   if ($userlastim    eq "") { $userlastim    = "$profile_txt{'470'}"; }  
   my ($lastonline, $lastpost, $lastPM);  
   ## MF-B code fix for lpd  
   if (${$uid.$user}{'postcount'} > 0) {  
       $userlastpost = &usersrecentposts(1);  
   }  
   ####  
   if (!$view) {  
       $lastonline = qq~$profile_amv_txt{'9'}~;  
       $lastpost = qq~$profile_amv_txt{'10'}~;  
       $lastPM = qq~$profile_amv_txt{'11'}~;  
   
   } else {  
       $lastonline = qq~$profile_amv_txt{'mylastonline'}~;  
       $lastpost = qq~$profile_amv_txt{'mylastpost'}~;  
       $lastPM = qq~$profile_amv_txt{'mylastpm'}~;  
   }  
   
   $showProfile .= qq~  
   $row_signature  
   <tr>  
       <td class="catbg" align="left">  
           <img src="$imagesdir/profile.gif" alt="" border="0" style="vertical-align: middle;" />&nbsp;  
           <span class="text1"><b>$profile_txt{'459'}</b></span>  
       </td>  
   </tr>  
   <tr>  
       <td class="windowbg2" align="left">  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$lastonline: </b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">$userlastlogin</div>  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$lastpost:</b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">$userlastpost</div>\n~;  
   
   if ($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))) {  
       $showProfile .= qq~  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$lastPM: </b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">$userlastim</div>~;  
   }  
   
   $showProfile .= qq~  
       </td>  
   </tr>~;  
   
   if (($iamadmin || $iamgmod && $gmod_access2{'ipban3'}) && !$view && $user ne $username && ${$uid.$user}{'position'} ne 'Administrator') {  
       $is_banned = &check_banlist("${$uid.$user}{'email'}","","$user");  
           $ban_user_email = ${$uid.$user}{'email'};  
           $ban_user_email =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;  
           if ($is_banned =~/E/) { $ban_email_link = qq~<a href="$adminurl?action=ipban3;ban_email=$ban_user_email;username=$useraccount{$user};unban=1"><span class="small">[$profile_txt{'904'}]</span></a>~; }  
           else { $ban_email_link = qq~<a href="$adminurl?action=ipban3;ban_email=$ban_user_email;username=$useraccount{$user}"><span class="small">[$profile_txt{'907'}]</span></a>~; }  
   
           $ban_user_name = $useraccount{$user};  
           $ban_user_name =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;  
           if ($is_banned =~/U/) { $ban_user_link = qq~<a href="$adminurl?action=ipban3;ban_memname=$ban_user_name;username=$useraccount{$user};unban=1"><span class="small">[$profile_txt{'903'}]</span></a>~; }  
           else { $ban_user_link = qq~<a href="$adminurl?action=ipban3;ban_memname=$ban_user_name;username=$useraccount{$user}"><span class="small">[$profile_txt{'906'}]</span></a>~; }  
   
       # Shows the banning stuff for IP's  
       if (${$uid.$user}{'lastips'}) {  
           ($ip_one, $ip_two, $ip_three) = split (/\|/, ${$uid.$user}{'lastips'});  
   
           if (&check_banlist("","$ip_one","")) { $banlink_one = qq~<a href="$adminurl?action=ipban3;ban=$ip_one;username=$useraccount{$user};unban=1"><span class="small">[$profile_txt{'905'}]</span></a>~; }  
           else { $banlink_one = qq~<a href="$adminurl?action=ipban3;ban=$ip_one;username=$useraccount{$user}"><span class="small">[$profile_txt{'908'}]</span></a>~; }  
   
           if (&check_banlist("","$ip_two","")) { $banlink_two = qq~<a href="$adminurl?action=ipban3;ban=$ip_two;username=$useraccount{$user};unban=1"><span class="small">[$profile_txt{'905'}]</span></a>~; }  
           else { $banlink_two = qq~<a href="$adminurl?action=ipban3;ban=$ip_two;username=$useraccount{$user}"><span class="small">[$profile_txt{'908'}]</span></a>~; }  
   
           if (&check_banlist("","$ip_three","")) { $banlink_three = qq~<a href="$adminurl?action=ipban3;ban=$ip_three;username=$useraccount{$user};unban=1"><span class="small">[$profile_txt{'905'}]</span></a>~; }  
           else { $banlink_three = qq~<a href="$adminurl?action=ipban3;ban=$ip_three;username=$useraccount{$user}"><span class="small">[$profile_txt{'908'}]</span></a>~; }  
   
           if ($ip_one) { $ip_ban_options = qq~$ip_one<br />$banlink_one <br />~; }  
           if ($ip_two) { $ip_ban_options .= qq~$ip_two<br />$banlink_two <br />~; }  
           if ($ip_three) { $ip_ban_options .= qq~$ip_three<br />$banlink_three <br />~; }  
       }  
   
       $showProfile .= qq~  
   <tr>  
       <td class="windowbg2" align="left">  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$profile_txt{'902'}:</b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">$user<br />$ban_user_link</div>  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$profile_txt{'69'}:</b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">${$uid.$user}{'email'}<br />$ban_email_link</div>  
           <div style="float: left; clear: left; width: 30%; padding-top: 5px; padding-bottom: 5px;"><b>$profile_txt{'909'}:</b></div>  
           <div style="float: left; width: 70%; padding-top: 5px; padding-bottom: 5px;">$ip_ban_options</div>  
       </td>  
   </tr>~;  
   }  
   
   if (${$uid.$user}{'postcount'} > 0 && $maxrecentdisplay > 0 && !$view) {  
       $showProfile .= qq~  
   <tr>  
       <td class="windowbg2" align="left">  
           <form action="$scripturl?action=usersrecentposts;username=$useraccount{$user}" method="post">  
           $profile_txt{'460'} <select name="viewscount" size="1">~;  
   
       my ($x,$y) = (int($maxrecentdisplay/5),0);  
       if ($x) {  
           for (my $i = 1; $i <= 5; $i++) {  
               $y = $i * $x;  
               $showProfile .= qq~  
           <option value="$y">$y</option>~;  
           }  
       }  
       $showProfile .= qq~  
           <option value="$maxrecentdisplay">$maxrecentdisplay</option>~ if $maxrecentdisplay > $y;  
   
       $showProfile .= qq~  
           </select> $profile_txt{'461'} ${$uid.$user}{'realname'}.  
           <input type="submit" value="$profile_txt{'462'}" class="button" />  
           </form>  
       </td>  
   </tr>~;  
   }  
   
   $showProfile .= qq~         if ( ${ $uid . $user }{'bday'} ne "$member{'bday'}" ) { 
</table>             $Update_EventCal = 1; 
~;         } 
   
   $yytitle = "$profile_txt{'92'} ${$uid.$user}{'realname'}";         if ( 
   if (!$view) {             $editGenderLimit 
       $yymain .= $showProfile;             && (   ${ $uid . $user }{'gender'} ne $member{'gender'} 
       &template;                 || ${ $uid . $user }{'gender'} eq q{} ) 
   }           ) 
}         { 
             if ( ${ $uid . $user }{'disablegender'} eq q{} ) {
                 ${ $uid . $user }{'disablegender'} = 1;
             }
             else { ${ $uid . $user }{'disablegender'}++; }
         }
         if (
             $editAgeLimit
             && (   ${ $uid . $user }{'bday'} ne $member{'bday'}
                 || ${ $uid . $user }{'bday'} eq q{} )
           )
         {
             if ( ${ $uid . $user }{'disableage'} eq q{} ) {
                 ${ $uid . $user }{'disableage'} = 1;
             }
             else { ${ $uid . $user }{'disableage'}++; }
         }
   
sub usersrecentposts {         # EventCal Begin 
   if ($iamguest) { &fatal_error("members_only"); }         if (   ${ $uid . $user }{'bday'} ne "$member{'bday'}" 
   if ($INFO{'username'} =~ /\//) { &fatal_error("no_user_slash"); }             || ${ $uid . $user }{'hideage'} ne "$member{'hideage'}" ) 
   if ($INFO{'username'} =~ /\\/) { &fatal_error("no_user_backslash"); }         { 
   if (!-e ("$memberdir/$INFO{'username'}.vars")) { &fatal_error("no_profile_exists"); }             $Update_EventCal = 1; 
   &spam_protection if $action =~ /^(?:my)?usersrecentposts$/;         } 
   
   my $curuser = $INFO{'username'};  
   &LoadUser($curuser);  
   
   my $display = $FORM{'viewscount'} ? $FORM{'viewscount'} : $_[0];  
   if (!$display) { $display = 5; }  
   elsif ($display =~ /\D/) { &fatal_error("only_numbers_allowed"); }  
   if ($display > $maxrecentdisplay) { $display = $maxrecentdisplay; }  
   
   my (%data, $numfound, %threadfound, %boardtxt, %recentthreadfound, $recentfound, $save_recent, $boardperms, $curcat, %boardcat, %catinfos, %catboards, $openmemgr, @membergroups, $tmpa, %openmemgr, $curboard, @threads, @boardinfo, $i, $c, @messages, $tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $mns, $counter, $board, $notify, $catid);  
   
   &Recent_Load($curuser);  
   my @recent = sort { ${$recent{$b}}[1] <=> ${$recent{$a}}[1] } grep { ${$recent{$_}}[1] > 0 } keys %recent;  
   my $recentcount = keys %recent;  
   my @data;  
   $#data = $display - 1;  
   @data = map(0, @data);  
   
   if (!$mloaded) { require "$boardsdir/forum.master"; }  
   foreach $catid (@categoryorder) {  
       foreach (split(/\,/, $cat{$catid})) {  
           $boardcat{$_} = $catid;  
           @{$catinfos{$_}} = split(/\|/, $catinfo{$catid}, 3);  
       }  
   }  
   
   recentcheck: foreach $thread (@recent) {  
       &MessageTotals("load",$thread);  
       if (${$thread}{'board'} eq '') {  
           $save_recent = 1;  
           delete $recent{$thread};  
           $recentcount--;  
           next recentcheck;  
       }  
       $curboard = ${$thread}{'board'};  
   
       if (!$boardtxt{$curboard}) {  
           ($boardname{$curboard}, $boardperms, undef) = split(/\|/, $board{$curboard});  
   
           if (!$iamadmin && (!&CatAccess(${$catinfos{$curboard}}[1]) || &AccessCheck($curboard,'',$boardperms) ne "granted")) { $recentcount--; next recentcheck; }  
   
           fopen(FILE, "$boardsdir/$curboard.txt");  
           @{$boardtxt{$curboard}} = <FILE>;  
           fclose(FILE);  
   
           if (!@{$boardtxt{$curboard}}) {  
               $save_recent = 1;  
               delete $recent{$thread};  
               $recentcount--;  
               next recentcheck;  
           }  
       } elsif ($numfound) {  
           $recentfound += $recentthreadfound{$thread} if exists $recentthreadfound{$thread};  
           last if $recentfound >= $display && $data[$#data] > ${$recent{$thread}}[1];  
           next;  
       }  
   
       for ($i = 0; $i < @{$boardtxt{$curboard}}; $i++) {  
           ($tnum, $tsub, $tname, $temail, $tdate, $treplies, $tusername, $ticon, $tstate) = split(/\|/, ${$boardtxt{$curboard}}[$i]);  
   
           if (($display == 1 && $thread == $tnum) || ($display > 1 && exists $recent{$tnum})) {  
               if ($tstate =~ /h/ && !$iamadmin && !$iamgmod) {  
                   $recentcount--;  
               } else {  
                   fopen(FILE, "$datadir/$tnum.txt");  
                   @messages = <FILE>;  
                   fclose(FILE);  
   
                   my $usercheck = 0;  
   
                   for ($c = $#messages; $c >= 0 ; $c--) {  
                       ($msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns) = split(/\|/, $messages[$c]);  
   
                       if ($curuser eq $musername) {  
                           my @i = (@data, $mdate);  
                           @data = sort { $b <=> $a } @i;  
                           if (pop(@data) < $mdate) {  
                               chomp $mns;  
                               $data{$mdate} = [$curboard, $tnum, $c, $tname, $msub, $mname, $memail, $mdate, $musername, $micon, $mattach, $mip, $message, $mns, $tstate];  
                               if (!$usercheck) {  
                                   $numfound++;  
                                   $threadfound{$tnum} = 1;  
                               }  
                               if (exists $recent{$tnum}) {  
                                   $recentthreadfound{$tnum}++;  
                                   $recentfound++ if $thread == $tnum;  
                               }  
                               if (${$recent{$tnum}}[1] < $mdate) {  
                                   $save_recent = 1;  
                                   ${$recent{$tnum}}[1] = $mdate;  
                               }  
                           }  
                           $usercheck = 1;  
                       }  
                   }  
                   if (!$usercheck) {  
                       $save_recent = 1;  
                       delete $recent{$tnum};  
                       $recentcount--;  
                   }  
               }  
           }  
       }  
   }  
   
   if ($recentfound < $display && $numfound < $recentcount) {  
       categorycheck: foreach $catid (@categoryorder) {  
           if (!&CatAccess((split(/\|/, $catinfo{$catid}, 3))[1])) { next categorycheck; }  
   
           boardcheck: foreach $curboard (split(/\,/, $cat