FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,
FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.UI.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Phys, FireDAC.Phys.FB, FireDAC.Phys.FBDef,
- FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef;
+ FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef, FireDAC.VCLUI.Wait,
+ FireDAC.Comp.UI;
type
TWebModule1 = class(TWebModule)
master: TPageProducer;
alert: TDataSetPageProducer;
mail: TPageProducer;
- css1: TPageProducer;
css2: TPageProducer;
css3: TPageProducer;
css4: TPageProducer;
header: TDataSetPageProducer;
js1: TPageProducer;
js2: TPageProducer;
- js3: TPageProducer;
- js4: TPageProducer;
adhead: TPageProducer;
js5: TPageProducer;
title: TPageProducer;
FDTable2DATE: TDateField;
FDTable2PASS: TWideStringField;
FDTable5: TFDTable;
- FDQuery1: TFDQuery;
FDTable4: TFDTable;
FDTable4ID: TIntegerField;
FDTable4DBNAME: TIntegerField;
FDTable1: TFDTable;
FDTable1DBNUM: TIntegerField;
FDTable1DATABASE: TWideStringField;
- FDTable5ID: TIntegerField;
- FDTable5NAME: TWideStringField;
- FDTable5SOURCE: TBlobField;
login: TPageProducer;
footer: TPageProducer;
- FDTable3mente: TBooleanField;
+ FDGUIxWaitCursor1: TFDGUIxWaitCursor;
+ FDQuery1: TFDQuery;
+ FDTable3mente: TSmallintField;
+ FDTable5id: TIntegerField;
+ FDTable5name: TWideStringField;
+ FDTable5source: TWideMemoField;
procedure indexHTMLTag(Sender: TObject; Tag: TTag; const TagString: string;
TagParams: TStrings; var ReplaceText: string);
procedure WebModule1indexpageAction(Sender: TObject; Request: TWebRequest;
procedure pages(count: Integer; var page: Integer);
procedure strsCheck(var Error: string; list: TStringList);
procedure setLastArticle;
+ function footerLink(Data: array of const): string;
function isInfo: Boolean;
function loginCheck: Boolean;
function hash(str: string): string;
ReplaceText := promotion
else if TagString = 'uri' then
ReplaceText := Request.ScriptName
- else if (TagString = 'mente') and
- (FDTable3.FieldByName('mente').AsBoolean = true) then
+ else if (TagString = 'mente') and (FDTable3.FieldByName('mente').AsInteger = 1)
+ then
ReplaceText := 'checked="checked"'
else if TagString = 'database' then
ReplaceText := Request.QueryFields.Values['db'];
var Align: THTMLAlign; var VAlign: THTMLVAlign;
var CustomAttrs, CellData: string);
begin
- if (CellColumn = 0) and (CellRow > 0) then
- CellData := Format('<input name=check%d type=checkbox>', [CellRow]);
+ if CellRow = 0 then
+ begin
+ BgColor:='Silver';
+ Exit;
+ end;
+ if CellRow mod 2 = 0 then
+ BgColor:='snow';
+ case CellColumn of
+ 0:
+ CellData := Format('<input name=check%d type=checkbox>', [CellRow]);
+ 1:
+ CellData := '<b>' + CellData + '</b>';
+ 2:
+ CellData := '<p style=color:red>' + CellData + '</p>';
+ 3:
+ CellData := '<p style=color:green>' + CellData + '</p>';
+ end;
end;
procedure TWebModule1.alertHTMLTag(Sender: TObject; Tag: TTag;
const TagString: string; TagParams: TStrings; var ReplaceText: string);
var
s: TStringList;
- i, j: Integer;
+ i: Integer;
begin
if (TagString = 'plus') and (alert.Tag = 0) then
ReplaceText := '<a href=' + Request.ScriptName +
'/jump?db=<#dbname>&num=<#posnum>>[ <#dbname>-<#posnum> ]</a>'
else if TagString = 'article' then
begin
- i := FDTable4.FieldByName('dbname').AsInteger;
- j := FDTable4.FieldByName('posnum').AsInteger;
- if FDTable2.Locate('dbnum;number', VarArrayOf([i, j])) = false then
+ if alert.Tag = 1 then
begin
ReplaceText := '<p>\83\8a\83N\83G\83X\83g';
Exit;
const TagString: string; TagParams: TStrings; var ReplaceText: string);
var
i: Integer;
+ s: shortstring;
+ x: Boolean;
begin
if TagString = 'link' then
begin
for i := 1 to 10 do
- if i = index.Tag then
- ReplaceText := ReplaceText + ' ' + i.ToString + ' '
- else
- ReplaceText := ReplaceText +
- Format(' <a style=text-decoration-line:none href="%s?db=%d&num=%d">%d</a> ',
- [Request.ScriptName + PString(Self.Tag)^,
- FDTable1.FieldByName('dbnum').AsInteger, i, i]);
- end
- else if TagString = 'recent' then
- if index.Tag = -1 then
- ReplaceText := TagString
- else
- ReplaceText := '<a style=text-decoration-line:none href="' +
- Request.ScriptName + PString(Self.Tag)^ + '?db=' +
- FDTable1.FieldByName('dbnum').AsString + '">recent</a>';
+ begin
+ x := i = index.Tag;
+ ReplaceText := ReplaceText + footerLink([i, i, x]);
+ end;
+ x := index.Tag = -1;
+ s:='\82³\82¢\82²';
+ ReplaceText := ReplaceText + footerLink([-1, s, x]);
+ end;
+end;
+
+function TWebModule1.footerLink(Data: array of const): string;
+var
+ s, t: string;
+begin
+ if data[1].VType = vtInteger then
+ t:=data[1].VInteger.toString
+ else
+ t:=data[1].VString^;
+ if Data[2].VBoolean = true then
+ s := ' active'
+ else
+ s := '';
+ result := Format
+ ('<li class="page-item%s"><a class=page-link href="%s?db=%d&num=%d">%s</a></li>',
+ [s, Request.ScriptName + PString(Self.Tag)^, FDTable1.FieldByName('dbnum')
+ .AsInteger, Data[0].VInteger, t]);
end;
function TWebModule1.hash(str: string): string;
procedure TWebModule1.masterHTMLTag(Sender: TObject; Tag: TTag;
const TagString: string; TagParams: TStrings; var ReplaceText: string);
var
- i: Integer;
+ i, j: Integer;
begin
if TagString = 'pr' then
ReplaceText := promotion
else if TagString = 'uri' then
ReplaceText := Request.ScriptName
else if TagString = 'request' then
+ begin
+ FDTable1.Close;
with FDTable4 do
begin
First;
while Eof = false do
begin
+ i := FieldByName('dbname').AsInteger;
+ j := FieldByName('posnum').AsInteger;
+ if FDTable2.Locate('dbnum;number', VarArrayOf([i, j])) = true then
+ alert.Tag := 0
+ else
+ alert.Tag := 1;
ReplaceText := ReplaceText + alert.ContentFromString(alert.Content);
Next;
end;
ReplaceText := '<table border=1 align=center>' + ReplaceText +
'</table>';
end;
+ FDTable1.Open;
+ FDTable1.Refresh;
+ end;
end;
function TWebModule1.mente: Boolean;
+var
+ s: string;
begin
- if FDTable3.FieldByName('mente').AsBoolean = true then
+ if FDTable3.FieldByName('mente').AsInteger = 1 then
begin
+ s := Request.QueryFields.Values['db'];
+ if s <> '' then
+ s := '?db=' + s;
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>' +
- Format('<p style=text-align:center><a href=%s/admin>\8aÇ\97\9d\8eÒ\97p\83\8d\83O\83C\83\93</a>',
- [Request.ScriptName]);
+ Format('<p style=text-align:center><a href=%s/admin%s>\8aÇ\97\9d\8eÒ\97p\83\8d\83O\83C\83\93</a>',
+ [Request.ScriptName, s]);
end
else
result := false;
else if TagString = 'database' then
ReplaceText := FDTable1.FieldByName('database').AsString
else if TagString = 'date' then
- with FDTable2 do
- begin
- Last;
- ReplaceText := FieldByName('date').AsString;
- end;
+ ReplaceText := FDQuery1.FieldByName('max(date)').AsString;
end;
procedure TWebModule1.titleHTMLTag(Sender: TObject; Tag: TTag;
else if TagString = 'main' then
begin
FDQuery1.Open;
- FDTable1.First;
- while (FDQuery1.Eof = false) and (FDTable1.Eof = false) do
+ while FDQuery1.Eof = false do
begin
- if FDTable1.FieldByName('dbnum').AsInteger = FDQuery1.FieldByName('dbnum')
- .AsInteger then
- begin
- ReplaceText := ReplaceText + ti.Content;
- FDQuery1.Next;
- end
- else if FDTable2.Eof = false then
- ReplaceText := ReplaceText + ti.Content;
- FDTable1.Next;
+ FDTable1.Locate('dbnum', FDQuery1.FieldByName('dbnum').AsInteger);
+ ReplaceText := ReplaceText + ti.Content;
+ FDQuery1.Next;
end;
FDQuery1.Close;
end;
[t, Request.ScriptName, j, s]);
FDTable1.Next;
end;
+ ReplaceText :=
+ '<div class="carousel-caption text-left" style="text-align:bottom;font-size:1.5rem">'
+ + ReplaceText + '</div>';
end
else if TagString = 'info' then
ReplaceText := FDTable1.Lookup('dbnum', FDTable3.FieldByName('info')
ReplaceText := detail(TagString, TagParams.Values['id'])
else if TagString = 'slide' then
begin
+ s := ' active';
for i := 1 to (FDTable1.RecordCount div tcnt) + 1 do
+ begin
+ ReplaceText := ReplaceText +
+ Format('<div class="carousel-item%s"><img src="%s/src?name=slide%d.jpg"',
+ [s, Request.ScriptName, i]) +
+ ' class="d-sm-block d-none" style=float:right;height:465px><div style=height:465px></div><#list></div>';
+ s := '';
+ end;
+ end
+ else if TagString = 'indicator' then
+ begin
+ s := ' class="active"';
+ for i := 0 to (FDTable1.RecordCount div tcnt) do
+ begin
ReplaceText := ReplaceText +
- Format('<div class="slide"><img src="%s/src?name=slide%d.jpg"',
- [Request.ScriptName, i]) +
- ' style=float:right;height:465px><#list></div>';
+ Format('<li data-target="#slide-1" data-slide-to=%d%s></li>', [i, s]);
+ s := '';
+ end;
end;
end;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
s: string;
+ i: Integer;
begin
s := Request.ContentFields.Values['pass'];
with FDTable3 do
begin
Edit;
- FieldByName('mente').AsBoolean := Request.ContentFields.Values
- ['mente'] = 'on';
- if s <> '' then
+ if Request.ContentFields.Values['mente'] = 'on' then
+ i := 1
+ else
+ i := 0;
+ FieldByName('mente').AsInteger := i;
+ if (s <> '') and (s = Request.ContentFields.Values['pass2']) then
begin
s := hash(s);
FieldByName('password').AsString := hash(s);
s := '(No Comment)';
AppendRecord([i, num1, num2, Now, s]);
end;
- Response.SendRedirect(Format('%s/index?db=%d&num=%d#%d',
- [Request.ScriptName, num1, num2, num2]))
+ WebModule1jumpAction(nil, Request, Response, Handled);
end;
end;
Response: TWebResponse; var Handled: Boolean);
var
s: string;
- res: TStream;
+ p: TBytes;
+ res: TMemoryStream;
begin
with FDTable5 do
begin
- s := Request.ContentFields.Values['name'];
+ s := Request.QueryFields.Values['name'];
Response.ContentType := 'image/jpeg';
if Locate('name', s) = true then
begin
- res := CreateBlobStream(FieldByName('source'), bmRead);
- Response.ContentStream := res;
- end
- else if s = 'sprites.png' then
- begin
- Response.ContentType := 'image/png';
- res := TResourceStream.Create(HInstance, 'PngImage_1', RT_RCDATA);
+ s := FieldByName('source').AsString;
+ p := TNetEncoding.Base64.DecodeStringToBytes(s);
+ res := TMemoryStream.Create;
+ res.WriteBuffer(p, Length(p));
Response.ContentStream := res;
end
else
i: Integer;
s: string;
begin
+ Response.ContentType := 'text/html; charset="utf-8"';
+ if mente = true then
+ Exit;
s := Request.QueryFields.Values['db'];
if s <> '' then
FDTable1.Locate('dbnum', s, []);
index.Tag := i;
tagstr := '/index';
Self.Tag := Integer(@tagstr);
- Response.ContentType := 'text/html; charset="utf-8"';
- if mente = false then
- Response.Content := index.Content;
+ Response.Content := index.Content;
end;
procedure TWebModule1.WebModule1jumpAction(Sender: TObject;
if Request.MethodType = mtPost then
begin
s := Request.ContentFields.Values['delete'];
- if s = 'all' then
- with FDTable4 do
- repeat
- Delete;
- until (Bof = true) and (Eof = true)
+ with FDTable4 do
+ if s = 'all' then
+ while not((Bof = true) and (Eof = true)) do
+ Delete
else
begin
- FDTable4.First;
- while FDTable4.Eof = false do
+ First;
+ while Eof = false do
begin
- i := FDTable4.FieldByName('dbname').AsInteger;
+ i := FieldByName('dbname').AsInteger;
if FDTable1.Locate('dbnum', i) = true then
begin
- i := FDTable4.FieldByName('posnum').AsInteger;
+ i := FieldByName('posnum').AsInteger;
if FDTable2.Locate('number', i) = false then
- FDTable4.Delete
+ Delete
else
- FDTable4.Next;
+ Next;
end
else
- FDTable4.Delete;
+ Delete;
end;
end;
end;
+ FDTable4.First;
Response.ContentType := 'text/html;charset=utf-8';
Response.Content := master.Content;
end;
FDTable3.AppendRecord
(['\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, i, 30, hash(hash('admin')), s]);
+ 0, i, 30, hash(hash('admin')), s]);
end;
+ admin.MaxRows := FDTable3.FieldByName('count').AsInteger;
end;
end.