Browse Subversion Repository
Contents of /UserSessionUnit.pas
Parent Directory
| Revision Log
Revision 11 -
( show annotations)
( download)
( as text)
Fri Jul 22 23:40:03 2016 UTC
(7 years, 8 months ago)
by yamat0jp
File MIME type: text/x-pascal
File size: 1833 byte(s)
パスワードをハッシュ値に置き換えました
クッキーに対応
| 1 |
unit UserSessionUnit; |
| 2 |
|
| 3 |
{ |
| 4 |
This is a DataModule where you can add components or declare fields that are specific to |
| 5 |
ONE user. Instead of creating global variables, it is better to use this datamodule. You can then |
| 6 |
access the it using UserSession. |
| 7 |
} |
| 8 |
interface |
| 9 |
|
| 10 |
uses |
| 11 |
IWUserSessionBase, SysUtils, Classes, Unit3; |
| 12 |
|
| 13 |
type |
| 14 |
TIWUserSession = class(TIWUserSessionBase) |
| 15 |
procedure IWUserSessionBaseDestroy(Sender: TObject); |
| 16 |
procedure IWUserSessionBaseCreate(Sender: TObject); |
| 17 |
private |
| 18 |
FDM: TDataModule3; |
| 19 |
function GetDM: TDataModule3; |
| 20 |
{ Private declarations } |
| 21 |
public |
| 22 |
{ Public declarations } |
| 23 |
FPage: Boolean; |
| 24 |
user_number: integer; |
| 25 |
FThumbnail: Boolean; |
| 26 |
Serial: integer; |
| 27 |
function hash(const pass: string): string; |
| 28 |
property DM: TDataModule3 read GetDM; |
| 29 |
end; |
| 30 |
|
| 31 |
implementation |
| 32 |
|
| 33 |
{$R *.dfm} |
| 34 |
{ TIWUserSession } |
| 35 |
|
| 36 |
function TIWUserSession.GetDM: TDataModule3; |
| 37 |
begin |
| 38 |
if Assigned(FDM) = false then |
| 39 |
FDM := TDataModule3.Create(nil); |
| 40 |
result := FDM; |
| 41 |
end; |
| 42 |
|
| 43 |
function TIWUserSession.hash(const pass: string): string; |
| 44 |
var |
| 45 |
i: integer; |
| 46 |
k: integer; |
| 47 |
begin |
| 48 |
result := ''; |
| 49 |
for i := Length(pass) downto 1 do |
| 50 |
begin |
| 51 |
k := Ord(pass[i]) * i; |
| 52 |
result := result + k.ToString; |
| 53 |
end; |
| 54 |
end; |
| 55 |
|
| 56 |
procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject); |
| 57 |
var |
| 58 |
s: string; |
| 59 |
begin |
| 60 |
FThumbnail := true; |
| 61 |
s := WebApplication.Request.CookieFields.Values['user_cookie']; |
| 62 |
if (s <> '') and (DM.FDTable1.Locate('NUMBER', s, []) = true) then |
| 63 |
begin |
| 64 |
user_number:=s.ToInteger; |
| 65 |
if DM.FDTable1.FieldByName('EMAIL').AsString = '' then |
| 66 |
FPage:=true |
| 67 |
else |
| 68 |
FPage:=false; |
| 69 |
end |
| 70 |
else |
| 71 |
FPage:=true; |
| 72 |
end; |
| 73 |
|
| 74 |
procedure TIWUserSession.IWUserSessionBaseDestroy(Sender: TObject); |
| 75 |
begin |
| 76 |
FreeAndNil(FDM); |
| 77 |
end; |
| 78 |
|
| 79 |
end. |
|