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
catch (wfViewNotFoundException $e) {
[4000] Fix | Delete
//Ignore -- should never happen since we validate the type
[4001] Fix | Delete
}
[4002] Fix | Delete
[4003] Fix | Delete
if (!empty($viewContent)) {
[4004] Fix | Delete
$content .= $viewContent . "\n\n";
[4005] Fix | Delete
}
[4006] Fix | Delete
}
[4007] Fix | Delete
}
[4008] Fix | Delete
else {
[4009] Fix | Delete
$content .= __('No Ignored Issues', 'wordfence') . "\n\n";
[4010] Fix | Delete
}
[4011] Fix | Delete
[4012] Fix | Delete
$content .= str_repeat('-', 80);
[4013] Fix | Delete
$content .= "\n\n";
[4014] Fix | Delete
[4015] Fix | Delete
ob_start();
[4016] Fix | Delete
if (wfUtils::funcEnabled('phpinfo')) { phpinfo(); } else { echo "\n\n" . __('Unable to output phpinfo content because it is disabled', 'wordfence') . "\n\n"; }
[4017] Fix | Delete
$phpinfo = ob_get_contents();
[4018] Fix | Delete
ob_get_clean();
[4019] Fix | Delete
[4020] Fix | Delete
$content .= $phpinfo;
[4021] Fix | Delete
[4022] Fix | Delete
$rawEmails = explode(",", $_POST['email']);
[4023] Fix | Delete
$emails = array();
[4024] Fix | Delete
foreach ($rawEmails as $e) {
[4025] Fix | Delete
$e = trim($e);
[4026] Fix | Delete
if (wfUtils::isValidEmail($e)) {
[4027] Fix | Delete
$emails[] = $e;
[4028] Fix | Delete
}
[4029] Fix | Delete
}
[4030] Fix | Delete
if (count($emails)) {
[4031] Fix | Delete
wp_mail(implode(', ', $emails), __('Wordfence Activity Log', 'wordfence'), $content);
[4032] Fix | Delete
}
[4033] Fix | Delete
return array('ok' => 1);
[4034] Fix | Delete
}
[4035] Fix | Delete
public static function ajax_downgradeLicense_callback(){
[4036] Fix | Delete
$api = new wfAPI('', wfUtils::getWPVersion());
[4037] Fix | Delete
try {
[4038] Fix | Delete
$keyData = $api->call('get_anon_api_key', array(), array('previousLicense' => wfConfig::get('apiKey')));
[4039] Fix | Delete
if($keyData['ok'] && $keyData['apiKey']){
[4040] Fix | Delete
wfLicense::current()->downgradeToFree($keyData['apiKey'])->save();
[4041] Fix | Delete
//When downgrading we must disable all two factor authentication because it can lock an admin out if we don't.
[4042] Fix | Delete
wfConfig::set_ser('twoFactorUsers', array());
[4043] Fix | Delete
wfConfig::remove('premiumAutoRenew');
[4044] Fix | Delete
wfConfig::remove('premiumNextRenew');
[4045] Fix | Delete
wfConfig::remove('premiumPaymentExpiring');
[4046] Fix | Delete
wfConfig::remove('premiumPaymentExpired');
[4047] Fix | Delete
wfConfig::remove('premiumPaymentMissing');
[4048] Fix | Delete
wfConfig::remove('premiumPaymentHold');
[4049] Fix | Delete
self::licenseStatusChanged();
[4050] Fix | Delete
if (method_exists(wfWAF::getInstance()->getStorageEngine(), 'purgeIPBlocks')) {
[4051] Fix | Delete
wfWAF::getInstance()->getStorageEngine()->purgeIPBlocks(wfWAFStorageInterface::IP_BLOCKS_BLACKLIST);
[4052] Fix | Delete
}
[4053] Fix | Delete
} else {
[4054] Fix | Delete
throw new Exception(__("Could not understand the response we received from the Wordfence servers when applying for a free license key.", 'wordfence'));
[4055] Fix | Delete
}
[4056] Fix | Delete
} catch(Exception $e){
[4057] Fix | Delete
return array('errorMsg' => sprintf(/* translators: Error message. */ __("Could not fetch free license key from Wordfence: %s", 'wordfence'), wp_kses($e->getMessage(), array())));
[4058] Fix | Delete
}
[4059] Fix | Delete
return array('ok' => 1);
[4060] Fix | Delete
}
[4061] Fix | Delete
public static function ajax_tourClosed_callback() {
[4062] Fix | Delete
$page = '';
[4063] Fix | Delete
if (isset($_POST['page'])) {
[4064] Fix | Delete
$page = $_POST['page'];
[4065] Fix | Delete
}
[4066] Fix | Delete
[4067] Fix | Delete
[4068] Fix | Delete
$keys = array(wfOnboardingController::TOUR_DASHBOARD, wfOnboardingController::TOUR_FIREWALL, wfOnboardingController::TOUR_SCAN, wfOnboardingController::TOUR_BLOCKING, wfOnboardingController::TOUR_LIVE_TRAFFIC, wfOnboardingController::TOUR_LOGIN_SECURITY);
[4069] Fix | Delete
if (in_array($page, $keys)) {
[4070] Fix | Delete
if (wfOnboardingController::shouldShowNewTour($page)) {
[4071] Fix | Delete
wfConfig::set('needsNewTour_' . $page, 0);
[4072] Fix | Delete
}
[4073] Fix | Delete
else if (wfOnboardingController::shouldShowUpgradeTour($page)) {
[4074] Fix | Delete
wfConfig::set('needsUpgradeTour_' . $page, 0);
[4075] Fix | Delete
}
[4076] Fix | Delete
}
[4077] Fix | Delete
[4078] Fix | Delete
return array('ok' => 1);
[4079] Fix | Delete
}
[4080] Fix | Delete
public static function ajax_autoUpdateChoice_callback(){
[4081] Fix | Delete
$choice = $_POST['choice'];
[4082] Fix | Delete
wfConfig::set('autoUpdateChoice', '1');
[4083] Fix | Delete
if($choice == 'yes'){
[4084] Fix | Delete
wfConfig::set('autoUpdate', '1');
[4085] Fix | Delete
} else {
[4086] Fix | Delete
wfConfig::set('autoUpdate', '0');
[4087] Fix | Delete
}
[4088] Fix | Delete
return array('ok' => 1);
[4089] Fix | Delete
}
[4090] Fix | Delete
public static function ajax_misconfiguredHowGetIPsChoice_callback() {
[4091] Fix | Delete
$choice = $_POST['choice'];
[4092] Fix | Delete
if ($choice == 'yes') {
[4093] Fix | Delete
wfConfig::set('howGetIPs', wfConfig::get('detectProxyRecommendation', ''));
[4094] Fix | Delete
[4095] Fix | Delete
if (isset($_POST['issueID'])) {
[4096] Fix | Delete
$issueID = intval($_POST['issueID']);
[4097] Fix | Delete
$wfIssues = new wfIssues();
[4098] Fix | Delete
$wfIssues->updateIssue($issueID, 'delete');
[4099] Fix | Delete
wfScanEngine::refreshScanNotification($wfIssues);
[4100] Fix | Delete
}
[4101] Fix | Delete
}
[4102] Fix | Delete
else {
[4103] Fix | Delete
wfConfig::set('misconfiguredHowGetIPsChoice' . WORDFENCE_VERSION, '1');
[4104] Fix | Delete
}
[4105] Fix | Delete
return array('ok' => 1);
[4106] Fix | Delete
}
[4107] Fix | Delete
public static function ajax_switchLiveTrafficSecurityOnlyChoice_callback() {
[4108] Fix | Delete
$choice = $_POST['choice'];
[4109] Fix | Delete
if ($choice == 'yes') {
[4110] Fix | Delete
wfConfig::set('liveTrafficEnabled', false);
[4111] Fix | Delete
}
[4112] Fix | Delete
else {
[4113] Fix | Delete
wfConfig::set('switchLiveTrafficSecurityOnlyChoice', '1');
[4114] Fix | Delete
}
[4115] Fix | Delete
return array('ok' => 1);
[4116] Fix | Delete
}
[4117] Fix | Delete
public static function ajax_wordfenceSatisfactionChoice_callback() {
[4118] Fix | Delete
wfConfig::set('satisfactionPromptDismissed', time());
[4119] Fix | Delete
$choice = $_POST['choice'];
[4120] Fix | Delete
if ($choice == 'feedback' && isset($_POST['feedback']) && !empty($_POST['feedback'])) {
[4121] Fix | Delete
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
[4122] Fix | Delete
$result = $api->call('plugin_feedback', array(), array('feedback' => $_POST['feedback']));
[4123] Fix | Delete
}
[4124] Fix | Delete
//else -- no additional action for yes/no
[4125] Fix | Delete
return array('ok' => 1);
[4126] Fix | Delete
}
[4127] Fix | Delete
public static function ajax_dismissAdminNotice_callback() {
[4128] Fix | Delete
if (isset($_POST['id'])) {
[4129] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice($_POST['id']);
[4130] Fix | Delete
}
[4131] Fix | Delete
return array('ok' => 1);
[4132] Fix | Delete
}
[4133] Fix | Delete
public static function ajax_hideNoticeForUser_callback() {
[4134] Fix | Delete
if (isset($_POST['id'])) {
[4135] Fix | Delete
self::hideNoticeForUser($_POST['id']);
[4136] Fix | Delete
}
[4137] Fix | Delete
return array('ok' => 1);
[4138] Fix | Delete
}
[4139] Fix | Delete
public static function ajax_updateConfig_callback(){
[4140] Fix | Delete
$key = $_POST['key'];
[4141] Fix | Delete
$val = $_POST['val'];
[4142] Fix | Delete
wfConfig::set($key, $val);
[4143] Fix | Delete
[4144] Fix | Delete
if ($key == 'howGetIPs') {
[4145] Fix | Delete
wfConfig::set('detectProxyNextCheck', false, wfConfig::DONT_AUTOLOAD);
[4146] Fix | Delete
$ipAll = wfUtils::getIPPreview();
[4147] Fix | Delete
$ip = wfUtils::getIP(true);
[4148] Fix | Delete
return array('ok' => 1, 'ip' => $ip, 'ipAll' => $ipAll);
[4149] Fix | Delete
}
[4150] Fix | Delete
[4151] Fix | Delete
return array('ok' => 1);
[4152] Fix | Delete
}
[4153] Fix | Delete
public static function ajax_checkHtaccess_callback(){
[4154] Fix | Delete
if(wfUtils::isNginx()){
[4155] Fix | Delete
return array('nginx' => 1);
[4156] Fix | Delete
}
[4157] Fix | Delete
$file = wfCache::getHtaccessPath();
[4158] Fix | Delete
if(! $file){
[4159] Fix | Delete
return array('err' => __("We could not find your .htaccess file to modify it.", 'wordfence'));
[4160] Fix | Delete
}
[4161] Fix | Delete
$fh = @fopen($file, 'r+');
[4162] Fix | Delete
if(! $fh){
[4163] Fix | Delete
$err = error_get_last();
[4164] Fix | Delete
return array('err' => sprintf(/* translators: Error message. */ __("We found your .htaccess file but could not open it for writing: %s", 'wordfence'), $err['message']));
[4165] Fix | Delete
}
[4166] Fix | Delete
return array('ok' => 1);
[4167] Fix | Delete
}
[4168] Fix | Delete
public static function ajax_downloadHtaccess_callback(){
[4169] Fix | Delete
$url = site_url();
[4170] Fix | Delete
$url = preg_replace('/^https?:\/\//i', '', $url);
[4171] Fix | Delete
$url = preg_replace('/[^a-zA-Z0-9\.]+/', '_', $url);
[4172] Fix | Delete
$url = preg_replace('/^_+/', '', $url);
[4173] Fix | Delete
$url = preg_replace('/_+$/', '', $url);
[4174] Fix | Delete
header('Content-Type: application/octet-stream');
[4175] Fix | Delete
header('Content-Disposition: attachment; filename="htaccess_Backup_for_' . $url . '.txt"');
[4176] Fix | Delete
$file = wfCache::getHtaccessPath();
[4177] Fix | Delete
readfile($file);
[4178] Fix | Delete
die();
[4179] Fix | Delete
}
[4180] Fix | Delete
public static function ajax_downloadLogFile_callback() {
[4181] Fix | Delete
if (!isset($_GET['logfile'])) {
[4182] Fix | Delete
status_header(400);
[4183] Fix | Delete
nocache_headers();
[4184] Fix | Delete
exit;
[4185] Fix | Delete
}
[4186] Fix | Delete
[4187] Fix | Delete
wfErrorLogHandler::outputErrorLog(stripslashes($_GET['logfile'])); //exits
[4188] Fix | Delete
}
[4189] Fix | Delete
public static function _blocksAJAXReponse(&$hasCountryBlock = false, $offset = 0, $sortColumn = 'type', $sortDirection = 'ascending', $filter = '') {
[4190] Fix | Delete
$includeAutomatic = wfConfig::get('displayAutomaticBlocks');
[4191] Fix | Delete
$types = array(); //Empty array is all
[4192] Fix | Delete
if (!$includeAutomatic) {
[4193] Fix | Delete
$types = array(wfBlock::TYPE_IP_MANUAL, wfBlock::TYPE_IP_AUTOMATIC_PERMANENT, wfBlock::TYPE_COUNTRY, wfBlock::TYPE_PATTERN);
[4194] Fix | Delete
}
[4195] Fix | Delete
[4196] Fix | Delete
if (empty($filter)) {
[4197] Fix | Delete
$blocks = wfBlock::allBlocks(true, $types, $offset, WORDFENCE_BLOCKED_IPS_PER_PAGE, $sortColumn, $sortDirection);
[4198] Fix | Delete
}
[4199] Fix | Delete
else {
[4200] Fix | Delete
$blocks = wfBlock::filteredBlocks(true, $types, $offset, WORDFENCE_BLOCKED_IPS_PER_PAGE, $sortColumn, $sortDirection, $filter);
[4201] Fix | Delete
}
[4202] Fix | Delete
$dateFormat = get_option('date_format') . ' ' . get_option('time_format');
[4203] Fix | Delete
$hasCountryBlock = wfUtils::array_first(wfBlock::countryBlocks(true));
[4204] Fix | Delete
if ($hasCountryBlock !== null) {
[4205] Fix | Delete
$hasCountryBlock = json_encode($hasCountryBlock->editValues());
[4206] Fix | Delete
}
[4207] Fix | Delete
else {
[4208] Fix | Delete
$hasCountryBlock = '';
[4209] Fix | Delete
}
[4210] Fix | Delete
[4211] Fix | Delete
$response = array();
[4212] Fix | Delete
foreach ($blocks as $b) {
[4213] Fix | Delete
$skip = false;
[4214] Fix | Delete
[4215] Fix | Delete
$entry = array();
[4216] Fix | Delete
$entry['id'] = $b->id;
[4217] Fix | Delete
$entry['typeSort'] = $b->type;
[4218] Fix | Delete
$entry['typeDisplay'] = esc_html(wfBlock::nameForType($b->type));
[4219] Fix | Delete
[4220] Fix | Delete
switch ($b->type) {
[4221] Fix | Delete
case wfBlock::TYPE_IP_MANUAL:
[4222] Fix | Delete
$entry['editType'] = 'ip-address';
[4223] Fix | Delete
case wfBlock::TYPE_IP_AUTOMATIC_PERMANENT:
[4224] Fix | Delete
$entry['detailSort'] = base64_encode(wfUtils::inet_pton($b->ip));
[4225] Fix | Delete
$entry['detailDisplay'] = esc_html($b->ip);
[4226] Fix | Delete
break;
[4227] Fix | Delete
case wfBlock::TYPE_IP_AUTOMATIC_TEMPORARY:
[4228] Fix | Delete
case wfBlock::TYPE_WFSN_TEMPORARY:
[4229] Fix | Delete
case wfBlock::TYPE_RATE_BLOCK:
[4230] Fix | Delete
case wfBlock::TYPE_RATE_THROTTLE:
[4231] Fix | Delete
case wfBlock::TYPE_LOCKOUT:
[4232] Fix | Delete
if (!$includeAutomatic) { $skip = true; }
[4233] Fix | Delete
$entry['detailSort'] = base64_encode(wfUtils::inet_pton($b->ip));
[4234] Fix | Delete
$entry['detailDisplay'] = esc_html($b->ip);
[4235] Fix | Delete
break;
[4236] Fix | Delete
case wfBlock::TYPE_COUNTRY:
[4237] Fix | Delete
require(WORDFENCE_PATH . 'lib/wfBulkCountries.php'); /** @var array $wfBulkCountries */
[4238] Fix | Delete
ksort($wfBulkCountries);
[4239] Fix | Delete
$countries = $b->countries;
[4240] Fix | Delete
sort($countries);
[4241] Fix | Delete
$entry['editable'] = 1;
[4242] Fix | Delete
$entry['editType'] = 'country';
[4243] Fix | Delete
$entry['editValues'] = json_encode($b->editValues());
[4244] Fix | Delete
$entry['detailSort'] = $b->blockLogin . '|' . $b->blockSite . '|' . implode('|', $countries);
[4245] Fix | Delete
$entry['detailDisplay'] = '';
[4246] Fix | Delete
if ($countries == array_keys($wfBulkCountries)) {
[4247] Fix | Delete
$entry['detailDisplay'] = __('All Countries', 'wordfence');
[4248] Fix | Delete
}
[4249] Fix | Delete
else if (count($countries) == 1) {
[4250] Fix | Delete
$entry['detailDisplay'] = __('1 Country', 'wordfence');
[4251] Fix | Delete
}
[4252] Fix | Delete
else {
[4253] Fix | Delete
$entry['detailDisplay'] = sprintf(/* translators: Number of countries. */ __('%d Countries', 'wordfence'), count($countries));
[4254] Fix | Delete
}
[4255] Fix | Delete
[4256] Fix | Delete
if ($b->blockLogin && $b->blockSite) {
[4257] Fix | Delete
$entry['detailDisplay'] .= ' (' . __('Entire Site', 'wordfence') . ')';
[4258] Fix | Delete
}
[4259] Fix | Delete
else if ($b->blockLogin) {
[4260] Fix | Delete
$entry['detailDisplay'] .= ' (' . __('Login Only', 'wordfence') . ')';
[4261] Fix | Delete
}
[4262] Fix | Delete
else if ($b->blockSite) {
[4263] Fix | Delete
$entry['detailDisplay'] .= ' (' . __('Site Except Login', 'wordfence') . ')';
[4264] Fix | Delete
}
[4265] Fix | Delete
[4266] Fix | Delete
break;
[4267] Fix | Delete
case wfBlock::TYPE_PATTERN:
[4268] Fix | Delete
$entry['editType'] = 'custom-pattern';
[4269] Fix | Delete
$entry['detailSort'] = base64_encode($b->ipRange . '|' . $b->userAgent . '|' . $b->referrer . '|' . $b->hostname);
[4270] Fix | Delete
$components = array();
[4271] Fix | Delete
if (!empty($b->ipRange)) { $components[] = __('IP Range', 'wordfence') . ' - ' . $b->ipRange; }
[4272] Fix | Delete
if (!empty($b->userAgent)) { $components[] = __('User Agent', 'wordfence') . ' - ' . $b->userAgent; }
[4273] Fix | Delete
if (!empty($b->referrer)) { $components[] = __('Referrer', 'wordfence') . ' - ' . $b->referrer; }
[4274] Fix | Delete
if (!empty($b->hostname)) { $components[] = __('Hostname', 'wordfence') . ' - ' . $b->hostname; }
[4275] Fix | Delete
$entry['detailDisplay'] = esc_html(implode(', ', $components));
[4276] Fix | Delete
break;
[4277] Fix | Delete
}
[4278] Fix | Delete
[4279] Fix | Delete
if ($skip) { continue; }
[4280] Fix | Delete
[4281] Fix | Delete
$entry['ruleAdded'] = $b->blockedTime;
[4282] Fix | Delete
$entry['ruleAddedSort'] = $b->blockedTime;
[4283] Fix | Delete
$entry['ruleAddedDisplay'] = esc_html(wfUtils::formatLocalTime($dateFormat, $b->blockedTime));
[4284] Fix | Delete
$entry['reasonSort'] = esc_attr($b->reason);
[4285] Fix | Delete
$entry['reasonDisplay'] = esc_html($b->reason);
[4286] Fix | Delete
$entry['expiration'] = $b->expiration;
[4287] Fix | Delete
$entry['expirationSort'] = $b->expiration;
[4288] Fix | Delete
$entry['expirationDisplay'] = ($b->expiration == wfBlock::DURATION_FOREVER ? __('Permanent', 'wordfence') : esc_html(wfUtils::formatLocalTime($dateFormat, $b->expiration)));
[4289] Fix | Delete
$entry['blockCountSort'] = $b->blockedHits;
[4290] Fix | Delete
$entry['blockCountDisplay'] = $b->blockedHits;
[4291] Fix | Delete
$entry['lastAttemptSort'] = $b->lastAttempt;
[4292] Fix | Delete
$entry['lastAttemptDisplay'] = ($b->lastAttempt == 0 ? __('Never', 'wordfence') : esc_html(wfUtils::formatLocalTime($dateFormat, $b->lastAttempt)));
[4293] Fix | Delete
[4294] Fix | Delete
$response[] = $entry;
[4295] Fix | Delete
}
[4296] Fix | Delete
return $response;
[4297] Fix | Delete
}
[4298] Fix | Delete
public static function ajax_getBlocks_callback() {
[4299] Fix | Delete
$offset = 0;
[4300] Fix | Delete
if (isset($_POST['offset'])) {
[4301] Fix | Delete
$offset = (int) $_POST['offset'];
[4302] Fix | Delete
}
[4303] Fix | Delete
[4304] Fix | Delete
$sortColumn = 'type';
[4305] Fix | Delete
if (isset($_POST['sortColumn']) && in_array($_POST['sortColumn'], array('type', 'detail', 'ruleAdded', 'reason', 'expiration', 'blockCount', 'lastAttempt'))) {
[4306] Fix | Delete
$sortColumn = $_POST['sortColumn'];
[4307] Fix | Delete
}
[4308] Fix | Delete
[4309] Fix | Delete
$sortDirection = 'ascending';
[4310] Fix | Delete
if (isset($_POST['sortDirection']) && in_array($_POST['sortDirection'], array('ascending', 'descending'))) {
[4311] Fix | Delete
$sortDirection = $_POST['sortDirection'];
[4312] Fix | Delete
}
[4313] Fix | Delete
[4314] Fix | Delete
$filter = '';
[4315] Fix | Delete
if (isset($_POST['blocksFilter'])) {
[4316] Fix | Delete
$filter = $_POST['blocksFilter'];
[4317] Fix | Delete
}
[4318] Fix | Delete
[4319] Fix | Delete
$hasCountryBlock = false;
[4320] Fix | Delete
$blocks = self::_blocksAJAXReponse($hasCountryBlock, $offset, $sortColumn, $sortDirection, $filter);
[4321] Fix | Delete
return array('blocks' => $blocks, 'hasCountryBlock' => $hasCountryBlock);
[4322] Fix | Delete
}
[4323] Fix | Delete
public static function ajax_createBlock_callback() {
[4324] Fix | Delete
$offset = 0;
[4325] Fix | Delete
if (isset($_POST['offset'])) {
[4326] Fix | Delete
$offset = (int) $_POST['offset'];
[4327] Fix | Delete
}
[4328] Fix | Delete
[4329] Fix | Delete
$sortColumn = 'type';
[4330] Fix | Delete
if (isset($_POST['sortColumn']) && in_array($_POST['sortColumn'], array('type', 'detail', 'ruleAdded', 'reason', 'expiration', 'blockCount', 'lastAttempt'))) {
[4331] Fix | Delete
$sortColumn = $_POST['sortColumn'];
[4332] Fix | Delete
}
[4333] Fix | Delete
[4334] Fix | Delete
$sortDirection = 'ascending';
[4335] Fix | Delete
if (isset($_POST['sortDirection']) && in_array($_POST['sortDirection'], array('ascending', 'descending'))) {
[4336] Fix | Delete
$sortDirection = $_POST['sortDirection'];
[4337] Fix | Delete
}
[4338] Fix | Delete
[4339] Fix | Delete
$filter = '';
[4340] Fix | Delete
if (isset($_POST['blocksFilter'])) {
[4341] Fix | Delete
$filter = $_POST['blocksFilter'];
[4342] Fix | Delete
}
[4343] Fix | Delete
[4344] Fix | Delete
if (!empty($_POST['payload']) && ($payload = json_decode(stripslashes($_POST['payload']), true)) !== false) {
[4345] Fix | Delete
try {
[4346] Fix | Delete
$error = wfBlock::validate($payload);
[4347] Fix | Delete
if ($error !== true) {
[4348] Fix | Delete
return array(
[4349] Fix | Delete
'error' => $error,
[4350] Fix | Delete
);
[4351] Fix | Delete
}
[4352] Fix | Delete
[4353] Fix | Delete
wfBlock::create($payload);
[4354] Fix | Delete
$hasCountryBlock = false;
[4355] Fix | Delete
$blocks = self::_blocksAJAXReponse($hasCountryBlock, $offset, $sortColumn, $sortDirection, $filter);
[4356] Fix | Delete
return array('success' => true, 'blocks' => $blocks, 'hasCountryBlock' => $hasCountryBlock);
[4357] Fix | Delete
}
[4358] Fix | Delete
catch (Exception $e) {
[4359] Fix | Delete
return array(
[4360] Fix | Delete
'error' => __('An error occurred while creating the block.', 'wordfence'),
[4361] Fix | Delete
);
[4362] Fix | Delete
}
[4363] Fix | Delete
}
[4364] Fix | Delete
[4365] Fix | Delete
return array(
[4366] Fix | Delete
'error' => __('No block parameters were provided.', 'wordfence'),
[4367] Fix | Delete
);
[4368] Fix | Delete
}
[4369] Fix | Delete
public static function ajax_deleteBlocks_callback() {
[4370] Fix | Delete
$offset = 0;
[4371] Fix | Delete
if (isset($_POST['offset'])) {
[4372] Fix | Delete
$offset = (int) $_POST['offset'];
[4373] Fix | Delete
}
[4374] Fix | Delete
[4375] Fix | Delete
$sortColumn = 'type';
[4376] Fix | Delete
if (isset($_POST['sortColumn']) && in_array($_POST['sortColumn'], array('type', 'detail', 'ruleAdded', 'reason', 'expiration', 'blockCount', 'lastAttempt'))) {
[4377] Fix | Delete
$sortColumn = $_POST['sortColumn'];
[4378] Fix | Delete
}
[4379] Fix | Delete
[4380] Fix | Delete
$sortDirection = 'ascending';
[4381] Fix | Delete
if (isset($_POST['sortDirection']) && in_array($_POST['sortDirection'], array('ascending', 'descending'))) {
[4382] Fix | Delete
$sortDirection = $_POST['sortDirection'];
[4383] Fix | Delete
}
[4384] Fix | Delete
[4385] Fix | Delete
$filter = '';
[4386] Fix | Delete
if (isset($_POST['blocksFilter'])) {
[4387] Fix | Delete
$filter = $_POST['blocksFilter'];
[4388] Fix | Delete
}
[4389] Fix | Delete
[4390] Fix | Delete
if (!empty($_POST['blocks']) && ($blocks = json_decode(stripslashes($_POST['blocks']), true)) !== false && is_array($blocks)) {
[4391] Fix | Delete
$removed = wfBlock::removeBlockIDs($blocks, true); //wfBlock::removeBlockIDs sanitizes the array
[4392] Fix | Delete
if($removed!==false) {
[4393] Fix | Delete
foreach($removed as $block) {
[4394] Fix | Delete
self::clearLockoutCounters(wfUtils::inet_ntop($block->IP));
[4395] Fix | Delete
}
[4396] Fix | Delete
}
[4397] Fix | Delete
$hasCountryBlock = false;
[4398] Fix | Delete
$blocks = self::_blocksAJAXReponse($hasCountryBlock, $offset, $sortColumn, $sortDirection, $filter);
[4399] Fix | Delete
return array('success' => true, 'blocks' => $blocks, 'hasCountryBlock' => $hasCountryBlock);
[4400] Fix | Delete
}
[4401] Fix | Delete
[4402] Fix | Delete
return array(
[4403] Fix | Delete
'error' => __('No blocks were provided.', 'wordfence'),
[4404] Fix | Delete
);
[4405] Fix | Delete
}
[4406] Fix | Delete
public static function ajax_makePermanentBlocks_callback() {
[4407] Fix | Delete
$offset = 0;
[4408] Fix | Delete
if (isset($_POST['offset'])) {
[4409] Fix | Delete
$offset = (int) $_POST['offset'];
[4410] Fix | Delete
}
[4411] Fix | Delete
[4412] Fix | Delete
$sortColumn = 'type';
[4413] Fix | Delete
if (isset($_POST['sortColumn']) && in_array($_POST['sortColumn'], array('type', 'detail', 'ruleAdded', 'reason', 'expiration', 'blockCount', 'lastAttempt'))) {
[4414] Fix | Delete
$sortColumn = $_POST['sortColumn'];
[4415] Fix | Delete
}
[4416] Fix | Delete
[4417] Fix | Delete
$sortDirection = 'ascending';
[4418] Fix | Delete
if (isset($_POST['sortDirection']) && in_array($_POST['sortDirection'], array('ascending', 'descending'))) {
[4419] Fix | Delete
$sortDirection = $_POST['sortDirection'];
[4420] Fix | Delete
}
[4421] Fix | Delete
[4422] Fix | Delete
$filter = '';
[4423] Fix | Delete
if (isset($_POST['blocksFilter'])) {
[4424] Fix | Delete
$filter = $_POST['blocksFilter'];
[4425] Fix | Delete
}
[4426] Fix | Delete
[4427] Fix | Delete
if (!empty($_POST['updates']) && ($updates = json_decode(stripslashes($_POST['updates']), true)) !== false && is_array($updates)) {
[4428] Fix | Delete
wfBlock::makePermanentBlockIDs($updates); //wfBlock::makePermanentBlockIDs sanitizes the array
[4429] Fix | Delete
$hasCountryBlock = false;
[4430] Fix | Delete
$blocks = self::_blocksAJAXReponse($hasCountryBlock, $offset, $sortColumn, $sortDirection, $filter);
[4431] Fix | Delete
return array('success' => true, 'blocks' => $blocks, 'hasCountryBlock' => $hasCountryBlock);
[4432] Fix | Delete
}
[4433] Fix | Delete
[4434] Fix | Delete
return array(
[4435] Fix | Delete
'error' => __('No blocks were provided.', 'wordfence'),
[4436] Fix | Delete
);
[4437] Fix | Delete
}
[4438] Fix | Delete
public static function ajax_installLicense_callback() {
[4439] Fix | Delete
if (!empty($_POST['license'])) {
[4440] Fix | Delete
$statusChange = array_key_exists('status_change', $_POST) ? filter_var($_POST['status_change'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) : null;
[4441] Fix | Delete
$license = strtolower(trim($_POST['license']));
[4442] Fix | Delete
if (!preg_match('/^[a-fA-F0-9]+$/', $license)) {
[4443] Fix | Delete
return array(
[4444] Fix | Delete
'error' => __('The license key entered is not in a valid format. It must contain only numbers and the letters A-F.', 'wordfence'),
[4445] Fix | Delete
);
[4446] Fix | Delete
}
[4447] Fix | Delete
[4448] Fix | Delete
$existingLicense = strtolower(wfConfig::get('apiKey', ''));
[4449] Fix | Delete
if ($existingLicense != $license) { //Key changed, try activating
[4450] Fix | Delete
$api = new wfAPI($license, wfUtils::getWPVersion());
[4451] Fix | Delete
try {
[4452] Fix | Delete
$parameters = array();
[4453] Fix | Delete
if (!empty($existingLicense))
[4454] Fix | Delete
$parameters['previousLicense'] = $existingLicense;
[4455] Fix | Delete
$res = $api->call('check_api_key', array(), $parameters);
[4456] Fix | Delete
if ($res['ok'] && isset($res['isPaid'])) {
[4457] Fix | Delete
$isPaid = wfUtils::truthyToBoolean($res['isPaid']);
[4458] Fix | Delete
wfConfig::set('apiKey', $license);
[4459] Fix | Delete
wfConfig::set('isPaid', $isPaid); //res['isPaid'] is boolean coming back as JSON and turned back into PHP struct. Assuming JSON to PHP handles bools.
[4460] Fix | Delete
if ($statusChange !== false) {
[4461] Fix | Delete
self::licenseStatusChanged();
[4462] Fix | Delete
}
[4463] Fix | Delete
if (!$isPaid) {
[4464] Fix | Delete
wfConfig::set('keyType', wfLicense::KEY_TYPE_FREE);
[4465] Fix | Delete
}
[4466] Fix | Delete
self::scheduleCrons();
[4467] Fix | Delete
return array(
[4468] Fix | Delete
'success' => 1,
[4469] Fix | Delete
'isPaid' => wfConfig::get('isPaid') ? 1 : 0,
[4470] Fix | Delete
'type' => wfLicense::current()->getType()
[4471] Fix | Delete
);
[4472] Fix | Delete
}
[4473] Fix | Delete
else if (isset($res['_hasKeyConflict']) && $res['_hasKeyConflict']) {
[4474] Fix | Delete
return array(
[4475] Fix | Delete
'error' => __('The license provided is already in use on another site.', 'wordfence'),
[4476] Fix | Delete
);
[4477] Fix | Delete
}
[4478] Fix | Delete
else {
[4479] Fix | Delete
return array(
[4480] Fix | Delete
'error' => __('The Wordfence activation server returned an unexpected response. Please try again.', 'wordfence'),
[4481] Fix | Delete
);
[4482] Fix | Delete
}
[4483] Fix | Delete
}
[4484] Fix | Delete
catch (Exception $e) {
[4485] Fix | Delete
return array(
[4486] Fix | Delete
'error' => __('We received an error while trying to activate the license with the Wordfence servers: ', 'wordfence') . wp_kses($e->getMessage(), array())
[4487] Fix | Delete
);
[4488] Fix | Delete
}
[4489] Fix | Delete
}
[4490] Fix | Delete
else {
[4491] Fix | Delete
if ($statusChange === true) {
[4492] Fix | Delete
self::licenseStatusChanged();
[4493] Fix | Delete
}
[4494] Fix | Delete
return array(
[4495] Fix | Delete
'success' => 1,
[4496] Fix | Delete
'isPaid' => wfConfig::get('isPaid') ? 1 : 0,
[4497] Fix | Delete
'type' => wfLicense::current()->getType()
[4498] Fix | Delete
);
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function