8.5.x bootstrap.inc drupal_generate_test_ua($prefix)
8.0.x bootstrap.inc drupal_generate_test_ua($prefix)
8.1.x bootstrap.inc drupal_generate_test_ua($prefix)
8.2.x bootstrap.inc drupal_generate_test_ua($prefix)
8.3.x bootstrap.inc drupal_generate_test_ua($prefix)
8.4.x bootstrap.inc drupal_generate_test_ua($prefix)
8.6.x bootstrap.inc drupal_generate_test_ua($prefix)
7.x bootstrap.inc drupal_generate_test_ua($prefix)

Generates a user agent string with a HMAC and timestamp for simpletest.

3 calls to drupal_generate_test_ua()
DrupalWebTestCase::curlInitialize in modules/simpletest/drupal_web_test_case.php
Initializes the cURL connection.
drupal_http_request in includes/common.inc
Performs an HTTP request.
SimpleTestFunctionalTest::testUserAgentValidation in modules/simpletest/simpletest.test
Test validation of the User-Agent header we use to perform test requests.

File

includes/bootstrap.inc, line 2847
Functions that need to be loaded on every Drupal request.

Code

function drupal_generate_test_ua($prefix) {
  static $key;
  if (!isset($key)) {

    // We use the salt from settings.php to make the HMAC key, since
    // the database is not yet initialized and we can't access any Drupal variables.
    // The file properties add more entropy not easily accessible to others.
    $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
  }

  // Generate a moderately secure HMAC based on the database credentials.
  $salt = uniqid('', TRUE);
  $check_string = $prefix . ';' . time() . ';' . $salt;
  return $check_string . ';' . drupal_hmac_base64($check_string, $key);
}