redirect('index.php');}?>"> IP banning not working correctly - Forums

Forums

IP banning not working correctly

jimdda 09 Sep, 2013
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 09 Sep, 2013
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
jimdda 09 Sep, 2013
Ah! It's always something small that you miss isn't it!

Thanks!
This topic is locked and no more replies can be posted.