F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\Sessions.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\Sessions.pm
############################################################################### ###############################################################################
# Sessions.pl                                                                 # # Sessions.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.                      #
############################################################################### ###############################################################################
  our $VERSION = '2.6.12';
   
$sessionsplver = 'YaBB 2.5.2 $Revision: 1.2 $'; $sessionspmver = 'YaBB 2.6.12 $Revision: 1651 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
&LoadLanguage('Sessions');  LoadLanguage('Sessions'); 
  get_micon();
  get_template('Other');
   
sub SessionReval { sub SessionReval {
   if (${$uid.$username}{'sesquest'} eq "" || ${$uid.$username}{'sesquest'} eq "password") {     if (   ${ $uid . $username }{'sesquest'} eq q{} 
       $sesremark   = qq~<br /><br /><fieldset><i>$session_txt{'10'}</i></fieldset>~;         || ${ $uid . $username }{'sesquest'} eq 'password' ) 
       $sesquestion = "password";     { 
       $sestype     = "password";         $sesremark = 
   } else {           qq~<br /><br /><fieldset><i>$session_txt{'10'}</i></fieldset>~; 
       $sesremark   = "";         $sesquestion = 'password'; 
         $sestype     = 'password';
     }
     else {
         $sesremark   = q{};
       $sesquestion = "${$uid.$username}{'sesquest'}";        $sesquestion = "${$uid.$username}{'sesquest'}";
       $sestype     = "text";         $sestype     = 'text'; 
   }    }
   
   $yymain .= qq~     $yymain .= $my_sessions; 
<br /><br />     $yymain =~ s/{yabb sesremark}/$sesremark/sm; 
<form action="$scripturl?action=revalidatesession2" method="post" name="sesform">     $yymain =~ s/{yabb sestype}/$sestype/sm; 
<div class="bordercolor" style="padding: 1px; width: 50%; margin-left: auto; margin-right: auto;">     $yymain =~ s/{yabb sesstext3}/$session_txt{'3'}/sm; 
<table width="100%" cellspacing="0" cellpadding="3">     $yymain =~ s/{yabb sesstext4}/$session_txt{'4'}/sm; 
   <tr>     $yymain =~ s/{yabb sesquestion}/$sesquest_txt{$sesquestion}/sm; 
       <td class="titlebg" colspan="3" align="left">     $yymain =~ s/{yabb sesredir}/$INFO{'sesredir'}/sm; 
           <img src="$imagesdir/session.gif" alt="" /><b>$img_txt{'34a'}</b>     $yytitle   = "$img_txt{'34a'}"; 
       </td>     template(); 
   </tr><tr>     return; 
       <td align="left" class="windowbg" colspan="3">  
           $session_txt{'3'}<br /><br />$session_txt{'4'}$sesremark  
       </td>  
   </tr><tr>  
       <td align="right" class="windowbg">  
           <label for="sesanswer"><b>$sesquest_txt{$sesquestion}:</b></label>  
       </td>  
       <td align="left" class="windowbg">  
           <input type="$sestype" name="sesanswer" id="sesanswer" size="20" tabindex="1" />  
           <input type="hidden" name="sredir" value="$INFO{'sesredir'}" />  
       </td>  
   </tr><tr>  
       <td align="center" colspan="2" class="windowbg">  
           <br />  
           <input type="submit" value="$img_txt{'34a'}" tabindex="2" class="button" /></td>  
   </tr>  
</table>  
</div>  
</form>  
<script type="text/javascript" language="JavaScript">  
<!--  
   document.sesform.sesanswer.focus();  
//-->  
</script>  
~;  
   $yytitle = "$img_txt{'34a'}";  
   &template;  
} }
   
