Ignore:
Timestamp:
Aug 15, 2010, 3:32:31 AM (14 years ago)
Author:
Eric
Message:
  • Merge from Trunk to Branch 2.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/nbc_HistoryIPExcluder/branches/2.1/main.inc.php

    r5615 r6761  
    22/*
    33Plugin Name: History IP Excluder
    4 Version: 2.1.0
    5 Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l historique - Excludes one IP or a range of IP from the history.
     4Version: 2.1.1
     5Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l'historique et de les blacklister à l'inscription - Base MySql seulement! / Excludes one IP or a range of IP from the history and to blacklist them on registration - MySql database only!
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=147
    77Author: Nicco, Eric
     
    2020                  - Removing "nbc_" prefix in plugin code and display in piwigo's plugin manager
    2121                  - Displaying the good plugin name and current version in admin panel
     22                 
     232.1.1             - Bug 1792 fixed (Thx to TOnin)
     24                  - Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration
    2225
    2326--------------------------------------------------------------------------------
     
    8689  }
    8790}
     91
     92/* Check users registration */
     93add_event_handler('register_user_check', 'HIPE_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL +2, 2);
     94
     95function HIPE_RegistrationCheck($err, $user)
     96{
     97  global $errors, $conf;
     98  load_language('plugin.lang', HIPE_PATH);
     99 
     100  if (count($err)!=0 ) return $err;
     101 
     102  $IP_Client = explode('.', $_SERVER['REMOTE_ADDR']);
     103  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
     104  $conf_HIPE = explode("," , $conf['HistoryIPExcluder']);
     105 
     106  if (isset($HIPE_Config['Blacklist']) and $HIPE_Config['Blacklist'] == true)
     107  {
     108    foreach ($conf_HIPE as $Exclusion)
     109    {
     110      $IP_Exclude = explode('.', $Exclusion);
     111 
     112      if (
     113        (($IP_Client[0] == $IP_Exclude[0]) or ($IP_Exclude[0] == '%')) and
     114        (!isset($IP_Exclude[1]) or ($IP_Client[1] == $IP_Exclude[1]) or ($IP_Exclude[1] == '%')) and
     115        (!isset($IP_Exclude[2]) or ($IP_Client[2] == $IP_Exclude[2]) or ($IP_Exclude[2] == '%')) and
     116        (!isset($IP_Exclude[3]) or ($IP_Client[3] == $IP_Exclude[3]) or ($IP_Exclude[3] == '%'))
     117      )
     118      {
     119        $err = l10n('Error_HIPE_BlacklistedIP');
     120      }
     121    }
     122    return $err;
     123  }
     124}
    88125?>
Note: See TracChangeset for help on using the changeset viewer.