-
Notifications
You must be signed in to change notification settings - Fork 2
/
antiscan.install
84 lines (75 loc) · 2.38 KB
/
antiscan.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* @file
* Install, update and uninstall functions for the Antiscan module.
*/
/**
* Implements hook_requirements().
*/
function antiscan_requirements($phase) {
$requirements = array();
$t = get_t();
$config = config('antiscan.settings');
$test_mode = $config->get('test_mode');
if ($phase == 'install') {
$ip_blocking_info = system_get_info('module', 'ip_blocking');
if (empty($ip_blocking_info) || empty($ip_blocking_info['version'])) {
// The module doesn't exist, it's not enabled?
return FALSE;
}
if (version_compare($ip_blocking_info['version'], '1.x-1.0.5', '<')) {
$requirements['version'] = array(
'title' => $t('IP Address Blocking module version'),
'description' => $t('IP Address Blocking module must have version 1.x-1.0.5 or newest.'),
'value' => check_plain($ip_blocking_info['version']),
'severity' => REQUIREMENT_ERROR,
);
}
}
if ($phase == 'runtime') {
if ($test_mode) {
$url = url('admin/config/people/antiscan');
$requirements['antiscan'] = array(
'title' => t('"Test mode" of "Antiscan" module is on'),
'value' => t('Antiscan module "test mode" is on. <a href="@url">Turn off "Test Mode"</a> for the module to work properly.',
array('@url' => $url)),
'severity' => REQUIREMENT_WARNING,
);
}
}
return $requirements;
}
/**
* Add and initialize new variable.
* Set first starting time for reports.
*/
function antiscan_update_1000() {
$config = config('antiscan.settings');
$config->set('abuseipdb_report', 0);
$config->save();
state_set('antiscan_abuseipdb_report_last_date', time());
}
/**
* Add and initialize new variables.
*
*/
function antiscan_update_1001() {
$config = config('antiscan.settings');
$config->set("blocked_ua", "drupalgeddon2\r\nGo-http-client/*\r\nlibwww-perl*\r\npython-requests/*");
$config->set('blocked_referrer', 'semalt.com,buttons-for-website.com,simple-share-buttons.com,simplesharebuttons.com');
$config->save();
}
/**
* Note: next update function will be named antiscan_update_1003 - skip 1002.
*/
/**
* Add and initialize new variables.
*
*/
function antiscan_update_1003() {
$config = config('antiscan.settings');
$config->set('threshold_enabled', 0);
$config->set('threshold_limit', 1);
$config->set('threshold_window', 3600);
$config->save();
}