Changeset 78


Ignore:
Timestamp:
Jun 18, 2012, 10:44:21 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Obsluha stránek rozdělena do samostatných sezení(TWebSession). Každé sezení si tak alokuje vlastní instanci TSqlDatabase. Zároveň při obsluze jednoduchých souborů se nyní již nenačítá info o přihlášeném uživateli a nevytváří se tak pro každé načítání souboru instance databázového připojení.
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/UMainModule.lfm

    r77 r78  
    22  OldCreateOrder = False
    33  Height = 278
    4   HorizontalOffset = 418
    5   VerticalOffset = 205
     4  HorizontalOffset = 554
     5  VerticalOffset = 266
    66  Width = 431
    7   object HTTPSessionStorageMySQL1: THTTPSessionStorageMySQL
    8     Database = Database
    9     Timeout = 10800
    10     SessionIdCookieName = 'SessionId'
    11     left = 304
    12     top = 32
    13   end
    14   object Database: TSqlDatabase
    15     Connected = False
    16     Port = 3306
    17     Encoding = 'utf8'
    18     left = 81
    19     top = 86
    20   end
    217  object WebApp1: TWebApp
    228    OnPageProduce = WebApp1PageProduce
    23     ServerType = stTCP
     9    ServerType = stCGI
    2410    left = 160
    2511    top = 88
  • trunk/Modules/UMainModule.lrs

    r77 r78  
    33LazarusResources.Add('TMainModule','FORMDATA',[
    44  'TPF0'#11'TMainModule'#10'MainModule'#14'OldCreateOrder'#8#6'Height'#3#22#1#16
    5   +'HorizontalOffset'#3#162#1#14'VerticalOffset'#3#205#0#5'Width'#3#175#1#0#24
    6   +'THTTPSessionStorageMySQL'#24'HTTPSessionStorageMySQL1'#8'Database'#7#8'Data'
    7   +'base'#7'Timeout'#3'0*'#19'SessionIdCookieName'#6#9'SessionId'#4'left'#3'0'#1
    8   +#3'top'#2' '#0#0#12'TSqlDatabase'#8'Database'#9'Connected'#8#4'Port'#3#234#12
    9   +#8'Encoding'#6#4'utf8'#4'left'#2'Q'#3'top'#2'V'#0#0#7'TWebApp'#7'WebApp1'#13
    10   +'OnPageProduce'#7#18'WebApp1PageProduce'#10'ServerType'#7#5'stTCP'#4'left'#3
    11   +#160#0#3'top'#2'X'#0#0#0
     5  +'HorizontalOffset'#3'*'#2#14'VerticalOffset'#3#10#1#5'Width'#3#175#1#0#7'TWe'
     6  +'bApp'#7'WebApp1'#13'OnPageProduce'#7#18'WebApp1PageProduce'#10'ServerType'#7
     7  +#5'stCGI'#4'left'#3#160#0#3'top'#2'X'#0#0#0
    128]);
  • trunk/Modules/UMainModule.pas

    r77 r78  
    1515
    1616type
    17   TSession = class
    18 
     17  TMainModule = class;
     18
     19  { TWebSession }
     20
     21  TWebSession = class(THTTPHandlerData)
     22  private
     23    procedure TopMenu;
     24    procedure Footer;
     25  public
     26    MainModule: TMainModule;
     27    Database: TSqlDatabase;
     28    SessionStorage: THTTPSessionStorageMySQL;
     29    User: TWebUser;
     30    UserOnline: TWebOnlineUser;
     31    HtmlDocument: THtmlDocument;
     32    GlobalTitle: string;
     33    TimeStart: TDateTime;
     34    procedure LoadUserInfo;
     35    procedure InitDatabase;
     36    procedure GeneratePage(Page: TWebPage);
     37    constructor Create; override;
     38    destructor Destroy; override;
    1939  end;
    2040
     
    2242
    2343  TMainModule = class(TDataModule)
    24     HTTPSessionStorageMySQL1: THTTPSessionStorageMySQL;
    25     Database: TSqlDatabase;
    2644    WebApp1: TWebApp;
    2745    procedure WebApp1PageProduce(HandlerData: THTTPHandlerData);
    2846  private
    29     procedure Footer;
    30     procedure InitDatabase;
    3147    procedure Show(Content: string);
    32     procedure TopMenu;
    3348  public
    34     TimeStart: TDateTime;
    3549    Load: string;
    3650    Unload: string;
    37     GlobalTitle: string;
    3851    ShowRuntimeInfo: Boolean;
    3952    Charset: string;
    4053    Admin: string;
    4154    AdminEmail: string;
     55    Keywords: string;
    4256    Style: string;
    43     Keywords: string;
    44     HtmlDocument: THtmlDocument;
    4557    BaseURL: string;
    46     User: TWebUser;
    47     UserOnline: TWebOnlineUser;
    4858    FormatHTML: Boolean;
    4959    NetworkAddress: string;
     
    5161    MaxConnections: Integer;
    5262    Pages: TPageList;
    53     procedure LoadUserInfo(HandlerData: THTTPHandlerData);
     63    DatabaseHostname: string;
     64    DatabaseUserName: string;
     65    DatabasePassword: string;
     66    DatabaseSchema: string;
    5467    procedure LoadFromRegistry;
    5568    procedure SaveToRegistry;
    56     procedure GeneratePage(HandlerData: THTTPHandlerData; Page: TWebPage);
    5769    procedure Run;
    5870    constructor Create(AOwner: TComponent); override;
     
    7183  UNetworkPage, UAboutPage, UContactPage;
    7284
    73 { TMainModule }
    74 
    75 procedure TMainModule.GeneratePage(HandlerData: THTTPHandlerData; Page: TWebPage);
     85{ TWebSession }
     86
     87constructor TWebSession.Create;
     88begin
     89  inherited;
     90  Database := TSqlDatabase.Create(nil);
     91  SessionStorage := THTTPSessionStorageMySQL.Create(nil);
     92  SessionStorage.Database := Database;
     93  HtmlDocument := THtmlDocument.Create;
     94  User := TWebUser.Create;
     95  User.Database := Database;
     96  UserOnline := TWebOnlineUser.Create;
     97  UserOnline.Database := Database;
     98end;
     99
     100destructor TWebSession.Destroy;
     101begin
     102  HtmlDocument.Free;
     103  User.Free;
     104  UserOnline.Free;
     105  SessionStorage.Free;
     106  Database.Free;
     107  inherited Destroy;
     108end;
     109
     110procedure TWebSession.InitDatabase;
     111var
     112  DbRows: TDbRows;
     113begin
     114  with Database do begin
     115    Connect;
     116  end;
     117  try
     118    DbRows := TDbRows.Create;
     119    Database.Query(DbRows, 'SET NAMES utf8');
     120  finally
     121    DbRows.Free;
     122  end;
     123end;
     124
     125procedure TWebSession.LoadUserInfo;
     126begin
     127  User.HandlerData := Self;
     128  UserOnline.HandlerData := Self;
     129  UserOnline.Update;
     130  User.Id := UserOnline.User;
     131  User.Load;
     132end;
     133
     134procedure TWebSession.GeneratePage(Page: TWebPage);
    76135var
    77136  I: Integer;
    78137  TitleTag: THtmlString;
    79138begin
    80   with HandlerData do begin
    81139    HtmlDocument.ContentLanguage := 'cs';
    82140    GlobalTitle := 'ZděchovNET';
    83     HtmlDocument.Styles.Add(NavigationLink('/Style/' + Style + '/Style.css'));
    84     HtmlDocument.Scripts.Add(NavigationLink('/Style/' + Style + '/Global.js'));
    85     HtmlDocument.Scripts.Add(NavigationLink('/Style/' + Style + '/jquery.js'));
     141    HtmlDocument.Styles.Add(NavigationLink('/Style/' + MainModule.Style + '/Style.css'));
     142    HtmlDocument.Scripts.Add(NavigationLink('/Style/' + MainModule.Style + '/Global.js'));
     143    HtmlDocument.Scripts.Add(NavigationLink('/Style/' + MainModule.Style + '/jquery.js'));
    86144
    87145      TitleTag := THtmlString.Create;
     
    95153      with HtmlDocument.AsXmlDocument do
    96154      try
    97         Formated := FormatHTML;
     155        Formated := MainModule.FormatHTML;
    98156        Response.Content.WriteString(AsString);
    99157      finally
    100158        Free;
    101159      end;
    102   end;
    103 end;
    104 
    105 procedure TMainModule.InitDatabase;
    106 var
    107   DbRows: TDbRows;
    108 begin
    109   with Database do begin
    110     Connect;
    111   end;
    112   try
    113     DbRows := TDbRows.Create;
    114     Database.Query(DbRows, 'SET NAMES utf8');
    115   finally
    116     DbRows.Free;
    117   end;
    118 end;
     160end;
     161
     162
     163{ TMainModule }
    119164
    120165constructor TMainModule.Create(AOwner: TComponent);
     
    122167  inherited;
    123168  Pages := TPageList.Create;
    124   HtmlDocument := THtmlDocument.Create;
    125   User := TWebUser.Create;
    126   User.Database := Database;
    127   UserOnline := TWebOnlineUser.Create;
    128   UserOnline.Database := Database;
    129169  LoadFromRegistry;
    130170  with Pages do begin
     
    156196begin
    157197  //SaveToRegistry;
    158   HtmlDocument.Free;
    159   User.Free;
    160   UserOnline.Free;
    161198  Pages.Free;
    162199  inherited Destroy;
    163200end;
    164201
    165 procedure TMainModule.Footer;
     202procedure TWebSession.Footer;
    166203var
    167204  Tag: TXMLTag;
     
    178215      Name := 'li';
    179216      with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin
    180         Text := Admin;
     217        Text := MainModule.Admin;
    181218      end;
    182219    end;
     
    184221      Name := 'li';
    185222      with TXmlString(SubElements.AddNew(TXmlString.Create)) do begin
    186         Text := AdminEmail;
    187       end;
    188     end;
    189     if ShowRuntimeInfo then begin
     223        Text := MainModule.AdminEmail;
     224      end;
     225    end;
     226    if MainModule.ShowRuntimeInfo then begin
    190227      with TXmlTag(SubElements.AddNew(TXmlTag.Create)) do begin
    191228        Name := 'li';
     
    232269end;
    233270
    234 procedure TMainModule.TopMenu;
     271procedure TWebSession.TopMenu;
    235272begin
    236273  with THtmlString(HtmlDocument.Body.SubItems.InsertNew(1, THtmlString.Create)) do begin
     
    269306end;
    270307
    271 procedure TMainModule.LoadUserInfo(HandlerData: THTTPHandlerData);
    272 begin
    273   User.HandlerData := HandlerData;
    274   UserOnline.HandlerData := HandlerData;
    275   UserOnline.Update;
    276   User.Id := UserOnline.User;
    277   User.Load;
    278 end;
    279 
    280308procedure TMainModule.WebApp1PageProduce(HandlerData: THTTPHandlerData);
    281309var
    282310  FileName: string;
     311  PageName: string;
     312  Page: TRegistredPage;
     313  NewSession: TWebSession;
     314  BaseUrlParts: TListString;
    283315begin
    284316  with HandlerData do begin
    285     if not Pages.ProducePage(HandlerData) then begin
     317    try
     318      BaseUrlParts := TListString.Create;
     319      BaseUrlParts.Explode(BaseURL, '/', StrToStr);
     320      while (BaseUrlParts.Count > 0) and (Request.Path.Count > 0) and
     321         (BaseUrlParts[0] = Request.Path[0]) do begin
     322           BaseUrlParts.Delete(0);
     323           Request.Path.Delete(0);
     324         end;
     325    finally
     326      BaseUrlParts.Free;
     327    end;
     328    if Request.Path.Count > 0 then PageName := Request.Path[0]
     329      else PageName := '';
     330    Page := Pages.FindByName(PageName);
     331    if Assigned(Page) then begin
     332      NewSession := TWebSession.Create;
     333      NewSession.MainModule := Self;
     334      NewSession.Assign(HandlerData);
     335      NewSession.TimeStart := Now;
     336      NewSession.Database.HostName := DatabaseHostName;
     337      NewSession.Database.Password := DatabasePassword;
     338      NewSession.Database.Database := DatabaseSchema;
     339      NewSession.Database.UserName := DatabaseUserName;
     340      NewSession.InitDatabase;
     341      Page.Page.OnProduce(NewSession);
     342      HandlerData.Assign(NewSession);
     343    end else begin
    286344      WebApp1.HTTPServer.FileResponse(HandlerData)
    287345    end;
     
    301359    Style := ReadString(SectionGeneral, 'Style', 'Basic');
    302360    BaseURL := ReadString(SectionGeneral, 'BaseURL', 'http://localhost');
    303     Database.Hostname := ReadString(SectionDatabase, 'DatabaseHostName', 'localhost');
    304     Database.Database := ReadString(SectionDatabase, 'DatabaseDatabase', 'web');
    305     Database.UserName := ReadString(SectionDatabase, 'DatabaseUserName', 'user');
    306     Database.Password := ReadString(SectionDatabase, 'DatabasePassword', 'password');
     361    DatabaseHostname := ReadString(SectionDatabase, 'DatabaseHostName', 'localhost');
     362    DatabaseSchema := ReadString(SectionDatabase, 'DatabaseDatabase', 'web');
     363    DatabaseUserName := ReadString(SectionDatabase, 'DatabaseUserName', 'user');
     364    DatabasePassword := ReadString(SectionDatabase, 'DatabasePassword', 'password');
    307365    FormatHTML := ReadBool(SectionGeneral, 'FormatHTML', False);
    308366    //MainModule.WebApp1.LogException := not ReadBool(SectionGeneral, 'ShowException', False);
     
    327385    WriteString(SectionGeneral, 'Style', Style);
    328386    WriteString(SectionGeneral, 'BaseURL', BaseURL);
    329     WriteString(SectionDatabase, 'DatabaseHostName', Database.Hostname);
    330     WriteString(SectionDatabase, 'DatabaseDatabase', Database.Database);
    331     WriteString(SectionDatabase, 'DatabaseUserName', Database.UserName);
    332     WriteString(SectionDatabase, 'DatabasePassword', Database.Password);
     387    WriteString(SectionDatabase, 'DatabaseHostName', DatabaseHostname);
     388    WriteString(SectionDatabase, 'DatabaseDatabase', DatabaseSchema);
     389    WriteString(SectionDatabase, 'DatabaseUserName', DatabaseUserName);
     390    WriteString(SectionDatabase, 'DatabasePassword', DatabasePassword);
    333391    WriteBool(SectionGeneral, 'FormatHTML', FormatHTML);
    334392    //WriteBool(SectionGeneral, 'ShowException', not MainModule.WebApp1.LogException);
     
    343401procedure TMainModule.Run;
    344402begin
    345   InitDatabase;
    346   //Database.Query('SELECT * FROM ssss');
    347 
     403  WebApp1.HTTPServer.DocumentRoot := ExtractFileDir(ParamStrUTF8(0));
    348404  WebApp1.Run;
    349405end;
  • trunk/Pages/UAboutPage.pas

    r77 r78  
    3636  TextBlock: THtmlString;
    3737begin
    38   with MainModule do begin
    39     LoadUserInfo(HandlerData);
     38  with TWebSession(HandlerData) do begin
     39    LoadUserInfo;
    4040    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4141    Text := '<img align="left" src="' + NavigationLink('/images/umisteni.gif') + '" alt="Umístění obce"/>' +
     
    8080      '<i>Aktualizováno: 21.1.2011</i>';
    8181    end;
     82    GeneratePage(Self);
    8283  end;
    83   MainModule.GeneratePage(HandlerData, Self);
    8484end;
    8585
  • trunk/Pages/UContactPage.pas

    r77 r78  
    3232procedure TContactPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3333begin
    34   with MainModule, HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    35     LoadUserInfo(HandlerData);
     34  with TWebSession(HandlerData), HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
     35    LoadUserInfo;
    3636    Text := '<strong>Kontaktní informace</strong><br/>' +
    37     'Provozovatel: Ing. Jiří Hajda<br/>' +
    38     'Adresa: Zděchov 208, 75607<br/>' +
    39     'Telefon: 737785792<br/>' +
     37    'Provozovatel: <strong>Ing. Jiří Hajda</strong><br/>' +
     38    'Adresa: <strong>Zděchov 208, 75607</strong><br/>' +
     39    'Telefon: <strong>737785792</strong><br/>' +
    4040    'E-mail: <a href="mailto: robie@centrum.cz">robie@centrum.cz</a><br/>' +
    41     'Jabber: chronos@jabbim.cz<br/>' +
     41    'Jabber: <strong>chronos@jabbim.cz</strong><br/>' +
    4242    'ICQ: <a href="http://www.icq.com/people/277158770">277158770</a><br/>' +
    43     'IČ: 75904535<br/>' +
    44     'DIČ: CZ8303255884<br/>' +
    45     'Bankovní spojení pro platby v CZK v ČR: 2600134781 / 2010' +
    46     'Bankovní spojení pro platby v EUR v SR: 2600134781 / 8330' +
    47     'Starý bankovní účet: 218098370 / 0300<br/>';
     43    'IČ: <strong>75904535</strong><br/>' +
     44    'DIČ: <strong>CZ8303255884</strong><br/>' +
     45    'Bankovní spojení pro platby v CZK v ČR: <strong>2600134781 / 2010</strong><br/>' +
     46    'Bankovní spojení pro platby v EUR v SR: <strong>2600134781 / 8330</strong><br/>' +
     47    'Starý bankovní účet: <strong>218098370 / 0300</strong><br/>';
     48    GeneratePage(Self);
    4849  end;
    49   MainModule.GeneratePage(HandlerData, Self);
    5050end;
    5151
  • trunk/Pages/UDocumentsPage.pas

    r77 r78  
    3434procedure TDocumentsPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3535begin
    36   with MainModule do begin
    37     LoadUserInfo(HandlerData);
     36  with TWebSession(HandlerData) do begin
     37    LoadUserInfo;
    3838    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    3939      Text := '<strong>O obci:</strong><br/>' +
     
    5252      IconedLink(NavigationLink('/docs/vyzva_do_infokanalu_15.8.2004.pdf'), 'Výzva do infokanálu (15.8.2004)') + '<br/>';
    5353    end;
     54    GeneratePage(Self);
    5455  end;
    55   MainModule.GeneratePage(HandlerData, Self);
    5656end;
    5757
  • trunk/Pages/UHistoryPage.pas

    r77 r78  
    3737  I: Integer;
    3838begin
    39   with MainModule do begin
    40     LoadUserInfo(HandlerData);
     39  with TWebSession(HandlerData) do begin
     40    LoadUserInfo;
    4141    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4242      Text := '<table>';
     
    5454      Text := Text + '</table>';
    5555    end;
     56    GeneratePage(Self);
    5657  end;
    57   MainModule.GeneratePage(HandlerData, Self);
    5858end;
    5959
  • trunk/Pages/UHostingPage.pas

    r77 r78  
    3838  DbRows: TDbRows;
    3939begin
    40   with MainModule do begin
    41     LoadUserInfo(HandlerData);
     40  with TWebSession(HandlerData) do begin
     41    LoadUserInfo;
    4242    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4343      Text := 'V nabídce je provoz virtualizovaných Linuxových serverů dle dohodnutých parameterů.<br/><br/>' +
     
    9393      end;
    9494    end;
     95    GeneratePage(Self);
    9596  end;
    96   MainModule.GeneratePage(HandlerData, Self);
    9797end;
    9898
  • trunk/Pages/UInternetPage.pas

    r77 r78  
    3434procedure TInternetPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3535begin
    36   with MainModule do begin
    37     LoadUserInfo(HandlerData);
     36  with TWebSession(HandlerData) do begin
     37    LoadUserInfo;
    3838    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    3939      Text := Text + 'Hlavní náplní činnosti sítě je poskytovat výhodné připojení k internetu pro občany.<br/><br/>' +
     
    5454      '<i>Aktualizováno: 1.8.2011</i>';
    5555    end;
     56    GeneratePage(Self);
    5657  end;
    57   MainModule.GeneratePage(HandlerData, Self);
    5858end;
    5959
  • trunk/Pages/ULinksPage.pas

    r77 r78  
    3434procedure TLinksPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3535begin
    36   with MainModule, HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    37     LoadUserInfo(HandlerData);
     36  with TWebSession(HandlerData), HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
     37    LoadUserInfo;
    3838    Text := '<strong>Odkazy související s obcí:</strong><br/>' +
    3939
     
    6363    '<a href="http://www.ustinet.cz/">Ústí.Net</a> - síť v Ústí u Vsetína<br/>' +
    6464    '<br/>';
     65    GeneratePage(Self);
    6566  end;
    66   MainModule.GeneratePage(HandlerData, Self);
    6767end;
    6868
  • trunk/Pages/UNetworkPage.pas

    r77 r78  
    3636  TextBlock: THtmlString;
    3737begin
    38   with MainModule do begin
    39     LoadUserInfo(HandlerData);
     38  with TWebSession(HandlerData) do begin
     39    LoadUserInfo;
    4040    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4141      Text := MakeLink('Historie', NavigationLink('/historie/')) + '<br/>' +
     
    4343        MakeLink('Plánované projekty', NavigationLink('/plany/')) + '<br/>';
    4444    end;
     45    GeneratePage(Self);
    4546  end;
    46   MainModule.GeneratePage(HandlerData, Self);
    4747end;
    4848
  • trunk/Pages/UPlansPage.pas

    r77 r78  
    3737  I: Integer;
    3838begin
    39   with MainModule do begin
    40     LoadUserInfo(HandlerData);
     39  with TWebSession(HandlerData) do begin
     40    LoadUserInfo;
    4141    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4242      Text := '<table>';
     
    6565      Text := Text + '</table>';
    6666    end;
     67    GeneratePage(Self);
    6768  end;
    68   MainModule.GeneratePage(HandlerData, Self);
    6969end;
    7070
  • trunk/Pages/UServerInfoPage.pas

    r77 r78  
    3434procedure TServerInfoPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3535begin
    36   with MainModule do begin
    37     LoadUserInfo(HandlerData);
    38     HandlerData.Session.Values['Test'] := 'Tst';
    39     WebApp1.HTTPServer.ServerInfo(HandlerData);
    40     GeneratePage(HandlerData, Self);
     36  with TWebSession(HandlerData) do begin
     37    LoadUserInfo;
     38    Session.Values['Test'] := 'Tst';
     39    MainModule.WebApp1.HTTPServer.ServerInfo(HandlerData);
     40    GeneratePage(Self);
    4141  end;
    4242end;
  • trunk/Pages/UUserControlPage.pas

    r77 r78  
    4343  NewItem: TQueryFormItem;
    4444begin
    45   if HandlerData.Request.QueryParts.Count > 1 then PageName := HandlerData.Request.QueryParts[1]
    46     else PageName := '';
    47   with MainModule, HtmlDocument.Body do begin
    48     LoadUserInfo(HandlerData);
    49     if PageName = '' then PageName := 'prihlaseni';
    50     if PageName = 'prihlaseni' then HandleLogin(HandlerData)
    51       else if PageName = 'registrace' then HandleRegistration(HandlerData)
    52       else if PageName = 'odhlaseni' then HandleLogout(HandlerData)
    53       else if PageName = 'profil' then HandleProfile(HandlerData);
    54   end;
    55   MainModule.GeneratePage(HandlerData, Self);
     45  with TWebSession(HandlerData) do begin
     46    if Request.Path.Count > 1 then PageName := Request.Path[1]
     47      else PageName := '';
     48    with HtmlDocument.Body do begin
     49      LoadUserInfo;
     50      if PageName = '' then PageName := 'prihlaseni';
     51      if PageName = 'prihlaseni' then HandleLogin(HandlerData)
     52        else if PageName = 'registrace' then HandleRegistration(HandlerData)
     53        else if PageName = 'odhlaseni' then HandleLogout(HandlerData)
     54        else if PageName = 'profil' then HandleProfile(HandlerData);
     55    end;
     56    GeneratePage(Self);
     57  end;
    5658end;
    5759
     
    6163  UserId: Integer;
    6264begin
    63   with MainModule, HtmlDocument.Body do begin
     65  with TWebSession(MainModule), HtmlDocument.Body do begin
    6466    Form := TQueryForm.Create;
    6567    with Form do begin
     
    9294      with THtmlString(SubItems.AddNew(THtmlString.Create)) do
    9395        Text := 'Přihlášení user: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;
    94       UserId := MainModule.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
     96      UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
    9597        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value);
    9698      UserOnline.Login(UserId);
     
    106108  UserId: Integer;
    107109begin
    108   with MainModule, HtmlDocument.Body do begin
     110  with TWebSession(MainModule), HtmlDocument.Body do begin
    109111    Form := TQueryForm.Create;
    110112    with Form do begin
     
    150152      with THtmlString(SubItems.AddNew(THtmlString.Create)) do
    151153        Text := 'Registrace uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;
    152       MainModule.User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
     154      User.Add(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
    153155        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value,
    154156        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value);
    155       UserId := MainModule.User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
     157      UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
    156158        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value);
    157       MainModule.UserOnline.Login(UserId);
     159      UserOnline.Login(UserId);
    158160      Form.Free;
    159161    end else SubItems.AddNew(Form);
     
    163165procedure TUserControlPage.HandleLogout(HandlerData: THTTPHandlerData);
    164166begin
    165   with MainModule, HtmlDocument.Body do begin
     167  with TWebSession(MainModule), HtmlDocument.Body do begin
    166168    UserOnline.Logout;
    167169    with THtmlString(SubItems.AddNew(THtmlString.Create)) do
     
    174176  Form: TQueryForm;
    175177begin
    176   with MainModule, HtmlDocument.Body do begin
     178  with TWebSession(HandlerData), HtmlDocument.Body do begin
    177179    Form := TQueryForm.Create;
    178180    with Form do begin
  • trunk/Pages/UVoIPPage.pas

    r77 r78  
    3434procedure TVoIPPage.DataModuleProduce(HandlerData: THTTPHandlerData);
    3535begin
    36   with MainModule do begin
    37     LoadUserInfo(HandlerData);
     36  with TWebSession(HandlerData) do begin
     37    LoadUserInfo;
    3838    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    3939      Text := 'Volejte levněji do pevných a mobilních sítí s sekundovou tarifikací a bez měsíčního paušálu.' +
     
    6565    '</ol>';
    6666    end;
     67    GeneratePage(Self);
    6768  end;
    68   MainModule.GeneratePage(HandlerData, Self);
    6969end;
    7070
  • trunk/Pages/UWebCamPage.pas

    r77 r78  
    4343  ImageWidth, ImageHeight: string;
    4444begin
    45   with MainModule do begin
    46     LoadUserInfo(HandlerData);
     45  with TWebSession(HandlerData) do begin
     46    LoadUserInfo;
    4747    with HtmlDocument.Body, THtmlString(SubItems.AddNew(THtmlString.Create)) do begin
    4848      Text := '';
     
    154154      Text := Text + '</td></tr></table>';
    155155    end;
     156    GeneratePage(Self);
    156157  end;
    157   MainModule.GeneratePage(HandlerData, Self);
    158158end;
    159159
Note: See TracChangeset for help on using the changeset viewer.