Changeset 28323 for extensions/AntiAspi/maintain.inc.php
- Timestamp:
- May 2, 2014, 9:45:06 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AntiAspi/maintain.inc.php
r3609 r28323 1 1 <?php 2 3 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 3 5 function plugin_install() 4 class AntiAspi_maintain extends PluginMaintain 6 5 { 7 global $prefixeTable;6 private $installed = false; 8 7 9 $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'antiaspi_ip_ban"'; 10 $result = pwg_query($query); 11 if (!mysql_fetch_row($result)) 8 function __construct($plugin_id) 12 9 { 13 $q = "CREATE TABLE " . $prefixeTable . "antiaspi_ip_ban ( 14 id int(11) NOT NULL auto_increment, 15 ip char(50) NOT NULL default '', 16 date char(20) NOT NULL default '', 17 PRIMARY KEY (id), 18 KEY ip (ip)) 19 DEFAULT CHARACTER SET utf8"; 20 pwg_query($q); 10 parent::__construct($plugin_id); 11 } 12 13 function install($plugin_version, &$errors=array()) 14 { 15 global $prefixeTable; 16 17 // table antiaspi_ip_ban to store list of banned IP addresses 18 $result = pwg_query('SHOW TABLES LIKE "'.$prefixeTable.'antiaspi_ip_ban";'); 19 if (!pwg_db_num_rows($result)) 20 { 21 $query = " 22 CREATE TABLE " . $prefixeTable . "antiaspi_ip_ban ( 23 id int(11) NOT NULL auto_increment, 24 ip char(50) NOT NULL default '', 25 date char(20) NOT NULL default '', 26 PRIMARY KEY (id), 27 KEY ip (ip) 28 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 29 ;"; 30 pwg_query($query); 31 } 32 33 // table antiaspi_log to store a specific "short-term" log 34 // (ENGINE=MEMORY, specific) 35 $result = pwg_query('SHOW TABLES LIKE "'.$prefixeTable.'antiaspi_log";'); 36 if (!pwg_db_num_rows($result)) 37 { 38 $query = " 39 CREATE TABLE " . $prefixeTable . "antiaspi_log ( 40 IP varchar(15) NOT NULL default '', 41 occured_on datetime NOT NULL, 42 image_id mediumint(8) default NULL, 43 category_id smallint(5) default NULL 44 ) ENGINE=MEMORY DEFAULT CHARSET=utf8 45 ;"; 46 pwg_query($query); 47 } 48 49 $this->installed = true; 50 } 51 52 function activate($plugin_version, &$errors=array()) 53 { 54 if (!$this->installed) 55 { 56 $this->install($plugin_version, $errors); 57 } 58 } 59 60 function deactivate() 61 { 62 } 63 64 function uninstall() 65 { 66 global $prefixeTable; 67 68 pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_ip_ban;'); 69 pwg_query('DROP TABLE '.$prefixeTable.'antiaspi_log;'); 21 70 } 22 71 } 23 24 function plugin_uninstall()25 {26 global $prefixeTable;27 28 $q = 'DROP TABLE ' . $prefixeTable . 'antiaspi_ip_ban;';29 pwg_query($q);30 }31 32 72 ?>
Note: See TracChangeset
for help on using the changeset viewer.