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
}
[5500] Fix | Delete
return array('ok' => 1, 'data' => $data);
[5501] Fix | Delete
}
[5502] Fix | Delete
}
[5503] Fix | Delete
else if ($grouping == 'logins') {
[5504] Fix | Delete
$data = null;
[5505] Fix | Delete
if ($period == 'success') { $data = $dashboard->loginsSuccess; }
[5506] Fix | Delete
else if ($period == 'fail') { $data = $dashboard->loginsFail; }
[5507] Fix | Delete
[5508] Fix | Delete
if ($data !== null) {
[5509] Fix | Delete
$data = array_slice($data, 0, 100);
[5510] Fix | Delete
foreach ($data as &$d) {
[5511] Fix | Delete
$d['ip'] = esc_html($d['ip']);
[5512] Fix | Delete
$d['name'] = esc_html($d['name']);
[5513] Fix | Delete
if (time() - $d['t'] < 86400) {
[5514] Fix | Delete
$d['t'] = esc_html(wfUtils::makeTimeAgo(time() - $d['t']) . ' ago');
[5515] Fix | Delete
}
[5516] Fix | Delete
else {
[5517] Fix | Delete
$d['t'] = esc_html(wfUtils::formatLocalTime(get_option('date_format') . ' ' . get_option('time_format'), (int) $d['t']));
[5518] Fix | Delete
}
[5519] Fix | Delete
}
[5520] Fix | Delete
return array('ok' => 1, 'data' => $data);
[5521] Fix | Delete
}
[5522] Fix | Delete
}
[5523] Fix | Delete
[5524] Fix | Delete
return array('error' => __('Unknown dashboard data set.', 'wordfence'));
[5525] Fix | Delete
}
[5526] Fix | Delete
public static function startScan(){
[5527] Fix | Delete
wfScanEngine::startScan();
[5528] Fix | Delete
}
[5529] Fix | Delete
public static function templateRedir(){
[5530] Fix | Delete
if (!empty($_GET['wordfence_lh'])) {
[5531] Fix | Delete
self::ajax_lh_callback();
[5532] Fix | Delete
exit;
[5533] Fix | Delete
}
[5534] Fix | Delete
if (!empty($_GET['wfcentral_admin_redirect'])) {
[5535] Fix | Delete
wp_safe_redirect(remove_query_arg('wfcentral_admin_redirect', network_admin_url('admin.php?page=Wordfence' . rawurlencode(ucwords(preg_replace('/\W/', '', $_GET['wfcentral_admin_redirect']))) . '&' . $_SERVER['QUERY_STRING'])));
[5536] Fix | Delete
exit;
[5537] Fix | Delete
}
[5538] Fix | Delete
[5539] Fix | Delete
$wfFunc = !empty($_GET['_wfsf']) && is_string($_GET['_wfsf']) ? $_GET['_wfsf'] : '';
[5540] Fix | Delete
[5541] Fix | Delete
//Logging
[5542] Fix | Delete
self::doEarlyAccessLogging();
[5543] Fix | Delete
//End logging
[5544] Fix | Delete
[5545] Fix | Delete
[5546] Fix | Delete
if(! ($wfFunc == 'diff' || $wfFunc == 'view' || $wfFunc == 'viewOption' || $wfFunc == 'sysinfo' || $wfFunc == 'IPTraf' || $wfFunc == 'viewActivityLog' || $wfFunc == 'testmem' || $wfFunc == 'testtime' || $wfFunc == 'download' || $wfFunc == 'blockedIPs' || ($wfFunc == 'debugWAF' && WFWAF_DEBUG))){
[5547] Fix | Delete
return;
[5548] Fix | Delete
}
[5549] Fix | Delete
if(! wfUtils::isAdmin()){
[5550] Fix | Delete
return;
[5551] Fix | Delete
}
[5552] Fix | Delete
[5553] Fix | Delete
$nonce = $_GET['nonce'];
[5554] Fix | Delete
if(! wp_verify_nonce($nonce, 'wp-ajax')){
[5555] Fix | Delete
_e("Bad security token. It may have been more than 12 hours since you reloaded the page you came from. Try reloading the page you came from. If that doesn't work, please sign out and sign-in again.", 'wordfence');
[5556] Fix | Delete
exit(0);
[5557] Fix | Delete
}
[5558] Fix | Delete
if($wfFunc == 'diff'){
[5559] Fix | Delete
self::wfFunc_diff();
[5560] Fix | Delete
} else if($wfFunc == 'view'){
[5561] Fix | Delete
self::wfFunc_view();
[5562] Fix | Delete
} else if($wfFunc == 'viewOption'){
[5563] Fix | Delete
self::wfFunc_viewOption();
[5564] Fix | Delete
} else if($wfFunc == 'sysinfo') {
[5565] Fix | Delete
require(dirname(__FILE__) . '/sysinfo.php' );
[5566] Fix | Delete
} else if($wfFunc == 'IPTraf'){
[5567] Fix | Delete
self::wfFunc_IPTraf();
[5568] Fix | Delete
} else if($wfFunc == 'viewActivityLog'){
[5569] Fix | Delete
self::wfFunc_viewActivityLog();
[5570] Fix | Delete
} else if($wfFunc == 'testmem'){
[5571] Fix | Delete
self::wfFunc_testmem();
[5572] Fix | Delete
} else if($wfFunc == 'testtime'){
[5573] Fix | Delete
self::wfFunc_testtime();
[5574] Fix | Delete
} else if($wfFunc == 'download'){
[5575] Fix | Delete
self::wfFunc_download();
[5576] Fix | Delete
} else if($wfFunc == 'blockedIPs'){
[5577] Fix | Delete
self::wfFunc_blockedIPs();
[5578] Fix | Delete
} else if($wfFunc == 'debugWAF' && WFWAF_DEBUG){
[5579] Fix | Delete
self::wfFunc_debugWAF();
[5580] Fix | Delete
}
[5581] Fix | Delete
exit(0);
[5582] Fix | Delete
}
[5583] Fix | Delete
public static function memtest_error_handler($errno, $errstr, $errfile, $errline){
[5584] Fix | Delete
echo "Error received: $errstr\n";
[5585] Fix | Delete
}
[5586] Fix | Delete
private static function wfFunc_testtime(){
[5587] Fix | Delete
header('Content-Type: text/plain');
[5588] Fix | Delete
@error_reporting(E_ALL);
[5589] Fix | Delete
wfUtils::iniSet('display_errors','On');
[5590] Fix | Delete
set_error_handler('wordfence::memtest_error_handler', E_ALL);
[5591] Fix | Delete
[5592] Fix | Delete
echo "Wordfence process duration benchmarking utility version " . WORDFENCE_VERSION . ".\n";
[5593] Fix | Delete
echo "This utility tests how long your WordPress host allows a process to run.\n\n--Starting test--\n";
[5594] Fix | Delete
echo "Starting timed test. This will take at least three minutes. Seconds elapsed are printed below.\nAn error after this line is not unusual. Read it and the elapsed seconds to determine max process running time on your host.\n";
[5595] Fix | Delete
for($i = 1; $i <= 180; $i++){
[5596] Fix | Delete
echo "\n$i:";
[5597] Fix | Delete
for($j = 0; $j < 1000; $j++){
[5598] Fix | Delete
echo '.';
[5599] Fix | Delete
}
[5600] Fix | Delete
flush();
[5601] Fix | Delete
sleep(1);
[5602] Fix | Delete
}
[5603] Fix | Delete
echo "\n--Test complete.--\n\nCongratulations, your web host allows your PHP processes to run at least 3 minutes.\n";
[5604] Fix | Delete
exit();
[5605] Fix | Delete
}
[5606] Fix | Delete
private static function wfFunc_testmem(){
[5607] Fix | Delete
header('Content-Type: text/plain');
[5608] Fix | Delete
@error_reporting(E_ALL);
[5609] Fix | Delete
wfUtils::iniSet('display_errors','On');
[5610] Fix | Delete
set_error_handler('wordfence::memtest_error_handler', E_ALL);
[5611] Fix | Delete
[5612] Fix | Delete
$maxMemory = ini_get('memory_limit');
[5613] Fix | Delete
$last = strtolower(substr($maxMemory, -1));
[5614] Fix | Delete
$maxMemory = (int) $maxMemory;
[5615] Fix | Delete
[5616] Fix | Delete
$configuredMax = wfConfig::get('maxMem', 0);
[5617] Fix | Delete
if ($configuredMax <= 0) {
[5618] Fix | Delete
if ($last == 'g') { $configuredMax = $maxMemory * 1024; }
[5619] Fix | Delete
else if ($last == 'm') { $configuredMax = $maxMemory; }
[5620] Fix | Delete
else if ($last == 'k') { $configuredMax = $maxMemory / 1024; }
[5621] Fix | Delete
$configuredMax = floor($configuredMax);
[5622] Fix | Delete
}
[5623] Fix | Delete
[5624] Fix | Delete
$stepSize = 5242880; //5 MB
[5625] Fix | Delete
[5626] Fix | Delete
echo "Wordfence Memory benchmarking utility version " . WORDFENCE_VERSION . ".\n";
[5627] Fix | Delete
echo "This utility tests if your WordPress host respects the maximum memory configured\nin their php.ini file, or if they are using other methods to limit your access to memory.\n\n--Starting test--\n";
[5628] Fix | Delete
echo "Current maximum memory configured in php.ini: " . ini_get('memory_limit') . "\n";
[5629] Fix | Delete
echo "Current memory usage: " . sprintf('%.2f', memory_get_usage(true) / (1024 * 1024)) . "M\n";
[5630] Fix | Delete
echo "Attempting to set max memory to {$configuredMax}M.\n";
[5631] Fix | Delete
wfUtils::iniSet('memory_limit', ($configuredMax + 5) . 'M'); //Allow a little extra for testing overhead
[5632] Fix | Delete
echo "Starting memory benchmark. Seeing an error after this line is not unusual. Read the error carefully\nto determine how much memory your host allows. We have requested {$configuredMax} megabytes.\n";
[5633] Fix | Delete
[5634] Fix | Delete
if (memory_get_usage(true) < 1) {
[5635] Fix | Delete
echo "Exiting test because memory_get_usage() returned a negative number\n";
[5636] Fix | Delete
exit();
[5637] Fix | Delete
}
[5638] Fix | Delete
if (memory_get_usage(true) > (1024 * 1024 * 1024)) {
[5639] Fix | Delete
echo "Exiting because current memory usage is greater than a gigabyte.\n";
[5640] Fix | Delete
exit();
[5641] Fix | Delete
}
[5642] Fix | Delete
[5643] Fix | Delete
if (!defined('WP_SANDBOX_SCRAPING')) { define('WP_SANDBOX_SCRAPING', true); } //Disables the WP error handler in somewhat of a hacky way
[5644] Fix | Delete
[5645] Fix | Delete
$accumulatedMemory = array_fill(0, ceil($configuredMax / $stepSize), '');
[5646] Fix | Delete
$currentUsage = memory_get_usage(true);
[5647] Fix | Delete
$tenMB = 10 * 1024 * 1024;
[5648] Fix | Delete
$start = ceil($currentUsage / $tenMB) * $tenMB - $currentUsage; //Start at the closest 10 MB increment to the current usage
[5649] Fix | Delete
$configuredMax = $configuredMax * 1048576; //Bytes
[5650] Fix | Delete
$testLimit = $configuredMax - memory_get_usage(true);
[5651] Fix | Delete
$finalUsage = '0';
[5652] Fix | Delete
$previous = 0;
[5653] Fix | Delete
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111222222222222222222233333333333333334444444444444444444444444555555555555666666666666666666";
[5654] Fix | Delete
$index = 0;
[5655] Fix | Delete
while ($start <= $testLimit) {
[5656] Fix | Delete
$accumulatedMemory[$index] = str_repeat($chars, ($start - $previous) / 256);
[5657] Fix | Delete
[5658] Fix | Delete
$finalUsage = sprintf('%.2f', (memory_get_usage(true) / 1024 / 1024));
[5659] Fix | Delete
echo "Tested up to " . $finalUsage . " megabytes.\n";
[5660] Fix | Delete
if ($start == $testLimit) { break; }
[5661] Fix | Delete
$previous = $start;
[5662] Fix | Delete
$start = min($start + $stepSize, $testLimit);
[5663] Fix | Delete
[5664] Fix | Delete
if (memory_get_usage(true) > $configuredMax) { break; }
[5665] Fix | Delete
$index++;
[5666] Fix | Delete
}
[5667] Fix | Delete
echo "--Test complete.--\n\nYour web host allows you to use at least {$finalUsage} megabytes of memory for each PHP process hosting your WordPress site.\n";
[5668] Fix | Delete
exit();
[5669] Fix | Delete
}
[5670] Fix | Delete
public static function wfLogHumanHeader(){
[5671] Fix | Delete
//Final check in case this was added as an action before the request was fully initialized
[5672] Fix | Delete
if (self::getLog()->getCurrentRequest()->jsRun || !wfConfig::liveTrafficEnabled()) {
[5673] Fix | Delete
return;
[5674] Fix | Delete
}
[5675] Fix | Delete
[5676] Fix | Delete
self::$hitID = self::getLog()->logHit();
[5677] Fix | Delete
if (self::$hitID) {
[5678] Fix | Delete
$URL = home_url('/?wordfence_lh=1&hid=' . wfUtils::encrypt(self::$hitID));
[5679] Fix | Delete
$URL = addslashes(preg_replace('/^https?:/i', '', $URL));
[5680] Fix | Delete
#Load as external script async so we don't slow page down.
[5681] Fix | Delete
echo <<<HTML
[5682] Fix | Delete
<script type="text/javascript">
[5683] Fix | Delete
(function(url){
[5684] Fix | Delete
if(/(?:Chrome\/26\.0\.1410\.63 Safari\/537\.31|WordfenceTestMonBot)/.test(navigator.userAgent)){ return; }
[5685] Fix | Delete
var addEvent = function(evt, handler) {
[5686] Fix | Delete
if (window.addEventListener) {
[5687] Fix | Delete
document.addEventListener(evt, handler, false);
[5688] Fix | Delete
} else if (window.attachEvent) {
[5689] Fix | Delete
document.attachEvent('on' + evt, handler);
[5690] Fix | Delete
}
[5691] Fix | Delete
};
[5692] Fix | Delete
var removeEvent = function(evt, handler) {
[5693] Fix | Delete
if (window.removeEventListener) {
[5694] Fix | Delete
document.removeEventListener(evt, handler, false);
[5695] Fix | Delete
} else if (window.detachEvent) {
[5696] Fix | Delete
document.detachEvent('on' + evt, handler);
[5697] Fix | Delete
}
[5698] Fix | Delete
};
[5699] Fix | Delete
var evts = 'contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop keydown keypress keyup mousedown mousemove mouseout mouseover mouseup mousewheel scroll'.split(' ');
[5700] Fix | Delete
var logHuman = function() {
[5701] Fix | Delete
if (window.wfLogHumanRan) { return; }
[5702] Fix | Delete
window.wfLogHumanRan = true;
[5703] Fix | Delete
var wfscr = document.createElement('script');
[5704] Fix | Delete
wfscr.type = 'text/javascript';
[5705] Fix | Delete
wfscr.async = true;
[5706] Fix | Delete
wfscr.src = url + '&r=' + Math.random();
[5707] Fix | Delete
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(wfscr);
[5708] Fix | Delete
for (var i = 0; i < evts.length; i++) {
[5709] Fix | Delete
removeEvent(evts[i], logHuman);
[5710] Fix | Delete
}
[5711] Fix | Delete
};
[5712] Fix | Delete
for (var i = 0; i < evts.length; i++) {
[5713] Fix | Delete
addEvent(evts[i], logHuman);
[5714] Fix | Delete
}
[5715] Fix | Delete
})('$URL');
[5716] Fix | Delete
</script>
[5717] Fix | Delete
HTML;
[5718] Fix | Delete
}
[5719] Fix | Delete
}
[5720] Fix | Delete
public static function shutdownAction(){
[5721] Fix | Delete
}
[5722] Fix | Delete
public static function wfFunc_viewActivityLog(){
[5723] Fix | Delete
require(dirname(__FILE__) . '/viewFullActivityLog.php');
[5724] Fix | Delete
exit(0);
[5725] Fix | Delete
}
[5726] Fix | Delete
public static function wfFunc_IPTraf(){
[5727] Fix | Delete
$IP = $_GET['IP'];
[5728] Fix | Delete
try {
[5729] Fix | Delete
$response = self::IPTraf($IP);
[5730] Fix | Delete
$reverseLookup = $response['reverseLookup'];
[5731] Fix | Delete
$results = $response['results'];
[5732] Fix | Delete
require(dirname(__FILE__) . '/IPTraf.php');
[5733] Fix | Delete
exit(0);
[5734] Fix | Delete
} catch (InvalidArgumentException $e) {
[5735] Fix | Delete
echo $e->getMessage();
[5736] Fix | Delete
exit;
[5737] Fix | Delete
}
[5738] Fix | Delete
}
[5739] Fix | Delete
[5740] Fix | Delete
private static function IPTraf($ip) {
[5741] Fix | Delete
if(!wfUtils::isValidIP($ip)){
[5742] Fix | Delete
throw new InvalidArgumentException(__("An invalid IP address was specified.", 'wordfence'));
[5743] Fix | Delete
}
[5744] Fix | Delete
$reverseLookup = wfUtils::reverseLookup($ip);
[5745] Fix | Delete
$wfLog = wfLog::shared();
[5746] Fix | Delete
$results = array_merge(
[5747] Fix | Delete
$wfLog->getHits('hits', '404', 0, 10000, $ip),
[5748] Fix | Delete
$wfLog->getHits('hits', 'hit', 0, 10000, $ip)
[5749] Fix | Delete
);
[5750] Fix | Delete
usort($results, 'wordfence::iptrafsort');
[5751] Fix | Delete
[5752] Fix | Delete
$ids = array();
[5753] Fix | Delete
foreach ($results as $k => $r) {
[5754] Fix | Delete
if (isset($ids[$r['id']])) {
[5755] Fix | Delete
unset($results[$k]);
[5756] Fix | Delete
}
[5757] Fix | Delete
else {
[5758] Fix | Delete
$ids[$r['id']] = 1;
[5759] Fix | Delete
}
[5760] Fix | Delete
}
[5761] Fix | Delete
[5762] Fix | Delete
$results = array_values($results);
[5763] Fix | Delete
[5764] Fix | Delete
for ($i = 0; $i < count($results); $i++){
[5765] Fix | Delete
if(array_key_exists($i + 1, $results)){
[5766] Fix | Delete
$results[$i]['timeSinceLastHit'] = sprintf('%.4f', $results[$i]['ctime'] - $results[$i + 1]['ctime']);
[5767] Fix | Delete
} else {
[5768] Fix | Delete
$results[$i]['timeSinceLastHit'] = '';
[5769] Fix | Delete
}
[5770] Fix | Delete
}
[5771] Fix | Delete
return compact('reverseLookup', 'results');
[5772] Fix | Delete
}
[5773] Fix | Delete
[5774] Fix | Delete
public static function iptrafsort($b, $a){
[5775] Fix | Delete
if($a['ctime'] == $b['ctime']){ return 0; }
[5776] Fix | Delete
return ($a['ctime'] < $b['ctime']) ? -1 : 1;
[5777] Fix | Delete
}
[5778] Fix | Delete
[5779] Fix | Delete
private static function checkRealFileParameters() {
[5780] Fix | Delete
if (array_key_exists('realFile', $_GET)) {
[5781] Fix | Delete
$realFile = stripslashes($_GET['realFile']);
[5782] Fix | Delete
$token = array_key_exists('realFileToken', $_GET) ? $_GET['realFileToken'] : '';
[5783] Fix | Delete
if (!wfIssues::verifyRealFileToken($token, $realFile)) {
[5784] Fix | Delete
esc_html_e('This link has expired. Refresh the scan results page and try again.', 'wordfence');
[5785] Fix | Delete
exit(0);
[5786] Fix | Delete
}
[5787] Fix | Delete
return $realFile;
[5788] Fix | Delete
}
[5789] Fix | Delete
return null;
[5790] Fix | Delete
}
[5791] Fix | Delete
[5792] Fix | Delete
public static function wfFunc_viewOption() {
[5793] Fix | Delete
/** @var wpdb $wpdb */
[5794] Fix | Delete
global $wpdb;
[5795] Fix | Delete
$site_id = !empty($_GET['site_id']) ? absint($_GET['site_id']) : get_current_blog_id();
[5796] Fix | Delete
$option_name = !empty($_GET['option']) ? $_GET['option'] : false;
[5797] Fix | Delete
[5798] Fix | Delete
$table_options = wfDB::blogTable('options', $site_id);
[5799] Fix | Delete
$option_value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM {$table_options} WHERE option_name = %s", $option_name));
[5800] Fix | Delete
[5801] Fix | Delete
header('Content-type: text/plain');
[5802] Fix | Delete
exit($option_value);
[5803] Fix | Delete
}
[5804] Fix | Delete
[5805] Fix | Delete
public static function wfFunc_view(){
[5806] Fix | Delete
wfUtils::doNotCache();
[5807] Fix | Delete
if (WORDFENCE_DISABLE_FILE_VIEWER) {
[5808] Fix | Delete
_e("File access blocked. (WORDFENCE_DISABLE_FILE_VIEWER is true)", 'wordfence');
[5809] Fix | Delete
exit();
[5810] Fix | Delete
}
[5811] Fix | Delete
$localFile = self::checkRealFileParameters();
[5812] Fix | Delete
if ($localFile === null)
[5813] Fix | Delete
$localFile = ABSPATH . preg_replace('/^(?:\.\.|[\/]+)/', '', sanitize_text_field($_GET['file']));
[5814] Fix | Delete
if(strpos($localFile, '..') !== false){
[5815] Fix | Delete
_e("Invalid file requested. (Relative paths not allowed)", 'wordfence');
[5816] Fix | Delete
exit();
[5817] Fix | Delete
}
[5818] Fix | Delete
if(preg_match('/[\'\"<>\!\{\}\(\)\&\@\%\$\*\+\[\]\?]+/', $localFile)){
[5819] Fix | Delete
_e("File contains illegal characters.", 'wordfence');
[5820] Fix | Delete
exit();
[5821] Fix | Delete
}
[5822] Fix | Delete
$cont = @file_get_contents($localFile);
[5823] Fix | Delete
$isEmpty = false;
[5824] Fix | Delete
if(! $cont){
[5825] Fix | Delete
if(file_exists($localFile) && filesize($localFile) === 0){ //There's a remote possibility that very large files on 32 bit systems will return 0 here, but it's about 1 in 2 billion
[5826] Fix | Delete
$isEmpty = true;
[5827] Fix | Delete
} else {
[5828] Fix | Delete
$err = error_get_last();
[5829] Fix | Delete
printf(/* translators: Error message. */ __("We could not open the requested file for reading. The error was: %s", 'wordfence'), $err['message']);
[5830] Fix | Delete
exit(0);
[5831] Fix | Delete
}
[5832] Fix | Delete
}
[5833] Fix | Delete
$fileMTime = @filemtime($localFile);
[5834] Fix | Delete
$fileMTime = date('l jS \of F Y h:i:s A', $fileMTime);
[5835] Fix | Delete
try {
[5836] Fix | Delete
if(wfUtils::fileOver2Gigs($localFile)){
[5837] Fix | Delete
$fileSize = __("Greater than 2 Gigs", 'wordfence');
[5838] Fix | Delete
} else {
[5839] Fix | Delete
$fileSize = @filesize($localFile); //Checked if over 2 gigs above
[5840] Fix | Delete
$fileSize = number_format($fileSize, 0, '', ',') . ' bytes';
[5841] Fix | Delete
}
[5842] Fix | Delete
} catch(Exception $e){ $fileSize = __('Unknown file size.', 'wordfence'); }
[5843] Fix | Delete
[5844] Fix | Delete
require(dirname(__FILE__) . '/wfViewResult.php');
[5845] Fix | Delete
exit(0);
[5846] Fix | Delete
}
[5847] Fix | Delete
[5848] Fix | Delete
public static function wfFunc_diff(){
[5849] Fix | Delete
wfUtils::doNotCache();
[5850] Fix | Delete
if (WORDFENCE_DISABLE_FILE_VIEWER) {
[5851] Fix | Delete
esc_html_e("File access blocked. (WORDFENCE_DISABLE_FILE_VIEWER is true)", 'wordfence');
[5852] Fix | Delete
exit();
[5853] Fix | Delete
}
[5854] Fix | Delete
if(preg_match('/[\'\"<>\!\{\}\(\)\&\@\%\$\*\+\[\]\?]+/', $_GET['file'])){
[5855] Fix | Delete
esc_html_e("File contains illegal characters.", 'wordfence');
[5856] Fix | Delete
exit();
[5857] Fix | Delete
}
[5858] Fix | Delete
[5859] Fix | Delete
$result = self::getWPFileContent($_GET['file'], $_GET['cType'], wp_unslash($_GET['cName']), $_GET['cVersion']);
[5860] Fix | Delete
if( isset( $result['errorMsg'] ) && $result['errorMsg']){
[5861] Fix | Delete
echo wp_kses($result['errorMsg'], array());
[5862] Fix | Delete
exit(0);
[5863] Fix | Delete
} else if(! $result['fileContent']){
[5864] Fix | Delete
esc_html_e("We could not get the contents of the original file to do a comparison.", 'wordfence');
[5865] Fix | Delete
exit(0);
[5866] Fix | Delete
}
[5867] Fix | Delete
[5868] Fix | Delete
$localFile = self::checkRealFileParameters();
[5869] Fix | Delete
if ($localFile === null) {
[5870] Fix | Delete
$localFile = realpath(ABSPATH . '/' . preg_replace('/^[\.\/]+/', '', $_GET['file']));
[5871] Fix | Delete
}
[5872] Fix | Delete
if (empty($localFile)) {
[5873] Fix | Delete
esc_html_e('Empty file path provided', 'wordfence');
[5874] Fix | Delete
exit(0);
[5875] Fix | Delete
}
[5876] Fix | Delete
$localContents = file_get_contents($localFile);
[5877] Fix | Delete
if ($localContents === false) {
[5878] Fix | Delete
esc_html_e('Unable to read file contents', 'wordfence');
[5879] Fix | Delete
exit(0);
[5880] Fix | Delete
}
[5881] Fix | Delete
if($localContents == $result['fileContent']){
[5882] Fix | Delete
$diffResult = '';
[5883] Fix | Delete
} else {
[5884] Fix | Delete
$diff = new Diff(
[5885] Fix | Delete
//Treat DOS and Unix files the same
[5886] Fix | Delete
preg_split("/(?:\r\n|\n)/", $result['fileContent']),
[5887] Fix | Delete
preg_split("/(?:\r\n|\n)/", $localContents),
[5888] Fix | Delete
array()
[5889] Fix | Delete
);
[5890] Fix | Delete
$renderer = new Diff_Renderer_Html_SideBySide;
[5891] Fix | Delete
$diffResult = $diff->Render($renderer);
[5892] Fix | Delete
}
[5893] Fix | Delete
require(dirname(__FILE__) . '/diffResult.php');
[5894] Fix | Delete
exit(0);
[5895] Fix | Delete
}
[5896] Fix | Delete
[5897] Fix | Delete
public static function wfFunc_download() {
[5898] Fix | Delete
wfUtils::doNotCache();
[5899] Fix | Delete
if (WORDFENCE_DISABLE_FILE_VIEWER) {
[5900] Fix | Delete
esc_html_e("File access blocked. (WORDFENCE_DISABLE_FILE_VIEWER is true)", 'wordfence');
[5901] Fix | Delete
exit();
[5902] Fix | Delete
}
[5903] Fix | Delete
$localFile = self::checkRealFileParameters();
[5904] Fix | Delete
if ($localFile === null)
[5905] Fix | Delete
$localFile = ABSPATH . preg_replace('/^(?:\.\.|[\/]+)/', '', sanitize_text_field($_GET['file']));
[5906] Fix | Delete
if (strpos($localFile, '..') !== false) {
[5907] Fix | Delete
esc_html_e("Invalid file requested. (Relative paths not allowed)", 'wordfence');
[5908] Fix | Delete
exit();
[5909] Fix | Delete
}
[5910] Fix | Delete
if (preg_match('/[\'\"<>\!\{\}\(\)\&\@\%\$\*\+\[\]\?]+/', $localFile)) {
[5911] Fix | Delete
esc_html_e("File contains illegal characters.", 'wordfence');
[5912] Fix | Delete
exit();
[5913] Fix | Delete
}
[5914] Fix | Delete
if (!file_exists($localFile)) {
[5915] Fix | Delete
_e('File does not exist.', 'wordfence');
[5916] Fix | Delete
exit();
[5917] Fix | Delete
}
[5918] Fix | Delete
[5919] Fix | Delete
$filename = basename($localFile);
[5920] Fix | Delete
header('Content-Type: application/octet-stream');
[5921] Fix | Delete
header('Content-Disposition: attachment; filename="' . $filename . '"');
[5922] Fix | Delete
header('Content-Length: ' . filesize($localFile));
[5923] Fix | Delete
readfile($localFile);
[5924] Fix | Delete
exit;
[5925] Fix | Delete
}
[5926] Fix | Delete
[5927] Fix | Delete
public static function wfFunc_blockedIPs() {
[5928] Fix | Delete
$blocks = wfBlock::ipBlocks(true);
[5929] Fix | Delete
[5930] Fix | Delete
$output = '';
[5931] Fix | Delete
if (is_array($blocks)) {
[5932] Fix | Delete
foreach ($blocks as $entry) {
[5933] Fix | Delete
$output .= $entry->ip . "\n";
[5934] Fix | Delete
}
[5935] Fix | Delete
}
[5936] Fix | Delete
[5937] Fix | Delete
header('Content-Type: application/octet-stream');
[5938] Fix | Delete
header('Content-Disposition: attachment; filename="' . get_bloginfo('name', 'raw') . ' - Blocked IPs.txt"');
[5939] Fix | Delete
header('Content-Length: ' . strlen($output));
[5940] Fix | Delete
[5941] Fix | Delete
echo $output;
[5942] Fix | Delete
exit;
[5943] Fix | Delete
}
[5944] Fix | Delete
[5945] Fix | Delete
/**
[5946] Fix | Delete
*
[5947] Fix | Delete
*/
[5948] Fix | Delete
public static function wfFunc_debugWAF() {
[5949] Fix | Delete
$data = array();
[5950] Fix | Delete
if (!empty($_GET['hitid'])) {
[5951] Fix | Delete
$data['hit'] = new wfRequestModel($_GET['hitid']);
[5952] Fix | Delete
if ($data['hit']->actionData) {
[5953] Fix | Delete
$data['hitData'] = (object) wfRequestModel::unserializeActionData($data['hit']->actionData);
[5954] Fix | Delete
}
[5955] Fix | Delete
echo wfView::create('waf/debug', $data);
[5956] Fix | Delete
}
[5957] Fix | Delete
}
[5958] Fix | Delete
[5959] Fix | Delete
public static function isWafFailureLoggingEnabled() {
[5960] Fix | Delete
return wfConfig::get('other_WFNet', true);
[5961] Fix | Delete
}
[5962] Fix | Delete
[5963] Fix | Delete
private static function purgeWafFailures() {
[5964] Fix | Delete
global $wpdb;
[5965] Fix | Delete
$table = wfDB::networkTable('wfWafFailures');
[5966] Fix | Delete
$wpdb->query("DELETE FROM {$table} WHERE `timestamp` < DATE_SUB(NOW(), INTERVAL 1 DAY)");
[5967] Fix | Delete
}
[5968] Fix | Delete
[5969] Fix | Delete
private static function capWafFailures() {
[5970] Fix | Delete
global $wpdb;
[5971] Fix | Delete
$table = wfDB::networkTable('wfWafFailures');
[5972] Fix | Delete
$highestDeletableId = $wpdb->get_var("SELECT id FROM {$table} ORDER BY id DESC LIMIT 1 OFFSET 25");
[5973] Fix | Delete
if ($highestDeletableId === null)
[5974] Fix | Delete
return;
[5975] Fix | Delete
$wpdb->query(
[5976] Fix | Delete
$wpdb->prepare(
[5977] Fix | Delete
"DELETE FROM {$table} WHERE id <= %d",
[5978] Fix | Delete
$highestDeletableId
[5979] Fix | Delete
)
[5980] Fix | Delete
);
[5981] Fix | Delete
}
[5982] Fix | Delete
[5983] Fix | Delete
public static function logWafFailure() {
[5984] Fix | Delete
global $wf_waf_failure, $wpdb;
[5985] Fix | Delete
if (!self::isWafFailureLoggingEnabled())
[5986] Fix | Delete
return;
[5987] Fix | Delete
if (is_array($wf_waf_failure) && array_key_exists('throwable', $wf_waf_failure)) {
[5988] Fix | Delete
$throwable = $wf_waf_failure['throwable'];
[5989] Fix | Delete
if (!($throwable instanceof Throwable || $throwable instanceof Exception))
[5990] Fix | Delete
return;
[5991] Fix | Delete
$table = wfDB::networkTable('wfWafFailures');
[5992] Fix | Delete
$data = [
[5993] Fix | Delete
'throwable' => (string) $throwable
[5994] Fix | Delete
];
[5995] Fix | Delete
if (array_key_exists('rule_id', $wf_waf_failure)) {
[5996] Fix | Delete
$ruleId = $wf_waf_failure['rule_id'];
[5997] Fix | Delete
if (is_int($ruleId) || $ruleId >= 0)
[5998] Fix | Delete
$data['rule_id'] = (int) $ruleId;
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function