Shield Security for WordPress - Version 14.1.5

Version Description

Download this release

Release Info

Developer paultgoodchild
Plugin Icon 128x128 Shield Security for WordPress
Version 14.1.5
Comparing to
See all releases

Code changes from version 14.1.3 to 14.1.5

cl.json CHANGED
@@ -148,6 +148,24 @@
148
  "type": "fixed"
149
  }
150
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
  ]
153
  },
148
  "type": "fixed"
149
  }
150
  ]
151
+ },
152
+ {
153
+ "version": "5",
154
+ "released_at": 1647948720,
155
+ "items": [
156
+ {
157
+ "title": "Allow direct searching of request path in Traffic Log.",
158
+ "type": "improve"
159
+ },
160
+ {
161
+ "title": "Provide a more robust database migration for large request log tables.",
162
+ "type": "fixed"
163
+ },
164
+ {
165
+ "title": "Adjust the traffic log database to account for very long request paths.",
166
+ "type": "fixed"
167
+ }
168
+ ]
169
  }
170
  ]
171
  },
config/data.json CHANGED
@@ -77,7 +77,7 @@
77
  },
78
  "path": {
79
  "macro_type": "varchar",
80
- "length": 256,
81
  "comment": "Request Path"
82
  },
83
  "code": {
77
  },
78
  "path": {
79
  "macro_type": "varchar",
80
+ "length": 512,
81
  "comment": "Request Path"
82
  },
83
  "code": {
config/deprecated/comments_filter.php CHANGED
@@ -336,12 +336,6 @@
336
  "ip_address",
337
  "user_agent"
338
  ]
339
- },
340
- {
341
- "key": "enable_antibot_check",
342
- "section": "section_non_ui",
343
- "type": "checkbox",
344
- "default": ""
345
  }
346
  ],
347
  "definitions": {
336
  "ip_address",
337
  "user_agent"
338
  ]
 
 
 
 
 
 
339
  }
340
  ],
