-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.php
108 lines (91 loc) · 3.96 KB
/
install.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
rex_sql_table::get(rex::getTable('pagestats_data'))
->ensureColumn(new rex_sql_column('type', 'varchar(255)'))
->ensureColumn(new rex_sql_column('name', 'varchar(255)'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['type', 'name'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_visits_per_day'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('domain', 'varchar(255)'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['date', 'domain'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_visitors_per_day'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('domain', 'varchar(255)'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['date', 'domain'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_visits_per_url'))
->ensureColumn(new rex_sql_column('hash', 'varchar(255)'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('url', 'varchar(2048)'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['hash'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_urlstatus'))
->ensureColumn(new rex_sql_column('hash', 'varchar(255)'))
->ensureColumn(new rex_sql_column('url', 'varchar(2048)'))
->ensureColumn(new rex_sql_column('status', 'varchar(255)'))
->setPrimaryKey(['hash'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_bot'))
->ensureColumn(new rex_sql_column('name', 'varchar(255)'))
->ensureColumn(new rex_sql_column('category', 'varchar(255)'))
->ensureColumn(new rex_sql_column('producer', 'varchar(255)'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['name', 'category', 'producer'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_hash'))
->ensureColumn(new rex_sql_column('hash', 'varchar(255)'))
->ensureColumn(new rex_sql_column('datetime', 'datetime'))
->setPrimaryKey(['hash'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_referer'))
->removeColumn('id')
->ensureColumn(new rex_sql_column('hash', 'varchar(255)'))
->ensureColumn(new rex_sql_column('referer', 'varchar(2048)'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['hash'])
->ensure();
rex_sql_table::get(rex::getTable('pagestats_sessionstats'))
->ensureColumn(new rex_sql_column('token', 'varchar(255)'))
->ensureColumn(new rex_sql_column('lastpage', 'varchar(255)'))
->ensureColumn(new rex_sql_column('lastvisit', 'datetime'))
->ensureColumn(new rex_sql_column('visitduration', 'int'))
->ensureColumn(new rex_sql_column('pagecount', 'int'))
->setPrimaryKey(['token'])
->ensure();
// media
rex_sql_table::get(rex::getTable('pagestats_media'))
->ensureColumn(new rex_sql_column('url', 'varchar(255)'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['url', 'date'])
->ensure();
// api
rex_sql_table::get(rex::getTable('pagestats_api'))
->ensureColumn(new rex_sql_column('name', 'varchar(255)'))
->ensureColumn(new rex_sql_column('date', 'date'))
->ensureColumn(new rex_sql_column('count', 'int'))
->setPrimaryKey(['name', 'date'])
->ensure();
// ip 2 geo database installation
$today = new DateTimeImmutable();
$dbUrl = "https://download.db-ip.com/free/dbip-country-lite-{$today->format('Y-m')}.mmdb.gz";
try {
$socket = rex_socket::factoryUrl($dbUrl);
$response = $socket->doGet();
if ($response->isOk()) {
$body = $response->getBody();
$body = gzdecode($body);
rex_file::put(rex_path::addonData("statistics", "ip2geo.mmdb"), $body);
return true;
}
return false;
} catch (rex_socket_exception $e) {
rex_logger::logException($e);
return false;
}