source: extensions/AntiAspi/maintain.class.php @ 30113

Last change on this file since 30113 was 29307, checked in by mistic100, 10 years ago

compatibility 2.7

File size: 1.4 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4class 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 = "
15CREATE 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 = "
32CREATE 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    $this->install($new_version, $errors);
46  }
47
48  function uninstall()
49  {
50    global $prefixeTable;
51
52    pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_ip_ban;');
53    pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_log;');
54  }
55}
Note: See TracBrowser for help on using the repository browser.