1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | class AntiAspi_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | function install($plugin_version, &$errors=array()) |
---|
7 | { |
---|
8 | global $prefixeTable; |
---|
9 | |
---|
10 | // table antiaspi_ip_ban to store list of banned IP addresses |
---|
11 | $result = pwg_query('SHOW TABLES LIKE "'.$prefixeTable.'antiaspi_ip_ban";'); |
---|
12 | if (!pwg_db_num_rows($result)) |
---|
13 | { |
---|
14 | $query = " |
---|
15 | CREATE TABLE " . $prefixeTable . "antiaspi_ip_ban ( |
---|
16 | id int(11) NOT NULL auto_increment, |
---|
17 | ip char(50) NOT NULL default '', |
---|
18 | date char(20) NOT NULL default '', |
---|
19 | PRIMARY KEY (id), |
---|
20 | KEY ip (ip) |
---|
21 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
---|
22 | ;"; |
---|
23 | pwg_query($query); |
---|
24 | } |
---|
25 | |
---|
26 | // table antiaspi_log to store a specific "short-term" log |
---|
27 | // (ENGINE=MEMORY, specific) |
---|
28 | $result = pwg_query('SHOW TABLES LIKE "'.$prefixeTable.'antiaspi_log";'); |
---|
29 | if (!pwg_db_num_rows($result)) |
---|
30 | { |
---|
31 | $query = " |
---|
32 | CREATE TABLE " . $prefixeTable . "antiaspi_log ( |
---|
33 | IP varchar(15) NOT NULL default '', |
---|
34 | occured_on datetime NOT NULL, |
---|
35 | image_id mediumint(8) default NULL, |
---|
36 | category_id smallint(5) default NULL |
---|
37 | ) ENGINE=MEMORY DEFAULT CHARSET=utf8 |
---|
38 | ;"; |
---|
39 | pwg_query($query); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | function update($old_version, $new_version, &$errors=array()) |
---|
44 | { |
---|
45 | global $conf; |
---|
46 | |
---|
47 | if (!isset($conf['antiaspi'])) |
---|
48 | { |
---|
49 | $conf['antiaspi'] = array( |
---|
50 | 'diff' => '20 pages in 00:00:10' , |
---|
51 | 'same' => '15 pages in 00:00:30' , |
---|
52 | 'banned during' => '23:59:59' , |
---|
53 | 'only guest' => true , |
---|
54 | 'only picture' => false , |
---|
55 | 'allowed ip' => array('123.123.123.123','122.122.122.122'), |
---|
56 | ); |
---|
57 | conf_update_param('antiaspi', $conf['antiaspi']); |
---|
58 | } |
---|
59 | |
---|
60 | $this->install($new_version, $errors); |
---|
61 | } |
---|
62 | |
---|
63 | function uninstall() |
---|
64 | { |
---|
65 | global $prefixeTable; |
---|
66 | |
---|
67 | pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_ip_ban;'); |
---|
68 | pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_log;'); |
---|
69 | } |
---|
70 | } |
---|