341
  "definitions": {
icwp-wpsf.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Shield Security
4
  * Plugin URI: https://shsec.io/2f
5
  * Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
6
- * Version: 14.1.3
7
  * Text Domain: wp-simple-firewall
8
  * Domain Path: /languages
9
  * Author: Shield Security
3
  * Plugin Name: Shield Security
4
  * Plugin URI: https://shsec.io/2f
5
  * Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
6
+ * Version: 14.1.5
7
  * Text Domain: wp-simple-firewall
8
  * Domain Path: /languages
9
  * Author: Shield Security
plugin-spec.php CHANGED
@@ -1,8 +1,8 @@
1
  {
2
  "properties": {
3
- "version": "14.1.3",
4
- "release_timestamp": 1647854124,
5
- "build": "202203.2103",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "human_name": "Shield Security",
@@ -454,6 +454,7 @@
454
  }
455
  ],
456
  "version_upgrades": [
 
457
  "14.1.1",
458
  "11.2.0",
459
  "12.0.0",
1
  {
2
  "properties": {
3
+ "version": "14.1.5",
4
+ "release_timestamp": 1647948720,
5
+ "build": "202203.2201",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "human_name": "Shield Security",
454
  }
455
  ],
456
  "version_upgrades": [
457
+ "14.1.4",
458
  "14.1.1",
459
  "11.2.0",
460
  "12.0.0",
plugin.json CHANGED
@@ -1,8 +1,8 @@
1
  {
2
  "properties": {
3
- "version": "14.1.3",
4
- "release_timestamp": 1647854124,
5
- "build": "202203.2103",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "human_name": "Shield Security",
@@ -454,6 +454,7 @@
454
  }
455
  ],
456
  "version_upgrades": [
 
457
  "14.1.1",
458
  "11.2.0",
459
  "12.0.0",
1
  {
2
  "properties": {
3
+ "version": "14.1.5",
4
+ "release_timestamp": 1647948720,
5
+ "build": "202203.2201",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "human_name": "Shield Security",
454
  }
455
  ],
456
  "version_upgrades": [
457
+ "14.1.4",
458
  "14.1.1",
459
  "11.2.0",
460
  "12.0.0",
readme.txt CHANGED
@@ -8,7 +8,7 @@ Requires at least: 3.7
8
  Requires PHP: 7.0
9
  Recommended PHP: 7.4
10
  Tested up to: 5.9
11
- Stable tag: 14.1.3
12
 
13
  No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
14
 
8
  Requires PHP: 7.0
9
  Recommended PHP: 7.4
10
  Tested up to: 5.9
11
+ Stable tag: 14.1.5
12
 
13
  No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
14
 
resources/js/shield/traffic.js CHANGED
@@ -107,6 +107,8 @@
107
  reqData.type = base.options.type;
108
  reqData.file = base.options.file;
109
  reqData.table_data = data;
 
 
110
  $.post( ajaxurl, reqData, function ( response ) {
111
  if ( response.success ) {
112
  callback( response.data.datatable_data );
@@ -118,7 +120,10 @@
118
  }
119
  alert( msg );
120
  }
121
- } );
 
 
 
122
  },
123
  deferRender: true,
124
  select: {
107
  reqData.type = base.options.type;
108
  reqData.file = base.options.file;
109
  reqData.table_data = data;
110
+
111
+ iCWP_WPSF_BodyOverlay.show();
112
  $.post( ajaxurl, reqData, function ( response ) {
113
  if ( response.success ) {
114
  callback( response.data.datatable_data );
120
  }
121
  alert( msg );
122
  }
123
+ } )
124
+ .always( function () {
125
+ iCWP_WPSF_BodyOverlay.hide();
126
+ } );
127
  },
128
  deferRender: true,
129
  select: {
src/lib/src/Databases/ReqLogs/QueueReqDbRecordMigrator.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare( strict_types=1 );
2
+
3
+ namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\ReqLogs;
4
+
5
+ use FernleafSystems\Wordpress\Plugin\Shield;
6
+ use FernleafSystems\Wordpress\Plugin\Shield\Modules\Data\DB\ReqLogs\Ops as ReqDB;
7
+
8
+ class QueueReqDbRecordMigrator extends Shield\Databases\Utility\QueueDbRecordsMigrator {
9
+
10
+ public function __construct() {
11
+ parent::__construct( 'db_upgrader_reqlogs' );
12
+ }
13
+
14
+ /**
15
+ * @return ReqDB\Select
16
+ */
17
+ protected function getDbSelector() {
18
+ /** @var Shield\Modules\Data\ModCon $mod */
19
+ $mod = $this->getMod();
20
+ /** @var ReqDB\Select $select */
21
+ $select = $mod->getDbH_ReqLogs()->getQuerySelector();
22
+ return $select->addWhere( 'type', '' );
23
+ }
24
+
25
+ protected function processRecord( $record ) {
26
+ /** @var $record Shield\Modules\Data\DB\ReqLogs\Ops\Record */
27
+ /** @var Shield\Modules\Data\ModCon $mod */
28
+ $mod = $this->getMod();
29
+
30
+ $upgradeData = [
31
+ 'type' => ReqDB\Handler::TYPE_HTTP,
32
+ 'path' => $record->path ?? '',
33
+ ];
34
+
35
+ $meta = $record->meta;
36
+
37
+ if ( $meta[ 'ua' ] === 'wpcli' ) {
38
+ $isWpCli = true;
39
+ $upgradeData[ 'type' ] = ReqDB\Handler::TYPE_WPCLI;
40
+ unset( $meta[ 'ua' ] );
41
+ }
42
+ else {
43
+ $isWpCli = false;
44
+ }
45
+
46
+ if ( isset( $meta[ 'code' ] ) && is_numeric( $meta[ 'code' ] ) ) {
47
+ $upgradeData[ 'code' ] = (int)$meta[ 'code' ];
48
+ unset( $meta[ 'code' ] );
49
+ }
50
+
51
+ if ( isset( $meta[ 'offense' ] ) ) {
52
+ $upgradeData[ 'offense' ] = true;
53
+ unset( $meta[ 'offense' ] );
54
+ }
55
+
56
+ if ( !empty( $meta[ 'path' ] ) ) {
57
+ $parts = explode( $isWpCli ? ' ' : '?', (string)$meta[ 'path' ], 2 );
58
+ $upgradeData[ 'path' ] = $parts[ 0 ];
59
+ if ( !empty( $parts[ 1 ] ) ) {
60
+ $meta[ 'query' ] = $parts[ 1 ];
61
+ }
62
+ unset( $meta[ 'path' ] );
63
+ }
64
+
65
+ if ( !empty( $meta[ 'verb' ] ) ) {
66
+ $upgradeData[ 'verb' ] = strtoupper( (string)$meta[ 'verb' ] );
67
+ unset( $meta[ 'verb' ] );
68
+ }
69
+
70
+ if ( !empty( $meta[ 'uid' ] ) ) {
71
+ $upgradeData[ 'uid' ] = (int)$meta[ 'uid' ];
72
+ unset( $meta[ 'uid' ] );
73
+ }
74
+
75
+ if ( ( $meta[ 'ua' ] ?? '' ) === 'wpcli' ) {
76
+ $upgradeData[ 'type' ] = ReqDB\Handler::TYPE_WPCLI;
77
+ unset( $meta[ 'ua' ] );
78
+ }
79
+ elseif ( wp_parse_url( admin_url( 'admin-ajax.php' ), PHP_URL_PATH ) === $upgradeData[ 'path' ] ) {
80
+ $upgradeData[ 'type' ] = ReqDB\Handler::TYPE_AJAX;
81
+ }
82
+ elseif ( wp_parse_url( home_url( 'wp-cron.php' ), PHP_URL_PATH ) === $upgradeData[ 'path' ] ) {
83
+ $upgradeData[ 'type' ] = ReqDB\Handler::TYPE_CRON;
84
+ }
85
+ elseif ( wp_parse_url( home_url( 'xmlrpc.php' ), PHP_URL_PATH ) === $upgradeData[ 'path' ] ) {
86
+ $upgradeData[ 'type' ] = ReqDB\Handler::TYPE_XMLRPC;
87
+ }
88
+
89
+ $record->meta = $meta;
90
+ $upgradeData[ 'meta' ] = $record->getRawData()[ 'meta' ];
91
+
92
+ $success = $mod->getDbH_ReqLogs()
93
+ ->getQueryUpdater()
94
+ ->updateById( $record->id, $upgradeData );
95
+ if ( !$success ) {
96
+ $mod->getDbH_ReqLogs()->getQueryDeleter()->deleteById( $record->id );
97
+ throw new \Exception( 'failed to update' );
98
+ }
99
+
100
+ return $record;
101
+ }
102
+ }
src/lib/src/Databases/Utility/QueueDbRecordsMigrator.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare( strict_types=1 );
2
+
3
+ namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\Utility;
4
+
5
+ use FernleafSystems\Wordpress\Plugin\Core\Databases\Base\Record;
6
+ use FernleafSystems\Wordpress\Plugin\Core\Databases\Base\Select;
7
+ use FernleafSystems\Wordpress\Plugin\Shield;
8
+ use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
9
+ use FernleafSystems\Wordpress\Services\Utilities;
10
+
11
+ abstract class QueueDbRecordsMigrator extends Utilities\BackgroundProcessing\BackgroundProcess {
12
+
13
+ use ModConsumer;
14
+
15
+ const PAGE_SIZE = 100;
16
+
17
+ /**
18
+ * Get batch
19
+ *
20
+ * @return \stdClass Return the first batch from the queue
21
+ */
22
+ protected function get_batch() {
23
+ $batch = new \stdClass();
24
+
25
+ try {
26
+ $batch->key = rand();
27
+ $batch->data = $this->getNextItems();
28
+ }
29
+ catch ( \Exception $e ) {
30
+ // This should never happen as "is_queue_empty()" is called before
31
+ error_log( $e->getMessage() );
32
+ }
33
+
34
+ return $batch;
35
+ }
36
+
37
+ protected function getNextItems() :array {
38
+ $result = $this->getDbSelector()
39
+ ->setLimit( static::PAGE_SIZE )
40
+ ->setPage( 1 )
41
+ ->queryWithResult();
42
+ return is_array( $result ) ? $result : [];
43
+ }
44
+
45
+ /**
46
+ * @return Select|mixed
47
+ */
48
+ abstract protected function getDbSelector();
49
+
50
+ /**
51
+ * Task
52
+ *
53
+ * Override this method to perform any actions required on each
54
+ * queue item. Return the modified item for further processing
55
+ * in the next pass through. Or, return false to remove the
56
+ * item from the queue.
57
+ *
58
+ * @param Record $item Array of records to be processed.
59
+ * @return false
60
+ */
61
+ protected function task( $item ) {
62
+ try {
63
+ $this->processRecord( $item );
64
+ }
65
+ catch ( \Exception $e ) {
66
+ $this->cancel_process();
67
+ }
68
+ return false;
69
+ }
70
+
71
+ /**
72
+ * @param Record $record
73
+ * @return Record
74
+ * @throws \Exception
75
+ */
76
+ abstract protected function processRecord( $record );
77
+
78
+ /**
79
+ * Delete queue
80
+ *
81
+ * @param string $key Key.
82
+ * @return $this
83
+ */
84
+ public function delete( $key ) {
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Is queue empty
90
+ *
91
+ * @return bool
92
+ */
93
+ protected function is_queue_empty() {
94
+ return $this->getDbSelector()->count() === 0;
95
+ }
96
+
97
+ /**
98
+ * Save queue
99
+ *
100
+ * @return $this
101
+ */
102
+ public function save() {
103
+ return $this;
104
+ }
105
+
106
+ public function update( $key, $data ) {
107
+ // Do nothing. Results are stored separately.
108
+ return $this;
109
+ }
110
+ }
src/lib/src/Modules/AuditTrail/Lib/LogTable/BuildAuditTableData.php CHANGED
@@ -17,6 +17,10 @@ class BuildAuditTableData extends BaseBuildTableData {
17
  */
18
  private $log;
19
 
 
 
 
 
20
  protected function getSearchPanesData() :array {
21
  return ( new BuildSearchPanesData() )
22
  ->setMod( $this->getMod() )
@@ -51,7 +55,7 @@ class BuildAuditTableData extends BaseBuildTableData {
51
  /**
52
  * The Wheres need to align with the structure of the Query called from getRecords()
53
  */
54
- protected function buildWheresFromSearchPanes() :array {
55
  $wheres = [];
56
  if ( !empty( $this->table_data[ 'searchPanes' ] ) ) {
57
  foreach ( array_filter( $this->table_data[ 'searchPanes' ] ) as $column => $selected ) {
@@ -81,7 +85,7 @@ class BuildAuditTableData extends BaseBuildTableData {
81
 
82
  protected function countTotalRecordsFiltered() :int {
83
  $loader = $this->getRecordsLoader();
84
- $loader->wheres = $this->buildWheresFromSearchPanes();
85
  return $loader->countAll();
86
  }
87
 
17
  */
18
  private $log;
19
 
20
+ protected function loadLogsWithDirectQuery() :array {
21
+ return $this->loadLogsWithSearch();
22
+ }
23
+
24
  protected function getSearchPanesData() :array {
25
  return ( new BuildSearchPanesData() )
26
  ->setMod( $this->getMod() )
55
  /**
56
  * The Wheres need to align with the structure of the Query called from getRecords()
57
  */
58
+ protected function buildWheresFromSearchParams() :array {
59
  $wheres = [];
60
  if ( !empty( $this->table_data[ 'searchPanes' ] ) ) {
61
  foreach ( array_filter( $this->table_data[ 'searchPanes' ] ) as $column => $selected ) {
85
 
86
  protected function countTotalRecordsFiltered() :int {
87
  $loader = $this->getRecordsLoader();
88
+ $loader->wheres = $this->buildWheresFromSearchParams();
89
  return $loader->countAll();
90
  }
91
 
src/lib/src/Modules/Data/Lib/UpgradeReqLogsTable.php CHANGED
@@ -76,7 +76,9 @@ class UpgradeReqLogsTable extends ExecOnceModConsumer {
76
  if ( !empty( $meta[ 'path' ] ) ) {
77
  $parts = explode( $isWpCli ? ' ' : '?', (string)$meta[ 'path' ], 2 );
78
  $upgradeData[ 'path' ] = $parts[ 0 ];
79
- $meta[ 'query' ] = $parts[ 1 ];
 
 
80
  unset( $meta[ 'path' ] );
81
  }
82
 
76
  if ( !empty( $meta[ 'path' ] ) ) {
77
  $parts = explode( $isWpCli ? ' ' : '?', (string)$meta[ 'path' ], 2 );
78
  $upgradeData[ 'path' ] = $parts[ 0 ];
79
+ if ( !empty( $parts[ 1 ] ) ) {
80
+ $meta[ 'query' ] = $parts[ 1 ];
81
+ }
82
  unset( $meta[ 'path' ] );
83
  }
84
 
src/lib/src/Modules/Data/ModCon.php CHANGED
@@ -2,14 +2,29 @@
2
 
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Data;
4
 
 
5
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\{
6
  AuditTrail,
7
- Data\Lib\UpgradeReqLogsTable,
8
- Traffic};
9
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\BaseShield;
10
 
11
  class ModCon extends BaseShield\ModCon {
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  public function getDbH_IPs() :DB\IPs\Ops\Handler {
14
  return $this->getDbHandler()->loadDbH( 'ips' );
15
  }
@@ -23,10 +38,9 @@ class ModCon extends BaseShield\ModCon {
23
  return $this->getDbHandler()->loadDbH( 'req_logs' );
24
  }
25
 
26
- public function runHourlyCron() {
27
- ( new UpgradeReqLogsTable() )
28
- ->setMod( $this->getCon()->getModule_Data() )
29
- ->execute();
30
  }
31
 
32
  protected function cleanupDatabases() {
@@ -56,7 +70,6 @@ class ModCon extends BaseShield\ModCon {
56
  ) )
57
  )
58
  ->query();
59
-
60
  // TODO 3. Clean User Meta.
61
  }
62
  }
2
 
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Data;
4
 
5
+ use FernleafSystems\Wordpress\Plugin\Shield\Databases\ReqLogs\QueueReqDbRecordMigrator;
6
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\{
7
  AuditTrail,
8
+ Traffic
9
+ };
10
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\BaseShield;
11
 
12
  class ModCon extends BaseShield\ModCon {
13
 
14
+ private $reqDbMigrator;
15
+
16
+ public function onWpLoaded() {
17
+ parent::onWpLoaded();
18
+ $this->getReqDbMigrator();
19
+ }
20
+
21
+ public function getReqDbMigrator() :QueueReqDbRecordMigrator {
22
+ if ( !isset( $this->reqDbMigrator ) ) {
23
+ $this->reqDbMigrator = ( new QueueReqDbRecordMigrator() )->setMod( $this );
24
+ }
25
+ return $this->reqDbMigrator;
26
+ }
27
+
28
  public function getDbH_IPs() :DB\IPs\Ops\Handler {
29
  return $this->getDbHandler()->loadDbH( 'ips' );
30
  }
38
  return $this->getDbHandler()->loadDbH( 'req_logs' );
39
  }
40
 
41
+ public function runDailyCron() {
42
+ parent::runDailyCron();
43
+ $this->getReqDbMigrator()->dispatch();
 
44
  }
45
 
46
  protected function cleanupDatabases() {
70
  ) )
71
  )
72
  ->query();
 
73
  // TODO 3. Clean User Meta.
74
  }
75
  }
src/lib/src/Modules/Data/Upgrade.php CHANGED
@@ -3,13 +3,18 @@
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Data;
4
 
5
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Base;
6
- use FernleafSystems\Wordpress\Plugin\Shield\Modules\Data\Lib\UpgradeReqLogsTable;
7
 
8
  class Upgrade extends Base\Upgrade {
9
 
10
- protected function upgrade_1411() {
11
- ( new UpgradeReqLogsTable() )
12
- ->setMod( $this->getMod() )
13
- ->execute();
 
 
 
 
 
14
  }
15
  }
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Data;
4
 
5
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Base;
6
+ use FernleafSystems\Wordpress\Services\Services;
7
 
8
  class Upgrade extends Base\Upgrade {
9
 
10
+ public function upgrade_1414() {
11
+ /** @var ModCon $mod */
12
+ $mod = $this->getMod();
13
+ $schema = $mod->getDbH_ReqLogs()->getTableSchema();
14
+ $res = Services::WpDb()->doSql( sprintf( 'ALTER TABLE `%s` MODIFY COLUMN %s %s;',
15
+ $schema->table,
16
+ 'path',
17
+ $schema->enumerateColumns()[ 'path' ]
18
+ ) );
19
  }
20
  }
src/lib/src/Modules/HackGuard/Rest/Request/Results/GetAll.php CHANGED
@@ -38,7 +38,8 @@ class GetAll extends Base {
38
  'attempt_repair_at',
39
  'item_repaired_at',
40
  'item_deleted_at',
41
- 'scanresult_id'
 
42
  ] )
43
  )
44
  );
38
  'attempt_repair_at',
39
  'item_repaired_at',
40
  'item_deleted_at',
41
+ 'item_id',
42
+ 'item_type'
43
  ] )
44
  )
45
  );
src/lib/src/Modules/Traffic/AjaxHandler.php CHANGED
@@ -3,7 +3,6 @@
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Traffic;
4
 
5
  use FernleafSystems\Wordpress\Plugin\Shield;
6
- use FernleafSystems\Wordpress\Plugin\Shield\Modules\Data\Lib\UpgradeReqLogsTable;
7
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Traffic\Lib\TrafficTable\BuildTrafficTableData;
8
  use FernleafSystems\Wordpress\Services\Services;
9
 
@@ -44,10 +43,6 @@ class AjaxHandler extends Shield\Modules\BaseShield\AjaxHandler {
44
  }
45
 
46
  private function retrieveTableData() :array {
47
- ( new UpgradeReqLogsTable() )
48
- ->setMod( $this->getCon()->getModule_Data() )
49
- ->execute();
50
-
51
  $builder = ( new BuildTrafficTableData() )->setMod( $this->getMod() );
52
  $builder->table_data = Services::Request()->post( 'table_data', [] );
53
  return [
3
  namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Traffic;
4
 
5
  use FernleafSystems\Wordpress\Plugin\Shield;
 
6
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Traffic\Lib\TrafficTable\BuildTrafficTableData;
7
  use FernleafSystems\Wordpress\Services\Services;
8
 
43
  }
44
 
45
  private function retrieveTableData() :array {
 
 
 
 
46
  $builder = ( new BuildTrafficTableData() )->setMod( $this->getMod() );
47
  $builder->table_data = Services::Request()->post( 'table_data', [] );
48
  return [
src/lib/src/Modules/Traffic/Lib/TrafficTable/BuildSearchPanesData.php CHANGED
@@ -11,6 +11,8 @@ class BuildSearchPanesData {
11
 
12
  use ModConsumer;
13
 
 
 
14
  public function build() :array {
15
  return [
16
  'options' => [
@@ -22,19 +24,27 @@ class BuildSearchPanesData {
22
  ];
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  private function buildForCodes() :array {
26
  return array_values( array_filter( array_map(
27
- function ( $result ) {
28
- $code = $result[ 'code' ] ?? null;
29
- if ( !empty( $code ) ) {
30
- $code = [
31
- 'label' => $code,
32
- 'value' => $code,
33
- ];
34
  }
35
- return $code;
 
 
 
36
  },
37
- $this->runQuery( 'code as code', false )
38
  ) ) );
39
  }
40
 
@@ -53,17 +63,16 @@ class BuildSearchPanesData {
53
 
54
  private function buildForType() :array {
55
  return array_values( array_filter( array_map(
56
- function ( $result ) {
57
- $type = $result[ 'type' ] ?? null;
58
- if ( !empty( $type ) ) {
59
- $type = [
60
- 'label' => Handler::GetTypeName( $type ),
61
- 'value' => $type,
62
- ];
63
  }
64
- return $type;
 
 
 
65
  },
66
- $this->runQuery( 'type as type', false )
67
  ) ) );
68
  }
69
 
@@ -99,4 +108,19 @@ class BuildSearchPanesData {
99
  );
100
  return is_array( $results ) ? $results : [];
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
11
 
12
  use ModConsumer;
13
 
14
+ private $distinctQueryResult = null;
15
+
16
  public function build() :array {
17
  return [
18
  'options' => [
24
  ];
25
  }
26
 
27
+ protected function getDistinctQueryResult() :array {
28
+ if ( is_null( $this->distinctQueryResult ) ) {
29
+ $this->distinctQueryResult = array_map( function ( $raw ) {
30
+ return explode( ',', $raw );
31
+ }, $this->compositeDistinctQuery( [ 'type', 'code' ] ) );
32
+ }
33
+ return $this->distinctQueryResult;
34
+ }
35
+
36
  private function buildForCodes() :array {
37
  return array_values( array_filter( array_map(
38
+ function ( $code ) {
39
+ if ( empty( $code ) ) {
40
+ return null;
 
 
 
 
41
  }
42
+ return [
43
+ 'label' => $code,
44
+ 'value' => $code,
45
+ ];
46
  },
47
+ $this->getDistinctQueryResult()[ 'code' ] ?? []
48
  ) ) );
49
  }
50
 
63
 
64
  private function buildForType() :array {
65
  return array_values( array_filter( array_map(
66
+ function ( $type ) {
67
+ if ( empty( $type ) ) {
68
+ return null;
 
 
 
 
69
  }
70
+ return [
71
+ 'label' => Handler::GetTypeName( $type ),
72
+ 'value' => $type,
73
+ ];
74
  },
75
+ $this->getDistinctQueryResult()[ 'type' ] ?? []
76
  ) ) );
77
  }
78
 
108
  );
109
  return is_array( $results ) ? $results : [];
110
  }
111
+
112
+ /**
113
+ * https://stackoverflow.com/questions/12188027/mysql-select-distinct-multiple-columns#answer-12188117
114
+ */
115
+ private function compositeDistinctQuery( array $columns ) :array {
116
+ /** @var ModCon $mod */
117
+ $mod = $this->getMod();
118
+ $results = Services::WpDb()->selectCustom( sprintf( 'SELECT %s',
119
+ implode( ', ', array_map( function ( $col ) use ( $mod ) {
120
+ return sprintf( '(SELECT group_concat(DISTINCT %s) FROM %s) as %s',
121
+ $col, $mod->getDbH_ReqLogs()->getTableSchema()->table, $col );
122
+ }, $columns ) ) )
123
+ );
124
+ return empty( $results ) ? [] : $results[ 0 ];
125
+ }
126
  }
src/lib/src/Modules/Traffic/Lib/TrafficTable/BuildTrafficTableData.php CHANGED
@@ -32,6 +32,10 @@ class BuildTrafficTableData extends BaseBuildTableData {
32
 
33
  private $ipInfo = [];
34
 
 
 
 
 
35
  protected function getSearchPanesData() :array {
36
  return ( new BuildSearchPanesData() )
37
  ->setMod( $this->getCon()->getModule_Data() )
@@ -94,14 +98,14 @@ class BuildTrafficTableData extends BaseBuildTableData {
94
 
95
  protected function countTotalRecordsFiltered() :int {
96
  $loader = $this->getRecordsLoader();
97
- $loader->wheres = $this->buildWheresFromSearchPanes();
98
  return $loader->countAll();
99
  }
100
 
101
  /**
102
  * The Wheres need to align with the structure of the Query called from getRecords()
103
  */
104
- protected function buildWheresFromSearchPanes() :array {
105
  $wheres = [];
106
  if ( !empty( $this->table_data[ 'searchPanes' ] ) ) {
107
  foreach ( array_filter( $this->table_data[ 'searchPanes' ] ) as $column => $selected ) {
@@ -119,6 +123,9 @@ class BuildTrafficTableData extends BaseBuildTableData {
119
  }
120
  }
121
  }
 
 
 
122
  return $wheres;
123
  }
124
 
32
 
33
  private $ipInfo = [];
34
 
35
+ protected function loadLogsWithSearch() :array {
36
+ return $this->loadLogsWithDirectQuery();
37
+ }
38
+
39
  protected function getSearchPanesData() :array {
40
  return ( new BuildSearchPanesData() )
41
  ->setMod( $this->getCon()->getModule_Data() )
98
 
99
  protected function countTotalRecordsFiltered() :int {
100
  $loader = $this->getRecordsLoader();
101
+ $loader->wheres = $this->buildWheresFromSearchParams();
102
  return $loader->countAll();
103
  }
104
 
105
  /**
106
  * The Wheres need to align with the structure of the Query called from getRecords()
107
  */
108
+ protected function buildWheresFromSearchParams() :array {
109
  $wheres = [];
110
  if ( !empty( $this->table_data[ 'searchPanes' ] ) ) {
111
  foreach ( array_filter( $this->table_data[ 'searchPanes' ] ) as $column => $selected ) {
123
  }
124
  }
125
  }
126
+ if ( !empty( $this->table_data[ 'search' ][ 'value' ] ) ) {
127
+ $wheres[] = sprintf( "`req`.`path` LIKE '%%%s%%'", esc_sql( $this->table_data[ 'search' ][ 'value' ] ) );
128
+ }
129
  return $wheres;
130
  }
131
 
src/lib/src/Tables/DataTables/LoadData/BaseBuildTableData.php CHANGED
@@ -29,10 +29,25 @@ abstract class BaseBuildTableData extends DynPropertiesClass {
29
  }
30
 
31
  public function loadForLogs() :array {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  $start = (int)$this->table_data[ 'start' ];
33
  $length = (int)$this->table_data[ 'length' ];
34
  $search = (string)$this->table_data[ 'search' ][ 'value' ] ?? '';
35
- $wheres = $this->buildWheresFromSearchPanes();
36
 
37
  $searchableColumns = array_flip( $this->getSearchableColumns() );
38
 
@@ -84,7 +99,7 @@ abstract class BaseBuildTableData extends DynPropertiesClass {
84
  return array_values( $results );
85
  }
86
 
87
- protected function buildWheresFromSearchPanes() :array {
88
  return [];
89
  }
90
 
29
  }
30
 
31
  public function loadForLogs() :array {
32
+ if ( empty( $this->table_data[ 'search' ][ 'value' ] ) ) {
33
+ return $this->loadLogsWithDirectQuery();
34
+ }
35
+ else {
36
+ return $this->loadLogsWithSearch();
37
+ }
38
+ }
39
+
40
+ protected function loadLogsWithDirectQuery() :array {
41
+ return $this->buildTableRowsFromRawLogs(
42
+ $this->getRecords( $this->buildWheresFromSearchParams(), (int)$this->table_data[ 'start' ], (int)$this->table_data[ 'length' ] )
43
+ );
44
+ }
45
+
46
+ protected function loadLogsWithSearch() :array {
47
  $start = (int)$this->table_data[ 'start' ];
48
  $length = (int)$this->table_data[ 'length' ];
49
  $search = (string)$this->table_data[ 'search' ][ 'value' ] ?? '';
50
+ $wheres = $this->buildWheresFromSearchParams();
51
 
52
  $searchableColumns = array_flip( $this->getSearchableColumns() );
53
 
99
  return array_values( $results );
100
  }
101
 
102
+ protected function buildWheresFromSearchParams() :array {
103
  return [];
104
  }
105
 
src/lib/vendor/composer/autoload_classmap.php CHANGED
@@ -171,6 +171,7 @@ return array(
171
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Insert' => $baseDir . '/src/Databases/Reports/Insert.php',
172
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Select' => $baseDir . '/src/Databases/Reports/Select.php',
173
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Update' => $baseDir . '/src/Databases/Reports/Update.php',
 
174
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Common' => $baseDir . '/src/Databases/ScanQueue/Common.php',
175
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Delete' => $baseDir . '/src/Databases/ScanQueue/Delete.php',
176
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\EntryVO' => $baseDir . '/src/Databases/ScanQueue/EntryVO.php',
@@ -191,6 +192,7 @@ return array(
191
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Insert' => $baseDir . '/src/Databases/Session/Insert.php',
192
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Select' => $baseDir . '/src/Databases/Session/Select.php',
193
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Update' => $baseDir . '/src/Databases/Session/Update.php',
 
194
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Helpers\\QuickAccess' => $baseDir . '/src/Helpers/QuickAccess.php',
195
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => $baseDir . '/src/License/EddLicenseVO.php',
196
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Logging\\Processors\\BaseMetaProcessor' => $baseDir . '/src/Logging/Processors/BaseMetaProcessor.php',
171
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Insert' => $baseDir . '/src/Databases/Reports/Insert.php',
172
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Select' => $baseDir . '/src/Databases/Reports/Select.php',
173
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Update' => $baseDir . '/src/Databases/Reports/Update.php',
174
+ 'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ReqLogs\\QueueReqDbRecordMigrator' => $baseDir . '/src/Databases/ReqLogs/QueueReqDbRecordMigrator.php',
175
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Common' => $baseDir . '/src/Databases/ScanQueue/Common.php',
176
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Delete' => $baseDir . '/src/Databases/ScanQueue/Delete.php',
177
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\EntryVO' => $baseDir . '/src/Databases/ScanQueue/EntryVO.php',
192
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Insert' => $baseDir . '/src/Databases/Session/Insert.php',
193
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Select' => $baseDir . '/src/Databases/Session/Select.php',
194
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Update' => $baseDir . '/src/Databases/Session/Update.php',
195
+ 'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Utility\\QueueDbRecordsMigrator' => $baseDir . '/src/Databases/Utility/QueueDbRecordsMigrator.php',
196
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Helpers\\QuickAccess' => $baseDir . '/src/Helpers/QuickAccess.php',
197
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => $baseDir . '/src/License/EddLicenseVO.php',
198
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Logging\\Processors\\BaseMetaProcessor' => $baseDir . '/src/Logging/Processors/BaseMetaProcessor.php',
src/lib/vendor/composer/autoload_static.php CHANGED
@@ -358,6 +358,7 @@ class ComposerStaticInit4fc2c6daaffaf40b64b79b6d26830171
358
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Insert' => __DIR__ . '/../..' . '/src/Databases/Reports/Insert.php',
359
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Select' => __DIR__ . '/../..' . '/src/Databases/Reports/Select.php',
360
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Update' => __DIR__ . '/../..' . '/src/Databases/Reports/Update.php',
 
361
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Common' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/Common.php',
362
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Delete' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/Delete.php',
363
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\EntryVO' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/EntryVO.php',
@@ -378,6 +379,7 @@ class ComposerStaticInit4fc2c6daaffaf40b64b79b6d26830171
378
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Insert' => __DIR__ . '/../..' . '/src/Databases/Session/Insert.php',
379
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Select' => __DIR__ . '/../..' . '/src/Databases/Session/Select.php',
380
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Update' => __DIR__ . '/../..' . '/src/Databases/Session/Update.php',
 
381
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Helpers\\QuickAccess' => __DIR__ . '/../..' . '/src/Helpers/QuickAccess.php',
382
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => __DIR__ . '/../..' . '/src/License/EddLicenseVO.php',
383
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Logging\\Processors\\BaseMetaProcessor' => __DIR__ . '/../..' . '/src/Logging/Processors/BaseMetaProcessor.php',
358
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Insert' => __DIR__ . '/../..' . '/src/Databases/Reports/Insert.php',
359
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Select' => __DIR__ . '/../..' . '/src/Databases/Reports/Select.php',
360
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Reports\\Update' => __DIR__ . '/../..' . '/src/Databases/Reports/Update.php',
361
+ 'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ReqLogs\\QueueReqDbRecordMigrator' => __DIR__ . '/../..' . '/src/Databases/ReqLogs/QueueReqDbRecordMigrator.php',
362
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Common' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/Common.php',
363
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\Delete' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/Delete.php',
364
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\ScanQueue\\EntryVO' => __DIR__ . '/../..' . '/src/Databases/ScanQueue/EntryVO.php',
379
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Insert' => __DIR__ . '/../..' . '/src/Databases/Session/Insert.php',
380
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Select' => __DIR__ . '/../..' . '/src/Databases/Session/Select.php',
381
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Session\\Update' => __DIR__ . '/../..' . '/src/Databases/Session/Update.php',
382
+ 'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Utility\\QueueDbRecordsMigrator' => __DIR__ . '/../..' . '/src/Databases/Utility/QueueDbRecordsMigrator.php',
383
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Helpers\\QuickAccess' => __DIR__ . '/../..' . '/src/Helpers/QuickAccess.php',
384
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => __DIR__ . '/../..' . '/src/License/EddLicenseVO.php',
385
  'FernleafSystems\\Wordpress\\Plugin\\Shield\\Logging\\Processors\\BaseMetaProcessor' => __DIR__ . '/../..' . '/src/Logging/Processors/BaseMetaProcessor.php',
src/lib/vendor/fernleafsystems/utilities/src/Data/Adapter/DynProperties.php CHANGED
@@ -6,11 +6,6 @@ trait DynProperties {
6
 
7
  private $raw = [];
8
 
9
- public function isEmpty( string $key ) :bool {
10
- $value = $this->{$key};
11
- return empty( $value );
12
- }
13
-
14
  /**
15
  * @param string $key
16
  * @return mixed
@@ -38,13 +33,6 @@ trait DynProperties {
38
  unset( $this->raw[ $key ] );
39
  }
40
 
41
- /**
42
- * @param string $key
43
- */
44
- public function __empty( string $key ) {
45
- unset( $this->raw[ $key ] );
46
- }
47
-
48
  public function applyFromArray( array $data, array $restrictedKeys = [] ) {
49
  if ( !empty( $restrictedKeys ) ) {
50
  $data = array_intersect_key( $data, array_flip( $restrictedKeys ) );
6
 
7
  private $raw = [];
8
 
 
 
 
 
 
9
  /**
10
  * @param string $key
11
  * @return mixed
33
  unset( $this->raw[ $key ] );
34
  }
35
 
 
 
 
 
 
 
 
36
  public function applyFromArray( array $data, array $restrictedKeys = [] ) {
37
  if ( !empty( $restrictedKeys ) ) {
38
  $data = array_intersect_key( $data, array_flip( $restrictedKeys ) );
src/lib/vendor/fernleafsystems/wordpress-plugin-core/src/Databases/Common/TableReadyCache.php CHANGED
@@ -25,7 +25,10 @@ class TableReadyCache {
25
  }
26
  }
27
 
28
- public function isReady( TableSchema $schema, int $lifetime = self::READY_LIFETIME ) :bool {
 
 
 
29
  return ( Services::Request()->ts() - $lifetime )
30
  < ( $this->getStatus()[ $this->uniqTableID( $schema ) ] ?? 0 );
31
  }
@@ -39,13 +42,13 @@ class TableReadyCache {
39
 
40
  private function getStatus() :array {
41
  if ( !isset( $this->status ) ) {
42
- $this->status = Services::WpGeneral()->getOption( self::DB_STATUS_KEY );
43
- if ( !is_array( $this->status ) ) {
44
- $this->status = [];
45
- }
46
- $this->status = array_filter( $this->status, function ( int $ts ) {
47
- return Services::Request()->ts() - $ts < HOUR_IN_SECONDS;
48
- } );
49
  }
50
  return $this->status;
51
  }
25
  }
26
  }
27
 
28
+ public function isReady( TableSchema $schema ) :bool {
29
+ $lifetime = (int)max( 1,
30
+ apply_filters( 'apto/db/table_ready_cache_lifetime', self::READY_LIFETIME, $schema )
31
+ );
32
  return ( Services::Request()->ts() - $lifetime )
33
  < ( $this->getStatus()[ $this->uniqTableID( $schema ) ] ?? 0 );
34
  }
42
 
43
  private function getStatus() :array {
44
  if ( !isset( $this->status ) ) {
45
+ $status = Services::WpGeneral()->getOption( self::DB_STATUS_KEY );
46
+ $this->status = array_filter(
47
+ is_array( $status ) ? $status : [],
48
+ function ( int $ts ) {
49
+ return ( Services::Request()->ts() - $ts ) < WEEK_IN_SECONDS;
50
+ }
51
+ );
52
  }
53
  return $this->status;
54
  }