function protected_pages_enter_password_validate in Protected Pages 7
Same name and namespace in other branches
- 7.2 protected_pages.inc \protected_pages_enter_password_validate()
Implements hook_validate().
File
- ./
protected_pages.inc, line 57 - Provides page callbacks for enter password page.
Code
function protected_pages_enter_password_validate($form, &$form_state) {
$password = sha1(trim(check_plain($form_state['values']['password'])));
$global_password_setting = variable_get('protected_pages_user_global_password', 'per_page_or_global');
if ($global_password_setting == 'per_page_password') {
$pid = db_select('protected_pages')
->fields('protected_pages', array(
'pid',
))
->condition('password', $password)
->range(0, 1)
->execute()
->fetchField();
if (!$pid) {
form_set_error('password', t('Incorrect password!'));
}
}
elseif ($global_password_setting == 'per_page_or_global') {
$pid = db_select('protected_pages')
->fields('protected_pages', array(
'pid',
))
->condition('password', $password)
->range(0, 1)
->execute()
->fetchField();
$global_password = variable_get('protected_pages_global_password', '');
if (!$pid && $global_password != $password) {
form_set_error('password', t('Incorrect password!'));
}
}
else {
$global_password = variable_get('protected_pages_global_password', '');
if ($global_password != $password) {
form_set_error('password', t('Incorrect password!'));
}
}
}