Skip to content

Commit

Permalink
update to VER 2.3m
Browse files Browse the repository at this point in the history
  • Loading branch information
jianboy committed Dec 18, 2019
1 parent 40c7370 commit e0100cc
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 58 deletions.
Binary file modified src/data.RES
Binary file not shown.
14 changes: 7 additions & 7 deletions src/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ COMMENT with these you can disable some features of the template. Please note th
[list]
<div id='files_outer'>
<div style='height:1.6em;'></div> {.comment| this is quite ugly, i know, but if i use any vertical padding with height:100% i'll get a scrollbar .}
{.if not| %number% |{: <div style='font-size:200%; padding:1em;'>{.!No {.if|{.length|{.?search.}.}|results|files.}.}</div> :}|{:
{.if not| %number% |{: <div style='font-size:200%; padding:1em;'>{.!{.if|{.length|{.?search.}.}|No results|No files.}.}</div> :}|{:
<form method='post'>
<table id='files'>
{.set|sortlink| {:<a href="{.trim|
Expand Down Expand Up @@ -93,7 +93,7 @@ COMMENT with these you can disable some features of the template. Please note th
<button onclick='changePwd.call(this)' style='font-size:x-small;'>{.!Change password.}</button>
.}
:}
| <a href="~login">Login</a>
| <a href="~login">{.!Login.}</a>
.}
</center>
</fieldset>
Expand Down Expand Up @@ -155,7 +155,7 @@ COMMENT with these you can disable some features of the template. Please note th
selectedChanged();
">{.!Invert.}</button>
<button onclick='selectionMask.call(this)'>{.!Mask.}</button>
<p style='display:none; margin-top:1em;'><span id='selected-number'>0</span> items selected</p>
<p style='display:none; margin-top:1em;'><span id='selected-number'>0</span> {.!items selected.}</p>
</center>
</fieldset>

Expand Down Expand Up @@ -270,7 +270,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%

[+folder]
<td class='nosize'>folder<td>%item-modified%<td>%item-dl-count%
<td class='nosize'>{.!folder-item|folder.}<td>%item-modified%<td>%item-dl-count%

[+link]
<td class='nosize'>link<td colspan='2'>
Expand Down Expand Up @@ -377,7 +377,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }

[progress-upload-file]
{.if not|{.{.?only.} = down.}|{:
<li> Uploading %total% @ %speed-kb% KB/s
<li> {.!Uploading.} %total% @ %speed-kb% KB/s
<br /><span class='fn'>%filename%</span>
<br />{.!Time left.} %time-left%"
<br /><div class='out_bar'><div class='in_bar' style="width:%perc%px"></div></div> %perc%%
Expand Down Expand Up @@ -465,7 +465,7 @@ can change pwd=member of|can change password
can move=or|1|1
escape attr=replace|"|&quot;|$1
commentNL=if|{.pos|<br|$1.}|$1|{.replace|{.chr|10.}|<br />|$1.}
add bytes=switch|{.cut|-1||$1.}|,|0,1,2,3,4,5,6,7,8,9|$1 Bytes|K,M,G,T|$1Bytes
add bytes=switch|{.cut|-1||$1.}|,|0,1,2,3,4,5,6,7,8,9|$1 {.!Bytes.}|K,M,G,T|$1{.!Bytes.}

[special:import]
{.new account|can change password|enabled=1|is group=1|notes=accounts members of this group will be allowed to change their password.}
Expand Down Expand Up @@ -516,7 +516,7 @@ $(function(){
if (!$("[name=file]").val()) return false; // no file, no submit
$(this).hide(); // we don't need the form anymore, make space for the progress bars
// build the gui
x.append("<div id='progress'>in progress...</div>");
x.append("<div id='progress'>{.!in progress....}</div>");
x.append($("<button style='float:right'>{.!Cancel.}</button>").click(function(){
// stop submit/upload
if (typeof stop == 'function')
Expand Down
5 changes: 5 additions & 0 deletions src/hfs.bdsproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
<VersionInfoKeys Name="ProductVersion">2.3</VersionInfoKeys>
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
</VersionInfoKeys>





<Excluded_Packages>
<Excluded_Packages Name="c:\programmi\borland\bds\4.0\Bin\dclsoap100.bpl">Borland SOAP Components</Excluded_Packages>
<Excluded_Packages Name="c:\programmi\borland\bds\4.0\Bin\dclie100.bpl">Internet Explorer Components</Excluded_Packages>
Expand Down
5 changes: 5 additions & 0 deletions src/hfs.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ uses
types,
hslib,
sysUtils,
uFreeLocalizer,
main in 'main.pas' {mainFrm},
newuserpassDlg in 'newuserpassDlg.pas' {newuserpassFrm},
optionsDlg in 'optionsDlg.pas' {optionsFrm},
Expand Down Expand Up @@ -94,6 +95,10 @@ begin
end;
{$IFDEF EX_DEBUG}initErrorHandler(format('HFS %s (%s)', [VERSION, VERSION_BUILD]));{$ENDIF}
Application.Initialize();

FreeLocalizer.AutoTranslate := True;
FreeLocalizer.LanguageFile := 'hfs.lng';

Application.CreateForm(TmainFrm, mainFrm);
Application.CreateForm(TnewuserpassFrm, newuserpassFrm);
Application.CreateForm(ToptionsFrm, optionsFrm);
Expand Down
Binary file modified src/hfs.res
Binary file not shown.
31 changes: 15 additions & 16 deletions src/hfs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ COMMENT with these you can disable some features of the template. Please note th
[list]
<div id='files_outer'>
<div style='height:1.6em;'></div> {.comment| this is quite ugly, i know, but if i use any vertical padding with height:100% i'll get a scrollbar .}
{.if not| %number% |{: <div style='font-size:200%; padding:1em;'>{.!No {.if|{.length|{.?search.}.}|results|files.}.}</div> :}|{:
{.if not| %number% |{: <div style='font-size:200%; padding:1em;'>{.!{.if|{.length|{.?search.}.}|No results|No files.}.}</div> :}|{:
<form method='post'>
<table id='files'>
{.set|sortlink| {:<a href="{.trim|
Expand Down Expand Up @@ -93,7 +93,7 @@ COMMENT with these you can disable some features of the template. Please note th
<button onclick='changePwd.call(this)' style='font-size:x-small;'>{.!Change password.}</button>
.}
:}
| <a href="~login">Login</a>
| <a href="~login">{.!Login.}</a>
.}
</center>
</fieldset>
Expand Down Expand Up @@ -155,7 +155,7 @@ COMMENT with these you can disable some features of the template. Please note th
selectedChanged();
">{.!Invert.}</button>
<button onclick='selectionMask.call(this)'>{.!Mask.}</button>
<p style='display:none; margin-top:1em;'><span id='selected-number'>0</span> items selected</p>
<p style='display:none; margin-top:1em;'><span id='selected-number'>0</span> {.!items selected.}</p>
</center>
</fieldset>

Expand Down Expand Up @@ -270,7 +270,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%

[+folder]
<td class='nosize'>folder<td>%item-modified%<td>%item-dl-count%
<td class='nosize'>{.!folder.}<td>%item-modified%<td>%item-dl-count%

[+link]
<td class='nosize'>link<td colspan='2'>
Expand Down Expand Up @@ -377,7 +377,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }

[progress-upload-file]
{.if not|{.{.?only.} = down.}|{:
<li> Uploading %total% @ %speed-kb% KB/s
<li> {.!Uploading.} %total% @ %speed-kb% KB/s
<br /><span class='fn'>%filename%</span>
<br />{.!Time left.} %time-left%"
<br /><div class='out_bar'><div class='in_bar' style="width:%perc%px"></div></div> %perc%%
Expand Down Expand Up @@ -446,8 +446,8 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }
{.check session.}
{.break|if={.not|{.can comment.}.} |result=forbidden.}
{.for each|fn|{.replace|:|{.no pipe||.}|{.postvar|files.}.}|{:
{.break|if={.is file protected|var=fn.}|result=forbidden.}
{.set item|{.force ansi|%folder%{.^fn.}.}|comment={.encode html|{.force ansi|{.postvar|text.}.}.}.}
{.break|if={.is file protected|var=fn.}|result=forbidden.}
{.set item|{.force ansi|%folder%{.^fn.}.}|comment={.encode html|{.force ansi|{.postvar|text.}.}.}.}
:}.}
{.pipe|ok.}

Expand All @@ -465,8 +465,7 @@ can change pwd=member of|can change password
can move=or|1|1
escape attr=replace|"|&quot;|$1
commentNL=if|{.pos|<br|$1.}|$1|{.replace|{.chr|10.}|<br />|$1.}
add bytes=switch|{.cut|-1||$1.}|,|0,1,2,3,4,5,6,7,8,9|$1 Bytes|K,M,G,T|$1Bytes
quote={:"$1":}
add bytes=switch|{.cut|-1||$1.}|,|0,1,2,3,4,5,6,7,8,9|$1 {.!Bytes.}|K,M,G,T|$1{.!Bytes.}

[special:import]
{.new account|can change password|enabled=1|is group=1|notes=accounts members of this group will be allowed to change their password.}
Expand Down Expand Up @@ -517,7 +516,7 @@ $(function(){
if (!$("[name=file]").val()) return false; // no file, no submit
$(this).hide(); // we don't need the form anymore, make space for the progress bars
// build the gui
x.append("<div id='progress'>in progress...</div>");
x.append("<div id='progress'>{.!in progress....}</div>");
x.append($("<button style='float:right'>{.!Cancel.}</button>").click(function(){
// stop submit/upload
if (typeof stop == 'function')
Expand Down Expand Up @@ -674,7 +673,7 @@ function selectedChanged() {
function getItemName(el) {
if (typeof el == 'undefined')
return false;
// we handle elements, not jquery sets
// we handle elements, not jquery sets
if (el.jquery)
if (el.size())
el = el[0];
Expand Down Expand Up @@ -749,7 +748,7 @@ function ezprompt(msg, options, cb) {
}
if (!$.prompt) { // load on demand
include('/?mode=section&id=impromptu.css');
include('/?mode=section&id=jquery.impromptu.js');
include('/?mode=section&id=jquery.impromptu.js');
}
var v;
if (v = options.type) {
Expand All @@ -764,17 +763,17 @@ function ezprompt(msg, options, cb) {
$.prompt(msg, {
opacity: 0.9,
overlayspeed: 'fast',
loaded: function(){
loaded: function(){
$('#jqibox').find(':input').keypress(function (e) {
var c = (e.keyCode || e.which);
if (options.keypress && options.keypress(c, this, e) === false) return;
if (c != 13 || this.tagName == 'TEXTAREA') return; // ENTER key is like submit, but not in textarea
$('.jqibuttons button:first').click();
return false;
}).filter(':first').focus()[0].select();
}).filter(':first').focus()[0].select();
},
submit: function(val,div,form) {
var res = cb(options.type ? form.txt : form, $('#jqibox'), options.cbData );
var res = cb(options.type ? $.trim(form.txt) : form, $('#jqibox'), options.cbData );
if (res === false) {
$('#jqibox').find(':input:first').focus();
return false;
Expand Down Expand Up @@ -919,7 +918,7 @@ function delCookie(name) {
setCookie(name,"",-1);
} // delCookie
[jquery.impromptu.js|no log]
/*
* jQuery Impromptu
Expand Down
80 changes: 55 additions & 25 deletions src/hslib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ ThttpConn = class
constructor create(server:ThttpSrv);
destructor Destroy; override;
procedure disconnect();
procedure addHeader(s:string; overwrite:boolean=TRUE); // append an additional header line
procedure addHeader(s:string; overwrite:boolean=TRUE); // set an additional header line. If overwrite=false will always append.
function setHeaderIfNone(s:string):boolean; // set header if not already existing
procedure removeHeader(name:string);
function getHeader(h:string):string; // extract the value associated to the specified header field
function getCookie(k:string):string;
procedure setCookie(k, v:string; pairs:array of string; extra:string='');
Expand Down Expand Up @@ -1518,7 +1520,8 @@ procedure ThttpConn.tryNotify(ev:ThttpEvent);
procedure ThttpConn.sendheader(h:string='');
begin
state:=HCS_REPLYING_HEADER;
if reply.header = '' then reply.header:=h;
if reply.header = '' then
reply.header:=h;
includeTrailingString(reply.header, CRLF);
reply.header:=reply.header+reply.additionalHeaders;
includeTrailingString(reply.header, CRLF);
Expand Down Expand Up @@ -1555,32 +1558,59 @@ function ThttpConn.replyHeader_code(code:integer):string;
function ThttpConn.replyHeader_mode(mode:ThttpReplyMode):string;
begin result:=replyHeader_code(HRM2CODE[mode]) end;

procedure ThttpConn.addHeader(s:string; overwrite:boolean=TRUE);
function getNameOf(s:string):string; // colon included
begin result:=copy(s, 1, pos(':', s)) end;

// return 0 if not found
function namePos(name:string; headers:string; from:integer=1):integer;
begin
result:=from;
repeat
result:=ipos(name, headers, result);
until (result<=1) // both not found and found at the start of the string
or (headers[result-1] = #10) // or start of the line
end; // namePos

// return true if the operation succeded
function ThttpConn.setHeaderIfNone(s:string):boolean;
var
i, j, from: integer;
name, was: string;
name: string;
begin
name:=getNameOf(s);
if name = '' then
raise Exception.Create('Missing colon');
result:=namePos(name, reply.additionalHeaders) = 0; // empty text will also be considered as existing
if result then
addHeader(s, FALSE); // with FALSE it's faster
end; // setHeaderIfNone

procedure ThttpConn.removeHeader(name:string);
var
i, eol: integer;
s: string;
begin
s:=reply.additionalHeaders;
includeTrailingString(name,':');
// see if it already exists
i:=1;
repeat
i:=namePos(name, s, i);
if i = 0 then break;
// yes it does
eol:=posEx(#10, s, i);
if eol = 0 then // this never happens, unless the string is corrupted. Just to be sounder.
eol:=length(s);
delete(s, i, eol-i+1); // remove it
until false;
reply.additionalHeaders:=s;
end; // removeHeader

procedure ThttpConn.addHeader(s:string; overwrite:boolean=TRUE);
begin
was:=reply.additionalHeaders; // handy shortcut
if overwrite then
begin
// calculate the matching text
i:=pos(':', s);
if i = 0 then
i:=length(s);
name:=copy(s, 1, i);
// see if it already exists
from:=1;
repeat
i:=ipos(name, was, from);
if (i=0) or (i>1) and (was[i-1] <> #10) then break;
// yes it does
j:=posEx(#10, was, i)+1;
delete(was, i, j-i); // remove it
from:=i;
until false;
end;
reply.additionalHeaders:=was+s+CRLF;
end;
removeHeader(getNameOf(s));
appendStr(reply.additionalHeaders, s+CRLF);
end; // addHeader

function ThttpConn.getDontFree():boolean;
begin result:=lockCount > 0 end;
Expand Down
12 changes: 6 additions & 6 deletions src/main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ interface
HSlib, traylib, monoLib, progFrmLib, classesLib;

const
VERSION = '2.3k';
VERSION_BUILD = '299';
VERSION = '2.3m';
VERSION_BUILD = '300';
VERSION_STABLE = {$IFDEF STABLE } TRUE {$ELSE} FALSE {$ENDIF};
CURRENT_VFS_FORMAT :integer = 1;
CRLF = #13#10;
Expand Down Expand Up @@ -311,7 +311,7 @@ TconnData = class // data associated to a client connection
downloadingWhat: TdownloadingWhat;
preReply: TpreReply;
banReason: string;
lastBytesSent, lastBytesGot: int64; // used for print to log only the recent amount of bytes
lastBytesSent, lastBytesGot: int64; // used for print to log only the recent amount of bytes
lastActivityTime, fileXferStart: Tdatetime;
uploadSrc, uploadDest: string;
uploadFailed: string; // reason (empty on success)
Expand Down Expand Up @@ -5387,13 +5387,12 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
exit;
end;

if notModified(conn, f) then // calling notModified before limitsExceededOnDownload makes possible for [download] to manipualate headers set here
exit;
data.countAsDownload:=f.shouldCountAsDownload();
if data.countAsDownload and limitsExceededOnDownload() then
exit;

if notModified(conn, f) then
exit;

setupDownloadIcon(data);
data.eta.idx:=0;
conn.reply.contentType:=name2mimetype(f.name, DEFAULT_MIME);
Expand Down Expand Up @@ -10668,6 +10667,7 @@ procedure Tmainfrm.compressReply(cd:TconnData);
s:=ZcompressStr2(s, zcFastest, 31,8,zsDefault);
if (cd.workaroundForIEutf8 = yes) and (length(s) < BAD_IE_THRESHOLD) then exit;
cd.conn.addHeader('Content-Encoding: gzip');
cd.conn.addHeader('Content-Length: '+intToStr(length(s)));
cd.conn.reply.body:=s;
end; // compressReply

Expand Down
9 changes: 8 additions & 1 deletion src/scriptLib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,14 @@ function cbMacros(fullMacro:string; pars:Tstrings; cbData:pointer):string;
url:=trim(substr(p, ':'))
end
else
md.cd.conn.addHeader(p);
md.cd.conn.addHeader(p, isTrue(par('overwrite',true,'1')));
end;

if name = 'remove header' then
if satisfied(md.cd) then
begin
result:='';
md.cd.conn.removeHeader(p);
end;

if name = 'get ini' then
Expand Down
6 changes: 3 additions & 3 deletions src/utillib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,13 @@ function loadFile(fn:string; from:int64=0; size:int64=-1):ansistring;
try
reset(f,1);
if IOresult <> 0 then exit;
seek(f, from);
if size < 0 then
if (size < 0) or (size > filesize(f)-from) then
size:=filesize(f)-from;
setLength(result, size);
seek(f, from);
blockRead(f, result[1], size);
closeFile(f);
finally
closeFile(f);
filemode:=bak;
end;
end; // loadFile
Expand Down
Loading

0 comments on commit e0100cc

Please sign in to comment.