Diff
14 years ago
.htaccess
14 years ago
Diff.php
14 years ago
GeoIP.dat
13 years ago
IPTraf.php
13 years ago
diffResult.php
14 years ago
email_genericAlert.php
14 years ago
email_newIssues.php
14 years ago
email_unlockRequest.php
14 years ago
menu_activity.php
13 years ago
menu_blockedIPs.php
13 years ago
menu_countryBlocking.php
13 years ago
menu_options.php
13 years ago
menu_scan.php
13 years ago
menu_scanSchedule.php
13 years ago
schedWeekEntry.php
13 years ago
sysinfo.php
14 years ago
unknownFiles.php
13 years ago
viewFullActivityLog.php
13 years ago
wf503.php
13 years ago
wfAPI.php
13 years ago
wfAction.php
14 years ago
wfArray.php
13 years ago
wfBrowscap.php
14 years ago
wfBrowscapCache.php
14 years ago
wfBulkCountries.php
13 years ago
wfConfig.php
13 years ago
wfCountryMap.php
13 years ago
wfCrawl.php
13 years ago
wfDB.php
13 years ago
wfDict.php
14 years ago
wfGeoIP.php
13 years ago
wfIssues.php
13 years ago
wfLockedOut.php
14 years ago
wfLog.php
13 years ago
wfModTracker.php
14 years ago
wfRate.php
14 years ago
wfScanEngine.php
13 years ago
wfSchema.php
13 years ago
wfUnlockMsg.php
14 years ago
wfUtils.php
13 years ago
wfViewResult.php
14 years ago
wordfenceClass.php
13 years ago
wordfenceConstants.php
13 years ago
wordfenceHash.php
13 years ago
wordfenceScanner.php
13 years ago
wordfenceURLHoover.php
13 years ago
wfSchema.php
181 lines
| 1 | <?php |
| 2 | require_once('wfDB.php'); |
| 3 | class wfSchema { |
| 4 | private $tables = array( |
| 5 | "wfBadLeechers" => "( |
| 6 | eMin int UNSIGNED NOT NULL, |
| 7 | IP int UNSIGNED NOT NULL, |
| 8 | hits int UNSIGNED NOT NULL, |
| 9 | PRIMARY KEY k1(eMin, IP) |
| 10 | ) default charset=latin1", |
| 11 | "wfVulnScanners" => "( |
| 12 | IP int UNSIGNED PRIMARY KEY, |
| 13 | ctime int UNSIGNED NOT NULL, |
| 14 | hits int UNSIGNED NOT NULL |
| 15 | )", |
| 16 | "wfBlocks" => "( |
| 17 | IP int UNSIGNED PRIMARY KEY, |
| 18 | blockedTime int UNSIGNED NOT NULL, |
| 19 | reason varchar(255) NOT NULL, |
| 20 | lastAttempt int UNSIGNED default 0, |
| 21 | blockedHits int UNSIGNED default 0, |
| 22 | wfsn tinyint UNSIGNED default 0, |
| 23 | permanent tinyint UNSIGNED default 0, |
| 24 | KEY k1(wfsn) |
| 25 | ) default charset=utf8", |
| 26 | "wfConfig" => "( |
| 27 | name varchar(100) PRIMARY KEY NOT NULL, |
| 28 | val longblob |
| 29 | ) default charset=utf8", |
| 30 | "wfCrawlers" => "( |
| 31 | IP INT UNSIGNED NOT NULL, |
| 32 | patternSig binary(16) NOT NULL, |
| 33 | status char(8) NOT NULL, |
| 34 | lastUpdate int UNSIGNED NOT NULL, |
| 35 | PTR varchar(255) default '', |
| 36 | PRIMARY KEY k1(IP, patternSig) |
| 37 | ) default charset=latin1", |
| 38 | "wfFileChanges" => "( |
| 39 | filenameHash char(64) NOT NULL PRIMARY KEY, |
| 40 | file varchar(1000) NOT NULL, |
| 41 | md5 char(32) NOT NULL |
| 42 | ) default charset=utf8", |
| 43 | "wfHits" => "( |
| 44 | id int UNSIGNED auto_increment PRIMARY KEY, |
| 45 | ctime DOUBLE(17,6) UNSIGNED NOT NULL, |
| 46 | IP int UNSIGNED NOT NULL, |
| 47 | jsRun tinyint default 0, |
| 48 | is404 tinyint NOT NULL, |
| 49 | isGoogle tinyint NOT NULL, |
| 50 | userID int UNSIGNED NOT NULL, |
| 51 | newVisit tinyint UNSIGNED NOT NULL, |
| 52 | URL text, |
| 53 | referer text, |
| 54 | UA text, |
| 55 | KEY k1(ctime), |
| 56 | KEY k2(IP, ctime) |
| 57 | ) default charset=latin1", |
| 58 | "wfIssues" => "( |
| 59 | id int UNSIGNED NOT NULL auto_increment PRIMARY KEY, |
| 60 | time int UNSIGNED NOT NULL, |
| 61 | status varchar(10) NOT NULL, |
| 62 | type varchar(20) NOT NULL, |
| 63 | severity tinyint UNSIGNED NOT NULL, |
| 64 | ignoreP char(32) NOT NULL, |
| 65 | ignoreC char(32) NOT NULL, |
| 66 | shortMsg varchar(255) NOT NULL, |
| 67 | longMsg text, |
| 68 | data text |
| 69 | ) default charset=utf8", |
| 70 | "wfLeechers" => "( |
| 71 | eMin int UNSIGNED NOT NULL, |
| 72 | IP int UNSIGNED NOT NULL, |
| 73 | hits int UNSIGNED NOT NULL, |
| 74 | PRIMARY KEY k1(eMin, IP) |
| 75 | ) default charset=latin1", |
| 76 | "wfLockedOut" => "( |
| 77 | IP int UNSIGNED PRIMARY KEY, |
| 78 | blockedTime int UNSIGNED NOT NULL, |
| 79 | reason varchar(255) NOT NULL, |
| 80 | lastAttempt int UNSIGNED default 0, |
| 81 | blockedHits int UNSIGNED default 0 |
| 82 | ) default charset=utf8", |
| 83 | "wfLocs" => "( |
| 84 | IP int UNSIGNED NOT NULL PRIMARY KEY, |
| 85 | ctime int UNSIGNED NOT NULL, |
| 86 | failed tinyint UNSIGNED NOT NULL, |
| 87 | city varchar(255) default '', |
| 88 | region varchar(255) default '', |
| 89 | countryName varchar(255) default '', |
| 90 | countryCode char(2) default '', |
| 91 | lat float(10,7) default 0, |
| 92 | lon float(10,7) default 0 |
| 93 | ) default charset=utf8", |
| 94 | "wfLogins" => "( |
| 95 | id int UNSIGNED auto_increment PRIMARY KEY, |
| 96 | ctime DOUBLE(17,6) UNSIGNED NOT NULL, |
| 97 | fail tinyint UNSIGNED NOT NULL, |
| 98 | action varchar(40) NOT NULL, |
| 99 | username varchar(255) NOT NULL, |
| 100 | userID int UNSIGNED NOT NULL, |
| 101 | IP int UNSIGNED NOT NULL, |
| 102 | UA text, |
| 103 | KEY k1(IP, fail) |
| 104 | ) default charset=utf8", |
| 105 | "wfReverseCache" => "( |
| 106 | IP int UNSIGNED PRIMARY KEY, |
| 107 | host varchar(255) NOT NULL, |
| 108 | lastUpdate int UNSIGNED NOT NULL |
| 109 | ) default charset=latin1", |
| 110 | "wfScanners" => "( |
| 111 | eMin int UNSIGNED NOT NULL, |
| 112 | IP int UNSIGNED NOT NULL, |
| 113 | hits smallint UNSIGNED NOT NULL, |
| 114 | PRIMARY KEY k1(eMin, IP) |
| 115 | ) default charset=latin1", |
| 116 | "wfThrottleLog" => "( |
| 117 | IP int UNSIGNED NOT NULL PRIMARY KEY, |
| 118 | startTime int UNSIGNED NOT NULL, |
| 119 | endTime int UNSIGNED NOT NULL, |
| 120 | timesThrottled int UNSIGNED NOT NULL, |
| 121 | lastReason varchar(255) NOT NULL, |
| 122 | KEY k2(endTime) |
| 123 | ) default charset=utf8", |
| 124 | "wfStatus" => "( |
| 125 | ctime DOUBLE(17,6) UNSIGNED NOT NULL, |
| 126 | level tinyint UNSIGNED NOT NULL, |
| 127 | type char(5) NOT NULL, |
| 128 | msg varchar(1000) NOT NULL, |
| 129 | KEY k1(ctime), |
| 130 | KEY k2(type) |
| 131 | ) default charset=utf8", |
| 132 | 'wfNet404s' => "( |
| 133 | sig binary(16) NOT NULL PRIMARY KEY, |
| 134 | ctime int UNSIGNED NOT NULL, |
| 135 | URI varchar(1000) NOT NULL, |
| 136 | KEY k1(ctime) |
| 137 | ) default charset=utf8", |
| 138 | 'wfHoover' => "( |
| 139 | id int UNSIGNED auto_increment PRIMARY KEY, |
| 140 | owner text, |
| 141 | host text, |
| 142 | path text, |
| 143 | hostKey binary(4), |
| 144 | KEY k2(hostKey) |
| 145 | ) default charset=utf8", |
| 146 | 'wfFileQueue' => "( |
| 147 | id int UNSIGNED NOT NULL auto_increment PRIMARY KEY, |
| 148 | filename text |
| 149 | ) default charset=utf8" |
| 150 | ); |
| 151 | private $db = false; |
| 152 | private $prefix = 'wp_'; |
| 153 | public function __construct($dbhost = false, $dbuser = false, $dbpassword = false, $dbname = false){ |
| 154 | if($dbhost){ //for testing |
| 155 | $this->db = new wfDB(false, $dbhost, $dbuser, $dbpassword, $dbname); |
| 156 | $this->prefix = 'wp_'; |
| 157 | } else { |
| 158 | global $wpdb; |
| 159 | $this->db = new wfDB(); |
| 160 | $this->prefix = $wpdb->base_prefix; |
| 161 | } |
| 162 | } |
| 163 | public function dropAll(){ |
| 164 | foreach($this->tables as $table => $def){ |
| 165 | $this->db->query("drop table if exists " . $this->prefix . $table); |
| 166 | } |
| 167 | } |
| 168 | public function createAll(){ |
| 169 | foreach($this->tables as $table => $def){ |
| 170 | $this->db->query("create table IF NOT EXISTS " . $this->prefix . $table . " " . $def); |
| 171 | } |
| 172 | } |
| 173 | public function create($table){ |
| 174 | $this->db->query("create table IF NOT EXISTS " . $this->prefix . $table . " " . $this->tables[$table]); |
| 175 | } |
| 176 | public function drop($table){ |
| 177 | $this->db->query("drop table if exists " . $this->prefix . $table); |
| 178 | } |
| 179 | } |
| 180 | ?> |
| 181 |