Changeset 103 for trunk/Packages
- Timestamp:
- Oct 8, 2012, 8:48:16 AM (12 years ago)
- Location:
- trunk/Packages/CoolWeb
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CoolWeb/CoolWeb.lpk
r96 r103 27 27 <License Value="GNU/GPL"/> 28 28 <Version Minor="3"/> 29 <Files Count="1 8">29 <Files Count="17"> 30 30 <Item1> 31 31 <Filename Value="WebServer/UHTTPServer.pas"/> … … 74 74 </Item10> 75 75 <Item11> 76 <Filename Value=" Modules/UUser.pas"/>77 <UnitName Value="U User"/>76 <Filename Value="Common/UHtmlClasses.pas"/> 77 <UnitName Value="UHtmlClasses"/> 78 78 </Item11> 79 79 <Item12> 80 <Filename Value="Common/U HtmlClasses.pas"/>81 <UnitName Value="U HtmlClasses"/>80 <Filename Value="Common/UMemoryStreamEx.pas"/> 81 <UnitName Value="UMemoryStreamEx"/> 82 82 </Item12> 83 83 <Item13> 84 <Filename Value="Common/UM emoryStreamEx.pas"/>85 <UnitName Value="UM emoryStreamEx"/>84 <Filename Value="Common/UMIMEType.pas"/> 85 <UnitName Value="UMIMEType"/> 86 86 </Item13> 87 87 <Item14> 88 <Filename Value="Common/U MIMEType.pas"/>89 <UnitName Value="U MIMEType"/>88 <Filename Value="Common/UXmlClasses.pas"/> 89 <UnitName Value="UXmlClasses"/> 90 90 </Item14> 91 91 <Item15> 92 <Filename Value="Common/UXmlClasses.pas"/>93 <UnitName Value="UXmlClasses"/>94 </Item15>95 <Item16>96 92 <Filename Value="WebServer/UWebPage.pas"/> 97 93 <HasRegisterProc Value="True"/> 98 94 <UnitName Value="UWebPage"/> 99 </Item1 6>100 <Item1 7>95 </Item15> 96 <Item16> 101 97 <Filename Value="WebServer/UWebApp.pas"/> 102 98 <HasRegisterProc Value="True"/> 103 99 <UnitName Value="UWebApp"/> 104 </Item1 7>105 <Item1 8>100 </Item16> 101 <Item17> 106 102 <Filename Value="LazIDEReg.pas"/> 107 103 <HasRegisterProc Value="True"/> 108 104 <UnitName Value="LazIDEReg"/> 109 </Item1 8>105 </Item17> 110 106 </Files> 111 107 <Type Value="RunAndDesignTime"/> -
trunk/Packages/CoolWeb/CoolWeb.pas
r84 r103 10 10 UHTTPServer, UHTTPServerCGI, UHTTPServerTCP, UHTTPServerTurboPower, 11 11 UTurboPowerForm, UHTTPSessionFile, UHTTPSessionMySQL, USqlDatabase, 12 UTCPServer, UPageList, U User, UHtmlClasses, UMemoryStreamEx, UMIMEType,12 UTCPServer, UPageList, UHtmlClasses, UMemoryStreamEx, UMIMEType, 13 13 UXmlClasses, UWebPage, UWebApp, LazIDEReg, LazarusPackageIntf; 14 14 -
trunk/Packages/CoolWeb/Modules/UUser.pas
r100 r103 31 31 function GetIdByNamePassword(Name: string; PassWord: string): Integer; 32 32 procedure Load; 33 function CheckPermission(Module, Operation: string; ItemType: string = ''; 34 ItemId: Integer = 0): Boolean; 35 function CheckGroupPermission(Group, Operation: Integer): Boolean; 33 36 end; 34 37 … … 215 218 end; 216 219 220 function TWebUser.CheckPermission(Module, Operation: string; 221 ItemType: string = ''; ItemId: Integer = 0): Boolean; 222 var 223 DbRows: TDbRows; 224 DbRows2: TDbRows; 225 OperationId: Integer; 226 begin 227 Result := False; 228 try 229 DbRows := TDbRows.Create; 230 Database.Query(DbRows, 'SELECT `Id` FROM `PermissionOperation` WHERE `Module`="' + Module + '"' + 231 ' AND `Operation` = "' + Operation + '" AND `Item` = "' + ItemType + '"' + 232 ' AND `ItemId` = ' + IntToStr(ItemId)); 233 if DbRows.Count > 0 then 234 try 235 DbRows2 := TDbRows.Create; 236 OperationId := StrToInt(DbRows[0].Values['Id']); 237 238 // Check user-operation relation 239 Database.Select(DbRows2, 'PermissionUserAssignment', 'Id', 240 '`User` = ' + IntToStr(Id) + ' AND `AssignedOperation` = ' + IntToStr(OperationId)); 241 if DbRows2.Count > 0 then begin 242 Result := True; 243 Exit; 244 end; 245 246 // Check user-group relation 247 Database.Select(DbRows2, 'PermissionUserAssignment', 'AssignedGroup', 248 '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL'); 249 if DbRows2.Count > 0 then begin 250 if CheckGroupPermission(StrToInt(DbRows2[0].Values['AssignedGroup']), OperationId) then begin 251 Result := True; 252 Exit; 253 end; 254 end; 255 finally 256 DbRows2.Free; 257 end; 258 finally 259 DBRows.Free; 260 end; 261 end; 262 263 function TWebUser.CheckGroupPermission(Group, Operation: Integer): Boolean; 264 var 265 DbRows2: TDbRows; 266 begin 267 Result := False; 268 try 269 DbRows2 := TDbRows.Create; 270 271 // Check group-operation relation 272 Database.Select(DbRows2, 'PermissionGroupAssignment', 'Id', 273 '`User` = ' + IntToStr(Id) + ' AND `AssignedOperation` = ' + IntToStr(Operation)); 274 if DbRows2.Count > 0 then begin 275 Result := True; 276 Exit; 277 end; 278 279 // Check group-group relation 280 Database.Select(DbRows2, 'PermissionGroupAssignment', 'AssignedGroup', 281 '`User` = ' + IntToStr(Id) + ' AND `AssignedGroup` IS NOT NULL'); 282 if DbRows2.Count > 0 then begin 283 if CheckGroupPermission(StrToInt(DbRows2[0].Values['AssignedGroup']), Operation) then begin 284 Result := True; 285 Exit; 286 end; 287 end; 288 finally 289 DbRows2.Free; 290 end; 291 end; 292 217 293 end. 218 294 -
trunk/Packages/CoolWeb/Persistence/USqlDatabase.pas
r99 r103 52 52 procedure SetConnected(const AValue: Boolean); 53 53 procedure SetDatabase(const Value: string); 54 procedure SetEncoding(AValue: string); 54 55 public 55 56 LastUsedTable: string; … … 84 85 property Password: string read FPassword write FPassword; 85 86 property Port: Word read FPort write FPort; 86 property Encoding: string read FEncoding write FEncoding;87 property Encoding: string read FEncoding write SetEncoding; 87 88 property OnLogQuery: TLogEvent read FOnLogQuery write FOnLogQuery; 88 89 end; … … 198 199 try 199 200 Rows := TDbRows.Create; 200 Query(Rows, 'SET NAMES ' + Encoding);201 Query(Rows, 'SET NAMES ' + FEncoding); 201 202 finally 202 203 Rows.Free; … … 452 453 end; 453 454 455 procedure TSqlDatabase.SetEncoding(AValue: string); 456 var 457 Rows: TDbRows; 458 begin 459 if FEncoding = AValue then Exit; 460 FEncoding := AValue; 461 if Connected then begin 462 try 463 Rows := TDbRows.Create; 464 Query(Rows, 'SET NAMES ' + FEncoding); 465 finally 466 Rows.Free; 467 end; 468 end; 469 end; 470 454 471 function TSqlDatabase.EscapeString(Text: string): string; 455 472 var
Note:
See TracChangeset
for help on using the changeset viewer.