1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: NBC History IP Excluder |
---|
4 | Version: 2.0.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. plugin directement derive de Stats Ip Excluder de Eric |
---|
6 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=147 |
---|
7 | Author: Nicco, Eric |
---|
8 | Author URI: http://gallery-nicco.no-ip.org - http://www.infernoweb.net |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__))); |
---|
14 | if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
15 | |
---|
16 | load_language('plugin.lang', HIPE_PATH); |
---|
17 | |
---|
18 | add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer'); |
---|
19 | add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu'); |
---|
20 | |
---|
21 | /* Set the administration panel of the plugin */ |
---|
22 | function HIPE_admin_menu($menu) |
---|
23 | { |
---|
24 | array_push($menu, |
---|
25 | array( |
---|
26 | 'NAME' => 'History IP Excluder', |
---|
27 | 'URL' => get_admin_plugin_menu_link(HIPE_PATH.'admin/HIPE_admin.php') |
---|
28 | ) |
---|
29 | ); |
---|
30 | |
---|
31 | return $menu; |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | function HIPE_IP_Filtrer($do_log) |
---|
36 | { |
---|
37 | global $conf; |
---|
38 | |
---|
39 | $conf_HIPE = explode("," , $conf['nbc_HistoryIPExcluder']); |
---|
40 | |
---|
41 | if (!$do_log) |
---|
42 | return $do_log; |
---|
43 | else |
---|
44 | { |
---|
45 | $IP_Client = explode('.', $_SERVER['REMOTE_ADDR']); |
---|
46 | |
---|
47 | foreach ($conf_HIPE as $Exclusion) |
---|
48 | { |
---|
49 | $IP_Exclude = explode('.', $Exclusion); |
---|
50 | |
---|
51 | if ( |
---|
52 | (($IP_Client[0] == $IP_Exclude[0]) or ($IP_Exclude[0] == '%')) and |
---|
53 | (!isset($IP_Exclude[1]) or ($IP_Client[1] == $IP_Exclude[1]) or ($IP_Exclude[1] == '%')) and |
---|
54 | (!isset($IP_Exclude[2]) or ($IP_Client[2] == $IP_Exclude[2]) or ($IP_Exclude[2] == '%')) and |
---|
55 | (!isset($IP_Exclude[3]) or ($IP_Client[3] == $IP_Exclude[3]) or ($IP_Exclude[3] == '%')) |
---|
56 | ) |
---|
57 | { |
---|
58 | $do_log = false; |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | return $do_log; |
---|
63 | } |
---|
64 | } |
---|
65 | ?> |
---|