Ignore:
Timestamp:
Dec 16, 2009, 12:46:51 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Načítání XML konfigurace.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DirectWeb/UWebServer.pas

    r83 r84  
    1212  UMIMEType, Synautil,
    1313  USqlDatabase, DOM, XMLRead;
     14
     15const
     16  ConfigFileName = 'Config.xml';
    1417
    1518type
     
    4144
    4245procedure TWebServer.LoadConfiguration;
    43 const
    44   ConfigFileName = 'Config.xml';
    4546var
    4647  Config: TXMLDocument;
    47   I: Integer;
    48   II: Integer;
     48  I1: Integer;
     49  I2: Integer;
     50  I3: Integer;
    4951begin
    5052  if FileExists(ConfigFileName) then begin
    5153    ReadXMLFile(Config, ConfigFileName);
    52     for I := 0 to Config.ChildNodes.Count - 1 do begin
    53       if Config.ChildNodes[I].NodeName = 'database' then
    54       for II := 0 to Config.ChildNodes[I].ChildNodes.Count - 1 do begin;
    55         if Config.ChildNodes[I].ChildNodes[II].NodeName = 'hostname' then
    56           HostName := Config.ChildNodes[I].ChildNodes[II].TextContent;
    57         if Config.ChildNodes[I].ChildNodes[II].NodeName = 'schema' then
    58           Schema := Config.ChildNodes[I].ChildNodes[II].TextContent;
    59         if Config.ChildNodes[I].ChildNodes[II].NodeName = 'username' then
    60           UserName := Config.ChildNodes[I].ChildNodes[II].TextContent;
    61         if Config.ChildNodes[I].ChildNodes[II].NodeName = 'password' then
    62           Password := Config.ChildNodes[I].ChildNodes[II].TextContent;
     54    for I1 := 0 to Config.ChildNodes.Count - 1 do
     55    with Config.ChildNodes[I1] do begin
     56      if NodeName = 'configuration' then
     57      for I2 := 0 to ChildNodes.Count - 1 do
     58      with ChildNodes[I2] do begin
     59        if NodeName = 'database' then
     60        for I3 := 0 to ChildNodes.Count - 1 do
     61        with ChildNodes[I3] do begin
     62          if NodeName = 'hostname' then
     63            HostName := TextContent;
     64          if NodeName = 'schema' then
     65            Schema := TextContent;
     66          if NodeName = 'username' then
     67            UserName := TextContent;
     68          if NodeName = 'password' then
     69            Password := TextContent;
     70        end;
     71        if NodeName = 'server' then
     72        for I3 := 0 to ChildNodes.Count - 1 do
     73        with ChildNodes[I3] do begin
     74          if NodeName = 'address' then
     75            HTTPServer.Socket.Address := TextContent;
     76          if NodeName = 'port' then
     77            HTTPServer.Socket.Port := StrToInt(TextContent);
     78        end;
    6379      end;
    6480    end;
     
    272288  HTTPServer := THTTPServer.Create;
    273289  with HTTPServer, Socket do begin
    274     Address := '0.0.0.0';
    275     Port := 81;
    276290    DocumentRoot := './';
    277291    with RequestHandlerList do begin
Note: See TracChangeset for help on using the changeset viewer.