drupal_generate_test_ua

Versions
7
drupal_generate_test_ua($prefix)

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

Code

includes/bootstrap.inc, line 1692

<?php
function drupal_generate_test_ua($prefix) {
  global $databases;
  static $key;

  if (!isset($key)) {
    // We use the database credentials to make the HMAC key, since we
    // check the HMAC before the database is initialized. filectime()
    // and fileinode() are not easily determined from remote.
    $filepath = DRUPAL_ROOT . '/includes/bootstrap.inc';
    $key = sha1(serialize($databases) . filectime($filepath) . fileinode($filepath), TRUE);
  }
   // Generate a moderately secure HMAC based on the database credentials.
   $salt = uniqid('', TRUE);
   $check_string = $prefix . ';' . time() . ';' . $salt;
   return  $check_string . ';' . base64_encode(hash_hmac('sha1', $check_string, $key, TRUE));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.