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
switch ($scanFailed) {
[5000] Fix | Delete
case wfIssues::SCAN_FAILED_TIMEOUT:
[5001] Fix | Delete
$scanFailedSeconds = time() - wfIssues::lastScanStatusUpdate();
[5002] Fix | Delete
$scanFailedTiming = wfUtils::makeTimeAgo($scanFailedSeconds);
[5003] Fix | Delete
[5004] Fix | Delete
if ($scanFailedSeconds > $timeLimit) {
[5005] Fix | Delete
$scanFailedTiming = sprintf(/* translators: Time until. */ __('more than %s', 'wordfence'), wfUtils::makeTimeAgo($timeLimit));
[5006] Fix | Delete
}
[5007] Fix | Delete
[5008] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5009] Fix | Delete
'messageHTML' => sprintf(/* translators: Localized date. */ __('The current scan looks like it has failed. Its last status update was <span id="wf-scan-failed-time-ago">%s</span> ago. You may continue to wait in case it resumes or stop and restart the scan. Some sites may need adjustments to run scans reliably.', 'wordfence'), $scanFailedTiming) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_FAILS) . '" target="_blank" rel="noopener noreferrer">' . __('Click here for steps you can try.', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5010] Fix | Delete
'buttonTitle' => __('Cancel Scan', 'wordfence'),
[5011] Fix | Delete
))->render();
[5012] Fix | Delete
[5013] Fix | Delete
break;
[5014] Fix | Delete
case wfIssues::SCAN_FAILED_FORK_FAILED:
[5015] Fix | Delete
case wfIssues::SCAN_FAILED_GENERAL:
[5016] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5017] Fix | Delete
'messageHTML' => __('The previous scan has failed. Some sites may need adjustments to run scans reliably.', 'wordfence') . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_FAILS) . '" target="_blank" rel="noopener noreferrer">' . __('Click here for steps you can try.', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5018] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5019] Fix | Delete
))->render();
[5020] Fix | Delete
break;
[5021] Fix | Delete
case wfIssues::SCAN_FAILED_DURATION_REACHED:
[5022] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5023] Fix | Delete
'messageHTML' => sprintf(/* translators: Time limit (number). */ __('The previous scan has terminated because the time limit of %s was reached. This limit can be customized on the options page.', 'wordfence'), wfUtils::makeDuration($timeLimit)) . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_OPTION_OVERALL_TIME_LIMIT) . '" target="_blank" rel="noopener noreferrer" class="wf-inline-help"><i class="wf-fa wf-fa-question-circle-o" aria-hidden="true"></i><span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5024] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5025] Fix | Delete
))->render();
[5026] Fix | Delete
break;
[5027] Fix | Delete
case wfIssues::SCAN_FAILED_VERSION_CHANGE:
[5028] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5029] Fix | Delete
'messageHTML' => esc_html__('The previous scan has terminated because we detected an update occurring during the scan.', 'wordfence'),
[5030] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5031] Fix | Delete
))->render();
[5032] Fix | Delete
break;
[5033] Fix | Delete
case wfIssues::SCAN_FAILED_START_TIMEOUT:
[5034] Fix | Delete
case wfIssues::SCAN_FAILED_CALLBACK_TEST_FAILED:
[5035] Fix | Delete
$resumeAttempts = wfScanMonitor::getConfiguredResumeAttempts();
[5036] Fix | Delete
if ($resumeAttempts > 0) {
[5037] Fix | Delete
if ($resumeAttempts === 1)
[5038] Fix | Delete
$resumeMessage = __('Wordfence will make one attempt to resume each failed scan stage. This scan may recover if this attempt is successful.', 'wordfence');
[5039] Fix | Delete
else
[5040] Fix | Delete
$resumeMessage = sprintf(__('Wordfence will make up to %d attempts to resume each failed scan stage. This scan may recover if one of these attempts is successful.', 'wordfence'), $resumeAttempts);
[5041] Fix | Delete
$resumeMessage = " {$resumeMessage} ";
[5042] Fix | Delete
}
[5043] Fix | Delete
else {
[5044] Fix | Delete
$resumeMessage = '';
[5045] Fix | Delete
}
[5046] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5047] Fix | Delete
'messageTitle' => __('Scan Stage Failed', 'wordfence'),
[5048] Fix | Delete
'messageHTML' => __('A scan stage has failed to start. This is often because the site either cannot make outbound requests or is blocked from connecting to itself.', 'wordfence') . $resumeMessage . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_FAILED_START) . '" target="_blank" rel="noopener noreferrer">' . __('Click here for steps you can try.', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5049] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5050] Fix | Delete
))->render();
[5051] Fix | Delete
break;
[5052] Fix | Delete
case wfIssues::SCAN_FAILED_API_SSL_UNAVAILABLE:
[5053] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5054] Fix | Delete
'messageHTML' => esc_html__('Scans are not functional because SSL is unavailable.', 'wordfence'),
[5055] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5056] Fix | Delete
))->render();
[5057] Fix | Delete
break;
[5058] Fix | Delete
case wfIssues::SCAN_FAILED_API_CALL_FAILED:
[5059] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5060] Fix | Delete
'messageHTML' => __('The scan has failed because we were unable to contact the Wordfence servers. Some sites may need adjustments to run scans reliably.', 'wordfence') . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_FAILS) . '" target="_blank" rel="noopener noreferrer">' . __('Click here for steps you can try.', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5061] Fix | Delete
'rawErrorHTML' => esc_html(wfConfig::get('lastScanCompleted', '')),
[5062] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5063] Fix | Delete
))->render();
[5064] Fix | Delete
break;
[5065] Fix | Delete
case wfIssues::SCAN_FAILED_API_INVALID_RESPONSE:
[5066] Fix | Delete
case wfIssues::SCAN_FAILED_API_ERROR_RESPONSE:
[5067] Fix | Delete
$scanFailedHTML = wfView::create('scanner/scan-failed', array(
[5068] Fix | Delete
'messageHTML' => __('The scan has failed because we received an unexpected response from the Wordfence servers. This may be a temporary error, though some sites may need adjustments to run scans reliably.', 'wordfence') . ' <a href="' . wfSupportController::esc_supportURL(wfSupportController::ITEM_SCAN_FAILS) . '" target="_blank" rel="noopener noreferrer">' . __('Click here for steps you can try.', 'wordfence') . '<span class="screen-reader-text"> (' . esc_html__('opens in new tab', 'wordfence') . ')</span></a>',
[5069] Fix | Delete
'rawErrorHTML' => esc_html(wfConfig::get('lastScanCompleted'), ''),
[5070] Fix | Delete
'buttonTitle' => __('Close', 'wordfence'),
[5071] Fix | Delete
))->render();
[5072] Fix | Delete
break;
[5073] Fix | Delete
}
[5074] Fix | Delete
[5075] Fix | Delete
wfUtils::doNotCache();
[5076] Fix | Delete
return array(
[5077] Fix | Delete
'ok' => 1,
[5078] Fix | Delete
'lastMessage' => $lastMessage,
[5079] Fix | Delete
'items' => self::getLog()->getStatusEvents($_POST['lastctime']),
[5080] Fix | Delete
'currentScanID' => wfScanner::shared()->lastScanTime(),
[5081] Fix | Delete
'signatureUpdateTime' => wfConfig::get('signatureUpdateTime'),
[5082] Fix | Delete
'scanFailedHTML' => $scanFailedHTML,
[5083] Fix | Delete
'scanStalled' => ($scanFailed == wfIssues::SCAN_FAILED_TIMEOUT || $scanFailed == wfIssues::SCAN_FAILED_START_TIMEOUT ? 1 : 0),
[5084] Fix | Delete
'scanRunning' => wfScanner::shared()->isRunning() ? 1 : 0,
[5085] Fix | Delete
'scanStages' => $stages,
[5086] Fix | Delete
'scanStats' => $stats,
[5087] Fix | Delete
'issues' => $issues,
[5088] Fix | Delete
'issueCounts' => $issueCounts,
[5089] Fix | Delete
'issueUpdateTimestamp'=> $lastIssueUpdateTimestamp,
[5090] Fix | Delete
);
[5091] Fix | Delete
}
[5092] Fix | Delete
public static function ajax_updateAlertEmail_callback(){
[5093] Fix | Delete
$email = trim($_POST['email']);
[5094] Fix | Delete
if(! preg_match('/[^\@]+\@[^\.]+\.[^\.]+/', $email) || in_array(hash('sha256', $email), wfConfig::alertEmailBlacklist())){
[5095] Fix | Delete
return array( 'err' => __("Invalid email address given.", 'wordfence'));
[5096] Fix | Delete
}
[5097] Fix | Delete
wfConfig::set('alertEmails', $email);
[5098] Fix | Delete
return array('ok' => 1, 'email' => $email);
[5099] Fix | Delete
}
[5100] Fix | Delete
private static function resolveLocalFile($issue) {
[5101] Fix | Delete
$data = $issue['data'];
[5102] Fix | Delete
if (array_key_exists('realFile', $data)) {
[5103] Fix | Delete
return $data['realFile'];
[5104] Fix | Delete
}
[5105] Fix | Delete
else {
[5106] Fix | Delete
$file = $issue['data']['file'];
[5107] Fix | Delete
$localFile = ABSPATH . '/' . $file;
[5108] Fix | Delete
$localFile = realpath($localFile);
[5109] Fix | Delete
if (strpos($localFile, ABSPATH) !== 0) {
[5110] Fix | Delete
return null;
[5111] Fix | Delete
}
[5112] Fix | Delete
return $localFile;
[5113] Fix | Delete
}
[5114] Fix | Delete
}
[5115] Fix | Delete
public static function ajax_bulkOperation_callback() {
[5116] Fix | Delete
$op = sanitize_text_field($_POST['op']);
[5117] Fix | Delete
if ($op == 'del' || $op == 'repair') {
[5118] Fix | Delete
$idsRemoved = array();
[5119] Fix | Delete
$filesWorkedOn = 0;
[5120] Fix | Delete
$errors = array();
[5121] Fix | Delete
$wfIssues = new wfIssues();
[5122] Fix | Delete
$issueCount = $wfIssues->getIssueCount();
[5123] Fix | Delete
for ($offset = floor($issueCount / 100) * 100; $offset >= 0; $offset -= 100) {
[5124] Fix | Delete
$issues = $wfIssues->getIssues($offset, 100, 0, 0);
[5125] Fix | Delete
foreach ($issues['new'] as $i) {
[5126] Fix | Delete
if ($op == 'del' && @$i['data']['canDelete']) {
[5127] Fix | Delete
$file = $i['data']['file'];
[5128] Fix | Delete
$localFile = self::resolveLocalFile($i);
[5129] Fix | Delete
if ($localFile === null)
[5130] Fix | Delete
continue;
[5131] Fix | Delete
if ($localFile === ABSPATH . 'wp-config.php') {
[5132] Fix | Delete
$errors[] = esc_html__('Deleting an infected wp-config.php file must be done outside of Wordfence. The wp-config.php file contains your database credentials, which you will need to restore normal site operations. Your site will NOT function once the wp-config.php file has been deleted.', 'wordfence');
[5133] Fix | Delete
}
[5134] Fix | Delete
else if (@unlink($localFile)) {
[5135] Fix | Delete
$wfIssues->updateIssue($i['id'], 'delete');
[5136] Fix | Delete
$idsRemoved[] = $i['id'];
[5137] Fix | Delete
$filesWorkedOn++;
[5138] Fix | Delete
}
[5139] Fix | Delete
else {
[5140] Fix | Delete
$err = error_get_last();
[5141] Fix | Delete
$errors[] = esc_html(sprintf(/* translators: 1. File path. 2. Error message. */ __('Could not delete file %1$s. Error was: %2$s', 'wordfence'), wp_kses($file, array()), wp_kses(str_replace(ABSPATH, '{WordPress Root}/', $err['message']), array())));
[5142] Fix | Delete
}
[5143] Fix | Delete
}
[5144] Fix | Delete
else if ($op == 'repair' && @$i['data']['canFix']) {
[5145] Fix | Delete
$file = $i['data']['file'];
[5146] Fix | Delete
$localFile = self::resolveLocalFile($i);
[5147] Fix | Delete
if ($localFile === null)
[5148] Fix | Delete
continue;
[5149] Fix | Delete
$result = array();
[5150] Fix | Delete
if (isset($i['data']) && is_array($i['data']) && isset($i['data']['file']) && isset($i['data']['cType']) && ( //Basics
[5151] Fix | Delete
$i['data']['cType'] == 'core' || //Core file
[5152] Fix | Delete
($i['data']['cType'] == 'plugin' || $i['data']['cType'] == 'theme') && isset($i['data']['cName']) && isset($i['data']['cVersion']) //Plugin or Theme file
[5153] Fix | Delete
)) {
[5154] Fix | Delete
$result = self::getWPFileContent($i['data']['file'], $i['data']['cType'], isset($i['data']['cName']) ? $i['data']['cName'] : null, isset($i['data']['cVersion']) ? $i['data']['cVersion'] : null);
[5155] Fix | Delete
}
[5156] Fix | Delete
[5157] Fix | Delete
if (is_array($result) && isset($result['errorMsg'])) {
[5158] Fix | Delete
$errors[] = esc_html($result['errorMsg']);
[5159] Fix | Delete
continue;
[5160] Fix | Delete
}
[5161] Fix | Delete
else if (!is_array($result) || !isset($result['fileContent'])) {
[5162] Fix | Delete
$errors[] = esc_html(sprintf(/* translators: File path. */ __('We could not retrieve the original file of %s to do a repair.', 'wordfence'), wp_kses($file, array())));
[5163] Fix | Delete
continue;
[5164] Fix | Delete
}
[5165] Fix | Delete
[5166] Fix | Delete
if (preg_match('/\.\./', $file)) {
[5167] Fix | Delete
$errors[] = sprintf(/* translators: File path. */ __('An invalid file %s was specified for repair.', 'wordfence'), wp_kses($file, array()));
[5168] Fix | Delete
continue;
[5169] Fix | Delete
}
[5170] Fix | Delete
[5171] Fix | Delete
$fh = fopen($localFile, 'w');
[5172] Fix | Delete
if (!$fh) {
[5173] Fix | Delete
$err = error_get_last();
[5174] Fix | Delete
if (preg_match('/Permission denied/i', $err['message'])) {
[5175] Fix | Delete
$errMsg = esc_html(sprintf(/* translators: File path. */ __('You don\'t have permission to repair %s. You need to either fix the file manually using FTP or change the file permissions and ownership so that your web server has write access to repair the file.', 'wordfence'), wp_kses($file, array())));
[5176] Fix | Delete
}
[5177] Fix | Delete
else {
[5178] Fix | Delete
$errMsg = esc_html(sprintf(/* translators: 1. File path. 2. Error message. */ __('We could not write to %1$s. The error was: %2$s', 'wordfence'), wp_kses($file, array()), $err['message']));
[5179] Fix | Delete
}
[5180] Fix | Delete
$errors[] = $errMsg;
[5181] Fix | Delete
continue;
[5182] Fix | Delete
}
[5183] Fix | Delete
[5184] Fix | Delete
flock($fh, LOCK_EX);
[5185] Fix | Delete
$bytes = fwrite($fh, $result['fileContent']);
[5186] Fix | Delete
flock($fh, LOCK_UN);
[5187] Fix | Delete
fclose($fh);
[5188] Fix | Delete
if ($bytes < 1) {
[5189] Fix | Delete
$errors[] = esc_html(sprintf(/* translators: 1. File path. 2. Number of bytes. */ __('We could not write to %1$s. (%2$d bytes written) You may not have permission to modify files on your WordPress server.', 'wordfence'), wp_kses($file, array()), $bytes));
[5190] Fix | Delete
continue;
[5191] Fix | Delete
}
[5192] Fix | Delete
[5193] Fix | Delete
$filesWorkedOn++;
[5194] Fix | Delete
$wfIssues->updateIssue($i['id'], 'delete');
[5195] Fix | Delete
$idsRemoved[] = $i['id'];
[5196] Fix | Delete
}
[5197] Fix | Delete
}
[5198] Fix | Delete
}
[5199] Fix | Delete
[5200] Fix | Delete
if ($filesWorkedOn > 0 && count($errors) > 0) {
[5201] Fix | Delete
$headMsg = esc_html($op == 'del' ? __('Deleted some files with errors', 'wordfence') : __('Repaired some files with errors', 'wordfence'));
[5202] Fix | Delete
$bodyMsg = sprintf(esc_html($op == 'del' ?
[5203] Fix | Delete
/* translators: 1. Number of files. 2. Error message. */
[5204] Fix | Delete
__('Deleted %1$d files but we encountered the following errors with other files: %2$s', 'wordfence') :
[5205] Fix | Delete
/* translators: 1. Number of files. 2. Error message. */
[5206] Fix | Delete
__('Repaired %1$d files but we encountered the following errors with other files: %2$s', 'wordfence')),
[5207] Fix | Delete
$filesWorkedOn, implode('<br>', $errors));
[5208] Fix | Delete
}
[5209] Fix | Delete
else if ($filesWorkedOn > 0) {
[5210] Fix | Delete
$headMsg = sprintf(esc_html($op == 'del' ? /* translators: Number of files. */ __('Deleted %d files successfully', 'wordfence') : /* translators: Number of files. */ __('Repaired %d files successfully', 'wordfence')), $filesWorkedOn);
[5211] Fix | Delete
$bodyMsg = sprintf(esc_html($op == 'del' ? /* translators: Number of files. */ __('Deleted %d files successfully. No errors were encountered.', 'wordfence') : /* translators: Number of files. */ __('Repaired %d files successfully. No errors were encountered.', 'wordfence')), $filesWorkedOn);
[5212] Fix | Delete
}
[5213] Fix | Delete
else if (count($errors) > 0) {
[5214] Fix | Delete
$headMsg = esc_html($op == 'del' ? __('Could not delete files', 'wordfence') : __('Could not repair files', 'wordfence'));
[5215] Fix | Delete
$bodyMsg = sprintf(esc_html($op == 'del' ?
[5216] Fix | Delete
/* translators: Error message. */
[5217] Fix | Delete
__('We could not delete any of the files you selected. We encountered the following errors: %s', 'wordfence') :
[5218] Fix | Delete
/* translators: Error message. */
[5219] Fix | Delete
__('We could not repair any of the files you selected. We encountered the following errors: %s', 'wordfence')), implode('<br>', $errors));
[5220] Fix | Delete
}
[5221] Fix | Delete
else {
[5222] Fix | Delete
$headMsg = esc_html__('Nothing done', 'wordfence');
[5223] Fix | Delete
$bodyMsg = esc_html($op == 'del' ? __('We didn\'t delete anything and no errors were found.', 'wordfence') : __('We didn\'t repair anything and no errors were found.', 'wordfence'));
[5224] Fix | Delete
}
[5225] Fix | Delete
[5226] Fix | Delete
wfScanEngine::refreshScanNotification($wfIssues);
[5227] Fix | Delete
$counts = $wfIssues->getIssueCounts();
[5228] Fix | Delete
return array('ok' => 1, 'bulkHeading' => $headMsg, 'bulkBody' => $bodyMsg, 'idsRemoved' => $idsRemoved, 'issueCounts' => $counts);
[5229] Fix | Delete
}
[5230] Fix | Delete
else {
[5231] Fix | Delete
return array('errorMsg' => esc_html__('Invalid bulk operation selected', 'wordfence'));
[5232] Fix | Delete
}
[5233] Fix | Delete
}
[5234] Fix | Delete
public static function ajax_deleteFile_callback($issueID = null){
[5235] Fix | Delete
if ($issueID === null) {
[5236] Fix | Delete
$issueID = intval($_POST['issueID']);
[5237] Fix | Delete
}
[5238] Fix | Delete
$wfIssues = new wfIssues();
[5239] Fix | Delete
$issue = $wfIssues->getIssueByID($issueID);
[5240] Fix | Delete
if(! $issue){
[5241] Fix | Delete
return array('errorMsg' => __('Could not delete file because we could not find that issue.', 'wordfence'));
[5242] Fix | Delete
}
[5243] Fix | Delete
if(! $issue['data']['file']){
[5244] Fix | Delete
return array('errorMsg' => __('Could not delete file because that issue does not appear to be a file related issue.', 'wordfence'));
[5245] Fix | Delete
}
[5246] Fix | Delete
$file = $issue['data']['file'];
[5247] Fix | Delete
$localFile = self::resolveLocalFile($issue);
[5248] Fix | Delete
if($localFile === null){
[5249] Fix | Delete
return array('errorMsg' => __('An invalid file was requested for deletion.', 'wordfence'));
[5250] Fix | Delete
}
[5251] Fix | Delete
if ($file === 'wp-config.php') {
[5252] Fix | Delete
return array(
[5253] Fix | Delete
'errorMsg' => __('Deleting an infected wp-config.php file must be done outside of Wordfence. The wp-config.php file contains your database credentials, which you will need to restore normal site operations. Your site will NOT function once the wp-config.php file has been deleted.', 'wordfence')
[5254] Fix | Delete
);
[5255] Fix | Delete
}
[5256] Fix | Delete
[5257] Fix | Delete
/** @var WP_Filesystem_Base $wp_filesystem */
[5258] Fix | Delete
global $wp_filesystem;
[5259] Fix | Delete
[5260] Fix | Delete
$adminURL = network_admin_url('admin.php?' . http_build_query(array(
[5261] Fix | Delete
'page' => 'WordfenceScan',
[5262] Fix | Delete
'subpage' => 'scan_credentials',
[5263] Fix | Delete
'action' => 'deleteFile',
[5264] Fix | Delete
'issueID' => $issueID,
[5265] Fix | Delete
'nonce' => wp_create_nonce('wp-ajax'),
[5266] Fix | Delete
)));
[5267] Fix | Delete
[5268] Fix | Delete
if (!self::requestFilesystemCredentials($adminURL, null, true, false)) {
[5269] Fix | Delete
return array(
[5270] Fix | Delete
'ok' => 1,
[5271] Fix | Delete
'needsCredentials' => 1,
[5272] Fix | Delete
'redirect' => $adminURL,
[5273] Fix | Delete
);
[5274] Fix | Delete
}
[5275] Fix | Delete
[5276] Fix | Delete
if ($wp_filesystem->delete($localFile)) {
[5277] Fix | Delete
$wfIssues->updateIssue($issueID, 'delete');
[5278] Fix | Delete
$counts = $wfIssues->getIssueCounts();
[5279] Fix | Delete
wfScanEngine::refreshScanNotification($wfIssues);
[5280] Fix | Delete
return array(
[5281] Fix | Delete
'ok' => 1,
[5282] Fix | Delete
'localFile' => $localFile,
[5283] Fix | Delete
'file' => $file,
[5284] Fix | Delete
'issueCounts' => $counts,
[5285] Fix | Delete
);
[5286] Fix | Delete
}
[5287] Fix | Delete
[5288] Fix | Delete
$err = error_get_last();
[5289] Fix | Delete
return array(
[5290] Fix | Delete
'errorMsg' => sprintf(
[5291] Fix | Delete
/* translators: 1. File path. 2. Error message. */
[5292] Fix | Delete
__('Could not delete file %1$s. The error was: %2$s', 'wordfence'),
[5293] Fix | Delete
wp_kses($file, array()),
[5294] Fix | Delete
wp_kses(str_replace(ABSPATH, '{WordPress Root}/', $err['message']), array())
[5295] Fix | Delete
)
[5296] Fix | Delete
);
[5297] Fix | Delete
}
[5298] Fix | Delete
public static function ajax_deleteDatabaseOption_callback(){
[5299] Fix | Delete
/** @var wpdb $wpdb */
[5300] Fix | Delete
global $wpdb;
[5301] Fix | Delete
$issueID = intval($_POST['issueID']);
[5302] Fix | Delete
$wfIssues = new wfIssues();
[5303] Fix | Delete
$issue = $wfIssues->getIssueByID($issueID);
[5304] Fix | Delete
if (!$issue) {
[5305] Fix | Delete
return array('errorMsg' => __("Could not remove the option because we could not find that issue.", 'wordfence'));
[5306] Fix | Delete
}
[5307] Fix | Delete
if (empty($issue['data']['option_name'])) {
[5308] Fix | Delete
return array('errorMsg' => __("Could not remove the option because that issue does not appear to be a database related issue.", 'wordfence'));
[5309] Fix | Delete
}
[5310] Fix | Delete
$table_options = wfDB::blogTable('options', $issue['data']['site_id']);
[5311] Fix | Delete
if ($wpdb->query($wpdb->prepare("DELETE FROM {$table_options} WHERE option_name = %s", $issue['data']['option_name']))) {
[5312] Fix | Delete
$wfIssues->updateIssue($issueID, 'delete');
[5313] Fix | Delete
wfScanEngine::refreshScanNotification($wfIssues);
[5314] Fix | Delete
return array(
[5315] Fix | Delete
'ok' => 1,
[5316] Fix | Delete
'option_name' => $issue['data']['option_name'],
[5317] Fix | Delete
);
[5318] Fix | Delete
} else {
[5319] Fix | Delete
return array('errorMsg' => sprintf(
[5320] Fix | Delete
/* translators: 1. WordPress option. 2. Error message. */
[5321] Fix | Delete
__('Could not remove the option %1$s. The error was: %2$s', 'wordfence'),
[5322] Fix | Delete
esc_html($issue['data']['option_name']),
[5323] Fix | Delete
esc_html($wpdb->last_error)
[5324] Fix | Delete
));
[5325] Fix | Delete
}
[5326] Fix | Delete
}
[5327] Fix | Delete
public static function ajax_fixFPD_callback(){
[5328] Fix | Delete
$issues = new wfIssues();
[5329] Fix | Delete
$issue = $issues->getIssueByID($_POST['issueID']);
[5330] Fix | Delete
if (!$issue) {
[5331] Fix | Delete
return array('cerrorMsg' => __("We could not find that issue in our database.", 'wordfence'));
[5332] Fix | Delete
}
[5333] Fix | Delete
[5334] Fix | Delete
$htaccess = ABSPATH . '/.htaccess';
[5335] Fix | Delete
$change = "<IfModule mod_php5.c>\n\tphp_value display_errors 0\n</IfModule>\n<IfModule mod_php7.c>\n\tphp_value display_errors 0\n</IfModule>\n<IfModule mod_php.c>\n\tphp_value display_errors 0\n</IfModule>";
[5336] Fix | Delete
$content = "";
[5337] Fix | Delete
if (file_exists($htaccess)) {
[5338] Fix | Delete
$content = file_get_contents($htaccess);
[5339] Fix | Delete
}
[5340] Fix | Delete
[5341] Fix | Delete
if (@file_put_contents($htaccess, trim($content . "\n" . $change), LOCK_EX) === false) {
[5342] Fix | Delete
return array('cerrorMsg' => __("You don't have permission to repair .htaccess. You need to either fix the file manually using FTP or change the file permissions and ownership so that your web server has write access to repair the file.", 'wordfence'));
[5343] Fix | Delete
}
[5344] Fix | Delete
if (wfScanEngine::testForFullPathDisclosure()) {
[5345] Fix | Delete
// Didn't fix it, so revert the changes and return an error
[5346] Fix | Delete
file_put_contents($htaccess, $content, LOCK_EX);
[5347] Fix | Delete
return array(
[5348] Fix | Delete
'cerrorMsg' => __("Modifying the .htaccess file did not resolve the issue, so the original .htaccess file was restored. You can fix this manually by setting <code>display_errors</code> to <code>Off</code> in your php.ini if your site is on a VPS or dedicated server that you control.", 'wordfence'),
[5349] Fix | Delete
);
[5350] Fix | Delete
}
[5351] Fix | Delete
$issues->updateIssue($_POST['issueID'], 'delete');
[5352] Fix | Delete
wfScanEngine::refreshScanNotification($issues);
[5353] Fix | Delete
return array('ok' => 1);
[5354] Fix | Delete
}
[5355] Fix | Delete
public static function ajax_restoreFile_callback($issueID = null){
[5356] Fix | Delete
if ($issueID === null) {
[5357] Fix | Delete
$issueID = intval($_POST['issueID']);
[5358] Fix | Delete
}
[5359] Fix | Delete
$wfIssues = new wfIssues();
[5360] Fix | Delete
$issue = $wfIssues->getIssueByID($issueID);
[5361] Fix | Delete
if(! $issue){
[5362] Fix | Delete
return array('cerrorMsg' => __("We could not find that issue in our database.", 'wordfence'));
[5363] Fix | Delete
}
[5364] Fix | Delete
[5365] Fix | Delete
/** @var WP_Filesystem_Base $wp_filesystem */
[5366] Fix | Delete
global $wp_filesystem;
[5367] Fix | Delete
[5368] Fix | Delete
$adminURL = network_admin_url('admin.php?' . http_build_query(array(
[5369] Fix | Delete
'page' => 'WordfenceScan',
[5370] Fix | Delete
'subpage' => 'scan_credentials',
[5371] Fix | Delete
'action' => 'restoreFile',
[5372] Fix | Delete
'issueID' => $issueID,
[5373] Fix | Delete
'nonce' => wp_create_nonce('wp-ajax'),
[5374] Fix | Delete
)));
[5375] Fix | Delete
[5376] Fix | Delete
if (!self::requestFilesystemCredentials($adminURL, null, true, false)) {
[5377] Fix | Delete
return array(
[5378] Fix | Delete
'ok' => 1,
[5379] Fix | Delete
'needsCredentials' => true,
[5380] Fix | Delete
'redirect' => $adminURL,
[5381] Fix | Delete
);
[5382] Fix | Delete
}
[5383] Fix | Delete
[5384] Fix | Delete
$dat = $issue['data'];
[5385] Fix | Delete
$result = self::getWPFileContent($dat['file'], $dat['cType'], (isset($dat['cName']) ? $dat['cName'] : ''), (isset($dat['cVersion']) ? $dat['cVersion'] : ''));
[5386] Fix | Delete
$file = $dat['file'];
[5387] Fix | Delete
if(isset($result['errorMsg']) && $result['errorMsg']){
[5388] Fix | Delete
return $result;
[5389] Fix | Delete
} else if(! $result['fileContent']){
[5390] Fix | Delete
return array('errorMsg' => __("We could not get the original file to do a repair.", 'wordfence'));
[5391] Fix | Delete
}
[5392] Fix | Delete
[5393] Fix | Delete
if(preg_match('/\.\./', $file)){
[5394] Fix | Delete
return array('errorMsg' => __("An invalid file was specified for repair.", 'wordfence'));
[5395] Fix | Delete
}
[5396] Fix | Delete
if (array_key_exists('realFile', $dat)) {
[5397] Fix | Delete
$localFile = $dat['realFile'];
[5398] Fix | Delete
}
[5399] Fix | Delete
else {
[5400] Fix | Delete
$localFile = rtrim(ABSPATH, '/') . '/' . preg_replace('/^[\.\/]+/', '', $file);
[5401] Fix | Delete
}
[5402] Fix | Delete
if ($wp_filesystem->put_contents($localFile, $result['fileContent'])) {
[5403] Fix | Delete
$wfIssues->updateIssue($issueID, 'delete');
[5404] Fix | Delete
$counts = $wfIssues->getIssueCounts();
[5405] Fix | Delete
wfScanEngine::refreshScanNotification($wfIssues);
[5406] Fix | Delete
return array(
[5407] Fix | Delete
'ok' => 1,
[5408] Fix | Delete
'localFile' => $localFile,
[5409] Fix | Delete
'file' => $file,
[5410] Fix | Delete
'issueCounts' => $counts,
[5411] Fix | Delete
);
[5412] Fix | Delete
}
[5413] Fix | Delete
return array(
[5414] Fix | Delete
'errorMsg' => __("We could not write to that file. You may not have permission to modify files on your WordPress server.", 'wordfence'),
[5415] Fix | Delete
);
[5416] Fix | Delete
}
[5417] Fix | Delete
public static function ajax_scan_callback(){
[5418] Fix | Delete
self::status(4, 'info', __("Ajax request received to start scan.", 'wordfence'));
[5419] Fix | Delete
$err = wfScanEngine::startScan();
[5420] Fix | Delete
if ($err) {
[5421] Fix | Delete
return array('errorMsg' => wp_kses($err, array()));
[5422] Fix | Delete
}
[5423] Fix | Delete
else {
[5424] Fix | Delete
$issueCounts = array_merge(array('new' => 0, 'ignoreP' => 0, 'ignoreC' => 0), wfIssues::shared()->getIssueCounts());
[5425] Fix | Delete
return array("ok" => 1, 'issueCounts' => $issueCounts);
[5426] Fix | Delete
}
[5427] Fix | Delete
}
[5428] Fix | Delete
public static function ajax_exportSettings_callback() {
[5429] Fix | Delete
$result = wfImportExportController::shared()->export();
[5430] Fix | Delete
return $result;
[5431] Fix | Delete
}
[5432] Fix | Delete
public static function ajax_importSettings_callback(){
[5433] Fix | Delete
$token = $_POST['token'];
[5434] Fix | Delete
return self::importSettings($token);
[5435] Fix | Delete
}
[5436] Fix | Delete
public static function importSettings($token) { //Documented call for external interfacing.
[5437] Fix | Delete
return wfImportExportController::shared()->import($token);
[5438] Fix | Delete
}
[5439] Fix | Delete
public static function ajax_dismissNotification_callback() {
[5440] Fix | Delete
$id = $_POST['id'];
[5441] Fix | Delete
$n = wfNotification::getNotificationForID($id);
[5442] Fix | Delete
if ($n !== null) {
[5443] Fix | Delete
$n->markAsRead();
[5444] Fix | Delete
}
[5445] Fix | Delete
return array(
[5446] Fix | Delete
'ok' => 1,
[5447] Fix | Delete
);
[5448] Fix | Delete
}
[5449] Fix | Delete
public static function ajax_utilityScanForBlacklisted_callback() {
[5450] Fix | Delete
if (wfScanner::shared()->isRunning()) {
[5451] Fix | Delete
return array('wait' => 2); //Can't run while a scan is running since the URL hoover is currently implemented like a singleton
[5452] Fix | Delete
}
[5453] Fix | Delete
[5454] Fix | Delete
$pageURL = stripslashes($_POST['url']);
[5455] Fix | Delete
$source = stripslashes($_POST['source']);
[5456] Fix | Delete
$apiKey = wfConfig::get('apiKey');
[5457] Fix | Delete
$wp_version = wfUtils::getWPVersion();
[5458] Fix | Delete
$h = new wordfenceURLHoover($apiKey, $wp_version);
[5459] Fix | Delete
$h->hoover(1, $source);
[5460] Fix | Delete
$hooverResults = $h->getBaddies();
[5461] Fix | Delete
if ($h->errorMsg) {
[5462] Fix | Delete
$h->cleanup();
[5463] Fix | Delete
return array('wait' => 3, 'errorMsg' => $h->errorMsg); //Unable to contact noc1 to verify
[5464] Fix | Delete
}
[5465] Fix | Delete
$h->cleanup();
[5466] Fix | Delete
if (sizeof($hooverResults) > 0 && isset($hooverResults[1])) {
[5467] Fix | Delete
$hresults = $hooverResults[1];
[5468] Fix | Delete
$count = count($hresults);
[5469] Fix | Delete
if ($count > 0) {
[5470] Fix | Delete
new wfNotification(
[5471] Fix | Delete
null,
[5472] Fix | Delete
wfNotification::PRIORITY_HIGH_WARNING,
[5473] Fix | Delete
sprintf(/* translators: Number of URLs. */ _n("Page contains %d malware URL: ", "Page contains %d malware URLs: ", $count, 'wordfence') . esc_html($pageURL)),
[5474] Fix | Delete
'wfplugin_malwareurl_' . md5($pageURL),
[5475] Fix | Delete
null,
[5476] Fix | Delete
array(array('link' => wfUtils::wpAdminURL('admin.php?page=WordfenceScan'), 'label' => __('Run a Scan', 'wordfence'))));
[5477] Fix | Delete
return array('bad' => $count);
[5478] Fix | Delete
}
[5479] Fix | Delete
}
[5480] Fix | Delete
return array('ok' => 1);
[5481] Fix | Delete
}
[5482] Fix | Delete
public static function ajax_dashboardShowMore_callback() {
[5483] Fix | Delete
$grouping = $_POST['grouping'];
[5484] Fix | Delete
$period = $_POST['period'];
[5485] Fix | Delete
[5486] Fix | Delete
$dashboard = new wfDashboard();
[5487] Fix | Delete
if ($grouping == 'ips') {
[5488] Fix | Delete
$data = null;
[5489] Fix | Delete
if ($period == '24h') { $data = $dashboard->ips24h; }
[5490] Fix | Delete
else if ($period == '7d') { $data = $dashboard->ips7d; }
[5491] Fix | Delete
else if ($period == '30d') { $data = $dashboard->ips30d; }
[5492] Fix | Delete
[5493] Fix | Delete
if ($data !== null) {
[5494] Fix | Delete
foreach ($data as &$d) {
[5495] Fix | Delete
$d['IP'] = esc_html(wfUtils::inet_ntop($d['IP']));
[5496] Fix | Delete
$d['blockCount'] = esc_html(number_format_i18n($d['blockCount']));
[5497] Fix | Delete
$d['countryFlag'] = esc_attr('wf-flag-' . strtolower($d['countryCode']));
[5498] Fix | Delete
$d['countryName'] = esc_html($d['countryName']);
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function