You are here

function aes_config_validate in AES encryption 7

Same name and namespace in other branches
  1. 5 aes.module \aes_config_validate()
  2. 6 aes.module \aes_config_validate()

Validates aes_config form.

File

./aes.admin.inc, line 167
AES encryption module administration settings.

Code

function aes_config_validate($form, &$form_state) {
  if (empty($form_state['values']['aes_implementation'])) {
    form_set_error("aes_implementation", t("AES needs an encryption implementation to function. See the README.txt for instructions on how to install one."));
  }
  if (!empty($form_state['values']['aes_key'])) {
    if ($form_state['values']['aes_key'] !== $form_state['values']['aes_key_c']) {
      form_set_error("aes_key", t("The encryption keys didn't match."));
    }
  }

  // If the storage method is set to File, ensure the file can be opened.
  // for writing
  if ($form_state['values']['aes_key_storage_method'] == "File") {
    $fp = @fopen($form_state['values']['aes_key_path'], "a");
    if ($fp === FALSE) {
      form_set_error("aes_key_path", t("Can't write to the specified location."));
    }
    else {
      fclose($fp);
    }
  }
}