source: extensions/nbc_HistoryIPExcluder/branches/2.1/main.inc.php @ 5616

Last change on this file since 5616 was 5615, checked in by Eric, 14 years ago

[nbc_HistoryIPExcluder]

  • Piwigo 2.1 compliance
  • Multiple database support
  • Improving the display of plugin's name
  • Property svn:eol-style set to LF
File size: 2.6 KB
Line 
1<?php
2/*
3Plugin Name: History IP Excluder
4Version: 2.1.0
5Description: 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.
6Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=147
7Author: Nicco, Eric
8Author URI: http://gallery-nicco.no-ip.org - http://www.infernoweb.net
9*/
10
11/*
12:: HISTORY
13
141.0.x to 1.6.x          - Plugin only for PWG 1.7.x
15
162.0.0             - Compliance with Piwigo 2.0.x
17
182.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
26if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
27
28if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__)));
29if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
30
31include_once (HIPE_PATH.'/include/functions.inc.php');
32
33load_language('plugin.lang', HIPE_PATH);
34
35add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer');
36add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu');
37
38/* Set the administration panel of the plugin */
39function 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
58function 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?>
Note: See TracBrowser for help on using the repository browser.