source: extensions/nbc_HistoryIPExcluder/trunk/main.inc.php @ 5099

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

[nbc_HistoryIPExcluder] Initial SVN creation

  • Trunk directory created with beta version of next plugin version for Piwigo
  • Branche 2.0 created
  • Tags directory created
  • Property svn:eol-style set to LF
File size: 2.0 KB
Line 
1<?php
2/*
3Plugin Name: NBC History IP Excluder
4Version: 2.0.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. plugin directement derive de Stats Ip Excluder de Eric
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
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__)));
14if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
15//define('NBC_HISTORYIPEXCLUDER_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
16
17load_language('plugin.lang', HIPE_PATH);
18
19add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer');
20add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu');
21
22/* Set the administration panel of the plugin */
23function HIPE_admin_menu($menu)
24{
25  array_push($menu,
26    array(
27      'NAME' => 'History IP Excluder',
28      'URL' => get_admin_plugin_menu_link(HIPE_PATH.'admin/HIPE_admin.php')
29    )
30  );
31   
32  return $menu;
33}
34
35
36function HIPE_IP_Filtrer($do_log)
37{
38  global $conf;
39
40  $conf_HIPE = unserialize($conf['nbc_HistoryIPExcluder']);
41  //$conf_nbc_HistoryIPExcluder = explode("," , $conf['nbc_HistoryIPExcluder']);
42
43  if ( !$do_log )
44    return $do_log;
45  else
46  {
47    $IP_Client = explode(".", $_SERVER['REMOTE_ADDR']);
48 
49    foreach ( $conf_HIPE as $Exclusion )
50    {
51      $IP_Exclude = explode(".", $Exclusion);
52 
53      if (
54        (($IP_Client[0] == $IP_Exclude[0]) or ($IP_Exclude[0] == '%')) and
55        (!isset($IP_Exclude[1]) or ($IP_Client[1] == $IP_Exclude[1]) or ($IP_Exclude[1] == '%')) and
56        (!isset($IP_Exclude[2]) or ($IP_Client[2] == $IP_Exclude[2]) or ($IP_Exclude[2] == '%')) and
57        (!isset($IP_Exclude[3]) or ($IP_Client[3] == $IP_Exclude[3]) or ($IP_Exclude[3] == '%'))
58      )
59      {
60        $do_log = false;
61      }   
62    }
63     
64    return $do_log;
65  }
66}
67
68?>
Note: See TracBrowser for help on using the repository browser.