function Cleantalk::httpPing in Anti Spam by CleanTalk 7.2
Same name and namespace in other branches
- 7.5 src/Cleantalk.php \Cleantalk::httpPing()
- 7 cleantalk.module \Cleantalk::httpPing()
- 7.4 src/Cleantalk.php \Cleantalk::httpPing()
Function to check response time param string
Return value
int
1 call to Cleantalk::httpPing()
- Cleantalk::get_servers_ip in ./
cleantalk.module - Function DNS request
File
- ./
cleantalk.module, line 1112 - Main CleanTalk integration module functions.
Class
- Cleantalk
- Cleantalk class create request
Code
function httpPing($host) {
// Skip localhost ping cause it raise error at fsockopen.
// And return minimun value
if ($host == 'localhost') {
return 0.001;
}
$starttime = microtime(true);
$file = @fsockopen($host, 80, $errno, $errstr, $this->server_timeout);
$stoptime = microtime(true);
$status = 0;
if (!$file) {
$status = -1;
// Site is down
}
else {
fclose($file);
$status = $stoptime - $starttime;
$status = round($status, 4);
}
return $status;
}