Changeset 250
- Timestamp:
- Jun 13, 2011, 8:00:17 AM (13 years ago)
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UCommon.pas
r245 r250 36 36 function TryHexToInt(Data: string; var Value: Integer): Boolean; 37 37 function TryBinToInt(Data: string; var Value: Integer): Boolean; 38 function BinToHexString(Source: AnsiString): string; 38 39 //function DelTree(DirName : string): Boolean; 39 40 //function GetSpecialFolderPath(Folder: Integer): string; … … 57 58 implementation 58 59 60 function BinToHexString(Source: AnsiString): string; 61 var 62 I: Integer; 63 begin 64 for I := 1 to Length(Source) do begin 65 Result := Result + LowerCase(IntToHex(Ord(Source[I]), 2)); 66 end; 67 end; 68 69 59 70 procedure DeleteFiles(APath, AFileSpec: string); 60 71 var -
Common/UDebugLog.pas
r118 r250 21 21 { TDebugLog } 22 22 23 TDebugLog = class 23 TDebugLog = class(TComponent) 24 24 private 25 FFileName: string; 25 26 FOnNewItem: TNewItemEvent; 26 27 public 27 FileName: string;28 28 WriteToFileEnable: Boolean; 29 29 Items: TThreadList; … … 32 32 procedure WriteToFile(Text: string); 33 33 property OnNewItem: TNewItemEvent read FOnNewItem write FOnNewItem; 34 constructor Create ;34 constructor Create(AOwner: TComponent); override; 35 35 destructor Destroy; override; 36 published 37 property FileName: string read FFileName write FFileName; 36 38 end; 37 39 … … 85 87 end; 86 88 87 constructor TDebugLog.Create ;89 constructor TDebugLog.Create(AOwner: TComponent); 88 90 begin 91 inherited; 89 92 Items := TThreadList.Create; 90 93 MaxCount := 100; … … 105 108 end; 106 109 107 initialization108 109 DebugLog := TDebugLog.Create;110 111 finalization112 113 DebugLog.Free;114 115 110 end. 116 111 -
CoolStreaming/CoolStreaming.lpk
r233 r250 49 49 </Files> 50 50 <Type Value="RunAndDesignTime"/> 51 <RequiredPkgs Count=" 2">51 <RequiredPkgs Count="3"> 52 52 <Item1> 53 <PackageName Value=" TemplateGenerics"/>53 <PackageName Value="LCL"/> 54 54 </Item1> 55 55 <Item2> 56 <PackageName Value="TemplateGenerics"/> 57 </Item2> 58 <Item3> 56 59 <PackageName Value="FCL"/> 57 60 <MinVersion Major="1" Valid="True"/> 58 </Item 2>61 </Item3> 59 62 </RequiredPkgs> 60 63 <UsageOptions> -
Generics/TemplateGenerics/TemplateGenerics.lpk
r222 r250 83 83 <Item14> 84 84 <Filename Value="Generic\GenericStream.inc"/> 85 <UnitName Value="GenericStream"/> 85 86 </Item14> 86 87 <Item15> … … 132 133 </RequiredPkgs> 133 134 <UsageOptions> 134 <IncludePath Value="Generic"/>135 135 <UnitPath Value="$(PkgOutDir)"/> 136 136 </UsageOptions> -
Network/CoolWeb/CoolWeb.lpk
r238 r250 20 20 <License Value="GNU/GPL"/> 21 21 <Version Minor="2"/> 22 <Files Count="1 7">22 <Files Count="16"> 23 23 <Item1> 24 24 <Filename Value="WebServer/UHTTPServer.pas"/> … … 63 63 </Item9> 64 64 <Item10> 65 <Filename Value="Common/U Common.pas"/>66 <UnitName Value="U Common"/>65 <Filename Value="Common/UHtmlClasses.pas"/> 66 <UnitName Value="UHtmlClasses"/> 67 67 </Item10> 68 68 <Item11> 69 <Filename Value="Common/U HtmlClasses.pas"/>70 <UnitName Value="U HtmlClasses"/>69 <Filename Value="Common/UMemoryStreamEx.pas"/> 70 <UnitName Value="UMemoryStreamEx"/> 71 71 </Item11> 72 72 <Item12> 73 <Filename Value="Common/UM emoryStreamEx.pas"/>74 <UnitName Value="UM emoryStreamEx"/>73 <Filename Value="Common/UMIMEType.pas"/> 74 <UnitName Value="UMIMEType"/> 75 75 </Item12> 76 76 <Item13> 77 <Filename Value="Common/U MIMEType.pas"/>78 <UnitName Value="U MIMEType"/>77 <Filename Value="Common/UPool.pas"/> 78 <UnitName Value="UPool"/> 79 79 </Item13> 80 80 <Item14> 81 <Filename Value="Common/U Pool.pas"/>82 <UnitName Value="U Pool"/>81 <Filename Value="Common/UResetableThread.pas"/> 82 <UnitName Value="UResetableThread"/> 83 83 </Item14> 84 84 <Item15> 85 <Filename Value="Common/U ResetableThread.pas"/>86 <UnitName Value="U ResetableThread"/>85 <Filename Value="Common/UXmlClasses.pas"/> 86 <UnitName Value="UXmlClasses"/> 87 87 </Item15> 88 88 <Item16> 89 <Filename Value="Common/UXmlClasses.pas"/>90 <UnitName Value="UXmlClasses"/>91 </Item16>92 <Item17>93 89 <Filename Value="WebServer/UWebPage.pas"/> 94 90 <UnitName Value="UWebPage"/> 95 </Item1 7>91 </Item16> 96 92 </Files> 97 93 <Type Value="RunAndDesignTime"/> 98 <RequiredPkgs Count=" 3">94 <RequiredPkgs Count="4"> 99 95 <Item1> 96 <PackageName Value="Common"/> 97 </Item1> 98 <Item2> 100 99 <PackageName Value="TemplateGenerics"/> 101 100 <MaxVersion Minor="3" Valid="True"/> 102 101 <MinVersion Minor="3" Valid="True"/> 103 </Item1>104 <Item2>105 <PackageName Value="synapse"/>106 102 </Item2> 107 103 <Item3> 104 <PackageName Value="synapse"/> 105 </Item3> 106 <Item4> 108 107 <PackageName Value="FCL"/> 109 108 <MinVersion Major="1" Valid="True"/> 110 </Item 3>109 </Item4> 111 110 </RequiredPkgs> 112 111 <UsageOptions> -
Network/CoolWeb/CoolWeb.pas
r238 r250 9 9 uses 10 10 UHTTPServer, UHTTPServerCGI, UHTTPServerTCP, UHTTPSessionFile, 11 UHTTPSessionMySQL, USqlDatabase, UTCPServer, UPageList, UUser, U Common,12 U HtmlClasses, UMemoryStreamEx, UMIMEType, UPool, UResetableThread,13 UXmlClasses, UWebPage,LazarusPackageIntf;11 UHTTPSessionMySQL, USqlDatabase, UTCPServer, UPageList, UUser, UHtmlClasses, 12 UMemoryStreamEx, UMIMEType, UPool, UResetableThread, UXmlClasses, UWebPage, 13 LazarusPackageIntf; 14 14 15 15 implementation -
Network/CoolWeb/Persistence/USqlDatabase.pas
r238 r250 20 20 21 21 TSetClientCapabilities = set of TClientCapabilities; 22 23 TLogEvent = procedure(Sender: TObject; Text: string) of object; 22 24 23 25 TDbRows = class(TListObject) … … 41 43 FDatabase: string; 42 44 FUserName: string; 45 FOnLogQuery: TLogEvent; 43 46 procedure mySQLClient1ConnectError(Sender: TObject; Msg: String); 44 47 function GetConnected: Boolean; … … 56 59 procedure Query(DbRows: TDbRows; Data: string); 57 60 procedure Select(DbRows: TDbRows; ATable: string; Filter: string = '*'; Condition: string = '1'); 58 procedure Delete(ATable: string; Condition: string = '1'); 59 procedure Insert(ATable: string; Data: TDictionaryStringString); 60 procedure Update(ATable: string; Data: TDictionaryStringString; Condition: string = '1'); 61 procedure Replace(ATable: string; Data: TDictionaryStringString); 61 procedure Delete(ATable: string; Condition: string = '1'; 62 Schema: string = ''); 63 procedure Insert(ATable: string; Data: TDictionaryStringString; 64 Schema: string = ''); 65 procedure Update(ATable: string; Data: TDictionaryStringString; 66 Condition: string = '1'; Schema: string = ''); 67 procedure Replace(ATable: string; Data: TDictionaryStringString; 68 Schema: string = ''); 62 69 procedure Connect; 63 70 procedure Disconnect; … … 75 82 property Password: string read FPassword write FPassword; 76 83 property Encoding: string read FEncoding write FEncoding; 84 property OnLogQuery: TLogEvent read FOnLogQuery write FOnLogQuery; 77 85 end; 78 86 … … 193 201 end; 194 202 195 procedure TSqlDatabase.Insert(ATable: string; Data: TDictionaryStringString); 203 procedure TSqlDatabase.Insert(ATable: string; Data: TDictionaryStringString; 204 Schema: string); 196 205 var 197 206 DbNames: string; … … 215 224 try 216 225 DbResult := TDbRows.Create; 217 Query(DbResult, 'INSERT INTO `' + ATable + '` (' + DbNames + ') VALUES (' + DbValues + ')'); 226 if Schema <> '' then Schema := '`' + Schema + '`.'; 227 Query(DbResult, 'INSERT INTO ' + Schema + '`' + ATable + '` (' + DbNames + ') VALUES (' + DbValues + ')'); 218 228 finally 219 229 DbResult.Free; … … 228 238 begin 229 239 DbRows.Clear; 230 //DebugLog('SqlDatabase query: '+Data);240 if Assigned(FOnLogQuery) then FOnLogQuery(Self, Data); 231 241 LastQuery := Data; 232 242 mysql_query(FSession, PChar(Data)); … … 252 262 end; 253 263 254 procedure TSqlDatabase.Replace(ATable: string; Data: TDictionaryStringString); 264 procedure TSqlDatabase.Replace(ATable: string; Data: TDictionaryStringString; 265 Schema: string = ''); 255 266 var 256 267 DbNames: string; … … 274 285 try 275 286 DbResult := TDbRows.Create; 276 Query(DbResult, 'REPLACE INTO `' + ATable + '` (' + DbNames + ') VALUES (' + DbValues + ')'); 287 if Schema <> '' then Schema := '`' + Schema + '`.'; 288 Query(DbResult, 'REPLACE INTO ' + Schema + '`' + ATable + '` (' + DbNames + ') VALUES (' + DbValues + ')'); 277 289 finally 278 290 DbResult.Free; … … 286 298 end; 287 299 288 procedure TSqlDatabase.Update(ATable: string; Data: TDictionaryStringString; Condition: string = '1'); 300 procedure TSqlDatabase.Update(ATable: string; Data: TDictionaryStringString; 301 Condition: string = '1'; Schema: string = ''); 289 302 var 290 303 DbValues: string; … … 304 317 try 305 318 DbResult := TDbRows.Create; 306 Query(DbResult, 'UPDATE `' + ATable + '` SET (' + DbValues + ') WHERE ' + Condition); 319 if Schema <> '' then Schema := '`' + Schema + '`.'; 320 Query(DbResult, 'UPDATE ' + Schema + '`' + ATable + '` SET (' + DbValues + ') WHERE ' + Condition); 307 321 finally 308 322 DbResult.Free; … … 315 329 end; 316 330 317 procedure TSqlDatabase.Delete(ATable: string; Condition: string = '1'); 331 procedure TSqlDatabase.Delete(ATable: string; Condition: string = '1'; 332 Schema: string = ''); 318 333 var 319 334 DbResult: TDbRows; … … 322 337 try 323 338 DbResult := TDbRows.Create; 324 Query(DbResult, 'DELETE FROM `' + ATable + '` WHERE ' + Condition); 339 if Schema <> '' then Schema := '`' + Schema + '`.'; 340 Query(DbResult, 'DELETE FROM ' + Schema + '`' + ATable + '` WHERE ' + Condition); 325 341 finally 326 342 DbResult.Free; -
Network/CoolWeb/WebServer/UHTTPServer.pas
r237 r250 78 78 79 79 THTTPSessionStorage = class(TComponent) 80 public 80 81 procedure Load(HandlerData: THTTPHandlerData); virtual; 81 82 procedure Save(HandlerData: THTTPHandlerData); virtual; -
Network/CoolWeb/WebServer/UHTTPSessionFile.pas
r237 r250 6 6 7 7 uses 8 Classes, SysUtils, UHTTPServer, syncobjs, synacode, UCommon ;8 Classes, SysUtils, UHTTPServer, syncobjs, synacode, UCommon, FileUtil; 9 9 10 10 type … … 37 37 implementation 38 38 39 resourcestring 40 SCantCreateSessionStorageDirectory = 'Can''t create session storage directory.'; 41 39 42 procedure Register; 40 43 begin … … 48 51 begin 49 52 Result := BinToHexString(SHA1(FloatToStr(Now))); 50 while FileExists (Directory + '/'+ Result) do53 while FileExistsUTF8(Directory + DirectorySeparator + Result) do 51 54 Result := BinToHexString(SHA1(FloatToStr(Now))); 52 55 end; … … 71 74 try 72 75 Lock.Acquire; 73 SessionFile := Directory + '/'+ HandlerData.SessionId;74 if FileExists (SessionFile) then76 SessionFile := Directory + DirectorySeparator + HandlerData.SessionId; 77 if FileExistsUTF8(SessionFile) then 75 78 HandlerData.Session.LoadFromFile(SessionFile) 76 79 else HandlerData.SessionId := GetNewSessionId; … … 87 90 try 88 91 Lock.Acquire; 89 SessionFile := Directory + '/'+ HandlerData.SessionId;92 SessionFile := Directory + DirectorySeparator + HandlerData.SessionId; 90 93 ForceDirectories(Directory); 91 if DirectoryExists (Directory) then begin94 if DirectoryExistsUTF8(Directory) then begin 92 95 DeleteFile(SessionFile); 93 96 HandlerData.Session.SaveToFile(SessionFile) 94 end else raise Exception.Create( 'Can''t create session storage directory.');97 end else raise Exception.Create(SCantCreateSessionStorageDirectory); 95 98 96 99 HandlerData.Response.Cookies.Values[SessionIdCookieName] := HandlerData.SessionId;
Note:
See TracChangeset
for help on using the changeset viewer.