";
exit;
}
}
}else{
die(header('Location: index.php'));
}
if(isset($_POST['add_ip'])){
$data = $_POST['ip_address']."\n";
file_put_contents('block-list/ip-list.txt', $data, FILE_APPEND);
}
// If strict types are enabled i.e. declare(strict_types=1);
$file = file_get_contents('block-list/ip-list.txt', true);
// Otherwise
$file = file_get_contents('block-list/ip-list.txt', FILE_USE_INCLUDE_PATH);
$list = $file;
//Remove IP
if(isset($_POST['rem_ip'])){
$ipToRemove = $_POST['ip_address'];
$contents = file('block-list/ip-list.txt'); //Read all lines
$contents = array_filter($contents, function ($rmip) use ($ipToRemove) {
return trim($rmip, " \n\r,") != $ipToRemove;
}); // Filter out the matching rmip
file_put_contents('block-list/ip-list.txt', implode("\n", $contents)); // Write back
}
?>
Document
";
}
fclose($file);
?>