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: wfDiagnostic.php
<?php
[0] Fix | Delete
[1] Fix | Delete
require_once __DIR__ . '/wfCurlInterceptor.php';
[2] Fix | Delete
[3] Fix | Delete
class wfGrant
[4] Fix | Delete
{
[5] Fix | Delete
public $select = false;
[6] Fix | Delete
public $update = false;
[7] Fix | Delete
public $insert = false;
[8] Fix | Delete
public $delete = false;
[9] Fix | Delete
public $alter = false;
[10] Fix | Delete
public $create = false;
[11] Fix | Delete
public $drop = false;
[12] Fix | Delete
[13] Fix | Delete
public static function get()
[14] Fix | Delete
{
[15] Fix | Delete
static $instance;
[16] Fix | Delete
if ($instance === null) {
[17] Fix | Delete
$instance = new self;
[18] Fix | Delete
}
[19] Fix | Delete
return $instance;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
private function __construct()
[23] Fix | Delete
{
[24] Fix | Delete
global $wpdb;
[25] Fix | Delete
$rows = $wpdb->get_results("SHOW GRANTS FOR current_user()", ARRAY_N);
[26] Fix | Delete
[27] Fix | Delete
foreach ($rows as $row) {
[28] Fix | Delete
preg_match("/GRANT (.+) ON (.+) TO/", $row[0], $matches);
[29] Fix | Delete
foreach (explode(",", $matches[1]) as $permission) {
[30] Fix | Delete
$permission = str_replace(" ", "_", trim(strtolower($permission)));
[31] Fix | Delete
if ($permission === 'all_privileges') {
[32] Fix | Delete
foreach ($this as $key => $value) {
[33] Fix | Delete
$this->$key = true;
[34] Fix | Delete
}
[35] Fix | Delete
break 2;
[36] Fix | Delete
}
[37] Fix | Delete
if (property_exists($this, $permission))
[38] Fix | Delete
$this->$permission = true;
[39] Fix | Delete
}
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
class wfDiagnostic
[45] Fix | Delete
{
[46] Fix | Delete
protected $minVersion = array(
[47] Fix | Delete
'PHP' => '5.6.20',
[48] Fix | Delete
'cURL' => '1.0',
[49] Fix | Delete
);
[50] Fix | Delete
[51] Fix | Delete
protected $description = false; //Defined in the constructor to allow for localization
[52] Fix | Delete
[53] Fix | Delete
protected $results = array();
[54] Fix | Delete
[55] Fix | Delete
public function __construct()
[56] Fix | Delete
{
[57] Fix | Delete
$this->description = array(
[58] Fix | Delete
'Wordfence Status' => array(
[59] Fix | Delete
'description' => __('General information about the Wordfence installation.', 'wordfence'),
[60] Fix | Delete
'tests' => array(
[61] Fix | Delete
'wfVersion' => __('Wordfence Version', 'wordfence'),
[62] Fix | Delete
'geoIPVersion' => __('GeoIP Version', 'wordfence'),
[63] Fix | Delete
'cronStatus' => __('Cron Status', 'wordfence'),
[64] Fix | Delete
),
[65] Fix | Delete
),
[66] Fix | Delete
'Filesystem' => array(
[67] Fix | Delete
'description' => __('Ability to read/write various files.', 'wordfence'),
[68] Fix | Delete
'tests' => array(
[69] Fix | Delete
'isPluginReadable' => __('Checking if web server can read from <code>~/plugins/wordfence</code>', 'wordfence'),
[70] Fix | Delete
'isPluginWritable' => __('Checking if web server can write to <code>~/plugins/wordfence</code>', 'wordfence'),
[71] Fix | Delete
'isWAFReadable' => __('Checking if web server can read from <code>~/wp-content/wflogs</code>', 'wordfence'),
[72] Fix | Delete
'isWAFWritable' => __('Checking if web server can write to <code>~/wp-content/wflogs</code>', 'wordfence'),
[73] Fix | Delete
),
[74] Fix | Delete
),
[75] Fix | Delete
'Wordfence Config' => array(
[76] Fix | Delete
'description' => __('Ability to save Wordfence settings to the database.', 'wordfence'),
[77] Fix | Delete
'tests' => array(
[78] Fix | Delete
'configWritableSet' => __('Checking basic config reading/writing', 'wordfence'),
[79] Fix | Delete
'configWritableSetSer' => __('Checking serialized config reading/writing', 'wordfence'),
[80] Fix | Delete
),
[81] Fix | Delete
),
[82] Fix | Delete
'Wordfence Firewall' => array(
[83] Fix | Delete
'description' => __('Current WAF configuration.', 'wordfence'),
[84] Fix | Delete
'tests' => array(
[85] Fix | Delete
'wafAutoPrepend' => __('WAF auto prepend active', 'wordfence'),
[86] Fix | Delete
'wafStorageEngine' => __('Configured WAF storage engine (WFWAF_STORAGE_ENGINE)', 'wordfence'),
[87] Fix | Delete
'wafActiveStorageEngine' => __('Active WAF storage engine', 'wordfence'),
[88] Fix | Delete
'wafLogPath' => __('WAF log path', 'wordfence'),
[89] Fix | Delete
'wafSubdirectoryInstall' => __('WAF subdirectory installation', 'wordfence'),
[90] Fix | Delete
'wafAutoPrependFilePath' => __('wordfence-waf.php path', 'wordfence'),
[91] Fix | Delete
'wafFilePermissions' => __('WAF File Permissions', 'wordfence'),
[92] Fix | Delete
'wafRecentlyRemoved' => __('Recently removed wflogs files', 'wordfence'),
[93] Fix | Delete
'wafLoaded' => __('WAF Loaded Successfully', 'wordfence'),
[94] Fix | Delete
'wafAutoPrependHtaccess' => __('WAF .htaccess contents', 'wordfence'),
[95] Fix | Delete
'wafAutoPrependUserIni' => __('WAF .user.ini contents', 'wordfence'),
[96] Fix | Delete
'wafAutoPrependHtaccessOther' => __('.htaccess other auto prepend', 'wordfence'),
[97] Fix | Delete
'wafAutoPrependUserIniOther' => __('.user.ini other auto prepend', 'wordfence'),
[98] Fix | Delete
),
[99] Fix | Delete
),
[100] Fix | Delete
'MySQL' => array(
[101] Fix | Delete
'description' => __('Database version and privileges.', 'wordfence'),
[102] Fix | Delete
'tests' => array(
[103] Fix | Delete
'databaseVersion' => __('Database Version', 'wordfence'),
[104] Fix | Delete
'userCanDelete' => __('Checking if MySQL user has <code>DELETE</code> privilege', 'wordfence'),
[105] Fix | Delete
'userCanInsert' => __('Checking if MySQL user has <code>INSERT</code> privilege', 'wordfence'),
[106] Fix | Delete
'userCanUpdate' => __('Checking if MySQL user has <code>UPDATE</code> privilege', 'wordfence'),
[107] Fix | Delete
'userCanSelect' => __('Checking if MySQL user has <code>SELECT</code> privilege', 'wordfence'),
[108] Fix | Delete
'userCanCreate' => __('Checking if MySQL user has <code>CREATE TABLE</code> privilege', 'wordfence'),
[109] Fix | Delete
'userCanAlter' => __('Checking if MySQL user has <code>ALTER TABLE</code> privilege', 'wordfence'),
[110] Fix | Delete
'userCanDrop' => __('Checking if MySQL user has <code>DROP</code> privilege', 'wordfence'),
[111] Fix | Delete
'userCanTruncate' => __('Checking if MySQL user has <code>TRUNCATE</code> privilege', 'wordfence'),
[112] Fix | Delete
)
[113] Fix | Delete
),
[114] Fix | Delete
'PHP Environment' => array(
[115] Fix | Delete
'description' => __('PHP version, important PHP extensions.', 'wordfence'),
[116] Fix | Delete
'tests' => array(
[117] Fix | Delete
'phpVersion' => array('raw' => true, 'value' => wp_kses(sprintf(/* translators: Support URL. */ __('PHP version >= PHP 5.6.20<br><em> (<a href="https://wordpress.org/about/requirements/" target="_blank" rel="noopener noreferrer">Minimum version required by WordPress</a>)</em> <a href="%s" target="_blank" rel="noopener noreferrer" class="wfhelp"><span class="screen-reader-text"> (opens in new tab)</span></a>', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_VERSION_PHP)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array(), 'class'=>array()), 'span'=>array('class'=>array())))),
[118] Fix | Delete
'processOwner' => __('Process Owner', 'wordfence'),
[119] Fix | Delete
'hasOpenSSL' => __('Checking for OpenSSL support', 'wordfence'),
[120] Fix | Delete
'openSSLVersion' => __('Checking OpenSSL version', 'wordfence'),
[121] Fix | Delete
'hasCurl' => __('Checking for cURL support', 'wordfence'),
[122] Fix | Delete
'curlFeatures' => __('cURL Features Code', 'wordfence'),
[123] Fix | Delete
'curlHost' => __('cURL Host', 'wordfence'),
[124] Fix | Delete
'curlProtocols' => __('cURL Support Protocols', 'wordfence'),
[125] Fix | Delete
'curlSSLVersion' => __('cURL SSL Version', 'wordfence'),
[126] Fix | Delete
'curlLibZVersion' => __('cURL libz Version', 'wordfence'),
[127] Fix | Delete
'displayErrors' => array('raw' => true, 'value' => wp_kses(__('Checking <code>display_errors</code><br><em> (<a href="http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors" target="_blank" rel="noopener noreferrer">Should be disabled on production servers<span class="screen-reader-text"> (opens in new tab)</span></a>)</em>', 'wordfence'), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array()), 'span'=>array('class'=>array()), 'em'=>array(), 'code'=>array(), 'br'=>array()))),
[128] Fix | Delete
)
[129] Fix | Delete
),
[130] Fix | Delete
'Connectivity' => array(
[131] Fix | Delete
'description' => __('Ability to connect to the Wordfence servers and your own site.', 'wordfence'),
[132] Fix | Delete
'tests' => array(
[133] Fix | Delete
'connectToServer2' => __('Connecting to Wordfence servers (https)', 'wordfence'),
[134] Fix | Delete
'connectToSelf' => __('Connecting back to this site', 'wordfence'),
[135] Fix | Delete
'connectToSelfIpv6' => array('raw' => true, 'value' => wp_kses(sprintf(__('Connecting back to this site via IPv6 (not required; failure to connect may not be an issue on some sites) <a href="%s" target="_blank" rel="noopener noreferrer" class="wfhelp"><span class="screen-reader-text"> (opens in new tab)</span></a>', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_DIAGNOSTICS_IPV6)), array('a'=>array('href'=>array(), 'target'=>array(), 'rel'=>array(), 'class'=>array()), 'span'=>array('class'=>array())))),
[136] Fix | Delete
'serverIP' => __('IP(s) used by this server', 'wordfence'),
[137] Fix | Delete
)
[138] Fix | Delete
),
[139] Fix | Delete
'Time' => array(
[140] Fix | Delete
'description' => __('Server time accuracy and applied offsets.', 'wordfence'),
[141] Fix | Delete
'tests' => array(
[142] Fix | Delete
'wfTime' => __('Wordfence Network Time', 'wordfence'),
[143] Fix | Delete
'serverTime' => __('Server Time', 'wordfence'),
[144] Fix | Delete
'wfTimeOffset' => __('Wordfence Network Time Offset', 'wordfence'),
[145] Fix | Delete
'ntpTimeOffset' => __('NTP Time Offset', 'wordfence'),
[146] Fix | Delete
'ntpStatus' => __('NTP Status', 'wordfence'),
[147] Fix | Delete
'timeSourceInUse' => __('TOTP Time Source', 'wordfence'),
[148] Fix | Delete
'wpTimeZone' => __('WordPress Time Zone', 'wordfence'),
[149] Fix | Delete
),
[150] Fix | Delete
),
[151] Fix | Delete
);
[152] Fix | Delete
[153] Fix | Delete
foreach ($this->description as $title => $tests) {
[154] Fix | Delete
$this->results[$title] = array(
[155] Fix | Delete
'description' => $tests['description'],
[156] Fix | Delete
);
[157] Fix | Delete
foreach ($tests['tests'] as $name => $description) {
[158] Fix | Delete
if (!method_exists($this, $name)) {
[159] Fix | Delete
continue;
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
$result = $this->$name();
[163] Fix | Delete
[164] Fix | Delete
if (is_bool($result)) {
[165] Fix | Delete
$result = array(
[166] Fix | Delete
'test' => $result,
[167] Fix | Delete
'message' => $result ? 'OK' : 'FAIL',
[168] Fix | Delete
);
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
$result['label'] = $description;
[172] Fix | Delete
$result['name'] = $name;
[173] Fix | Delete
[174] Fix | Delete
$this->results[$title]['results'][] = $result;
[175] Fix | Delete
}
[176] Fix | Delete
}
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
public function getResults()
[180] Fix | Delete
{
[181] Fix | Delete
return $this->results;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
public function wfVersion() {
[185] Fix | Delete
return array('test' => true, 'message' => WORDFENCE_VERSION . ' (' . WORDFENCE_BUILD_NUMBER . ')');
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
public function geoIPVersion() {
[189] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => wfUtils::geoIPVersion());
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
public function cronStatus() {
[193] Fix | Delete
$cron = _get_cron_array();
[194] Fix | Delete
$overdue = 0;
[195] Fix | Delete
foreach ($cron as $timestamp => $values) {
[196] Fix | Delete
if (is_array($values)) {
[197] Fix | Delete
foreach ($values as $cron_job => $v) {
[198] Fix | Delete
if (is_numeric($timestamp)) {
[199] Fix | Delete
if ((time() - 1800) > $timestamp) { $overdue++; }
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $overdue ? sprintf(/* translators: Number of jobs. */ _n('%d Job Overdue', '%d Jobs Overdue', $overdue, 'wordfence'), $overdue) : __('Normal', 'wordfence'));
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
public function geoIPError() {
[209] Fix | Delete
$error = wfUtils::last_error('geoip');
[210] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $error ? $error : __('None', 'wordfence'));
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
public function isPluginReadable() {
[214] Fix | Delete
return is_readable(WORDFENCE_PATH);
[215] Fix | Delete
}
[216] Fix | Delete
[217] Fix | Delete
public function isPluginWritable() {
[218] Fix | Delete
return is_writable(WORDFENCE_PATH);
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
public function isWAFReadable() {
[222] Fix | Delete
if (!is_readable(WFWAF_LOG_PATH)) {
[223] Fix | Delete
if (defined('WFWAF_STORAGE_ENGINE') && WFWAF_STORAGE_ENGINE == 'mysqli') {
[224] Fix | Delete
return array('test' => false, 'infoOnly' => true, 'message' => __('No files readable', 'wordfence'));
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
return array('test' => false, 'message' => __('No files readable', 'wordfence'));
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
$files = array(
[231] Fix | Delete
WFWAF_LOG_PATH . 'attack-data.php',
[232] Fix | Delete
WFWAF_LOG_PATH . 'ips.php',
[233] Fix | Delete
WFWAF_LOG_PATH . 'config.php',
[234] Fix | Delete
WFWAF_LOG_PATH . 'rules.php',
[235] Fix | Delete
);
[236] Fix | Delete
$unreadable = array();
[237] Fix | Delete
foreach ($files as $f) {
[238] Fix | Delete
if (!file_exists($f)) {
[239] Fix | Delete
$unreadable[] = sprintf(__('File "%s" does not exist', 'wordfence'), basename($f));
[240] Fix | Delete
}
[241] Fix | Delete
else if (!is_readable($f)) {
[242] Fix | Delete
$unreadable[] = sprintf(/* translators: File path. */ __('File "%s" is unreadable', 'wordfence'), basename($f));
[243] Fix | Delete
}
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
if (count($unreadable) > 0) {
[247] Fix | Delete
if (defined('WFWAF_STORAGE_ENGINE') && WFWAF_STORAGE_ENGINE == 'mysqli') {
[248] Fix | Delete
return array('test' => false, 'infoOnly' => true, 'message' => implode(', ', $unreadable));
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
return array('test' => false, 'message' => implode(', ', $unreadable));
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
return true;
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
public function isWAFWritable() {
[258] Fix | Delete
if (!is_writable(WFWAF_LOG_PATH)) {
[259] Fix | Delete
if (defined('WFWAF_STORAGE_ENGINE') && WFWAF_STORAGE_ENGINE == 'mysqli') {
[260] Fix | Delete
return array('test' => false, 'infoOnly' => true, 'message' => __('No files writable', 'wordfence'));
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
return array('test' => false, 'message' => __('No files writable', 'wordfence'));
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
$files = array(
[267] Fix | Delete
WFWAF_LOG_PATH . 'attack-data.php',
[268] Fix | Delete
WFWAF_LOG_PATH . 'ips.php',
[269] Fix | Delete
WFWAF_LOG_PATH . 'config.php',
[270] Fix | Delete
WFWAF_LOG_PATH . 'rules.php',
[271] Fix | Delete
);
[272] Fix | Delete
$unwritable = array();
[273] Fix | Delete
foreach ($files as $f) {
[274] Fix | Delete
if (!file_exists($f)) {
[275] Fix | Delete
$unwritable[] = sprintf(/* translators: File name. */__('File "%s" does not exist', 'wordfence'), basename($f));
[276] Fix | Delete
}
[277] Fix | Delete
else if (!is_writable($f)) {
[278] Fix | Delete
$unwritable[] = sprintf(/* translators: File name. */__('File "%s" is unwritable', 'wordfence'), basename($f));
[279] Fix | Delete
}
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
if (count($unwritable) > 0) {
[283] Fix | Delete
if (defined('WFWAF_STORAGE_ENGINE') && WFWAF_STORAGE_ENGINE == 'mysqli') {
[284] Fix | Delete
return array('test' => false, 'infoOnly' => true, 'message' => implode(', ', $unwritable));
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
return array('test' => false, 'message' => implode(', ', $unwritable));
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
return true;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
public function databaseVersion() {
[294] Fix | Delete
global $wpdb;
[295] Fix | Delete
$version = $wpdb->get_var("SELECT VERSION()");
[296] Fix | Delete
return array('test' => true, 'message' => $version);
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
public function userCanInsert() {
[300] Fix | Delete
return wfGrant::get()->insert;
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
public function userCanUpdate() {
[304] Fix | Delete
return wfGrant::get()->update;
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
public function userCanDelete() {
[308] Fix | Delete
return wfGrant::get()->delete;
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
public function userCanSelect() {
[312] Fix | Delete
return wfGrant::get()->select;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
public function userCanCreate() {
[316] Fix | Delete
return wfGrant::get()->create;
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
public function userCanDrop() {
[320] Fix | Delete
return wfGrant::get()->drop;
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
public function userCanTruncate() {
[324] Fix | Delete
return wfGrant::get()->drop && wfGrant::get()->delete;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
public function userCanAlter() {
[328] Fix | Delete
return wfGrant::get()->alter;
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
public function phpVersion()
[332] Fix | Delete
{
[333] Fix | Delete
return array(
[334] Fix | Delete
'test' => version_compare(phpversion(), $this->minVersion['PHP'], '>='),
[335] Fix | Delete
'message' => phpversion(),
[336] Fix | Delete
);
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
public function configWritableSet() {
[340] Fix | Delete
global $wpdb;
[341] Fix | Delete
$show = $wpdb->hide_errors();
[342] Fix | Delete
$val = md5(time());
[343] Fix | Delete
wfConfig::set('configWritingTest', $val, wfConfig::DONT_AUTOLOAD);
[344] Fix | Delete
$testVal = wfConfig::get('configWritingTest');
[345] Fix | Delete
$wpdb->show_errors($show);
[346] Fix | Delete
return array(
[347] Fix | Delete
'test' => ($val === $testVal),
[348] Fix | Delete
'message' => __('Basic config writing', 'wordfence')
[349] Fix | Delete
);
[350] Fix | Delete
}
[351] Fix | Delete
public function configWritableSetSer() {
[352] Fix | Delete
global $wpdb;
[353] Fix | Delete
$show = $wpdb->hide_errors();
[354] Fix | Delete
$val = md5(time());
[355] Fix | Delete
wfConfig::set_ser('configWritingTest_ser', array($val), false, wfConfig::DONT_AUTOLOAD);
[356] Fix | Delete
$testVal = @array_shift(wfConfig::get_ser('configWritingTest_ser', array(), false));
[357] Fix | Delete
$wpdb->show_errors($show);
[358] Fix | Delete
return array(
[359] Fix | Delete
'test' => ($val === $testVal),
[360] Fix | Delete
'message' => __('Serialized config writing', 'wordfence')
[361] Fix | Delete
);
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
public function wafAutoPrepend() {
[365] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => (defined('WFWAF_AUTO_PREPEND') && WFWAF_AUTO_PREPEND ? __('Yes', 'wordfence') : __('No', 'wordfence')));
[366] Fix | Delete
}
[367] Fix | Delete
public function wafAutoPrependHtaccess() {
[368] Fix | Delete
$htaccessPath = wfWAFAutoPrependHelper::getHtaccessPath();
[369] Fix | Delete
if (!file_exists($htaccessPath)) {
[370] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.htaccess not present)', 'wordfence'));
[371] Fix | Delete
}
[372] Fix | Delete
else if (!is_readable($htaccessPath)) {
[373] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.htaccess not readable)', 'wordfence'));
[374] Fix | Delete
}
[375] Fix | Delete
[376] Fix | Delete
$htaccessContents = file_get_contents($htaccessPath);
[377] Fix | Delete
$section = wfWAFAutoPrependHelper::getHtaccessSectionContent($htaccessContents);
[378] Fix | Delete
if ($section === false) {
[379] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(not set)', 'wordfence'));
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
$snippet = wfUtils::pregExtract("/auto_prepend_file\s+['\"]?[^'\"]*['\"]?/", $section);
[383] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $snippet, 'detail' => array('escaped' => nl2br(esc_html($section)), 'textonly' => $section));
[384] Fix | Delete
}
[385] Fix | Delete
public function wafAutoPrependHtaccessOther() {
[386] Fix | Delete
$htaccessPath = wfWAFAutoPrependHelper::getHtaccessPath();
[387] Fix | Delete
if (!file_exists($htaccessPath)) {
[388] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.htaccess not present)', 'wordfence'));
[389] Fix | Delete
}
[390] Fix | Delete
else if (!is_readable($htaccessPath)) {
[391] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.htaccess not readable)', 'wordfence'));
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
$htaccessContents = file_get_contents($htaccessPath);
[395] Fix | Delete
$section = wfWAFAutoPrependHelper::getHtaccessSectionContent($htaccessContents);
[396] Fix | Delete
if ($section !== false) {
[397] Fix | Delete
$htaccessContents = str_replace($section, '', $htaccessContents);
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
$snippet = wfUtils::pregExtract("/auto_prepend_file\s+['\"]?[^'\"]*['\"]?/", $htaccessContents, true);
[401] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => ($snippet === false ? __('(not present)', 'wordfence') : trim($snippet)));
[402] Fix | Delete
}
[403] Fix | Delete
public function wafAutoPrependUserIni() {
[404] Fix | Delete
$userIniPath = wfWAFAutoPrependHelper::getUserIniPath();
[405] Fix | Delete
if (!file_exists($userIniPath)) {
[406] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.user.ini not present)', 'wordfence'));
[407] Fix | Delete
}
[408] Fix | Delete
else if (!is_readable($userIniPath)) {
[409] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.user.ini not readable)', 'wordfence'));
[410] Fix | Delete
}
[411] Fix | Delete
[412] Fix | Delete
$userIniContents = file_get_contents($userIniPath);
[413] Fix | Delete
$section = wfWAFAutoPrependHelper::getUserIniSectionContent($userIniContents);
[414] Fix | Delete
if ($section === false) {
[415] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(not set)', 'wordfence'));
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
$snippet = wfUtils::pregExtract("/auto_prepend_file\s*=\s*['\"]?[^'\"]*['\"]?/", $section);
[419] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $snippet, 'detail' => $section);
[420] Fix | Delete
}
[421] Fix | Delete
public function wafAutoPrependUserIniOther() {
[422] Fix | Delete
$userIniPath = wfWAFAutoPrependHelper::getUserIniPath();
[423] Fix | Delete
if (!file_exists($userIniPath)) {
[424] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.user.ini not present)', 'wordfence'));
[425] Fix | Delete
}
[426] Fix | Delete
else if (!is_readable($userIniPath)) {
[427] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => __('(.user.ini not readable)', 'wordfence'));
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
$userIniContents = file_get_contents($userIniPath);
[431] Fix | Delete
$section = wfWAFAutoPrependHelper::getUserIniSectionContent($userIniContents);
[432] Fix | Delete
if ($section !== false) {
[433] Fix | Delete
$userIniContents = str_replace($section, '', $userIniContents);
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
$snippet = wfUtils::pregExtract("/auto_prepend_file\s*=\s*['\"]?[^'\"]*['\"]?/", $userIniContents, true);
[437] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => ($snippet === false ? __('(not present)', 'wordfence') : trim($snippet)));
[438] Fix | Delete
}
[439] Fix | Delete
public function wafStorageEngine() {
[440] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => (defined('WFWAF_STORAGE_ENGINE') ? WFWAF_STORAGE_ENGINE : __('(default)', 'wordfence')));
[441] Fix | Delete
}
[442] Fix | Delete
private static function getStorageEngineDescription($storageEngine) {
[443] Fix | Delete
if ($storageEngine === null) {
[444] Fix | Delete
return __('None', 'wordfence');
[445] Fix | Delete
}
[446] Fix | Delete
else if (method_exists($storageEngine, 'getDescription')) {
[447] Fix | Delete
return $storageEngine->getDescription();
[448] Fix | Delete
}
[449] Fix | Delete
else {
[450] Fix | Delete
return __('Unknown (mixed plugin version)', 'wordfence');
[451] Fix | Delete
}
[452] Fix | Delete
}
[453] Fix | Delete
public function wafActiveStorageEngine() {
[454] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => self::getStorageEngineDescription(wfWAF::getSharedStorageEngine()));
[455] Fix | Delete
}
[456] Fix | Delete
public function wafLogPath() {
[457] Fix | Delete
$logPath = __('(not set)', 'wordfence');
[458] Fix | Delete
if (defined('WFWAF_LOG_PATH')) {
[459] Fix | Delete
$logPath = WFWAF_LOG_PATH;
[460] Fix | Delete
if (strpos($logPath, ABSPATH) === 0) {
[461] Fix | Delete
$logPath = '~/' . substr($logPath, strlen(ABSPATH));
[462] Fix | Delete
}
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $logPath);
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
public function wafSubdirectoryInstall() {
[469] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => (defined('WFWAF_SUBDIRECTORY_INSTALL') && WFWAF_SUBDIRECTORY_INSTALL ? __('Yes', 'wordfence') : __('No', 'wordfence')));
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
public function wafAutoPrependFilePath() {
[473] Fix | Delete
$path = wordfence::getWAFBootstrapPath();
[474] Fix | Delete
if (!file_exists($path)) {
[475] Fix | Delete
$path = '';
[476] Fix | Delete
}
[477] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => $path);
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
public function wafFilePermissions() {
[481] Fix | Delete
if (defined('WFWAF_LOG_FILE_MODE')) {
[482] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => sprintf(/* translators: Unix file permissions in octal (example 0777). */ __('%s - using constant', 'wordfence'), str_pad(decoct(WFWAF_LOG_FILE_MODE), 4, '0', STR_PAD_LEFT)));
[483] Fix | Delete
}
[484] Fix | Delete
[485] Fix | Delete
if (defined('WFWAF_LOG_PATH')) {
[486] Fix | Delete
$template = rtrim(WFWAF_LOG_PATH, '/') . '/template.php';
[487] Fix | Delete
if (file_exists($template)) {
[488] Fix | Delete
$stat = @stat($template);
[489] Fix | Delete
if ($stat !== false) {
[490] Fix | Delete
$mode = $stat[2];
[491] Fix | Delete
$updatedMode = 0600;
[492] Fix | Delete
if (($mode & 0020) == 0020) {
[493] Fix | Delete
$updatedMode = $updatedMode | 0060;
[494] Fix | Delete
}
[495] Fix | Delete
return array('test' => true, 'infoOnly' => true, 'message' => sprintf(/* translators: Unix file permissions in octal (example 0777). */ __('%s - using template', 'wordfence'), str_pad(decoct($updatedMode), 4, '0', STR_PAD_LEFT)));
[496] Fix | Delete
}
[497] Fix | Delete
}
[498] Fix | Delete
}
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function