sub SessionReval2 { sub SessionReval2 {
   require "$sourcedir/Decoder.pl";  #    require Sources::Decoder; 
   $FORM{'cookielength'}   = 360;    $FORM{'cookielength'}   = 360;
   $FORM{'cookieneverexp'} = 1;    $FORM{'cookieneverexp'} = 1;
   if ( $FORM{'sesanswer'} eq q{} ) { fatal_error('no_secret_answer'); }    if ( $FORM{'sesanswer'} eq q{} ) { fatal_error('no_secret_answer'); }
   if (   ${ $uid . $username }{'sesquest'} eq q{}    if (   ${ $uid . $username }{'sesquest'} eq q{}
       || ${ $uid . $username }{'sesquest'} eq 'password' )        || ${ $uid . $username }{'sesquest'} eq 'password' )
   {    {
       $question = ${ $uid . $username }{'password'};        $question = ${ $uid . $username }{'password'};
       $answer   = encode_password("$FORM{'sesanswer'}");        $answer   = encode_password("$FORM{'sesanswer'}");
       chomp $answer;        chomp $answer;
   }    }
   else {    else {
       $question = descramble(${ $uid.$username }{'sesanswer'}, $username);         $question = encode_password( ${ $uid . $username }{'sesanswer'} ); 
       $answer = $FORM{'sesanswer'};         $answer =   encode_password( $FORM{'sesanswer'} ); 
#       bug fix courtesy Derek Barnstorm;  
#        $question = ${ $uid . $username }{'sesanswer'};         #       bug fix courtesy Derek Barnstorm; 
#        $answer = scramble( "$FORM{'sesanswer'}", $username );  
       chomp $answer;        chomp $answer;
   }    }
   if ($answer ne $question) {    if ( $answer ne $question ) {
       &UpdateCookie("delete");         UpdateCookie('delete'); 
   
       $username           = 'Guest';        $username = 'Guest';
       $iamguest           = '1';        $iamguest = '1';
       $iamadmin           = '';         $iamadmin = q{}; 
       $iamgmod            = '';         $iamgmod  = q{}; 
       $password           = '';         $password = q{}; 
       $yyim               = '';         $yyim     = q{}; 
       $ENV{'HTTP_COOKIE'} = '';         local $ENV{'HTTP_COOKIE'} = q{}; 
       $yyuname            = '';         $yyuname     = q{}; 
       $formsession        = &cloak("$mbname$username");         $formsession = cloak("$mbname$username"); 
   
       require "$sourcedir/LogInOut.pl";         require Sources::LogInOut; 
       $sharedLogin_text   = $session_txt{'6'};        $sharedLogin_text = $session_txt{'6'};
       $action             = "login";         $action           = 'login'; 
       &Login;         Login(); 
   } else {     } 
       $iamadmin     = ${$uid.$username}{'position'} eq 'Administrator' ? 1 : 0;     else { 
       $iamgmod      = ${$uid.$username}{'position'} eq 'Global Moderator' ? 1 : 0;         $iamadmin = 
           ${ $uid . $username }{'position'} eq 'Administrator' ? 1 : 0;
         $iamgmod =
           ${ $uid . $username }{'position'} eq 'Global Moderator' ? 1 : 0;
       $sessionvalid = 1;        $sessionvalid = 1;
   }    }
   if ($FORM{'cookielength'} < 1 || $FORM{'cookielength'} > 9999) { $FORM{'cookielength'} = $Cookie_Length; }     if ( $FORM{'cookielength'} < 1 || $FORM{'cookielength'} > 9999 ) { 
   if (!$FORM{'cookieneverexp'}) { $ck{'len'} = "\+$FORM{'cookielength'}m"; }         $FORM{'cookielength'} = $Cookie_Length; 
     }
     if ( !$FORM{'cookieneverexp'} ) { $ck{'len'} = "\+$FORM{'cookielength'}m"; }
   else { $ck{'len'} = 'Sunday, 17-Jan-2038 00:00:00 GMT'; }    else { $ck{'len'} = 'Sunday, 17-Jan-2038 00:00:00 GMT'; }
   ${$uid.$username}{'session'} = &encode_password($user_ip);     ${ $uid . $username }{'session'} = encode_password($user_ip); 
   chomp ${$uid.$username}{'session'};     chomp ${ $uid . $username }{'session'}; 
   &UserAccount($username, "update");     UserAccount( $username, 'update' ); 
   &UpdateCookie("write", $username, ${$uid.$username}{'password'}, ${$uid.$username}{'session'}, "/", $ck{'len'});     UpdateCookie( 
         'write', $username,
         ${ $uid . $username }{'password'},
         ${ $uid . $username }{'session'},
         q{/}, $ck{'len'}
     );
   
   $redir = "";     $redir = q{}; 
   if($FORM{'sredir'}) {    if ( $FORM{'sredir'} ) {
       my $tmpredir = $FORM{'sredir'};        my $tmpredir = $FORM{'sredir'};
       $tmpredir =~ s/\~/\=/g;         $tmpredir =~ s/\~/\=/gxsm; 
       $tmpredir =~ s/x3B/;/g;         $tmpredir =~ s/x3B/;/gxsm; 
       $tmpredir =~ s/search2/search/g;         $tmpredir =~ s/search2/search/gxsm; 
       $redir = qq~?$tmpredir~;        $redir = qq~?$tmpredir~;
   }    }
   $yySetLocation = qq~$scripturl$redir~;    $yySetLocation = qq~$scripturl$redir~;
   &redirectexit;     redirectexit(); 
     return;
} }
   
1; 1;