Buy Now
Sign in

IP banning not working correctly

jimdda , September 09 2013
j
jimdda

Hello all!

I've just installed some custom code on "on submit" on a form to ban some spammers however it does not seem to have worked? I used the code from the FAQ and simply added the IP addresses, this has worked on one form but not on the other. Please could you tell me if I've done something wrong in the code.

<?php
$banned_ips = array(
'188.143.232.12',
'94.23.238.222'
'89.73.123.158'
'27.153.232.179'
'27.153.233.2'
'120.43.11.143'
'117.26.116.157'
'173.196.144.130'
);
$ip_address = JRequest::getString( 'REMOTE_ADDR', '', 'server' );
if ( in_array($ip_address, $banned_ips) ) {
$mainframe->redirect('index.php');
}
?>

GreyHead

Hi jimdda,

You missed the commas at the end of the IP address lines after the first one.

				'188.143.232.12', // this one is good
'94.23.238.222' // add comma here and on the following lines
. . .

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

j
jimdda

Ah! It's always something small that you miss isn't it!

Thanks!