Tempcode for templates/LOGIN_SCREEN.tpl

Post

Posted
Rating:
#3406 (In Topic #642)
Avatar
Standard member
Terry is in the usergroup ‘Well-settled’

Is there a way to redirect on-the-fly?

I'm working on templates/LOGIN_SCREEN.tpl

When the site is CLOSED, people have to register and login, in order to use the site. To do that, they first meet a screen that tells then they have to register, and they click OK to be forwarded to the login screen (LOGIN_SCREEN.tpl). On this closed-site welcome screen, I've removed the OK button and I've added 5 buttons of my own. Each button links to LOGIN_SCREEN.tpl, but also carries with it a unique number in the url (GET, POST methods). 

When LOGIN_SCREEN.tpl is loaded, I use…

Code

{+START,IF,{$EQ,{$_GET,my_value_variable},555}}

yes


{+END}

…to get the value of the passed variable. 

If the value of the passed variable is equal to 555, I want to redirect the page immediately to an off-site webpage. So as soon as they are sent to the login screen, if the passed variable is 555, I want the page to go to a different page without a link or anything. I can't find the Tempcode I'm looking for to do that. Anyone have any ideas?
 
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Adam)
#3408
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Right, so I think your problem is you can't put in your own <meta> redirect because Composr has it's own default redirect that works at the HTTP level (so sooner).

The login form actually supports a 'redirect' GET parameter. So just pass in like &redirect=http://... differently on each button.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3415
Avatar
Standard member
Terry is in the usergroup ‘Well-settled’
For banning an ip (not the member because they can simply create a new account), it's just a matter of adding an entry to cms_banned_ip...is that correct? 

If that's right, then on adding the ip to the database, should the ip be masked at that point (44.55.66.*), and then added?

for cms_banned_ip...

ip (varchar) is the masked ip?
i_ban_positive (tinyint) is a boolean for what purpose?
i_ban_until (int 10) is the unix format date to lift the ban...but will the system monitor this by itself and lift the ban by itself when the unix-time is met?
i_descrip (longtext) is just the description of the ban?

Is there any known Tempcode to ban an ip, or should I just create some php to do it as perhaps a miniblock, and then call the miniblock? ( I hope to put this all in LOGIN_SCREEN.tpl )



 
Online now: No Back to the top

Post

Posted
Rating:
#3426
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
For banning an ip (not the member because they can simply create a new account), it's just a matter of adding an entry to cms_banned_ip…is that correct?

Yes.
You but it is easier to do this:

Code

require_code('failure');
add_ip_ban('12.34.56.78');

should the ip be masked at that point (44.55.66.*), and then added?

Your choice.

p (varchar) is the masked ip?
i_ban_positive (tinyint) is a boolean for what purpose?
i_ban_until (int 10) is the unix format date to lift the ban…but will the system monitor this by itself and lift the ban by itself when the unix-time is met?
i_descrip (longtext) is just the description of the ban?

If i_ban_positive is zero then this is used internally to represent an IP that has been seen not to be banned by a RBL (DNS remote block list). i.e. we're using it internally as a cache value, as we only do RBL checks once per IP. It's only peripherally related to the IP banning you're thinking of.

Rest is correct.

Is there any known Tempcode to ban an ip, or should I just create some php to do it as perhaps a miniblock, and then call the miniblock? ( I hope to put this all in LOGIN_SCREEN.tpl )

Well, definitely not in Tempcode - as that's for display, not for backend actions.

You could put it in a miniblock code, although that's a bit hackerish.
If you're specifically trying to just target the login page, it is a clean enough solution regardless.

Depending on exactly what you're trying to do here, a startup hook may also be an option.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

Manu, MVLipwig, amit.nigam, ManojSree, gabriel58, mytracker

Forum statistics:
  • 1,298 topics, 5,830 posts, 7,065 members
  • Our newest member is raguragavan
Birthdays:
Back to Top