You are here

function Cleantalk::httpPing in Anti Spam by CleanTalk 8.3

Function to check response time param string

Return value

int

1 call to Cleantalk::httpPing()
Cleantalk::get_servers_ip in src/lib/Cleantalk/Antispam/Cleantalk.php
Function DNS request

File

src/lib/Cleantalk/Antispam/Cleantalk.php, line 659

Class

Cleantalk
Cleantalk class create request

Namespace

Drupal\cleantalk\lib\Cleantalk\Antispam

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;
}