This repository has been archived by the owner on Jan 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.php
84 lines (70 loc) · 2.56 KB
/
scripts.php
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
use Doctrine\DBAL\Schema\Comparator;
return [
/*
* Installation hook
*
*/
'install' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@security_ban') === false) {
$util->createTable('@security_ban', function ($table) {
$table->addColumn('id', 'integer', [
'unsigned' => true,
'length' => 10,
'autoincrement' => true,
]);
$table->addColumn('ip', 'string', ['length' => 255]);
$table->addColumn('status', 'smallint');
$table->addColumn('reason', 'text');
$table->addColumn('jail', 'string', ['length' => 255]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('modified', 'datetime');
$table->setPrimaryKey(['id']);
});
}
if ($util->tableExists('@security_entry') === false) {
$util->createTable('@security_entry', function ($table) {
$table->addColumn('id', 'integer', [
'unsigned' => true,
'length' => 10,
'autoincrement' => true,
]);
$table->addColumn('event', 'string', ['length' => 255]);
$table->addColumn('ip', 'string', ['length' => 255]);
$table->addColumn('referrer', 'string', ['length' => 255]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->setPrimaryKey(['id']);
});
}
},
/*
* Enable hook
*
*/
'enable' => function ($app) {
},
/*
* Uninstall hook
*
*/
'uninstall' => function ($app) {
// remove the tables
$util = $app['db']->getUtility();
if ($util->tableExists('@security_ban')) {
$util->dropTable('@security_ban');
}
if ($util->tableExists('@security_entry')) {
$util->dropTable('@security_entry');
}
// remove the config
$app['config']->remove('spqr/security');
},
/*
* Runs all updates that are newer than the current version.
*
*/
'updates' => [],
];