Changeset 9870 for extensions/nbc_HistoryIPExcluder/trunk
- Timestamp:
- Mar 26, 2011, 5:01:30 PM (13 years ago)
- Location:
- extensions/nbc_HistoryIPExcluder/trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/nbc_HistoryIPExcluder/trunk/main.inc.php
r6760 r9870 2 2 /* 3 3 Plugin Name: History IP Excluder 4 Version: 2. 1.14 Version: 2.2.0 5 5 Description: 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! 6 6 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=147 … … 24 24 - Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration 25 25 26 2.2.0 - Compliance with Piwigo 2.2.x 27 - Plugin directory renamed from nbc_HistoryIPExcluder to HistoryIPExcluder 28 26 29 -------------------------------------------------------------------------------- 27 30 */ … … 29 32 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 30 33 31 if (!defined('HIPE_DIR')) define('HIPE_DIR' , basename(dirname(__FILE__)));32 34 if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); 33 35 … … 36 38 load_language('plugin.lang', HIPE_PATH); 37 39 38 add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer');39 40 add_event_handler('get_admin_plugin_menu_links', 'HIPE_admin_menu'); 40 41 … … 51 52 array( 52 53 '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) 54 55 ) 55 56 ); … … 58 59 } 59 60 61 // IP exclusion from logs 62 add_event_handler('pwg_log_allowed', 'HIPE_IP_Filtrer'); 60 63 61 64 function HIPE_IP_Filtrer($do_log) -
extensions/nbc_HistoryIPExcluder/trunk/maintain.inc.php
r6758 r9870 1 1 <?php 2 2 3 if (!defined('HIPE_PATH')) define('HIPE_PATH' , PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); 4 5 include_once (HIPE_PATH.'include/functions.inc.php'); 6 3 7 function plugin_install() 4 8 { 5 9 global $conf; 6 10 11 // Set plugin parameters 7 12 $default= array(); 8 13 9 $q = ' 14 $query = ' 15 SELECT param 16 FROM '.CONFIG_TABLE.' 17 WHERE param = "HistoryIPExcluder" 18 ;'; 19 $count = pwg_db_num_rows(pwg_query($query)); 20 21 if ($count == 0) 22 { 23 $q = ' 10 24 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 11 25 VALUES ("HistoryIPExcluder","","History IP Excluder parameters"); 12 26 '; 13 27 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 = ' 41 SELECT param 42 FROM '.CONFIG_TABLE.' 43 WHERE param = "HistoryIPConfig" 44 ;'; 45 $count = pwg_db_num_rows(pwg_query($query)); 46 47 if ($count == 0) 48 { 49 $q = ' 22 50 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 23 51 VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options"); 24 52 '; 25 26 pwg_query($q);53 pwg_query($q); 54 } 27 55 } 28 56 … … 43 71 if ($count == 1) 44 72 { 45 /* upgrade from branch 2.0.0 to 2.0.1*/73 /* upgrade from version 2.0.0 to 2.0.1 */ 46 74 /* ************************************ */ 47 75 upgrade_200(); … … 57 85 if ($count == 0) 58 86 { 59 /* upgrade from branch 2.1.0 to 2.1.1*/87 /* upgrade from version 2.1.0 to 2.1.1 */ 60 88 /* ************************************ */ 61 89 upgrade_210(); 62 90 } 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 } 63 99 } 64 100 … … 126 162 pwg_query($q); 127 163 } 164 165 function upgrade_211() 166 { 167 global $conf; 168 169 // Update plugin version 170 $query = ' 171 SELECT value 172 FROM '.CONFIG_TABLE.' 173 WHERE 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 = ' 186 UPDATE '.CONFIG_TABLE.' 187 SET value="'.addslashes($update_conf).'" 188 WHERE param="HistoryIPConfig" 189 LIMIT 1 190 ;'; 191 192 pwg_query($query); 193 194 // Create new HIPE entry in plugins table 195 $query = ' 196 INSERT INTO '.PLUGINS_TABLE.' (id, state, version) 197 VALUES ("HistoryIPExcluder","active","2.2.0") 198 ;'; 199 200 pwg_query($query); 201 202 // Delete old plugin entry in plugins table 203 $query = ' 204 DELETE FROM '.PLUGINS_TABLE.' 205 WHERE id="nbc_HistoryIPExcluder" 206 LIMIT 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 } 128 217 ?>
Note: See TracChangeset
for help on using the changeset viewer.