1 | <?php |
---|
2 | |
---|
3 | /* Database upgrading functions */ |
---|
4 | |
---|
5 | // This wil 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 | $update_conf = serialize($Newconf_HIPE); |
---|
29 | |
---|
30 | $query = ' |
---|
31 | UPDATE '.CONFIG_TABLE.' |
---|
32 | SET value="'.addslashes($update_conf).'" |
---|
33 | WHERE param="HistoryIPConfig" |
---|
34 | LIMIT 1 |
---|
35 | ;'; |
---|
36 | |
---|
37 | pwg_query($query); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | function upgrade_200() |
---|
42 | { |
---|
43 | global $conf; |
---|
44 | |
---|
45 | $q = ' |
---|
46 | UPDATE '.CONFIG_TABLE.' |
---|
47 | SET param = "HistoryIPExcluder" |
---|
48 | WHERE param = "nbc_HistoryIPExcluder" |
---|
49 | ;'; |
---|
50 | pwg_query($q); |
---|
51 | |
---|
52 | $q = ' |
---|
53 | UPDATE '.CONFIG_TABLE.' |
---|
54 | SET comment = "History IP Excluder parameters" |
---|
55 | WHERE comment = "Parametres nbc History IP Excluder" |
---|
56 | ;'; |
---|
57 | pwg_query($q); |
---|
58 | |
---|
59 | upgrade_210(); |
---|
60 | } |
---|
61 | |
---|
62 | function upgrade_210() |
---|
63 | { |
---|
64 | global $conf; |
---|
65 | |
---|
66 | $default = array ( |
---|
67 | 'Blacklist' => "0", |
---|
68 | 'Version'=> "2.1.1", |
---|
69 | ); |
---|
70 | |
---|
71 | $q = ' |
---|
72 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
73 | VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options"); |
---|
74 | '; |
---|
75 | |
---|
76 | pwg_query($q); |
---|
77 | |
---|
78 | upgrade_211(); |
---|
79 | } |
---|
80 | |
---|
81 | function upgrade_211() |
---|
82 | { |
---|
83 | global $conf; |
---|
84 | |
---|
85 | // Create new HIPE entry in plugins table |
---|
86 | $query = ' |
---|
87 | INSERT INTO '.PLUGINS_TABLE.' (id, state, version) |
---|
88 | VALUES ("HistoryIPExcluder","active","2.2.0") |
---|
89 | ;'; |
---|
90 | |
---|
91 | pwg_query($query); |
---|
92 | |
---|
93 | // Delete old plugin entry in plugins table |
---|
94 | $query = ' |
---|
95 | DELETE FROM '.PLUGINS_TABLE.' |
---|
96 | WHERE id="nbc_HistoryIPExcluder" |
---|
97 | LIMIT 1 |
---|
98 | ;'; |
---|
99 | |
---|
100 | pwg_query($query); |
---|
101 | |
---|
102 | // rename directory |
---|
103 | if (!rename(PHPWG_PLUGINS_PATH.'nbc_HistoryIPExcluder', PHPWG_PLUGINS_PATH.'HistoryIPExcluder')) |
---|
104 | { |
---|
105 | 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.'); |
---|
106 | } |
---|
107 | } |
---|
108 | ?> |
---|