Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r871 r880  
    3434      'Icon' => '',
    3535    ), 0);
    36     if(array_key_exists('Search', $this->System->ModuleManager->Modules))
     36    if (array_key_exists('Search', $this->System->ModuleManager->Modules))
    3737      $this->System->ModuleManager->Modules['Search']->RegisterSearch('user',
    3838      T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search='));
     
    4949      'WHERE (`ActivityTime` >= NOW() - 300) '.
    5050      'ORDER BY `ActivityTime` DESC ) AS `T` GROUP BY `Name`');
    51     while($DbUser = $DbResult->fetch_assoc())
     51    while ($DbUser = $DbResult->fetch_assoc())
    5252    {
    5353      $Name = '<a href="'.$this->System->Link('/user/?user='.$DbUser['ID']).'">'.$DbUser['Name'].'</a>';
    5454      $Output .= $Name.'<br />';
    5555    }
    56     return($Output);
     56    return $Output;
    5757  }
    5858
     
    6060  {
    6161    $Output = '';
    62     if($this->System->User->Licence(LICENCE_USER))
     62    if ($this->System->User->Licence(LICENCE_USER))
    6363    {
    6464      //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
     
    7979        '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';
    8080    }
    81     return($Output);
     81    return $Output;
    8282  }
    8383}
     
    104104      </table>
    105105      </fieldset></form>';
    106       return($Output);
     106      return $Output;
    107107  }
    108108}
     
    132132    $this->Database = &$System->Database;
    133133    $this->OnlineStateTimeout = 600; // in seconds
    134     if(isset($_SESSION)) $this->Check();
     134    if (isset($_SESSION)) $this->Check();
    135135  }
    136136
     
    144144    $DbResult = $this->Database->query('SELECT `ID` FROM `User` WHERE '.
    145145      'LOWER(`Name`) = LOWER("'.$Name.'") AND `Pass` = '.$this->CryptPasswordSQL('"'.$Password.'"', '`Salt`'));
    146     if($DbResult->num_rows > 0)
     146    if ($DbResult->num_rows > 0)
    147147    {
    148148      $User = $DbResult->fetch_assoc();
     
    151151      // Prepare cookies for permanent login
    152152      $StayLoggedSalt = $this->GetPasswordSalt();
    153       if($StayLogged == true) $StayLoggedValue = 1; else $StayLoggedValue = 0;
     153      if ($StayLogged == true) $StayLoggedValue = 1; else $StayLoggedValue = 0;
    154154      $this->Database->update('UserOnline', '`SessionId`="'.$SID.'"', array(
    155155        'User' => $User['ID'], 'StayLogged' => $StayLoggedValue, 'StayLoggedHash' => $StayLoggedSalt));
    156       if($StayLogged)
     156      if ($StayLogged)
    157157      {
    158158        setcookie('LoginUserId', $User['ID'], time() + 365 * 24 * 60 * 60);
     
    176176  {
    177177    $SID = session_id();
    178     if($this->Role != LICENCE_ANONYMOUS)
     178    if ($this->Role != LICENCE_ANONYMOUS)
    179179    {
    180180      $this->Database->update('UserOnline', '`SessionId`="'.$SID.'"', array('User' => null));
     
    192192    'LEFT JOIN `ClientVersion` ON `ClientVersion`.`Id` = `User`.`PreferredVersion` '.
    193193    'WHERE `User`.`ID` = '.$this->Id);
    194     if($DbResult->num_rows > 0)
     194    if ($DbResult->num_rows > 0)
    195195    {
    196196      $User = $DbResult->fetch_assoc();
     
    222222  function Licence($Licence)
    223223  {
    224     if(GetRemoteAddress() == '') return(true); // Execution from command line
    225       else return($this->Role >= $Licence);
     224    if (GetRemoteAddress() == '') return true; // Execution from command line
     225      else return $this->Role >= $Licence;
    226226  }
    227227
     
    229229  {
    230230    $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"');
    231     if($DbResult->num_rows > 0)
     231    if ($DbResult->num_rows > 0)
    232232    {
    233233      $DbRow = $DbResult->fetch_assoc();
    234234      $DbResult2 = $this->Database->select('User', 'GM', '`ID`="'.$DbRow['User'].'"');
    235235      $DbRow2 = $DbResult2->fetch_assoc();
    236       return($DbRow2['GM'] >= $Licence);
    237     } else return(false);
     236      return $DbRow2['GM'] >= $Licence;
     237    } else return false;
    238238  }
    239239
    240240  function GetPasswordSalt()
    241241  {
    242     return(substr(sha1(mt_rand()), 0, 8));
     242    return substr(sha1(mt_rand()), 0, 8);
    243243  }
    244244
    245245  function CryptPasswordSQL($Password, $Salt)
    246246  {
    247     return('SHA1(CONCAT(SHA1('.$Password.'), '.$Salt.'))');
     247    return 'SHA1(CONCAT(SHA1('.$Password.'), '.$Salt.'))';
    248248  }
    249249
     
    253253    // Lookup user record
    254254    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    255     if($Query->num_rows > 0)
     255    if ($Query->num_rows > 0)
    256256    {
    257257      // Refresh time of last access
    258258      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    259259    } else {
    260       if(GetRemoteAddress() != '') $HostName = gethostbyaddr(GetRemoteAddress());
     260      if (GetRemoteAddress() != '') $HostName = gethostbyaddr(GetRemoteAddress());
    261261        else $HostName = '';
    262262      $this->Database->insert('UserOnline', array('SessionId' => $SID,
     
    267267
    268268    // Logged permanently?
    269     if(array_key_exists('LoginHash', $_COOKIE))
     269    if (array_key_exists('LoginHash', $_COOKIE))
    270270    {
    271271      $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId'].
    272272        ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"');
    273       if($DbResult->num_rows > 0)
     273      if ($DbResult->num_rows > 0)
    274274      {
    275275        $DbRow = $DbResult->fetch_assoc();
    276         if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
     276        if (sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash'])
    277277        {
    278278          $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"');
     
    285285    $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"');
    286286    $Row = $Query->fetch_assoc();
    287     if($Row['User'] != '')
     287    if ($Row['User'] != '')
    288288    {
    289289      $this->Id = $Row['User'];
     
    296296    // Remove nonactive users
    297297    $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)');
    298     while($DbRow = $DbResult->fetch_array())
     298    while ($DbRow = $DbResult->fetch_array())
    299299    {
    300300      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
     
    305305  {
    306306    $Salt = $this->GetPasswordSalt();
    307     if($Team == null) $Team = 'NULL';
    308     if($PreferredVersion == null) $PreferredVersion = 'NULL';
     307    if ($Team == null) $Team = 'NULL';
     308    if ($PreferredVersion == null) $PreferredVersion = 'NULL';
    309309    $this->Database->query('INSERT INTO `User` '.
    310310      '(`Name` , `Pass` , `Salt`, `Email` , `Language` , `Team` , `NeedUpdate`, `RegistrationTime`, `PreferredVersion` ) '.
Note: See TracChangeset for help on using the changeset viewer.