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.5
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/LBxX

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: 54.234.65.78!




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

Hide forms for certain IP addresses

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.5
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/LBxX