function cleantalk_settings_form_validate in Anti Spam by CleanTalk 7.5
Same name and namespace in other branches
- 7.4 src/Form/CleantalkSettingsForm.php \cleantalk_settings_form_validate()
File
- src/
Form/ CleantalkSettingsForm.php, line 243 - CleanTalk module admin functions.
Code
function cleantalk_settings_form_validate($form, &$form_state) {
if ($form_state['values']['cleantalk_authkey']) {
$cleantalk_auth_key = trim($form_state['values']['cleantalk_authkey']);
$is_valid = CleantalkHelper::api_method__notice_validate_key($cleantalk_auth_key);
if (isset($is_valid['valid']) && $is_valid['valid'] == 1) {
CleantalkHelper::api_method_send_empty_feedback($cleantalk_auth_key, CLEANTALK_USER_AGENT);
$path_to_cms = preg_replace('/http[s]?:\\/\\//', '', $GLOBALS['base_url'], 1);
$account_status = CleantalkHelper::api_method__notice_paid_till($cleantalk_auth_key, $path_to_cms);
if (empty($account_status['error'])) {
variable_set('cleantalk_api_show_notice', isset($account_status['show_notice']) ? $account_status['show_notice'] : 0);
variable_set('cleantalk_api_renew', isset($account_status['renew']) ? $account_status['renew'] : 0);
variable_set('cleantalk_api_trial', isset($account_status['trial']) ? $account_status['trial'] : 0);
variable_set('cleantalk_api_user_token', isset($account_status['user_token']) ? $account_status['user_token'] : '');
variable_set('cleantalk_api_spam_count', isset($account_status['spam_count']) ? $account_status['spam_count'] : 0);
variable_set('cleantalk_api_moderate_ip', isset($account_status['moderate_ip']) ? $account_status['moderate_ip'] : 0);
variable_set('cleantalk_api_moderate', isset($account_status['moderate']) ? $account_status['moderate'] : 0);
variable_set('cleantalk_api_show_review', isset($account_status['show_review']) ? $account_status['show_review'] : 0);
variable_set('cleantalk_api_service_id', isset($account_status['service_id']) ? $account_status['service_id'] : 0);
variable_set('cleantalk_api_license_trial', isset($account_status['license_trial']) ? $account_status['license_trial'] : 0);
variable_set('cleantalk_api_account_name_ob', isset($account_status['account_name_ob']) ? $account_status['account_name_ob'] : '');
variable_set('cleantalk_api_ip_license', isset($account_status['ip_license']) ? $account_status['ip_license'] : 0);
variable_set('cleantalk_show_renew_banner', variable_get('cleantalk_api_show_notice', 0) && variable_get('cleantalk_api_trial', 0) ? 1 : 0);
}
if ($form_state['values']['cleantalk_sfw'] === 1) {
$sfw = new CleantalkSFW();
$sfw
->sfw_update($cleantalk_auth_key);
$sfw
->send_logs($cleantalk_auth_key);
variable_set('cleantalk_sfw_last_logs_sent', time());
variable_set('cleantalk_sfw_last_updated', time());
}
// Turns off alternative cookies setting if cookies are disabled
if (0 == $form_state['values']['cleantalk_set_cookies']) {
$form_state['values']['cleantalk_alternative_cookies_session'] = 0;
}
}
else {
form_set_error('cleantalk_authkey', t('Access key is not valid.'));
}
}
}