You are here

public function HtmlAssetInliner::remote_file_exists in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()
  2. 8 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()
  3. 8.2 src/Context/HtmlAssetInliner.php \Drupal\tmgmt_smartling\Context\HtmlAssetInliner::remote_file_exists()

Checks whether or not remote file exists

Parameters

$url:

$proj_settings:

int $connection_timeout:

int $timeout:

Return value

bool

File

src/Context/HtmlAssetInliner.php, line 117

Class

HtmlAssetInliner

Namespace

Drupal\tmgmt_smartling\Context

Code

public function remote_file_exists($url, $proj_settings, $connection_timeout = 500, $timeout = 5000) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);

  # don't download content
  curl_setopt($ch, CURLOPT_NOBODY, 1);
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $connection_timeout);
  curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout);
  $this
    ->applySettingsToCurl($proj_settings, $ch);
  if (curl_exec($ch) !== FALSE) {
    return TRUE;
  }
  return FALSE;
}