[17452] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* Database upgrading functions */ |
---|
| 4 | |
---|
| 5 | // This will update only current plugin version number in database |
---|
| 6 | function global_version_update() |
---|
| 7 | { |
---|
| 8 | global $conf; |
---|
| 9 | |
---|
| 10 | // Get current plugin version |
---|
| 11 | $plugin = HIPE_infos(HIPE_PATH); |
---|
| 12 | $version = $plugin['version']; |
---|
| 13 | |
---|
| 14 | // Update plugin version |
---|
| 15 | $query = ' |
---|
| 16 | SELECT value |
---|
| 17 | FROM '.CONFIG_TABLE.' |
---|
| 18 | WHERE param = "HistoryIPConfig" |
---|
| 19 | ;'; |
---|
| 20 | $result = pwg_query($query); |
---|
| 21 | |
---|
| 22 | $conf_HIPE = pwg_db_fetch_assoc($result); |
---|
| 23 | |
---|
| 24 | $Newconf_HIPE = unserialize($conf_HIPE['value']); |
---|
| 25 | |
---|
| 26 | $Newconf_HIPE['Version'] = $version; |
---|
| 27 | |
---|
| 28 | conf_update_param('HistoryIPConfig', pwg_db_real_escape_string(serialize($Newconf_HIPE))); |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | function upgrade_200() |
---|
| 33 | { |
---|
| 34 | global $conf; |
---|
| 35 | |
---|
| 36 | $q = ' |
---|
| 37 | UPDATE '.CONFIG_TABLE.' |
---|
| 38 | SET param = "HistoryIPExcluder" |
---|
| 39 | WHERE param = "nbc_HistoryIPExcluder" |
---|
| 40 | ;'; |
---|
| 41 | pwg_query($q); |
---|
| 42 | |
---|
| 43 | $q = ' |
---|
| 44 | UPDATE '.CONFIG_TABLE.' |
---|
| 45 | SET comment = "History IP Excluder parameters" |
---|
| 46 | WHERE comment = "Parametres nbc History IP Excluder" |
---|
| 47 | ;'; |
---|
| 48 | pwg_query($q); |
---|
| 49 | |
---|
| 50 | upgrade_210(); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | function upgrade_210() |
---|
| 54 | { |
---|
| 55 | global $conf; |
---|
| 56 | |
---|
| 57 | $default = array ( |
---|
| 58 | 'Blacklist' => "0", |
---|
| 59 | 'Version'=> "2.1.1", |
---|
| 60 | ); |
---|
| 61 | |
---|
| 62 | $q = ' |
---|
| 63 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
| 64 | VALUES ("HistoryIPConfig","'.pwg_db_real_escape_string(serialize($default)).'","History IP Excluder options"); |
---|
| 65 | '; |
---|
| 66 | |
---|
| 67 | pwg_query($q); |
---|
| 68 | |
---|
| 69 | upgrade_211(); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | function upgrade_211() |
---|
| 73 | { |
---|
| 74 | global $conf; |
---|
| 75 | |
---|
| 76 | // Create new HIPE entry in plugins table |
---|
| 77 | $query = ' |
---|
| 78 | INSERT INTO '.PLUGINS_TABLE.' (id, state, version) |
---|
| 79 | VALUES ("HistoryIPExcluder","active","2.2.0") |
---|
| 80 | ;'; |
---|
| 81 | |
---|
| 82 | pwg_query($query); |
---|
| 83 | |
---|
| 84 | // Delete old plugin entry in plugins table |
---|
| 85 | $query = ' |
---|
| 86 | DELETE FROM '.PLUGINS_TABLE.' |
---|
| 87 | WHERE id="nbc_HistoryIPExcluder" |
---|
| 88 | LIMIT 1 |
---|
| 89 | ;'; |
---|
| 90 | |
---|
| 91 | pwg_query($query); |
---|
| 92 | |
---|
| 93 | // rename directory |
---|
| 94 | if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder')) |
---|
| 95 | { |
---|
| 96 | 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.'); |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | ?> |
---|