| 133 | | |
| 134 | | |
| 135 | | function upgrade_200() |
| 136 | | { |
| 137 | | global $conf; |
| 138 | | |
| 139 | | $q = ' |
| 140 | | UPDATE '.CONFIG_TABLE.' |
| 141 | | SET param = "HistoryIPExcluder" |
| 142 | | WHERE param = "nbc_HistoryIPExcluder" |
| 143 | | ;'; |
| 144 | | pwg_query($q); |
| 145 | | |
| 146 | | $q = ' |
| 147 | | UPDATE '.CONFIG_TABLE.' |
| 148 | | SET comment = "History IP Excluder parameters" |
| 149 | | WHERE comment = "Parametres nbc History IP Excluder" |
| 150 | | ;'; |
| 151 | | pwg_query($q); |
| 152 | | |
| 153 | | upgrade_210(); |
| 154 | | } |
| 155 | | |
| 156 | | function upgrade_210() |
| 157 | | { |
| 158 | | global $conf; |
| 159 | | |
| 160 | | $default = array ( |
| 161 | | 'Blacklist' => "0", |
| 162 | | 'Version'=> "2.1.1", |
| 163 | | ); |
| 164 | | |
| 165 | | $q = ' |
| 166 | | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
| 167 | | VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options"); |
| 168 | | '; |
| 169 | | |
| 170 | | pwg_query($q); |
| 171 | | } |
| 172 | | |
| 173 | | function upgrade_211() |
| 174 | | { |
| 175 | | global $conf; |
| 176 | | |
| 177 | | // Update plugin version |
| 178 | | $query = ' |
| 179 | | SELECT value |
| 180 | | FROM '.CONFIG_TABLE.' |
| 181 | | WHERE param = "HistoryIPConfig" |
| 182 | | ;'; |
| 183 | | $result = pwg_query($query); |
| 184 | | |
| 185 | | $conf_HIPE = pwg_db_fetch_assoc($result); |
| 186 | | |
| 187 | | $Newconf_HIPE = unserialize($conf_HIPE['value']); |
| 188 | | |
| 189 | | $Newconf_HIPE['Version'] = '2.2.0'; |
| 190 | | |
| 191 | | $update_conf = serialize($Newconf_HIPE); |
| 192 | | |
| 193 | | $query = ' |
| 194 | | UPDATE '.CONFIG_TABLE.' |
| 195 | | SET value="'.addslashes($update_conf).'" |
| 196 | | WHERE param="HistoryIPConfig" |
| 197 | | LIMIT 1 |
| 198 | | ;'; |
| 199 | | |
| 200 | | pwg_query($query); |
| 201 | | |
| 202 | | // Create new HIPE entry in plugins table |
| 203 | | $query = ' |
| 204 | | INSERT INTO '.PLUGINS_TABLE.' (id, state, version) |
| 205 | | VALUES ("HistoryIPExcluder","active","2.2.0") |
| 206 | | ;'; |
| 207 | | |
| 208 | | pwg_query($query); |
| 209 | | |
| 210 | | // Delete old plugin entry in plugins table |
| 211 | | $query = ' |
| 212 | | DELETE FROM '.PLUGINS_TABLE.' |
| 213 | | WHERE id="nbc_HistoryIPExcluder" |
| 214 | | LIMIT 1 |
| 215 | | ;'; |
| 216 | | |
| 217 | | pwg_query($query); |
| 218 | | |
| 219 | | // rename directory |
| 220 | | if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder')) |
| 221 | | { |
| 222 | | 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.'); |
| 223 | | } |
| 224 | | } |
| 225 | | |
| 226 | | |
| 227 | | function upgrade_220() |
| 228 | | { |
| 229 | | global $conf; |
| 230 | | |
| 231 | | // Update plugin version |
| 232 | | $query = ' |
| 233 | | SELECT value |
| 234 | | FROM '.CONFIG_TABLE.' |
| 235 | | WHERE param = "HistoryIPConfig" |
| 236 | | ;'; |
| 237 | | $result = pwg_query($query); |
| 238 | | |
| 239 | | $conf_HIPE = pwg_db_fetch_assoc($result); |
| 240 | | |
| 241 | | $Newconf_HIPE = unserialize($conf_HIPE['value']); |
| 242 | | |
| 243 | | $Newconf_HIPE['Version'] = '2.2.1'; |
| 244 | | |
| 245 | | $update_conf = serialize($Newconf_HIPE); |
| 246 | | |
| 247 | | $query = ' |
| 248 | | UPDATE '.CONFIG_TABLE.' |
| 249 | | SET value="'.addslashes($update_conf).'" |
| 250 | | WHERE param="HistoryIPConfig" |
| 251 | | LIMIT 1 |
| 252 | | ;'; |
| 253 | | |
| 254 | | pwg_query($query); |
| 255 | | } |