You are here

function aes_config_validate in AES encryption 5

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

File

./aes.module, line 124

Code

function aes_config_validate($form, &$form_state) {
  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, check that the file can be openend 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);
    }
  }
}