2017 © Pedro Peláez
 

library htaccess-firewall

Simple access control using Htaccess

image

jpkleemans/htaccess-firewall

Simple access control using Htaccess

  • Wednesday, March 22, 2017
  • by jpkleemans
  • Repository
  • 2 Watchers
  • 4 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Htaccess Firewall

Build Status Code Quality License, (*1)

SensioLabsInsight, (*2)

Simple access control using Htaccess., (*3)

This library is currently under development. Things will change!, (*4)

Install

Via Composer, (*5)

``` bash $ composer require jpkleemans/htaccess-firewall:dev-master, (*6)


## Usage First, create an instance of the `HtaccessFirewall\HtaccessFirewall` class: ``` php $firewall = new HtaccessFirewall('path/to/.htaccess');

Block IP

``` php $host = IP::fromString('123.0.0.1');, (*7)

$firewall->deny($host);, (*8)


### Unblock IP ``` php $host = IP::fromString('123.0.0.1'); $firewall->undeny($host);

Get all denied hosts

``` php $hosts = $firewall->getDenied();, (*9)


### Deactivate firewall (comment .htaccess lines) ``` php $firewall->deactivate(); // And to reactivate: $firewall->reactivate();

Set 403 message

``` php $hosts = $firewall->set403Message('You are blocked!');, (*10)

// And to remove: $hosts = $firewall->remove403Message();, (*11)


## Use other filesystem You can use another filesystem by passing it as the second argument of the `HtaccessFirewall` constructor. The filesystem must implement the `HtaccessFirewall\Filesystem\Filesystem` interface. ``` php $filesystem = new YourCustomFilesystem(); $firewall = new HtaccessFirewall('path/to/.htaccess', $filesystem);

Testing

bash $ phpspec run, (*12)

The Versions

22/03 2017

dev-master

9999999-dev https://github.com/jpkleemans/htaccess-firewall

Simple access control using Htaccess

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Jan-Paul Kleemans

access block firewall blacklist htaccess deny