function restrict_by_ip_user_admin_perm_submit in Restrict Login or Role Access by IP Address 6.2
Hook to the admin_permissions submit function
1 string reference to 'restrict_by_ip_user_admin_perm_submit'
- restrict_by_ip_form_user_admin_perm_alter in ./
restrict_by_ip.module - Hook to the admin_permissions form
File
- ./
restrict_by_ip.module, line 31 - Allows the admin to select which ip addresses role or a user can login from for this site Some of the code below is taken from the cck_ipaddress_module
Code
function restrict_by_ip_user_admin_perm_submit($form, &$form_state) {
$rid = $form_state['values']['rid'];
$role_restrict_by_ip_type = $form_state['values']['restrict_by_ip_type'];
$restrict_by_ip_address = $form_state['values']['restrict_by_ip_address'];
if ($role_restrict_by_ip_type == "1") {
if (db_result(db_query('SELECT rid FROM {restrict_by_ip} WHERE rid = %d', $rid))) {
db_query("UPDATE {restrict_by_ip} SET restrict_by_ip_type = %d, restrict_by_ip_address = '%s' WHERE rid = %d", intval($role_restrict_by_ip_type), t($restrict_by_ip_address), intval($rid));
}
else {
db_query("INSERT INTO {restrict_by_ip} (rid, restrict_by_ip_type, restrict_by_ip_address) VALUES ( %d ,%d, '%s' )", intval($rid), intval($role_restrict_by_ip_type), t($restrict_by_ip_address));
}
}
else {
db_query("DELETE FROM {restrict_by_ip} WHERE rid=%d", intval($rid));
}
}