rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: Fenn on January 24, 2022, 10:22:52 AM

Title: Ways to trigger events at a specific file download/ request
Post by: Fenn on January 24, 2022, 10:22:52 AM
I'm trying to figure out a way to run a specific script by form of [request] or [download] but not any download or request but if a specific directory/ file is accessed.
i have looked though a bunch of threads and i could never find highly detailed information or a manual to use the hfs.events file
if anyone has done this please help
Thanks
Title: Re: Ways to trigger events at a specific file download/ request
Post by: rejetto on January 24, 2022, 04:48:21 PM
hi, and welcome!
the idea is that inside the [whatever] you can decide your action based on the url. For example

[request]
{.if|{.pos|/asd|%url%.}|{:{.disconnect.}:}.}



this disconnects, but you can do something else
Title: Re: Ways to trigger events at a specific file download/ request
Post by: Fenn on January 25, 2022, 12:54:48 PM
Thanks for the reply!
What i am trying to do is basically use HFS as a simple API.
what i am trying to do is send a request to a file through the link including arguments that my application is going to send.
which is going to run a php script that would send a message through a discord bot that would then display a users game status and his nickname
And i am wondering if that is possible to do using HFS since ive wanted to move over to a personal host instead amazon/ google hackery and paid services
Title: Re: Ways to trigger events at a specific file download/ request
Post by: rejetto on January 25, 2022, 02:33:05 PM
HFS doesn't support PHP.
Still you can use HFS to execute a file (with parameters) when a specific url is requested, by using the {.exec.} command.
Yet, this is hardly what HFS is designed for, so if that's your only goal you may find better solutions.
You can replace the disconnect command in my example with exec, that is documented here
https://rejetto.com/wiki/index.php/HFS:_scripting_commands#Others

hfs' scripting language is quite bad, but it's all you got on hfs :)
Title: Re: Ways to trigger events at a specific file download/ request
Post by: Fenn on January 25, 2022, 02:49:42 PM
Thanks ill look into that and probably try running another app alongside HFS if it doesnt work

since im already running a file server that lets the my app download things remotely
You can actually check it out using my ip. since i dont really want to reveal its domain link.
as far as i know its a read-only file server
Title: Re: Ways to trigger events at a specific file download/ request
Post by: rejetto on January 25, 2022, 04:01:49 PM
yes, i can see it running with your ip.
HFS is by default read-only.
There's no way for me to know that you didn't create an account that once logged in can upload or delete stuff, but I assume from your words that you didn't do it.

Be careful exposing your php files, or other files that may contain sensible informations.
A php file in HFS is just a text file where people can read your source.
You may expect that it is executed and only its output is visible, but that's not true in HFS (because it doesn't support PHP)