mysql_query("UPDATE `Sessions` SET time = time + 1");
mysql_query("UPDATE `Sessions` SET status = 0, time = 0, bytes = 0 WHERE (time > '".$settings['limittime']."' OR bytes > '".$settings['traffic']."') AND status = 1");
mysql_query("UPDATE `Sessions` SET status = 1 WHERE time > '".$settings['waittime']."' AND status = 0");
mysql_query("INSERT INTO `DenyList` (`clientip`) SELECT clientip FROM `Sessions` WHERE status = 0");
$time = time();
$lasttime = $settings['droptime']*60;
mysql_query("DELETE FROM `DenyList` WHERE clientip IN (SELECT clientip FROM `Sessions` WHERE status = 1 OR (".$time." - lasttime) > ".$lasttime.")");
mysql_query("DELETE FROM `Sessions` WHERE (".$time." - lasttime) > ".$lasttime." ");
CREATE TABLE IF NOT EXISTS `Config` (
`name` varchar(250) NOT NULL,
`value` int(10) unsigned NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251;
CREATE TABLE IF NOT EXISTS `DenyList` (
`clientip` int(10) unsigned NOT NULL,
PRIMARY KEY (`clientip`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251;
CREATE TABLE IF NOT EXISTS `Sessions` (
`ids` int(10) unsigned NOT NULL,
`clientip` int(10) unsigned NOT NULL,
`time` int(3) NOT NULL,
`bytes` int(10) NOT NULL,
`status` int(1) unsigned NOT NULL,
`lasttime` varchar(11) NOT NULL,
PRIMARY KEY (`ids`),
KEY `date` (`clientip`,`time`,`bytes`,`status`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251;
CREATE TABLE IF NOT EXISTS `Traffic` (
`idt` int(10) unsigned NOT NULL auto_increment,
`date` varchar(11) NOT NULL,
`clientip` int(10) unsigned NOT NULL,
`resultcode` varchar(250) NOT NULL,
`bytes` int(10) unsigned NOT NULL,
`url` text NOT NULL,
`peerip` int(10) unsigned NOT NULL,
`mimetype` varchar(250) NOT NULL,
PRIMARY KEY (`idt`),
KEY `date` (`date`,`clientip`,`resultcode`,`bytes`,`peerip`,`mimetype`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251;