Wordfence connectivity tester
DNS lookup for noc1.wordfence.com returns:
Starting wp_remote_post() test
\n";
$cronURL = admin_url('admin-ajax.php');
$cronURL = preg_replace('/^(https?:\/\/)/i', '://noc1.wordfence.com/scanptest/', $cronURL);
$cronURL .= '?action=wordfence_doScan&isFork=0&cronKey=47e9d1fa6a675b5999999333';
$cronURL = $protocol . $cronURL;
$result = wp_remote_post($cronURL, array(
'timeout' => 10, //Must be less than max execution time or more than 2 HTTP children will be occupied by scan
'blocking' => true, //Non-blocking seems to block anyway, so we use blocking
// This causes cURL to throw errors in some versions since WordPress uses its own certificate bundle ('CA certificate set, but certificate verification is disabled')
// 'sslverify' => false,
'headers' => array()
));
if( (! is_wp_error($result)) && $result['response']['code'] == 200 && strpos($result['body'], "scanptestok") !== false){
echo "wp_remote_post() test to noc1.wordfence.com passed!
\n";
} else if(is_wp_error($result)){
echo "wp_remote_post() test to noc1.wordfence.com failed! Response was: " . $result->get_error_message() . "
\n";
} else {
echo "wp_remote_post() test to noc1.wordfence.com failed! Response was: " . $result['response']['code'] . " " . $result['response']['message'] . "
\n";
echo "This likely means that your hosting provider is blocking requests to noc1.wordfence.com or has set up a proxy that is not behaving itself.
\n";
echo "This additional info may help you diagnose the issue. The response headers we received were:
\n";
foreach($result['headers'] as $key => $value){
echo "$key => $value
\n";
}
}
}
function doCurlTest($protocol){
if(! function_exists('curl_init')){
echo "
CURL is not installed. Asking your hosting provider to install and enable CURL may improve any connection problems.
\n";
return;
}
echo "
STARTING CURL $protocol CONNECTION TEST....
\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 a license key') !== false){
echo "Curl connectivity test passed.
\n";
} else {
$curlErrorNo = curl_errno($curl);
$curlError = curl_error($curl);
echo "Curl connectivity test failed with response: $curlContent
";
echo "
Curl HTTP status: $httpStatus
Curl error code: $curlErrorNo
Curl Error: $curlError
\n";
}
}
doCurlTest('http');
doCurlTest('https');
doWPostTest('http');
doWPostTest('https');
?>