rejetto forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - danny

Pages: 1 2 3 4 5 ... 15
31
HTML & templates / Re: Responsive small screen template
« on: April 15, 2021, 01:32:54 AM »
Does javascript have a case-blind option, or does it need something like this?:
Code: [Select]
var ext='a[href$=".mp3"],a[href$=".Mp3"],a[href$=".MP3"],a[href$=".ogg"],a[href$=".OGG"],a[href$=".m4a"],a[href$=".M4A"],a[href$=".flac"],a[href$=".FLAC"],a[href$=".wma"],a[href$=".WMA"],a[href$=".aac"],a[href$=".AAC"],a[href$=".mp4"],a[href$=".MP4"]'  //edit here

32
Bug reports / back to 2.3
« on: April 15, 2021, 01:11:09 AM »
... revert from 2.4 back to 2.3...
The Virtual File System, VFS, may need to be renewed/replaced. 

For my testing purposes, I had to put HFS2.3 and HFS2.4RC into 2 different folders so as to prevent VFS trouble. 

These may help: 
HFS > Menu > Clear file system
HFS > Menu > Save options > Clear options and quit
Also, right click house icon, bind root to real folder (your new empty folder) and then don't add any virtual folders (use only real folders).

P.S.
I also reverted to HFS2.3, because HFS2.4RC does "please wait server busy" too much (can't adjust?).

33
HTML & templates / Re: Stripes, the template for simple and easy
« on: April 13, 2021, 06:57:13 PM »
hi my version is now corrected and upddated looks smooth
I like the classic color scheme, like Throwback4.  Instead of "!! Connection Established !!" you could try a purpose declaration, such as "this is a file server" or "files for download" so that users can know how to use the site.  It is good to highlight the file list by making its background different than main background. 

34
Programmers corner / Halp! missed the target for the 404
« on: April 13, 2021, 08:59:01 AM »
@Mars, I need some help with macro string processing to hit target of 1 folder higher, because some other use may have already deleted that folder...
Code: [Select]
[not found]
{.add header|Cache-Control: no-cache, max-age=0.}{.redirect|/~404?path={.encodeuri|{.filepath|%url%.}.}.}
[404|public]
{.set|backpath|{.decodeuri|{.urlvar|path.}.}.}<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<META HTTP-EQUIV="Refresh" CONTENT="1;URL={.^backpath.}"><TITLE>404</TITLE><link rel="icon" href="data:,"></head><body><center><h2><br>Not Found.</h2>Returning to previous page...</center></body></html>
If that had been entirely macro, it would be deadlock-loop. 
Problem is, wrong target for 404 (if missing), because the need is parent of, aka 1 folder higher than that.  Halp!


35
HTML & templates / Re: Stripes, the template for simple and easy
« on: April 12, 2021, 05:20:09 PM »
ive heavyilly modified my version from you with colorings etc could you give me the line the code is on thanks
not a particular line, because it is modular. 
however, find </tr></table>
replace with </tr></table><a href="/~login" style="float:left"><font size=2>&#128100; log-in/out</font></a>

P.S.
you can share your version here too

36
compact lazyload script
Code: [Select]
<script>document.addEventListener("DOMContentLoaded",function(){var e,t;"IntersectionObserver"in window?(e=document.querySelectorAll(".lazy"),t=new IntersectionObserver(function(e,n){e.forEach(function(n){n.isIntersecting&&setTimeout(()=>{var e=n.target;e.src=e.dataset.src,e.classList.remove("lazy"),t.unobserve(e)},181)})}),e.forEach(function(e){t.observe(e)})):alert("Your browser needs an update")});</script>has 181ms delay in-between photos so that the server has some time to perform other tasks or serve multiple users 

The new version of Takeback seems to spend more time with macros; maybe there are some tasks that can be done with javascript (many client CPUs) instead of macro (one server CPU)? 

37
RAWR-Designs / Re: cant install theme on 2.4.0 RC 6
« on: April 11, 2021, 06:09:08 AM »
Replace/Add/Update these [sections]
Code: [Select]
[api level]
999

[error-page]
%content%
[overload]
{.if|{.{.calc|{.get ini|max-connections.}.}<>0.}|{:{.set ini|max-connections=-1.}:}.}{.disconnect.}{.add to log|%ip% %user% disconnected at %connections% connections.}

[max contemp downloads]
{.add header|Cache-Control: no-cache, max-age=0.}{.redirect|/~server%20is%20busy?path={.encodeuri|{.filepath|%url%.}.}.}
[server is busy|public]
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<META HTTP-EQUIV="Refresh" CONTENT="3;URL={.decodeuri|{.urlvar|path.}.}"><TITLE>Busy</TITLE><link rel="icon" href="data:,"></head>
<body bgcolor="#EDF0F9"><center><h2><br>Server is busy.</h2>Returning to previous page...</center></body></html>

[not found]
{.if|{.match|*.php*;*.js;*.py;*.vbs*;*.exe|%url%.}|{:{.disconnect.}:}.}{.add header|Cache-Control: no-cache, max-age=0.}<!DOCTYPE html><html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<META HTTP-EQUIV="Refresh" CONTENT="1;URL=../"><TITLE>404</TITLE><link rel="icon" href="data:,"></head>
<body bgcolor="#EDF0F9"><center><h2><br>You have found the 404 page.</h2></center></body></html>

[unauth]
{.redirect|/~login.}

[deny]
{.disconnection reason|NO.}

[ban]
{.disconnect.}

[ajax.changepwd|public|no log]
{.check session.}
{.break|if={.not|{.can change pwd.}.} |result={.!Forbidden.} (0).}
{.if|{.length|{.set account||password={.postvar|new.}.}/length.}|{.!OK.} (1)|{.!Failed.} (2).}

[login|public]
{.if|{.match|*.php*;*.js;*.py;*.vbs*;*.exe|%url%.}|{:{.disconnect.}:}.}{.add header|Cache-Control: no-cache, max-age=0.}<!DOCTYPE html><html lang="en"><head><meta charset=UTF-8 /><meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv=CACHE-CONTROL content=no-cache><title>HFS %version%</title><link rel="icon" href="data:,"></head>
<body bgcolor="black" text="white" alink="white" link="white" vlink="white">
<font size=4><center><br><br><br>
    <form method='post' onsubmit='return login()' >  <!-- return true   / -->
      <table border="0" cellspacing="20">
      <tr><td align='right'><label for="user">{.!Username.}</label><td><input name='user' size='25' required placeholder="%user%" id='user' />
      <tr ><td align='right'><label for="pw">{.!Password.}</label><td><input name='password' size='25' type='password' required id='pw' />
      <tr ><td><td><input type='submit' value='{.!Login.}' style='margin-top:13px'>
      </table>
    </form>
<font size="2">Keep me logged-in<input type="checkbox"></font><br><br>
<button onclick="var tmp=prompt('new password'); if(tmp) {var fd=new FormData();fd.append('new',tmp);fd.append('token','{.cookie|HFS_SID_.}');fetch('/~ajax.changepwd',{method:'POST',body:fd})}" hidden>{.!Change password.}</button>
<br><br>
</center>
<script>
const loc={}; loc.Logout='{.!Logout.}'  /*translate here*/
var sha256 = function(s) {return SHA256.hash(s)}
function logout() {fetch("/?mode=logout").then(res => location.reload()); return false;}
function login() {
    var sid = "{.cookie|HFS_SID_.}"  //getCookie('HFS_SID');
    if (!sid) return true;  //let the form act normally
    var usr = user.value;
    var pwd = pw.value;
var xhr = new XMLHttpRequest();
xhr.open("POST", "/?mode=login");  // /~login
var formData = new FormData();
formData.append("user",usr)
if (typeof SHA256 != 'undefined') formData.append("passwordSHA256",sha256(sha256(pwd).toLowerCase()+sid).toLowerCase()); else formData.append("password",pwd)
xhr.onload=function(){if(xhr.response=='ok') {
 if(document.querySelector("input[type=checkbox]").checked) localStorage.login=JSON.stringify([usr,pwd]); else localStorage.removeItem('login');
 location.replace(document.referrer)} else {alert("user or password don't match");document.querySelector("form").reset();location.reload(true)}}
xhr.send(formData)
    return false;
}
if(localStorage.login) document.querySelector("input[type=checkbox]").checked=true  //stop keep logged-in: call /~login and disable "Keep me logged-in"
document.querySelector("input[type=checkbox]").onchange=function(){if(!this.checked) localStorage.removeItem('login')}
if('%user%') {document.querySelector("input[type=submit]").value=loc.Logout; document.querySelector("input[type=submit]").onclick=function(){logout(); return false}; document.querySelector('button').hidden=false}
if(!'%user%' && localStorage.login) {
var tmp=JSON.parse(localStorage.login)
user.value=tmp[0]
pw.value=tmp[1]
var myform=document.querySelector("form"); if (myform.requestSubmit) myform.requestSubmit(); else myForm.submit()
} </script> <script src="/~sha256.js" onerror="setTimeout(()=> this.src='/~sha256.js',181)"></script>
Also update the target of [login-link] to href="/~login"

P.S. 
There are also '2.4-Ready' versions of Takeback, Throwback, Mobil-Light, Stripes, White, etc...
See also:  http://rejetto.com/forum/index.php?topic=13326.0

38
HFS ~ HTTP File Server / Re: "max connections"
« on: April 10, 2021, 12:08:58 PM »
To avoid 'right click save as corrupt file' a redirect is needed; however, can't redirect from [overload] when already past the limit; therefore, must use disconnect to defeat the masquerade. 
Solution:   
Code: [Select]
[overload]
{.if|{.{.calc|{.get ini|max-connections.}.}<>0.}|{:{.set ini|max-connections=-1.}:}.}{.disconnect.}{.add to log|%ip% %user% disconnected at %connections% connections.}
Global max connections limit = ddos so that is unset; and then, the remaining possibility is per-ip connections limit which is repurposed as a miscreant disconnector+logger. 

39
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 08, 2021, 02:59:25 PM »
Is it possible to do something like?:
{.if|{.current connections|ip=%ip%.} > 9.}|{: busy excuse + animated recheck :}|{: do file list :}.}

