Changeset 138 for trunk/Packages/CoolWeb/Modules
- Timestamp:
- Sep 9, 2022, 8:20:25 PM (2 years ago)
- Location:
- trunk/Packages/CoolWeb/Modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CoolWeb/Modules/UPageList.pas
r137 r138 7 7 8 8 type 9 10 { TPageList } 11 9 12 TPageList = class 10 13 TotalCount: Integer; … … 19 22 Around: Integer; 20 23 constructor Create; 24 destructor Destroy; override; 21 25 function Hyperlink: string; 22 26 function Process: string; … … 33 37 QueryItems.SetStringServer; 34 38 HTMLId := ''; 39 end; 40 41 destructor TPageList.Destroy; 42 begin 43 FreeAndNil(QueryItems); 44 inherited; 35 45 end; 36 46 -
trunk/Packages/CoolWeb/Modules/UWebUser.pas
r137 r138 5 5 uses 6 6 Classes, SysUtils, synacode, USqlDatabase, UCommon, UHTTPServer, 7 SpecializedDictionary;7 UGenerics; 8 8 9 9 const … … 60 60 DbRows: TDbRows; 61 61 Id: Integer; 62 begin 63 try 64 DbRows := TDbRows.Create; 65 if HandlerData.Request.Cookies.SearchKey('SessionId') <> -1 then begin 62 Value: string; 63 begin 64 try 65 DbRows := TDbRows.Create; 66 if HandlerData.Request.Cookies.TryGetValue('SessionId', Value) then begin 66 67 Database.Query(DbRows, 'SELECT * FROM `UserOnline` WHERE `SessionId`="' + 67 HandlerData.Request.Cookies.Values['SessionId']+ '"');68 Value + '"'); 68 69 if DbRows.Count > 0 then begin 69 70 // Update exited 70 Id := StrToInt(DbRows[0]. Values['Id']);71 User := StrToInt(DbRows[0]. Values['User']);71 Id := StrToInt(DbRows[0].Items['Id']); 72 User := StrToInt(DbRows[0].Items['User']); 72 73 Database.Query(DbRows, 'UPDATE `UserOnline` SET `ActivityTime` = NOW() WHERE `Id`=' + IntToStr(Id)); 73 74 end else begin 74 75 // Create new record 75 76 Database.Query(DbRows, 'INSERT INTO `UserOnline` (`User`, `ActivityTime`, `SessionId`, `ScriptName`) ' + 76 'VALUES (1, NOW(), "' + HandlerData.Request.Cookies.Values['SessionId']+ '", "")');77 'VALUES (1, NOW(), "' + Value + '", "")'); 77 78 Id := Database.LastInsertId; 78 79 User := 1; … … 88 89 var 89 90 DbRows: TDbRows; 91 SessionId: string; 90 92 begin 91 93 Logout; 94 if HandlerData.Request.Cookies.TryGetValue('SessionId', SessionId) then 92 95 try 93 96 DbRows := TDbRows.Create; 94 97 Database.Query(DbRows, 'UPDATE `UserOnline` SET `User` = ' + IntToStr(User) + ', `LoginTime` = NOW() WHERE `SessionId`="' + 95 HandlerData.Request.Cookies.Values['SessionId']+ '"');98 SessionId + '"'); 96 99 finally 97 100 DbRows.Free; … … 103 106 var 104 107 DbRows: TDbRows; 108 SessionId: string; 105 109 begin 106 110 if Id = AnonymousUserId then Update; 107 if User <> AnonymousUserId then begin 111 if (User <> AnonymousUserId) and 112 HandlerData.Request.Cookies.TryGetValue('SessionId', SessionId) then begin 108 113 try 109 114 DbRows := TDbRows.Create; 110 115 Database.Query(DbRows, 'UPDATE `UserOnline` SET `User` = ' + IntToStr(AnonymousUserId) + ' WHERE `SessionId`="' + 111 HandlerData.Request.Cookies.Values['SessionId']+ '"');116 SessionId + '"'); 112 117 finally 113 118 DbRows.Free; … … 178 183 DbRows := TDbRows.Create; 179 184 Database.Query(DbRows, 'SELECT `Id` FROM `User` WHERE `Name`="' + Name + '"'); 180 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[ 0].Value)185 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items['Id']) 181 186 else Result := -1; 182 187 finally … … 193 198 Database.Query(DbRows, 'SELECT `Id` FROM `User` WHERE `Name`="' + Name + '" AND ' + 194 199 '`Password` = SHA1(CONCAT("' + Password + '", Salt))'); 195 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[ 0].Value)200 if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items['Id']) 196 201 else Result := -1; 197 202 finally … … 208 213 Database.Query(DbRows, 'SELECT * FROM `User` WHERE `Id`="' + IntToStr(Id) + '"'); 209 214 if DbRows.Count = 1 then begin 210 Name := DbRows[0]. Values['Name'];211 FullName := DbRows[0]. Values['FullName'];212 Email := DbRows[0]. Values['Email'];215 Name := DbRows[0].Items['Name']; 216 FullName := DbRows[0].Items['FullName']; 217 Email := DbRows[0].Items['Email']; 213 218 end; // else raise ENotFound.Create(Format(SUserNotFound, [IntToStr(Id)])); 214 219 finally … … 233 238 try 234 239 DbRows2 := TDbRows.Create; 235 OperationId := StrToInt(DbRows[0]. Values['Id']);240 OperationId := StrToInt(DbRows[0].Items['Id']); 236 241 237 242 // Check user-operation relation … … 247 252 '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL'); 248 253 if DbRows2.Count > 0 then begin 249 if CheckGroupPermission(StrToInt(DbRows2[0]. Values['AssignedGroup']), OperationId) then begin254 if CheckGroupPermission(StrToInt(DbRows2[0].Items['AssignedGroup']), OperationId) then begin 250 255 Result := True; 251 256 Exit; … … 280 285 '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL'); 281 286 if DbRows2.Count > 0 then begin 282 if CheckGroupPermission(StrToInt(DbRows2[0]. Values['AssignedGroup']), Operation) then begin287 if CheckGroupPermission(StrToInt(DbRows2[0].Items['AssignedGroup']), Operation) then begin 283 288 Result := True; 284 289 Exit;
Note:
See TracChangeset
for help on using the changeset viewer.