Changeset 725


Ignore:
Timestamp:
Jan 7, 2014, 8:45:46 PM (11 years ago)
Author:
chronos
Message:
  • Fixed: Permanent user logon was not kept after restart of web browser. This is now done with cookies.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/Translation.php

    r626 r725  
    5959  function ShowRSS()
    6060  {
    61     $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100');
     61    $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` '.
     62    'JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100');
    6263    while($DbRow = $DbResult->fetch_assoc())
    6364    {
  • trunk/Modules/User/User.php

    r714 r725  
    120120      $User = $DbResult->fetch_assoc();
    121121      $this->Id = $User['ID'];
    122       $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $User['ID'], 'StayLogged' => $StayLogged));     
     122     
     123      // Prepare cookies for permanent login     
     124      $StayLoggedSalt = $this->GetPasswordSalt();
     125      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array(
     126        'User' => $User['ID'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt));
     127      if($StayLogged)
     128      {
     129        setcookie('LoginUserId', $User['ID'], time()+365*24*60*60);
     130        setcookie('LoginHash', sha1($User['ID'].$StayLoggedSalt), time()+365*24*60*60);
     131      } else {
     132        setcookie('LoginUserId', '', time() - 3600);
     133        setcookie('LoginHash', '', time() - 3600);
     134      }     
     135     
    123136      $this->Database->query('UPDATE `UserTrace` SET '.
    124137        '`LastLogin` = NOW(), '.
     
    216229      'ScriptName' => $_SERVER['PHP_SELF']));
    217230     
    218     // Check login
     231    // Logged permanently?
     232          if(array_key_exists('LoginHash', $_COOKIE))
     233          {
     234            $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId'].
     235              ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"');
     236            if($DbResult->num_rows > 0)
     237            {
     238              $DbRow = $DbResult->fetch_assoc();
     239              if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
     240              {               
     241                $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"');
     242                $this->Database->query('UPDATE `UserOnline` SET `SessionId`="'.$SID.'" WHERE `Id`='.$DbRow['Id']);
     243              }
     244            }
     245    }
     246       
     247          // Check login
    219248    $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"');
    220249    $Row = $Query->fetch_assoc();
  • trunk/admin/UpdateTrace.php

    r716 r725  
    27162716}
    27172717
     2718function UpdateTo725($Manager)
     2719{
     2720        $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLoggedHash` VARCHAR( 40 ) NOT NULL ;');   
     2721}
     2722
    27182723
    27192724$Updates = array(
     
    27382743        695 => array('Revision' => 712 , 'Function' => 'UpdateTo712'),
    27392744        712 => array('Revision' => 716 , 'Function' => 'UpdateTo716'),
     2745        716 => array('Revision' => 725 , 'Function' => 'UpdateTo725'),
    27402746);
  • trunk/includes/Version.php

    r724 r725  
    66// and system will need database update.
    77
    8 $Revision = 724; // Subversion revision
    9 $DatabaseRevision = 716; // Database structure revision
     8$Revision = 725; // Subversion revision
     9$DatabaseRevision = 725; // Database structure revision
    1010$ReleaseTime = '2014-01-07';
Note: See TracChangeset for help on using the changeset viewer.