interface
uses System.SysUtils, System.Classes, Web.HTTPApp, Web.DSProd, Web.HTTPProd,
- Web.DBWeb, System.Variants, System.NetEncoding, System.RegularExpressions;
+ Web.DBWeb, System.Variants, System.NetEncoding, System.RegularExpressions,
+ IdHashSHA, IdGlobal;
type
TTWebModule1 = class(TWebModule)
ss: TStringList;
procedure pages(count: Integer; var page: Integer);
function getdbname: string;
+ function hash(str: string): string;
+ function mente: Boolean;
public
{ public \90é\8c¾ }
end;
result := '';
end;
+function TTWebModule1.hash(str: string): string;
+var
+ s: TIdHashSHA512;
+begin
+ s := TIdHashSHA512.Create;
+ try
+ result := s.HashStringAsHex(str, IndyTextEncoding_UTF8);
+ finally;
+ s.Free;
+ end;
+ if result = '' then
+ result := 'admin';
+end;
+
procedure TTWebModule1.headerHTMLTag(Sender: TObject; Tag: TTag;
const TagString: string; TagParams: TStrings; var ReplaceText: string);
var
ReplaceText := header.Content;
end
else if (TagString = 'css') or (TagString = 'js') then
- ReplaceText := detail;
+ ReplaceText := detail
+ else if TagString = 'database' then
+ ReplaceText := DataModule1.FDTable1.FieldByName('database').AsString;
end;
procedure TTWebModule1.itemsHTMLTag(Sender: TObject; Tag: TTag;
end;
end;
+function TTWebModule1.mente: Boolean;
+begin
+ if DataModule1.FDTable3.FieldByName('mente').AsBoolean = true then
+ begin
+ result := true;
+ Response.Content :=
+ '<p><br><h1 style=text-align:center>\82½\82¾\82¢\82Ü\83\81\83\93\83e\83i\83\93\83X\92\86\82Å\82·^_^</h1>' +
+ '<p style=text-align:center><a href=/admin>\8aÇ\97\9d\8eÒ\97p\83\8d\83O\83C\83\93</a>'
+ end
+ else
+ result := false;
+end;
+
procedure TTWebModule1.pages(count: Integer; var page: Integer);
var
max: Integer;
Edit;
FieldByName('mente').AsBoolean := Request.ContentFields.Values
['mente'] = 'on';
- FieldByName('password').AsString := Request.ContentFields.Values['pass'];
+ FieldByName('password').AsString :=
+ hash(Request.ContentFields.Values['pass']);
Post;
end;
TWebModule1adminAction(nil, Request, Response, Handled);
s := '/index';
Self.Tag := Integer(@s);
Response.ContentType := 'text/html; charset="utf-8"';
- if DataModule1.FDTable3.FieldByName('mente').AsBoolean = true then
- Response.Content := '\82½\82¾\82¢\82Ü\83\81\83\93\83e\83i\83\93\83X\92\86\82Å\82·^_^'
- else
+ if mente = false then
Response.Content := index.Content;
end;
with Response.Cookies.Add do
begin
Name := 'user';
- Value := DataModule1.FDTable3.FieldByName('password').AsString;
+ Value := hash(Request.ContentFields.Values['password']);
Expires := Now + 14;
end;
s := Request.ContentFields.Values['record'];
error := '<p style=font-size:2.3em;color:blue>\81«\81«\83v\83\8c\83r\83\85\81[\81«\81«<p>' +
comment.Text;
Request.ContentFields.Values['show'] := 'false';
- Request.ContentFields.Add('preview=' + error);
- Request.ContentFields.Add('raw=' + raw);
+ Request.ContentFields.Values['preview'] := error;
+ Request.ContentFields.Values['raw'] := raw;
end
else
begin
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.ContentType := 'text/html;charset=utf-8';
- Response.Content := top.Content;
+ if mente = false then
+ Response.Content := top.Content;
end;
procedure TTWebModule1.WebModuleCreate(Sender: TObject);
begin
a := DataModule1.FDTable1.Lookup('database', 'info', 'dbnum');
DataModule1.FDTable3.AppendRecord
- (['\82Æ\82é\82Ë\81`\82Ç\8d\86', '<p style=color:gray>\82Æ\82é\82Ë\81`\82Ç\8d\86</p>', false, a, 30, 'admin']);
+ (['\82Æ\82é\82Ë\81`\82Ç\8d\86',
+ '<h1 style=color:maron;text-align:center;font-style:italic>\82Æ\82é\82Ë\81`\82Ç\8d\86</h1>',
+ false, a, 30, hash('admin')]);
end;
end;