1 | <?php |
---|
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 | |
---|
7 | function plugin_install() |
---|
8 | { |
---|
9 | global $conf; |
---|
10 | |
---|
11 | // Set plugin parameters |
---|
12 | $default= array(); |
---|
13 | |
---|
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 = ' |
---|
24 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
25 | VALUES ("HistoryIPExcluder","","History IP Excluder parameters"); |
---|
26 | '; |
---|
27 | |
---|
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 = ' |
---|
50 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
51 | VALUES ("HistoryIPConfig","'.pwg_db_real_escape_string(serialize($default)).'","History IP Excluder options"); |
---|
52 | '; |
---|
53 | pwg_query($q); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | function plugin_activate() |
---|
59 | { |
---|
60 | global $conf; |
---|
61 | |
---|
62 | include_once (HIPE_PATH.'include/dbupgrade.inc.php'); |
---|
63 | |
---|
64 | /* Check for upgrade from 2.0.0 to 2.0.1 */ |
---|
65 | /* *************************************** */ |
---|
66 | $query = ' |
---|
67 | SELECT param |
---|
68 | FROM '.CONFIG_TABLE.' |
---|
69 | WHERE param = "nbc_HistoryIPExcluder" |
---|
70 | ;'; |
---|
71 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
72 | |
---|
73 | if ($count == 1) |
---|
74 | { |
---|
75 | /* upgrade from version 2.0.0 to 2.0.1 */ |
---|
76 | /* ************************************ */ |
---|
77 | upgrade_200(); |
---|
78 | } |
---|
79 | |
---|
80 | $query = ' |
---|
81 | SELECT param |
---|
82 | FROM '.CONFIG_TABLE.' |
---|
83 | WHERE param = "HistoryIPConfig" |
---|
84 | ;'; |
---|
85 | $count = pwg_db_num_rows(pwg_query($query)); |
---|
86 | |
---|
87 | if ($count == 0) |
---|
88 | { |
---|
89 | /* upgrade from version 2.1.0 to 2.1.1 */ |
---|
90 | /* ************************************ */ |
---|
91 | upgrade_210(); |
---|
92 | } |
---|
93 | |
---|
94 | /* upgrade from version 2.1.1 to 2.2.0 */ |
---|
95 | /* *********************************** */ |
---|
96 | $HIPE_Config = unserialize($conf['HistoryIPConfig']); |
---|
97 | if ($HIPE_Config['Version'] == '2.1.1') |
---|
98 | { |
---|
99 | upgrade_211(); |
---|
100 | } |
---|
101 | |
---|
102 | /* Global version number upgrade */ |
---|
103 | /* ***************************** */ |
---|
104 | global_version_update(); |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | function plugin_uninstall() |
---|
109 | { |
---|
110 | global $conf; |
---|
111 | |
---|
112 | if (isset($conf['HistoryIPExcluder'])) |
---|
113 | { |
---|
114 | $q = ' |
---|
115 | DELETE FROM '.CONFIG_TABLE.' |
---|
116 | WHERE param="HistoryIPExcluder" LIMIT 1; |
---|
117 | '; |
---|
118 | |
---|
119 | pwg_query($q); |
---|
120 | } |
---|
121 | if (isset($conf['HistoryIPConfig'])) |
---|
122 | { |
---|
123 | $q = ' |
---|
124 | DELETE FROM '.CONFIG_TABLE.' |
---|
125 | WHERE param="HistoryIPConfig" LIMIT 1; |
---|
126 | '; |
---|
127 | |
---|
128 | pwg_query($q); |
---|
129 | } |
---|
130 | } |
---|
131 | ?> |
---|