Legend:
- Unmodified
- Added
- Removed
-
user.php
r15 r18 41 41 $SID = session_id(); 42 42 // Lookup user record 43 $Query = $this->Database->select($this->TableUserOnline, '*', ' SessionId="'.$SID.'"');43 $Query = $this->Database->select($this->TableUserOnline, '*', '`SessionId`="'.$SID.'"'); 44 44 if($Query->num_rows > 0) 45 45 { 46 46 // Refresh time of last access 47 $this->Database->update($this->TableUserOnline, ' SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));47 $this->Database->update($this->TableUserOnline, '`SessionId`="'.$SID.'"', array('ActivityTime' => 'NOW()')); 48 48 } else $this->Database->insert($this->TableUserOnline, array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()))); 49 49 //echo($this->Database->LastQuery); … … 54 54 if($Row['User'] != 0) 55 55 { 56 $Query = $this->Database->select($this->TableUser, '*', "Id=".$Row['User'].""); 57 $this->User = $Query->fetch_array(); 56 $Query = $this->Database->query('SELECT * FROM `'.$this->TableUser.'` WHERE `ItemId`='.$Row['User'].' ORDER BY `Id` DESC LIMIT 1'); 57 $this->User = $Query->fetch_assoc(); 58 //print_r($this->User); 58 59 $Result = USER_LOGGED; 59 } else 60 { 61 $Query = $this->Database->select($this->TableUser, '*', " Id=0");62 $this->User = $Query->fetch_a rray();60 } else 61 { 62 $Query = $this->Database->select($this->TableUser, '*', "`ItemId`=0"); 63 $this->User = $Query->fetch_assoc(); 63 64 $Result = USER_NOT_LOGGED; 64 65 } 65 66 66 67 // Odeber neaktivní uživatele 67 $DbResult = $this->Database->select($this->TableUserOnline, 'User', ' ActivityTime< DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)');68 while($DbRow = $DbResult->fetch_a rray())69 { 70 $this->Database->delete($this->TableUserOnline, ' User='.$DbRow['User']);68 $DbResult = $this->Database->select($this->TableUserOnline, 'User', '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)'); 69 while($DbRow = $DbResult->fetch_assoc()) 70 { 71 $this->Database->delete($this->TableUserOnline, '`User`='.$DbRow['User']); 71 72 //$this->System->Modules['Log']->Add('User', 'Logout'); 72 73 } … … 94 95 else 95 96 { 96 $this->Database->insert($this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => sha1($Password), 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));97 $this->Database->insert($this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1)); 97 98 $UserId = $this->Database->insert_id; 98 99 99 100 $Subject = FromUTF8('Registrace nového účtu', 'iso2'); 100 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Nick."\n<br>Pro dokončení registrace klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='. sha1($Password).'">tento odkaz</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte.";101 $Message = 'Provedli jste registraci nového účtu na serveru <a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'">http://'.$Config['Web']['Host'].$Config['Web']['RootFolder']."</a>.<br>\nPokud jste tak neučinili, měli by jste tento email ignorovat.<br><br>\n\nVáš účet je: ".$Nick."\n<br>Pro dokončení registrace klikněte na ".'<a href="http://'.$Config['Web']['Host'].$Config['Web']['RootFolder'].'/?Action=UserRegisterConfirm&User='.$UserId.'&H='.$Password.'">tento odkaz</a>.'."\n<br> \n\n<br><br>Na tento email neodpovídejte."; 101 102 $AdditionalHeaders = "To: ".$Nick." <".$Email.">\n"."From: ".FromUTF8($Config['Web']['Title'], 'iso2')." <noreplay@zdechov.net>\n"."MIME-Version: 1.0\n"."Content-type: text/html; charset=utf-8"; 102 103 mail($Email, $Subject, $Message, $AdditionalHeaders); … … 133 134 { 134 135 $Row = $Query->fetch_array(); 135 if($Row['Password'] != sha1($Password)) $Result = BAD_PASSWORD;136 if($Row['Password'] != $Password) $Result = BAD_PASSWORD; 136 137 else if($Row['Locked'] == 1) $Result = ACCOUNT_LOCKED; 137 else 138 else 138 139 { 139 140 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()')); 140 $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['I d']));141 $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['ItemId'], 'ItemId' => $Row['ItemId'])); 141 142 // načtení stavu stromu 142 143 $Result = USER_LOGGED_IN; … … 188 189 if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password'])) 189 190 { 190 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Password' => sha1($NewPassword), 'Locked' => 0));191 $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Password' => $NewPassword, 'Locked' => 0)); 191 192 $Output = USER_PASSWORD_RECOVERY_CONFIRMED; 192 193 //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']);
Note:
See TracChangeset
for help on using the changeset viewer.