From e0100cc7d95e9e10a4fe3b7c4c1441124e3b70d2 Mon Sep 17 00:00:00 2001 From: liuyuqi-dellpc Date: Wed, 18 Dec 2019 21:19:31 +0800 Subject: [PATCH] update to VER 2.3m --- src/data.RES | Bin 133448 -> 133668 bytes src/default.tpl | 14 ++++---- src/hfs.bdsproj | 5 +++ src/hfs.dpr | 5 +++ src/hfs.res | Bin 31272 -> 31272 bytes src/hfs.tpl | 31 +++++++++--------- src/hslib.pas | 80 +++++++++++++++++++++++++++++++--------------- src/main.pas | 12 +++---- src/scriptLib.pas | 9 +++++- src/utillib.pas | 6 ++-- src/whatsnew.txt | 10 ++++++ 11 files changed, 114 insertions(+), 58 deletions(-) diff --git a/src/data.RES b/src/data.RES index 3ebc5ab5a6ba017562d4db33455b532fc7866d26..cbf5f7fa15c0540c846bbae6acc433779354d3d7 100644 GIT binary patch delta 608 zcmX>xiDStWjtORroEyzoGBK?_KKT)o4kPDger9D3t!ll@w3=$YoYcJZk_;fjzBo0p zC^ zC8@c^3dN~8smUd&DL{!{DLD~wphQ}JPD*N#E=axx!Ujri)U)8`14@P#jAZ5Q)>%UT&)K;vm_(4SRuExxI`f-RUsumFBM3q|mOl;yzy<7!*#GC8@NAr zoTpGwl%Ecamts92sNF0Q$Sbi~IrA>(X2#;%jFYPa`8K~P+0Qt6O<96~ie5=kX08U% zGr4*t6(yRRMapZ0H&5vbvY-6oq#iH{h@Wz21XA&*^O=Cu`LpamYV!5-(}86Eh5taI k{ENXL1&1%0GXtsLSFei$smpJxfr8Ec@3;HEXZ$G%0F{~B6951J delta 388 zcmZ27h2z8|jtORr0vpX&GBKS!Hu({g4x_+ker9D34!?YbYQ4;~n#m5jVw^Qasl}x^ zCB-$HW4Nsu851|p;Q7YP>XV2g2@evs+$i< zeG_I&%g;$kEt*`Qr?dID9uGHDXu)J1>&ngTR`b{xIVaoO$xn`PRh*pZcxm!ICymJq zql71WINMH^ay9^B9lA3D0xJtcRJt%kcO6Pt?gzn9CuG^U=n|sU^O{y$O zEw1s_@zrtH38_&r1oJn4_ISs^mzk$fP?Vnz^hvRvp5Ep!fxHq-3JRMUv+i;-Dr~-2 ze47!(-C25;kx^lCTX_OUT7FTkUP(pC=5OUS!Ym3vu(_x^$exj5^5IkZz+n1(%AFBN zS)a*g0#d8bu>+~en=ecUlHM2p1BJXV1%njKziiG7q^@7PE)JyDzpDlcHfw*_uKj`W Grz8NkeU2#r diff --git a/src/default.tpl b/src/default.tpl index 2eb20a7..588b72f 100644 --- a/src/default.tpl +++ b/src/default.tpl @@ -48,7 +48,7 @@ COMMENT with these you can disable some features of the template. Please note th [list]
{.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% |{:
{.!No {.if|{.length|{.?search.}.}|results|files.}.}
:}|{: + {.if not| %number% |{:
{.!{.if|{.length|{.?search.}.}|No results|No files.}.}
:}|{:
{.set|sortlink| {:Login + | {.!Login.} .} @@ -155,7 +155,7 @@ COMMENT with these you can disable some features of the template. Please note th selectedChanged(); ">{.!Invert.} -

0 items selected

+

0 {.!items selected.}

@@ -270,7 +270,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }
%item-size%B%item-modified%%item-dl-count% [+folder] -folder%item-modified%%item-dl-count% +{.!folder-item|folder.}%item-modified%%item-dl-count% [+link] link @@ -377,7 +377,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; } [progress-upload-file] {.if not|{.{.?only.} = down.}|{: -
  • Uploading %total% @ %speed-kb% KB/s +
  • {.!Uploading.} %total% @ %speed-kb% KB/s
    %filename%
    {.!Time left.} %time-left%"
    %perc%% @@ -465,7 +465,7 @@ can change pwd=member of|can change password can move=or|1|1 escape attr=replace|"|"|$1 commentNL=if|{.pos||$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.} @@ -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("
    in progress...
    "); + x.append("
    {.!in progress....}
    "); x.append($("").click(function(){ // stop submit/upload if (typeof stop == 'function') diff --git a/src/hfs.bdsproj b/src/hfs.bdsproj index ea71cc5..c4179b8 100644 --- a/src/hfs.bdsproj +++ b/src/hfs.bdsproj @@ -171,6 +171,11 @@ 2.3 + + + + + Borland SOAP Components Internet Explorer Components diff --git a/src/hfs.dpr b/src/hfs.dpr index 9fa5b70..4ae79c9 100644 --- a/src/hfs.dpr +++ b/src/hfs.dpr @@ -32,6 +32,7 @@ uses types, hslib, sysUtils, + uFreeLocalizer, main in 'main.pas' {mainFrm}, newuserpassDlg in 'newuserpassDlg.pas' {newuserpassFrm}, optionsDlg in 'optionsDlg.pas' {optionsFrm}, @@ -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); diff --git a/src/hfs.res b/src/hfs.res index 6ea6efe8a4f5769fa87347a418290ee616edf247..46d2be120337e1d260913060e7dcfc28008f11f1 100644 GIT binary patch delta 42 ucmZ4Sg>l6f#tCMOoEy!Lt1@zK{;%rp1f<+Ej&lGh{=(_3Kx%neBQpS0=nlI8 delta 42 ucmZ4Sg>l6f#tCMO0vpYbt1=2~{;%rp1f<+Ej&lGh{=(_3Kx%neBQpS3oetgr diff --git a/src/hfs.tpl b/src/hfs.tpl index 443bed5..d208418 100644 --- a/src/hfs.tpl +++ b/src/hfs.tpl @@ -48,7 +48,7 @@ COMMENT with these you can disable some features of the template. Please note th [list]
    {.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% |{:
    {.!No {.if|{.length|{.?search.}.}|results|files.}.}
    :}|{: + {.if not| %number% |{:
    {.!{.if|{.length|{.?search.}.}|No results|No files.}.}
    :}|{: {.set|sortlink| {:Login + | {.!Login.} .} @@ -155,7 +155,7 @@ COMMENT with these you can disable some features of the template. Please note th selectedChanged(); ">{.!Invert.} -

    0 items selected

    +

    0 {.!items selected.}

    @@ -270,7 +270,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; }
    %item-size%B%item-modified%%item-dl-count% [+folder] -folder%item-modified%%item-dl-count% +{.!folder.}%item-modified%%item-dl-count% [+link] link @@ -377,7 +377,7 @@ fieldset { margin-bottom:0.7em; text-align:left; padding:0.6em; } [progress-upload-file] {.if not|{.{.?only.} = down.}|{: -
  • Uploading %total% @ %speed-kb% KB/s +
  • {.!Uploading.} %total% @ %speed-kb% KB/s
    %filename%
    {.!Time left.} %time-left%"
    %perc%% @@ -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.} @@ -465,8 +465,7 @@ can change pwd=member of|can change password can move=or|1|1 escape attr=replace|"|"|$1 commentNL=if|{.pos||$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.} @@ -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("
    in progress...
    "); + x.append("
    {.!in progress....}
    "); x.append($("").click(function(){ // stop submit/upload if (typeof stop == 'function') @@ -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]; @@ -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) { @@ -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; @@ -919,7 +918,7 @@ function delCookie(name) { setCookie(name,"",-1); } // delCookie - + [jquery.impromptu.js|no log] /* * jQuery Impromptu diff --git a/src/hslib.pas b/src/hslib.pas index 0b5212f..c7f973a 100644 --- a/src/hslib.pas +++ b/src/hslib.pas @@ -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=''); @@ -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); @@ -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; diff --git a/src/main.pas b/src/main.pas index a528e8a..dab417b 100644 --- a/src/main.pas +++ b/src/main.pas @@ -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; @@ -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) @@ -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); @@ -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 diff --git a/src/scriptLib.pas b/src/scriptLib.pas index 353a095..2b9387e 100644 --- a/src/scriptLib.pas +++ b/src/scriptLib.pas @@ -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 diff --git a/src/utillib.pas b/src/utillib.pas index 1f4c996..123c7ed 100644 --- a/src/utillib.pas +++ b/src/utillib.pas @@ -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 diff --git a/src/whatsnew.txt b/src/whatsnew.txt index 9cebb3e..4561805 100644 --- a/src/whatsnew.txt +++ b/src/whatsnew.txt @@ -7,6 +7,16 @@ LEGEND - bug fix AV access violation +VER 2.3m +propaganda + Bug fixes +/propaganda ++ initial localization support http://www.rejetto.com/forum/programmers-corner/translations-to-other-languages/ ++ {.remove header.} +- fixed error pages' loading problem http://www.rejetto.com/forum/bug-reports/httpauth-challenge-http-headers-bug/ +- fixed error with {.load.} with size exceeding real size http://rejetto.com/forum/index.php?topic=12059.msg1062781#msg1062781 +- fixed template translation issues http://rejetto.com/forum/index.php?topic=11880.msg1062167#msg1062167 + VER 2.3k propaganda Bug fixes