rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: Age on November 30, 2009, 11:13:14 PM

Title: Ban Unless User
Post by: Age on November 30, 2009, 11:13:14 PM
Hello, I was wondering how I might go about this if it's even possible.

I have setup a "ban" with reverse logic:

\132.*.*.*

So anyone who does not have a 132.x.x.x IP address is banned/blocked from accessing the server.  Is there anyway to override this block if I have a user account?

Basically, I want anyone who has a 132 IP or a user account to be able to access the server, but not the general public.  While there isn't a "Login" feature on the "You are currently banned" page in the default template, even after logging in, without having a 132 IP, I'm still not able to access it.

Thanks for any advice/input?  Thanks.
Title: Re: Ban Unless User
Post by: bacter on December 01, 2009, 12:53:07 AM
if you ban a range of ip's, you ban them! no matter who's behind an ip.

With the beta version of hfs and using macros, you can make a welcomepage that shows up if %folder% = /.
In this welcomepage, you set links to login and, if allowed ip, to next folder.

Also at beginning of your template, you set conditions:
if the folder is not /  or no %user% is logged in, then disconnect that request.
Title: Re: Ban Unless User
Post by: rejetto on December 01, 2009, 01:16:13 AM
as bacter says.
something like this event handler (ALT+F6)

[request]
{.if
|{.and|{.%folder% != /.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
|{:{.disconnection reason|i'm sorry.}:}
.}
Title: Re: Ban Unless User
Post by: Age on February 28, 2010, 10:00:37 PM
This is great guys, thanks a lot.

Also, do you know how I could go about allowing users to log-in on the Unallowed page?
Title: Re: Ban Unless User
Post by: rejetto on February 28, 2010, 10:53:40 PM
ok i applied the fix in my own post

Also, do you know how I could go about allowing users to log-in on the Unallowed page?

put a link like this
<a href="~login">please login</a>
Title: Re: Ban Unless User
Post by: Age on February 28, 2010, 11:16:11 PM
put a link like this
<a href="~login">please login</a>

Normally you'd think that would work, except that it would seem that the same rules that are preventing non-users/non-132.x.x.x IPs from having access, also prevents them from accessing the login page.

Is there anyway to prevent all folder access except ~login ?
Title: Re: Ban Unless User
Post by: rejetto on February 28, 2010, 11:34:53 PM
use this line (untested)

|{.and|{.%folder% != /.}|{.not|{.match|*/~login|%folder%.}.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
Title: Re: Ban Unless User
Post by: Age on March 01, 2010, 12:54:01 AM
use this line (untested)

|{.and|{.%folder% != /.}|{.not|{.match|*/~login|%folder%.}.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}

Alright, so I've been fiddling around. Using this:

[request]
{.if
|{.and|{.%folder% != /.}|{.not|{.match|*/~login|%folder%.}.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
|{:{.disconnection reason|i'm sorry <a href="~login">please login</a>.}:}
.}

When I visit the server externally from a 132 IP it lets me in fine, so that's good. Also, when I login at that point, then go to http://localhost (to pretend that I'm not on a 132 IP) I am able to get in fine because I'm logged in already. Great. Perfect, that works.

But when I visit from a non-132 IP while not logged in, I continue to get the Unallowed page, even when going to http://localhost/~login in order to login.
Title: Re: Ban Unless User
Post by: rejetto on March 01, 2010, 01:31:50 AM
what's this "unallowed" page?
maybe you set a ban rule.
you should remove it.
Title: Re: Ban Unless User
Post by: Age on March 01, 2010, 02:18:01 AM
what's this "unallowed" page?
maybe you set a ban rule.
you should remove it.

Sorry, I don't think I explained that correctly. There aren't any ban rules.
|{:{.disconnection reason|i'm sorry.}:} appears to trigger the [deny] section of the template, which by default says "Unallowed."

Basically,
|{.and|{.%folder% != /.}|{.not|{.match|*/~login|%folder%.}.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
still doesn't allow users to login if they're not on a 132 IP. I'll keep fiddling and re-read the wiki, thanks for your continued guidance. I'll post findings for people looking at this in the future.
Title: Re: Ban Unless User
Post by: rejetto on March 01, 2010, 10:32:42 AM
there's an error indeed:
try this:

|{.and|{.%folder% != /.}|{.match|\*/~login|%url%.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
Title: Re: Ban Unless User
Post by: Age on March 01, 2010, 09:15:29 PM
rejetto you're amazing. Thank you so much.

To summarize:

My goal was to deny access to everyone except for those who a)Have a username and password or b)Are using IP addresses that begin with 132.
The problem was that the login page was being blocked from letting users who did not have a 132.x.x.x IP address from logging in.
The solution (thanks to rejetto) was to use the beta, press ALT-F6 to get into events and then paste this into it:

[request]
{.if
|{.and|{.%folder% != /.}|{.match|\*/~login|%url%.}|{.not|%user%.}|{.match address|\132.*|%ip%.}/and.}
|{:{.disconnection reason|You're either not logged in as a user or not on a 132.x.x.x IP address. <a href="~login">Please Login</a>.}:}
.}

Thanks again rejetto.
Title: Re: Ban Unless User
Post by: KooolaNL on March 18, 2010, 07:25:08 PM
i thought i reply here

i have kooola.nl/pic and kooola.nl/crap

i want a use 2 disconnect when he tries  kooola.nl/pic and kooola.nl/crap  without being logged in

what kinda line do i have 2 add where :3

thx in advance
Title: Re: Ban Unless User
Post by: rejetto on March 18, 2010, 07:28:42 PM
right click on the folders > properties > permissions > any account
Title: Re: Ban Unless User
Post by: KooolaNL on March 18, 2010, 10:05:16 PM
when i do that can ppl olso not see kooola.nl/pic/photo.jpg because i only want ppl to not be able 2 browse the root of /pic/ get what i mean  :-*

i want everyone 2 see kooola.nl/pic/photo.jpg  but i want then to get a error message saying not logged in when they wanne inspect the root of /pic/

plz
Title: Re: Ban Unless User
Post by: KooolaNL on March 19, 2010, 08:06:06 AM
if i embed a pic from /pic/   on  http://kooola.nl it ask for login but i only wanne trigger a login when ppl use /pic/

:)
Title: Re: Ban Unless User
Post by: rejetto on March 19, 2010, 10:18:23 AM
right click on the folder > properties > flags > browsable

uncheck it
Title: Re: Ban Unless User
Post by: KooolaNL on March 19, 2010, 10:21:04 PM
will only non logged in persons be able to NOT see it and logged in ppl DO see it ?


because i want able 2 watch /pic/ when i am logged in :)
Title: Re: Ban Unless User
Post by: rejetto on March 20, 2010, 02:02:25 PM
ok, try this (untested)
right click on the folder > properties > diff template
put this text:

{.if|%user%|{:{.section||back=1.}:}|{:{.disconnection reason|sorry.}:}.}
Title: Re: Ban Unless User
Post by: KooolaNL on March 20, 2010, 02:08:50 PM
hey super the /pic/wat.jpeg on my main site can still be viewed when not logged in and when i do

/pic/ without being logged in it says Unallowed works

last thing can i change the Unallowed tekst to something else maybe ?

i am annoying sorry
Title: Re: Ban Unless User
Post by: rejetto on March 20, 2010, 04:52:21 PM
sure you can