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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordfenc.../lib
File: wordfenceClass.php
foreach ($patternBlocks as $b) {
[1000] Fix | Delete
if (!empty($b->ipRange) && preg_match('/^\d+\-\d+$/', $b->ipRange)) { //Old-style range block using long2ip
[1001] Fix | Delete
$ipRange = new wfUserIPRange($b->ipRange);
[1002] Fix | Delete
$ipRange = $ipRange->getIPString();
[1003] Fix | Delete
[1004] Fix | Delete
$parameters = $b->parameters;
[1005] Fix | Delete
$parameters['ipRange'] = $ipRange;
[1006] Fix | Delete
$wpdb->query($wpdb->prepare("UPDATE `{$blocksTable}` SET `parameters` = %s WHERE `id` = %d", json_encode($parameters), $b->id));
[1007] Fix | Delete
}
[1008] Fix | Delete
}
[1009] Fix | Delete
[1010] Fix | Delete
wfConfig::set('needsGeoIPSync', true, wfConfig::DONT_AUTOLOAD);
[1011] Fix | Delete
[1012] Fix | Delete
// Set the default scan options based on scan type.
[1013] Fix | Delete
if (!wfConfig::get('config720Migration', false)) {
[1014] Fix | Delete
// Replace critical/warning checkboxes with setting based on numeric severity value.
[1015] Fix | Delete
if (wfConfig::hasCachedOption('alertOn_critical') && wfConfig::hasCachedOption('alertOn_warnings')) {
[1016] Fix | Delete
$alertOnCritical = wfConfig::get('alertOn_critical');
[1017] Fix | Delete
$alertOnWarnings = wfConfig::get('alertOn_warnings');
[1018] Fix | Delete
wfConfig::set('alertOn_scanIssues', $alertOnCritical || $alertOnWarnings);
[1019] Fix | Delete
if ($alertOnCritical && ! $alertOnWarnings) {
[1020] Fix | Delete
wfConfig::set('alertOn_severityLevel', wfIssues::SEVERITY_HIGH);
[1021] Fix | Delete
} else {
[1022] Fix | Delete
wfConfig::set('alertOn_severityLevel', wfIssues::SEVERITY_LOW);
[1023] Fix | Delete
}
[1024] Fix | Delete
}
[1025] Fix | Delete
[1026] Fix | Delete
// Update severity for existing issues where they are still using the old severity values.
[1027] Fix | Delete
foreach (wfIssues::$issueSeverities as $issueType => $severity) {
[1028] Fix | Delete
$wpdb->query($wpdb->prepare("UPDATE $issuesTable SET severity = %d
[1029] Fix | Delete
WHERE `type` = %s
[1030] Fix | Delete
AND severity in (0,1,2)
[1031] Fix | Delete
", $severity, $issueType));
[1032] Fix | Delete
}
[1033] Fix | Delete
[1034] Fix | Delete
$syncedOptions = array();
[1035] Fix | Delete
switch (wfConfig::get('scanType')) {
[1036] Fix | Delete
case wfScanner::SCAN_TYPE_LIMITED:
[1037] Fix | Delete
$syncedOptions = wfScanner::limitedScanTypeOptions();
[1038] Fix | Delete
break;
[1039] Fix | Delete
case wfScanner::SCAN_TYPE_STANDARD:
[1040] Fix | Delete
$syncedOptions = wfScanner::standardScanTypeOptions();
[1041] Fix | Delete
break;
[1042] Fix | Delete
case wfScanner::SCAN_TYPE_HIGH_SENSITIVITY:
[1043] Fix | Delete
$syncedOptions = wfScanner::highSensitivityScanTypeOptions();
[1044] Fix | Delete
break;
[1045] Fix | Delete
}
[1046] Fix | Delete
if ($syncedOptions) {
[1047] Fix | Delete
foreach ($syncedOptions as $key => $value) {
[1048] Fix | Delete
if (is_bool($value)) {
[1049] Fix | Delete
wfConfig::set($key, $value ? 1 : 0);
[1050] Fix | Delete
}
[1051] Fix | Delete
}
[1052] Fix | Delete
}
[1053] Fix | Delete
[1054] Fix | Delete
wfConfig::set('config720Migration', true);
[1055] Fix | Delete
}
[1056] Fix | Delete
[1057] Fix | Delete
//7.2.3
[1058] Fix | Delete
if (wfConfig::get('waf_status') === false) {
[1059] Fix | Delete
$firewall = new wfFirewall();
[1060] Fix | Delete
$firewall->syncStatus(true);
[1061] Fix | Delete
}
[1062] Fix | Delete
[1063] Fix | Delete
//7.3.1
[1064] Fix | Delete
//---- drop long deprecated tables
[1065] Fix | Delete
$tables = array('wfBadLeechers', 'wfBlockedCommentLog', 'wfBlocks', 'wfBlocksAdv', 'wfLeechers', 'wfLockedOut', 'wfNet404s', 'wfScanners', 'wfThrottleLog', 'wfVulnScanners');
[1066] Fix | Delete
foreach ($tables as $t) {
[1067] Fix | Delete
$schema->drop($t);
[1068] Fix | Delete
}
[1069] Fix | Delete
[1070] Fix | Delete
//7.5.10
[1071] Fix | Delete
$knownFilesTable = wfDB::networkTable('wfKnownFileList');
[1072] Fix | Delete
$wordpressPathColumn = $wpdb->get_row($wpdb->prepare("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = %s AND COLUMN_NAME = 'wordpress_path'", $knownFilesTable));
[1073] Fix | Delete
if ($wordpressPathColumn === null) {
[1074] Fix | Delete
$wpdb->query("DELETE FROM `{$knownFilesTable}`");
[1075] Fix | Delete
$wpdb->query("ALTER TABLE `{$knownFilesTable}` ADD COLUMN wordpress_path TEXT NOT NULL");
[1076] Fix | Delete
}
[1077] Fix | Delete
[1078] Fix | Delete
$realPathColumn = $wpdb->get_row($wpdb->prepare("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = %s AND COLUMN_NAME = 'real_path'", $fileModsTable));
[1079] Fix | Delete
if ($realPathColumn === null) {
[1080] Fix | Delete
$wpdb->query("DELETE FROM `{$fileModsTable}`");
[1081] Fix | Delete
$wpdb->query("ALTER TABLE `{$fileModsTable}` ADD COLUMN real_path TEXT NOT NULL AFTER filename");
[1082] Fix | Delete
}
[1083] Fix | Delete
[1084] Fix | Delete
//wfFileMods updates
[1085] Fix | Delete
$wpdb->query("ALTER TABLE {$fileModsTable} ALTER COLUMN oldMD5 SET DEFAULT ''");
[1086] Fix | Delete
[1087] Fix | Delete
//---- enable legacy 2fa if applicable
[1088] Fix | Delete
if (wfConfig::get('isPaid') && (wfCredentialsController::hasOld2FARecords() || version_compare(phpversion(), '5.3', '<'))) {
[1089] Fix | Delete
wfConfig::set(wfCredentialsController::ALLOW_LEGACY_2FA_OPTION, true);
[1090] Fix | Delete
}
[1091] Fix | Delete
[1092] Fix | Delete
//Record the installation timestamp if activating the plugin for the first time
[1093] Fix | Delete
if (get_option('wordfenceActivated') != 1 && wfConfig::get('satisfactionPromptInstallDate') == 0 && empty(wfConfig::get('apiKey'))) {
[1094] Fix | Delete
wfConfig::set('satisfactionPromptInstallDate', time());
[1095] Fix | Delete
}
[1096] Fix | Delete
[1097] Fix | Delete
//Check the How does Wordfence get IPs setting
[1098] Fix | Delete
wfUtils::requestDetectProxyCallback();
[1099] Fix | Delete
[1100] Fix | Delete
//Install new schedule. If schedule config is blank it will install the default 'auto' schedule.
[1101] Fix | Delete
wfScanner::shared()->scheduleScans();
[1102] Fix | Delete
[1103] Fix | Delete
//Check our minimum versions and generate the necessary warnings
[1104] Fix | Delete
if (!wp_next_scheduled('wordfence_version_check')) {
[1105] Fix | Delete
wp_schedule_single_event(time(), 'wordfence_version_check');
[1106] Fix | Delete
}
[1107] Fix | Delete
[1108] Fix | Delete
//Must be the final line
[1109] Fix | Delete
}
[1110] Fix | Delete
private static function doEarlyAccessLogging(){
[1111] Fix | Delete
$wfLog = self::getLog();
[1112] Fix | Delete
if($wfLog->logHitOK()){
[1113] Fix | Delete
$request = $wfLog->getCurrentRequest();
[1114] Fix | Delete
[1115] Fix | Delete
if(is_404()){
[1116] Fix | Delete
if ($request) {
[1117] Fix | Delete
$request->statusCode = 404;
[1118] Fix | Delete
}
[1119] Fix | Delete
$wfLog->logLeechAndBlock('404');
[1120] Fix | Delete
} else {
[1121] Fix | Delete
$wfLog->logLeechAndBlock('hit');
[1122] Fix | Delete
}
[1123] Fix | Delete
}
[1124] Fix | Delete
}
[1125] Fix | Delete
public static function initProtection(){ //Basic protection during WAF learning period
[1126] Fix | Delete
// Infinite WP Client - Authentication Bypass < 1.9.4.5
[1127] Fix | Delete
// https://wpvulndb.com/vulnerabilities/10011
[1128] Fix | Delete
$iwpRule = new wfWAFRule(wfWAF::getInstance(), 0x80000000, null, 'auth-bypass', 100, 'Infinite WP Client - Authentication Bypass < 1.9.4.5', 0, 'block', null);
[1129] Fix | Delete
wfWAF::getInstance()->setRules(wfWAF::getInstance()->getRules() + array(0x80000000 => $iwpRule));
[1130] Fix | Delete
[1131] Fix | Delete
if (strrpos(wfWAF::getInstance()->getRequest()->getRawBody(), '_IWP_JSON_PREFIX_') !== false) {
[1132] Fix | Delete
$iwpRequestDataArray = explode('_IWP_JSON_PREFIX_', wfWAF::getInstance()->getRequest()->getRawBody());
[1133] Fix | Delete
$iwpRequest = json_decode(trim(base64_decode($iwpRequestDataArray[1])), true);
[1134] Fix | Delete
if (is_array($iwpRequest)) {
[1135] Fix | Delete
if (array_key_exists('iwp_action', $iwpRequest) &&
[1136] Fix | Delete
($iwpRequest['iwp_action'] === 'add_site' || $iwpRequest['iwp_action'] === 'readd_site')
[1137] Fix | Delete
) {
[1138] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/plugin.php';
[1139] Fix | Delete
if (is_plugin_active('iwp-client/init.php')) {
[1140] Fix | Delete
$iwpPluginData = get_plugin_data(WP_PLUGIN_DIR . '/iwp-client/init.php');
[1141] Fix | Delete
if (version_compare('1.9.4.5', $iwpPluginData['Version'], '>')) {
[1142] Fix | Delete
remove_action('setup_theme', 'iwp_mmb_set_request');
[1143] Fix | Delete
}
[1144] Fix | Delete
}
[1145] Fix | Delete
[1146] Fix | Delete
if ((is_multisite() ? get_site_option('iwp_client_action_message_id') : get_option('iwp_client_action_message_id')) &&
[1147] Fix | Delete
(is_multisite() ? get_site_option('iwp_client_public_key') : get_option('iwp_client_public_key'))
[1148] Fix | Delete
) {
[1149] Fix | Delete
wfWAF::getInstance()->getStorageEngine()->logAttack(array($iwpRule), 'request.rawBody',
[1150] Fix | Delete
wfWAF::getInstance()->getRequest()->getRawBody(),
[1151] Fix | Delete
wfWAF::getInstance()->getRequest(),
[1152] Fix | Delete
wfWAF::getInstance()->getRequest()->getMetadata()
[1153] Fix | Delete
);
[1154] Fix | Delete
}
[1155] Fix | Delete
}
[1156] Fix | Delete
}
[1157] Fix | Delete
}
[1158] Fix | Delete
}
[1159] Fix | Delete
public static function install_actions(){
[1160] Fix | Delete
register_activation_hook(WORDFENCE_FCPATH, 'wordfence::installPlugin');
[1161] Fix | Delete
register_deactivation_hook(WORDFENCE_FCPATH, 'wordfence::uninstallPlugin');
[1162] Fix | Delete
[1163] Fix | Delete
$versionInOptions = ((is_multisite() && function_exists('get_network_option')) ? get_network_option(null, 'wordfence_version', false) : get_option('wordfence_version', false));
[1164] Fix | Delete
if( (! $versionInOptions) || version_compare(WORDFENCE_VERSION, $versionInOptions, '>')){
[1165] Fix | Delete
//Either there is no version in options or the version in options is greater and we need to run the upgrade
[1166] Fix | Delete
self::runInstall();
[1167] Fix | Delete
}
[1168] Fix | Delete
[1169] Fix | Delete
self::getLog()->initLogRequest();
[1170] Fix | Delete
[1171] Fix | Delete
//Fix wp_mail bug when $_SERVER['SERVER_NAME'] is undefined
[1172] Fix | Delete
add_filter('wp_mail_from', 'wordfence::fixWPMailFromAddress');
[1173] Fix | Delete
[1174] Fix | Delete
//These access wfConfig::get('apiKey') and will fail if runInstall hasn't executed.
[1175] Fix | Delete
if(defined('MULTISITE') && MULTISITE === true){
[1176] Fix | Delete
global $blog_id;
[1177] Fix | Delete
if($blog_id == 1 && get_option('wordfenceActivated') != 1){ return; } //Because the plugin is active once installed, even before it's network activated, for site 1 (WordPress team, why?!)
[1178] Fix | Delete
}
[1179] Fix | Delete
//User may be logged in or not, so register both handlers
[1180] Fix | Delete
add_action('wp_ajax_nopriv_wordfence_lh', 'wordfence::ajax_lh_callback');
[1181] Fix | Delete
add_action('wp_ajax_nopriv_wordfence_doScan', 'wordfence::ajax_doScan_callback');
[1182] Fix | Delete
add_action('wp_ajax_nopriv_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
[1183] Fix | Delete
if(wfUtils::hasLoginCookie()){ //may be logged in. Fast way to check. These aren't secure functions, this is just a perf optimization, along with every other use of hasLoginCookie()
[1184] Fix | Delete
add_action('wp_ajax_wordfence_lh', 'wordfence::ajax_lh_callback');
[1185] Fix | Delete
add_action('wp_ajax_wordfence_doScan', 'wordfence::ajax_doScan_callback');
[1186] Fix | Delete
add_action('wp_ajax_wordfence_testAjax', 'wordfence::ajax_testAjax_callback');
[1187] Fix | Delete
[1188] Fix | Delete
if (is_multisite()) {
[1189] Fix | Delete
add_action('wp_network_dashboard_setup', 'wordfence::addDashboardWidget');
[1190] Fix | Delete
} else {
[1191] Fix | Delete
add_action('wp_dashboard_setup', 'wordfence::addDashboardWidget');
[1192] Fix | Delete
}
[1193] Fix | Delete
}
[1194] Fix | Delete
[1195] Fix | Delete
add_action('wp_ajax_wordfence_wafStatus', 'wordfence::ajax_wafStatus_callback');
[1196] Fix | Delete
add_action('wp_ajax_nopriv_wordfence_wafStatus', 'wordfence::ajax_wafStatus_callback');
[1197] Fix | Delete
[1198] Fix | Delete
add_action('wp_ajax_nopriv_wordfence_remoteVerifySwitchTo2FANew', 'wordfence::ajax_remoteVerifySwitchTo2FANew_callback');
[1199] Fix | Delete
[1200] Fix | Delete
add_action('wordfence_start_scheduled_scan', 'wordfence::wordfenceStartScheduledScan');
[1201] Fix | Delete
add_action('wordfence_daily_cron', 'wordfence::dailyCron');
[1202] Fix | Delete
add_action('wordfence_daily_autoUpdate', 'wfConfig::autoUpdate');
[1203] Fix | Delete
add_action('wordfence_hourly_cron', 'wordfence::hourlyCron');
[1204] Fix | Delete
add_action('wordfence_version_check', array(wfVersionCheckController::shared(), 'checkVersionsAndWarn'));
[1205] Fix | Delete
add_action('plugins_loaded', 'wordfence::veryFirstAction');
[1206] Fix | Delete
add_action('init', 'wordfence::initAction');
[1207] Fix | Delete
//add_action('admin_bar_menu', 'wordfence::admin_bar_menu', 99);
[1208] Fix | Delete
add_action('template_redirect', 'wordfence::templateRedir', 1001);
[1209] Fix | Delete
add_action('shutdown', 'wordfence::shutdownAction');
[1210] Fix | Delete
[1211] Fix | Delete
if (!wfConfig::get('ajaxWatcherDisabled_front')) {
[1212] Fix | Delete
add_action('wp_enqueue_scripts', 'wordfence::enqueueAJAXWatcher');
[1213] Fix | Delete
}
[1214] Fix | Delete
if (!wfConfig::get('ajaxWatcherDisabled_admin')) {
[1215] Fix | Delete
add_action('admin_enqueue_scripts', 'wordfence::enqueueAJAXWatcher');
[1216] Fix | Delete
}
[1217] Fix | Delete
[1218] Fix | Delete
//add_action('wp_enqueue_scripts', 'wordfence::enqueueDashboard');
[1219] Fix | Delete
add_action('admin_enqueue_scripts', 'wordfence::enqueueDashboard');
[1220] Fix | Delete
[1221] Fix | Delete
add_action('wp_authenticate','wordfence::authAction', 1, 2);
[1222] Fix | Delete
add_action('wp_authenticate_user', 'wordfence::authUserAction', 1, 2); //A secondary lockout check for plugins that override the login flow and don't call the complete set of hooks
[1223] Fix | Delete
add_filter('authenticate', 'wordfence::authenticateFilter', 99, 3);
[1224] Fix | Delete
[1225] Fix | Delete
$lockout = wfBlock::lockoutForIP(wfUtils::getIP());
[1226] Fix | Delete
if ($lockout !== false) {
[1227] Fix | Delete
add_filter('xmlrpc_enabled', '__return_false');
[1228] Fix | Delete
}
[1229] Fix | Delete
[1230] Fix | Delete
add_action('login_init','wordfence::loginInitAction');
[1231] Fix | Delete
add_action('wp_login','wordfence::loginAction');
[1232] Fix | Delete
add_action('wp_logout','wordfence::logoutAction');
[1233] Fix | Delete
add_action('lostpassword_post', 'wordfence::lostPasswordPost', 1, 2);
[1234] Fix | Delete
[1235] Fix | Delete
$allowSeparatePrompt = ini_get('output_buffering') > 0;
[1236] Fix | Delete
if (wfConfig::get('loginSec_enableSeparateTwoFactor') && $allowSeparatePrompt) {
[1237] Fix | Delete
add_action('login_form', 'wordfence::showTwoFactorField');
[1238] Fix | Delete
}
[1239] Fix | Delete
[1240] Fix | Delete
if(wfUtils::hasLoginCookie()){
[1241] Fix | Delete
add_action('user_profile_update_errors', 'wordfence::validateProfileUpdate', 0, 3 );
[1242] Fix | Delete
add_action('profile_update', 'wordfence::profileUpdateAction', 99, 2);
[1243] Fix | Delete
}
[1244] Fix | Delete
[1245] Fix | Delete
add_action('validate_password_reset', 'wordfence::validatePassword', 10, 2);
[1246] Fix | Delete
[1247] Fix | Delete
// Add actions for the email summary
[1248] Fix | Delete
add_action('wordfence_email_activity_report', array('wfActivityReport', 'executeCronJob'));
[1249] Fix | Delete
[1250] Fix | Delete
//For debugging
[1251] Fix | Delete
//add_filter( 'cron_schedules', 'wordfence::cronAddSchedules' );
[1252] Fix | Delete
[1253] Fix | Delete
add_filter('wp_redirect', 'wordfence::wpRedirectFilter', 99, 2);
[1254] Fix | Delete
add_filter('wp_redirect_status', 'wordfence::wpRedirectStatusFilter', 99, 2);
[1255] Fix | Delete
//html|xhtml|atom|rss2|rdf|comment|export
[1256] Fix | Delete
if(wfConfig::get('other_hideWPVersion')){
[1257] Fix | Delete
add_filter('style_loader_src', 'wordfence::replaceVersion');
[1258] Fix | Delete
add_filter('script_loader_src', 'wordfence::replaceVersion');
[1259] Fix | Delete
[1260] Fix | Delete
add_action('upgrader_process_complete', 'wordfence::hideReadme');
[1261] Fix | Delete
}
[1262] Fix | Delete
add_filter('get_the_generator_html', 'wordfence::genFilter', 99, 2);
[1263] Fix | Delete
add_filter('get_the_generator_xhtml', 'wordfence::genFilter', 99, 2);
[1264] Fix | Delete
add_filter('get_the_generator_atom', 'wordfence::genFilter', 99, 2);
[1265] Fix | Delete
add_filter('get_the_generator_rss2', 'wordfence::genFilter', 99, 2);
[1266] Fix | Delete
add_filter('get_the_generator_rdf', 'wordfence::genFilter', 99, 2);
[1267] Fix | Delete
add_filter('get_the_generator_comment', 'wordfence::genFilter', 99, 2);
[1268] Fix | Delete
add_filter('get_the_generator_export', 'wordfence::genFilter', 99, 2);
[1269] Fix | Delete
add_filter('registration_errors', 'wordfence::registrationFilter', 99, 3);
[1270] Fix | Delete
add_filter('woocommerce_new_customer_data', 'wordfence::wooRegistrationFilter', 99, 1);
[1271] Fix | Delete
[1272] Fix | Delete
if (wfConfig::get('loginSec_disableAuthorScan')) {
[1273] Fix | Delete
add_filter('oembed_response_data', 'wordfence::oembedAuthorFilter', 99, 4);
[1274] Fix | Delete
add_filter('rest_request_before_callbacks', 'wordfence::jsonAPIAuthorFilter', 99, 3);
[1275] Fix | Delete
add_filter('rest_post_dispatch', 'wordfence::jsonAPIAdjustHeaders', 99, 3);
[1276] Fix | Delete
add_filter('wp_sitemaps_users_pre_url_list', '__return_false', 99, 0);
[1277] Fix | Delete
add_filter('wp_sitemaps_add_provider', 'wordfence::wpSitemapUserProviderFilter', 99, 2);
[1278] Fix | Delete
}
[1279] Fix | Delete
[1280] Fix | Delete
if (wfConfig::get('loginSec_disableApplicationPasswords')) {
[1281] Fix | Delete
add_filter('wp_is_application_passwords_available', '__return_false');
[1282] Fix | Delete
add_action('edit_user_profile', 'wordfence::showDisabledApplicationPasswordsMessage', -1);
[1283] Fix | Delete
add_action('show_user_profile', 'wordfence::showDisabledApplicationPasswordsMessage', -1);
[1284] Fix | Delete
[1285] Fix | Delete
// Override the wp_die handler to let the user know app passwords were disabled by the Wordfence option.
[1286] Fix | Delete
if (!empty($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] === ABSPATH . 'wp-admin/authorize-application.php') {
[1287] Fix | Delete
add_filter('wp_die_handler', function ($handler = null) {
[1288] Fix | Delete
return function ($message, $title, $args) {
[1289] Fix | Delete
if ($message === 'Application passwords are not available.') {
[1290] Fix | Delete
$message = __('Application passwords have been disabled by Wordfence.', 'wordfence');
[1291] Fix | Delete
}
[1292] Fix | Delete
_default_wp_die_handler($message, $title, $args);
[1293] Fix | Delete
};
[1294] Fix | Delete
}, 10, 1);
[1295] Fix | Delete
}
[1296] Fix | Delete
}
[1297] Fix | Delete
[1298] Fix | Delete
add_filter('rest_dispatch_request', 'wordfence::_filterCentralFromLiveTraffic', 99, 4);
[1299] Fix | Delete
[1300] Fix | Delete
// Change GoDaddy's limit login mu-plugin since it can interfere with the two factor auth message.
[1301] Fix | Delete
if (self::hasGDLimitLoginsMUPlugin()) {
[1302] Fix | Delete
add_action('login_errors', array('wordfence', 'fixGDLimitLoginsErrors'), 11);
[1303] Fix | Delete
}
[1304] Fix | Delete
[1305] Fix | Delete
add_action('upgrader_process_complete', 'wfUpdateCheck::syncAllVersionInfo');
[1306] Fix | Delete
add_action('upgrader_process_complete', 'wordfence::_scheduleRefreshUpdateNotification', 99, 2);
[1307] Fix | Delete
add_action('automatic_updates_complete', 'wordfence::_scheduleRefreshUpdateNotification', 99, 0);
[1308] Fix | Delete
add_action('wordfence_refreshUpdateNotification', 'wordfence::_refreshUpdateNotification', 99, 0);
[1309] Fix | Delete
add_action('wordfence_completeCoreUpdateNotification', 'wordfence::_completeCoreUpdateNotification', 99, 0);
[1310] Fix | Delete
[1311] Fix | Delete
add_action('wfls_xml_rpc_blocked', 'wordfence::checkSecurityNetwork');
[1312] Fix | Delete
add_action('wfls_registration_blocked', 'wordfence::checkSecurityNetwork');
[1313] Fix | Delete
add_action('wfls_activation_page_footer', 'wordfence::_outputLoginSecurityTour');
[1314] Fix | Delete
add_action('wfls_settings_set', 'wordfence::queueCentralConfigurationSync', 10, 2);
[1315] Fix | Delete
[1316] Fix | Delete
if(is_admin()){
[1317] Fix | Delete
add_action('admin_init', 'wordfence::admin_init');
[1318] Fix | Delete
add_action('admin_head', 'wordfence::_retargetWordfenceSubmenuCallout');
[1319] Fix | Delete
if(is_multisite()){
[1320] Fix | Delete
if(wfUtils::isAdminPageMU()){
[1321] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus', 10);
[1322] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_20', 20);
[1323] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_30', 30);
[1324] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_40', 40);
[1325] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_50', 50);
[1326] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_60', 60);
[1327] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_70', 70);
[1328] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_80', 80);
[1329] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_85', 85);
[1330] Fix | Delete
add_action('network_admin_menu', 'wordfence::admin_menus_90', 90);
[1331] Fix | Delete
} //else don't show menu
[1332] Fix | Delete
} else {
[1333] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus', 10);
[1334] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_20', 20);
[1335] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_30', 30);
[1336] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_40', 40);
[1337] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_50', 50);
[1338] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_60', 60);
[1339] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_70', 70);
[1340] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_80', 80);
[1341] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_85', 85);
[1342] Fix | Delete
add_action('admin_menu', 'wordfence::admin_menus_90', 90);
[1343] Fix | Delete
}
[1344] Fix | Delete
add_filter('plugin_action_links_' . plugin_basename(realpath(dirname(__FILE__) . '/../wordfence.php')), 'wordfence::_pluginPageActionLinks');
[1345] Fix | Delete
add_filter('pre_current_active_plugins', 'wordfence::registerDeactivationPrompt');
[1346] Fix | Delete
}
[1347] Fix | Delete
[1348] Fix | Delete
add_action('request', 'wordfence::preventAuthorNScans');
[1349] Fix | Delete
add_action('password_reset', 'wordfence::actionPasswordReset');
[1350] Fix | Delete
[1351] Fix | Delete
$adminUsers = new wfAdminUserMonitor();
[1352] Fix | Delete
if ($adminUsers->isEnabled()) {
[1353] Fix | Delete
add_action('set_user_role', array($adminUsers, 'updateToUserRole'), 10, 3);
[1354] Fix | Delete
add_action('grant_super_admin', array($adminUsers, 'grantSuperAdmin'), 10, 1);
[1355] Fix | Delete
add_action('revoke_super_admin', array($adminUsers, 'revokeSuperAdmin'), 10, 1);
[1356] Fix | Delete
} else if (wfConfig::get_ser('adminUserList', false)) {
[1357] Fix | Delete
// reset this in the event it's disabled or the network is too large
[1358] Fix | Delete
wfConfig::set_ser('adminUserList', false);
[1359] Fix | Delete
}
[1360] Fix | Delete
[1361] Fix | Delete
if (wfConfig::liveTrafficEnabled()) {
[1362] Fix | Delete
add_action('wp_head', 'wordfence::wfLogHumanHeader');
[1363] Fix | Delete
add_action('login_head', 'wordfence::wfLogHumanHeader');
[1364] Fix | Delete
}
[1365] Fix | Delete
[1366] Fix | Delete
add_action('wordfence_processAttackData', 'wordfence::processAttackData');
[1367] Fix | Delete
if (!empty($_GET['wordfence_syncAttackData']) && get_site_option('wordfence_syncingAttackData') <= time() - 60 && get_site_option('wordfence_lastSyncAttackData', 0) < time() - 8) {
[1368] Fix | Delete
@ignore_user_abort(true);
[1369] Fix | Delete
update_site_option('wordfence_syncingAttackData', time());
[1370] Fix | Delete
header('Content-Type: text/javascript');
[1371] Fix | Delete
define('WORDFENCE_SYNCING_ATTACK_DATA', true);
[1372] Fix | Delete
add_action('init', 'wordfence::syncAttackData', 10, 0);
[1373] Fix | Delete
add_filter('woocommerce_unforce_ssl_checkout', '__return_false');
[1374] Fix | Delete
}
[1375] Fix | Delete
[1376] Fix | Delete
add_action('wordfence_batchReportBlockedAttempts', 'wordfence::wfsnBatchReportBlockedAttempts');
[1377] Fix | Delete
add_action('wordfence_batchReportFailedAttempts', 'wordfence::wfsnBatchReportFailedAttempts');
[1378] Fix | Delete
[1379] Fix | Delete
add_action('wordfence_batchSendSecurityEvents', 'wfCentral::sendPendingSecurityEvents');
[1380] Fix | Delete
[1381] Fix | Delete
if (wfConfig::get('other_hideWPVersion')) {
[1382] Fix | Delete
add_filter('update_feedback', 'wordfence::restoreReadmeForUpgrade');
[1383] Fix | Delete
}
[1384] Fix | Delete
[1385] Fix | Delete
add_action('rest_api_init', 'wordfence::initRestAPI');
[1386] Fix | Delete
[1387] Fix | Delete
if (wfCentral::isConnected()) {
[1388] Fix | Delete
add_action('wordfence_security_event', 'wfCentral::sendSecurityEvent', 10, 3);
[1389] Fix | Delete
} else {
[1390] Fix | Delete
add_action('wordfence_security_event', 'wfCentral::sendAlertCallback', 10, 3);
[1391] Fix | Delete
}
[1392] Fix | Delete
[1393] Fix | Delete
if (!wfConfig::get('wordfenceI18n', true)) {
[1394] Fix | Delete
add_filter('gettext', function ($translation, $text, $domain) {
[1395] Fix | Delete
if ($domain === 'wordfence') {
[1396] Fix | Delete
return $text;
[1397] Fix | Delete
}
[1398] Fix | Delete
return $translation;
[1399] Fix | Delete
}, 10, 3);
[1400] Fix | Delete
}
[1401] Fix | Delete
[1402] Fix | Delete
wfScanMonitor::registerActions();
[1403] Fix | Delete
wfUpdateCheck::installPluginAPIFixer();
[1404] Fix | Delete
}
[1405] Fix | Delete
[1406] Fix | Delete
public static function registerDeactivationPrompt() {
[1407] Fix | Delete
$deleteMain = (bool) wfConfig::get('deleteTablesOnDeact');
[1408] Fix | Delete
$deleteLoginSecurity = (bool) \WordfenceLS\Controller_Settings::shared()->get('delete-deactivation');
[1409] Fix | Delete
echo wfView::create(
[1410] Fix | Delete
'offboarding/deactivation-prompt',
[1411] Fix | Delete
array(
[1412] Fix | Delete
'deactivationOption' => wfDeactivationOption::forState($deleteMain, $deleteLoginSecurity),
[1413] Fix | Delete
'wafOptimized' => defined('WFWAF_AUTO_PREPEND') && WFWAF_AUTO_PREPEND && (!defined('WFWAF_SUBDIRECTORY_INSTALL') || !WFWAF_SUBDIRECTORY_INSTALL),
[1414] Fix | Delete
'deactivate' => array_key_exists('wf_deactivate', $_GET)
[1415] Fix | Delete
)
[1416] Fix | Delete
)->render();
[1417] Fix | Delete
}
[1418] Fix | Delete
[1419] Fix | Delete
public static function showDisabledApplicationPasswordsMessage() {
[1420] Fix | Delete
echo wfView::create('user/disabled-application-passwords', array('isAdmin' => self::isCurrentUserAdmin()))->render();
[1421] Fix | Delete
}
[1422] Fix | Delete
[1423] Fix | Delete
public static function _pluginPageActionLinks($links) {
[1424] Fix | Delete
if (!wfConfig::get('isPaid')) {
[1425] Fix | Delete
$links = array_merge(array('aWordfencePluginCallout' => '<a href="https://www.wordfence.com/zz12/wordfence-signup/" target="_blank" rel="noopener noreferrer"><strong style="color: #11967A; display: inline;">' . esc_html__('Upgrade To Premium', 'wordfence') . '</strong><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>'), $links);
[1426] Fix | Delete
}
[1427] Fix | Delete
return $links;
[1428] Fix | Delete
}
[1429] Fix | Delete
[1430] Fix | Delete
public static function _outputLoginSecurityTour() {
[1431] Fix | Delete
if (WORDFENCE_LS_FROM_CORE) {
[1432] Fix | Delete
echo wfView::create('tours/login-security', array())->render();
[1433] Fix | Delete
}
[1434] Fix | Delete
}
[1435] Fix | Delete
[1436] Fix | Delete
public static function fixWPMailFromAddress($from_email) {
[1437] Fix | Delete
if ($from_email == 'wordpress@') { //$_SERVER['SERVER_NAME'] is undefined so we get an incomplete email address
[1438] Fix | Delete
wordfence::status(4, 'info', __("wp_mail from address is incomplete, attempting to fix", 'wordfence'));
[1439] Fix | Delete
$urls = array(get_site_url(), get_home_url());
[1440] Fix | Delete
foreach ($urls as $u) {
[1441] Fix | Delete
if (!empty($u)) {
[1442] Fix | Delete
$u = preg_replace('#^[^/]*//+([^/]+).*$#', '\1', $u);
[1443] Fix | Delete
if (substr($u, 0, 4) == 'www.') {
[1444] Fix | Delete
$u = substr($u, 4);
[1445] Fix | Delete
}
[1446] Fix | Delete
[1447] Fix | Delete
if (!empty($u)) {
[1448] Fix | Delete
wordfence::status(4, 'info', sprintf(/* translators: Email address. */ __("Fixing wp_mail from address: %s", 'wordfence'), $from_email . $u));
[1449] Fix | Delete
return $from_email . $u;
[1450] Fix | Delete
}
[1451] Fix | Delete
}
[1452] Fix | Delete
}
[1453] Fix | Delete
[1454] Fix | Delete
//Can't fix it, return it as it was
[1455] Fix | Delete
}
[1456] Fix | Delete
return $from_email;
[1457] Fix | Delete
}
[1458] Fix | Delete
public static function wpRedirectFilter($location, $status) {
[1459] Fix | Delete
self::getLog()->initLogRequest();
[1460] Fix | Delete
self::getLog()->getCurrentRequest()->statusCode = $status;
[1461] Fix | Delete
return $location;
[1462] Fix | Delete
}
[1463] Fix | Delete
public static function wpRedirectStatusFilter($status, $location) {
[1464] Fix | Delete
self::getLog()->initLogRequest();
[1465] Fix | Delete
self::getLog()->getCurrentRequest()->statusCode = $status;
[1466] Fix | Delete
self::getLog()->logHit();
[1467] Fix | Delete
return $status;
[1468] Fix | Delete
}
[1469] Fix | Delete
public static function enqueueAJAXWatcher() {
[1470] Fix | Delete
$wafDisabled = !WFWAF_ENABLED || (class_exists('wfWAFConfig') && wfWAFConfig::isDisabled());
[1471] Fix | Delete
if (wfUtils::isAdmin() && !$wafDisabled) {
[1472] Fix | Delete
wp_enqueue_style('wordfenceAJAXcss', wfUtils::getBaseURL() . wfUtils::versionedAsset('css/wordfenceBox.css'), '', WORDFENCE_VERSION);
[1473] Fix | Delete
wp_enqueue_script('wfi18njs', wfUtils::getBaseURL() . wfUtils::versionedAsset('js/wfi18n.js'), array(), WORDFENCE_VERSION);
[1474] Fix | Delete
wp_enqueue_script('wordfenceAJAXjs', wfUtils::getBaseURL() . wfUtils::versionedAsset('js/admin.ajaxWatcher.js'), array('jquery'), WORDFENCE_VERSION);
[1475] Fix | Delete
wp_localize_script('wordfenceAJAXjs', 'WFAJAXWatcherVars', array(
[1476] Fix | Delete
'nonce' => wp_create_nonce('wf-waf-error-page'),
[1477] Fix | Delete
));
[1478] Fix | Delete
self::setupI18nJSStrings();
[1479] Fix | Delete
}
[1480] Fix | Delete
}
[1481] Fix | Delete
[1482] Fix | Delete
private static function isWordfencePage($includeWfls = true) {
[1483] Fix | Delete
return (isset($_GET['page']) && (preg_match('/^Wordfence/', @$_GET['page']) || ($includeWfls && $_GET['page'] == 'WFLS' && wfOnboardingController::shouldShowNewTour(wfOnboardingController::TOUR_LOGIN_SECURITY))));
[1484] Fix | Delete
}
[1485] Fix | Delete
[1486] Fix | Delete
private static function isWordfenceSubpage($page, $subpage) {
[1487] Fix | Delete
return array_key_exists('page', $_GET) && $_GET['page'] == ('Wordfence' . ucfirst($page)) && array_key_exists('subpage', $_GET) && $_GET['subpage'] == $subpage;
[1488] Fix | Delete
}
[1489] Fix | Delete
[1490] Fix | Delete
public static function enqueueDashboard() {
[1491] Fix | Delete
if (wfUtils::isAdmin()) {
[1492] Fix | Delete
wp_enqueue_style('wf-adminbar', wfUtils::getBaseURL() . wfUtils::versionedAsset('css/wf-adminbar.css'), '', WORDFENCE_VERSION);
[1493] Fix | Delete
wp_enqueue_style('wordfence-license-global-style', wfLicense::current()->getGlobalStylesheet(), '', WORDFENCE_VERSION);
[1494] Fix | Delete
wp_enqueue_script('wordfenceDashboardjs', wfUtils::getBaseURL() . wfUtils::versionedAsset('js/wfdashboard.js'), array('jquery'), WORDFENCE_VERSION);
[1495] Fix | Delete
if (wfConfig::get('showAdminBarMenu')) {
[1496] Fix | Delete
wp_enqueue_script('wordfencePopoverjs', wfUtils::getBaseURL() . wfUtils::versionedAsset('js/wfpopover.js'), array('jquery'), WORDFENCE_VERSION);
[1497] Fix | Delete
wp_localize_script('wordfenceDashboardjs', 'WFDashVars', array(
[1498] Fix | Delete
'ajaxURL' => admin_url('admin-ajax.php'),
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function