Hello,
is there a way to make my comment form show for certain IP Blocks? I have a list of IP adresses I would like to block from seeing my comment form. Would you have sample code.
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
May 05, 2009 5:44pm
Subscribe [2]#1 / May 05, 2009 5:44pm
Hello,
is there a way to make my comment form show for certain IP Blocks? I have a list of IP adresses I would like to block from seeing my comment form. Would you have sample code.
#2 / May 06, 2009 7:25am
Well, a basic example using PHP (you need to allow PHP for the template) could go along the lines of this:
<?php
global $IN;
$show = TRUE;
$block = array("195.195.", "69.", "192.168.0.2"); // Array of IP-addresses to be blocked
foreach ($block as $ip)
{
if ( strncmp($IN->IP, $ip, strlen($ip)) == 0 )
{
$show = FALSE;
break;
}
}
if ($show === TRUE)
{
?>
{exp:comment:form}
{/exp:comment:form}
<?php
}
?>