Log in

View Full Version : Redirect malicious page loads


marto
09-25-2007, 05:36 AM
Is there a way to add this into the forum index.php??

<?
$gawd = array ("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx");
foreach($gawd as $kill) {
if (ereg($kill, $_SERVER['REMOTE_ADDR'])) {
header('Location: http://www.ic3.gov');
exit();
} else {
LOAD FORUM INDEX HERE;
exit();
}
}

?>

I know I can ban them in the CP but this still uses resources to load the error page. Wouldn't something like this be less intensive.

maybe .htaccess would be a better way to go. I dunno what does anyone think?

Dismounted
09-25-2007, 05:47 AM
$banned = array("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx");

if (in_array($banned, $_SERVER['REMOTE_ADDR']))
{
header('Location: http://www.ic3.gov/');
}
Place this in a plugin at the init_startup hook.

marto
09-25-2007, 05:58 AM
wow that was fast. I did a htaccess on it with RewriteCond and Rewriterule. I got to thinking maybe it would be better in php then again maybe not since they could target something else to reload.

Thank you very much for the information

--------------- Added at 01:08 ---------------

Warning: in_array(): Wrong datatype for second argument in /includes/init.php(329) : eval()'d code on line 3

?? REMOTE_ADDR

my start up order is 1

Dismounted
09-25-2007, 06:22 AM
$banned = array("xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx", "xxx.xxx.xxx.xxx");

if (in_array($_SERVER['REMOTE_ADDR'], $banned))
{
header('Location: http://www.ic3.gov/');
}
Sorry, I had the variables the wrong way round.

marto
09-25-2007, 06:34 AM
No problem. I'm dangerous enough to dabble as it is, it worked :) sweet.