push array into array in a different file
so i'm making a cms for some mods. i'm trying to make them a handy ip banning tool. rather than them having to deal with htaccess i wanted to block ips via php.
from what i found out so far, i figure i'll make a form for the ip to be put on the ban list, then when submitted it will add the ip to the 'ban array'.
this is what i found for checking to see if someone is on the banned list, i'm going to try and mod this and work with it:
PHP Code:
$banned = array('129.168.1.1');
if(in_array($_SERVER['REMOTE_ADDR'], $banned))
{
die();
}
i can just include a mod of this on every page i want the chosen ips banned from.
for organization i want to have the array of banned ips in it's own php file. i can do the form and all, but my question is how can i push an array of the chosen ip into an array that's in a different file?
i made the array in banned.php like so:
PHP Code:
<?php
$banned = array();
?>
and the tool in a seperate file looks like this:
PHP Code:
<?php
include("banned.php");
$ban_this = $_POST["ip"]; //ip being the name of the text field from the form
$stack = array($ban_this);
array_push($banned, $stack);
?>
but when it uploads, the banned file is the same, empty :/ what am i doing wrong? should i put the tool's code in banned.php and just direct the form there? i feel like it's possible with this setup though.
can anyone nudge me in the right direction?