Changeset 98


Ignore:
Timestamp:
Oct 2, 2012, 12:24:00 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Přihlašování, odhlašování, registrace a nastavení profilu uživatele.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/UUserControlPage.pas

    r91 r98  
    9393      Form.Load(HandlerData.Request.Post);
    9494      with THtmlString(SubItems.AddNew(THtmlString.Create)) do
    95         Text := 'Přihlášení user: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;
     95        Text := 'Přihlášení uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;
    9696      UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
    9797        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value);
    98       UserOnline.Login(UserId);
     98      if UserId = -1 then begin
     99        with THtmlString(SubItems.AddNew(THtmlString.Create)) do
     100          Text := '<br/>Chybné jméno nebo heslo';
     101      end else UserOnline.Login(UserId);
    99102      Form.Free;
    100103    end else
     
    157160      UserId := User.GetIdByNamePassword(TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value,
    158161        TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Password').Value.Value);
    159       UserOnline.Login(UserId);
     162      if UserId <> -1 then UserOnline.Login(UserId);
    160163      Form.Free;
    161164    end else SubItems.AddNew(Form);
     
    188191          Hint := 'Zadejte vaše přihlašovací jméno';
    189192          Required := True;
     193          Value.Value := User.Name;
    190194        end;
    191195        with AddNewItem do begin
     
    202206          Required := True;
    203207          ItemType := fitText;
     208          Value.Value := User.Email;
    204209        end;
    205210        with AddNewItem do begin
     
    209214          Required := False;
    210215          ItemType := fitText;
     216          Value.Value := User.FullName;
    211217        end;
    212218      end;
     
    221227      with THtmlString(SubItems.AddNew(THtmlString.Create)) do
    222228        Text := 'Profil uživatele: ' + TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value + ' uložen';
     229      User.Name := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('UserName').Value.Value;
     230      User.FullName := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('FullName').Value.Value;
     231      User.Email := TQueryFormGroup(Form.Groups[0]).Rows.FindByName('Email').Value.Value;
     232      User.Save;
    223233      Form.Free;
    224234    end else SubItems.AddNew(Form);
  • trunk/Modules/ZdechovNET/UHostingPage.pas

    r97 r98  
    6161      'Použité technologie: <a href="http://www.linux.cz/">GNU/Linux</a>, <a href="http://openvz.org/">OpenVZ</a>, <a href="http://pve.proxmox.com/">Proxmox VE</a>, <a href="http://backuppc.sourceforge.net/">BackupPC</a><br/>' +
    6262      '<br/>' +
    63       '<i>Aktualizováno: 3.4.2010</i><br/><br/>';
     63      '<i>Aktualizováno: 1.10.2012</i><br/><br/>';
    6464
    6565      Text := Text + '<p>Hosting je využíván především pro provoz herních serverů MMORPG her jako např. World of Warcraft (WoW), Lineage II, Aion, aj.</p>';
  • trunk/Modules/ZdechovNET/UModuleZdechovNET.pas

    r97 r98  
    146146    ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
    147147
     148    Core.CommonDatabase.Query(DbRows,
     149    'CREATE TABLE IF NOT EXISTS `HostedProject` (' +
     150    '  `Id` int(11) NOT NULL AUTO_INCREMENT,' +
     151    '  `Name` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
     152    '  `Homepage` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
     153    '  `User` int(255) NOT NULL COMMENT "User.Id",' +
     154    '  `TimeCreate` datetime NOT NULL,' +
     155    '  `Server` int(11) DEFAULT NULL COMMENT "NetworkDevice.Id",' +
     156    '  `Active` int(11) NOT NULL DEFAULT "1",' +
     157    '  `WebHosting` int(11) NOT NULL,' +
     158    '  PRIMARY KEY (`Id`)' +
     159    ') ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;');
     160
    148161  finally
    149162    Data.Free;
     
    161174  try
    162175    DbRows := TDbRows.Create;
     176    Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `HostedProject`');
    163177    Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `Plans`');
    164178    Core.CommonDatabase.Query(DbRows, 'DROP TABLE IF EXISTS `Webcam`');
  • trunk/Packages/CoolWeb/Modules/UUser.pas

    r97 r98  
    66
    77uses
    8   Classes, SysUtils, synacode, USqlDatabase, UCommon, UHTTPServer;
     8  Classes, SysUtils, synacode, USqlDatabase, UCommon, UHTTPServer,
     9  SpecializedDictionary;
    910
    1011const
     
    2425    Database: TSqlDatabase;
    2526    HandlerData: THTTPHandlerData;
     27    procedure Save;
    2628    procedure Delete(Id: Integer);
    2729    procedure Add(Name, Password, Email: string);
     
    112114{ TUser }
    113115
     116procedure TWebUser.Save;
     117var
     118  DbRows: TDbRows;
     119  Data: TDictionaryStringString;
     120begin
     121  try
     122    DbRows := TDbRows.Create;
     123    Data := TDictionaryStringString.Create;
     124    Data.Add('FullName', FullName);
     125    Data.Add('Email', Email);
     126    Data.Add('Name', Name);
     127    //Data.Add('Password', 'SHA1(CONCAT("' + Password + '", "' + Salt + '"))');
     128    Database.Update('User', Data, '`Id`=' + IntToStr(Id));
     129  finally
     130    Data.Free;
     131    DbRows.Free;
     132  end;
     133end;
     134
    114135procedure TWebUser.Delete(Id: Integer);
    115136var
     
    129150  DbRows: TDbRows;
    130151begin
    131   if (Name = '') or (Password = '') or (Email = '') then raise Exception.Create(SEmptyUserParameters);
     152  if (Name = '') or (Password = '') or (Email = '') then
     153  raise Exception.Create(SEmptyUserParameters);
    132154  try
    133155    DbRows := TDbRows.Create;
     
    135157    if DbRows.Count = 0 then begin
    136158      Salt := EncodeBase64(Copy(BinToHexString(SHA1(FloatToStr(Now))), 1, 8));
    137       Database.Query(DbRows, 'INSERT INTO `User` (`Name`, `Password`, `Salt`, `Email`, `RegistrationTime`) VALUES ("' +
     159      Database.Query(DbRows, 'INSERT INTO `User` (`Name`, `Password`, `Salt`, `Email`, `RegistrationTime`, `FullName`) VALUES ("' +
    138160        Name + '", SHA1(CONCAT("' + Password + '", "' + Salt + '")), "' + Salt +
    139         '", "' + Email + '", NOW())');
     161        '", "' + Email + '", NOW(), "")');
    140162    end else raise EDuplicateItem.Create(Format(SDuplicateUserItem, [Name]));
    141163  finally
     
    152174    Database.Query(DbRows, 'SELECT `Id` FROM `User` WHERE `Name`="' + Name + '"');
    153175    if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[0].Value)
    154       else raise ENotFound.Create(Format(SUserNotFound, [Name]));
     176      else Result := -1;
    155177  finally
    156178    DBRows.Free;
     
    167189      '`Password` = SHA1(CONCAT("' + Password + '", Salt))');
    168190    if DbRows.Count = 1 then Result := StrToInt(DbRows[0].Items[0].Value)
    169       else raise ENotFound.Create(Format(SUserNotFound, [Name]));
     191      else Result := -1;
    170192  finally
    171193    DBRows.Free;
     
    184206      FullName := DbRows[0].Values['FullName'];
    185207      Email := DbRows[0].Values['Email'];
    186     end else raise ENotFound.Create(Format(SUserNotFound, [IntToStr(Id)]));
     208    end; // else raise ENotFound.Create(Format(SUserNotFound, [IntToStr(Id)]));
    187209  finally
    188210    DBRows.Free;
  • trunk/Packages/CoolWeb/WebServer/UHTTPServerTCP.pas

    r96 r98  
    4242  HandlerData: THTTPHandlerData;
    4343  I: Integer;
     44  ContentLength: Integer;
    4445begin
    4546  with TTCPClientThread(Sender), Socket do begin
     
    8182          Inc(LineIndex);
    8283        until Line = '';
     84
     85        if Request.Method = 'POST' then begin
     86          ContentLength := StrToInt(Request.Headers.Values['Content-Length']);
     87          SetLength(Line, ContentLength);
     88          RecvBufferEx(PByte(Line), ContentLength, 1000);
     89          Request.Post.Parse(Line);
     90        end;
    8391      finally
    8492        LineParts.Free;
    8593      end;
     94
     95
    8696
    8797    // Process cookies
     
    95105    Response.Content.Clear;
    96106    Response.Headers.Add('Content-Type', 'text/html');
     107
     108
    97109
    98110    if Assigned(OnRequest) then OnRequest(HandlerData)
  • trunk/UCore.pas

    r94 r98  
    8888  UModuleSystem, UModuleZdechovNET, UModuleUser, UPageAdmin;
    8989
     90resourcestring
     91  SError = '<div>Error: %s</div>';
     92
    9093{ TWebSession }
    9194
     
    366369      NewSession.Database.UserName := DatabaseUserName;
    367370      NewSession.InitDatabase;
    368       Page.Page.OnProduce(NewSession);
     371      try
     372        Page.Page.OnProduce(NewSession);
     373      except
     374        on E: Exception do begin
     375          THTMLString(TWebSession(NewSession).HtmlDocument.Body.SubItems.AddNew(THtmlString.Create)).
     376            Text := Format(SError, [E.Message]);
     377          NewSession.GeneratePage(Page.Page);
     378        end;
     379      end;
    369380      HandlerData.Assign(NewSession);
    370381    end else begin
  • trunk/languages/index.cs.po

    r76 r98  
    5858msgstr ""
    5959
     60#: ucore.serror
     61msgid "<div>Error: %s</div>"
     62msgstr ""
     63
    6064#: ucustomapplication.spagenotfound
    6165msgctxt "ucustomapplication.spagenotfound"
  • trunk/languages/index.po

    r76 r98  
    5050msgstr ""
    5151
     52#: ucore.serror
     53msgid "<div>Error: %s</div>"
     54msgstr ""
     55
    5256#: ucustomapplication.spagenotfound
    5357msgctxt "ucustomapplication.spagenotfound"
Note: See TracChangeset for help on using the changeset viewer.