You are here

function get_2fa_timestamp in Google Authenticator / 2 Factor Authentication - 2FA 7

1 call to get_2fa_timestamp()
miniorange_2fa_feedback in ./miniorange_2fa_feedback.php

File

./miniorange_2fa_feedback.php, line 247

Code

function get_2fa_timestamp() {
  $url = 'https://login.xecurify.com/moas/rest/mobile/get-timestamp';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_ENCODING, "");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

  // required for https urls
  curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  curl_setopt($ch, CURLOPT_POST, true);
  if (defined('WP_PROXY_HOST') && defined('WP_PROXY_PORT') && defined('WP_PROXY_USERNAME') && defined('WP_PROXY_PASSWORD')) {
    curl_setopt($ch, CURLOPT_PROXY, WP_PROXY_HOST);
    curl_setopt($ch, CURLOPT_PROXYPORT, WP_PROXY_PORT);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_PROXYUSERPWD, WP_PROXY_USERNAME . ':' . WP_PROXY_PASSWORD);
  }
  $content = curl_exec($ch);
  if (curl_errno($ch)) {
    echo 'Error in sending curl Request';
    exit;
  }
  curl_close($ch);
  if (empty($content)) {
    $currentTimeInMillis = round(microtime(true) * 1000);
    $currentTimeInMillis = number_format($currentTimeInMillis, 0, '', '');
  }
  return empty($content) ? $currentTimeInMillis : $content;
}