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
'nonce' => wp_create_nonce('wp-ajax'),
[1500] Fix | Delete
));
[1501] Fix | Delete
}
[1502] Fix | Delete
}
[1503] Fix | Delete
}
[1504] Fix | Delete
public static function ajax_testAjax_callback(){
[1505] Fix | Delete
die("WFSCANTESTOK");
[1506] Fix | Delete
}
[1507] Fix | Delete
public static function ajax_doScan_callback(){
[1508] Fix | Delete
@ignore_user_abort(true);
[1509] Fix | Delete
self::$wordfence_wp_version = false;
[1510] Fix | Delete
if (!defined('DONOTCACHEDB')) { define('DONOTCACHEDB', true); }
[1511] Fix | Delete
//This is messy, but not sure of a better way to do this without guaranteeing we get $wp_version
[1512] Fix | Delete
require(ABSPATH . 'wp-includes/version.php'); /** @var string $wp_version */
[1513] Fix | Delete
self::$wordfence_wp_version = $wp_version;
[1514] Fix | Delete
require_once(dirname(__FILE__) . '/wfScan.php');
[1515] Fix | Delete
wfScan::wfScanMain();
[1516] Fix | Delete
[1517] Fix | Delete
} //END doScan
[1518] Fix | Delete
public static function ajax_lh_callback(){
[1519] Fix | Delete
self::getLog()->canLogHit = false;
[1520] Fix | Delete
$UA = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
[1521] Fix | Delete
$isCrawler = empty($UA);
[1522] Fix | Delete
if ($UA) {
[1523] Fix | Delete
if (wfCrawl::isCrawler($UA) || wfCrawl::isGoogleCrawler()) {
[1524] Fix | Delete
$isCrawler = true;
[1525] Fix | Delete
}
[1526] Fix | Delete
}
[1527] Fix | Delete
[1528] Fix | Delete
@ob_end_clean();
[1529] Fix | Delete
if(! headers_sent()){
[1530] Fix | Delete
header('Content-type: text/javascript');
[1531] Fix | Delete
header("Connection: close");
[1532] Fix | Delete
header("Content-Length: 0");
[1533] Fix | Delete
header("X-Robots-Tag: noindex");
[1534] Fix | Delete
if (!$isCrawler) {
[1535] Fix | Delete
wfLog::cacheHumanRequester(wfUtils::getIP(), $UA);
[1536] Fix | Delete
}
[1537] Fix | Delete
}
[1538] Fix | Delete
flush();
[1539] Fix | Delete
if (!$isCrawler && array_key_exists('hid', $_GET)) {
[1540] Fix | Delete
$hid = $_GET['hid'];
[1541] Fix | Delete
$hid = wfUtils::decrypt($hid);
[1542] Fix | Delete
if (!is_string($hid) || !preg_match('/^\d+$/', $hid)) { exit(); }
[1543] Fix | Delete
$db = new wfDB();
[1544] Fix | Delete
$table_wfHits = wfDB::networkTable('wfHits');
[1545] Fix | Delete
$db->queryWrite("update {$table_wfHits} set jsRun=1 where id=%d", $hid);
[1546] Fix | Delete
}
[1547] Fix | Delete
die("");
[1548] Fix | Delete
}
[1549] Fix | Delete
public static function ajaxReceiver(){
[1550] Fix | Delete
if(! wfUtils::isAdmin()){
[1551] Fix | Delete
wfUtils::send_json(array('errorMsg' => __("You appear to have logged out or you are not an admin. Please sign-out and sign-in again.", 'wordfence')));
[1552] Fix | Delete
}
[1553] Fix | Delete
$func = (isset($_POST['action']) && $_POST['action']) ? $_POST['action'] : $_GET['action'];
[1554] Fix | Delete
$nonce = (isset($_POST['nonce']) && $_POST['nonce']) ? $_POST['nonce'] : $_GET['nonce'];
[1555] Fix | Delete
if(! wp_verify_nonce($nonce, 'wp-ajax')){
[1556] Fix | Delete
wfUtils::send_json(array('errorMsg' => __("Your browser sent an invalid security token to Wordfence. Please try reloading this page or signing out and in again.", 'wordfence'), 'tokenInvalid' => 1));
[1557] Fix | Delete
}
[1558] Fix | Delete
//func is e.g. wordfence_ticker so need to munge it
[1559] Fix | Delete
$func = str_replace('wordfence_', '', $func);
[1560] Fix | Delete
$returnArr = call_user_func('wordfence::ajax_' . $func . '_callback');
[1561] Fix | Delete
if($returnArr === false){
[1562] Fix | Delete
$returnArr = array('errorMsg' => __("Wordfence encountered an internal error executing that request.", 'wordfence'));
[1563] Fix | Delete
}
[1564] Fix | Delete
[1565] Fix | Delete
if(! is_array($returnArr)){
[1566] Fix | Delete
error_log("Function " . wp_kses($func, array()) . " did not return an array and did not generate an error.");
[1567] Fix | Delete
$returnArr = array();
[1568] Fix | Delete
}
[1569] Fix | Delete
if(isset($returnArr['nonce'])){
[1570] Fix | Delete
error_log("Wordfence ajax function return an array with 'nonce' already set. This could be a bug.");
[1571] Fix | Delete
}
[1572] Fix | Delete
$returnArr['nonce'] = wp_create_nonce('wp-ajax');
[1573] Fix | Delete
wfUtils::send_json($returnArr);
[1574] Fix | Delete
}
[1575] Fix | Delete
public static function ajax_remoteVerifySwitchTo2FANew_callback() {
[1576] Fix | Delete
$payload = wfUtils::decodeJWT(wfConfig::get('new2FAMigrationNonce'));
[1577] Fix | Delete
if (empty($payload)) {
[1578] Fix | Delete
wfUtils::send_json(new stdClass()); //Ensures an object response
[1579] Fix | Delete
}
[1580] Fix | Delete
[1581] Fix | Delete
$package = wfCrypt::noc1_encrypt($payload);
[1582] Fix | Delete
wfUtils::send_json($package);
[1583] Fix | Delete
}
[1584] Fix | Delete
public static function ajax_switchTo2FANew_callback() {
[1585] Fix | Delete
$migrate = (isset($_POST['migrate']) && wfUtils::truthyToBoolean($_POST['migrate']));
[1586] Fix | Delete
[1587] Fix | Delete
$twoFactorUsers = wfConfig::get_ser('twoFactorUsers', array());
[1588] Fix | Delete
if ($migrate && is_array($twoFactorUsers) && !empty($twoFactorUsers)) {
[1589] Fix | Delete
$smsActive = array();
[1590] Fix | Delete
$authenticatorActive = array();
[1591] Fix | Delete
foreach ($twoFactorUsers as &$t) {
[1592] Fix | Delete
if ($t[3] == 'activated') {
[1593] Fix | Delete
$user = new WP_User($t[0]);
[1594] Fix | Delete
if ($user instanceof WP_User && $user->exists()) {
[1595] Fix | Delete
if ((!isset($t[5]) || $t[5] != 'authenticator')) {
[1596] Fix | Delete
$smsActive[] = $user->user_login;
[1597] Fix | Delete
}
[1598] Fix | Delete
else {
[1599] Fix | Delete
$authenticatorActive[] = $t[6];
[1600] Fix | Delete
}
[1601] Fix | Delete
}
[1602] Fix | Delete
}
[1603] Fix | Delete
}
[1604] Fix | Delete
[1605] Fix | Delete
if (!empty($smsActive)) {
[1606] Fix | Delete
return array('ok' => 0, 'smsActive' => $smsActive);
[1607] Fix | Delete
}
[1608] Fix | Delete
[1609] Fix | Delete
$total = 0;
[1610] Fix | Delete
$imported = 0;
[1611] Fix | Delete
$nonce = bin2hex(wfWAFUtils::random_bytes(32));
[1612] Fix | Delete
wfConfig::set('new2FAMigrationNonce', wfUtils::generateJWT(array('nonce' => $nonce), 90));
[1613] Fix | Delete
$api = new wfAPI(wfConfig::get('apiKey'), wfUtils::getWPVersion());
[1614] Fix | Delete
try {
[1615] Fix | Delete
$response = $api->call('twoFactorTOTP_migrate', array(), array('migrateids' => json_encode($authenticatorActive), 'nonce' => $nonce, 'verifyurl' => add_query_arg(array('action' => 'wordfence_remoteVerifySwitchTo2FANew'), admin_url('admin-ajax.php'))));
[1616] Fix | Delete
/*
[1617] Fix | Delete
* A successful response will be in the format
[1618] Fix | Delete
* {
[1619] Fix | Delete
* "ok": 1,
[1620] Fix | Delete
* "records": {
[1621] Fix | Delete
* "skipped": {
[1622] Fix | Delete
* <id>: true, ... if applicable
[1623] Fix | Delete
* },
[1624] Fix | Delete
* "totp": {
[1625] Fix | Delete
* <id>: {
[1626] Fix | Delete
* "secret": <secret>,
[1627] Fix | Delete
* "recovery": <recovery keys>,
[1628] Fix | Delete
* "ctime": <timestamp created>,
[1629] Fix | Delete
* "vtime": <timestamp of last verified TOTP code>
[1630] Fix | Delete
* },
[1631] Fix | Delete
* ...
[1632] Fix | Delete
* }
[1633] Fix | Delete
* }
[1634] Fix | Delete
* }
[1635] Fix | Delete
*/
[1636] Fix | Delete
[1637] Fix | Delete
if (!is_array($response) || !isset($response['records']) || !is_array($response['records'])) {
[1638] Fix | Delete
return array('ok' => 0, 'fail' => 1);
[1639] Fix | Delete
}
[1640] Fix | Delete
[1641] Fix | Delete
$secrets = $response['records'];
[1642] Fix | Delete
if (!isset($secrets['totp']) || !is_array($secrets['totp'])) {
[1643] Fix | Delete
return array('ok' => 0, 'fail' => 2);
[1644] Fix | Delete
}
[1645] Fix | Delete
[1646] Fix | Delete
$import = array();
[1647] Fix | Delete
foreach ($twoFactorUsers as &$t) {
[1648] Fix | Delete
if ($t[3] == 'activated') {
[1649] Fix | Delete
$user = new WP_User($t[0]);
[1650] Fix | Delete
if ($user instanceof WP_User && $user->exists()) {
[1651] Fix | Delete
if ((!isset($t[5]) || $t[5] != 'authenticator')) {
[1652] Fix | Delete
//Do nothing
[1653] Fix | Delete
}
[1654] Fix | Delete
else {
[1655] Fix | Delete
if (isset($secrets['totp'][$t[6]])) {
[1656] Fix | Delete
$import[$user->ID] = $secrets['totp'][$t[6]];
[1657] Fix | Delete
$import[$user->ID]['type'] = 'authenticator';
[1658] Fix | Delete
$total++;
[1659] Fix | Delete
}
[1660] Fix | Delete
}
[1661] Fix | Delete
}
[1662] Fix | Delete
}
[1663] Fix | Delete
}
[1664] Fix | Delete
[1665] Fix | Delete
$imported = WFLSPHP52Compatability::import_2fa($import);
[1666] Fix | Delete
}
[1667] Fix | Delete
catch (Exception $e) {
[1668] Fix | Delete
wordfence::status(4, 'error', sprintf(/* translators: Error message. */ __('2FA Migration Error: %s', 'wordfence'), $e->getMessage()));
[1669] Fix | Delete
return array('ok' => 0, 'fail' => 1);
[1670] Fix | Delete
}
[1671] Fix | Delete
[1672] Fix | Delete
wfConfig::remove('new2FAMigrationNonce');
[1673] Fix | Delete
wfConfig::set(wfCredentialsController::DISABLE_LEGACY_2FA_OPTION, true);
[1674] Fix | Delete
return array('ok' => 1, 'total' => $total, 'imported' => $imported);
[1675] Fix | Delete
}
[1676] Fix | Delete
[1677] Fix | Delete
//No legacy 2FA active, just set the option.
[1678] Fix | Delete
wfConfig::set(wfCredentialsController::DISABLE_LEGACY_2FA_OPTION, true);
[1679] Fix | Delete
return array('ok' => 1);
[1680] Fix | Delete
}
[1681] Fix | Delete
public static function ajax_switchTo2FAOld_callback() {
[1682] Fix | Delete
wfConfig::set(wfCredentialsController::DISABLE_LEGACY_2FA_OPTION, false);
[1683] Fix | Delete
return array('ok' => 1);
[1684] Fix | Delete
}
[1685] Fix | Delete
public static function validateProfileUpdate($errors, $update, $userData){
[1686] Fix | Delete
wordfence::validatePassword($errors, $userData);
[1687] Fix | Delete
}
[1688] Fix | Delete
public static function validatePassword($errors, $userData) {
[1689] Fix | Delete
$password = (isset($_POST['pass1']) && trim($_POST['pass1'])) ? $_POST['pass1'] : false;
[1690] Fix | Delete
$user_id = isset($userData->ID) ? $userData->ID : false;
[1691] Fix | Delete
$username = isset($_POST["user_login"]) ? $_POST["user_login"] : $userData->user_login;
[1692] Fix | Delete
if ($password == false) { return $errors; }
[1693] Fix | Delete
if ($errors->get_error_data("pass")) { return $errors; }
[1694] Fix | Delete
[1695] Fix | Delete
$enforceStrongPasswds = false;
[1696] Fix | Delete
if (wfConfig::get('loginSec_strongPasswds_enabled')) {
[1697] Fix | Delete
if (wfConfig::get('loginSec_strongPasswds') == 'pubs') {
[1698] Fix | Delete
if (user_can($user_id, 'publish_posts')) {
[1699] Fix | Delete
$enforceStrongPasswds = true;
[1700] Fix | Delete
}
[1701] Fix | Delete
}
[1702] Fix | Delete
else if (wfConfig::get('loginSec_strongPasswds') == 'all') {
[1703] Fix | Delete
$enforceStrongPasswds = true;
[1704] Fix | Delete
}
[1705] Fix | Delete
}
[1706] Fix | Delete
[1707] Fix | Delete
if ($enforceStrongPasswds && !wordfence::isStrongPasswd($password, $username)) {
[1708] Fix | Delete
$errors->add('pass', __('<strong>ERROR</strong>: The password could not be changed. Please choose a stronger password and try again. A strong password will follow these guidelines: <ul class="wf-password-requirements">
[1709] Fix | Delete
<li>At least 12 characters</li>
[1710] Fix | Delete
<li>Uppercase and lowercase letters</li>
[1711] Fix | Delete
<li>At least one symbol</li>
[1712] Fix | Delete
<li>At least one number</li>
[1713] Fix | Delete
<li>Avoid common words or sequences of letters/numbers</li>
[1714] Fix | Delete
</ul>', 'wordfence'));
[1715] Fix | Delete
return $errors;
[1716] Fix | Delete
}
[1717] Fix | Delete
[1718] Fix | Delete
$twoFactorUsers = wfConfig::get_ser('twoFactorUsers', array());
[1719] Fix | Delete
if (preg_match(self::$passwordCodePattern, $password) && is_array($twoFactorUsers) && count($twoFactorUsers) > 0) {
[1720] Fix | Delete
$errors->add('pass', __('Passwords containing a space followed by "wf" without quotes are not allowed.', 'wordfence'));
[1721] Fix | Delete
return $errors;
[1722] Fix | Delete
}
[1723] Fix | Delete
[1724] Fix | Delete
$enforceBreachedPasswds = false;
[1725] Fix | Delete
if (wfConfig::get('loginSec_breachPasswds_enabled')) {
[1726] Fix | Delete
if ($user_id !== false && wfConfig::get('loginSec_breachPasswds') == 'admins' && wfUtils::isAdmin($user_id)) {
[1727] Fix | Delete
$enforceBreachedPasswds = true;
[1728] Fix | Delete
}
[1729] Fix | Delete
else if ($user_id !== false && wfConfig::get('loginSec_breachPasswds') == 'pubs' && user_can($user_id, 'publish_posts')) {
[1730] Fix | Delete
$enforceBreachedPasswds = true;
[1731] Fix | Delete
}
[1732] Fix | Delete
}
[1733] Fix | Delete
[1734] Fix | Delete
if ($enforceBreachedPasswds && wfCredentialsController::isLeakedPassword($username, $password)) {
[1735] Fix | Delete
$errors->add('pass', sprintf(/* translators: Support URL. */ __('Please choose a different password. The password you are using exists on lists of passwords leaked in data breaches. Attackers use such lists to break into sites and install malicious code. <a href="%s">Learn More</a>', 'wordfence'), wfSupportController::esc_supportURL(wfSupportController::ITEM_USING_BREACH_PASSWORD)));
[1736] Fix | Delete
return $errors;
[1737] Fix | Delete
}
[1738] Fix | Delete
else if ($user_id !== false) {
[1739] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, '2faBreachPassword', array($user_id));
[1740] Fix | Delete
wfAdminNoticeQueue::removeAdminNotice(false, 'previousIPBreachPassword', array($user_id));
[1741] Fix | Delete
wfCredentialsController::clearCachedCredentialStatus($userData);
[1742] Fix | Delete
}
[1743] Fix | Delete
[1744] Fix | Delete
return $errors;
[1745] Fix | Delete
}
[1746] Fix | Delete
public static function isStrongPasswd($passwd, $username ) {
[1747] Fix | Delete
$passwd = trim($passwd);
[1748] Fix | Delete
$lowerPasswd = strtolower($passwd);
[1749] Fix | Delete
$passwdLength = strlen($lowerPasswd);
[1750] Fix | Delete
if ($passwdLength < 12)
[1751] Fix | Delete
return false;
[1752] Fix | Delete
if ($lowerPasswd == strtolower( $username ) )
[1753] Fix | Delete
return false;
[1754] Fix | Delete
if (preg_match('/(?:password|passwd|mypass|wordpress)/i', $passwd))
[1755] Fix | Delete
return false;
[1756] Fix | Delete
if (preg_match('/(.)\1{2,}/', $lowerPasswd)) //Disallow any character repeated 3 or more times
[1757] Fix | Delete
return false;
[1758] Fix | Delete
/*
[1759] Fix | Delete
* Check for ordered sequences of at least 4 characters for alphabetic sequences and 3 characters for other sequences, ignoring case
[1760] Fix | Delete
* Examples:
[1761] Fix | Delete
* - 321
[1762] Fix | Delete
* - abcd
[1763] Fix | Delete
* - abab
[1764] Fix | Delete
*/
[1765] Fix | Delete
$last = null;
[1766] Fix | Delete
$sequenceLength = 1;
[1767] Fix | Delete
$alphabetic = true;
[1768] Fix | Delete
for ($i = 0; $i < $passwdLength; $i++) {
[1769] Fix | Delete
$current = ord($lowerPasswd[$i]);
[1770] Fix | Delete
if ($last !== null) {
[1771] Fix | Delete
if (abs($current - $last) === 1) {
[1772] Fix | Delete
$alphabetic &= ctype_alpha($lowerPasswd[$i]);
[1773] Fix | Delete
if (++$sequenceLength > ($alphabetic ? 3 : 2))
[1774] Fix | Delete
return false;
[1775] Fix | Delete
}
[1776] Fix | Delete
else {
[1777] Fix | Delete
$sequenceLength = 1;
[1778] Fix | Delete
$alphabetic = true;
[1779] Fix | Delete
}
[1780] Fix | Delete
}
[1781] Fix | Delete
$last = $current;
[1782] Fix | Delete
}
[1783] Fix | Delete
$characterTypes = array(
[1784] Fix | Delete
'/[a-z]/',
[1785] Fix | Delete
'/[A-Z]/',
[1786] Fix | Delete
'/[0-9]/',
[1787] Fix | Delete
'/[^a-zA-Z0-9]/'
[1788] Fix | Delete
);
[1789] Fix | Delete
foreach ($characterTypes as $type) {
[1790] Fix | Delete
if (!preg_match($type, $passwd))
[1791] Fix | Delete
return false;
[1792] Fix | Delete
}
[1793] Fix | Delete
return true;
[1794] Fix | Delete
}
[1795] Fix | Delete
public static function lostPasswordPost($errors = null, $user = null) {
[1796] Fix | Delete
$IP = wfUtils::getIP();
[1797] Fix | Delete
if ($request = self::getLog()->getCurrentRequest()) {
[1798] Fix | Delete
$request->action = 'lostPassword';
[1799] Fix | Delete
$request->save();
[1800] Fix | Delete
}
[1801] Fix | Delete
if (wfBlock::isWhitelisted($IP)) {
[1802] Fix | Delete
return;
[1803] Fix | Delete
}
[1804] Fix | Delete
[1805] Fix | Delete
$lockout = wfBlock::lockoutForIP(wfUtils::getIP());
[1806] Fix | Delete
if ($lockout !== false) {
[1807] Fix | Delete
$lockout->recordBlock();
[1808] Fix | Delete
$customText = wpautop(wp_strip_all_tags(wfConfig::get('blockCustomText', '')));
[1809] Fix | Delete
require(dirname(__FILE__) . '/wfLockedOut.php');
[1810] Fix | Delete
}
[1811] Fix | Delete
[1812] Fix | Delete
if ($user === null) {
[1813] Fix | Delete
if (empty($_POST['user_login'])) { return; }
[1814] Fix | Delete
$user_login = $_POST['user_login'];
[1815] Fix | Delete
if (is_array($user_login)) { $user_login = wfUtils::array_first($user_login); }
[1816] Fix | Delete
$user_login = trim($user_login);
[1817] Fix | Delete
$user = get_user_by('login', $user_login);
[1818] Fix | Delete
if (!$user) {
[1819] Fix | Delete
$user = get_user_by('email', $user_login);
[1820] Fix | Delete
}
[1821] Fix | Delete
}
[1822] Fix | Delete
[1823] Fix | Delete
if ($user === false && wfConfig::get('loginSec_maskLoginErrors')) {
[1824] Fix | Delete
if (self::hasWoocommerce() && isset($_POST['wc_reset_password'], $_POST['user_login'])) {
[1825] Fix | Delete
$redirectUrl = add_query_arg('reset-link-sent', 'true', wc_get_account_endpoint_url('lost-password'));
[1826] Fix | Delete
}
[1827] Fix | Delete
else {
[1828] Fix | Delete
$redirectUrl = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'wp-login.php?checkemail=confirm';
[1829] Fix | Delete
}
[1830] Fix | Delete
wp_safe_redirect($redirectUrl);
[1831] Fix | Delete
exit;
[1832] Fix | Delete
}
[1833] Fix | Delete
[1834] Fix | Delete
if($user){
[1835] Fix | Delete
$alertCallback = array(new wfLostPasswdFormAlert($user, wfUtils::getIP()), 'send');
[1836] Fix | Delete
do_action('wordfence_security_event', 'lostPasswdForm', array(
[1837] Fix | Delete
'email' => $user->user_email,
[1838] Fix | Delete
'ip' => wfUtils::getIP(),
[1839] Fix | Delete
), $alertCallback);
[1840] Fix | Delete
[1841] Fix | Delete
}
[1842] Fix | Delete
[1843] Fix | Delete
// do not count password reset attempts if there is a user logged in with the edit_users capability
[1844] Fix | Delete
// because they're probably using the "send password reset" feature in the WP admin and therefore we shouldn't
[1845] Fix | Delete
// be locking them out!
[1846] Fix | Delete
if(wfConfig::get('loginSecurityEnabled') && !current_user_can( 'edit_users' ) ){
[1847] Fix | Delete
$tKey = self::getForgotPasswordFailureCountTransient($IP);
[1848] Fix | Delete
$forgotAttempts = get_transient($tKey);
[1849] Fix | Delete
if($forgotAttempts){
[1850] Fix | Delete
$forgotAttempts++;
[1851] Fix | Delete
} else {
[1852] Fix | Delete
$forgotAttempts = 1;
[1853] Fix | Delete
}
[1854] Fix | Delete
if($forgotAttempts >= wfConfig::get('loginSec_maxForgotPasswd')){
[1855] Fix | Delete
self::lockOutIP($IP, sprintf(
[1856] Fix | Delete
/* translators: 1. Password reset limit (number). 2. WordPress username. */
[1857] Fix | Delete
__('Exceeded the maximum number of tries to recover their password which is set at: %1$s. The last username or email they entered before getting locked out was: \'%2$s\'', 'wordfence'),
[1858] Fix | Delete
wfConfig::get('loginSec_maxForgotPasswd'),
[1859] Fix | Delete
$_POST['user_login']
[1860] Fix | Delete
));
[1861] Fix | Delete
$customText = wpautop(wp_strip_all_tags(wfConfig::get('blockCustomText', '')));
[1862] Fix | Delete
require(dirname(__FILE__) . '/wfLockedOut.php');
[1863] Fix | Delete
}
[1864] Fix | Delete
set_transient($tKey, $forgotAttempts, wfConfig::get('loginSec_countFailMins') * 60);
[1865] Fix | Delete
}
[1866] Fix | Delete
}
[1867] Fix | Delete
public static function lockOutIP($IP, $reason) {
[1868] Fix | Delete
wfBlock::createLockout($reason, $IP, wfBlock::lockoutDuration(), time(), time(), 1);
[1869] Fix | Delete
self::getLog()->tagRequestForLockout($reason);
[1870] Fix | Delete
$alertCallback = array(new wfLoginLockoutAlert($IP, $reason), 'send');
[1871] Fix | Delete
do_action('wordfence_security_event', 'loginLockout', array(
[1872] Fix | Delete
'ip' => $IP,
[1873] Fix | Delete
'reason' => $reason,
[1874] Fix | Delete
'duration' => wfBlock::lockoutDuration(),
[1875] Fix | Delete
), $alertCallback);
[1876] Fix | Delete
[1877] Fix | Delete
}
[1878] Fix | Delete
[1879] Fix | Delete
public static function getLoginFailureCountTransient($IP) {
[1880] Fix | Delete
return 'wflginfl_' . bin2hex(wfUtils::inet_pton($IP));
[1881] Fix | Delete
}
[1882] Fix | Delete
[1883] Fix | Delete
public static function getForgotPasswordFailureCountTransient($IP) {
[1884] Fix | Delete
return 'wffgt_' . bin2hex(wfUtils::inet_pton($IP));
[1885] Fix | Delete
}
[1886] Fix | Delete
[1887] Fix | Delete
public static function clearLockoutCounters($IP) {
[1888] Fix | Delete
delete_transient(self::getLoginFailureCountTransient($IP));
[1889] Fix | Delete
delete_transient(self::getForgotPasswordFailureCountTransient($IP));
[1890] Fix | Delete
}
[1891] Fix | Delete
[1892] Fix | Delete
public static function veryFirstAction() {
[1893] Fix | Delete
/** @var wpdb $wpdb ; */
[1894] Fix | Delete
global $wpdb;
[1895] Fix | Delete
[1896] Fix | Delete
self::initProtection();
[1897] Fix | Delete
[1898] Fix | Delete
$wfFunc = isset($_GET['_wfsf']) ? @$_GET['_wfsf'] : false;
[1899] Fix | Delete
if ($wfFunc == 'unlockEmail') {
[1900] Fix | Delete
$nonceValid = false;
[1901] Fix | Delete
if (isset($_POST['nonce']) && is_string($_POST['nonce'])) {
[1902] Fix | Delete
$nonceValid = wp_verify_nonce($_POST['nonce'], 'wf-form');
[1903] Fix | Delete
if (!$nonceValid && method_exists(wfWAF::getInstance(), 'createNonce')) {
[1904] Fix | Delete
$nonceValid = wfWAF::getInstance()->verifyNonce($_POST['nonce'], 'wf-form');
[1905] Fix | Delete
}
[1906] Fix | Delete
}
[1907] Fix | Delete
[1908] Fix | Delete
if(!$nonceValid){
[1909] Fix | Delete
die(__("Sorry but your browser sent an invalid security token when trying to use this form.", 'wordfence'));
[1910] Fix | Delete
}
[1911] Fix | Delete
$numTries = get_transient('wordfenceUnlockTries');
[1912] Fix | Delete
if($numTries > 10){
[1913] Fix | Delete
printf("<html><body><h1>%s</h1><p>%s</p></body></html>",
[1914] Fix | Delete
esc_html__('Please wait 3 minutes and try again', 'wordfence'),
[1915] Fix | Delete
esc_html__('You have used this form too much. Please wait 3 minutes and try again.', 'wordfence')
[1916] Fix | Delete
);
[1917] Fix | Delete
exit();
[1918] Fix | Delete
}
[1919] Fix | Delete
if(! $numTries){ $numTries = 1; } else { $numTries = $numTries + 1; }
[1920] Fix | Delete
set_transient('wordfenceUnlockTries', $numTries, 180);
[1921] Fix | Delete
[1922] Fix | Delete
$email = trim(@$_POST['email']);
[1923] Fix | Delete
global $wpdb;
[1924] Fix | Delete
$ws = $wpdb->get_results($wpdb->prepare("SELECT ID, user_login FROM $wpdb->users WHERE user_email = %s", $email));
[1925] Fix | Delete
$found = false;
[1926] Fix | Delete
foreach($ws as $user){
[1927] Fix | Delete
$userDat = get_userdata($user->ID);
[1928] Fix | Delete
if(wfUtils::isAdmin($userDat)){
[1929] Fix | Delete
if($email == $userDat->user_email){
[1930] Fix | Delete
$found = true;
[1931] Fix | Delete
break;
[1932] Fix | Delete
}
[1933] Fix | Delete
}
[1934] Fix | Delete
}
[1935] Fix | Delete
if(! $found){
[1936] Fix | Delete
foreach(wfConfig::getAlertEmails() as $alertEmail){
[1937] Fix | Delete
if($alertEmail == $email){
[1938] Fix | Delete
$found = true;
[1939] Fix | Delete
break;
[1940] Fix | Delete
}
[1941] Fix | Delete
}
[1942] Fix | Delete
}
[1943] Fix | Delete
if($found){
[1944] Fix | Delete
$key = wfUtils::bigRandomHex();
[1945] Fix | Delete
$IP = wfUtils::getIP();
[1946] Fix | Delete
set_transient('wfunlock_' . $key, $IP, 1800);
[1947] Fix | Delete
$content = wfUtils::tmpl('email_unlockRequest.php', array(
[1948] Fix | Delete
'siteName' => get_bloginfo('name', 'raw'),
[1949] Fix | Delete
'siteURL' => wfUtils::getSiteBaseURL(),
[1950] Fix | Delete
'unlockHref' => wfUtils::getSiteBaseURL() . '?_wfsf=unlockAccess&key=' . $key,
[1951] Fix | Delete
'key' => $key,
[1952] Fix | Delete
'IP' => $IP
[1953] Fix | Delete
));
[1954] Fix | Delete
wp_mail($email, __("Unlock email requested", 'wordfence'), $content, "Content-Type: text/html");
[1955] Fix | Delete
}
[1956] Fix | Delete
echo "<html><body><h1>" . esc_html__('Your request was received', 'wordfence') . "</h1><p>" .
[1957] Fix | Delete
esc_html(sprintf(/* translators: Email address. */ __("We received a request to email \"%s\" instructions to unlock their access. If that is the email address of a site administrator or someone on the Wordfence alert list, they have been emailed instructions on how to regain access to this system. The instructions we sent will expire 30 minutes from now.", 'wordfence'), wp_kses($email, array())))
[1958] Fix | Delete
. "</p></body></html>";
[1959] Fix | Delete
[1960] Fix | Delete
exit();
[1961] Fix | Delete
} else if($wfFunc == 'unlockAccess'){
[1962] Fix | Delete
if (!preg_match('/^(?:(?:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9](?::|$)){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))$/i', get_transient('wfunlock_' . $_GET['key']))) {
[1963] Fix | Delete
_e("Invalid key provided for authentication.", 'wordfence');
[1964] Fix | Delete
exit();
[1965] Fix | Delete
}
[1966] Fix | Delete
[1967] Fix | Delete
if($_GET['func'] == 'unlockMyIP'){
[1968] Fix | Delete
wfBlock::unblockIP(wfUtils::getIP());
[1969] Fix | Delete
if (class_exists('wfWAFIPBlocksController')) { wfWAFIPBlocksController::setNeedsSynchronizeConfigSettings(); }
[1970] Fix | Delete
self::clearLockoutCounters(wfUtils::getIP());
[1971] Fix | Delete
header('Location: ' . wp_login_url());
[1972] Fix | Delete
exit();
[1973] Fix | Delete
} else if($_GET['func'] == 'unlockAllIPs'){
[1974] Fix | Delete
wordfence::status(1, 'info', __("Request received via unlock email link to unblock all IPs.", 'wordfence'));
[1975] Fix | Delete
wfBlock::removeAllIPBlocks();
[1976] Fix | Delete
if (class_exists('wfWAFIPBlocksController')) { wfWAFIPBlocksController::setNeedsSynchronizeConfigSettings(); }
[1977] Fix | Delete
self::clearLockoutCounters(wfUtils::getIP());
[1978] Fix | Delete
header('Location: ' . wp_login_url());
[1979] Fix | Delete
exit();
[1980] Fix | Delete
} else if($_GET['func'] == 'disableRules'){
[1981] Fix | Delete
wfConfig::set('firewallEnabled', 0);
[1982] Fix | Delete
wfConfig::set('loginSecurityEnabled', 0);
[1983] Fix | Delete
wordfence::status(1, 'info', __("Request received via unlock email link to unblock all IPs via disabling firewall rules.", 'wordfence'));
[1984] Fix | Delete
wfBlock::removeAllIPBlocks();
[1985] Fix | Delete
wfBlock::removeAllCountryBlocks();
[1986] Fix | Delete
if (class_exists('wfWAFIPBlocksController')) { wfWAFIPBlocksController::setNeedsSynchronizeConfigSettings(); }
[1987] Fix | Delete
self::clearLockoutCounters(wfUtils::getIP());
[1988] Fix | Delete
header('Location: ' . wp_login_url());
[1989] Fix | Delete
exit();
[1990] Fix | Delete
} else {
[1991] Fix | Delete
_e("Invalid function specified. Please check the link we emailed you and make sure it was not cut-off by your email reader.", 'wordfence');
[1992] Fix | Delete
exit();
[1993] Fix | Delete
}
[1994] Fix | Delete
}
[1995] Fix | Delete
else if ($wfFunc == 'detectProxy') {
[1996] Fix | Delete
wfUtils::doNotCache();
[1997] Fix | Delete
if (wfUtils::processDetectProxyCallback()) {
[1998] Fix | Delete
self::getLog()->getCurrentRequest()->action = 'scan:detectproxy'; //Exempt a valid callback from live traffic
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function