Changeset 9870


Ignore:
Timestamp:
Mar 26, 2011, 5:01:30 PM (10 years ago)
Author:
Eric
Message:

Piwigo 2.2 compliance
Renaming of plugin directory from nbc_HistoryIPExcluder to HistoryIPExcluder

Location:
extensions/nbc_HistoryIPExcluder/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/nbc_HistoryIPExcluder/trunk/main.inc.php

    r6760 r9870  
    22/*
    33Plugin Name: History IP Excluder
    4 Version: 2.1.1
     4Version: 2.2.0
    55Description: 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
     
    2424                  - Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration
    2525
     262.2.0             - Compliance with Piwigo 2.2.x
     27                  - Plugin directory renamed from nbc_HistoryIPExcluder to HistoryIPExcluder
     28
    2629--------------------------------------------------------------------------------
    2730*/
     
    2932if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    3033
    31 if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__)));
    3234if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
    3335
     
    3638load_language('plugin.lang', HIPE_PATH);
    3739
    38 add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer');
    3940add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu');
    4041
     
    5152    array(
    5253      'NAME' => $name,
    53       'URL' => get_admin_plugin_menu_link(HIPE_PATH.'admin/HIPE_admin.php')
     54      'URL' => get_root_url().'admin.php?page=plugin-'.basename(HIPE_PATH)
    5455    )
    5556  );
     
    5859}
    5960
     61// IP exclusion from logs
     62add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer');
    6063
    6164function HIPE_IP_Filtrer($do_log)
  • extensions/nbc_HistoryIPExcluder/trunk/maintain.inc.php

    r6758 r9870  
    11<?php
    22
     3if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
     4
     5include_once (HIPE_PATH.'include/functions.inc.php');
     6
    37function plugin_install()
    48{
    59  global $conf;
    610 
     11// Set plugin parameters
    712  $default= array();
    813
    9   $q = '
     14        $query = '
     15SELECT param
     16  FROM '.CONFIG_TABLE.'
     17WHERE param = "HistoryIPExcluder"
     18;';
     19  $count = pwg_db_num_rows(pwg_query($query));
     20 
     21  if ($count == 0)
     22  {
     23    $q = '
    1024INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
    1125VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
    1226';
    1327     
    14   pwg_query($q);
    15 
    16 $default = array (
    17   'Blacklist' => "0",
    18   'Version'=> "2.1.1",
    19 );
    20 
    21   $q = '
     28    pwg_query($q);
     29  }
     30
     31// Set plugin config
     32  $plugin =  HIPE_infos(HIPE_PATH);
     33  $version = $plugin['version'];
     34
     35  $default = array (
     36    'Blacklist' => "0",
     37    'Version'=> $version,
     38  );
     39
     40        $query = '
     41SELECT param
     42  FROM '.CONFIG_TABLE.'
     43WHERE param = "HistoryIPConfig"
     44;';
     45  $count = pwg_db_num_rows(pwg_query($query));
     46 
     47  if ($count == 0)
     48  {
     49    $q = '
    2250INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
    2351VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
    2452';
    25      
    26   pwg_query($q);
     53    pwg_query($q);
     54  }
    2755}
    2856
     
    4371        if ($count == 1)
    4472        {
    45   /* upgrade from branch 2.0.0 to 2.0.1   */
     73  /* upgrade from version 2.0.0 to 2.0.1  */
    4674  /* ************************************ */
    4775                upgrade_200();
     
    5785        if ($count == 0)
    5886        {
    59   /* upgrade from branch 2.1.0 to 2.1.1   */
     87  /* upgrade from version 2.1.0 to 2.1.1  */
    6088  /* ************************************ */
    6189                upgrade_210();
    6290        }
     91
     92  /* upgrade from version 2.1.1 to 2.2.0 */
     93  /* *********************************** */
     94  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
     95  if ($HIPE_Config['Version'] != "2.2.0")
     96  {
     97    upgrade_211();
     98  }
    6399}
    64100
     
    126162  pwg_query($q);
    127163}
     164
     165function upgrade_211()
     166{
     167  global $conf;
     168
     169// Update plugin version
     170  $query = '
     171SELECT value
     172  FROM '.CONFIG_TABLE.'
     173WHERE param = "HistoryIPConfig"
     174;';
     175  $result = pwg_query($query);
     176 
     177  $conf_HIPE = pwg_db_fetch_assoc($result);
     178   
     179  $Newconf_HIPE = unserialize($conf_HIPE['value']);
     180 
     181  $Newconf_HIPE[1] = '2.2.0';
     182 
     183  $update_conf = serialize($Newconf_HIPE);
     184
     185  $query = '
     186UPDATE '.CONFIG_TABLE.'
     187SET value="'.addslashes($update_conf).'"
     188WHERE param="HistoryIPConfig"
     189LIMIT 1
     190;';
     191
     192        pwg_query($query);
     193
     194  // Create new HIPE entry in plugins table
     195  $query = '
     196INSERT INTO '.PLUGINS_TABLE.' (id, state, version)
     197VALUES ("HistoryIPExcluder","active","2.2.0")
     198;';
     199 
     200  pwg_query($query);
     201
     202  // Delete old plugin entry in plugins table
     203  $query = '
     204DELETE FROM '.PLUGINS_TABLE.'
     205WHERE id="nbc_HistoryIPExcluder"
     206LIMIT 1
     207;';
     208 
     209  pwg_query($query);
     210
     211  // rename directory
     212  if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder'))
     213  {
     214    die('Fatal error on plugin upgrade process : Unable to rename directory ! Please, rename manualy the plugin directory name from ../plugins/nbc_HistoryIPExcluder to ../plugins/HistoryIPExcluder.');
     215  }
     216}
    128217?>
Note: See TracChangeset for help on using the changeset viewer.