PHP Classes

PHP Block Login Attempts: Block login attempts from IP after failures

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 316 All time: 7,249 This week: 182Up
Version License PHP version Categories
block-login-attempt 1.0Freeware5PHP 5, User Management, Security
Collaborate with this project 

Author

block-login-attempt - github.com

Description

This class can block login attempts from IP after failures.

It can check if a login attempt is valid and if it failed it increases the count of failed attempts and stores it in session variables.

Repeated failed login attempts will make the user IP address be added the blocked IP list.

The access from listed IP addresses will blocked for a given period of time after which the user may try again.

Picture of Bharat Parmar
  Performance   Level  
Name: Bharat Parmar <contact>
Classes: 11 packages by
Country: India India
Age: 33
All time rank: 52131 in India India
Week rank: 51 Up6 in India India Up
Innovation award
Innovation award
Nominee: 3x

Example

<?php
   
@include("class/Login.class.php");
   
$Login = new Login();
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Block Login Attempt : Bharat Parmar</title>
    </head>
<body>

<h4>Example : Block Login Attempt with IP Address </h4>
<ol>
    <li>Form Submit</li>
    <li>Form Data Clear</li>
    <li>Click on your Web Page</li>
    <li>Copy Web Page Content</li>
    <li>Print Web Page</li>
    <li>Right Click on Web Page</li>
</ol>
<p>Whenever the above events will be triggered, the screenshot of the webpage will be stored in the Screenshot Directory as well as the event log will be generated in event-log.log file in the same directory. Event Log will store data like Event Name, Screenshot Image File Name, Time and IP Address.</p>
<hr>
    <?php $Login->DisplayMessage(); ?>
<form method="post">
        <h3>Login</h3>
        <table width="50%">
            <tr>
                <th>Username</th>
                <td><input type="text" name="username"></td>
            </tr>
            <tr>
                <th>Password</th>
                <td><input type="password" name="password"></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" name="login_submit" value="Login">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>



Details

Block Failed Login Attempt

After Number Of Failed Login Attempt By User, the class will block the user's IP Address for some Hours. Developer can set Maximum Failed Login Attempt, Blocked IP Address and Unblock Time setting from the config.php file.

Currently this class is storing the Blocked IP Address details in the JSON file which can be stored in the Database.

After maximum failed login attempt, user's IP Address will be blocked for the time which has neen set in the config.php file. After the blocked timeout time, if user will try to access the page, his IP Address will be ublocked automatically.

Developed By :

Bharat Parmar

Version :

1.0

File Structure :

1) config.php : Configuration File contains setting about the Class.

2) class/Login.class.php : Login class file contains Login behind the Failed Login Attempt and Block/Unblock IP Address.

3) blockedip.json : JSON file contains Blocked IP Address and it Unblock Time.

4) example.php : Example script with description.

5) blocked.html : This file is just displaying Blocked IP Address Message.

Requirements :

1) PHP Version : 3.0 and above


  Files folder image Files  
File Role Description
Files folder imageclass (1 file)
Accessible without login Plain text file blocked.html Data Auxiliary data
Accessible without login Plain text file blockedip.json Data Auxiliary data
Accessible without login Plain text file config.php Conf. Configuration script
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  class  
File Role Description
  Plain text file Login.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:316
This week:0
All time:7,249
This week:182Up