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 - Mars

Pages: 1 2 3 4 5 ... 135
31
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 28, 2021, 05:43:39 PM »
Are there some per ip-specific measurements?

no

How to make global variable apply to only 1 ip? 

a variable is defined by its name which can include letters or numbers and preceded by # to become a global variable
just include %ip% in the name

{.set|#flag_%ip%| ....   .}

global variables only exist while hfs is running


32
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 13, 2021, 11:41:19 AM »
you must analyze the url which is sent by the path variable and check its validity by eliminating the non-existent parts or use a fallback url like the use with newurl in the following

[not found]
{set|newurl|/.}
{.add header|Cache-Control: no-cache, max-age=0.}
{.redirect|/~404?path={.if|{.exists|%url%.}|{:{.encodeuri|{.filepath|%url%.}.}:}|{:{.^newurl.}:}.}.}

the problem is that in section 404, the url is not that of the containing directory but that of the requested file "return to previous page" does not correspond to% url% as for [max contemp downloads]

use macro {. add to log | ..what you need to see.. .} in various places to control the transmitted data and more easily determine why you are having inconsistencies in the operation of your scripts

33
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 05, 2021, 08:42:24 PM »
{.set | #frompath | %encoded-folder%.} cannot work because [max contemp downloads] is served as a new page from root and at this point the session is no longer the original page then %encoded- folder% returns / because some %var% are not defined, on the other hand I came across %url% which is the link of the loaded file that allows to deduce the original path

you can either use a global variable but which risks being changed by another user in the same situation or an url variable which will be valid only for the right recipient

Code: [Select]
[max contemp downloads]
{.add header|Cache-Control: no-cache, max-age=0.}
{.set|#frompath|{.encodeuri|%url%.}.}
{.redirect|/~server%20is%20busy?path={.encodeuri|{.filepath|%url%.}.}.}

[server is busy|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="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>

34
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 05, 2021, 01:46:53 PM »
is this correct?   {.set|%encoded-folder%|#frompath.}

always  set | #variable | value

this variable will be initiated for all connections, if you plan to use it in an event, you should associate the ip and the name of the user to it in order to target the event

{.set|#frompath|%encoded-folder%;%ip%;%user%;.}

and separate the different fields in the event zone or the section considered
it may seem like a long process, but there is no simplified macro to do this kind of manipulation

this is an example you can verify in menu  > debug > run script

Quote
{.set|#frompath|http://127.0.0.1/test;127.0.0.255;MyName;Private message to the user;/set.}
Start = "{.^#frompath.}"

{.comment|Use script only frome here.}

{.set|frompath|{.substring||;|{.^#frompath.}/substring.}/set.}
frompath = "{.^frompath.}"

{.set|#frompath|{.replace|{.^frompath.};||{.^#frompath.}/replace.}/set.}
{.set|ip|{.substring||;|{.^#frompath.}/substring.}/set.}
ip = "{.^ip.}"

{.set|#frompath|{.replace|{.^ip.};||{.^#frompath.}/replace.}/set.}
{.set|user|{.substring||;|{.^#frompath.}/substring.}/set.}
user = "{.^user.}"

{.set|#frompath|{.replace|{.^user.};||{.^#frompath.}/replace.}/set.}
{.set|reply|{.substring||;|{.^#frompath.}/substring.}/set.}
reply = "{.^reply.}"

{.set|#frompath|{.replace|{.^reply.};||{.^#frompath.}/replace.}/set.}
Final = "{.^#frompath.}"

result give
 
Quote
Start = "http://127.0.0.1/test;127.0.0.255;MyName;Private message to the user;"

frompath = "http://127.0.0.1/test"
ip = "127.0.0.255"
user = "MyName"
reply = "Private message to the user"

Final = ""

everything is based only on the manipulation of the chains

another form of use if the number of elements is not known in advance

Quote
{.set|sep|;.}
{.set|#frompath|http://127.0.0.1/test{.^sep.}127.0.0.255{.^sep.}MyName{.^sep.}Private message to the user{.^sep.}/set.}

Start = "{.^#frompath.}"
{.set|tot|{.count substring|{.^sep.}|{.^#frompath.}.}/set.}
{.set|#nb|{.^tot.}.}

{.while| #nb | {:
{.set|tab[{.^#nb.}]|{.substring||{.^sep.}|{.^#frompath.}/substring.}/set.} {.set|#frompath|{.replace|{.^tab[{.^#nb.}].}{.^sep.}||{.^#frompath.}/replace.}/set.} {.dec|#nb.}
:}/while.}
total items = {.^tot.}
{.for|x|{.^tot.}|1|-1|{:
tab[{.^x.}] = {.^tab[{.^x.}].}:}/for.}

Quote
Start = "http://127.0.0.1/test;127.0.0.255;MyName;Private message to the user;"
 
total items = 4

tab[4] = http://127.0.0.1/test
tab[3] = 127.0.0.255
tab[2] = MyName
tab[1] = Private message to the user

or to have it in the real order

Quote
{.set|sep|;.}
{.set|#frompath|http://127.0.0.1/test{.^sep.}127.0.0.255{.^sep.}MyName{.^sep.}Private message to the user{.^sep.}/set.}
Start = "{.^#frompath.}"
{.set|tot|{.count substring|{.^sep.}|{.^#frompath.}.}/set.}
{.set|#nb|{.^tot.}.}
{.while| #nb | {:
{.set|idx|{.calc|{.^tot.}-{.^#nb.}+1.}/set.}
{.set|tab[{.^idx.}]|{.substring||{.^sep.}|{.^#frompath.}/substring.}/set.}
{.set|#frompath|{.replace|{.^tab[{.^idx.}].}{.^sep.}||{.^#frompath.}/replace.}/set.}
{.dec|#nb.}
:}/while.}
total items = {.^tot.}
{.for|x|1|{.^tot.}|{:
tab[{.^x.}] = {.^tab[{.^x.}].}:}/for.}

Quote
Start = "http://127.0.0.1/test;127.0.0.255;MyName;Private message to the user;"

total items = 4

tab[1] = http://127.0.0.1/test
tab[2] = 127.0.0.255
tab[3] = MyName
tab[4] = Private message to the user
tab [ x ] is not a real array but a series of variables with different names "tab" + "[" + x + "]"

35
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: April 03, 2021, 01:40:03 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, I don't know more, on the other hand there is an event [download] but I don't know how to manage it
you have to look at the list of working variables even if it means creating variables {.set | # var1.} in the sections of the template to reuse them in the event as {. ^ var1.}

36
Everything else / Re: permission
« on: March 30, 2021, 11:05:09 AM »
Thanks Mars! 

Good to know that the feature was already built-in.

This is what happens when we skip school during basic HFS lessons, we don't know how it works,
the next time you start again you will be deprived of dessert for 1 week  ;D ;D

37
Everything else / Re: permission
« on: March 28, 2021, 08:56:09 PM »
Forget what Danny says,

 it's not the right way to always want to put everything in the template or in events or to use javascript,

 hfs already has a large amount of technical possibilities to satisfy a lot of situations

1) your folder must first be added to VFS as real folder

2) right click on it to access its properties on the "FLAGS" tab

3) check browsable and no download

4) go to the "PERMISSIONS" tab? then the "UPLOAD" sub-tab and check Anyone if you accept that anyone can upload a file in the directory, otherwise check "Any account" if you want only logged in people to be able to uplode

5) to allow you to keep management access, go to the "DELETE" sub-tab and check your username, this will give you additional command buttons on the web page

as it is, the contents of the directory will be visible to any user, this amounts to the same if in the "ACCESS" sub-tab is checked "Anayone", otherwise in this tab by checking "Any account", only authenticated users will be able to see it. the contents

38
Bug reports / Re: user account login
« on: March 25, 2021, 09:40:23 PM »
this behavior is completely normal, everything is accessible as long as no protection policy is in place,

unless you really want to share sensitive data with the rest of the world, it is unconscious to open an external port without having first set up a minimum of security

start by creating a personal user account and protecting each element of the VFS tree structure,

depending on the listening port used or all of them, you can test the web content using the address 127.0.0.1 in the browser on the pc, or its ip address on the local network,

to connect to the internet address, it is necessary to use another provider

these links do not reflect all the possibilities and latest version of hfs, but it can help to start your server

http://rejetto.com/wiki/index.php?title=First_time_configuration

http://rejetto.com/forum/index.php?topic=1939.0

39
Programmers corner / Re: Template/events for QOS or traffic shaping.
« on: March 23, 2021, 01:17:45 PM »
whether it is possible to perform a comparison test without going through a macro as it
{.if|{.8000 > 7500.}|{: busy :}|{: archive :}.}

it is strongly preferable to place the equivalent macro as a precautionary measure
{.if|{.>|8000|7500.}|{: busy :}|{: archive :}.}

this allows you to acquire good habits and write functional code,  HFS does not support direct literal numerical calculations as javascript

{.%number-addresses-downloading%*%speed-out% > 7500.} is bad

{.>|{.calc|%number-addresses-downloading%*%speed-out%.}|7500.} is correct


{.256*3 < 10 .} is similar to "256*3" < "10"  as  strings comparaison

you can test this in menu>>debug>run script

{.if|{. 25.6*2 < 100.}|true|false.} ->>   "25.6*2"  > "100"   >:(

{.if|{. {.calc|25.6*2.} < 100.}|true|false.}  ->>  56.2 < 100   ;D




40
Bug reports / Re: Robots are scanning my HFS server
« on: March 21, 2021, 11:47:59 PM »
add it as attached file on root, and change its properties to hidden
 (click droit sur route +add file , ou saisir le fichier et le faire glisser sur l'icone de la racine)

un repertoire virtuel n'a pas d'existence physique mais un fichier dans le vfs est comme un raccourci pointant  vers le fichier du disque dur, ca permet de "masquer à l'utilisateur l'emplacement réel du fichier

ne jamais placer un fichier dans le vfs dans un répertoire réel (icone rouge) s'il y a un risque que le même nom de  fichier existe physiquement dans le répertoire



41
HFS ~ HTTP File Server / Re: Running HFS Behind A VPN
« on: March 20, 2021, 03:03:56 AM »
Several situations can approach the solution

How to: Accessing Local Network Resources While Using VPN
https://community.spiceworks.com/how_to/113798-accessing-local-network-resources-while-using-vpn

https://windowsreport.com/vpn-split-tunneling-windows-10/

https://superuser.com/questions/166555/how-to-use-one-connection-to-the-internet-for-vpn-and-another-for-accessing-othe
Quote
Follow these steps to set up a VPN connection in Windows Vista that uses split tunneling:

    From the Control Panel, choose "Network & Internet."
    Click "View Network Status and Tasks."
    Click "Manage Network Connections."
    Right-click on your VPN connection and select "Properties."
    Select the "Networking" tab.
    Highlight "Internet Protocol Version 4 (TCP/IP v4)."
    Click "Properties."
    Click "Advanced."
    Uncheck the "Use default gateway on remote network" box.
    Click "OK" three times to close the windows you opened.

From that point forward, only traffic destined for your corporate network will be sent through the VPN. All other traffic will use the local network.

https://apple.stackexchange.com/questions/134766/using-vpn-and-wifi-at-the-same-time
Quote
In Network preferences, choose your primary interface, and hit Advanced.... For me, this was wi-fi, but the same thing should work for ethernet, etc. Whatever you normally use to connect to the internet

In the DNS tab (where you may already have entries), add the VPN DNS. Also make sure that your main DNS(s) are there. Then, add the VPN domain into the search domains box.

Example:

VPN settings http://elibaum.com/img/Screen%20Shot%202014-06-18%20at%2021.18.22.png

Here, 10.0.1.1 is my home wifi router, which in turn routes to my ISP's DNS servers. 10.8.1.22 is the local DNS server on the VPN.

So, if I request www.google.com, the request is sent to my router, whether or not I am on VPN.
However, if I request server while on the VPN, the primary DNS fails, and moves on to the next nameserver. However, since this nameserver (10.8.1.22 in my case) is on the VPN's subnet, traffic is automagically routed to the VPN. The search domain field example.com transforms server into server.example.com, and the DNS lookup succeeds.

Important Note: this workaround requires that your primary DNS fails on non-existent domains — that is, your ISP is not doing DNS hijacking. If they are, switch to OpenDNS, Google Public DNS, etc. Also see my related question: https://superuser.com/questions/766713/what-is-67-63-55-3 in which I sorted out DNS hijacking in relation to this problem.

Is this enough to allow hfs to be visible from the internet through the local router, that remains to be seen

it is possible to assign several ip to the network card of a PC, is one of them able to override the VPN, it remains to be tried

42
HFS ~ HTTP File Server / Re: Running HFS Behind A VPN
« on: March 18, 2021, 01:26:13 AM »
When you are connected to a VPN, your machine is no longer visible on your local network,

for hfs to be visible on the web again, the remote user would need to connect to the VPN provider's IP address and activate a port forwarded to your machine, this is a situation that does not seem to have a solution,

 the VPN should only affect your browser, other programs using your router directly

43
HTML & templates / Re: How can I implement thing on image attached?
« on: March 16, 2021, 09:02:57 PM »
the section [file=folder=link|private]  containt the division of column name

use the totality of this text as a starting point to put in the diff template properties , instead of what you put there previously

Quote
[file=folder=link|private]
<div class='item item-type-%item-type% {.if|{.get|can access.}||cannot-access.} {.if|{.get|can archive item.}|can-archive.}'>
   <div class="item-link">
      <a href="%item-url%">
         <img src="%item-icon%" />
         %item-name%
      </a>
      {.if|{.=|%item-type%|folder.}|{:[<a href="http://example.site/view-2.php?name={.encode html|%item-name%.}"> Info </a>]:}.}
   </div>
   <div class='item-props'>
      <span class="item-ts"><i class='fa fa-clock-o'></i></span>

[+file]
      <span class="item-size"><i class='fa fa-download' title="{.!Download counter:.} %item-dl-count%"></i> %item-size%B</span>
[+file=folder=link]
      {.if|{.get|is new.}|<i class='fa fa-star' title="{.!NEW.}"></i>.}
[+file=folder]
        <button class='item-menu pure-button' title="More options"><i class="fa fa-bars"></i></button>
[+file=folder=link]
    </div>
   <div class='clearer'></div>
[+file=folder=link]
    {.if| {.length|{.?search.}.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
   {.123 if 2|<div class='comment'><i class="fa fa-quote-left"></i><span class="comment-text">|{.commentNL|%item-comment%.}|</span></div>.}
</div>



44
HTML & templates / Re: How can I implement thing on image attached?
« on: March 15, 2021, 02:08:44 PM »
use  %item-name% and update the value  using some macros replace, substring, cut , trim .. to include the result in the url link
http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands



45
@Rom_1983

dans le but de solutionner ton problème pour générer les raccourcis à publier sur le web

dans le template repère ces deux lignes

[+file]
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%


et juste avant ajoutes ceci

[+file]
{.if|{.=|%user%|myident.}|{:<br>
{.replace|%host%|www.mondomaine.com|{.replace|/_private_admin/|/|%item-full-url%.}.}
:}.}


prend soin de remplacer myident par le nom du compte admin sous lequel tu te logues,
ainsi que www.mondomaine.com par ton nom de domaine externe

ceci te mettra le lien à diffuser que t'auras juste à copier

dans cette configuration , ce sont toutes les dossiers  qui sont impactés,  mais si tu souhaites que ce ne soit valable que pour certaines pages, il faut utiliser  la propriété "diff template" du dossier _private_admin dans le vfs

on conserve le même principe que précédemment mais en changeant le nom de la section utilisée, par exemple

[link_private_public]
{.if|{.=|%user%|myident.}|{:<br>
{.replace|%host%|www.mondomaine.com|{.replace|/_private_admin/|/|%item-full-url%.}.}
:}.}


et dans le template principal il faudra mettre en conservant cet ordre


[+file]
{.$link_private_public.}

[+file]
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%


il faut garder à l'esprit que l'ajout de sections dans des diff tpl est soumis à une règle de parent-enfant et que l'utilisation de
[+file] dans le tpl aurait placé le résultat au mauvais endroit sur l'affichage web


dans la mesure ou cette approche permet seulement de créer le texte nécessaire qui peut prendre de la place à l'écran, il est tout à fait possible de le remplacer par un bouton qui générera le lien dans le presse-papier avec un message de validation au besoin
https://www.30secondsofcode.org/blog/s/copy-text-to-clipboard-with-javascript/
mais cette démarche dépasse mes possibilités et te laisse le soin d'évoluer ou non dans cette perspective.

Pages: 1 2 3 4 5 ... 135