1 | <?php |
---|
2 | |
---|
3 | function plugin_install() |
---|
4 | { |
---|
5 | global $conf; |
---|
6 | |
---|
7 | $default= array(); |
---|
8 | |
---|
9 | $q = ' |
---|
10 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
11 | VALUES ("HistoryIPExcluder","","History IP Excluder parameters"); |
---|
12 | '; |
---|
13 | |
---|
14 | pwg_query($q); |
---|
15 | |
---|
16 | $default = array ( |
---|
17 | 'Blacklist' => "0", |
---|
18 | 'Version'=> "2.1.1", |
---|
19 | ); |
---|
20 | |
---|
21 | $q = ' |
---|
22 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
23 | VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options"); |
---|
24 | '; |
---|
25 | |
---|
26 | pwg_query($q); |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | function plugin_activate() |
---|
31 | { |
---|
32 | global $conf; |
---|
33 | |
---|
34 | /* Check for upgrade from 2.0.0 to 2.0.1 */ |
---|
35 | /* *************************************** */ |
---|
36 | $query = ' |
---|
37 | SELECT param |
---|
38 | FROM '.CONFIG_TABLE.' |
---|
39 | WHERE param = "nbc_HistoryIPExcluder" |
---|
40 | ;'; |
---|
41 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
42 | |
---|
43 | if ($count == 1) |
---|
44 | { |
---|
45 | /* upgrade from branch 2.0.0 to 2.0.1 */ |
---|
46 | /* ************************************ */ |
---|
47 | upgrade_200(); |
---|
48 | } |
---|
49 | |
---|
50 | $query = ' |
---|
51 | SELECT param |
---|
52 | FROM '.CONFIG_TABLE.' |
---|
53 | WHERE param = "HistoryIPConfig" |
---|
54 | ;'; |
---|
55 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
56 | |
---|
57 | if ($count == 0) |
---|
58 | { |
---|
59 | /* upgrade from branch 2.1.0 to 2.1.1 */ |
---|
60 | /* ************************************ */ |
---|
61 | upgrade_210(); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | function plugin_uninstall() |
---|
67 | { |
---|
68 | global $conf; |
---|
69 | |
---|
70 | if (isset($conf['HistoryIPExcluder'])) |
---|
71 | { |
---|
72 | $q = ' |
---|
73 | DELETE FROM '.CONFIG_TABLE.' |
---|
74 | WHERE param="HistoryIPExcluder" LIMIT 1; |
---|
75 | '; |
---|
76 | |
---|
77 | pwg_query($q); |
---|
78 | } |
---|
79 | if (isset($conf['HistoryIPConfig'])) |
---|
80 | { |
---|
81 | $q = ' |
---|
82 | DELETE FROM '.CONFIG_TABLE.' |
---|
83 | WHERE param="HistoryIPConfig" LIMIT 1; |
---|
84 | '; |
---|
85 | |
---|
86 | pwg_query($q); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | function upgrade_200() |
---|
92 | { |
---|
93 | global $conf; |
---|
94 | |
---|
95 | $q = ' |
---|
96 | UPDATE '.CONFIG_TABLE.' |
---|
97 | SET param = "HistoryIPExcluder" |
---|
98 | WHERE param = "nbc_HistoryIPExcluder" |
---|
99 | ;'; |
---|
100 | pwg_query($q); |
---|
101 | |
---|
102 | $q = ' |
---|
103 | UPDATE '.CONFIG_TABLE.' |
---|
104 | SET comment = "History IP Excluder parameters" |
---|
105 | WHERE comment = "Parametres nbc History IP Excluder" |
---|
106 | ;'; |
---|
107 | pwg_query($q); |
---|
108 | |
---|
109 | upgrade_210(); |
---|
110 | } |
---|
111 | |
---|
112 | function upgrade_210() |
---|
113 | { |
---|
114 | global $conf; |
---|
115 | |
---|
116 | $default = array ( |
---|
117 | 'Blacklist' => "0", |
---|
118 | 'Version'=> "2.1.1", |
---|
119 | ); |
---|
120 | |
---|
121 | $q = ' |
---|
122 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
123 | VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options"); |
---|
124 | '; |
---|
125 | |
---|
126 | pwg_query($q); |
---|
127 | } |
---|
128 | ?> |
---|