Edit:  The flaw with {.if|{.%connections% > 39.}|{: busy excuse + javascript recheck timer :}|{: do file list :}.} is DDOS, because 1 abuser can hinder All users.  However, instead of global connections, if it were changed to connections-per-ip then the flaw is gone.

40
Beta / 2 login targets
« on: April 08, 2021, 10:49:30 AM »
How do I alter this form to:  refresh same page if url is not /~login? 

Edit; answer was:
Code: [Select]
location.replace({.if|{.match|*~login|%url%.}|{:document.referrer:}|{:"%encoded-folder%":}.})

41
Kudos to Mars for the new [max contemp downloads] (hfs > menu > limits > simultaneous downloads) redirection macro scripts; so it is sure to serve up valid files.  The most useful HFS limits setting is:  Max simultaneous downloads from single address.  Try it at 2.

Kudos to NaitLee for the new [not found] redirection macro scripts; so it is sure to serve up valid files (especially, right-click+save-as).

The update was 'under the hood'--it looks the same to users. 

42
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 06, 2021, 10:22:47 PM »
... I came across %url% which is the link of the loaded file that allows to deduce the original path
Thanks!!!  That works very well for the [max contemp downloads] section.


I found out that the approach doesn't apply to [overload] section because can't redirect when beyond the set connections limit.   
So, here is the other option for preventing right click + save as corrupt file (if connections limits are used): 
Code: [Select]
[overload]
{.if|{.{.calc|{.get ini|max-connections.}.}<>0.}|{:{.set ini|max-connections=-1.}:}.}{.disconnect.}{.add to log|%ip% %user% disconnected at %connections% connections.}
I've axed the Max connections limit so that 1 abuser can't knock out All users.  And, then the remaining possibility is that an individual went over Max connections from single address limit, got disconnected and then their ip got logged.   No corrupt downloads. 


