PluginProbe ʕ •ᴥ•ʔ
Wordfence Security – Firewall, Malware Scan, and Login Security / 7.2.4
Wordfence Security – Firewall, Malware Scan, and Login Security v7.2.4
8.2.2 8.2.1 8.2.0 3.7.1 3.7.2 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.8.8 3.8.9 3.9.1 4.0.1 4.0.2 4.0.3 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.1 5.1.2 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.1 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.1 5.3.10 5.3.11 5.3.12 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 6.0.1 6.0.10 6.0.11 6.0.12 6.0.14 6.0.15 6.0.16 6.0.17 6.0.18 6.0.19 6.0.2 6.0.20 6.0.21 6.0.22 6.0.23 6.0.24 6.0.25 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.1 6.1.10 6.1.11 6.1.12 6.1.14 6.1.15 6.1.16 6.1.17 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.10 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.2.9 6.3.0 6.3.1 6.3.10 6.3.11 6.3.12 6.3.14 6.3.15 6.3.16 6.3.17 6.3.18 6.3.19 6.3.2 6.3.20 6.3.21 6.3.22 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.3.8 6.3.9 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.14 7.1.15 7.1.16 7.1.17 7.1.18 7.1.19 7.1.2 7.1.20 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.10.0 7.10.1 7.10.2 7.10.3 7.10.4 7.10.5 7.10.6 7.10.7 7.11.0 7.11.1 7.11.2 7.11.3 7.11.4 7.11.5 7.11.6 7.11.7 7.2.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.4.0 7.4.1 7.4.10 7.4.11 7.4.12 7.4.14 7.4.2 7.4.3 trunk 7.4.4 1.1 7.4.5 1.2 7.4.6 1.3 7.4.7 1.3.1 7.4.8 1.3.2 7.4.9 1.3.3 7.5.0 1.4.2 7.5.1 1.4.3 7.5.10 1.4.4 7.5.11 1.4.5 7.5.2 1.4.6 7.5.3 1.4.7 7.5.4 1.4.8 7.5.5 1.5.1 7.5.6 1.5.2 7.5.7 1.5.3 7.5.8 1.5.4 7.5.9 1.5.5 7.6.0 1.5.6 7.6.1 2.0.1 7.6.2 2.0.2 7.7.0 2.0.3 7.7.1 2.0.5 7.8.0 2.0.6 7.8.1 2.0.7 7.8.2 2.1.0 7.9.0 2.1.1 7.9.1 2.1.2 7.9.2 2.1.3 7.9.3 2.1.4 8.0.0 2.1.5 8.0.1 3.0.2 8.0.2 3.0.3 8.0.3 3.0.4 8.0.4 3.0.5 8.0.5 3.0.6 8.1.0 3.0.7 8.1.1 3.0.8 8.1.2 3.0.9 8.1.3 3.1.0 8.1.4 3.1.1 v1.4.1 3.1.2 3.1.4 3.1.6 3.2.1 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.1 3.4.4 3.4.5 3.5.1 3.5.2 3.6.1 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
wordfence / lib / wfSchema.php
wordfence / lib Last commit date
Diff 8 years ago dashboard 7 years ago rest-api 7 years ago .htaccess 7 years ago Diff.php 14 years ago GeoLite2-Country.mmdb 7 years ago IPTraf.php 8 years ago IPTrafList.php 7 years ago compat.php 8 years ago conntest.php 7 years ago cronview.php 8 years ago dbview.php 8 years ago diffResult.php 8 years ago email_genericAlert.php 7 years ago email_newIssues.php 7 years ago email_unlockRequest.php 8 years ago email_unsubscribeRequest.php 7 years ago flags.php 7 years ago live_activity.php 8 years ago menu_dashboard.php 7 years ago menu_dashboard_options.php 7 years ago menu_firewall.php 7 years ago menu_firewall_blocking.php 7 years ago menu_firewall_blocking_options.php 8 years ago menu_firewall_waf.php 7 years ago menu_firewall_waf_options.php 7 years ago menu_options.php 7 years ago menu_scanner.php 7 years ago menu_scanner_credentials.php 8 years ago menu_scanner_options.php 8 years ago menu_support.php 7 years ago menu_tools.php 7 years ago menu_tools_diagnostic.php 7 years ago menu_tools_importExport.php 7 years ago menu_tools_livetraffic.php 7 years ago menu_tools_twoFactor.php 8 years ago menu_tools_whois.php 8 years ago menu_wordfence_central.php 7 years ago sysinfo.php 8 years ago unknownFiles.php 8 years ago viewFullActivityLog.php 8 years ago wf503.php 7 years ago wfAPI.php 7 years ago wfActivityReport.php 7 years ago wfAdminNoticeQueue.php 8 years ago wfArray.php 7 years ago wfBrowscap.php 8 years ago wfBrowscapCache.php 7 years ago wfBulkCountries.php 7 years ago wfCache.php 9 years ago wfCentralAPI.php 7 years ago wfConfig.php 7 years ago wfCrawl.php 8 years ago wfCredentialsController.php 7 years ago wfCrypt.php 8 years ago wfDB.php 7 years ago wfDashboard.php 7 years ago wfDateLocalization.php 8 years ago wfDiagnostic.php 7 years ago wfDict.php 8 years ago wfDirectoryIterator.php 7 years ago wfHelperBin.php 11 years ago wfHelperString.php 11 years ago wfIPWhitelist.php 7 years ago wfImportExportController.php 7 years ago wfIssues.php 7 years ago wfJWT.php 7 years ago wfLockedOut.php 7 years ago wfLog.php 7 years ago wfMD5BloomFilter.php 8 years ago wfNotification.php 8 years ago wfOnboardingController.php 7 years ago wfPersistenceController.php 8 years ago wfRESTAPI.php 7 years ago wfScan.php 7 years ago wfScanEngine.php 7 years ago wfSchema.php 7 years ago wfStyle.php 8 years ago wfSupportController.php 7 years ago wfUnlockMsg.php 7 years ago wfUpdateCheck.php 8 years ago wfUtils.php 7 years ago wfVersionCheckController.php 8 years ago wfView.php 10 years ago wfViewResult.php 8 years ago wordfenceClass.php 7 years ago wordfenceConstants.php 7 years ago wordfenceHash.php 7 years ago wordfenceScanner.php 7 years ago wordfenceURLHoover.php 7 years ago
wfSchema.php
317 lines
1 <?php
2 require_once('wfDB.php');
3 class wfSchema {
4 const TABLE_CASE_OPTION = 'wordfence_case'; //false is camel case, true is lower
5
6 private static $_usingLowercase = null;
7 private static $deprecatedTables = array(
8 'wfBlocks',
9 'wfBlocksAdv',
10 'wfLockedOut',
11 'wfThrottleLog',
12 'wfNet404s',
13 'wfBlockedCommentLog',
14 'wfVulnScanners',
15 'wfBadLeechers',
16 'wfLeechers',
17 'wfScanners',
18 );
19
20 private static $tables = array(
21 "wfBlocks7" => "(
22 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
23 `type` int(10) unsigned NOT NULL DEFAULT '0',
24 `IP` binary(16) NOT NULL DEFAULT '\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0',
25 `blockedTime` bigint(20) NOT NULL,
26 `reason` varchar(255) NOT NULL,
27 `lastAttempt` int(10) unsigned DEFAULT '0',
28 `blockedHits` int(10) unsigned DEFAULT '0',
29 `expiration` bigint(20) unsigned NOT NULL DEFAULT '0',
30 `parameters` text,
31 PRIMARY KEY (`id`),
32 KEY `type` (`type`),
33 KEY `IP` (`IP`),
34 KEY `expiration` (`expiration`)
35 ) DEFAULT CHARSET=utf8",
36 "wfConfig" => "(
37 `name` varchar(100) NOT NULL,
38 `val` longblob,
39 `autoload` enum('no','yes') NOT NULL DEFAULT 'yes',
40 PRIMARY KEY (`name`)
41 ) DEFAULT CHARSET=utf8",
42 "wfCrawlers" => "(
43 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
44 `patternSig` binary(16) NOT NULL,
45 `status` char(8) NOT NULL,
46 `lastUpdate` int(10) unsigned NOT NULL,
47 `PTR` varchar(255) DEFAULT '',
48 PRIMARY KEY (`IP`,`patternSig`)
49 ) DEFAULT CHARSET=utf8",
50 "wfFileChanges" => "(
51 `filenameHash` char(64) NOT NULL,
52 `file` varchar(1000) NOT NULL,
53 `md5` char(32) NOT NULL,
54 PRIMARY KEY (`filenameHash`)
55 ) CHARSET=utf8",
56 "wfHits" => "(
57 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
58 `attackLogTime` double(17,6) unsigned NOT NULL,
59 `ctime` double(17,6) unsigned NOT NULL,
60 `IP` binary(16) DEFAULT NULL,
61 `jsRun` tinyint(4) DEFAULT '0',
62 `statusCode` int(11) NOT NULL DEFAULT '200',
63 `isGoogle` tinyint(4) NOT NULL,
64 `userID` int(10) unsigned NOT NULL,
65 `newVisit` tinyint(3) unsigned NOT NULL,
66 `URL` text,
67 `referer` text,
68 `UA` text,
69 `action` varchar(64) NOT NULL DEFAULT '',
70 `actionDescription` text,
71 `actionData` text,
72 PRIMARY KEY (`id`),
73 KEY `k1` (`ctime`),
74 KEY `k2` (`IP`,`ctime`),
75 KEY `attackLogTime` (`attackLogTime`)
76 ) DEFAULT CHARSET=utf8",
77 "wfIssues" => "(
78 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
79 `time` int(10) unsigned NOT NULL,
80 `lastUpdated` int(10) unsigned NOT NULL,
81 `status` varchar(10) NOT NULL,
82 `type` varchar(20) NOT NULL,
83 `severity` tinyint(3) unsigned NOT NULL,
84 `ignoreP` char(32) NOT NULL,
85 `ignoreC` char(32) NOT NULL,
86 `shortMsg` varchar(255) NOT NULL,
87 `longMsg` text,
88 `data` text,
89 PRIMARY KEY (`id`),
90 KEY `lastUpdated` (`lastUpdated`),
91 KEY `status` (`status`),
92 KEY `ignoreP` (`ignoreP`),
93 KEY `ignoreC` (`ignoreC`)
94 ) DEFAULT CHARSET=utf8",
95 "wfPendingIssues" => "(
96 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
97 `time` int(10) unsigned NOT NULL,
98 `lastUpdated` int(10) unsigned NOT NULL,
99 `status` varchar(10) NOT NULL,
100 `type` varchar(20) NOT NULL,
101 `severity` tinyint(3) unsigned NOT NULL,
102 `ignoreP` char(32) NOT NULL,
103 `ignoreC` char(32) NOT NULL,
104 `shortMsg` varchar(255) NOT NULL,
105 `longMsg` text,
106 `data` text,
107 PRIMARY KEY (`id`),
108 KEY `lastUpdated` (`lastUpdated`),
109 KEY `status` (`status`),
110 KEY `ignoreP` (`ignoreP`),
111 KEY `ignoreC` (`ignoreC`)
112 ) DEFAULT CHARSET=utf8",
113 "wfTrafficRates" => "(
114 `eMin` int(10) unsigned NOT NULL,
115 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
116 `hitType` enum('hit','404') NOT NULL DEFAULT 'hit',
117 `hits` int(10) unsigned NOT NULL,
118 PRIMARY KEY (`eMin`,`IP`,`hitType`)
119 ) DEFAULT CHARSET=utf8",
120 "wfLocs" => "(
121 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
122 `ctime` int(10) unsigned NOT NULL,
123 `failed` tinyint(3) unsigned NOT NULL,
124 `city` varchar(255) DEFAULT '',
125 `region` varchar(255) DEFAULT '',
126 `countryName` varchar(255) DEFAULT '',
127 `countryCode` char(2) DEFAULT '',
128 `lat` float(10,7) DEFAULT '0.0000000',
129 `lon` float(10,7) DEFAULT '0.0000000',
130 PRIMARY KEY (`IP`)
131 ) DEFAULT CHARSET=utf8",
132 "wfLogins" => "(
133 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
134 `hitID` int(11) DEFAULT NULL,
135 `ctime` double(17,6) unsigned NOT NULL,
136 `fail` tinyint(3) unsigned NOT NULL,
137 `action` varchar(40) NOT NULL,
138 `username` varchar(255) NOT NULL,
139 `userID` int(10) unsigned NOT NULL,
140 `IP` binary(16) DEFAULT NULL,
141 `UA` text,
142 PRIMARY KEY (`id`),
143 KEY `k1` (`IP`,`fail`),
144 KEY `hitID` (`hitID`)
145 ) DEFAULT CHARSET=utf8",
146 "wfReverseCache" => "(
147 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
148 `host` varchar(255) NOT NULL,
149 `lastUpdate` int(10) unsigned NOT NULL,
150 PRIMARY KEY (`IP`)
151 ) DEFAULT CHARSET=utf8",
152 "wfStatus" => "(
153 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
154 `ctime` double(17,6) unsigned NOT NULL,
155 `level` tinyint(3) unsigned NOT NULL,
156 `type` char(5) NOT NULL,
157 `msg` varchar(1000) NOT NULL,
158 PRIMARY KEY (`id`),
159 KEY `k1` (`ctime`),
160 KEY `k2` (`type`)
161 ) DEFAULT CHARSET=utf8",
162 'wfHoover' => "(
163 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
164 `owner` text,
165 `host` text,
166 `path` text,
167 `hostKey` varbinary(124) DEFAULT NULL,
168 PRIMARY KEY (`id`),
169 KEY `k2` (`hostKey`)
170 ) DEFAULT CHARSET=utf8",
171 'wfFileMods' => "(
172 `filenameMD5` binary(16) NOT NULL,
173 `filename` varchar(1000) NOT NULL,
174 `knownFile` tinyint(3) unsigned NOT NULL,
175 `oldMD5` binary(16) NOT NULL,
176 `newMD5` binary(16) NOT NULL,
177 `SHAC` binary(32) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
178 `stoppedOnSignature` varchar(255) NOT NULL DEFAULT '',
179 `stoppedOnPosition` int(10) unsigned NOT NULL DEFAULT '0',
180 `isSafeFile` varchar(1) NOT NULL DEFAULT '?',
181 PRIMARY KEY (`filenameMD5`)
182 ) DEFAULT CHARSET=utf8",
183 'wfBlockedIPLog' => "(
184 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
185 `countryCode` varchar(2) NOT NULL,
186 `blockCount` int(10) unsigned NOT NULL DEFAULT '0',
187 `unixday` int(10) unsigned NOT NULL,
188 `blockType` varchar(50) NOT NULL DEFAULT 'generic',
189 PRIMARY KEY (`IP`,`unixday`,`blockType`)
190 ) DEFAULT CHARSET=utf8",
191 'wfSNIPCache' => "(
192 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
193 `IP` varchar(45) NOT NULL DEFAULT '',
194 `expiration` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
195 `body` varchar(255) NOT NULL DEFAULT '',
196 `count` int(10) unsigned NOT NULL DEFAULT '0',
197 `type` int(10) unsigned NOT NULL DEFAULT '0',
198 PRIMARY KEY (`id`),
199 KEY `expiration` (`expiration`),
200 KEY `IP` (`IP`),
201 KEY `type` (`type`)
202 ) DEFAULT CHARSET=utf8",
203 'wfKnownFileList' => "(
204 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
205 `path` text NOT NULL,
206 PRIMARY KEY (`id`)
207 ) DEFAULT CHARSET=utf8",
208 'wfNotifications' => "(
209 `id` varchar(32) NOT NULL DEFAULT '',
210 `new` tinyint(3) unsigned NOT NULL DEFAULT '1',
211 `category` varchar(255) NOT NULL,
212 `priority` int(11) NOT NULL DEFAULT '1000',
213 `ctime` int(10) unsigned NOT NULL,
214 `html` text NOT NULL,
215 `links` text NOT NULL,
216 PRIMARY KEY (`id`)
217 ) DEFAULT CHARSET=utf8;",
218 'wfLiveTrafficHuman' => "(
219 `IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
220 `identifier` binary(32) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
221 `expiration` int(10) unsigned NOT NULL,
222 PRIMARY KEY (`IP`,`identifier`),
223 KEY `expiration` (`expiration`)
224 ) DEFAULT CHARSET=utf8;",
225 /*
226 'wfPerfLog' => "(
227 id int UNSIGNED NOT NULL auto_increment PRIMARY KEY,
228 IP int UNSIGNED NOT NULL,
229 userID int UNSIGNED NOT NULL,
230 UA varchar(1000) NOT NULL,
231 URL varchar(1000) NOT NULL,
232 ctime int UNSIGNED NOT NULL,
233 fetchStart int UNSIGNED NOT NULL,
234 domainLookupStart int UNSIGNED NOT NULL,
235 domainLookupEnd int UNSIGNED NOT NULL,
236 connectStart int UNSIGNED NOT NULL,
237 connectEnd int UNSIGNED NOT NULL,
238 requestStart int UNSIGNED NOT NULL,
239 responseStart int UNSIGNED NOT NULL,
240 responseEnd int UNSIGNED NOT NULL,
241 domReady int UNSIGNED NOT NULL,
242 loaded int UNSIGNED NOT NULL,
243 KEY k1(ctime)
244 ) default charset=utf8"
245 */
246 );
247 private $db = false;
248 public function __construct($dbhost = false, $dbuser = false, $dbpassword = false, $dbname = false){
249 $this->db = new wfDB();
250 }
251 public function dropAll(){
252 foreach(self::$tables as $table => $def) {
253 $originalTable = wfDB::networkPrefix() . $table;
254 $convertedTable = wfDB::networkPrefix() . strtolower($table);
255
256 $this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
257 $this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
258 }
259
260 foreach (self::$deprecatedTables as $table) {
261 $originalTable = wfDB::networkTable($table, false);
262 $convertedTable = wfDB::networkTable($table);
263
264 $this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
265 if ($originalTable !== $convertedTable) {
266 $this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
267 }
268 }
269 }
270 public function createAll() {
271 foreach(self::$tables as $table => $def){
272 $this->db->queryWrite("CREATE TABLE IF NOT EXISTS " . wfDB::networkTable($table) . " " . $def);
273 }
274 }
275 public function create($table) {
276 $this->db->queryWrite("CREATE TABLE IF NOT EXISTS " . wfDB::networkTable($table) . " " . self::$tables[$table]);
277 }
278 public function drop($table) {
279 $originalTable = wfDB::networkTable($table, false);
280 $convertedTable = wfDB::networkTable($table);
281
282 $this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
283 if ($originalTable !== $convertedTable) {
284 $this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
285 }
286 }
287
288 public static function tableList() {
289 return array_keys(self::$tables);
290 }
291
292 public static function updateTableCase() {
293 global $wpdb;
294 $hasCamelCaseTable = !!$wpdb->get_var($wpdb->prepare('SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=%s', wfDB::networkTable('wfConfig', false)));
295 if (is_multisite() && function_exists('update_network_option')) {
296 update_network_option(null, self::TABLE_CASE_OPTION, !$hasCamelCaseTable);
297 self::$_usingLowercase = !$hasCamelCaseTable;
298 }
299 else {
300 update_option(self::TABLE_CASE_OPTION, !$hasCamelCaseTable);
301 self::$_usingLowercase = !$hasCamelCaseTable;
302 }
303 }
304
305 public static function usingLowercase() {
306 if (self::$_usingLowercase === null) {
307 if (is_multisite() && function_exists('update_network_option')) {
308 self::$_usingLowercase = !!get_network_option(null, self::TABLE_CASE_OPTION);
309 }
310 else {
311 self::$_usingLowercase = !!get_option(self::TABLE_CASE_OPTION);
312 }
313 }
314 return self::$_usingLowercase;
315 }
316 }
317