function uc_credit_settings_form_submit in Ubercart 6.2
Same name and namespace in other branches
- 5 payment/uc_credit/uc_credit.module \uc_credit_settings_form_submit()
- 7.3 payment/uc_credit/uc_credit.admin.inc \uc_credit_settings_form_submit()
Creates the encryption key file if it doesn't already exist.
See also
uc_credit_settings_form()
uc_credit_settings_form_validate()
1 string reference to 'uc_credit_settings_form_submit'
- uc_credit_form_alter in payment/
uc_credit/ uc_credit.module - Implements hook_form_alter().
File
- payment/
uc_credit/ uc_credit.module, line 978 - Defines the credit card payment method and hooks in payment gateways.
Code
function uc_credit_settings_form_submit($form, &$form_state) {
// Check to see if we need to create a key file.
if (isset($form_state['uc_credit']['update_cc_encrypt_dir']) && $form_state['uc_credit']['update_cc_encrypt_dir'] === TRUE) {
$key_path = $form_state['values']['uc_credit_encryption_path'];
$key_file = $key_path . '/' . UC_CREDIT_KEYFILE_NAME;
if (!file_exists($key_file)) {
if (!($file = fopen($key_file, 'wb'))) {
drupal_set_message(t('Credit card encryption key file creation failed for file @file. Check your filepath settings and directory permissions.', array(
'@file' => $key_file,
)), 'error');
watchdog('uc_credit', 'Credit card encryption key file creation failed for file @file. Check your filepath settings and directory permissions.', array(
'@file' => $key_file,
), WATCHDOG_ERROR);
}
else {
// Replacement key generation suggested by Barry Jaspan
// for increased security.
fwrite($file, md5(drupal_get_token(serialize($_REQUEST) . serialize($_SERVER) . time())));
fclose($file);
drupal_set_message(t('Credit card encryption key file generated. Card data will now be encrypted.'));
watchdog('uc_credit', 'Credit card encryption key file generated. Card data will now be encrypted.');
}
}
}
}