-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathApplication.php
More file actions
89 lines (79 loc) · 3.13 KB
/
Application.php
File metadata and controls
89 lines (79 loc) · 3.13 KB
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
<?php
/**
* @brief Antispam by Cleantalk Application Class
* @author <a href='https://cleantalk.org'>CleanTalk team</a>
* @copyright (c) 2020 CleanTalk team
* @package Invision Community
* @subpackage Antispam by Cleantalk
* @since 26 Oct 2020
* @version
*/
namespace IPS\antispambycleantalk;
require_once(\IPS\Application::getRootPath().'/applications/antispambycleantalk/sources/autoload.php');
use Cleantalk\ApbctIPS\Helper as CleantalkHelper;
use Cleantalk\ApbctIPS\DB;
use Cleantalk\Common\Firewall\Firewall;
define('APBCT_TBL_FIREWALL_DATA', 'cleantalk_sfw'); // Table with firewall data.
define('APBCT_TBL_FIREWALL_LOG', 'cleantalk_sfw_logs'); // Table with firewall logs.
define('APBCT_TBL_AC_LOG', 'cleantalk_ac_log'); // Table with firewall logs.
define('APBCT_TBL_AC_UA_BL', 'cleantalk_ua_bl'); // Table with User-Agents blacklist.
define('APBCT_TBL_SESSIONS', 'cleantalk_sessions'); // Table with session data.
define('APBCT_SPAMSCAN_LOGS', 'cleantalk_spamscan_logs'); // Table with session data.
define('APBCT_SELECT_LIMIT', 5000); // Select limit for logs.
define('APBCT_WRITE_LIMIT', 5000); // Write limit for firewall data.
/**
* Antispam by Cleantalk Application Class
*/
class _Application extends \IPS\Application
{
public function installOther() {
// Show admin notification about empty key
$coreApp = \IPS\Application::load('core');
if( \version_compare( $coreApp->version, '4.4.0') >= 0 ) {
if( ! \IPS\Settings::i()->ct_access_key ) {
\IPS\core\AdminNotification::send( 'antispambycleantalk', 'Notification', 'keyIsEmpty', true );
}
}
}
static public function apbct_sfw_update($access_key = '') {
if( empty( $access_key ) ){
$access_key = \IPS\Settings::i()->ct_access_key;
if (empty($access_key)) {
return false;
}
}
$firewall = new Firewall(
$access_key,
DB::getInstance(),
APBCT_TBL_FIREWALL_LOG
);
$firewall->setSpecificHelper( new CleantalkHelper() );
$fw_updater = $firewall->getUpdater( APBCT_TBL_FIREWALL_DATA );
$fw_updater->update();
}
static public function apbct_sfw_send_logs($access_key = '') {
if( empty( $access_key ) ){
$access_key = \IPS\Settings::i()->ct_access_key;
if (empty($access_key)) {
return false;
}
}
$firewall = new Firewall( $access_key, DB::getInstance(), APBCT_TBL_FIREWALL_LOG );
$firewall->setSpecificHelper( new CleantalkHelper() );
$result = $firewall->sendLogs();
return true;
}
/**
* @see \IPS\Application::privacyPolicyThirdParties()
*/
public function privacyPolicyThirdParties()
{
return array(
array(
'title' => \IPS\Member::loggedIn()->language()->addToStack('__app_antispambycleantalk'),
'description' => \IPS\Member::loggedIn()->language()->addToStack('antispambycleantalk_privacy_description'),
'privacyUrl' => 'https://cleantalk.org/publicoffer',
)
);
}
}