Changeset 84


Ignore:
Timestamp:
Dec 16, 2009, 12:46:51 PM (14 years ago)
Author:
george
Message:
  • Opraveno: Načítání XML konfigurace.
Location:
branches/DirectWeb
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DirectWeb/ConfigSample.xml

    r82 r84  
    77    <password>password</password>
    88  </database>
     9  <server>
     10    <address>0.0.0.0</address>
     11    <port>80</port>
     12  </server>
    913</configuration>
  • branches/DirectWeb/ReadMe.txt

    r83 r84  
    22======================
    33
     41) Instalace požadovaných balíčků:
     5
     6yum install mysql-devel
    47
    58
    6 
  • branches/DirectWeb/UTCPServer.pas

    r83 r84  
    7979      CreateSocket;
    8080      SetLinger(True, 10);
     81      WriteLn(Address + ':' + IntToStr(Port));
    8182      Bind(Address, IntToStr(Port));
    82       If LastError <> 0 then raise Exception.Create('Socket bind error');
     83      WriteLn(LastError);
     84      if LastError <> 0 then raise Exception.Create('Socket bind error');
    8385      Listen;
    84       If LastError <> 0 then raise Exception.Create('Socket listen error');
     86      if LastError <> 0 then raise Exception.Create('Socket listen error');
    8587      AcceptThread := TAcceptThread.Create(True);
    8688      AcceptThread.Parent := Self;
  • 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
  • branches/DirectWeb/WoWHostingWebServer.lpr

    r82 r84  
    33{$mode Delphi}{$H+}
    44
    5 uses {$IFDEF UNIX} {$IFDEF UseCThreads}
    6   cthreads, {$ENDIF} {$ENDIF}
     5uses
     6  {$IFDEF UNIX}
     7  {$DEFINE UseCthreads}
     8  {$IFDEF UseCThreads}
     9  cthreads,
     10  {$ENDIF}
     11{$ENDIF}
    712  Classes,
    813  SysUtils, UWebServer;
Note: See TracChangeset for help on using the changeset viewer.