Skip to content

Commit

Permalink
v.1.0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
findlabnet committed Feb 10, 2023
1 parent 6cf7e3e commit 0c02127
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ip_blocking.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ function ip_blocking_settings_form() {
$form = array();

$form['info'] = array(
'#markup' => '<p>' . t('Additional settings for module') . '</p>',
'#markup' => '<p>' . t('Additional settings') . ':</p>',
);

$form['log_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable logging'),
'#default_value' => config_get('ip_blocking.settings', 'log_enabled'),
'#description' => t('Enable logging for access attempts from blocked IPs'),
'#description' => t('Enable logging of access attempts from blocked IPs and actions of this module.'),
);
$form['return_404'] = array(
'#type' => 'checkbox',
'#title' => t('Return code 404'),
'#default_value' => config_get('ip_blocking.settings', 'return_404'),
'#description' => t('Return 404 (Not Found) status code for visitors from blocked IP instead of default 403 (Access Denied)'),
'#description' => t('Return 404 (Not Found) status code for visitors from blocked IP instead of default 403 (Access Denied).'),
);


Expand Down
2 changes: 1 addition & 1 deletion ip_blocking.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ package = Spam control
backdrop = 1.x
type = module
configure = admin/config/people/ip-blocking
version = 1.0.11
version = 1.0.12
10 changes: 8 additions & 2 deletions ip_blocking.module
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function ip_blocking_get_action_link($ip, $message) {
$action_link = '';
// If the IP is already blocked, display an unblock link or vice versa.
if (ip_is_denied($ip)) {
$action_link .= t('IP blocked') . ' - ';
$action_link .= '<b>' . t('IP @ip blocked', array('@ip' => $ip)) . '</b> - ';
$action = 'unblock';
}
else {
Expand Down Expand Up @@ -273,7 +273,13 @@ function ip_blocking_block_ip($ip, $reason) {
$uid = $user->uid;
$config = config('ip_blocking.settings');
$log_enabled = $config->get('log_enabled');
$reason_dec = 'Request: ' . urldecode($reason);

if (backdrop_strlen($reason) > 250) {
$reason_dec = 'Request: ' . urldecode(substr($reason, 0, 250)) . ' ... ';
}
else {
$reason_dec = 'Request: ' . urldecode($reason);
}

// Insert the record to DB.
db_insert('blocked_ips')
Expand Down

0 comments on commit 0c02127

Please sign in to comment.