You are here

function key_provider_file_get_key in Key 7

Same name and namespace in other branches
  1. 7.2 plugins/key_provider/file.inc \key_provider_file_get_key()

Callback function to return a key from a file.

1 call to key_provider_file_get_key()
key_provider_file_status in plugins/key_provider/file.inc
1 string reference to 'key_provider_file_get_key'
file.inc in plugins/key_provider/file.inc

File

plugins/key_provider/file.inc, line 20

Code

function key_provider_file_get_key($settings) {
  if (empty($settings['location']) || empty($settings['provider'])) {
    return NULL;
  }
  $file = $settings['location'];

  // Make sure the file exists and is readable.
  if (!is_file($file) || !is_readable($file)) {
    return NULL;
  }
  switch ($settings['provider']) {
    case 'file_contents':
      $key = file_get_contents($file);
      break;
    case 'md5':
      $key = md5_file($file);
      break;
    default:
      $key = NULL;
  }
  return $key;
}