added 'no log' section flag to support SAP themes like 'mobil-light'

This commit is contained in:
Massimo Melina 2020-06-08 12:40:34 +02:00
parent 782702c192
commit b028c47f10
2 changed files with 97 additions and 79 deletions

View File

@ -139,7 +139,7 @@ type
PtplSection = ^TtplSection; PtplSection = ^TtplSection;
TtplSection = record TtplSection = record
name, txt: string; name, txt: string;
nolog, nourl, cache: boolean; nolog, nourl, noList, cache: boolean;
ts: Tdatetime; ts: Tdatetime;
end; end;
@ -1023,9 +1023,10 @@ var
// there may be flags after | // there may be flags after |
s:=cur_section; s:=cur_section;
cur_section:=chop('|', s); cur_section:=chop('|', s);
base.nolog:=ansiPos('no log', s) > 0; base.nolog:=containsStr('no log', s);
base.nourl:=ansiPos('private', s) > 0; base.nourl:=containsStr('private', s);
base.cache:=ansiPos('cache', s) > 0; base.noList:=containsStr('no list', s);
base.cache:=containsStr('cache', s);
base.ts:=now(); base.ts:=now();
s:=cur_section; s:=cur_section;

View File

@ -1,4 +1,4 @@
{ {
Copyright (C) 2002-2014 Massimo Melina (www.rejetto.com) Copyright (C) 2002-2014 Massimo Melina (www.rejetto.com)
This file is part of HFS ~ HTTP File Server. This file is part of HFS ~ HTTP File Server.
@ -36,8 +36,8 @@ uses
HSlib, traylib, monoLib, progFrmLib, classesLib; HSlib, traylib, monoLib, progFrmLib, classesLib;
const const
VERSION = '2.4.0 RC1'; VERSION = '2.4.0 RC2';
VERSION_BUILD = '313'; VERSION_BUILD = '314';
VERSION_STABLE = {$IFDEF STABLE } TRUE {$ELSE} FALSE {$ENDIF}; VERSION_STABLE = {$IFDEF STABLE } TRUE {$ELSE} FALSE {$ENDIF};
CURRENT_VFS_FORMAT :integer = 1; CURRENT_VFS_FORMAT :integer = 1;
CRLF = #13#10; CRLF = #13#10;
@ -3645,16 +3645,12 @@ const MAX_CONCURRENTS = 3;
var var
i, n: integer; i, n: integer;
f: Tfile; f: Tfile;
useList: boolean;
mainSection: PtplSection;
begin begin
result:=''; result:='';
if (folder = NIL) or not folder.isFolder() then exit; if (folder = NIL) or not folder.isFolder() then exit;
if not available() then
begin
cd.conn.reply.mode:=HRM_OVERLOAD;
cd.conn.addHeader('Refresh: '+intToStr(1+random(2))); // random for less collisions
exit('Please wait, server busy');
end;
if macrosLogChk.checked and not appendmacroslog1.checked then if macrosLogChk.checked and not appendmacroslog1.checked then
resetLog(); resetLog();
diffTpl:=Ttpl.create(); diffTpl:=Ttpl.create();
@ -3676,6 +3672,18 @@ try
if otpl <> filelistTpl then if otpl <> filelistTpl then
diffTpl.fullText:=folder.getRecursiveDiffTplAsStr(); diffTpl.fullText:=folder.getRecursiveDiffTplAsStr();
mainSection:=diffTpl.getSection('');
if mainSection = NIL then
exit;
useList:=not mainSection.noList;
if useList and not available() then
begin
cd.conn.reply.mode:=HRM_OVERLOAD;
cd.conn.addHeader('Refresh: '+intToStr(1+random(2))); // random for less collisions
exit('Please wait, server busy');
end;
fullEncode:=FALSE; fullEncode:=FALSE;
ofsRelUrl:=length(folder.url(fullEncode))+1; ofsRelUrl:=length(folder.url(fullEncode))+1;
ofsRelItemUrl:=length(folder.pathTill())+1; ofsRelItemUrl:=length(folder.pathTill())+1;
@ -3693,6 +3701,8 @@ try
result:=diffTpl['special:begin']; result:=diffTpl['special:begin'];
tryApplyMacrosAndSymbols(result, md, FALSE); tryApplyMacrosAndSymbols(result, md, FALSE);
if useList then
begin
// cache these values // cache these values
fileTpl:=xtpl(diffTpl['file'], table); fileTpl:=xtpl(diffTpl['file'], table);
folderTpl:=xtpl(diffTpl['folder'], table); folderTpl:=xtpl(diffTpl['folder'], table);
@ -3726,7 +3736,7 @@ try
else else
inc(numberFiles); inc(numberFiles);
end; end;
{TODO this symbols will be available when executing macros in handleItem. Having {TODO these symbols will be available when executing macros in handleItem. Having
them at this stage is useful only in case immediate calculations are required. them at this stage is useful only in case immediate calculations are required.
This may happen seldom, but maybe some template is using it since we got this here. This may happen seldom, but maybe some template is using it since we got this here.
Each symbols is an extra iteration on the template piece and we may be tempted Each symbols is an extra iteration on the template piece and we may be tempted
@ -3762,12 +3772,17 @@ try
if cd.conn.state = HCS_DISCONNECTED then exit; if cd.conn.state = HCS_DISCONNECTED then exit;
// build final page // build final page
if not oneAccessible then md.archiveAvailable:=FALSE; if not oneAccessible then
md.archiveAvailable:=FALSE;
end
else
list:='';
md.table:=table; md.table:=table;
addArray(md.table, [ addArray(md.table, [
'%list%',list '%list%',list
]); ]);
result:=diffTpl['']; result:=mainSection.txt;
md.f:=NIL; md.f:=NIL;
md.afterTheList:=TRUE; md.afterTheList:=TRUE;
try tryApplyMacrosAndSymbols(result, md) try tryApplyMacrosAndSymbols(result, md)
@ -3777,6 +3792,7 @@ try
result:=replaceText(result, '%build-time%', result:=replaceText(result, '%build-time%',
floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7,3) ); floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7,3) );
finally finally
if useList then
updateAvailability(); updateAvailability();
folder.unlock(); folder.unlock();
diffTpl.free; diffTpl.free;
@ -4987,6 +5003,7 @@ var
data.session:=sessions[sid]; data.session:=sessions[sid];
if data.session.ip <> conn.address then if data.session.ip <> conn.address then
begin begin
conn.delCookie(SESSION_COOKIE); // legitimate clients that changed address must clear their cookie, or they will be stuck with this invalid session
conn.reply.mode:=HRM_DENY; conn.reply.mode:=HRM_DENY;
result:=FALSE; result:=FALSE;
exit; exit;