本文整理汇总了PHP中wfUtils::hostNotExcludedFromProxy方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::hostNotExcludedFromProxy方法的具体用法?PHP wfUtils::hostNotExcludedFromProxy怎么用?PHP wfUtils::hostNotExcludedFromProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::hostNotExcludedFromProxy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doCurlTest
function doCurlTest($protocol)
{
if (!function_exists('curl_init')) {
echo "<br /><b style='color: #F00;'>CURL is not installed</b>. Asking your hosting provider to install and enable CURL may improve any connection problems.</b><br />\n";
return;
}
echo "<br /><b>STARTING CURL {$protocol} CONNECTION TEST....</b><br />\n";
global $curlContent;
$curlContent = "";
$curl = curl_init($protocol . '://noc1.wordfence.com/');
if (defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') && wfUtils::hostNotExcludedFromProxy('noc1.wordfence.com')) {
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($curl, CURLOPT_PROXY, WP_PROXY_HOST . ':' . WP_PROXY_PORT);
if (defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD')) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 900);
curl_setopt($curl, CURLOPT_USERAGENT, "Wordfence.com UA " . (defined('WORDFENCE_VERSION') ? WORDFENCE_VERSION : '[Unknown version]'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_WRITEFUNCTION, 'curlWrite');
curl_exec($curl);
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if (strpos($curlContent, 'Your site did not send an API key') !== false) {
echo "Curl connectivity test passed.<br /><br />\n";
} else {
$curlErrorNo = curl_errno($curl);
$curlError = curl_error($curl);
echo "Curl connectivity test failed with response: <pre>{$curlContent}</pre>";
echo "<br />Curl HTTP status: {$httpStatus}<br />Curl error code: {$curlErrorNo}<br />Curl Error: {$curlError}<br /><br />\n";
}
}
示例2: wfsnIsBlocked
private static function wfsnIsBlocked($IP, $type)
{
try {
$curl = curl_init('http://noc3.wordfence.com:9050/hackAttempt/?k=' . wfConfig::get('apiKey') . '&IP=' . wfUtils::inet_aton($IP) . '&t=' . $type);
if (defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') && wfUtils::hostNotExcludedFromProxy('noc3.wordfence.com')) {
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($curl, CURLOPT_PROXY, WP_PROXY_HOST . ':' . WP_PROXY_PORT);
if (defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD')) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
curl_setopt($curl, CURLOPT_USERAGENT, "Wordfence.com UA " . (defined('WORDFENCE_VERSION') ? WORDFENCE_VERSION : '[Unknown version]'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, false);
$result = curl_exec($curl);
if (preg_match('/BLOCKED:(\\d+)/', $result, $matches) && !self::getLog()->isWhitelisted($IP)) {
return $matches[1];
}
return false;
} catch (Exception $err) {
return false;
}
}
示例3: binCall
public function binCall($func, $postData)
{
$url = $this->getAPIURL() . '/v' . WORDFENCE_API_VERSION . '/?' . $this->makeAPIQueryString() . '&action=' . $func;
if (function_exists('curl_init')) {
$curl = curl_init($url);
if (defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') && wfUtils::hostNotExcludedFromProxy($url)) {
error_log("BINCALL PROXY");
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 0);
curl_setopt($curl, CURLOPT_PROXY, WP_PROXY_HOST . ':' . WP_PROXY_PORT);
if (defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD')) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD);
}
}
curl_setopt($curl, CURLOPT_TIMEOUT, 900);
//curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Wordfence");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
if ($postData) {
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else {
curl_setopt($curl, CURLOPT_POSTFIELDS, array());
}
$data = curl_exec($curl);
$httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpStatus != 200) {
$cError = curl_error($curl);
curl_close($curl);
if ($cError) {
throw new Exception("We received an error response when trying to fetch binary data from the Wordfence scanning server. The HTTP status was [{$httpStatus}] with error: {$cError}");
} else {
throw new Exception("We received an error HTTP response when trying to fetch binary data from the Wordfence scanning server: [{$httpStatus}]");
}
}
} else {
$data = $this->fileGet($url, $postData);
if ($data === false) {
$err = error_get_last();
if ($err) {
throw new Exception("We received an error response when trying to fetch binary data from the Wordfence scanning server using file_get_contents: {$err}");
} else {
throw new Exception("We received an error when trying to fetch binary data from the Wordfence scanning server using file_get_contents. There was no message explaining the error.");
}
}
$httpStatus = '200';
}
if (preg_match('/\\{.*errorMsg/', $data)) {
$jdat = @json_decode($data, true);
if (is_array($jdat) && $jdat['errorMsg']) {
throw new Exception($jdat['errorMsg']);
}
}
return array('code' => $httpStatus, 'data' => $data);
}