Edit:  Can test-drive with the latest Stripes template. 

43
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 05, 2021, 03:43:59 PM »
The idea goes something like this:

[max contemp downloads]
{.add header|Cache-Control: no-cache, max-age=0.}{.set|#frompath|%encoded-folder%.}{.redirect|/~server%20is%20busy.}

[server is busy|public]
{.set|backpath|{.^#frompath.}.}<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<META HTTP-EQUIV="Refresh" CONTENT="3;URL={.^backpath.}"><TITLE>Busy</TITLE><link rel="icon" href="data:,"></head><body bgcolor="black" text="white" alink="white" link="white" vlink="white"><center><h2><br>Server is busy.</h2>Returning to previous page...</center></body></html>

Doesn't work as expected, because the url is only /

44
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 04, 2021, 11:19:43 PM »
under normal conditions if a download is interrupted the server sends the client a response with Not served: 503 - Overload, this is what should be reproduced instead of performing a sudden disconnection, perhaps a special section with a macro add header...
Some unexpected results:
Attempts to send those types of headers goes to Status=thinking, unresponsive console ui, stuck. 
Problem:  header does not reach client
Exception:  sending a header that hfs and client don't recognize, reaches the client (but a meaningful header does not)



P.S.  For preventing the "corrupt file generator" effect, (right-click+save-as with download limit set), it looks like the redirect macro is a working solution, because it changes the saved filename to section name with .htm extension (a proper file albeit not the one you clicked).  This could provide better opportunity for downloading the correct file (instead of a corrupt file).   Also new custom section name can be a message [server is busy], which would then look like user tried to download "server is busy.htm".    Very clanky, but workable.   

...creating variables {.set | # var1.} in the sections of the template to reuse them in the event as {. ^ var1.}
For the error redirect macro, I need to set global-variable to %encoded-folder% (or url) Before to redirection to [server is busy].  I need it to remember the original location. 
is this correct?   {.set|%encoded-folder%|#frompath.}
Upon arrival at [server is busy] I need to copy the global variable to temporary/local variable (no#) instantly (so that other user probably doesn't change it).  What is the macro to copy #frompath to frompath variable? 
For that, should I use %encoded-folder% or %item-url% ?
At [server is busy] I intend to display a nice message and redirect-after-seconds to frompath variable so that the user is not on an island. 

45
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 03, 2021, 03:07:18 AM »
@Mars

Would also like to streamline error handler for sections [overload] and [max contemp downloads].

Currently, I have: 
Code: [Select]
[overload]
{.if not|%user%|{:{.if|{.%url% = /.}|{:{.disconnect.}:}.}:}.}{.add header|Cache-Control: no-cache, max-age=0.}<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><META HTTP-EQUIV="Refresh" CONTENT="3;URL=./"><TITLE>Overload</TITLE><link rel="icon" href="data:,"></head><body bgcolor="black" text="white" alink="white" link="white" vlink="white"><center><h2><br>High traffic mode engaged.</h2>Returning to previous page after overload has cleared.</center></body>{.disconnect|{.current downloads|ip|file=this.}.}{.if|{.{.current downloads|ip=%ip%|file=this.} > 1.} |{: {.disconnection reason|knackered.} :}/if.}

[max contemp downloads]
{.add header|Cache-Control: no-cache, max-age=0.}<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><META HTTP-EQUIV="Refresh" CONTENT="3;URL=./"><TITLE>Downloads</TITLE><link rel="icon" href="data:,"></head><body bgcolor="black" text="white" alink="white" link="white" vlink="white"><center><h2><br>There are ongoing downloads.</h2>More available <i>after</i> current downloads finish.</center></body>{.disconnect|{.current downloads|ip|file=this.}.}

This is bulky/verbose and partially successful.  Main trouble is when in overdo condition, file downloaded consists of error page internally.  It would be nice to Stop the download without filling the requested file internals with contents of error page. 
Causing the client to stop a download requires either server-side redirect or disconnect, macros.  So, these pages need to start with if download then disconnect; but, how to? 

Pages: 1 2 3 4 5 ... 15