Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wfSchema.php
<?php
[0] Fix | Delete
require_once(dirname(__FILE__) . '/wfDB.php');
[1] Fix | Delete
class wfSchema {
[2] Fix | Delete
const TABLE_CASE_OPTION = 'wordfence_case'; //false is camel case, true is lower
[3] Fix | Delete
[4] Fix | Delete
private static $_usingLowercase = null;
[5] Fix | Delete
private static $deprecatedTables = array(
[6] Fix | Delete
'wfBlocks',
[7] Fix | Delete
'wfBlocksAdv',
[8] Fix | Delete
'wfLockedOut',
[9] Fix | Delete
'wfThrottleLog',
[10] Fix | Delete
'wfNet404s',
[11] Fix | Delete
'wfBlockedCommentLog',
[12] Fix | Delete
'wfVulnScanners',
[13] Fix | Delete
'wfBadLeechers',
[14] Fix | Delete
'wfLeechers',
[15] Fix | Delete
'wfScanners',
[16] Fix | Delete
);
[17] Fix | Delete
[18] Fix | Delete
private static $tables = array(
[19] Fix | Delete
"wfSecurityEvents" => "(
[20] Fix | Delete
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
[21] Fix | Delete
`type` varchar(255) NOT NULL DEFAULT '',
[22] Fix | Delete
`data` text NOT NULL,
[23] Fix | Delete
`event_time` double(14,4) NOT NULL,
[24] Fix | Delete
`state` enum('new','sending','sent') NOT NULL DEFAULT 'new',
[25] Fix | Delete
`state_timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
[26] Fix | Delete
PRIMARY KEY (`id`)
[27] Fix | Delete
) DEFAULT CHARSET=utf8",
[28] Fix | Delete
"wfBlocks7" => "(
[29] Fix | Delete
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
[30] Fix | Delete
`type` int(10) unsigned NOT NULL DEFAULT '0',
[31] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0\\\0',
[32] Fix | Delete
`blockedTime` bigint(20) NOT NULL,
[33] Fix | Delete
`reason` varchar(255) NOT NULL,
[34] Fix | Delete
`lastAttempt` int(10) unsigned DEFAULT '0',
[35] Fix | Delete
`blockedHits` int(10) unsigned DEFAULT '0',
[36] Fix | Delete
`expiration` bigint(20) unsigned NOT NULL DEFAULT '0',
[37] Fix | Delete
`parameters` text,
[38] Fix | Delete
PRIMARY KEY (`id`),
[39] Fix | Delete
KEY `type` (`type`),
[40] Fix | Delete
KEY `IP` (`IP`),
[41] Fix | Delete
KEY `expiration` (`expiration`)
[42] Fix | Delete
) DEFAULT CHARSET=utf8",
[43] Fix | Delete
"wfConfig" => "(
[44] Fix | Delete
`name` varchar(100) NOT NULL,
[45] Fix | Delete
`val` longblob,
[46] Fix | Delete
`autoload` enum('no','yes') NOT NULL DEFAULT 'yes',
[47] Fix | Delete
PRIMARY KEY (`name`)
[48] Fix | Delete
) DEFAULT CHARSET=utf8",
[49] Fix | Delete
"wfCrawlers" => "(
[50] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[51] Fix | Delete
`patternSig` binary(16) NOT NULL,
[52] Fix | Delete
`status` char(8) NOT NULL,
[53] Fix | Delete
`lastUpdate` int(10) unsigned NOT NULL,
[54] Fix | Delete
`PTR` varchar(255) DEFAULT '',
[55] Fix | Delete
PRIMARY KEY (`IP`,`patternSig`)
[56] Fix | Delete
) DEFAULT CHARSET=utf8",
[57] Fix | Delete
"wfFileChanges" => "(
[58] Fix | Delete
`filenameHash` char(64) NOT NULL,
[59] Fix | Delete
`file` varchar(1000) NOT NULL,
[60] Fix | Delete
`md5` char(32) NOT NULL,
[61] Fix | Delete
PRIMARY KEY (`filenameHash`)
[62] Fix | Delete
) CHARSET=utf8",
[63] Fix | Delete
"wfHits" => "(
[64] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[65] Fix | Delete
`attackLogTime` double(17,6) unsigned NOT NULL,
[66] Fix | Delete
`ctime` double(17,6) unsigned NOT NULL,
[67] Fix | Delete
`IP` binary(16) DEFAULT NULL,
[68] Fix | Delete
`jsRun` tinyint(4) DEFAULT '0',
[69] Fix | Delete
`statusCode` int(11) NOT NULL DEFAULT '200',
[70] Fix | Delete
`isGoogle` tinyint(4) NOT NULL,
[71] Fix | Delete
`userID` int(10) unsigned NOT NULL,
[72] Fix | Delete
`newVisit` tinyint(3) unsigned NOT NULL,
[73] Fix | Delete
`URL` text,
[74] Fix | Delete
`referer` text,
[75] Fix | Delete
`UA` text,
[76] Fix | Delete
`action` varchar(64) NOT NULL DEFAULT '',
[77] Fix | Delete
`actionDescription` text,
[78] Fix | Delete
`actionData` text,
[79] Fix | Delete
PRIMARY KEY (`id`),
[80] Fix | Delete
KEY `k1` (`ctime`),
[81] Fix | Delete
KEY `k2` (`IP`,`ctime`),
[82] Fix | Delete
KEY `attackLogTime` (`attackLogTime`)
[83] Fix | Delete
) DEFAULT CHARSET=utf8",
[84] Fix | Delete
"wfIssues" => "(
[85] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[86] Fix | Delete
`time` int(10) unsigned NOT NULL,
[87] Fix | Delete
`lastUpdated` int(10) unsigned NOT NULL,
[88] Fix | Delete
`status` varchar(10) NOT NULL,
[89] Fix | Delete
`type` varchar(20) NOT NULL,
[90] Fix | Delete
`severity` tinyint(3) unsigned NOT NULL,
[91] Fix | Delete
`ignoreP` char(32) NOT NULL,
[92] Fix | Delete
`ignoreC` char(32) NOT NULL,
[93] Fix | Delete
`shortMsg` varchar(255) NOT NULL,
[94] Fix | Delete
`longMsg` text,
[95] Fix | Delete
`data` text,
[96] Fix | Delete
PRIMARY KEY (`id`),
[97] Fix | Delete
KEY `lastUpdated` (`lastUpdated`),
[98] Fix | Delete
KEY `status` (`status`),
[99] Fix | Delete
KEY `ignoreP` (`ignoreP`),
[100] Fix | Delete
KEY `ignoreC` (`ignoreC`)
[101] Fix | Delete
) DEFAULT CHARSET=utf8",
[102] Fix | Delete
"wfPendingIssues" => "(
[103] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[104] Fix | Delete
`time` int(10) unsigned NOT NULL,
[105] Fix | Delete
`lastUpdated` int(10) unsigned NOT NULL,
[106] Fix | Delete
`status` varchar(10) NOT NULL,
[107] Fix | Delete
`type` varchar(20) NOT NULL,
[108] Fix | Delete
`severity` tinyint(3) unsigned NOT NULL,
[109] Fix | Delete
`ignoreP` char(32) NOT NULL,
[110] Fix | Delete
`ignoreC` char(32) NOT NULL,
[111] Fix | Delete
`shortMsg` varchar(255) NOT NULL,
[112] Fix | Delete
`longMsg` text,
[113] Fix | Delete
`data` text,
[114] Fix | Delete
PRIMARY KEY (`id`),
[115] Fix | Delete
KEY `lastUpdated` (`lastUpdated`),
[116] Fix | Delete
KEY `status` (`status`),
[117] Fix | Delete
KEY `ignoreP` (`ignoreP`),
[118] Fix | Delete
KEY `ignoreC` (`ignoreC`)
[119] Fix | Delete
) DEFAULT CHARSET=utf8",
[120] Fix | Delete
"wfTrafficRates" => "(
[121] Fix | Delete
`eMin` int(10) unsigned NOT NULL,
[122] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[123] Fix | Delete
`hitType` enum('hit','404') NOT NULL DEFAULT 'hit',
[124] Fix | Delete
`hits` int(10) unsigned NOT NULL,
[125] Fix | Delete
PRIMARY KEY (`eMin`,`IP`,`hitType`)
[126] Fix | Delete
) DEFAULT CHARSET=utf8",
[127] Fix | Delete
"wfLocs" => "(
[128] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[129] Fix | Delete
`ctime` int(10) unsigned NOT NULL,
[130] Fix | Delete
`failed` tinyint(3) unsigned NOT NULL,
[131] Fix | Delete
`city` varchar(255) DEFAULT '',
[132] Fix | Delete
`region` varchar(255) DEFAULT '',
[133] Fix | Delete
`countryName` varchar(255) DEFAULT '',
[134] Fix | Delete
`countryCode` char(2) DEFAULT '',
[135] Fix | Delete
`lat` float(10,7) DEFAULT '0.0000000',
[136] Fix | Delete
`lon` float(10,7) DEFAULT '0.0000000',
[137] Fix | Delete
PRIMARY KEY (`IP`)
[138] Fix | Delete
) DEFAULT CHARSET=utf8",
[139] Fix | Delete
"wfLogins" => "(
[140] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[141] Fix | Delete
`hitID` int(11) DEFAULT NULL,
[142] Fix | Delete
`ctime` double(17,6) unsigned NOT NULL,
[143] Fix | Delete
`fail` tinyint(3) unsigned NOT NULL,
[144] Fix | Delete
`action` varchar(40) NOT NULL,
[145] Fix | Delete
`username` varchar(255) NOT NULL,
[146] Fix | Delete
`userID` int(10) unsigned NOT NULL,
[147] Fix | Delete
`IP` binary(16) DEFAULT NULL,
[148] Fix | Delete
`UA` text,
[149] Fix | Delete
PRIMARY KEY (`id`),
[150] Fix | Delete
KEY `k1` (`IP`,`fail`),
[151] Fix | Delete
KEY `hitID` (`hitID`)
[152] Fix | Delete
) DEFAULT CHARSET=utf8",
[153] Fix | Delete
"wfReverseCache" => "(
[154] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[155] Fix | Delete
`host` varchar(255) NOT NULL,
[156] Fix | Delete
`lastUpdate` int(10) unsigned NOT NULL,
[157] Fix | Delete
PRIMARY KEY (`IP`)
[158] Fix | Delete
) DEFAULT CHARSET=utf8",
[159] Fix | Delete
"wfStatus" => "(
[160] Fix | Delete
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
[161] Fix | Delete
`ctime` double(17,6) unsigned NOT NULL,
[162] Fix | Delete
`level` tinyint(3) unsigned NOT NULL,
[163] Fix | Delete
`type` char(5) NOT NULL,
[164] Fix | Delete
`msg` varchar(1000) NOT NULL,
[165] Fix | Delete
PRIMARY KEY (`id`),
[166] Fix | Delete
KEY `k1` (`ctime`),
[167] Fix | Delete
KEY `k2` (`type`)
[168] Fix | Delete
) DEFAULT CHARSET=utf8",
[169] Fix | Delete
'wfHoover' => "(
[170] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[171] Fix | Delete
`owner` text,
[172] Fix | Delete
`host` text,
[173] Fix | Delete
`path` text,
[174] Fix | Delete
`hostKey` varbinary(124) DEFAULT NULL,
[175] Fix | Delete
PRIMARY KEY (`id`),
[176] Fix | Delete
KEY `k2` (`hostKey`)
[177] Fix | Delete
) DEFAULT CHARSET=utf8",
[178] Fix | Delete
'wfFileMods' => "(
[179] Fix | Delete
`filenameMD5` binary(16) NOT NULL,
[180] Fix | Delete
`filename` varchar(1000) NOT NULL,
[181] Fix | Delete
`knownFile` tinyint(3) unsigned NOT NULL,
[182] Fix | Delete
`oldMD5` binary(16) NOT NULL DEFAULT '',
[183] Fix | Delete
`newMD5` binary(16) NOT NULL,
[184] Fix | Delete
`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',
[185] Fix | Delete
`stoppedOnSignature` varchar(255) NOT NULL DEFAULT '',
[186] Fix | Delete
`stoppedOnPosition` int(10) unsigned NOT NULL DEFAULT '0',
[187] Fix | Delete
`isSafeFile` varchar(1) NOT NULL DEFAULT '?',
[188] Fix | Delete
PRIMARY KEY (`filenameMD5`)
[189] Fix | Delete
) DEFAULT CHARSET=utf8",
[190] Fix | Delete
'wfBlockedIPLog' => "(
[191] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[192] Fix | Delete
`countryCode` varchar(2) NOT NULL,
[193] Fix | Delete
`blockCount` int(10) unsigned NOT NULL DEFAULT '0',
[194] Fix | Delete
`unixday` int(10) unsigned NOT NULL,
[195] Fix | Delete
`blockType` varchar(50) NOT NULL DEFAULT 'generic',
[196] Fix | Delete
PRIMARY KEY (`IP`,`unixday`,`blockType`)
[197] Fix | Delete
) DEFAULT CHARSET=utf8",
[198] Fix | Delete
'wfSNIPCache' => "(
[199] Fix | Delete
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
[200] Fix | Delete
`IP` varchar(45) NOT NULL DEFAULT '',
[201] Fix | Delete
`expiration` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
[202] Fix | Delete
`body` varchar(255) NOT NULL DEFAULT '',
[203] Fix | Delete
`count` int(10) unsigned NOT NULL DEFAULT '0',
[204] Fix | Delete
`type` int(10) unsigned NOT NULL DEFAULT '0',
[205] Fix | Delete
PRIMARY KEY (`id`),
[206] Fix | Delete
KEY `expiration` (`expiration`),
[207] Fix | Delete
KEY `IP` (`IP`),
[208] Fix | Delete
KEY `type` (`type`)
[209] Fix | Delete
) DEFAULT CHARSET=utf8",
[210] Fix | Delete
'wfKnownFileList' => "(
[211] Fix | Delete
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
[212] Fix | Delete
`path` text NOT NULL,
[213] Fix | Delete
PRIMARY KEY (`id`)
[214] Fix | Delete
) DEFAULT CHARSET=utf8",
[215] Fix | Delete
'wfNotifications' => "(
[216] Fix | Delete
`id` varchar(32) NOT NULL DEFAULT '',
[217] Fix | Delete
`new` tinyint(3) unsigned NOT NULL DEFAULT '1',
[218] Fix | Delete
`category` varchar(255) NOT NULL,
[219] Fix | Delete
`priority` int(11) NOT NULL DEFAULT '1000',
[220] Fix | Delete
`ctime` int(10) unsigned NOT NULL,
[221] Fix | Delete
`html` text NOT NULL,
[222] Fix | Delete
`links` text NOT NULL,
[223] Fix | Delete
PRIMARY KEY (`id`)
[224] Fix | Delete
) DEFAULT CHARSET=utf8;",
[225] Fix | Delete
'wfLiveTrafficHuman' => "(
[226] Fix | Delete
`IP` binary(16) NOT NULL DEFAULT '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0',
[227] Fix | Delete
`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',
[228] Fix | Delete
`expiration` int(10) unsigned NOT NULL,
[229] Fix | Delete
PRIMARY KEY (`IP`,`identifier`),
[230] Fix | Delete
KEY `expiration` (`expiration`)
[231] Fix | Delete
) DEFAULT CHARSET=utf8;",
[232] Fix | Delete
'wfWafFailures' => "(
[233] Fix | Delete
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
[234] Fix | Delete
`throwable` TEXT NOT NULL,
[235] Fix | Delete
`rule_id` INT(10) UNSIGNED,
[236] Fix | Delete
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
[237] Fix | Delete
) DEFAULT CHARSET=utf8"
[238] Fix | Delete
);
[239] Fix | Delete
private $db = false;
[240] Fix | Delete
public function __construct($dbhost = false, $dbuser = false, $dbpassword = false, $dbname = false){
[241] Fix | Delete
$this->db = new wfDB();
[242] Fix | Delete
}
[243] Fix | Delete
public function dropAll(){
[244] Fix | Delete
foreach(self::$tables as $table => $def) {
[245] Fix | Delete
$originalTable = wfDB::networkPrefix() . $table;
[246] Fix | Delete
$convertedTable = wfDB::networkPrefix() . strtolower($table);
[247] Fix | Delete
[248] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
[249] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
foreach (self::$deprecatedTables as $table) {
[253] Fix | Delete
$originalTable = wfDB::networkTable($table, false);
[254] Fix | Delete
$convertedTable = wfDB::networkTable($table);
[255] Fix | Delete
[256] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
[257] Fix | Delete
if ($originalTable !== $convertedTable) {
[258] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
}
[262] Fix | Delete
public function createAll() {
[263] Fix | Delete
foreach(self::$tables as $table => $def){
[264] Fix | Delete
$this->db->queryWrite("CREATE TABLE IF NOT EXISTS " . wfDB::networkTable($table) . " " . $def);
[265] Fix | Delete
}
[266] Fix | Delete
}
[267] Fix | Delete
public function create($table) {
[268] Fix | Delete
$this->db->queryWrite("CREATE TABLE IF NOT EXISTS " . wfDB::networkTable($table) . " " . self::$tables[$table]);
[269] Fix | Delete
}
[270] Fix | Delete
public function drop($table) {
[271] Fix | Delete
$originalTable = wfDB::networkTable($table, false);
[272] Fix | Delete
$convertedTable = wfDB::networkTable($table);
[273] Fix | Delete
[274] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$convertedTable}");
[275] Fix | Delete
if ($originalTable !== $convertedTable) {
[276] Fix | Delete
$this->db->queryWrite("DROP TABLE IF EXISTS {$originalTable}");
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
public static function tableList() {
[281] Fix | Delete
return array_keys(self::$tables);
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
public static function updateTableCase() {
[285] Fix | Delete
global $wpdb;
[286] Fix | Delete
$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)));
[287] Fix | Delete
if (is_multisite() && function_exists('update_network_option')) {
[288] Fix | Delete
update_network_option(null, self::TABLE_CASE_OPTION, !$hasCamelCaseTable);
[289] Fix | Delete
self::$_usingLowercase = !$hasCamelCaseTable;
[290] Fix | Delete
}
[291] Fix | Delete
else {
[292] Fix | Delete
update_option(self::TABLE_CASE_OPTION, !$hasCamelCaseTable);
[293] Fix | Delete
self::$_usingLowercase = !$hasCamelCaseTable;
[294] Fix | Delete
}
[295] Fix | Delete
}
[296] Fix | Delete
[297] Fix | Delete
public static function usingLowercase() {
[298] Fix | Delete
if (self::$_usingLowercase === null) {
[299] Fix | Delete
if (is_multisite() && function_exists('update_network_option')) {
[300] Fix | Delete
self::$_usingLowercase = !!get_network_option(null, self::TABLE_CASE_OPTION);
[301] Fix | Delete
}
[302] Fix | Delete
else {
[303] Fix | Delete
self::$_usingLowercase = !!get_option(self::TABLE_CASE_OPTION);
[304] Fix | Delete
}
[305] Fix | Delete
}
[306] Fix | Delete
return self::$_usingLowercase;
[307] Fix | Delete
}
[308] Fix | Delete
}
[309] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function