Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>Ban Hackers</id>
<version>1.0.1</version>
<vqmver>2.1.5</vqmver>
<author>zuma design | billynoah@gmail.com</author>
<file name="system/library/db.php">
<operation>
<search position="after" regex="true"><![CDATA[~(db|driver) = new~]]></search>
<add><![CDATA[
$table_query = $this->query("SHOW TABLES LIKE '" . DB_PREFIX . "ban_ip'");
if (!$table_query->rows) {
$this->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "ban_ip` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(40) NOT NULL,
`fails` int(11) NOT NULL,
`username` varchar(40) NOT NULL DEFAULT '',
`password` varchar(40) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `ip` (`ip`),
KEY `fails` (`fails`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
}
// BANNED IPS
if (isset($_SERVER['REMOTE_ADDR']) && $this->query("SELECT * FROM " . DB_PREFIX . "ban_ip WHERE ip = '" . $this->escape($_SERVER['REMOTE_ADDR']) . "' AND fails >= '6'")->num_rows) die;
]]></add>
</operation>
</file>
<file name="system/library/user.php">
<operation>
<search position="before"><![CDATA[return true;]]></search>
<add><![CDATA[
if ($this->db->query("SELECT * FROM " . DB_PREFIX . "ban_ip WHERE ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "'")->num_rows) {
$this->db->query("UPDATE " . DB_PREFIX . "ban_ip SET fails = 0, username = '" . $this->db->escape($username) . "', password = '' WHERE ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "'");
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "ban_ip SET fails = 0, ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "', username = '" . $this->db->escape($username) . "', password = ''");
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[return false;]]></search>
<add><![CDATA[
if ($this->db->query("SELECT * FROM " . DB_PREFIX . "ban_ip WHERE ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "'")->num_rows) {
$this->db->query("UPDATE " . DB_PREFIX . "ban_ip SET fails = fails + 1, username = '" . $this->db->escape($username) . "', password = '" . $this->db->escape($password) . "' WHERE ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "'");
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "ban_ip SET fails = 1, ip = '" . $this->db->escape($_SERVER['REMOTE_ADDR']) . "', username = '" . $this->db->escape($username) . "', password = '" . $this->db->escape($password) . "'");
}
]]></add>
</operation>
</file>
</modification>