Diff
14 years ago
whois
12 years ago
.htaccess
14 years ago
Diff.php
14 years ago
GeoIP.dat
11 years ago
IPTraf.php
11 years ago
conntest.php
11 years ago
dashboard.php
11 years ago
diffResult.php
11 years ago
email_genericAlert.php
11 years ago
email_newIssues.php
11 years ago
email_unlockRequest.php
11 years ago
menuHeader.php
11 years ago
menu_activity.php
11 years ago
menu_blockedIPs.php
11 years ago
menu_countryBlocking.php
11 years ago
menu_options.php
11 years ago
menu_rangeBlocking.php
11 years ago
menu_scan.php
11 years ago
menu_scanSchedule.php
11 years ago
menu_sitePerf.php
11 years ago
menu_sitePerfStats.php
11 years ago
menu_twoFactor.php
11 years ago
menu_whois.php
11 years ago
pageTitle.php
13 years ago
schedWeekEntry.php
12 years ago
sysinfo.php
11 years ago
unknownFiles.php
11 years ago
viewFullActivityLog.php
11 years ago
wf503.php
12 years ago
wfAPI.php
11 years ago
wfAction.php
14 years ago
wfArray.php
13 years ago
wfBrowscap.php
11 years ago
wfBrowscapCache.php
11 years ago
wfBulkCountries.php
13 years ago
wfCache.php
11 years ago
wfConfig.php
11 years ago
wfCountryMap.php
13 years ago
wfCrawl.php
11 years ago
wfDB.php
11 years ago
wfDict.php
14 years ago
wfGeoIP.php
13 years ago
wfIssues.php
11 years ago
wfLockedOut.php
13 years ago
wfLog.php
11 years ago
wfRate.php
14 years ago
wfScan.php
11 years ago
wfScanEngine.php
11 years ago
wfSchema.php
11 years ago
wfUnlockMsg.php
11 years ago
wfUtils.php
11 years ago
wfViewResult.php
11 years ago
wordfenceClass.php
11 years ago
wordfenceConstants.php
11 years ago
wordfenceHash.php
11 years ago
wordfenceScanner.php
11 years ago
wordfenceURLHoover.php
11 years ago
wfSchema.php
216 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 | id bigint UNSIGNED NOT NULL auto_increment PRIMARY KEY, |
| 126 | ctime DOUBLE(17,6) UNSIGNED NOT NULL, |
| 127 | level tinyint UNSIGNED NOT NULL, |
| 128 | type char(5) NOT NULL, |
| 129 | msg varchar(1000) NOT NULL, |
| 130 | KEY k1(ctime), |
| 131 | KEY k2(type) |
| 132 | ) default charset=utf8", |
| 133 | 'wfNet404s' => "( |
| 134 | sig binary(16) NOT NULL PRIMARY KEY, |
| 135 | ctime int UNSIGNED NOT NULL, |
| 136 | URI varchar(1000) NOT NULL, |
| 137 | KEY k1(ctime) |
| 138 | ) default charset=utf8", |
| 139 | 'wfHoover' => "( |
| 140 | id int UNSIGNED auto_increment PRIMARY KEY, |
| 141 | owner text, |
| 142 | host text, |
| 143 | path text, |
| 144 | hostKey binary(4), |
| 145 | KEY k2(hostKey) |
| 146 | ) default charset=utf8", |
| 147 | 'wfFileMods' => "( |
| 148 | filenameMD5 binary(16) NOT NULL PRIMARY KEY, |
| 149 | filename varchar(1000) NOT NULL, |
| 150 | knownFile tinyint UNSIGNED NOT NULL, |
| 151 | oldMD5 binary(16) NOT NULL, |
| 152 | newMD5 binary(16) NOT NULL |
| 153 | ) default charset=utf8", |
| 154 | 'wfBlocksAdv' => "( |
| 155 | id int UNSIGNED NOT NULL auto_increment PRIMARY KEY, |
| 156 | blockType char(2) NOT NULL, |
| 157 | blockString varchar(255) NOT NULL, |
| 158 | ctime int UNSIGNED NOT NULL, |
| 159 | reason varchar(255) NOT NULL, |
| 160 | totalBlocked int UNSIGNED default 0, |
| 161 | lastBlocked int UNSIGNED default 0 |
| 162 | ) default charset=utf8" |
| 163 | /* |
| 164 | 'wfPerfLog' => "( |
| 165 | id int UNSIGNED NOT NULL auto_increment PRIMARY KEY, |
| 166 | IP int UNSIGNED NOT NULL, |
| 167 | userID int UNSIGNED NOT NULL, |
| 168 | UA varchar(1000) NOT NULL, |
| 169 | URL varchar(1000) NOT NULL, |
| 170 | ctime int UNSIGNED NOT NULL, |
| 171 | fetchStart int UNSIGNED NOT NULL, |
| 172 | domainLookupStart int UNSIGNED NOT NULL, |
| 173 | domainLookupEnd int UNSIGNED NOT NULL, |
| 174 | connectStart int UNSIGNED NOT NULL, |
| 175 | connectEnd int UNSIGNED NOT NULL, |
| 176 | requestStart int UNSIGNED NOT NULL, |
| 177 | responseStart int UNSIGNED NOT NULL, |
| 178 | responseEnd int UNSIGNED NOT NULL, |
| 179 | domReady int UNSIGNED NOT NULL, |
| 180 | loaded int UNSIGNED NOT NULL, |
| 181 | KEY k1(ctime) |
| 182 | ) default charset=utf8" |
| 183 | */ |
| 184 | ); |
| 185 | private $db = false; |
| 186 | private $prefix = 'wp_'; |
| 187 | public function __construct($dbhost = false, $dbuser = false, $dbpassword = false, $dbname = false){ |
| 188 | /* |
| 189 | if($dbhost){ //for testing |
| 190 | $this->db = new wfDB(false, $dbhost, $dbuser, $dbpassword, $dbname); |
| 191 | $this->prefix = 'wp_'; |
| 192 | } else { |
| 193 | */ |
| 194 | global $wpdb; |
| 195 | $this->db = new wfDB(); |
| 196 | $this->prefix = $wpdb->base_prefix; |
| 197 | } |
| 198 | public function dropAll(){ |
| 199 | foreach($this->tables as $table => $def){ |
| 200 | $this->db->queryWrite("drop table if exists " . $this->prefix . $table); |
| 201 | } |
| 202 | } |
| 203 | public function createAll(){ |
| 204 | foreach($this->tables as $table => $def){ |
| 205 | $this->db->queryWrite("create table IF NOT EXISTS " . $this->prefix . $table . " " . $def); |
| 206 | } |
| 207 | } |
| 208 | public function create($table){ |
| 209 | $this->db->queryWrite("create table IF NOT EXISTS " . $this->prefix . $table . " " . $this->tables[$table]); |
| 210 | } |
| 211 | public function drop($table){ |
| 212 | $this->db->queryWrite("drop table if exists " . $this->prefix . $table); |
| 213 | } |
| 214 | } |
| 215 | ?> |
| 216 |