Hide forms for certain IP addresses

  Previous article Next article  

Hide forms for certain IP addresses

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 30-05-2015
  Comments: 7

Hide website forms for certain IP addresses (partial banning)

Create a new User Defined Tag, named "form_ip_filter"

form_ip_filter
$banned_IPs = array(
  "123.123.000.000",
  "127.0.0.1"
);

if(in_array($_SERVER['REMOTE_ADDR'], $banned_IPs))
  $smarty->assign('ipbanned', 'true');

Fill the UDT with the IP addresses of the people you don't want to show the forms.

  How to use

Hide contact form
{form_ip_filter}

{if empty($ipbanned) || $ipbanned != 'true'}
     {FormBuilder form='contact'}
{/if}
Hide guestbook form, but show recieved messages
{form_ip_filter}

{if empty($ipbanned) || $ipbanned != 'true'}
     {Gbook action='form'}
{/if}

{Gbook}

  Working example

You wonder if it works? Add your own IP address in the list of addresses: 107.22.61.174!


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  7 Comments

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Hide forms for certain IP addresses

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 30-05-2015
  Comments: 7

A2 Webhosting CMS Made Simple