1 | <?php |
---|
2 | /* |
---|
3 | Plugin 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. |
---|
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 | /* |
---|
12 | :: HISTORY |
---|
13 | |
---|
14 | 1.0.x to 1.6.x - Plugin only for PWG 1.7.x |
---|
15 | |
---|
16 | 2.0.0 - Compliance with Piwigo 2.0.x |
---|
17 | |
---|
18 | 2.1.0 - Compliance with Piwigo 2.1.x |
---|
19 | - Multiple database support |
---|
20 | - Removing "nbc_" prefix in plugin code and display in piwigo's plugin manager |
---|
21 | - Displaying the good plugin name and current version in admin panel |
---|
22 | |
---|
23 | -------------------------------------------------------------------------------- |
---|
24 | */ |
---|
25 | |
---|
26 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
27 | |
---|
28 | if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__))); |
---|
29 | if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); |
---|
30 | |
---|
31 | include_once (HIPE_PATH.'/include/functions.inc.php'); |
---|
32 | |
---|
33 | load_language('plugin.lang', HIPE_PATH); |
---|
34 | |
---|
35 | add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer'); |
---|
36 | add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu'); |
---|
37 | |
---|
38 | /* Set the administration panel of the plugin */ |
---|
39 | function HIPE_admin_menu($menu) |
---|
40 | { |
---|
41 | // +-----------------------------------------------------------------------+ |
---|
42 | // | Getting plugin name | |
---|
43 | // +-----------------------------------------------------------------------+ |
---|
44 | $plugin = HIPE_infos(HIPE_PATH); |
---|
45 | $name = $plugin['name']; |
---|
46 | |
---|
47 | array_push($menu, |
---|
48 | array( |
---|
49 | 'NAME' => $name, |
---|
50 | 'URL' => get_admin_plugin_menu_link(HIPE_PATH.'admin/HIPE_admin.php') |
---|
51 | ) |
---|
52 | ); |
---|
53 | |
---|
54 | return $menu; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | function HIPE_IP_Filtrer($do_log) |
---|
59 | { |
---|
60 | global $conf; |
---|
61 | |
---|
62 | $conf_HIPE = explode("," , $conf['HistoryIPExcluder']); |
---|
63 | |
---|
64 | if (!$do_log) |
---|
65 | return $do_log; |
---|
66 | else |
---|
67 | { |
---|
68 | $IP_Client = explode('.', $_SERVER['REMOTE_ADDR']); |
---|
69 | |
---|
70 | foreach ($conf_HIPE as $Exclusion) |
---|
71 | { |
---|
72 | $IP_Exclude = explode('.', $Exclusion); |
---|
73 | |
---|
74 | if ( |
---|
75 | (($IP_Client[0] == $IP_Exclude[0]) or ($IP_Exclude[0] == '%')) and |
---|
76 | (!isset($IP_Exclude[1]) or ($IP_Client[1] == $IP_Exclude[1]) or ($IP_Exclude[1] == '%')) and |
---|
77 | (!isset($IP_Exclude[2]) or ($IP_Client[2] == $IP_Exclude[2]) or ($IP_Exclude[2] == '%')) and |
---|
78 | (!isset($IP_Exclude[3]) or ($IP_Client[3] == $IP_Exclude[3]) or ($IP_Exclude[3] == '%')) |
---|
79 | ) |
---|
80 | { |
---|
81 | $do_log = false; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | return $do_log; |
---|
86 | } |
---|
87 | } |
---|
88 | ?> |
---|