PHP Classes

File: example.firewall.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Petter Kjelkenes  >  Firewall Protection  >  example.firewall.php  >  Download  
File: example.firewall.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Firewall Protection
Restrict the access to pages based on IP address
Author: By
Last change: Added support for only block/filter of certian userinput variables.
Date: 5 years ago
Size: 1,421 bytes


Class file image Download

// Include the class file.
include 'Firewall.php';

// Start firewall.
$firewall = new Firewall();

// Block specific ips. Also block the 20.20.x.x subnet.

// Only allow specific IP's..

// This removed all input, meaning you cant do anything with POST and GET actions because it gets totally stripped !!
// Normally this method is not needed to be used because it makes your script very unflexible in many cases.

// Remove all possible XXS and SQL injections this filters every possible input that a user can do. Notice! User may not post tags when this is used, HTML tags is removed!!
// Now you dont need to escape data later in the script, because at a highlevel this filters all the $_POST,$_GET...etc.. variables.
// Leave no arguement or false if you want to filter all global variables, (recommended). In this example we only filter post & get.
$firewall->UserInput()->inputProtection(Firewall::POST & Firewall::GET);


// When finished setting settings you will need to run the firewall with the run() method.

$firewall->printSettings(); // For debugging only. remove this when you have checked the settings.
}catch(Exception $e){
"You are not allowed at this place.");