本文整理汇总了PHP中wfUtils::bigRandomHex方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::bigRandomHex方法的具体用法?PHP wfUtils::bigRandomHex怎么用?PHP wfUtils::bigRandomHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::bigRandomHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDefaults
public static function setDefaults()
{
foreach (self::$defaultConfig['checkboxes'] as $key => $val) {
if (self::get($key) === false) {
self::set($key, $val ? '1' : '0');
}
}
foreach (self::$defaultConfig['otherParams'] as $key => $val) {
if (self::get($key) === false) {
self::set($key, $val);
}
}
self::set('encKey', substr(wfUtils::bigRandomHex(), 0, 16));
if (self::get('maxMem', false) === false) {
self::set('maxMem', '256');
}
if (self::get('other_scanOutside', false) === false) {
self::set('other_scanOutside', 0);
}
if (self::get('email_summary_enabled')) {
wfActivityReport::scheduleCronJob();
} else {
wfActivityReport::disableCronJob();
}
}
示例2: setDefaults
public static function setDefaults()
{
foreach (self::$securityLevels[2]['checkboxes'] as $key => $val) {
if (self::get($key) === false) {
self::set($key, $val ? '1' : '0');
}
}
foreach (self::$securityLevels[2]['otherParams'] as $key => $val) {
if (self::get($key) === false) {
self::set($key, $val);
}
}
self::set('encKey', substr(wfUtils::bigRandomHex(), 0, 16));
if (self::get('maxMem', false) === false) {
self::set('maxMem', '256');
}
if (self::get('other_scanOutside', false) === false) {
self::set('other_scanOutside', 0);
}
}
示例3: veryFirstAction
public static function veryFirstAction()
{
/** @var wpdb $wpdb ; */
global $wpdb;
$wfFunc = isset($_GET['_wfsf']) ? @$_GET['_wfsf'] : false;
if ($wfFunc == 'unlockEmail') {
if (!wp_verify_nonce(@$_POST['nonce'], 'wf-form')) {
die("Sorry but your browser sent an invalid security token when trying to use this form.");
}
$numTries = get_transient('wordfenceUnlockTries');
if ($numTries > 10) {
echo "<html><body><h1>Please wait 3 minutes and try again</h1><p>You have used this form too much. Please wait 3 minutes and try again.</p></body></html>";
exit;
}
if (!$numTries) {
$numTries = 1;
} else {
$numTries = $numTries + 1;
}
set_transient('wordfenceUnlockTries', $numTries, 180);
$email = trim($_POST['email']);
global $wpdb;
$ws = $wpdb->get_results($wpdb->prepare("SELECT ID, user_login FROM {$wpdb->users} WHERE user_email = %s", $email));
foreach ($ws as $user) {
$userDat = get_userdata($user->ID);
if (wfUtils::isAdmin($userDat)) {
if ($email == $userDat->user_email) {
$found = true;
break;
}
}
}
if (!$found) {
foreach (wfConfig::getAlertEmails() as $alertEmail) {
if ($alertEmail == $email) {
$found = true;
break;
}
}
}
if ($found) {
$key = wfUtils::bigRandomHex();
$IP = wfUtils::getIP();
set_transient('wfunlock_' . $key, $IP, 1800);
$content = wfUtils::tmpl('email_unlockRequest.php', array('siteName' => get_bloginfo('name', 'raw'), 'siteURL' => wfUtils::getSiteBaseURL(), 'unlockHref' => wfUtils::getSiteBaseURL() . '?_wfsf=unlockAccess&key=' . $key, 'key' => $key, 'IP' => $IP));
wp_mail($email, "Unlock email requested", $content, "Content-Type: text/html");
}
echo "<html><body><h1>Your request was received</h1><p>We received a request to email \"" . wp_kses($email, array()) . "\" instructions to unlock their access. If that is the email address of a site administrator or someone on the Wordfence alert list, then they have been emailed instructions on how to regain access to this sytem. The instructions we sent will expire 30 minutes from now.</body></html>";
exit;
} else {
if ($wfFunc == 'unlockAccess') {
if (!preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', get_transient('wfunlock_' . $_GET['key']))) {
echo "Invalid key provided for authentication.";
exit;
}
/* You can enable this for paranoid security leve.
if(get_transient('wfunlock_' . $_GET['key']) != wfUtils::getIP()){
echo "You can only use this link from the IP address you used to generate the unlock email.";
exit();
}
*/
$wfLog = new wfLog(wfConfig::get('apiKey'), wfUtils::getWPVersion());
if ($_GET['func'] == 'unlockMyIP') {
$wfLog->unblockIP(wfUtils::getIP());
$wfLog->unlockOutIP(wfUtils::getIP());
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
header('Location: ' . wp_login_url());
exit;
} else {
if ($_GET['func'] == 'unlockAllIPs') {
wordfence::status(1, 'info', "Request received via unlock email link to unblock all IP's.");
$wfLog->unblockAllIPs();
$wfLog->unlockAllIPs();
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
header('Location: ' . wp_login_url());
exit;
} else {
if ($_GET['func'] == 'disableRules') {
wfConfig::set('firewallEnabled', 0);
wfConfig::set('loginSecurityEnabled', 0);
wordfence::status(1, 'info', "Request received via unlock email link to unblock all IP's via disabling firewall rules.");
$wfLog->unblockAllIPs();
$wfLog->unlockAllIPs();
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
wfConfig::set('cbl_countries', '');
//unblock all countries
header('Location: ' . wp_login_url());
exit;
} else {
echo "Invalid function specified. Please check the link we emailed you and make sure it was not cut-off by your email reader.";
exit;
}
}
}
}
}
// Sync the WAF data with the database.
//.........这里部分代码省略.........
示例4: startScan
public static function startScan($isFork = false)
{
if (!$isFork) {
//beginning of scan
wfConfig::inc('totalScansRun');
wfConfig::set('wfKillRequested', 0);
wordfence::status(4, 'info', "Entering start scan routine");
if (wfUtils::isScanRunning()) {
return "A scan is already running. Use the kill link if you would like to terminate the current scan.";
}
}
$timeout = self::getMaxExecutionTime() - 2;
//2 seconds shorter than max execution time which ensures that only 2 HTTP processes are ever occupied
$testURL = admin_url('admin-ajax.php?action=wordfence_testAjax');
if (!wfConfig::get('startScansRemotely', false)) {
$testResult = wp_remote_post($testURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => array()));
wordfence::status(4, 'info', "Test result of scan start URL fetch: " . var_export($testResult, true));
}
$cronKey = wfUtils::bigRandomHex();
wfConfig::set('currentCronKey', time() . ',' . $cronKey);
if (!wfConfig::get('startScansRemotely', false) && !is_wp_error($testResult) && is_array($testResult) && strstr($testResult['body'], 'WFSCANTESTOK') !== false) {
//ajax requests can be sent by the server to itself
$cronURL = 'admin-ajax.php?action=wordfence_doScan&isFork=' . ($isFork ? '1' : '0') . '&cronKey=' . $cronKey;
$cronURL = admin_url($cronURL);
$headers = array();
wordfence::status(4, 'info', "Starting cron with normal ajax at URL {$cronURL}");
wp_remote_get($cronURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => $headers));
wordfence::status(4, 'info', "Scan process ended after forking.");
} else {
$cronURL = admin_url('admin-ajax.php');
$cronURL = preg_replace('/^(https?:\\/\\/)/i', '$1noc1.wordfence.com/scanp/', $cronURL);
$cronURL .= '?action=wordfence_doScan&isFork=' . ($isFork ? '1' : '0') . '&cronKey=' . $cronKey;
$headers = array();
wordfence::status(4, 'info', "Starting cron via proxy at URL {$cronURL}");
wp_remote_get($cronURL, array('timeout' => $timeout, 'blocking' => true, 'sslverify' => false, 'headers' => $headers));
wordfence::status(4, 'info', "Scan process ended after forking.");
}
return false;
//No error
}
示例5: veryFirstAction
public static function veryFirstAction()
{
$wfFunc = isset($_GET['_wfsf']) ? @$_GET['_wfsf'] : false;
if ($wfFunc == 'unlockEmail') {
if (!wp_verify_nonce(@$_POST['nonce'], 'wf-form')) {
die("Sorry but your browser sent an invalid security token when trying to use this form.");
}
$numTries = get_transient('wordfenceUnlockTries');
if ($numTries > 10) {
echo "<html><body><h1>Please wait 3 minutes and try again</h1><p>You have used this form too much. Please wait 3 minutes and try again.</p></body></html>";
exit;
}
if (!$numTries) {
$numTries = 1;
} else {
$numTries = $numTries + 1;
}
set_transient('wordfenceUnlockTries', $numTries, 180);
$email = trim($_POST['email']);
global $wpdb;
$ws = $wpdb->get_results("SELECT ID, user_login FROM {$wpdb->users}");
foreach ($ws as $user) {
$userDat = get_userdata($user->ID);
if (wfUtils::isAdmin($userDat)) {
if ($email == $userDat->user_email) {
$found = true;
break;
}
}
}
if (!$found) {
foreach (wfConfig::getAlertEmails() as $alertEmail) {
if ($alertEmail == $email) {
$found = true;
break;
}
}
}
if ($found) {
$key = wfUtils::bigRandomHex();
$IP = wfUtils::getIP();
set_transient('wfunlock_' . $key, $IP, 1800);
$content = wfUtils::tmpl('email_unlockRequest.php', array('siteName' => get_bloginfo('name', 'raw'), 'siteURL' => wfUtils::getSiteBaseURL(), 'unlockHref' => wfUtils::getSiteBaseURL() . '?_wfsf=unlockAccess&key=' . $key, 'key' => $key, 'IP' => $IP));
wp_mail($email, "Unlock email requested", $content, "Content-Type: text/html");
}
echo "<html><body><h1>Your request was received</h1><p>We received a request to email \"" . wp_kses($email, array()) . "\" instructions to unlock their access. If that is the email address of a site administrator or someone on the Wordfence alert list, then they have been emailed instructions on how to regain access to this sytem. The instructions we sent will expire 30 minutes from now.</body></html>";
exit;
} else {
if ($wfFunc == 'unlockAccess') {
if (!preg_match('/^\\d+\\.\\d+\\.\\d+\\.\\d+$/', get_transient('wfunlock_' . $_GET['key']))) {
echo "Invalid key provided for authentication.";
exit;
}
/* You can enable this for paranoid security leve.
if(get_transient('wfunlock_' . $_GET['key']) != wfUtils::getIP()){
echo "You can only use this link from the IP address you used to generate the unlock email.";
exit();
}
*/
$wfLog = new wfLog(wfConfig::get('apiKey'), wfUtils::getWPVersion());
if ($_GET['func'] == 'unlockMyIP') {
$wfLog->unblockIP(wfUtils::getIP());
$wfLog->unlockOutIP(wfUtils::getIP());
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
header('Location: ' . wp_login_url());
exit;
} else {
if ($_GET['func'] == 'unlockAllIPs') {
wordfence::status(1, 'info', "Request received via unlock email link to unblock all IP's.");
$wfLog->unblockAllIPs();
$wfLog->unlockAllIPs();
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
header('Location: ' . wp_login_url());
exit;
} else {
if ($_GET['func'] == 'disableRules') {
wfConfig::set('firewallEnabled', 0);
wfConfig::set('loginSecurityEnabled', 0);
wordfence::status(1, 'info', "Request received via unlock email link to unblock all IP's via disabling firewall rules.");
$wfLog->unblockAllIPs();
$wfLog->unlockAllIPs();
delete_transient('wflginfl_' . bin2hex(wfUtils::inet_pton(wfUtils::getIP())));
//Reset login failure counter
wfConfig::set('cbl_countries', '');
//unblock all countries
header('Location: ' . wp_login_url());
exit;
} else {
echo "Invalid function specified. Please check the link we emailed you and make sure it was not cut-off by your email reader.";
exit;
}
}
}
}
}
if (wfConfig::get('firewallEnabled')) {
$wfLog = self::getLog();
$wfLog->firewallBadIPs();
//.........这里部分代码省略.........