source: extensions/nbc_HistoryIPExcluder/trunk/maintain.inc.php @ 6769

Last change on this file since 6769 was 6758, checked in by Eric, 14 years ago
  • Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration
  • Bug 1792 fixed (Thx to TOnin)
  • Property svn:eol-style set to LF
File size: 2.1 KB
RevLine 
[5099]1<?php
2
3function plugin_install()
4{
5  global $conf;
6 
7  $default= array();
8
9  $q = '
10INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
[5162]11VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
[5099]12';
13     
14  pwg_query($q);
[6758]15
16$default = array (
17  'Blacklist' => "0",
18  'Version'=> "2.1.1",
19);
20
21  $q = '
22INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
23VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
24';
25     
26  pwg_query($q);
[5099]27}
28
29
[5162]30function plugin_activate()
31{
32  global $conf;
33 
34/* Check for upgrade from 2.0.0 to 2.0.1 */
35/* *************************************** */
36        $query = '
37SELECT param
38  FROM '.CONFIG_TABLE.'
39WHERE param = "nbc_HistoryIPExcluder"
40;';
[5615]41  $count = pwg_db_num_rows(pwg_query($query));
[5162]42 
43        if ($count == 1)
44        {
[6758]45  /* upgrade from branch 2.0.0 to 2.0.1   */
[5162]46  /* ************************************ */
47                upgrade_200();
48        }
[6758]49
50        $query = '
51SELECT param
52  FROM '.CONFIG_TABLE.'
53WHERE 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        }
[5162]63}
64
65
[5099]66function plugin_uninstall()
67{
68  global $conf;
69
[6758]70  if (isset($conf['HistoryIPExcluder']))
[5099]71  {
72    $q = '
73DELETE FROM '.CONFIG_TABLE.'
[6758]74WHERE param="HistoryIPExcluder" LIMIT 1;
[5099]75';
76
77    pwg_query($q);
78  }
[6758]79  if (isset($conf['HistoryIPConfig']))
80  {
81    $q = '
82DELETE FROM '.CONFIG_TABLE.'
83WHERE param="HistoryIPConfig" LIMIT 1;
84';
85
86    pwg_query($q);
87  } 
[5099]88}
89
[5162]90
91function upgrade_200()
92{
93  global $conf;
94 
95  $q = '
96UPDATE '.CONFIG_TABLE.'
97SET param = "HistoryIPExcluder"
98WHERE param = "nbc_HistoryIPExcluder"
99;';
100  pwg_query($q);
101
102  $q = '
103UPDATE '.CONFIG_TABLE.'
104SET comment = "History IP Excluder parameters"
105WHERE comment = "Parametres nbc History IP Excluder"
106;';
107  pwg_query($q);
[6758]108
109  upgrade_210();
[5162]110}
[6758]111
112function upgrade_210()
113{
114  global $conf;
115 
116  $default = array (
117    'Blacklist' => "0",
118    'Version'=> "2.1.1",
119  );
120
121  $q = '
122INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
123VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
124';
125     
126  pwg_query($q);
127}
[5121]128?>
Note: See TracBrowser for help on using the repository browser.