Version Description
Current Release = Released: 23rd October, 2018 - Release Notes
(v.2) IMPROVED: Visitor IP address detection
(v.2) IMPROVED: Automatic whitelisting of Manage WP IP addresses
(v.2) IMPROVED: SPAM Comments code enhanced and optimised
(v.2) IMPROVED: IP Whitelisting code enhanced and optimised
(v.2) IMPROVED: Code cleaning and refactoring.
Download this release
Release Info
Developer | paultgoodchild |
Plugin | Shield Security for WordPress |
Version | 6.10.2 |
Comparing to | |
See all releases |
Code changes from version 6.10.1 to 6.10.2
- icwp-plugin-controller.php +1 -1
- icwp-wpsf.php +1 -1
- plugin-spec.php +2 -2
- readme.txt +10 -4
- src/common/icwp-data.php +38 -128
- src/common/icwp-ip.php +14 -6
- src/common/icwp-serviceproviders.php +44 -12
- src/common/icwp-wpfunctions.php +1 -4
- src/common/wp-comments.php +2 -2
- src/config/feature-comments_filter.php +2 -0
- src/config/feature-plugin.php +4 -0
- src/features/audit_trail.php +12 -9
- src/features/comments_filter.php +56 -16
- src/features/insights.php +7 -3
- src/features/ips.php +41 -21
- src/features/plugin.php +16 -11
- src/features/traffic.php +3 -3
- src/features/user_management.php +1 -1
- src/processors/admin_access_restriction.php +1 -3
- src/processors/adminaccess_whitelabel.php +1 -1
- src/processors/audit_trail.php +47 -50
- src/processors/audit_trail_auditor_base.php +1 -1
- src/processors/base.php +4 -0
- src/processors/base_commentsfilter.php +1 -23
- src/processors/basedb.php +10 -69
- src/processors/comments_filter.php +14 -18
- src/processors/commentsfilter_antibotspam.php +128 -200
- src/processors/commentsfilter_googlerecaptcha.php +17 -33
- src/processors/commentsfilter_humanspam.php +22 -29
- src/processors/firewall.php +1 -1
- src/processors/ips.php +168 -283
- src/processors/lockdown.php +1 -2
- src/processors/loginprotect_googleauthenticator.php +1 -1
- src/processors/loginprotect_intent.php +1 -1
- src/processors/plugin_tracking.php +1 -1
- src/processors/statistics.php +7 -5
- src/processors/statistics_tally.php +23 -16
- src/processors/traffic_logger.php +13 -28
- src/processors/user_management.php +3 -4
- src/query/VOs/ICWP_WPSF_AuditTrailEntryVO.php +49 -0
- src/query/VOs/ICWP_WPSF_BaseEntryVO.php +86 -0
- src/query/VOs/ICWP_WPSF_CommentsEntryVO.php +33 -0
- src/query/VOs/ICWP_WPSF_IpsEntryVO.php +64 -0
- src/query/VOs/ICWP_WPSF_NoteVO.php +25 -0
- src/query/VOs/ICWP_WPSF_SessionVO.php +81 -0
- src/query/VOs/ICWP_WPSF_TallyVO.php +14 -0
- src/query/{traffic → VOs}/ICWP_WPSF_TrafficEntryVO.php +0 -0
- src/query/{statistics → VOs}/StatisticsReportingVO.php +0 -0
- src/query/audittrail/ICWP_WPSF_AuditTrailEntryVO.php +0 -67
- src/query/audittrail/count.php +0 -10
- src/query/audittrail/delete.php +4 -4
- src/query/audittrail/insert.php +24 -0
- src/query/audittrail/select.php +24 -12
- src/query/base/count.php +0 -32
- src/query/base/delete.php +4 -4
- src/query/base/insert.php +15 -0
- src/query/base/query.php +19 -1
- src/query/base/select.php +93 -19
- src/query/base/update.php +33 -0
- src/query/comments/delete.php +27 -0
- src/query/comments/insert.php +21 -0
- src/query/comments/select.php +47 -0
- src/query/ips/delete.php +33 -0
- src/query/ips/insert.php +24 -0
- src/query/ips/select.php +53 -0
- src/query/ips/update.php +55 -0
- src/query/notes/ICWP_WPSF_NoteVO.php +0 -67
- src/query/notes/count.php +0 -11
- src/query/notes/delete.php +4 -4
- src/query/notes/select.php +3 -17
- src/query/sessions/ICWP_WPSF_SessionVO.php +0 -115
- src/query/sessions/count.php +0 -20
- src/query/sessions/delete.php +4 -4
- src/query/sessions/select.php +26 -36
- src/query/sessions/update.php +1 -22
- src/query/statistics/ICWP_WPSF_TallyVO.php +0 -18
- src/query/statistics/tally_count.php +0 -10
- src/query/statistics/tally_delete.php +4 -4
- src/query/statistics/tally_insert.php +14 -1
- src/query/statistics/tally_select.php +3 -16
- src/query/statistics/tally_update.php +1 -14
- src/query/traffic/common.php +7 -0
- src/query/traffic/count.php +0 -13
- src/query/traffic/delete.php +4 -4
- src/query/traffic/select.php +3 -19
- src/wizards/plugin.php +2 -2
icwp-plugin-controller.php
CHANGED
@@ -1625,7 +1625,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1625 |
*/
|
1626 |
public function getSessionId( $bSetIfNeeded = true ) {
|
1627 |
if ( empty( self::$sSessionId ) ) {
|
1628 |
-
self::$sSessionId = $this->loadDP()->
|
1629 |
if ( empty( self::$sSessionId ) && $bSetIfNeeded ) {
|
1630 |
self::$sSessionId = md5( uniqid( $this->getPluginPrefix() ) );
|
1631 |
$this->setSessionCookie();
|
1625 |
*/
|
1626 |
public function getSessionId( $bSetIfNeeded = true ) {
|
1627 |
if ( empty( self::$sSessionId ) ) {
|
1628 |
+
self::$sSessionId = $this->loadDP()->cookie( $this->getPluginPrefix(), '' );
|
1629 |
if ( empty( self::$sSessionId ) && $bSetIfNeeded ) {
|
1630 |
self::$sSessionId = md5( uniqid( $this->getPluginPrefix() ) );
|
1631 |
$this->setSessionCookie();
|
icwp-wpsf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://icwp.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
-
* Version: 6.10.
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages/
|
9 |
* Author: One Dollar Plugin
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://icwp.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
+
* Version: 6.10.2
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages/
|
9 |
* Author: One Dollar Plugin
|
plugin-spec.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "6.10.
|
4 |
-
"release_timestamp":
|
5 |
"slug_parent": "icwp",
|
6 |
"slug_plugin": "wpsf",
|
7 |
"human_name": "Shield",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "6.10.2",
|
4 |
+
"release_timestamp": 1540289000,
|
5 |
"slug_parent": "icwp",
|
6 |
"slug_plugin": "wpsf",
|
7 |
"human_name": "Shield",
|
readme.txt
CHANGED
@@ -7,8 +7,8 @@ Tags: security, all in one, scan, firewall, two factor authentication, spam, wor
|
|
7 |
Requires at least: 3.5.0
|
8 |
Requires PHP: 5.2.4
|
9 |
Recommended PHP: 5.4
|
10 |
-
Tested up to:
|
11 |
-
Stable tag: 6.10.
|
12 |
|
13 |
Complete All-In-One Protection for your WordPress sites, that makes Security Easy for Everyone - it doesn't have to be hard anymore.
|
14 |
|
@@ -354,8 +354,14 @@ You will always be able to use Shield Security and its free features in-full.
|
|
354 |
|
355 |
[Go Pro for just $1/month](https://icwp.io/aa).
|
356 |
|
357 |
-
= 6.10.
|
358 |
-
*Released:
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
= 6.10 - Series =
|
361 |
*Released: 15th October, 2018* - [Release Notes](https://icwp.io/dg)
|
7 |
Requires at least: 3.5.0
|
8 |
Requires PHP: 5.2.4
|
9 |
Recommended PHP: 5.4
|
10 |
+
Tested up to: 5.0
|
11 |
+
Stable tag: 6.10.2
|
12 |
|
13 |
Complete All-In-One Protection for your WordPress sites, that makes Security Easy for Everyone - it doesn't have to be hard anymore.
|
14 |
|
354 |
|
355 |
[Go Pro for just $1/month](https://icwp.io/aa).
|
356 |
|
357 |
+
= 6.10.2 - Current Release =
|
358 |
+
*Released: 23rd October, 2018* - [Release Notes](https://icwp.io/dg)
|
359 |
+
|
360 |
+
* **(v.2)** IMPROVED: Visitor IP address detection
|
361 |
+
* **(v.2)** IMPROVED: Automatic whitelisting of Manage WP IP addresses
|
362 |
+
* **(v.2)** IMPROVED: SPAM Comments code enhanced and optimised
|
363 |
+
* **(v.2)** IMPROVED: IP Whitelisting code enhanced and optimised
|
364 |
+
* **(v.2)** IMPROVED: Code cleaning and refactoring.
|
365 |
|
366 |
= 6.10 - Series =
|
367 |
*Released: 15th October, 2018* - [Release Notes](https://icwp.io/dg)
|
src/common/icwp-data.php
CHANGED
@@ -11,14 +11,9 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
11 |
protected static $oInstance = null;
|
12 |
|
13 |
/**
|
14 |
-
* @var
|
15 |
*/
|
16 |
-
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var integer
|
20 |
-
*/
|
21 |
-
protected static $nRequestTime;
|
22 |
|
23 |
/**
|
24 |
* @var array
|
@@ -38,16 +33,6 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
38 |
return self::$oInstance;
|
39 |
}
|
40 |
|
41 |
-
/**
|
42 |
-
* @return int
|
43 |
-
*/
|
44 |
-
public static function GetRequestTime() {
|
45 |
-
if ( empty( self::$nRequestTime ) ) {
|
46 |
-
self::$nRequestTime = time();
|
47 |
-
}
|
48 |
-
return self::$nRequestTime;
|
49 |
-
}
|
50 |
-
|
51 |
/**
|
52 |
* @param array $aA
|
53 |
* @return array
|
@@ -77,23 +62,32 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
77 |
|
78 |
/**
|
79 |
* @param string $sKey
|
80 |
-
* @param
|
81 |
* @param bool $bTrim -automatically trim whitespace
|
82 |
* @return mixed|null
|
83 |
*/
|
84 |
public function cookie( $sKey, $mDefault = null, $bTrim = true ) {
|
85 |
-
$mVal = $this->
|
86 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
/**
|
90 |
* @param string $sKey
|
91 |
* @param null $mDefault
|
92 |
* @param bool $bTrim -automatically trim whitespace
|
93 |
* @return mixed|null
|
94 |
*/
|
95 |
-
public function
|
96 |
-
$mVal = $this->
|
97 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
98 |
}
|
99 |
|
@@ -103,8 +97,8 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
103 |
* @param bool $bTrim -automatically trim whitespace
|
104 |
* @return mixed|null
|
105 |
*/
|
106 |
-
public function
|
107 |
-
$mVal = $this->
|
108 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
109 |
}
|
110 |
|
@@ -115,7 +109,7 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
115 |
* @return mixed|null
|
116 |
*/
|
117 |
public function server( $sKey, $mDefault = null, $bTrim = true ) {
|
118 |
-
$mVal = $this->
|
119 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
120 |
}
|
121 |
|
@@ -131,7 +125,7 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
131 |
if ( is_null( $mVal ) ) {
|
132 |
$mVal = $this->query( $sKey, null, $bTrim );
|
133 |
if ( is_null( $mVal && $bIncludeCookie ) ) {
|
134 |
-
$mVal =
|
135 |
}
|
136 |
}
|
137 |
return is_null( $mVal ) ? $mDefault : ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
@@ -149,14 +143,14 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
149 |
* @return string
|
150 |
*/
|
151 |
public function getRequestUri() {
|
152 |
-
return $this->
|
153 |
}
|
154 |
|
155 |
/**
|
156 |
* @return string
|
157 |
*/
|
158 |
public function getUserAgent() {
|
159 |
-
return $this->
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -332,7 +326,7 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
332 |
* @return string
|
333 |
*/
|
334 |
public function getRequestMethod() {
|
335 |
-
$sRequestMethod =
|
336 |
return ( empty( $sRequestMethod ) ? 'get' : strtolower( $sRequestMethod ) );
|
337 |
}
|
338 |
|
@@ -344,11 +338,12 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
344 |
}
|
345 |
|
346 |
/**
|
|
|
347 |
* Taken from http://www.phacks.net/detecting-search-engine-bot-and-web-spiders/
|
348 |
*/
|
349 |
-
public
|
350 |
|
351 |
-
$sUserAgent =
|
352 |
if ( empty( $sUserAgent ) ) {
|
353 |
return false;
|
354 |
}
|
@@ -366,7 +361,7 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
366 |
* @param boolean $bIgnoreAmb
|
367 |
* @return string
|
368 |
*/
|
369 |
-
|
370 |
$aChars = array( 'abcdefghijkmnopqrstuvwxyz' );
|
371 |
|
372 |
if ( $nStrength & 2 ) {
|
@@ -396,114 +391,27 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
396 |
/**
|
397 |
* @return string
|
398 |
*/
|
399 |
-
|
400 |
$sAtoZ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
401 |
-
$
|
402 |
-
return $sAtoZ[ $nRandomInt ];
|
403 |
}
|
404 |
|
405 |
/**
|
406 |
* @return string|null
|
407 |
*/
|
408 |
-
|
409 |
-
$sScriptName =
|
410 |
-
return !empty( $sScriptName ) ? $sScriptName :
|
411 |
-
}
|
412 |
-
|
413 |
-
/**
|
414 |
-
* @return bool
|
415 |
-
*/
|
416 |
-
static public function GetUseFilterInput() {
|
417 |
-
return self::$bUseFilterInput && function_exists( 'filter_input' );
|
418 |
-
}
|
419 |
-
|
420 |
-
/**
|
421 |
-
* @param array $aArray
|
422 |
-
* @param string $sKey The array key to fetch
|
423 |
-
* @param mixed $mDefault
|
424 |
-
* @return mixed|null
|
425 |
-
*/
|
426 |
-
public static function ArrayFetch( &$aArray, $sKey, $mDefault = null ) {
|
427 |
-
if ( !isset( $aArray[ $sKey ] ) ) {
|
428 |
-
return $mDefault;
|
429 |
-
}
|
430 |
-
return $aArray[ $sKey ];
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* @param string $sKey The $_COOKIE key
|
435 |
-
* @param mixed $mDefault
|
436 |
-
* @return mixed|null
|
437 |
-
*/
|
438 |
-
public static function FetchCookie( $sKey, $mDefault = null ) {
|
439 |
-
if ( self::GetUseFilterInput() && defined( 'INPUT_COOKIE' ) ) {
|
440 |
-
$mPossible = filter_input( INPUT_COOKIE, $sKey );
|
441 |
-
if ( !empty( $mPossible ) ) {
|
442 |
-
return $mPossible;
|
443 |
-
}
|
444 |
-
}
|
445 |
-
return self::ArrayFetch( $_COOKIE, $sKey, $mDefault );
|
446 |
}
|
447 |
|
448 |
/**
|
|
|
449 |
* @param string $sKey
|
450 |
* @param mixed $mDefault
|
451 |
* @return mixed|null
|
452 |
*/
|
453 |
-
public
|
454 |
-
|
455 |
-
$sPossible = filter_input( INPUT_ENV, $sKey );
|
456 |
-
if ( !empty( $sPossible ) ) {
|
457 |
-
return $sPossible;
|
458 |
-
}
|
459 |
-
}
|
460 |
-
return self::ArrayFetch( $_ENV, $sKey, $mDefault );
|
461 |
-
}
|
462 |
-
|
463 |
-
/**
|
464 |
-
* @deprecated
|
465 |
-
* @param string $sKey
|
466 |
-
* @param mixed $mDefault
|
467 |
-
* @return mixed|null
|
468 |
-
*/
|
469 |
-
public static function FetchGet( $sKey, $mDefault = null ) {
|
470 |
-
if ( self::GetUseFilterInput() && defined( 'INPUT_GET' ) ) {
|
471 |
-
$mPossible = filter_input( INPUT_GET, $sKey );
|
472 |
-
if ( !empty( $mPossible ) ) {
|
473 |
-
return $mPossible;
|
474 |
-
}
|
475 |
-
}
|
476 |
-
return self::ArrayFetch( $_GET, $sKey, $mDefault );
|
477 |
-
}
|
478 |
-
|
479 |
-
/**
|
480 |
-
* @param string $sKey The $_POST key
|
481 |
-
* @param mixed $mDefault
|
482 |
-
* @return mixed|null
|
483 |
-
*/
|
484 |
-
public static function FetchPost( $sKey, $mDefault = null ) {
|
485 |
-
if ( self::GetUseFilterInput() && defined( 'INPUT_POST' ) ) {
|
486 |
-
$mPossible = filter_input( INPUT_POST, $sKey );
|
487 |
-
if ( !empty( $mPossible ) ) {
|
488 |
-
return $mPossible;
|
489 |
-
}
|
490 |
-
}
|
491 |
-
return self::ArrayFetch( $_POST, $sKey, $mDefault );
|
492 |
-
}
|
493 |
-
|
494 |
-
/**
|
495 |
-
* @param string $sKey
|
496 |
-
* @param mixed $mDefault
|
497 |
-
* @return mixed|null
|
498 |
-
*/
|
499 |
-
public static function FetchServer( $sKey, $mDefault = null ) {
|
500 |
-
if ( self::GetUseFilterInput() && defined( 'INPUT_SERVER' ) ) {
|
501 |
-
$sPossible = filter_input( INPUT_SERVER, $sKey );
|
502 |
-
if ( !empty( $sPossible ) ) {
|
503 |
-
return $sPossible;
|
504 |
-
}
|
505 |
-
}
|
506 |
-
return self::ArrayFetch( $_SERVER, $sKey, $mDefault );
|
507 |
}
|
508 |
|
509 |
/**
|
@@ -536,7 +444,6 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
536 |
/**
|
537 |
* @param string $sStringContent
|
538 |
* @param string $sFilename
|
539 |
-
* @return bool
|
540 |
*/
|
541 |
public function downloadStringAsFile( $sStringContent, $sFilename ) {
|
542 |
header( "Content-type: application/octet-stream" );
|
@@ -740,6 +647,9 @@ class ICWP_WPSF_DataProcessor extends ICWP_WPSF_Foundation {
|
|
740 |
* @return int
|
741 |
*/
|
742 |
public function time() {
|
743 |
-
|
|
|
|
|
|
|
744 |
}
|
745 |
}
|
11 |
protected static $oInstance = null;
|
12 |
|
13 |
/**
|
14 |
+
* @var int
|
15 |
*/
|
16 |
+
protected static $nRequestTime = null;
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
/**
|
19 |
* @var array
|
33 |
return self::$oInstance;
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* @param array $aA
|
38 |
* @return array
|
62 |
|
63 |
/**
|
64 |
* @param string $sKey
|
65 |
+
* @param string $mDefault
|
66 |
* @param bool $bTrim -automatically trim whitespace
|
67 |
* @return mixed|null
|
68 |
*/
|
69 |
public function cookie( $sKey, $mDefault = null, $bTrim = true ) {
|
70 |
+
$mVal = $this->arrayFetch( $_COOKIE, $sKey, $mDefault );
|
71 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
72 |
}
|
73 |
|
74 |
+
/**
|
75 |
+
* @param string $sKey
|
76 |
+
* @param mixed $mDefault
|
77 |
+
* @return mixed|null
|
78 |
+
*/
|
79 |
+
public function env( $sKey, $mDefault = null ) {
|
80 |
+
return $this->arrayFetch( $_ENV, $sKey, $mDefault );
|
81 |
+
}
|
82 |
+
|
83 |
/**
|
84 |
* @param string $sKey
|
85 |
* @param null $mDefault
|
86 |
* @param bool $bTrim -automatically trim whitespace
|
87 |
* @return mixed|null
|
88 |
*/
|
89 |
+
public function post( $sKey, $mDefault = null, $bTrim = true ) {
|
90 |
+
$mVal = $this->arrayFetch( $_POST, $sKey, $mDefault );
|
91 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
92 |
}
|
93 |
|
97 |
* @param bool $bTrim -automatically trim whitespace
|
98 |
* @return mixed|null
|
99 |
*/
|
100 |
+
public function query( $sKey, $mDefault = null, $bTrim = true ) {
|
101 |
+
$mVal = $this->arrayFetch( $_GET, $sKey, $mDefault );
|
102 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
103 |
}
|
104 |
|
109 |
* @return mixed|null
|
110 |
*/
|
111 |
public function server( $sKey, $mDefault = null, $bTrim = true ) {
|
112 |
+
$mVal = $this->arrayFetch( $_SERVER, $sKey, $mDefault );
|
113 |
return ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
114 |
}
|
115 |
|
125 |
if ( is_null( $mVal ) ) {
|
126 |
$mVal = $this->query( $sKey, null, $bTrim );
|
127 |
if ( is_null( $mVal && $bIncludeCookie ) ) {
|
128 |
+
$mVal = $this->cookie( $sKey );
|
129 |
}
|
130 |
}
|
131 |
return is_null( $mVal ) ? $mDefault : ( $bTrim && is_scalar( $mVal ) ) ? trim( $mVal ) : $mVal;
|
143 |
* @return string
|
144 |
*/
|
145 |
public function getRequestUri() {
|
146 |
+
return $this->server( 'REQUEST_URI' );
|
147 |
}
|
148 |
|
149 |
/**
|
150 |
* @return string
|
151 |
*/
|
152 |
public function getUserAgent() {
|
153 |
+
return $this->server( 'HTTP_USER_AGENT' );
|
154 |
}
|
155 |
|
156 |
/**
|
326 |
* @return string
|
327 |
*/
|
328 |
public function getRequestMethod() {
|
329 |
+
$sRequestMethod = $this->server( 'REQUEST_METHOD' );
|
330 |
return ( empty( $sRequestMethod ) ? 'get' : strtolower( $sRequestMethod ) );
|
331 |
}
|
332 |
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
+
* TODO: scrap?
|
342 |
* Taken from http://www.phacks.net/detecting-search-engine-bot-and-web-spiders/
|
343 |
*/
|
344 |
+
public function isSearchEngineBot() {
|
345 |
|
346 |
+
$sUserAgent = $this->server( 'HTTP_USER_AGENT' );
|
347 |
if ( empty( $sUserAgent ) ) {
|
348 |
return false;
|
349 |
}
|
361 |
* @param boolean $bIgnoreAmb
|
362 |
* @return string
|
363 |
*/
|
364 |
+
public function generateRandomString( $nLength = 10, $nStrength = 7, $bIgnoreAmb = true ) {
|
365 |
$aChars = array( 'abcdefghijkmnopqrstuvwxyz' );
|
366 |
|
367 |
if ( $nStrength & 2 ) {
|
391 |
/**
|
392 |
* @return string
|
393 |
*/
|
394 |
+
public function generateRandomLetter() {
|
395 |
$sAtoZ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
396 |
+
return $sAtoZ[ wp_rand( 0, ( strlen( $sAtoZ ) - 1 ) ) ];
|
|
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* @return string|null
|
401 |
*/
|
402 |
+
public function getScriptName() {
|
403 |
+
$sScriptName = $this->server( 'SCRIPT_NAME' );
|
404 |
+
return !empty( $sScriptName ) ? $sScriptName : $this->server( 'PHP_SELF' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
+
* @param array $aA
|
409 |
* @param string $sKey
|
410 |
* @param mixed $mDefault
|
411 |
* @return mixed|null
|
412 |
*/
|
413 |
+
public function arrayFetch( &$aA, $sKey, $mDefault = null ) {
|
414 |
+
return isset( $aA[ $sKey ] ) ? $aA[ $sKey ] : $mDefault;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
}
|
416 |
|
417 |
/**
|
444 |
/**
|
445 |
* @param string $sStringContent
|
446 |
* @param string $sFilename
|
|
|
447 |
*/
|
448 |
public function downloadStringAsFile( $sStringContent, $sFilename ) {
|
449 |
header( "Content-type: application/octet-stream" );
|
647 |
* @return int
|
648 |
*/
|
649 |
public function time() {
|
650 |
+
if ( !isset( self::$nRequestTime ) ) {
|
651 |
+
self::$nRequestTime = time();
|
652 |
+
}
|
653 |
+
return self::$nRequestTime;
|
654 |
}
|
655 |
}
|
src/common/icwp-ip.php
CHANGED
@@ -177,6 +177,14 @@ class ICWP_WPSF_Ip extends ICWP_WPSF_Foundation {
|
|
177 |
return filter_var( $sIp, FILTER_VALIDATE_IP, $flags );
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
/**
|
181 |
* Assumes a valid IPv4 address is provided as we're only testing for a whether the IP is public or not.
|
182 |
* @param string $sIp
|
@@ -264,7 +272,7 @@ class ICWP_WPSF_Ip extends ICWP_WPSF_Foundation {
|
|
264 |
$sBestSource = null;
|
265 |
foreach ( $this->getIpSourceOptions() as $sSource ) {
|
266 |
|
267 |
-
$sIpToTest = $oDp->
|
268 |
if ( empty( $sIpToTest ) ) {
|
269 |
continue;
|
270 |
}
|
@@ -284,11 +292,10 @@ class ICWP_WPSF_Ip extends ICWP_WPSF_Foundation {
|
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
-
* @return
|
288 |
*/
|
289 |
public function discoverViableRequestIpSource() {
|
290 |
-
|
291 |
-
return $aResult[ 'source' ];
|
292 |
}
|
293 |
|
294 |
/**
|
@@ -303,9 +310,9 @@ class ICWP_WPSF_Ip extends ICWP_WPSF_Foundation {
|
|
303 |
$sIpToReturn = false;
|
304 |
$sSource = false;
|
305 |
$oDp = $this->loadDP();
|
306 |
-
foreach ( $this->getIpSourceOptions() as $
|
307 |
|
308 |
-
$sIpToTest = $oDp->server( $
|
309 |
if ( empty( $sIpToTest ) ) {
|
310 |
continue;
|
311 |
}
|
@@ -316,6 +323,7 @@ class ICWP_WPSF_Ip extends ICWP_WPSF_Foundation {
|
|
316 |
|
317 |
if ( $this->isViablePublicVisitorIp( $sIp ) ) {
|
318 |
$sIpToReturn = $sIp;
|
|
|
319 |
break( 2 );
|
320 |
}
|
321 |
}
|
177 |
return filter_var( $sIp, FILTER_VALIDATE_IP, $flags );
|
178 |
}
|
179 |
|
180 |
+
/**
|
181 |
+
* @param string $sIp
|
182 |
+
* @return boolean
|
183 |
+
*/
|
184 |
+
public function isValidIpOrRange( $sIp ) {
|
185 |
+
return $this->isValidIp_PublicRemote( $sIp ) || $this->isValidIpRange( $sIp );
|
186 |
+
}
|
187 |
+
|
188 |
/**
|
189 |
* Assumes a valid IPv4 address is provided as we're only testing for a whether the IP is public or not.
|
190 |
* @param string $sIp
|
272 |
$sBestSource = null;
|
273 |
foreach ( $this->getIpSourceOptions() as $sSource ) {
|
274 |
|
275 |
+
$sIpToTest = $oDp->server( $sSource );
|
276 |
if ( empty( $sIpToTest ) ) {
|
277 |
continue;
|
278 |
}
|
292 |
}
|
293 |
|
294 |
/**
|
295 |
+
* @return array
|
296 |
*/
|
297 |
public function discoverViableRequestIpSource() {
|
298 |
+
return $this->findViableVisitorIp( true );
|
|
|
299 |
}
|
300 |
|
301 |
/**
|
310 |
$sIpToReturn = false;
|
311 |
$sSource = false;
|
312 |
$oDp = $this->loadDP();
|
313 |
+
foreach ( $this->getIpSourceOptions() as $sMaybeSource ) {
|
314 |
|
315 |
+
$sIpToTest = $oDp->server( $sMaybeSource );
|
316 |
if ( empty( $sIpToTest ) ) {
|
317 |
continue;
|
318 |
}
|
323 |
|
324 |
if ( $this->isViablePublicVisitorIp( $sIp ) ) {
|
325 |
$sIpToReturn = $sIp;
|
326 |
+
$sSource = $sMaybeSource;
|
327 |
break( 2 );
|
328 |
}
|
329 |
}
|
src/common/icwp-serviceproviders.php
CHANGED
@@ -69,6 +69,21 @@ class ICWP_WPSF_ServiceProviders extends ICWP_WPSF_Foundation {
|
|
69 |
return array( '107.20.237.51', '23.21.226.191', '107.21.1.8', '54.208.102.37' );
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
/**
|
73 |
* @return array[]
|
74 |
*/
|
@@ -418,11 +433,14 @@ class ICWP_WPSF_ServiceProviders extends ICWP_WPSF_Foundation {
|
|
418 |
* @return string[]
|
419 |
*/
|
420 |
private function downloadServiceIps_Cloudflare( $sIpVersion = 4 ) {
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
426 |
}
|
427 |
|
428 |
/**
|
@@ -430,8 +448,7 @@ class ICWP_WPSF_ServiceProviders extends ICWP_WPSF_Foundation {
|
|
430 |
* @return string[]
|
431 |
*/
|
432 |
private function downloadServiceIps_Pingdom( $sIpVersion = 4 ) {
|
433 |
-
$
|
434 |
-
return array_filter( array_map( 'trim', explode( "\n", $this->loadFS()->getUrlContent( $sUrl ) ) ) );
|
435 |
}
|
436 |
|
437 |
/**
|
@@ -443,7 +460,9 @@ class ICWP_WPSF_ServiceProviders extends ICWP_WPSF_Foundation {
|
|
443 |
->getUrlContent( 'https://app.statuscake.com/Workfloor/Locations.php?format=json' ), true );
|
444 |
if ( is_array( $aData ) ) {
|
445 |
foreach ( $aData as $aItem ) {
|
446 |
-
|
|
|
|
|
447 |
}
|
448 |
}
|
449 |
return $aIps;
|
@@ -454,10 +473,23 @@ class ICWP_WPSF_ServiceProviders extends ICWP_WPSF_Foundation {
|
|
454 |
* @return string[]
|
455 |
*/
|
456 |
private function downloadServiceIps_UptimeRobot( $sIpVersion = 4 ) {
|
457 |
-
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
}
|
460 |
-
$
|
461 |
-
|
|
|
462 |
}
|
463 |
}
|
69 |
return array( '107.20.237.51', '23.21.226.191', '107.21.1.8', '54.208.102.37' );
|
70 |
}
|
71 |
|
72 |
+
/**
|
73 |
+
* @return array[]
|
74 |
+
*/
|
75 |
+
public function getIps_ManageWp() {
|
76 |
+
$oWp = $this->loadWp();
|
77 |
+
|
78 |
+
$sStoreKey = $this->prefix( 'serviceips_managewp' );
|
79 |
+
$aIps = $oWp->getTransient( $sStoreKey );
|
80 |
+
if ( empty( $aIps ) ) {
|
81 |
+
$aIps = $this->downloadServiceIps_ManageWp();
|
82 |
+
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
83 |
+
}
|
84 |
+
return $aIps;
|
85 |
+
}
|
86 |
+
|
87 |
/**
|
88 |
* @return array[]
|
89 |
*/
|
433 |
* @return string[]
|
434 |
*/
|
435 |
private function downloadServiceIps_Cloudflare( $sIpVersion = 4 ) {
|
436 |
+
return $this->downloadServiceIps_Standard( 'https://www.cloudflare.com/ips-v%s', $sIpVersion );
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* @return string[]
|
441 |
+
*/
|
442 |
+
private function downloadServiceIps_ManageWp() {
|
443 |
+
return $this->downloadServiceIps_Standard( 'https://managewp.com/wp-content/uploads/2016/11/managewp-ips.txt' );
|
444 |
}
|
445 |
|
446 |
/**
|
448 |
* @return string[]
|
449 |
*/
|
450 |
private function downloadServiceIps_Pingdom( $sIpVersion = 4 ) {
|
451 |
+
return $this->downloadServiceIps_Standard( 'https://my.pingdom.com/probes/ipv%s', $sIpVersion );
|
|
|
452 |
}
|
453 |
|
454 |
/**
|
460 |
->getUrlContent( 'https://app.statuscake.com/Workfloor/Locations.php?format=json' ), true );
|
461 |
if ( is_array( $aData ) ) {
|
462 |
foreach ( $aData as $aItem ) {
|
463 |
+
if ( !empty( $aItem[ 'ip' ] ) ) {
|
464 |
+
$aIps[] = $aItem[ 'ip' ];
|
465 |
+
}
|
466 |
}
|
467 |
}
|
468 |
return $aIps;
|
473 |
* @return string[]
|
474 |
*/
|
475 |
private function downloadServiceIps_UptimeRobot( $sIpVersion = 4 ) {
|
476 |
+
return $this->downloadServiceIps_Standard( 'https://uptimerobot.com/inc/files/ips/IPv%s.txt', $sIpVersion );
|
477 |
+
}
|
478 |
+
|
479 |
+
/**
|
480 |
+
* @param string $sSourceUrl must have an sprintf %s placeholder
|
481 |
+
* @param int $sIpVersion
|
482 |
+
* @return string[]
|
483 |
+
*/
|
484 |
+
private function downloadServiceIps_Standard( $sSourceUrl, $sIpVersion = null ) {
|
485 |
+
if ( !is_null( $sIpVersion ) ) {
|
486 |
+
if ( !in_array( (int)$sIpVersion, array( 4, 6 ) ) ) {
|
487 |
+
$sIpVersion = 4;
|
488 |
+
}
|
489 |
+
$sSourceUrl = $this->loadFS()->getUrlContent( sprintf( $sSourceUrl, $sIpVersion ) );
|
490 |
}
|
491 |
+
$sRaw = $this->loadFS()->getUrlContent( $sSourceUrl );
|
492 |
+
$aIps = empty( $sRaw ) ? array() : explode( "\n", $sRaw );
|
493 |
+
return array_filter( array_map( 'trim', $aIps ) );
|
494 |
}
|
495 |
}
|
src/common/icwp-wpfunctions.php
CHANGED
@@ -815,10 +815,7 @@ class ICWP_WPSF_WpFunctions extends ICWP_WPSF_Foundation {
|
|
815 |
public function getCurrentWpAdminPage() {
|
816 |
|
817 |
$oDp = $this->loadDP();
|
818 |
-
$sScript = $oDp->
|
819 |
-
if ( empty( $sScript ) ) {
|
820 |
-
$sScript = $oDp->FetchServer( 'PHP_SELF' );
|
821 |
-
}
|
822 |
if ( is_admin() && !empty( $sScript ) && basename( $sScript ) == 'admin.php' ) {
|
823 |
$sCurrentPage = $oDp->query( 'page' );
|
824 |
}
|
815 |
public function getCurrentWpAdminPage() {
|
816 |
|
817 |
$oDp = $this->loadDP();
|
818 |
+
$sScript = $oDp->getScriptName();
|
|
|
|
|
|
|
819 |
if ( is_admin() && !empty( $sScript ) && basename( $sScript ) == 'admin.php' ) {
|
820 |
$sCurrentPage = $oDp->query( 'page' );
|
821 |
}
|
src/common/wp-comments.php
CHANGED
@@ -25,7 +25,7 @@ class ICWP_WPSF_WpComments extends ICWP_WPSF_Foundation {
|
|
25 |
/**
|
26 |
* @return bool
|
27 |
*/
|
28 |
-
public function
|
29 |
return ( $this->loadWp()->getOption( 'comment_whitelist' ) == 1 );
|
30 |
}
|
31 |
|
@@ -52,7 +52,7 @@ class ICWP_WPSF_WpComments extends ICWP_WPSF_Foundation {
|
|
52 |
* @param string $sAuthorEmail
|
53 |
* @return bool
|
54 |
*/
|
55 |
-
public function
|
56 |
|
57 |
if ( !$this->loadDP()->validEmail( $sAuthorEmail ) ) {
|
58 |
return false;
|
25 |
/**
|
26 |
* @return bool
|
27 |
*/
|
28 |
+
public function getIfAllowCommentsByPreviouslyApproved() {
|
29 |
return ( $this->loadWp()->getOption( 'comment_whitelist' ) == 1 );
|
30 |
}
|
31 |
|
52 |
* @param string $sAuthorEmail
|
53 |
* @return bool
|
54 |
*/
|
55 |
+
public function isAuthorApproved( $sAuthorEmail ) {
|
56 |
|
57 |
if ( !$this->loadDP()->validEmail( $sAuthorEmail ) ) {
|
58 |
return false;
|
src/config/feature-comments_filter.php
CHANGED
@@ -103,6 +103,7 @@
|
|
103 |
"key": "comments_cooldown_interval",
|
104 |
"section": "section_bot_comment_spam_protection_filter",
|
105 |
"default": 10,
|
|
|
106 |
"type": "integer",
|
107 |
"link_info": "https://icwp.io/3o",
|
108 |
"link_blog": "",
|
@@ -270,6 +271,7 @@
|
|
270 |
"key": "comments_token_expire_interval",
|
271 |
"section": "section_bot_comment_spam_protection_filter",
|
272 |
"default": 600,
|
|
|
273 |
"type": "integer",
|
274 |
"link_info": "https://icwp.io/3o",
|
275 |
"link_blog": "https://icwp.io/9v",
|
103 |
"key": "comments_cooldown_interval",
|
104 |
"section": "section_bot_comment_spam_protection_filter",
|
105 |
"default": 10,
|
106 |
+
"min": 0,
|
107 |
"type": "integer",
|
108 |
"link_info": "https://icwp.io/3o",
|
109 |
"link_blog": "",
|
271 |
"key": "comments_token_expire_interval",
|
272 |
"section": "section_bot_comment_spam_protection_filter",
|
273 |
"default": 600,
|
274 |
+
"min": 0,
|
275 |
"type": "integer",
|
276 |
"link_info": "https://icwp.io/3o",
|
277 |
"link_blog": "https://icwp.io/9v",
|
src/config/feature-plugin.php
CHANGED
@@ -151,6 +151,10 @@
|
|
151 |
"value_key": "HTTP_INCAP_CLIENT_IP",
|
152 |
"text": "HTTP_INCAP_CLIENT_IP"
|
153 |
},
|
|
|
|
|
|
|
|
|
154 |
{
|
155 |
"value_key": "HTTP_FORWARDED",
|
156 |
"text": "HTTP_FORWARDED"
|
151 |
"value_key": "HTTP_INCAP_CLIENT_IP",
|
152 |
"text": "HTTP_INCAP_CLIENT_IP"
|
153 |
},
|
154 |
+
{
|
155 |
+
"value_key": "HTTP_X_SP_FORWARDED_IP",
|
156 |
+
"text": "HTTP_X_SP_FORWARDED_IP"
|
157 |
+
},
|
158 |
{
|
159 |
"value_key": "HTTP_FORWARDED",
|
160 |
"text": "HTTP_FORWARDED"
|
src/features/audit_trail.php
CHANGED
@@ -125,19 +125,22 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
125 |
|
126 |
/**
|
127 |
* Move to table
|
128 |
-
* @param $aEntries
|
129 |
* @return array
|
130 |
*/
|
131 |
public function formatEntriesForDisplay( $aEntries ) {
|
|
|
132 |
$sYou = $this->loadIpService()->getRequestIp();
|
133 |
if ( is_array( $aEntries ) ) {
|
134 |
-
foreach ( $aEntries as
|
135 |
-
$
|
136 |
-
$
|
137 |
-
$
|
138 |
-
|
139 |
-
|
|
|
140 |
}
|
|
|
141 |
}
|
142 |
}
|
143 |
return $aEntries;
|
@@ -222,7 +225,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
222 |
);
|
223 |
|
224 |
try {
|
225 |
-
$oFinder = $oProc->
|
226 |
->addWhereSearch( 'wp_username', $oUser->user_login )
|
227 |
->setResultsAsVo( true );
|
228 |
|
@@ -259,7 +262,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
259 |
|
260 |
try {
|
261 |
$oThisUsername = $this->loadWpUsers()->getUserByEmail( $sEmail )->user_login;
|
262 |
-
$oProc->
|
263 |
->addWhereSearch( 'wp_username', $oThisUsername )
|
264 |
->all();
|
265 |
$aData[ 'messages' ][] = sprintf( '%s Audit Entries deleted', $this->getConn()->getHumanName() );
|
125 |
|
126 |
/**
|
127 |
* Move to table
|
128 |
+
* @param ICWP_WPSF_AuditTrailEntryVO[] $aEntries
|
129 |
* @return array
|
130 |
*/
|
131 |
public function formatEntriesForDisplay( $aEntries ) {
|
132 |
+
$oDp = $this->loadDP();
|
133 |
$sYou = $this->loadIpService()->getRequestIp();
|
134 |
if ( is_array( $aEntries ) ) {
|
135 |
+
foreach ( $aEntries as $nKey => $oEntry ) {
|
136 |
+
$aE = $oDp->convertStdClassToArray( $oEntry->getRawData() );
|
137 |
+
$aE[ 'event' ] = str_replace( '_', ' ', sanitize_text_field( $oEntry->getEvent() ) );
|
138 |
+
$aE[ 'message' ] = stripslashes( sanitize_text_field( $oEntry->getMessage() ) );
|
139 |
+
$aE[ 'created_at' ] = $this->loadWp()->getTimeStringForDisplay( $oEntry->getCreatedAt() );
|
140 |
+
if ( $oEntry->getIp() == $sYou ) {
|
141 |
+
$aE[ 'ip' ] .= '<br /><div style="font-size: smaller;">('._wpsf__( 'Your IP' ).')</div>';
|
142 |
}
|
143 |
+
$aEntries[ $nKey ] = $aE;
|
144 |
}
|
145 |
}
|
146 |
return $aEntries;
|
225 |
);
|
226 |
|
227 |
try {
|
228 |
+
$oFinder = $oProc->getQuerySelector()
|
229 |
->addWhereSearch( 'wp_username', $oUser->user_login )
|
230 |
->setResultsAsVo( true );
|
231 |
|
262 |
|
263 |
try {
|
264 |
$oThisUsername = $this->loadWpUsers()->getUserByEmail( $sEmail )->user_login;
|
265 |
+
$oProc->getQueryDeleter()
|
266 |
->addWhereSearch( 'wp_username', $oThisUsername )
|
267 |
->all();
|
268 |
$aData[ 'messages' ][] = sprintf( '%s Audit Entries deleted', $this->getConn()->getHumanName() );
|
src/features/comments_filter.php
CHANGED
@@ -8,18 +8,71 @@ require_once( dirname( __FILE__ ).'/base_wpsf.php' );
|
|
8 |
|
9 |
class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* @return boolean
|
13 |
*/
|
14 |
public function getIfDoCommentsCheck() {
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
/**
|
19 |
* @return boolean
|
20 |
*/
|
21 |
public function getIfCheckCommentToken() {
|
22 |
-
return ( $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
@@ -60,16 +113,7 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
60 |
}
|
61 |
|
62 |
protected function doExtraSubmitProcessing() {
|
63 |
-
|
64 |
-
if ( $this->getOpt( 'comments_cooldown_interval' ) < 0 ) {
|
65 |
-
$this->getOptionsVo()->resetOptToDefault( 'comments_cooldown_interval' );
|
66 |
-
}
|
67 |
-
|
68 |
-
if ( $this->getOpt( 'comments_token_expire_interval' ) < 0 ) {
|
69 |
-
$this->getOptionsVo()->resetOptToDefault( 'comments_token_expire_interval' );
|
70 |
-
}
|
71 |
-
|
72 |
-
if ( $this->getOpt( 'comments_token_expire_interval' ) != 0 && $this->getOpt( 'comments_cooldown_interval' ) > $this->getOpt( 'comments_token_expire_interval' ) ) {
|
73 |
$this->getOptionsVo()->resetOptToDefault( 'comments_cooldown_interval' );
|
74 |
$this->getOptionsVo()->resetOptToDefault( 'comments_token_expire_interval' );
|
75 |
}
|
@@ -84,10 +128,6 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
84 |
* This is the point where you would want to do any options verification
|
85 |
*/
|
86 |
protected function doPrePluginOptionsSave() {
|
87 |
-
// TODO: remove as it's a temporary transition for clashing options
|
88 |
-
if ( $this->isOpt( 'enable_google_recaptcha', 'Y' ) ) {
|
89 |
-
$this->setOpt( 'enable_google_recaptcha_comments', 'Y' );
|
90 |
-
}
|
91 |
}
|
92 |
|
93 |
/**
|
8 |
|
9 |
class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
10 |
|
11 |
+
/**
|
12 |
+
* @var array
|
13 |
+
*/
|
14 |
+
private $aCommentData;
|
15 |
+
|
16 |
+
public function doPostConstruction() {
|
17 |
+
add_filter( 'preprocess_comment', array( $this, 'gatherRawCommentData' ), 1 );
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param array $aRawCommentData
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function gatherRawCommentData( $aRawCommentData ) {
|
25 |
+
$this->aCommentData = $aRawCommentData;
|
26 |
+
return $aRawCommentData;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function getCommentData() {
|
33 |
+
return ( isset( $this->aCommentData ) && is_array( $this->aCommentData ) ) ? $this->aCommentData : array();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param string $sKey
|
38 |
+
* @return array|mixed
|
39 |
+
*/
|
40 |
+
public function getCommentItem( $sKey ) {
|
41 |
+
$aD = $this->getCommentData();
|
42 |
+
return isset( $aD[ $sKey ] ) ? $aD[ $sKey ] : null;
|
43 |
+
}
|
44 |
+
|
45 |
/**
|
46 |
* @return boolean
|
47 |
*/
|
48 |
public function getIfDoCommentsCheck() {
|
49 |
+
$oWpComments = $this->loadWpComments();
|
50 |
+
|
51 |
+
// 1st are comments enabled on this post?
|
52 |
+
$oPost = $this->loadWp()->getPostById( $this->getCommentItem( 'comment_post_ID' ) );
|
53 |
+
return ( $oPost instanceof WP_Post ) && $oWpComments->isCommentsOpen( $oPost )
|
54 |
+
&& ( !$oWpComments->getIfAllowCommentsByPreviouslyApproved() || !$oWpComments->isAuthorApproved( $this->getCommentItem( 'comment_author_email' ) ) );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* @return boolean
|
59 |
*/
|
60 |
public function getIfCheckCommentToken() {
|
61 |
+
return ( $this->getTokenExpireInterval() > 0 || $this->getTokenCooldown() > 0 );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return int
|
66 |
+
*/
|
67 |
+
public function getTokenCooldown() {
|
68 |
+
return (int)$this->getOpt( 'comments_cooldown_interval' );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return int
|
73 |
+
*/
|
74 |
+
public function getTokenExpireInterval() {
|
75 |
+
return (int)$this->getOpt( 'comments_token_expire_interval' );
|
76 |
}
|
77 |
|
78 |
/**
|
113 |
}
|
114 |
|
115 |
protected function doExtraSubmitProcessing() {
|
116 |
+
if ( $this->getTokenExpireInterval() != 0 && $this->getTokenCooldown() > $this->getTokenExpireInterval() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
$this->getOptionsVo()->resetOptToDefault( 'comments_cooldown_interval' );
|
118 |
$this->getOptionsVo()->resetOptToDefault( 'comments_token_expire_interval' );
|
119 |
}
|
128 |
* This is the point where you would want to do any options verification
|
129 |
*/
|
130 |
protected function doPrePluginOptionsSave() {
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
|
133 |
/**
|
src/features/insights.php
CHANGED
@@ -454,6 +454,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
454 |
|
455 |
$oRetriever = $oProc->getSubProcessorNotes()
|
456 |
->getQuerySelector();
|
|
|
457 |
$aNotes = $oRetriever->setLimit( 10 )
|
458 |
->setResultsAsVo( false )
|
459 |
->query();
|
@@ -517,7 +518,9 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
517 |
),
|
518 |
'blackips' => array(
|
519 |
'title' => _wpsf__( 'Blacklist IPs' ),
|
520 |
-
'val' =>
|
|
|
|
|
521 |
'tooltip' => _wpsf__( 'Current IP addresses with transgressions against the site.' )
|
522 |
),
|
523 |
'pro' => array(
|
@@ -561,7 +564,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
561 |
->getModule( 'audit_trail' )
|
562 |
->getProcessor();
|
563 |
try {
|
564 |
-
$aItems = $oProc->
|
565 |
->setLimit( 20 )
|
566 |
->query();
|
567 |
}
|
@@ -597,7 +600,8 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
597 |
'insights_last_comment_block_at' => _wpsf__( 'Comment SPAM Block' ),
|
598 |
'insights_xml_block_at' => _wpsf__( 'XML-RPC Block' ),
|
599 |
'insights_restapi_block_at' => _wpsf__( 'Anonymous Rest API Block' ),
|
600 |
-
'insights_last_transgression_at' => sprintf( _wpsf__( '%s Transgression' ), $this->getConn()
|
|
|
601 |
'insights_last_ip_block_at' => _wpsf__( 'IP Connection Blocked' ),
|
602 |
);
|
603 |
}
|
454 |
|
455 |
$oRetriever = $oProc->getSubProcessorNotes()
|
456 |
->getQuerySelector();
|
457 |
+
/** @var stdClass[] $aNotes */
|
458 |
$aNotes = $oRetriever->setLimit( 10 )
|
459 |
->setResultsAsVo( false )
|
460 |
->query();
|
518 |
),
|
519 |
'blackips' => array(
|
520 |
'title' => _wpsf__( 'Blacklist IPs' ),
|
521 |
+
'val' => $oIPs->getQuerySelector()
|
522 |
+
->filterByList( ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK )
|
523 |
+
->count(),
|
524 |
'tooltip' => _wpsf__( 'Current IP addresses with transgressions against the site.' )
|
525 |
),
|
526 |
'pro' => array(
|
564 |
->getModule( 'audit_trail' )
|
565 |
->getProcessor();
|
566 |
try {
|
567 |
+
$aItems = $oProc->getQuerySelector()
|
568 |
->setLimit( 20 )
|
569 |
->query();
|
570 |
}
|
600 |
'insights_last_comment_block_at' => _wpsf__( 'Comment SPAM Block' ),
|
601 |
'insights_xml_block_at' => _wpsf__( 'XML-RPC Block' ),
|
602 |
'insights_restapi_block_at' => _wpsf__( 'Anonymous Rest API Block' ),
|
603 |
+
'insights_last_transgression_at' => sprintf( _wpsf__( '%s Transgression' ), $this->getConn()
|
604 |
+
->getHumanName() ),
|
605 |
'insights_last_ip_block_at' => _wpsf__( 'IP Connection Blocked' ),
|
606 |
);
|
607 |
}
|
src/features/ips.php
CHANGED
@@ -91,7 +91,7 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
91 |
protected function getFormatedData_WhiteList() {
|
92 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
93 |
$oProcessor = $this->getProcessor();
|
94 |
-
return $this->formatIpListData( $oProcessor->
|
95 |
}
|
96 |
|
97 |
/**
|
@@ -100,28 +100,34 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
100 |
protected function getFormatedData_AutoBlackList() {
|
101 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
102 |
$oProcessor = $this->getProcessor();
|
103 |
-
return $this->formatIpListData( $oProcessor->
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
-
* @param
|
108 |
* @return array
|
109 |
*/
|
110 |
protected function formatIpListData( $aListData ) {
|
111 |
$oWp = $this->loadWp();
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
$aListItem[ 'ip_link' ] =
|
115 |
sprintf( '<a href="%s" target="_blank">%s</a>',
|
116 |
(
|
117 |
-
( $this->loadIpService()->getIpVersion( $
|
118 |
-
'http://whois.domaintools.com/'.$
|
119 |
-
: sprintf( 'http://whois.arin.net/rest/nets;q=%s?showDetails=true', $
|
120 |
),
|
121 |
-
$
|
122 |
);
|
123 |
-
$
|
124 |
-
$
|
|
|
|
|
125 |
}
|
126 |
return $aListData;
|
127 |
}
|
@@ -180,11 +186,11 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
180 |
}
|
181 |
|
182 |
public function ajaxExec_RemoveIpFromList() {
|
183 |
-
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
184 |
-
$oProcessor = $this->getProcessor();
|
185 |
$oDp = $this->loadDP();
|
186 |
-
|
187 |
-
$
|
|
|
|
|
188 |
|
189 |
return array(
|
190 |
'success' => true,
|
@@ -193,9 +199,9 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
193 |
}
|
194 |
|
195 |
protected function ajaxExec_AddIpToWhitelist() {
|
|
|
196 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
197 |
$oProcessor = $this->getProcessor();
|
198 |
-
$oDp = $this->loadDP();
|
199 |
|
200 |
$sIp = $oDp->post( 'ip', '' );
|
201 |
$sLabel = $oDp->post( 'label', '' );
|
@@ -404,13 +410,27 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
404 |
parent::action_doFeatureShutdown(); //save
|
405 |
}
|
406 |
|
|
|
|
|
407 |
protected function addFilterIpsToWhiteList() {
|
408 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
if ( !empty( $aIps ) && is_array( $aIps ) ) {
|
410 |
-
/** @var ICWP_WPSF_Processor_Ips $
|
411 |
-
$
|
|
|
|
|
412 |
foreach ( $aIps as $sIP => $sLabel ) {
|
413 |
-
|
|
|
|
|
414 |
}
|
415 |
}
|
416 |
}
|
@@ -420,7 +440,7 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
420 |
if ( !$this->isModuleEnabled() ) {
|
421 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
422 |
$oProcessor = $this->getProcessor();
|
423 |
-
if ( count( $oProcessor->
|
424 |
$this->setIsMainFeatureEnabled( true );
|
425 |
$this->setFlashAdminNotice(
|
426 |
sprintf( _wpsf__( 'Sorry, the %s feature may not be disabled while there are IP addresses in the White List' ), $this->getMainFeatureName() )
|
91 |
protected function getFormatedData_WhiteList() {
|
92 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
93 |
$oProcessor = $this->getProcessor();
|
94 |
+
return $this->formatIpListData( $oProcessor->getWhitelistIpsData() );
|
95 |
}
|
96 |
|
97 |
/**
|
100 |
protected function getFormatedData_AutoBlackList() {
|
101 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
102 |
$oProcessor = $this->getProcessor();
|
103 |
+
return $this->formatIpListData( $oProcessor->getAutoBlacklistIpsData() );
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
+
* @param ICWP_WPSF_IpsEntryVO[] $aListData
|
108 |
* @return array
|
109 |
*/
|
110 |
protected function formatIpListData( $aListData ) {
|
111 |
$oWp = $this->loadWp();
|
112 |
+
$oDp = $this->loadDP();
|
113 |
+
|
114 |
+
foreach ( $aListData as $nKey => $oIp ) {
|
115 |
+
$aItem = $oDp->convertStdClassToArray( $oIp->getRawData() );
|
116 |
+
$sIp = $oIp->getIp();
|
117 |
|
118 |
+
$aItem[ 'ip_link' ] =
|
|
|
119 |
sprintf( '<a href="%s" target="_blank">%s</a>',
|
120 |
(
|
121 |
+
( $this->loadIpService()->getIpVersion( $sIp ) == 4 ) ?
|
122 |
+
'http://whois.domaintools.com/'.$sIp
|
123 |
+
: sprintf( 'http://whois.arin.net/rest/nets;q=%s?showDetails=true', $sIp )
|
124 |
),
|
125 |
+
$sIp
|
126 |
);
|
127 |
+
$aItem[ 'last_access_at' ] = $oWp->getTimeStringForDisplay( $oIp->getLastAccessAt() );
|
128 |
+
$aItem[ 'created_at' ] = $oWp->getTimeStringForDisplay( $oIp->getCreatedAt() );
|
129 |
+
|
130 |
+
$aListData[ $nKey ] = $aItem;
|
131 |
}
|
132 |
return $aListData;
|
133 |
}
|
186 |
}
|
187 |
|
188 |
public function ajaxExec_RemoveIpFromList() {
|
|
|
|
|
189 |
$oDp = $this->loadDP();
|
190 |
+
/** @var ICWP_WPSF_Processor_Ips $oPro */
|
191 |
+
$oPro = $this->getProcessor();
|
192 |
+
$oPro->getQueryDeleter()
|
193 |
+
->deleteIpOnList( $oDp->post( 'ip' ), $oDp->post( 'list' ) );
|
194 |
|
195 |
return array(
|
196 |
'success' => true,
|
199 |
}
|
200 |
|
201 |
protected function ajaxExec_AddIpToWhitelist() {
|
202 |
+
$oDp = $this->loadDP();
|
203 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
204 |
$oProcessor = $this->getProcessor();
|
|
|
205 |
|
206 |
$sIp = $oDp->post( 'ip', '' );
|
207 |
$sLabel = $oDp->post( 'label', '' );
|
410 |
parent::action_doFeatureShutdown(); //save
|
411 |
}
|
412 |
|
413 |
+
/**
|
414 |
+
*/
|
415 |
protected function addFilterIpsToWhiteList() {
|
416 |
+
$oSp = $this->loadServiceProviders();
|
417 |
+
|
418 |
+
$aMwp = function_exists( 'mwp_init' ) ? array_flip( $oSp->getIps_ManageWp() ) : array();
|
419 |
+
foreach ( $aMwp as $sIp => $n ) {
|
420 |
+
$aMwp[ $sIp ] = 'ManageWP';
|
421 |
+
}
|
422 |
+
|
423 |
+
$aIps = apply_filters( 'icwp_simple_firewall_whitelist_ips', $aMwp );
|
424 |
+
|
425 |
if ( !empty( $aIps ) && is_array( $aIps ) ) {
|
426 |
+
/** @var ICWP_WPSF_Processor_Ips $oPro */
|
427 |
+
$oPro = $this->getProcessor();
|
428 |
+
|
429 |
+
$aWhiteIps = $oPro->getWhitelistIps();
|
430 |
foreach ( $aIps as $sIP => $sLabel ) {
|
431 |
+
if ( !in_array( $sIP, $aWhiteIps ) ) {
|
432 |
+
$oPro->addIpToWhiteList( $sIP, $sLabel );
|
433 |
+
}
|
434 |
}
|
435 |
}
|
436 |
}
|
440 |
if ( !$this->isModuleEnabled() ) {
|
441 |
/** @var ICWP_WPSF_Processor_Ips $oProcessor */
|
442 |
$oProcessor = $this->getProcessor();
|
443 |
+
if ( count( $oProcessor->getWhitelistIpsData() ) > 0 ) {
|
444 |
$this->setIsMainFeatureEnabled( true );
|
445 |
$this->setFlashAdminNotice(
|
446 |
sprintf( _wpsf__( 'Sorry, the %s feature may not be disabled while there are IP addresses in the White List' ), $this->getMainFeatureName() )
|
src/features/plugin.php
CHANGED
@@ -107,23 +107,28 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
107 |
|
108 |
if ( !$this->isVisitorAddressSourceAutoDetect() ) {
|
109 |
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
}
|
118 |
|
119 |
// If the address at this stage is null, then the current setting is failing for IP detection
|
120 |
// So we try and rediscover a more correct source for the Request IP Address.
|
121 |
if ( empty( $sIp ) ) {
|
122 |
-
$
|
123 |
-
|
124 |
-
if ( !empty( $
|
125 |
-
$oIpService->setRequestIpAddress( $
|
126 |
-
$this->setVisitorAddressSource( $
|
127 |
}
|
128 |
}
|
129 |
}
|
107 |
|
108 |
if ( !$this->isVisitorAddressSourceAutoDetect() ) {
|
109 |
|
110 |
+
$sMaybeIp = $oDp->server( $this->getVisitorAddressSource() );
|
111 |
+
|
112 |
+
if ( !empty( $sMaybeIp ) ) {
|
113 |
+
$aMaybeIps = array_map( 'trim', explode( ',', $sMaybeIp ) ); // TODO:streamline this comma handling
|
114 |
+
foreach ( $aMaybeIps as $sMaybeIp ) {
|
115 |
+
if ( $oIpService->isViablePublicVisitorIp( $sMaybeIp, $this->getMyServerIp() ) ) {
|
116 |
+
$oIpService->setRequestIpAddress( $sMaybeIp );
|
117 |
+
$sIp = $sMaybeIp;
|
118 |
+
break;
|
119 |
+
}
|
120 |
+
}
|
121 |
}
|
122 |
}
|
123 |
|
124 |
// If the address at this stage is null, then the current setting is failing for IP detection
|
125 |
// So we try and rediscover a more correct source for the Request IP Address.
|
126 |
if ( empty( $sIp ) ) {
|
127 |
+
$aSourceAndIp = $oIpService->setServerIpAddress( $this->getMyServerIp() )
|
128 |
+
->discoverViableRequestIpSource();
|
129 |
+
if ( !empty( $aSourceAndIp[ 'source' ] ) ) {
|
130 |
+
$oIpService->setRequestIpAddress( $aSourceAndIp[ 'ip' ] );
|
131 |
+
$this->setVisitorAddressSource( $aSourceAndIp[ 'source' ] );
|
132 |
}
|
133 |
}
|
134 |
}
|
src/features/traffic.php
CHANGED
@@ -279,7 +279,7 @@ class ICWP_WPSF_FeatureHandler_Traffic extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
279 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
280 |
$oTrafficPro = $this->loadProcessor();
|
281 |
$oSelector = $oTrafficPro->getProcessorLogger()
|
282 |
-
->
|
283 |
->setPage( $nPage )
|
284 |
->setOrderBy( $aParams[ 'orderby' ], $aParams[ 'order' ] )
|
285 |
->setLimit( $this->getDefaultPerPage() )
|
@@ -426,8 +426,8 @@ class ICWP_WPSF_FeatureHandler_Traffic extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
426 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
427 |
$oTrafficPro = $this->loadProcessor();
|
428 |
$nCount = $oTrafficPro->getProcessorLogger()
|
429 |
-
->
|
430 |
-
->
|
431 |
return ( new LiveTrafficTable() )->setTotalRecords( $nCount );
|
432 |
}
|
433 |
|
279 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
280 |
$oTrafficPro = $this->loadProcessor();
|
281 |
$oSelector = $oTrafficPro->getProcessorLogger()
|
282 |
+
->getQuerySelector()
|
283 |
->setPage( $nPage )
|
284 |
->setOrderBy( $aParams[ 'orderby' ], $aParams[ 'order' ] )
|
285 |
->setLimit( $this->getDefaultPerPage() )
|
426 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
427 |
$oTrafficPro = $this->loadProcessor();
|
428 |
$nCount = $oTrafficPro->getProcessorLogger()
|
429 |
+
->getQuerySelector()
|
430 |
+
->count();
|
431 |
return ( new LiveTrafficTable() )->setTotalRecords( $nCount );
|
432 |
}
|
433 |
|
src/features/user_management.php
CHANGED
@@ -27,7 +27,7 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
27 |
$sTimeFormat = $oWp->getTimeFormat();
|
28 |
$sDateFormat = $oWp->getDateFormat();
|
29 |
foreach ( $aActiveSessions as $oSession ) {
|
30 |
-
$aSession = (array)$oSession->
|
31 |
$aSession[ 'logged_in_at' ] = $oWp->getTimeStringForDisplay( $oSession->getLoggedInAt() );
|
32 |
$aSession[ 'last_activity_at' ] = $oWp->getTimeStringForDisplay( $oSession->getLastActivityAt() );
|
33 |
$aSession[ 'is_secadmin' ] = ( $oSession->getSecAdminAt() > 0 ) ? __( 'Yes' ) : __( 'No' );
|
27 |
$sTimeFormat = $oWp->getTimeFormat();
|
28 |
$sDateFormat = $oWp->getDateFormat();
|
29 |
foreach ( $aActiveSessions as $oSession ) {
|
30 |
+
$aSession = (array)$oSession->getRawData();
|
31 |
$aSession[ 'logged_in_at' ] = $oWp->getTimeStringForDisplay( $oSession->getLoggedInAt() );
|
32 |
$aSession[ 'last_activity_at' ] = $oWp->getTimeStringForDisplay( $oSession->getLastActivityAt() );
|
33 |
$aSession[ 'is_secadmin' ] = ( $oSession->getSecAdminAt() > 0 ) ? __( 'Yes' ) : __( 'No' );
|
src/processors/admin_access_restriction.php
CHANGED
@@ -24,15 +24,13 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
24 |
add_filter( 'pre_update_option', array( $this, 'blockOptionsSaves' ), 1, 3 );
|
25 |
}
|
26 |
|
27 |
-
// Setup all the sec admin hooks
|
28 |
-
add_action( 'init', array( $this, 'onWpInit' ) );
|
29 |
-
|
30 |
if ( $oFO->isWlEnabled() ) {
|
31 |
$this->runWhiteLabel();
|
32 |
}
|
33 |
}
|
34 |
|
35 |
public function onWpInit() {
|
|
|
36 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
37 |
$oFO = $this->getMod();
|
38 |
if ( !$this->loadWpUsers()->isUserLoggedIn() || $this->isSecurityAdmin() ) {
|
24 |
add_filter( 'pre_update_option', array( $this, 'blockOptionsSaves' ), 1, 3 );
|
25 |
}
|
26 |
|
|
|
|
|
|
|
27 |
if ( $oFO->isWlEnabled() ) {
|
28 |
$this->runWhiteLabel();
|
29 |
}
|
30 |
}
|
31 |
|
32 |
public function onWpInit() {
|
33 |
+
parent::onWpInit();
|
34 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
35 |
$oFO = $this->getMod();
|
36 |
if ( !$this->loadWpUsers()->isUserLoggedIn() || $this->isSecurityAdmin() ) {
|
src/processors/adminaccess_whitelabel.php
CHANGED
@@ -16,11 +16,11 @@ class ICWP_WPSF_Processor_AdminAccess_Whitelabel extends ICWP_WPSF_Processor_Bas
|
|
16 |
add_filter( $this->prefix( 'is_relabelled' ), '__return_true' );
|
17 |
add_filter( $oFO->prefix( 'plugin_labels' ), array( $this, 'doRelabelPlugin' ) );
|
18 |
add_filter( 'plugin_row_meta', array( $this, 'fRemoveDetailsMetaLink' ), 200, 2 );
|
19 |
-
add_action( 'init', array( $this, 'onWpInit' ) );
|
20 |
add_action( 'admin_print_footer_scripts-plugin-editor.php', array( $this, 'hideFromPluginEditor' ) );
|
21 |
}
|
22 |
|
23 |
public function onWpInit() {
|
|
|
24 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
25 |
$oFO = $this->getMod();
|
26 |
$oCon = $this->getController();
|
16 |
add_filter( $this->prefix( 'is_relabelled' ), '__return_true' );
|
17 |
add_filter( $oFO->prefix( 'plugin_labels' ), array( $this, 'doRelabelPlugin' ) );
|
18 |
add_filter( 'plugin_row_meta', array( $this, 'fRemoveDetailsMetaLink' ), 200, 2 );
|
|
|
19 |
add_action( 'admin_print_footer_scripts-plugin-editor.php', array( $this, 'hideFromPluginEditor' ) );
|
20 |
}
|
21 |
|
22 |
public function onWpInit() {
|
23 |
+
parent::onWpInit();
|
24 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
25 |
$oFO = $this->getMod();
|
26 |
$oCon = $this->getController();
|
src/processors/audit_trail.php
CHANGED
@@ -50,7 +50,7 @@ class ICWP_WPSF_Processor_AuditTrail extends ICWP_WPSF_BaseDbProcessor {
|
|
50 |
/** @var ICWP_WPSF_FeatureHandler_AuditTrail $oFO */
|
51 |
$oFO = $this->getMod();
|
52 |
try {
|
53 |
-
$this->
|
54 |
->deleteExcess( $oFO->getMaxEntries() );
|
55 |
}
|
56 |
catch ( Exception $oE ) {
|
@@ -109,26 +109,16 @@ class ICWP_WPSF_Processor_AuditTrail extends ICWP_WPSF_BaseDbProcessor {
|
|
109 |
}
|
110 |
}
|
111 |
|
112 |
-
/**
|
113 |
-
* @return array|bool
|
114 |
-
*/
|
115 |
-
public function getAllAuditEntries() {
|
116 |
-
return array_reverse( $this->selectAll() );
|
117 |
-
}
|
118 |
-
|
119 |
/**
|
120 |
* @param string $sContext
|
121 |
* @return array|bool
|
122 |
*/
|
123 |
public function countAuditEntriesForContext( $sContext ) {
|
124 |
-
$
|
125 |
-
$
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
%s `deleted_at` = 0
|
130 |
-
";
|
131 |
-
return $this->loadDbProcessor()->getVar( sprintf( $sQuery, $this->getTableName(), $sContext ) );
|
132 |
}
|
133 |
|
134 |
/**
|
@@ -137,46 +127,43 @@ class ICWP_WPSF_Processor_AuditTrail extends ICWP_WPSF_BaseDbProcessor {
|
|
137 |
* @param string $sOrder
|
138 |
* @param int $nPage
|
139 |
* @param int $nLimit
|
140 |
-
* @return
|
141 |
*/
|
142 |
public function getAuditEntriesForContext( $sContext, $sOrderBy = 'created_at', $sOrder = 'DESC', $nPage = 1, $nLimit = 50 ) {
|
143 |
-
$
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
$sContext = ( $sContext == 'all' ) ? '' : sprintf( "`context`= '%s' AND", $sContext );
|
154 |
-
|
155 |
-
$sQuery = sprintf( $sQuery, $this->getTableName(), $sContext, $sOrderBy, $sOrder, $nLimit, $sOffset );
|
156 |
-
return $this->selectCustom( $sQuery );
|
157 |
}
|
158 |
|
159 |
/**
|
|
|
160 |
*/
|
161 |
protected function commitAuditTrial() {
|
|
|
|
|
162 |
$aEntries = apply_filters(
|
163 |
$this->getMod()->prefix( 'collect_audit_trail' ),
|
164 |
$this->getBaseAuditor()->getAuditTrailEntries( true )
|
165 |
);
|
166 |
-
if ( empty( $aEntries ) || !is_array( $aEntries ) ) {
|
167 |
-
return;
|
168 |
-
}
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
177 |
}
|
178 |
-
$aEntry[ 'rid' ] = $sReqId;
|
179 |
-
$this->insertData( $aEntry );
|
180 |
}
|
181 |
}
|
182 |
|
@@ -225,27 +212,37 @@ class ICWP_WPSF_Processor_AuditTrail extends ICWP_WPSF_BaseDbProcessor {
|
|
225 |
}
|
226 |
|
227 |
/**
|
228 |
-
* @return
|
229 |
*/
|
230 |
-
|
231 |
-
$
|
232 |
-
$
|
233 |
-
|
|
|
234 |
}
|
235 |
|
236 |
/**
|
237 |
* @return ICWP_WPSF_Query_AuditTrail_Delete
|
238 |
*/
|
239 |
-
public function
|
240 |
$this->queryRequireLib( 'delete.php' );
|
241 |
$oQ = new ICWP_WPSF_Query_AuditTrail_Delete();
|
242 |
return $oQ->setTable( $this->getTableName() );
|
243 |
}
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
/**
|
246 |
* @return ICWP_WPSF_Query_AuditTrail_Select
|
247 |
*/
|
248 |
-
public function
|
249 |
$this->queryRequireLib( 'select.php' );
|
250 |
$oQ = new ICWP_WPSF_Query_AuditTrail_Select();
|
251 |
return $oQ->setTable( $this->getTableName() );
|
50 |
/** @var ICWP_WPSF_FeatureHandler_AuditTrail $oFO */
|
51 |
$oFO = $this->getMod();
|
52 |
try {
|
53 |
+
$this->getQueryDeleter()
|
54 |
->deleteExcess( $oFO->getMaxEntries() );
|
55 |
}
|
56 |
catch ( Exception $oE ) {
|
109 |
}
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
/**
|
113 |
* @param string $sContext
|
114 |
* @return array|bool
|
115 |
*/
|
116 |
public function countAuditEntriesForContext( $sContext ) {
|
117 |
+
$oCounter = $this->getQuerySelector();
|
118 |
+
if ( $sContext != 'all' ) {
|
119 |
+
$oCounter->filterByContext( $sContext );
|
120 |
+
}
|
121 |
+
return $oCounter->count();
|
|
|
|
|
|
|
122 |
}
|
123 |
|
124 |
/**
|
127 |
* @param string $sOrder
|
128 |
* @param int $nPage
|
129 |
* @param int $nLimit
|
130 |
+
* @return ICWP_WPSF_AuditTrailEntryVO[]
|
131 |
*/
|
132 |
public function getAuditEntriesForContext( $sContext, $sOrderBy = 'created_at', $sOrder = 'DESC', $nPage = 1, $nLimit = 50 ) {
|
133 |
+
$oSelect = $this->getQuerySelector()
|
134 |
+
->setResultsAsVo( true )
|
135 |
+
->setOrderBy( $sOrderBy, $sOrder )
|
136 |
+
->setLimit( $nLimit )
|
137 |
+
->setPage( $nPage );
|
138 |
+
if ( $sContext != 'all' ) {
|
139 |
+
$oSelect->filterByContext( $sContext );
|
140 |
+
}
|
141 |
+
|
142 |
+
return $oSelect->query();
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* TODO: maybe create audit Entry VO at the time of registering entries
|
147 |
*/
|
148 |
protected function commitAuditTrial() {
|
149 |
+
$oDp = $this->loadDP();
|
150 |
+
|
151 |
$aEntries = apply_filters(
|
152 |
$this->getMod()->prefix( 'collect_audit_trail' ),
|
153 |
$this->getBaseAuditor()->getAuditTrailEntries( true )
|
154 |
);
|
|
|
|
|
|
|
155 |
|
156 |
+
if ( !empty( $aEntries ) && is_array( $aEntries ) ) {
|
157 |
+
$sReqId = $this->getController()->getShortRequestId();
|
158 |
+
|
159 |
+
$oInsert = $this->getQueryInserter();
|
160 |
+
$oSelector = $this->getQuerySelector();
|
161 |
+
foreach ( $aEntries as $aE ) {
|
162 |
+
/** @var ICWP_WPSF_AuditTrailEntryVO $oEntry */
|
163 |
+
$oEntry = $oSelector->getVo()->setRawData( $oDp->convertArrayToStdClass( $aE ) );
|
164 |
+
$oEntry->rid = $sReqId;
|
165 |
+
$oInsert->insert( $oEntry );
|
166 |
}
|
|
|
|
|
167 |
}
|
168 |
}
|
169 |
|
212 |
}
|
213 |
|
214 |
/**
|
215 |
+
* @return ICWP_WPSF_AuditTrailEntryVO
|
216 |
*/
|
217 |
+
protected function getEntryVo() {
|
218 |
+
/** @var ICWP_WPSF_AuditTrailEntryVO $oVo */
|
219 |
+
$oVo = $this->getQuerySelector()
|
220 |
+
->getVo();
|
221 |
+
return $oVo;
|
222 |
}
|
223 |
|
224 |
/**
|
225 |
* @return ICWP_WPSF_Query_AuditTrail_Delete
|
226 |
*/
|
227 |
+
public function getQueryDeleter() {
|
228 |
$this->queryRequireLib( 'delete.php' );
|
229 |
$oQ = new ICWP_WPSF_Query_AuditTrail_Delete();
|
230 |
return $oQ->setTable( $this->getTableName() );
|
231 |
}
|
232 |
|
233 |
+
/**
|
234 |
+
* @return ICWP_WPSF_Query_AuditTrail_Insert
|
235 |
+
*/
|
236 |
+
public function getQueryInserter() {
|
237 |
+
$this->queryRequireLib( 'insert.php' );
|
238 |
+
$oQ = new ICWP_WPSF_Query_AuditTrail_Insert();
|
239 |
+
return $oQ->setTable( $this->getTableName() );
|
240 |
+
}
|
241 |
+
|
242 |
/**
|
243 |
* @return ICWP_WPSF_Query_AuditTrail_Select
|
244 |
*/
|
245 |
+
public function getQuerySelector() {
|
246 |
$this->queryRequireLib( 'select.php' );
|
247 |
$oQ = new ICWP_WPSF_Query_AuditTrail_Select();
|
248 |
return $oQ->setTable( $this->getTableName() );
|
src/processors/audit_trail_auditor_base.php
CHANGED
@@ -34,7 +34,7 @@ class ICWP_WPSF_AuditTrail_Auditor_Base extends ICWP_WPSF_Foundation {
|
|
34 |
|
35 |
$aNewEntry = array(
|
36 |
'ip' => $oDp->loadIpService()->getRequestIp(),
|
37 |
-
'created_at' => $oDp->
|
38 |
'wp_username' => $sWpUsername,
|
39 |
'context' => $sContext,
|
40 |
'event' => $sEvent,
|
34 |
|
35 |
$aNewEntry = array(
|
36 |
'ip' => $oDp->loadIpService()->getRequestIp(),
|
37 |
+
'created_at' => $oDp->time(),
|
38 |
'wp_username' => $sWpUsername,
|
39 |
'context' => $sContext,
|
40 |
'event' => $sEvent,
|
src/processors/base.php
CHANGED
@@ -37,12 +37,16 @@ abstract class ICWP_WPSF_Processor_Base extends ICWP_WPSF_Foundation {
|
|
37 |
add_action( $oModCon->prefix( 'generate_admin_notices' ), array( $this, 'addToAdminNotices' ) );
|
38 |
}
|
39 |
|
|
|
40 |
add_action( 'wp_login', array( $this, 'onWpLogin' ), 10, 2 );
|
41 |
add_action( 'set_logged_in_cookie', array( $this, 'onWpSetLoggedInCookie' ), 5, 4 );
|
42 |
|
43 |
$this->init();
|
44 |
}
|
45 |
|
|
|
|
|
|
|
46 |
/**
|
47 |
* @param string $sUsername
|
48 |
* @param WP_User $oUser
|
37 |
add_action( $oModCon->prefix( 'generate_admin_notices' ), array( $this, 'addToAdminNotices' ) );
|
38 |
}
|
39 |
|
40 |
+
add_action( 'init', array( $this, 'onWpInit' ) );
|
41 |
add_action( 'wp_login', array( $this, 'onWpLogin' ), 10, 2 );
|
42 |
add_action( 'set_logged_in_cookie', array( $this, 'onWpSetLoggedInCookie' ), 5, 4 );
|
43 |
|
44 |
$this->init();
|
45 |
}
|
46 |
|
47 |
+
public function onWpInit() {
|
48 |
+
}
|
49 |
+
|
50 |
/**
|
51 |
* @param string $sUsername
|
52 |
* @param WP_User $oUser
|
src/processors/base_commentsfilter.php
CHANGED
@@ -8,11 +8,6 @@ require_once( dirname( __FILE__ ).'/base_wpsf.php' );
|
|
8 |
|
9 |
class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
11 |
-
/**
|
12 |
-
* @var array
|
13 |
-
*/
|
14 |
-
static protected $aRawCommentData;
|
15 |
-
|
16 |
/**
|
17 |
* @var string
|
18 |
*/
|
@@ -36,7 +31,7 @@ class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWp
|
|
36 |
*/
|
37 |
public function run() {
|
38 |
$oFO = $this->getMod();
|
39 |
-
add_filter( 'preprocess_comment', array( $this, 'doCommentChecking' ),
|
40 |
add_filter( $oFO->prefix( 'cf_status' ), array( $this, 'getCommentStatus' ), 1 );
|
41 |
add_filter( $oFO->prefix( 'cf_status_expl' ), array( $this, 'getCommentStatusExplanation' ), 1 );
|
42 |
}
|
@@ -46,9 +41,6 @@ class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWp
|
|
46 |
* @return array
|
47 |
*/
|
48 |
public function doCommentChecking( $aCommentData ) {
|
49 |
-
if ( empty( self::$aRawCommentData ) ) {
|
50 |
-
self::$aRawCommentData = $aCommentData;
|
51 |
-
}
|
52 |
return $aCommentData;
|
53 |
}
|
54 |
|
@@ -68,20 +60,6 @@ class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWp
|
|
68 |
return self::$sCommentStatusExplanation;
|
69 |
}
|
70 |
|
71 |
-
/**
|
72 |
-
* @param string $sKey
|
73 |
-
* @return string|array|null
|
74 |
-
*/
|
75 |
-
protected function getRawCommentData( $sKey = '' ) {
|
76 |
-
if ( !isset( self::$aRawCommentData ) ) {
|
77 |
-
self::$aRawCommentData = array();
|
78 |
-
}
|
79 |
-
if ( !empty( $sKey ) ) {
|
80 |
-
return isset( self::$aRawCommentData[ $sKey ] ) ? self::$aRawCommentData[ $sKey ] : null;
|
81 |
-
}
|
82 |
-
return self::$aRawCommentData;
|
83 |
-
}
|
84 |
-
|
85 |
/**
|
86 |
* @return string
|
87 |
*/
|
8 |
|
9 |
class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* @var string
|
13 |
*/
|
31 |
*/
|
32 |
public function run() {
|
33 |
$oFO = $this->getMod();
|
34 |
+
add_filter( 'preprocess_comment', array( $this, 'doCommentChecking' ), 5 );
|
35 |
add_filter( $oFO->prefix( 'cf_status' ), array( $this, 'getCommentStatus' ), 1 );
|
36 |
add_filter( $oFO->prefix( 'cf_status_expl' ), array( $this, 'getCommentStatusExplanation' ), 1 );
|
37 |
}
|
41 |
* @return array
|
42 |
*/
|
43 |
public function doCommentChecking( $aCommentData ) {
|
|
|
|
|
|
|
44 |
return $aCommentData;
|
45 |
}
|
46 |
|
60 |
return self::$sCommentStatusExplanation;
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* @return string
|
65 |
*/
|
src/processors/basedb.php
CHANGED
@@ -4,7 +4,7 @@ if ( class_exists( 'ICWP_WPSF_BaseDbProcessor', false ) ) {
|
|
4 |
return;
|
5 |
}
|
6 |
|
7 |
-
require_once( dirname( __FILE__ ).
|
8 |
|
9 |
abstract class ICWP_WPSF_BaseDbProcessor extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
@@ -90,78 +90,19 @@ abstract class ICWP_WPSF_BaseDbProcessor extends ICWP_WPSF_Processor_BaseWpsf {
|
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
* @param
|
94 |
-
* @return bool
|
95 |
-
*/
|
96 |
-
public function insertData( $aData ) {
|
97 |
-
return $this->loadDbProcessor()->insertDataIntoTable( $this->getTableName(), $aData );
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Returns all active, non-deleted rows
|
102 |
-
* @return array
|
103 |
-
*/
|
104 |
-
public function selectAll() {
|
105 |
-
return $this->query_selectAll();
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @param array $aColumns Leave empty to select all (*) columns
|
110 |
-
* @param bool $bExcludeDeletedRows
|
111 |
-
* @return array
|
112 |
-
*/
|
113 |
-
protected function query_selectAll( $aColumns = array(), $bExcludeDeletedRows = true ) {
|
114 |
-
|
115 |
-
// Try to get the database entry that corresponds to this set of data. If we get nothing, fail.
|
116 |
-
$sQuery = "SELECT %s FROM `%s` %s";
|
117 |
-
|
118 |
-
$aColumns = $this->validateColumnsParameter( $aColumns );
|
119 |
-
$sColumnsSelection = empty( $aColumns ) ? '*' : implode( ',', $aColumns );
|
120 |
-
|
121 |
-
$sQuery = sprintf( $sQuery,
|
122 |
-
$sColumnsSelection,
|
123 |
-
$this->getTableName(),
|
124 |
-
( $bExcludeDeletedRows && $this->getHasColumn( 'deleted_at' ) ) ? "WHERE `deleted_at` = 0" : ''
|
125 |
-
);
|
126 |
-
$mResult = $this->selectCustom( $sQuery );
|
127 |
-
return ( is_array( $mResult ) && isset( $mResult[ 0 ] ) ) ? $mResult : array();
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* @param string $sQuery
|
132 |
-
* @param $nFormat
|
133 |
-
* @return array|boolean
|
134 |
-
*/
|
135 |
-
public function selectCustom( $sQuery, $nFormat = ARRAY_A ) {
|
136 |
-
return $this->loadDbProcessor()->selectCustom( $sQuery, $nFormat );
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param array $aData - new insert data (associative array, column=>data)
|
141 |
-
* @param array $aWhere - insert where (associative array)
|
142 |
-
* @return integer|boolean (number of rows affected)
|
143 |
*/
|
144 |
-
|
145 |
-
return $this->
|
|
|
|
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
-
* @
|
150 |
-
* @return bool|int
|
151 |
*/
|
152 |
-
protected function
|
153 |
-
$sQuery = "
|
154 |
-
DELETE from `%s`
|
155 |
-
WHERE
|
156 |
-
`created_at` < '%s'
|
157 |
-
";
|
158 |
-
$sQuery = sprintf(
|
159 |
-
$sQuery,
|
160 |
-
$this->getTableName(),
|
161 |
-
esc_sql( $nTimeStamp )
|
162 |
-
);
|
163 |
-
return $this->loadDbProcessor()->doSql( $sQuery );
|
164 |
-
}
|
165 |
|
166 |
/**
|
167 |
* @return string
|
@@ -269,7 +210,7 @@ abstract class ICWP_WPSF_BaseDbProcessor extends ICWP_WPSF_Processor_BaseWpsf {
|
|
269 |
return false;
|
270 |
}
|
271 |
$nTimeStamp = $this->time() - $nAutoExpirePeriod;
|
272 |
-
return $this->
|
273 |
}
|
274 |
|
275 |
/**
|
4 |
return;
|
5 |
}
|
6 |
|
7 |
+
require_once( dirname( __FILE__ ).'/base_wpsf.php' );
|
8 |
|
9 |
abstract class ICWP_WPSF_BaseDbProcessor extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* @param int $nTimeStamp
|
94 |
+
* @return bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
*/
|
96 |
+
protected function deleteRowsOlderThan( $nTimeStamp ) {
|
97 |
+
return $this->getQueryDeleter()
|
98 |
+
->addWhereOlderThan( $nTimeStamp )
|
99 |
+
->query();
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* @return ICWP_WPSF_Query_BaseDelete
|
|
|
104 |
*/
|
105 |
+
abstract protected function getQueryDeleter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
/**
|
108 |
* @return string
|
210 |
return false;
|
211 |
}
|
212 |
$nTimeStamp = $this->time() - $nAutoExpirePeriod;
|
213 |
+
return $this->deleteRowsOlderThan( $nTimeStamp );
|
214 |
}
|
215 |
|
216 |
/**
|
src/processors/comments_filter.php
CHANGED
@@ -11,9 +11,17 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
11 |
/**
|
12 |
*/
|
13 |
public function run() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
15 |
$oFO = $this->getMod();
|
16 |
-
add_filter( $oFO->prefix( 'if-do-comments-check' ), array( $this, 'getIfDoCommentsCheck' ) );
|
17 |
|
18 |
if ( $oFO->isEnabledGaspCheck() ) {
|
19 |
require_once( dirname( __FILE__ ).'/commentsfilter_antibotspam.php' );
|
@@ -27,27 +35,15 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
27 |
$oHumanSpamProcessor->run();
|
28 |
}
|
29 |
|
30 |
-
if ( $oFO->isGoogleRecaptchaEnabled() ) {
|
31 |
require_once( dirname( __FILE__ ).'/commentsfilter_googlerecaptcha.php' );
|
32 |
-
$
|
33 |
-
$
|
34 |
}
|
35 |
|
36 |
add_filter( 'pre_comment_approved', array( $this, 'doSetCommentStatus' ), 1 );
|
37 |
add_filter( 'pre_comment_content', array( $this, 'doInsertCommentStatusExplanation' ), 1, 1 );
|
38 |
-
add_filter( 'comment_notification_recipients', array(
|
39 |
-
$this,
|
40 |
-
'doClearCommentNotificationEmail_Filter'
|
41 |
-
), 100, 1 );
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Always default to true, and if false, return that.
|
46 |
-
* @param boolean $bDoCheck
|
47 |
-
* @return boolean
|
48 |
-
*/
|
49 |
-
public function getIfDoCommentsCheck( $bDoCheck ) {
|
50 |
-
return $bDoCheck && !$this->loadWpUsers()->isUserLoggedIn();
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -112,7 +108,7 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
112 |
* @param array $aEmails
|
113 |
* @return array
|
114 |
*/
|
115 |
-
public function
|
116 |
$sStatus = apply_filters( $this->getMod()->prefix( 'cf_status' ), '' );
|
117 |
if ( in_array( $sStatus, array( 'reject', 'trash' ) ) ) {
|
118 |
$aEmails = array();
|
11 |
/**
|
12 |
*/
|
13 |
public function run() {
|
14 |
+
}
|
15 |
+
|
16 |
+
public function onWpInit() {
|
17 |
+
parent::onWpInit();
|
18 |
+
|
19 |
+
if ( $this->loadWpUsers()->isUserLoggedIn() ) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
24 |
$oFO = $this->getMod();
|
|
|
25 |
|
26 |
if ( $oFO->isEnabledGaspCheck() ) {
|
27 |
require_once( dirname( __FILE__ ).'/commentsfilter_antibotspam.php' );
|
35 |
$oHumanSpamProcessor->run();
|
36 |
}
|
37 |
|
38 |
+
if ( $oFO->isGoogleRecaptchaEnabled() && $oFO->isGoogleRecaptchaReady() ) {
|
39 |
require_once( dirname( __FILE__ ).'/commentsfilter_googlerecaptcha.php' );
|
40 |
+
$oReCap = new ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha( $oFO );
|
41 |
+
$oReCap->run();
|
42 |
}
|
43 |
|
44 |
add_filter( 'pre_comment_approved', array( $this, 'doSetCommentStatus' ), 1 );
|
45 |
add_filter( 'pre_comment_content', array( $this, 'doInsertCommentStatusExplanation' ), 1, 1 );
|
46 |
+
add_filter( 'comment_notification_recipients', array( $this, 'clearCommentNotificationEmail' ), 100, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
108 |
* @param array $aEmails
|
109 |
* @return array
|
110 |
*/
|
111 |
+
public function clearCommentNotificationEmail( $aEmails ) {
|
112 |
$sStatus = apply_filters( $this->getMod()->prefix( 'cf_status' ), '' );
|
113 |
if ( in_array( $sStatus, array( 'reject', 'trash' ) ) ) {
|
114 |
$aEmails = array();
|
src/processors/commentsfilter_antibotspam.php
CHANGED
@@ -8,12 +8,6 @@ require_once( dirname( __FILE__ ).'/basedb.php' );
|
|
8 |
|
9 |
class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbProcessor {
|
10 |
|
11 |
-
/**
|
12 |
-
* The unique comment token assigned to this page
|
13 |
-
* @var integer
|
14 |
-
*/
|
15 |
-
protected $sUniqueCommentToken;
|
16 |
-
|
17 |
/**
|
18 |
* The unique comment token assigned to this page
|
19 |
* @var string
|
@@ -30,11 +24,6 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
30 |
*/
|
31 |
protected $sCommentStatusExplanation;
|
32 |
|
33 |
-
/**
|
34 |
-
* @var array
|
35 |
-
*/
|
36 |
-
private $aRawCommentData;
|
37 |
-
|
38 |
/**
|
39 |
* @param ICWP_WPSF_FeatureHandler_CommentsFilter $oModCon
|
40 |
*/
|
@@ -42,70 +31,23 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
42 |
parent::__construct( $oModCon, $oModCon->getCommentsFilterTableName() );
|
43 |
}
|
44 |
|
45 |
-
/**
|
46 |
-
* Resets the object values to be re-used anew
|
47 |
-
*/
|
48 |
-
public function init() {
|
49 |
-
parent::init();
|
50 |
-
$this->getUniqueCommentToken(); //ensures the necessary cookie is set early
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @param bool $fIfDoCheck
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
public function getIfDoCommentsCheck( $fIfDoCheck ) {
|
58 |
-
if ( !$fIfDoCheck ) {
|
59 |
-
return $fIfDoCheck;
|
60 |
-
}
|
61 |
-
|
62 |
-
$oWpComments = $this->loadWpComments();
|
63 |
-
|
64 |
-
// 1st are comments enabled on this post?
|
65 |
-
$nPostId = $this->getRawCommentData( 'comment_post_ID' );
|
66 |
-
$oPost = $nPostId ? $this->loadWp()->getPostById( $nPostId ) : null;
|
67 |
-
if ( $oPost ) {
|
68 |
-
$fIfDoCheck = $oWpComments->isCommentsOpen( $oPost );
|
69 |
-
}
|
70 |
-
|
71 |
-
if ( $fIfDoCheck && $oWpComments->getIfCommentsMustBePreviouslyApproved()
|
72 |
-
&& $oWpComments->isCommentAuthorPreviouslyApproved( $this->getRawCommentData( 'comment_author_email' ) ) ) {
|
73 |
-
$fIfDoCheck = false;
|
74 |
-
}
|
75 |
-
|
76 |
-
return $fIfDoCheck;
|
77 |
-
}
|
78 |
-
|
79 |
/**
|
80 |
*/
|
81 |
public function run() {
|
82 |
-
if (
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
add_filter( $this->getMod()->prefix( 'if-do-comments-check' ), array( $this, 'getIfDoCommentsCheck' ) );
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
add_filter( $this->getMod()->prefix( 'cf_status' ), array( $this, 'getCommentStatus' ), 1 );
|
94 |
-
add_filter( $this->getMod()->prefix( 'cf_status_expl' ), array( $this, 'getCommentStatusExplanation' ), 1 );
|
95 |
}
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
*/
|
101 |
-
public function getRawCommentData( $sKey = '' ) {
|
102 |
-
if ( !isset( $this->aRawCommentData ) ) {
|
103 |
-
$this->aRawCommentData = array();
|
104 |
}
|
105 |
-
if ( !empty( $sKey ) ) {
|
106 |
-
return isset( $this->aRawCommentData[ $sKey ] ) ? $this->aRawCommentData[ $sKey ] : null;
|
107 |
-
}
|
108 |
-
return $this->aRawCommentData;
|
109 |
}
|
110 |
|
111 |
/**
|
@@ -131,20 +73,17 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
131 |
* @return array
|
132 |
*/
|
133 |
public function doCommentChecking( $aCommentData ) {
|
134 |
-
$this->aRawCommentData = $aCommentData;
|
135 |
-
|
136 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
137 |
$oFO = $this->getMod();
|
138 |
-
if ( !$oFO->getIfDoCommentsCheck() ) {
|
139 |
-
return $aCommentData;
|
140 |
-
}
|
141 |
|
142 |
-
$
|
|
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
|
|
148 |
}
|
149 |
|
150 |
return $aCommentData;
|
@@ -155,7 +94,6 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
155 |
* @param $nPostId
|
156 |
*/
|
157 |
protected function doGaspCommentCheck( $nPostId ) {
|
158 |
-
|
159 |
if ( !$this->getIfDoGaspCheck() ) {
|
160 |
return;
|
161 |
}
|
@@ -164,7 +102,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
164 |
$oFO = $this->getMod();
|
165 |
|
166 |
// Check that we haven't already marked the comment through another scan
|
167 |
-
if ( !empty( $this->sCommentStatus )
|
168 |
return;
|
169 |
}
|
170 |
|
@@ -175,7 +113,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
175 |
$oDp = $this->loadDP();
|
176 |
$sFieldCheckboxName = $oDp->post( 'cb_nombre' );
|
177 |
$sFieldHoney = $oDp->post( 'sugar_sweet_email' );
|
178 |
-
$
|
179 |
|
180 |
// we have the cb name, is it set?
|
181 |
if ( !$sFieldCheckboxName || !$oDp->post( $sFieldCheckboxName ) ) {
|
@@ -188,7 +126,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
188 |
$sStatKey = 'honeypot';
|
189 |
}
|
190 |
// check the unique comment token is present
|
191 |
-
else if ( $oFO->getIfCheckCommentToken() &&
|
192 |
$sExplanation = sprintf( _wpsf__( 'Failed GASP Bot Filter Test (%s)' ), _wpsf__( 'comment token failure' ) );
|
193 |
$sStatKey = 'token';
|
194 |
}
|
@@ -205,15 +143,12 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
205 |
}
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
return;
|
214 |
}
|
215 |
-
$this->insertUniquePostCommentToken();
|
216 |
-
echo $this->getGaspCommentsHookHtml();
|
217 |
}
|
218 |
|
219 |
/**
|
@@ -223,56 +158,40 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
223 |
protected function getIfDoGaspCheck() {
|
224 |
$bCheck = true;
|
225 |
|
226 |
-
if (
|
227 |
-
$bCheck = false;
|
228 |
-
}
|
229 |
-
else if ( $this->loadWpUsers()->isUserLoggedIn() ) {
|
230 |
-
$bCheck = false;
|
231 |
-
}
|
232 |
-
else if ( function_exists( 'WPWall_Init' ) ) {
|
233 |
-
// Compatibility with shoutbox WP Wall Plugin http://wordpress.org/plugins/wp-wall/
|
234 |
-
if ( !is_null( $this->loadDP()->post( 'submit_wall_post' ) ) ) {
|
235 |
-
$bCheck = false;
|
236 |
-
}
|
237 |
}
|
238 |
|
239 |
return $bCheck;
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
-
* @return
|
244 |
*/
|
245 |
-
protected function
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
apply_filters( 'icwp_shield_cf_gasp_uniqid', $sId ) );
|
252 |
-
}
|
253 |
-
return $this->sFormId;
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
-
* @
|
|
|
258 |
*/
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
|
|
|
|
264 |
}
|
265 |
|
266 |
/**
|
267 |
* @return string
|
268 |
*/
|
269 |
-
protected function getGaspCommentsHookHtml() {
|
270 |
-
$sReturn = '<p id="'.$this->getUniqueFormId().'"></p>'; // we use this unique <p> to hook onto using javascript
|
271 |
-
$sReturn .= '<input type="hidden" id="_sugar_sweet_email" name="sugar_sweet_email" value="" />';
|
272 |
-
$sReturn .= sprintf( '<input type="hidden" id="_comment_token" name="comment_token" value="%s" />', $this->getUniqueCommentToken() );
|
273 |
-
return $sReturn;
|
274 |
-
}
|
275 |
-
|
276 |
protected function getGaspCommentsHtml() {
|
277 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
278 |
$oFO = $this->getMod();
|
@@ -283,8 +202,8 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
283 |
$sCommentWait = $oFO->getTextOpt( 'custom_message_comment_wait' );
|
284 |
$sCommentReload = $oFO->getTextOpt( 'custom_message_comment_reload' );
|
285 |
|
286 |
-
$nCooldown = $
|
287 |
-
$nExpire = $
|
288 |
|
289 |
$sJsCommentWait = '"'.str_replace( '%s', '"+nRemaining+"', $sCommentWait ).'"';
|
290 |
$sCommentWait = str_replace( '%s', $nCooldown, $sCommentWait ); // don't use sprintf for errors.
|
@@ -373,49 +292,55 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
373 |
}
|
374 |
|
375 |
/**
|
376 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
* @param $sPostId
|
378 |
* @return bool
|
379 |
*/
|
380 |
-
protected function checkCommentToken( $
|
381 |
-
|
382 |
-
$
|
383 |
-
|
384 |
-
// Try to get the database entry that corresponds to this set of data. If we get nothing, fail.
|
385 |
-
$sQuery = "
|
386 |
-
SELECT *
|
387 |
-
FROM `%s`
|
388 |
-
WHERE
|
389 |
-
`unique_token` = '%s'
|
390 |
-
AND `post_id` = '%s'
|
391 |
-
AND `ip` = '%s'
|
392 |
-
AND `deleted_at` = '0'
|
393 |
-
";
|
394 |
-
$sQuery = sprintf( $sQuery,
|
395 |
-
$this->getTableName(),
|
396 |
-
$sToken,
|
397 |
-
$sPostId,
|
398 |
-
$this->ip()
|
399 |
-
);
|
400 |
-
$mResult = $this->selectCustom( $sQuery );
|
401 |
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
//
|
407 |
-
$this->
|
408 |
-
|
409 |
-
|
410 |
-
$
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
)
|
415 |
-
|
416 |
-
}
|
417 |
-
return true;
|
418 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
}
|
420 |
|
421 |
/**
|
@@ -439,20 +364,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
439 |
*/
|
440 |
protected function getTableColumnsByDefinition() {
|
441 |
$aDef = $this->getMod()->getDef( 'spambot_comments_filter_table_columns' );
|
442 |
-
return
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
* @param string $sUniqueToken
|
447 |
-
* @param string $sPostId
|
448 |
-
* @return bool|int
|
449 |
-
*/
|
450 |
-
protected function deleteUniquePostCommentToken( $sUniqueToken, $sPostId ) {
|
451 |
-
$aWhere = array(
|
452 |
-
'unique_token' => $sUniqueToken,
|
453 |
-
'post_id' => $sPostId
|
454 |
-
);
|
455 |
-
return $this->loadDbProcessor()->deleteRowsFromTableWhere( $this->getTableName(), $aWhere );
|
456 |
}
|
457 |
|
458 |
/**
|
@@ -467,27 +379,6 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
467 |
return $this->loadDbProcessor()->deleteRowsFromTableWhere( $this->getTableName(), $aWhere );
|
468 |
}
|
469 |
|
470 |
-
/**
|
471 |
-
* @return bool|int
|
472 |
-
*/
|
473 |
-
protected function insertUniquePostCommentToken() {
|
474 |
-
$aData = array(
|
475 |
-
'post_id' => $this->loadWp()->getCurrentPostId(),
|
476 |
-
'unique_token' => $this->getUniqueCommentToken(),
|
477 |
-
'ip' => $this->ip(),
|
478 |
-
'created_at' => $this->time()
|
479 |
-
);
|
480 |
-
return $this->insertData( $aData );
|
481 |
-
}
|
482 |
-
|
483 |
-
/**
|
484 |
-
* @alias $this->getController()->getUniqueRequestId();
|
485 |
-
* @return string
|
486 |
-
*/
|
487 |
-
protected function getUniqueCommentToken() {
|
488 |
-
return $this->getController()->getUniqueRequestId();
|
489 |
-
}
|
490 |
-
|
491 |
/**
|
492 |
* @param $sExplanation
|
493 |
*/
|
@@ -505,6 +396,43 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
505 |
* @return int
|
506 |
*/
|
507 |
protected function getAutoExpirePeriod() {
|
508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
}
|
510 |
}
|
8 |
|
9 |
class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbProcessor {
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* The unique comment token assigned to this page
|
13 |
* @var string
|
24 |
*/
|
25 |
protected $sCommentStatusExplanation;
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
/**
|
28 |
* @param ICWP_WPSF_FeatureHandler_CommentsFilter $oModCon
|
29 |
*/
|
31 |
parent::__construct( $oModCon, $oModCon->getCommentsFilterTableName() );
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
*/
|
36 |
public function run() {
|
37 |
+
if ( $this->isReadyToRun() ) {
|
38 |
+
// Add GASP checking to the comment form.
|
39 |
+
add_action( 'wp', array( $this, 'setupForm' ) );
|
|
|
|
|
40 |
|
41 |
+
add_filter( 'preprocess_comment', array( $this, 'doCommentChecking' ), 5 );
|
42 |
+
add_filter( $this->getMod()->prefix( 'cf_status' ), array( $this, 'getCommentStatus' ), 1 );
|
43 |
+
add_filter( $this->getMod()->prefix( 'cf_status_expl' ), array( $this, 'getCommentStatusExplanation' ), 1 );
|
44 |
+
}
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
+
public function setupForm() {
|
48 |
+
if ( !$this->loadDP()->isMethodPost() && $this->getIfDoGaspCheck() ) {
|
49 |
+
add_action( 'comment_form', array( $this, 'printGaspFormItems' ), 1 );
|
|
|
|
|
|
|
|
|
50 |
}
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
/**
|
73 |
* @return array
|
74 |
*/
|
75 |
public function doCommentChecking( $aCommentData ) {
|
|
|
|
|
76 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
77 |
$oFO = $this->getMod();
|
|
|
|
|
|
|
78 |
|
79 |
+
if ( $oFO->getIfDoCommentsCheck() ) {
|
80 |
+
$this->doGaspCommentCheck( $oFO->getCommentItem( 'comment_post_ID' ) );
|
81 |
|
82 |
+
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
83 |
+
if ( $this->sCommentStatus == 'reject' ) {
|
84 |
+
$oWp = $this->loadWp();
|
85 |
+
$oWp->doRedirect( $oWp->getHomeUrl(), array(), true, false );
|
86 |
+
}
|
87 |
}
|
88 |
|
89 |
return $aCommentData;
|
94 |
* @param $nPostId
|
95 |
*/
|
96 |
protected function doGaspCommentCheck( $nPostId ) {
|
|
|
97 |
if ( !$this->getIfDoGaspCheck() ) {
|
98 |
return;
|
99 |
}
|
102 |
$oFO = $this->getMod();
|
103 |
|
104 |
// Check that we haven't already marked the comment through another scan
|
105 |
+
if ( !empty( $this->sCommentStatus ) ) {
|
106 |
return;
|
107 |
}
|
108 |
|
113 |
$oDp = $this->loadDP();
|
114 |
$sFieldCheckboxName = $oDp->post( 'cb_nombre' );
|
115 |
$sFieldHoney = $oDp->post( 'sugar_sweet_email' );
|
116 |
+
$sCommentToken = $oDp->post( 'comment_token' );
|
117 |
|
118 |
// we have the cb name, is it set?
|
119 |
if ( !$sFieldCheckboxName || !$oDp->post( $sFieldCheckboxName ) ) {
|
126 |
$sStatKey = 'honeypot';
|
127 |
}
|
128 |
// check the unique comment token is present
|
129 |
+
else if ( $oFO->getIfCheckCommentToken() && !$this->checkCommentToken( $sCommentToken, $nPostId ) ) {
|
130 |
$sExplanation = sprintf( _wpsf__( 'Failed GASP Bot Filter Test (%s)' ), _wpsf__( 'comment token failure' ) );
|
131 |
$sStatKey = 'token';
|
132 |
}
|
143 |
}
|
144 |
}
|
145 |
|
146 |
+
public function printGaspFormItems() {
|
147 |
+
$oToken = $this->initCommentFormToken();
|
148 |
+
if ( $oToken instanceof ICWP_WPSF_CommentsEntryVO ) {
|
149 |
+
echo $this->getGaspCommentsHookHtml( $oToken );
|
150 |
+
echo $this->getGaspCommentsHtml();
|
|
|
151 |
}
|
|
|
|
|
152 |
}
|
153 |
|
154 |
/**
|
158 |
protected function getIfDoGaspCheck() {
|
159 |
$bCheck = true;
|
160 |
|
161 |
+
if ( function_exists( 'WPWall_Init' ) && !is_null( $this->loadDP()->post( 'submit_wall_post' ) ) ) {
|
162 |
+
$bCheck = false; // Compatibility with shoutbox WP Wall Plugin http://wordpress.org/plugins/wp-wall/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
return $bCheck;
|
166 |
}
|
167 |
|
168 |
/**
|
169 |
+
* @return ICWP_WPSF_CommentsEntryVO|null
|
170 |
*/
|
171 |
+
protected function initCommentFormToken() {
|
172 |
+
/** @var ICWP_WPSF_CommentsEntryVO $oToken */
|
173 |
+
$oToken = $this->getQuerySelector()->getVo();
|
174 |
+
$oToken->post_id = $this->loadWp()->getCurrentPostId();
|
175 |
+
$oToken->unique_token = md5( $this->getController()->getUniqueRequestId( false ) );
|
176 |
+
return $this->getQueryInserter()->insert( $oToken ) ? $oToken : null;
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
/**
|
180 |
+
* @param ICWP_WPSF_CommentsEntryVO $oToken
|
181 |
+
* @return string
|
182 |
*/
|
183 |
+
protected function getGaspCommentsHookHtml( $oToken ) {
|
184 |
+
$aHtml = array(
|
185 |
+
'<p id="'.$this->getUniqueFormId().'"></p>', // we use this unique <p> to hook onto using javascript
|
186 |
+
'<input type="hidden" id="_sugar_sweet_email" name="sugar_sweet_email" value="" />',
|
187 |
+
sprintf( '<input type="hidden" id="_comment_token" name="comment_token" value="%s" />', $oToken->getToken() )
|
188 |
+
);
|
189 |
+
return implode( '', $aHtml );
|
190 |
}
|
191 |
|
192 |
/**
|
193 |
* @return string
|
194 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
protected function getGaspCommentsHtml() {
|
196 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
197 |
$oFO = $this->getMod();
|
202 |
$sCommentWait = $oFO->getTextOpt( 'custom_message_comment_wait' );
|
203 |
$sCommentReload = $oFO->getTextOpt( 'custom_message_comment_reload' );
|
204 |
|
205 |
+
$nCooldown = $oFO->getTokenCooldown();
|
206 |
+
$nExpire = $oFO->getTokenExpireInterval();
|
207 |
|
208 |
$sJsCommentWait = '"'.str_replace( '%s', '"+nRemaining+"', $sCommentWait ).'"';
|
209 |
$sCommentWait = str_replace( '%s', $nCooldown, $sCommentWait ); // don't use sprintf for errors.
|
292 |
}
|
293 |
|
294 |
/**
|
295 |
+
* @return string
|
296 |
+
*/
|
297 |
+
protected function getUniqueFormId() {
|
298 |
+
if ( !isset( $this->sFormId ) ) {
|
299 |
+
$oDp = $this->loadDP();
|
300 |
+
$sId = $oDp->generateRandomLetter().$oDp->generateRandomString( rand( 7, 23 ), 7 );
|
301 |
+
$this->sFormId = preg_replace(
|
302 |
+
'#[^a-zA-Z0-9]#', '',
|
303 |
+
apply_filters( 'icwp_shield_cf_gasp_uniqid', $sId ) );
|
304 |
+
}
|
305 |
+
return $this->sFormId;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* @param string $sToken
|
310 |
* @param $sPostId
|
311 |
* @return bool
|
312 |
*/
|
313 |
+
protected function checkCommentToken( $sToken, $sPostId ) {
|
314 |
+
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
315 |
+
$oFO = $this->getMod();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
|
317 |
+
$bValidToken = false;
|
318 |
+
|
319 |
+
$oToken = $this->getPostCommentToken( $sToken, $sPostId );
|
320 |
+
if ( $oToken instanceof ICWP_WPSF_CommentsEntryVO ) {
|
321 |
+
// Did sufficient time pass and is it not-expired?
|
322 |
+
$nAge = $this->time() - $oToken->getCreatedAt();
|
323 |
+
$nExpires = $oFO->getTokenExpireInterval();
|
324 |
+
|
325 |
+
$bValidToken = ( $nAge > $oFO->getTokenCooldown() )
|
326 |
+
&& ( $nExpires < 1 || $nAge < $nExpires );
|
327 |
+
|
328 |
+
// Tokens are 1 time only.
|
329 |
+
$this->getQueryDeleter()
|
330 |
+
->deleteToken( $oToken );
|
|
|
|
|
331 |
}
|
332 |
+
|
333 |
+
return $bValidToken;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* @param string $sCommentToken
|
338 |
+
* @param int $sPostId
|
339 |
+
* @return ICWP_WPSF_CommentsEntryVO|null
|
340 |
+
*/
|
341 |
+
private function getPostCommentToken( $sCommentToken, $sPostId ) {
|
342 |
+
return $this->getQuerySelector()
|
343 |
+
->getTokenForPost( $sCommentToken, $sPostId, $this->ip() );
|
344 |
}
|
345 |
|
346 |
/**
|
364 |
*/
|
365 |
protected function getTableColumnsByDefinition() {
|
366 |
$aDef = $this->getMod()->getDef( 'spambot_comments_filter_table_columns' );
|
367 |
+
return is_array( $aDef ) ? $aDef : array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
|
370 |
/**
|
379 |
return $this->loadDbProcessor()->deleteRowsFromTableWhere( $this->getTableName(), $aWhere );
|
380 |
}
|
381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
/**
|
383 |
* @param $sExplanation
|
384 |
*/
|
396 |
* @return int
|
397 |
*/
|
398 |
protected function getAutoExpirePeriod() {
|
399 |
+
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
400 |
+
$oFO = $this->getMod();
|
401 |
+
return $oFO->getTokenExpireInterval();
|
402 |
+
}
|
403 |
+
|
404 |
+
/**
|
405 |
+
* @return ICWP_WPSF_Query_Comments_Delete
|
406 |
+
*/
|
407 |
+
public function getQueryDeleter() {
|
408 |
+
$this->queryRequireLib( 'delete.php' );
|
409 |
+
$oQ = new ICWP_WPSF_Query_Comments_Delete();
|
410 |
+
return $oQ->setTable( $this->getTableName() );
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* @return ICWP_WPSF_Query_Comments_Insert
|
415 |
+
*/
|
416 |
+
public function getQueryInserter() {
|
417 |
+
$this->queryRequireLib( 'insert.php' );
|
418 |
+
$oQ = new ICWP_WPSF_Query_Comments_Insert();
|
419 |
+
return $oQ->setTable( $this->getTableName() );
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* @return ICWP_WPSF_Query_Comments_Select
|
424 |
+
*/
|
425 |
+
public function getQuerySelector() {
|
426 |
+
$this->queryRequireLib( 'select.php' );
|
427 |
+
$oQ = new ICWP_WPSF_Query_Comments_Select();
|
428 |
+
return $oQ->setTable( $this->getTableName() )
|
429 |
+
->setResultsAsVo( true );
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* @return string
|
434 |
+
*/
|
435 |
+
protected function queryGetDir() {
|
436 |
+
return parent::queryGetDir().'comments/';
|
437 |
}
|
438 |
}
|
src/processors/commentsfilter_googlerecaptcha.php
CHANGED
@@ -11,13 +11,7 @@ class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Proce
|
|
11 |
/**
|
12 |
*/
|
13 |
public function run() {
|
14 |
-
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
15 |
-
$oFO = $this->getMod();
|
16 |
-
if ( !$oFO->isGoogleRecaptchaReady() ) {
|
17 |
-
return;
|
18 |
-
}
|
19 |
parent::run();
|
20 |
-
|
21 |
add_action( 'wp', array( $this, 'setup' ) );
|
22 |
}
|
23 |
|
@@ -58,42 +52,32 @@ class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Proce
|
|
58 |
* @return array
|
59 |
*/
|
60 |
public function doCommentChecking( $aCommentData ) {
|
61 |
-
parent::doCommentChecking( $aCommentData );
|
62 |
-
|
63 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
64 |
$oFO = $this->getMod();
|
65 |
-
if ( !$oFO->getIfDoCommentsCheck() ) {
|
66 |
-
return $aCommentData;
|
67 |
-
}
|
68 |
|
69 |
-
$
|
70 |
-
$sStatKey = '';
|
71 |
-
$sExplanation = '';
|
72 |
-
try {
|
73 |
-
$this->checkRequestRecaptcha();
|
74 |
-
}
|
75 |
-
catch ( Exception $oE ) {
|
76 |
-
$sStatKey = ( $oE->getCode() == 1 ) ? 'empty' : 'failed';
|
77 |
-
$sExplanation = $oE->getMessage();
|
78 |
-
$bIsSpam = true;
|
79 |
-
}
|
80 |
-
|
81 |
-
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
|
|
90 |
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
95 |
}
|
96 |
}
|
|
|
97 |
return $aCommentData;
|
98 |
}
|
99 |
}
|
11 |
/**
|
12 |
*/
|
13 |
public function run() {
|
|
|
|
|
|
|
|
|
|
|
14 |
parent::run();
|
|
|
15 |
add_action( 'wp', array( $this, 'setup' ) );
|
16 |
}
|
17 |
|
52 |
* @return array
|
53 |
*/
|
54 |
public function doCommentChecking( $aCommentData ) {
|
|
|
|
|
55 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
56 |
$oFO = $this->getMod();
|
|
|
|
|
|
|
57 |
|
58 |
+
if ( $oFO->getIfDoCommentsCheck() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
try {
|
61 |
+
$this->checkRequestRecaptcha();
|
62 |
+
}
|
63 |
+
catch ( Exception $oE ) {
|
64 |
+
$sStatKey = ( $oE->getCode() == 1 ) ? 'empty' : 'failed';
|
65 |
+
$sExplanation = $oE->getMessage();
|
66 |
|
67 |
+
$this->doStatIncrement( sprintf( 'spam.recaptcha.%s', $sStatKey ) );
|
68 |
+
self::$sCommentStatus = $this->getOption( 'comments_default_action_spam_bot' );
|
69 |
+
$this->setCommentStatusExplanation( $sExplanation );
|
70 |
|
71 |
+
$oFO->setOptInsightsAt( 'last_comment_block_at' );
|
72 |
+
$this->setIpTransgressed(); // black mark this IP
|
73 |
|
74 |
+
if ( self::$sCommentStatus == 'reject' ) {
|
75 |
+
$oWp = $this->loadWp();
|
76 |
+
$oWp->doRedirect( $oWp->getHomeUrl(), array(), true, false );
|
77 |
+
}
|
78 |
}
|
79 |
}
|
80 |
+
|
81 |
return $aCommentData;
|
82 |
}
|
83 |
}
|
src/processors/commentsfilter_humanspam.php
CHANGED
@@ -25,18 +25,20 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
25 |
if ( !$fIfDoCheck ) {
|
26 |
return $fIfDoCheck;
|
27 |
}
|
|
|
|
|
28 |
|
29 |
$oWpComments = $this->loadWpComments();
|
30 |
|
31 |
// 1st are comments enabled on this post?
|
32 |
-
$nPostId = $
|
33 |
$oPost = $nPostId ? $this->loadWp()->getPostById( $nPostId ) : null;
|
34 |
if ( $oPost ) {
|
35 |
$fIfDoCheck = $oWpComments->isCommentsOpen( $oPost );
|
36 |
}
|
37 |
|
38 |
-
if ( $fIfDoCheck && $oWpComments->
|
39 |
-
&& $oWpComments->
|
40 |
$fIfDoCheck = false;
|
41 |
}
|
42 |
|
@@ -48,39 +50,30 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
48 |
* @return array
|
49 |
*/
|
50 |
public function doCommentChecking( $aCommentData ) {
|
51 |
-
parent::doCommentChecking( $aCommentData );
|
52 |
-
|
53 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
54 |
$oFO = $this->getMod();
|
55 |
-
if ( !$oFO->getIfDoCommentsCheck() ) {
|
56 |
-
return $aCommentData;
|
57 |
-
}
|
58 |
-
|
59 |
-
$this->doBlacklistSpamCheck( $aCommentData );
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
return $aCommentData;
|
68 |
}
|
69 |
|
70 |
-
/**
|
71 |
-
* @param $aCommentData
|
72 |
-
*/
|
73 |
-
protected function doBlacklistSpamCheck( $aCommentData ) {
|
74 |
-
$this->doBlacklistSpamCheck_Action(
|
75 |
-
$aCommentData[ 'comment_author' ],
|
76 |
-
$aCommentData[ 'comment_author_email' ],
|
77 |
-
$aCommentData[ 'comment_author_url' ],
|
78 |
-
$aCommentData[ 'comment_content' ],
|
79 |
-
$this->ip(),
|
80 |
-
substr( $this->loadDP()->FetchServer( 'HTTP_USER_AGENT', '' ), 0, 254 )
|
81 |
-
);
|
82 |
-
}
|
83 |
-
|
84 |
/**
|
85 |
* Does the same as the WordPress blacklist filter, but more intelligently and with a nod towards much higher
|
86 |
* performance. It also uses defined options for which fields are checked for SPAM instead of just checking
|
@@ -92,7 +85,7 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
92 |
* @param string $sUserIp
|
93 |
* @param string $sUserAgent
|
94 |
*/
|
95 |
-
public function
|
96 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
97 |
$oFO = $this->getMod();
|
98 |
|
25 |
if ( !$fIfDoCheck ) {
|
26 |
return $fIfDoCheck;
|
27 |
}
|
28 |
+
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
29 |
+
$oFO = $this->getMod();
|
30 |
|
31 |
$oWpComments = $this->loadWpComments();
|
32 |
|
33 |
// 1st are comments enabled on this post?
|
34 |
+
$nPostId = $oFO->getCommentItem( 'comment_post_ID' );
|
35 |
$oPost = $nPostId ? $this->loadWp()->getPostById( $nPostId ) : null;
|
36 |
if ( $oPost ) {
|
37 |
$fIfDoCheck = $oWpComments->isCommentsOpen( $oPost );
|
38 |
}
|
39 |
|
40 |
+
if ( $fIfDoCheck && $oWpComments->getIfAllowCommentsByPreviouslyApproved()
|
41 |
+
&& $oWpComments->isAuthorApproved( $oFO->getCommentItem( 'comment_author_email' ) ) ) {
|
42 |
$fIfDoCheck = false;
|
43 |
}
|
44 |
|
50 |
* @return array
|
51 |
*/
|
52 |
public function doCommentChecking( $aCommentData ) {
|
|
|
|
|
53 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
54 |
$oFO = $this->getMod();
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
+
if ( $oFO->getIfDoCommentsCheck() ) {
|
57 |
+
|
58 |
+
$this->performBlacklistSpamCheck(
|
59 |
+
$aCommentData[ 'comment_author' ],
|
60 |
+
$aCommentData[ 'comment_author_email' ],
|
61 |
+
$aCommentData[ 'comment_author_url' ],
|
62 |
+
$aCommentData[ 'comment_content' ],
|
63 |
+
$this->ip(),
|
64 |
+
substr( $this->loadDP()->server( 'HTTP_USER_AGENT', '' ), 0, 254 )
|
65 |
+
);
|
66 |
+
|
67 |
+
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
68 |
+
if ( self::$sCommentStatus == 'reject' ) {
|
69 |
+
$oWp = $this->loadWp();
|
70 |
+
$oWp->doRedirect( $oWp->getHomeUrl(), array(), true, false );
|
71 |
+
}
|
72 |
}
|
73 |
|
74 |
return $aCommentData;
|
75 |
}
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* Does the same as the WordPress blacklist filter, but more intelligently and with a nod towards much higher
|
79 |
* performance. It also uses defined options for which fields are checked for SPAM instead of just checking
|
85 |
* @param string $sUserIp
|
86 |
* @param string $sUserAgent
|
87 |
*/
|
88 |
+
public function performBlacklistSpamCheck( $sAuthor, $sEmail, $sUrl, $sComment, $sUserIp, $sUserAgent ) {
|
89 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
90 |
$oFO = $this->getMod();
|
91 |
|
src/processors/firewall.php
CHANGED
@@ -79,7 +79,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
79 |
$bPerformScan = false;
|
80 |
}
|
81 |
|
82 |
-
if ( $bPerformScan && $this->getOption( 'ignore_search_engines' ) == 'Y' && $oDp->
|
83 |
$sAuditMessage = sprintf( _wpsf__( 'Skipping firewall checking for this visit: %s.' ), _wpsf__( 'Visitor detected as Search Engine Bot' ) );
|
84 |
$this->addToAuditEntry( $sAuditMessage, 2, 'firewall_skip' );
|
85 |
$bPerformScan = false;
|
79 |
$bPerformScan = false;
|
80 |
}
|
81 |
|
82 |
+
if ( $bPerformScan && $this->getOption( 'ignore_search_engines' ) == 'Y' && $oDp->isSearchEngineBot() ) {
|
83 |
$sAuditMessage = sprintf( _wpsf__( 'Skipping firewall checking for this visit: %s.' ), _wpsf__( 'Visitor detected as Search Engine Bot' ) );
|
84 |
$this->addToAuditEntry( $sAuditMessage, 2, 'firewall_skip' );
|
85 |
$bPerformScan = false;
|
src/processors/ips.php
CHANGED
@@ -173,7 +173,7 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
173 |
private function getTextOfRemainingTransgressions() {
|
174 |
return sprintf(
|
175 |
$this->getMod()->getTextOpt( 'text_remainingtrans' ),
|
176 |
-
$this->
|
177 |
);
|
178 |
}
|
179 |
|
@@ -181,25 +181,23 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
181 |
* @param string $sIp
|
182 |
* @return string
|
183 |
*/
|
184 |
-
protected function
|
185 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
186 |
$oFO = $this->getMod();
|
187 |
if ( empty( $sIp ) ) {
|
188 |
$sIp = $this->ip();
|
189 |
}
|
190 |
-
return $oFO->getOptTransgressionLimit() - $this->
|
191 |
}
|
192 |
|
193 |
/**
|
|
|
194 |
* @param string $sIp
|
195 |
* @return int
|
196 |
*/
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
}
|
201 |
-
$aData = $this->getIpHasTransgressions( $sIp, true );
|
202 |
-
return empty( $aData ) ? 0 : $aData[ 'transgressions' ];
|
203 |
}
|
204 |
|
205 |
protected function processBlacklist() {
|
@@ -210,11 +208,13 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
210 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
211 |
$oFO = $this->getMod();
|
212 |
$sIp = $this->ip();
|
213 |
-
$bKill = false;
|
|
|
|
|
214 |
|
215 |
// now try auto black list
|
216 |
if ( !$bKill && $oFO->isAutoBlackListFeatureEnabled() ) {
|
217 |
-
$bKill = $this->
|
218 |
}
|
219 |
|
220 |
if ( $bKill ) {
|
@@ -224,7 +224,8 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
224 |
->addToAuditEntry( $sAuditMessage, 3, 'black_list_connection_killed' );
|
225 |
$oFO->setOptInsightsAt( 'last_ip_block_at' );
|
226 |
|
227 |
-
$this->
|
|
|
228 |
|
229 |
$this->loadWp()
|
230 |
->wpDie(
|
@@ -275,18 +276,22 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
275 |
$oFO->setOptInsightsAt( 'last_transgression_at' );
|
276 |
$this->doStatIncrement( 'ip.transgression.incremented' );
|
277 |
|
278 |
-
$
|
279 |
-
if (
|
280 |
-
|
|
|
|
|
|
|
281 |
$sAuditMessage = sprintf(
|
282 |
_wpsf__( 'Auto Black List transgression counter was incremented from %s to %s.' ),
|
283 |
-
$
|
284 |
-
$
|
285 |
);
|
286 |
$this->addToAuditEntry( $sAuditMessage, 2, 'transgression_counter_increment' );
|
287 |
}
|
288 |
else {
|
289 |
-
$this->
|
|
|
290 |
$sAuditMessage = sprintf(
|
291 |
_wpsf__( 'Auto Black List transgression counter was started for visitor.' ),
|
292 |
$sIp
|
@@ -306,323 +311,167 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
306 |
}
|
307 |
|
308 |
/**
|
309 |
-
* @
|
310 |
-
* @return bool
|
311 |
*/
|
312 |
-
public function
|
313 |
-
|
314 |
-
return ( count( $aIpData ) > 0 );
|
315 |
}
|
316 |
|
317 |
/**
|
318 |
-
* @
|
319 |
-
* @param bool $bReturnListData
|
320 |
-
* @return bool|array
|
321 |
*/
|
322 |
-
public function
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
$bOnList = count( $aIpData ) > 0;
|
329 |
-
|
330 |
-
return ( $bOnList && $bReturnListData ) ? $aIpData : $bOnList;
|
331 |
}
|
332 |
|
333 |
/**
|
334 |
-
* @
|
335 |
-
* @param bool $bReturnListData
|
336 |
-
* @return bool|array
|
337 |
*/
|
338 |
-
public function
|
339 |
-
|
340 |
-
$aIpData = $this->getIpListData( $sIp, array( ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_BLACK ) );
|
341 |
-
$bOnList = count( $aIpData ) > 0;
|
342 |
-
|
343 |
-
return ( ( $bOnList && $bReturnListData ) ? $aIpData : $bOnList );
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
-
*
|
348 |
-
* @param string $sIp
|
349 |
-
* @param bool $bReturnListData
|
350 |
-
* @return bool|array - will return the associative array of the single row data
|
351 |
*/
|
352 |
-
public function
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
$aIpData = $this->query_getAutoBlackListDataForIp( $sIp, $nSinceTimeToConsider, $nTransgressions );
|
360 |
-
return ( $bReturnListData ? $aIpData : !empty( $aIpData ) );
|
361 |
}
|
362 |
|
363 |
/**
|
364 |
-
* The auto black list isn't a simple lookup, but rather has an auto expiration and a transgression count
|
365 |
* @param string $sIp
|
366 |
-
* @
|
367 |
-
* @return bool|array - will return the associative array of the single row data
|
368 |
*/
|
369 |
-
public function
|
370 |
-
|
371 |
-
$oFO = $this->getMod();
|
372 |
-
|
373 |
-
$nSinceTimeToConsider = $this->time() - $oFO->getAutoExpireTime();
|
374 |
-
|
375 |
-
$aIpData = $this->query_getAutoBlackListDataForIp( $sIp, $nSinceTimeToConsider, 0 );
|
376 |
-
return ( $bReturnListData ? $aIpData : !empty( $aIpData ) );
|
377 |
}
|
378 |
|
379 |
/**
|
380 |
-
* @
|
|
|
381 |
*/
|
382 |
-
public function
|
383 |
-
|
384 |
-
return $aData;
|
385 |
}
|
386 |
|
387 |
/**
|
388 |
-
* @
|
|
|
389 |
*/
|
390 |
-
public function
|
391 |
-
|
392 |
-
|
|
|
|
|
393 |
}
|
394 |
|
395 |
/**
|
396 |
* @param string $sIp
|
397 |
-
* @param
|
398 |
-
* @return
|
399 |
*/
|
400 |
-
|
401 |
-
|
402 |
-
$aData = array();
|
403 |
|
404 |
-
|
405 |
-
foreach ( $aResult as $aRow ) {
|
406 |
try {
|
407 |
-
if ( $this->loadIpService()->checkIp( $sIp, $
|
408 |
-
$
|
|
|
409 |
}
|
410 |
}
|
411 |
catch ( Exception $oE ) {
|
412 |
}
|
413 |
}
|
414 |
|
415 |
-
return $
|
416 |
}
|
417 |
|
418 |
/**
|
419 |
* @param string $sIp
|
420 |
* @param string $sLabel
|
421 |
-
* @return
|
422 |
*/
|
423 |
public function addIpToWhiteList( $sIp, $sLabel = '' ) {
|
424 |
-
$bSuccess = false;
|
425 |
$sIp = trim( $sIp );
|
426 |
-
if ( $this->isValidIpOrRange( $sIp ) ) {
|
427 |
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
$this->query_updateIpRecordLabel( $sLabel, $aIpData );
|
434 |
-
}
|
435 |
-
$bSuccess = !empty( $aIpData ) && is_array( $aIpData );
|
436 |
-
}
|
437 |
-
return $bSuccess;
|
438 |
-
}
|
439 |
|
440 |
-
|
441 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
}
|
443 |
|
444 |
/**
|
445 |
* @param string $sIp
|
446 |
-
* @
|
447 |
-
* @return array|bool|int
|
448 |
*/
|
449 |
-
protected function
|
450 |
-
|
451 |
-
|
452 |
-
$aNewData = array();
|
453 |
-
$aNewData[ 'ip' ] = $sIp;
|
454 |
-
$aNewData[ 'label' ] = empty( $sLabel ) ? _wpsf__( 'No Label' ) : $sLabel;
|
455 |
-
$aNewData[ 'list' ] = ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE;
|
456 |
-
$aNewData[ 'ip6' ] = $this->loadIpService()->getIpVersion( $sIp ) == 6;
|
457 |
-
$aNewData[ 'transgressions' ] = 0;
|
458 |
-
$aNewData[ 'is_range' ] = strpos( $sIp, '/' ) !== false;
|
459 |
-
$aNewData[ 'last_access_at' ] = 0;
|
460 |
-
$aNewData[ 'created_at' ] = $this->time();
|
461 |
-
|
462 |
-
$mResult = $this->insertData( $aNewData );
|
463 |
-
return $mResult ? $aNewData : $mResult;
|
464 |
}
|
465 |
|
466 |
/**
|
467 |
* @param string $sIp
|
468 |
-
* @
|
469 |
-
*/
|
470 |
-
protected function query_addNewAutoBlackListIp( $sIp ) {
|
471 |
-
|
472 |
-
// Ensure we delete any previous old entries as we go.
|
473 |
-
$this->query_deleteIpFromList( $sIp, ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK );
|
474 |
-
|
475 |
-
// Now add new entry
|
476 |
-
$aNewData = array();
|
477 |
-
$aNewData[ 'ip' ] = $sIp;
|
478 |
-
$aNewData[ 'label' ] = 'auto';
|
479 |
-
$aNewData[ 'list' ] = ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK;
|
480 |
-
$aNewData[ 'ip6' ] = $this->loadIpService()->getIpVersion( $sIp ) == 6;
|
481 |
-
$aNewData[ 'transgressions' ] = 1;
|
482 |
-
$aNewData[ 'is_range' ] = 0;
|
483 |
-
$aNewData[ 'last_access_at' ] = $this->time();
|
484 |
-
$aNewData[ 'created_at' ] = $this->time();
|
485 |
-
|
486 |
-
$mResult = $this->insertData( $aNewData );
|
487 |
-
return $mResult ? $aNewData : $mResult;
|
488 |
-
}
|
489 |
-
|
490 |
-
/**
|
491 |
-
* @param array $aCurrentData
|
492 |
-
* @return bool|int
|
493 |
-
*/
|
494 |
-
protected function query_updateBmCounterForIp( $aCurrentData ) {
|
495 |
-
$aUpdated = array(
|
496 |
-
'transgressions' => $aCurrentData[ 'transgressions' ] + 1,
|
497 |
-
'last_access_at' => $this->time(),
|
498 |
-
);
|
499 |
-
return $this->updateRowsWhere( $aUpdated, $aCurrentData );
|
500 |
-
}
|
501 |
-
|
502 |
-
/**
|
503 |
* @param string $sLabel
|
504 |
-
* @
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
$
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
/**
|
526 |
-
* @param $sIp
|
527 |
-
* @param $sList
|
528 |
-
* @return bool|int
|
529 |
-
*/
|
530 |
-
protected function query_deleteIpFromList( $sIp, $sList ) {
|
531 |
-
|
532 |
-
$sQuery = "
|
533 |
-
DELETE from `%s`
|
534 |
-
WHERE
|
535 |
-
`ip` = '%s'
|
536 |
-
AND `list` = '%s'
|
537 |
-
";
|
538 |
-
$sQuery = sprintf( $sQuery,
|
539 |
-
$this->getTableName(),
|
540 |
-
esc_sql( $sIp ),
|
541 |
-
esc_sql( $sList )
|
542 |
-
);
|
543 |
-
return $this->loadDbProcessor()->doSql( $sQuery );
|
544 |
-
}
|
545 |
|
546 |
-
|
547 |
-
* We can be specific with the IP in this query since auto black lists is single IPs only.
|
548 |
-
* @param string $sIp
|
549 |
-
* @return array
|
550 |
-
*/
|
551 |
-
protected function query_getIpWhiteListData( $sIp ) {
|
552 |
-
|
553 |
-
$sQuery = "
|
554 |
-
SELECT *
|
555 |
-
FROM `%s`
|
556 |
-
WHERE
|
557 |
-
`ip` = '%s'
|
558 |
-
AND `list` = '%s'
|
559 |
-
AND `deleted_at` = 0
|
560 |
-
";
|
561 |
-
|
562 |
-
$sQuery = sprintf( $sQuery,
|
563 |
-
$this->getTableName(),
|
564 |
-
esc_sql( $sIp ),
|
565 |
-
ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE
|
566 |
-
);
|
567 |
-
$mResult = $this->selectCustom( $sQuery );
|
568 |
-
return ( is_array( $mResult ) && isset( $mResult[ 0 ] ) ) ? $mResult[ 0 ] : array();
|
569 |
}
|
570 |
|
571 |
/**
|
572 |
-
*
|
573 |
* @param string $sIp
|
574 |
-
* @
|
575 |
-
* @param int $nTransgressionLimit
|
576 |
-
* @return array
|
577 |
-
*/
|
578 |
-
protected function query_getAutoBlackListDataForIp( $sIp, $nSince = 0, $nTransgressionLimit = 0 ) {
|
579 |
-
|
580 |
-
$sQuery = "
|
581 |
-
SELECT *
|
582 |
-
FROM `%s`
|
583 |
-
WHERE
|
584 |
-
`ip` = '%s'
|
585 |
-
AND `list` = '%s'
|
586 |
-
AND `transgressions` >= '%s'
|
587 |
-
AND `last_access_at` >= %s
|
588 |
-
AND `deleted_at` = 0
|
589 |
-
";
|
590 |
-
|
591 |
-
$sQuery = sprintf( $sQuery,
|
592 |
-
$this->getTableName(),
|
593 |
-
esc_sql( $sIp ),
|
594 |
-
ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK,
|
595 |
-
esc_sql( $nTransgressionLimit ),
|
596 |
-
esc_sql( $nSince )
|
597 |
-
);
|
598 |
-
$mResult = $this->selectCustom( $sQuery );
|
599 |
-
return ( is_array( $mResult ) && isset( $mResult[ 0 ] ) ) ? $mResult[ 0 ] : array();
|
600 |
-
}
|
601 |
-
|
602 |
-
/**
|
603 |
-
* @param array $aLists
|
604 |
-
* @return array
|
605 |
*/
|
606 |
-
protected function
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
`list` IN ( %s )
|
617 |
-
AND `deleted_at` = 0
|
618 |
-
";
|
619 |
-
|
620 |
-
$sQuery = sprintf( $sQuery,
|
621 |
-
$this->getTableName(),
|
622 |
-
sprintf( "'%s'", implode( "','", $aLists ) )
|
623 |
-
);
|
624 |
-
$mResult = $this->selectCustom( $sQuery );
|
625 |
-
return is_array( $mResult ) ? $mResult : array();
|
626 |
}
|
627 |
|
628 |
/**
|
@@ -657,19 +506,55 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
657 |
* @param int $nTimeStamp
|
658 |
* @return bool|int
|
659 |
*/
|
660 |
-
protected function
|
661 |
-
$
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
);
|
672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
}
|
674 |
|
675 |
/**
|
173 |
private function getTextOfRemainingTransgressions() {
|
174 |
return sprintf(
|
175 |
$this->getMod()->getTextOpt( 'text_remainingtrans' ),
|
176 |
+
$this->getRemainingTransgressions() - 1 // we take one off because it hasn't been incremented at this stage
|
177 |
);
|
178 |
}
|
179 |
|
181 |
* @param string $sIp
|
182 |
* @return string
|
183 |
*/
|
184 |
+
protected function getRemainingTransgressions( $sIp = '' ) {
|
185 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
186 |
$oFO = $this->getMod();
|
187 |
if ( empty( $sIp ) ) {
|
188 |
$sIp = $this->ip();
|
189 |
}
|
190 |
+
return $oFO->getOptTransgressionLimit() - $this->getTransgressions( $sIp );
|
191 |
}
|
192 |
|
193 |
/**
|
194 |
+
* The auto black list isn't a simple lookup, but rather has an auto expiration and a transgression count
|
195 |
* @param string $sIp
|
196 |
* @return int
|
197 |
*/
|
198 |
+
private function getTransgressions( $sIp ) {
|
199 |
+
$oBlackIp = $this->getAutoBlackListIp( $sIp );
|
200 |
+
return ( $oBlackIp instanceof ICWP_WPSF_IpsEntryVO ) ? $oBlackIp->getTransgressions() : 0;
|
|
|
|
|
|
|
201 |
}
|
202 |
|
203 |
protected function processBlacklist() {
|
208 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
209 |
$oFO = $this->getMod();
|
210 |
$sIp = $this->ip();
|
211 |
+
$bKill = false;
|
212 |
+
|
213 |
+
// TODO: *Maybe* Have a manual black list process first.
|
214 |
|
215 |
// now try auto black list
|
216 |
if ( !$bKill && $oFO->isAutoBlackListFeatureEnabled() ) {
|
217 |
+
$bKill = $this->isIpToBeBlocked( $sIp );
|
218 |
}
|
219 |
|
220 |
if ( $bKill ) {
|
224 |
->addToAuditEntry( $sAuditMessage, 3, 'black_list_connection_killed' );
|
225 |
$oFO->setOptInsightsAt( 'last_ip_block_at' );
|
226 |
|
227 |
+
$this->getQueryUpdater()
|
228 |
+
->updateLastAccessAt( $this->getAutoBlackListIp( $sIp ) );
|
229 |
|
230 |
$this->loadWp()
|
231 |
->wpDie(
|
276 |
$oFO->setOptInsightsAt( 'last_transgression_at' );
|
277 |
$this->doStatIncrement( 'ip.transgression.incremented' );
|
278 |
|
279 |
+
$oBlackIp = $this->getAutoBlackListIp( $sIp );
|
280 |
+
if ( $oBlackIp instanceof ICWP_WPSF_IpsEntryVO ) {
|
281 |
+
|
282 |
+
$this->getQueryUpdater()
|
283 |
+
->incrementTransgressions( $oBlackIp );
|
284 |
+
|
285 |
$sAuditMessage = sprintf(
|
286 |
_wpsf__( 'Auto Black List transgression counter was incremented from %s to %s.' ),
|
287 |
+
$oBlackIp->getTransgressions() - 1,
|
288 |
+
$oBlackIp->getTransgressions()
|
289 |
);
|
290 |
$this->addToAuditEntry( $sAuditMessage, 2, 'transgression_counter_increment' );
|
291 |
}
|
292 |
else {
|
293 |
+
$this->addIpToAutoBlackList( $sIp );
|
294 |
+
|
295 |
$sAuditMessage = sprintf(
|
296 |
_wpsf__( 'Auto Black List transgression counter was started for visitor.' ),
|
297 |
$sIp
|
311 |
}
|
312 |
|
313 |
/**
|
314 |
+
* @return ICWP_WPSF_IpsEntryVO[]
|
|
|
315 |
*/
|
316 |
+
public function getAutoBlacklistIpsData() {
|
317 |
+
return $this->getQuerySelector()->allFromList( ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK );
|
|
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
+
* @return string[]
|
|
|
|
|
322 |
*/
|
323 |
+
public function getAutoBlacklistIps() {
|
324 |
+
$aIps = array();
|
325 |
+
foreach ( $this->getAutoBlacklistIpsData() as $oIp ) {
|
326 |
+
$aIps[] = $oIp->getIp();
|
327 |
+
}
|
328 |
+
return $aIps;
|
|
|
|
|
|
|
329 |
}
|
330 |
|
331 |
/**
|
332 |
+
* @return ICWP_WPSF_IpsEntryVO[]
|
|
|
|
|
333 |
*/
|
334 |
+
public function getWhitelistIpsData() {
|
335 |
+
return $this->getQuerySelector()->allFromList( ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE );
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
+
* @return string[]
|
|
|
|
|
|
|
340 |
*/
|
341 |
+
public function getWhitelistIps() {
|
342 |
+
$aIps = array();
|
343 |
+
foreach ( $this->getWhitelistIpsData() as $oIp ) {
|
344 |
+
$aIps[] = $oIp->getIp();
|
345 |
+
}
|
346 |
+
return $aIps;
|
|
|
|
|
|
|
347 |
}
|
348 |
|
349 |
/**
|
|
|
350 |
* @param string $sIp
|
351 |
+
* @return bool
|
|
|
352 |
*/
|
353 |
+
public function isIpOnManualBlackList( $sIp ) {
|
354 |
+
return $this->isIpOnList( $sIp, ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_BLACK );
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
|
357 |
/**
|
358 |
+
* @param string $sIp
|
359 |
+
* @return bool
|
360 |
*/
|
361 |
+
public function isIpOnWhiteList( $sIp ) {
|
362 |
+
return $this->isIpOnList( $sIp, ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE );
|
|
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
+
* @param string $sIp
|
367 |
+
* @return bool|array - will return the associative array of the single row data
|
368 |
*/
|
369 |
+
public function isIpToBeBlocked( $sIp ) {
|
370 |
+
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
371 |
+
$oFO = $this->getMod();
|
372 |
+
$oIp = $this->getAutoBlackListIp( $sIp );
|
373 |
+
return ( $oIp instanceof ICWP_WPSF_IpsEntryVO && $oIp->getTransgressions() >= $oFO->getOptTransgressionLimit() );
|
374 |
}
|
375 |
|
376 |
/**
|
377 |
* @param string $sIp
|
378 |
+
* @param string $sList
|
379 |
+
* @return bool
|
380 |
*/
|
381 |
+
private function isIpOnList( $sIp, $sList ) {
|
382 |
+
$bOnList = false;
|
|
|
383 |
|
384 |
+
foreach ( $this->getQuerySelector()->allFromList( $sList ) as $oIp ) {
|
|
|
385 |
try {
|
386 |
+
if ( $this->loadIpService()->checkIp( $sIp, $oIp->getIp() ) ) {
|
387 |
+
$bOnList = true;
|
388 |
+
break;
|
389 |
}
|
390 |
}
|
391 |
catch ( Exception $oE ) {
|
392 |
}
|
393 |
}
|
394 |
|
395 |
+
return $bOnList;
|
396 |
}
|
397 |
|
398 |
/**
|
399 |
* @param string $sIp
|
400 |
* @param string $sLabel
|
401 |
+
* @return ICWP_WPSF_IpsEntryVO|null
|
402 |
*/
|
403 |
public function addIpToWhiteList( $sIp, $sLabel = '' ) {
|
|
|
404 |
$sIp = trim( $sIp );
|
|
|
405 |
|
406 |
+
/** @var ICWP_WPSF_IpsEntryVO $oIp */
|
407 |
+
$oIp = $this->getQuerySelector()
|
408 |
+
->filterByIp( $sIp )
|
409 |
+
->filterByList( ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE )
|
410 |
+
->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
|
412 |
+
if ( empty( $oIp ) ) {
|
413 |
+
$oIp = $this->addIpToList( $sIp, ICWP_WPSF_FeatureHandler_Ips::LIST_MANUAL_WHITE, $sLabel );
|
414 |
+
}
|
415 |
+
else if ( $sLabel != $oIp->getLabel() ) {
|
416 |
+
$this->getQueryUpdater()
|
417 |
+
->updateLabel( $oIp, $sLabel );
|
418 |
+
}
|
419 |
+
return $oIp;
|
420 |
}
|
421 |
|
422 |
/**
|
423 |
* @param string $sIp
|
424 |
+
* @return bool
|
|
|
425 |
*/
|
426 |
+
protected function addIpToAutoBlackList( $sIp ) {
|
427 |
+
$oIp = $this->addIpToList( $sIp, ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK, 'auto' );
|
428 |
+
return ( $oIp instanceof ICWP_WPSF_IpsEntryVO ) && $this->getQueryUpdater()->incrementTransgressions( $oIp );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
}
|
430 |
|
431 |
/**
|
432 |
* @param string $sIp
|
433 |
+
* @param string $sList
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
* @param string $sLabel
|
435 |
+
* @return ICWP_WPSF_IpsEntryVO|null
|
436 |
+
*/
|
437 |
+
private function addIpToList( $sIp, $sList, $sLabel = '' ) {
|
438 |
+
$oIp = null;
|
439 |
+
|
440 |
+
// delete any previous old entries as we go.
|
441 |
+
$this->getQueryDeleter()
|
442 |
+
->deleteIpOnList( $sIp, $sList );
|
443 |
+
|
444 |
+
/** @var ICWP_WPSF_IpsEntryVO $oTempIp */
|
445 |
+
$oTempIp = $this->getQuerySelector()->getVo();
|
446 |
+
$oTempIp->ip = $sIp;
|
447 |
+
$oTempIp->list = $sList;
|
448 |
+
$oTempIp->label = empty( $sLabel ) ? _wpsf__( 'No Label' ) : $sLabel;
|
449 |
+
|
450 |
+
if ( $this->getQueryInserter()->insert( $oTempIp ) ) {
|
451 |
+
/** @var ICWP_WPSF_IpsEntryVO $oIp */
|
452 |
+
$oIp = $this->getQuerySelector()
|
453 |
+
->setWheresFromVo( $oTempIp )
|
454 |
+
->first();
|
455 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
457 |
+
return $oIp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
}
|
459 |
|
460 |
/**
|
461 |
+
* The auto black list isn't a simple lookup, but rather has an auto expiration
|
462 |
* @param string $sIp
|
463 |
+
* @return ICWP_WPSF_IpsEntryVO|null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
*/
|
465 |
+
protected function getAutoBlackListIp( $sIp ) {
|
466 |
+
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
467 |
+
$oFO = $this->getMod();
|
468 |
+
/** @var ICWP_WPSF_IpsEntryVO $oIp */
|
469 |
+
$oIp = $this->getQuerySelector()
|
470 |
+
->filterByIp( $sIp )
|
471 |
+
->filterByList( ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK )
|
472 |
+
->filterByLastAccessAfter( $this->time() - $oFO->getAutoExpireTime() )
|
473 |
+
->first();
|
474 |
+
return $oIp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
475 |
}
|
476 |
|
477 |
/**
|
506 |
* @param int $nTimeStamp
|
507 |
* @return bool|int
|
508 |
*/
|
509 |
+
protected function deleteRowsOlderThan( $nTimeStamp ) {
|
510 |
+
return $this->getQueryDeleter()
|
511 |
+
->addWhereEquals( 'list', ICWP_WPSF_FeatureHandler_Ips::LIST_AUTO_BLACK )
|
512 |
+
->addWhereOlderThan( $nTimeStamp, 'last_access_at' )
|
513 |
+
->query();
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* @return ICWP_WPSF_Query_Ips_Delete
|
518 |
+
*/
|
519 |
+
public function getQueryDeleter() {
|
520 |
+
$this->queryRequireLib( 'delete.php' );
|
521 |
+
$oQ = new ICWP_WPSF_Query_Ips_Delete();
|
522 |
+
return $oQ->setTable( $this->getTableName() );
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* @return ICWP_WPSF_Query_Ips_Insert
|
527 |
+
*/
|
528 |
+
public function getQueryInserter() {
|
529 |
+
$this->queryRequireLib( 'insert.php' );
|
530 |
+
$oQ = new ICWP_WPSF_Query_Ips_Insert();
|
531 |
+
return $oQ->setTable( $this->getTableName() );
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* @return ICWP_WPSF_Query_Ips_Select
|
536 |
+
*/
|
537 |
+
public function getQuerySelector() {
|
538 |
+
$this->queryRequireLib( 'select.php' );
|
539 |
+
$oQ = new ICWP_WPSF_Query_Ips_Select();
|
540 |
+
return $oQ->setTable( $this->getTableName() )
|
541 |
+
->setResultsAsVo( true );
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* @return ICWP_WPSF_Query_Ips_Update
|
546 |
+
*/
|
547 |
+
public function getQueryUpdater() {
|
548 |
+
$this->queryRequireLib( 'update.php' );
|
549 |
+
$oQ = new ICWP_WPSF_Query_Ips_Update();
|
550 |
+
return $oQ->setTable( $this->getTableName() );
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* @return string
|
555 |
+
*/
|
556 |
+
protected function queryGetDir() {
|
557 |
+
return parent::queryGetDir().'ips/';
|
558 |
}
|
559 |
|
560 |
/**
|
src/processors/lockdown.php
CHANGED
@@ -53,8 +53,6 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
53 |
add_filter( 'xmlrpc_enabled', array( $this, 'disableXmlrpc' ), 1000, 0 );
|
54 |
add_filter( 'xmlrpc_methods', array( $this, 'disableXmlrpc' ), 1000, 0 );
|
55 |
}
|
56 |
-
|
57 |
-
add_action( 'init', array( $this, 'onWpInit' ), 5 );
|
58 |
}
|
59 |
|
60 |
/**
|
@@ -69,6 +67,7 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
69 |
}
|
70 |
|
71 |
public function onWpInit() {
|
|
|
72 |
if ( $this->loadWp()->isRest() ) {
|
73 |
$this->processRestApi();
|
74 |
}
|
53 |
add_filter( 'xmlrpc_enabled', array( $this, 'disableXmlrpc' ), 1000, 0 );
|
54 |
add_filter( 'xmlrpc_methods', array( $this, 'disableXmlrpc' ), 1000, 0 );
|
55 |
}
|
|
|
|
|
56 |
}
|
57 |
|
58 |
/**
|
67 |
}
|
68 |
|
69 |
public function onWpInit() {
|
70 |
+
parent::onWpInit();
|
71 |
if ( $this->loadWp()->isRest() ) {
|
72 |
$this->processRestApi();
|
73 |
}
|
src/processors/loginprotect_googleauthenticator.php
CHANGED
@@ -13,7 +13,7 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
13 |
public function run() {
|
14 |
parent::run();
|
15 |
if ( $this->loadDP()->query( 'shield_action' ) == 'garemovalconfirm' ) {
|
16 |
-
add_action( '
|
17 |
}
|
18 |
}
|
19 |
|
13 |
public function run() {
|
14 |
parent::run();
|
15 |
if ( $this->loadDP()->query( 'shield_action' ) == 'garemovalconfirm' ) {
|
16 |
+
add_action( 'wp_loaded', array( $this, 'validateUserGaRemovalLink' ), 10 );
|
17 |
}
|
18 |
}
|
19 |
|
src/processors/loginprotect_intent.php
CHANGED
@@ -23,7 +23,6 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
23 |
public function run() {
|
24 |
/** @var ICWP_WPSF_FeatureHandler_LoginProtect $oFO */
|
25 |
$oFO = $this->getMod();
|
26 |
-
add_action( 'init', array( $this, 'onWpInit' ), 0 );
|
27 |
add_action( 'wp_logout', array( $this, 'onWpLogout' ) );
|
28 |
|
29 |
// 100 priority is important as this takes priority
|
@@ -45,6 +44,7 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
45 |
}
|
46 |
|
47 |
public function onWpInit() {
|
|
|
48 |
$this->setupLoginIntent();
|
49 |
}
|
50 |
|
23 |
public function run() {
|
24 |
/** @var ICWP_WPSF_FeatureHandler_LoginProtect $oFO */
|
25 |
$oFO = $this->getMod();
|
|
|
26 |
add_action( 'wp_logout', array( $this, 'onWpLogout' ) );
|
27 |
|
28 |
// 100 priority is important as this takes priority
|
44 |
}
|
45 |
|
46 |
public function onWpInit() {
|
47 |
+
parent::onWpInit();
|
48 |
$this->setupLoginIntent();
|
49 |
}
|
50 |
|
src/processors/plugin_tracking.php
CHANGED
@@ -109,7 +109,7 @@ class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin
|
|
109 |
'slug' => $this->getController()->getPluginSlug(),
|
110 |
'version' => $this->getController()->getVersion(),
|
111 |
'is_wpms' => $oWP->isMultisite() ? 1 : 0,
|
112 |
-
'ssl' => (
|
113 |
'locale' => get_locale(),
|
114 |
'plugins_total' => count( $oWpPlugins->getPlugins() ),
|
115 |
'plugins_active' => count( $oWpPlugins->getActivePlugins() ),
|
109 |
'slug' => $this->getController()->getPluginSlug(),
|
110 |
'version' => $this->getController()->getVersion(),
|
111 |
'is_wpms' => $oWP->isMultisite() ? 1 : 0,
|
112 |
+
'ssl' => is_ssl() ? 1 : 0,
|
113 |
'locale' => get_locale(),
|
114 |
'plugins_total' => count( $oWpPlugins->getPlugins() ),
|
115 |
'plugins_active' => count( $oWpPlugins->getActivePlugins() ),
|
src/processors/statistics.php
CHANGED
@@ -222,14 +222,16 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
222 |
* @return ICWP_WPSF_TallyVO[]
|
223 |
*/
|
224 |
protected function getAllTallys() {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
230 |
}
|
231 |
|
232 |
/**
|
|
|
233 |
* @return ICWP_WPSF_Processor_Statistics_Reporting
|
234 |
*/
|
235 |
protected function getReportingProcessor() {
|
222 |
* @return ICWP_WPSF_TallyVO[]
|
223 |
*/
|
224 |
protected function getAllTallys() {
|
225 |
+
/** @var ICWP_WPSF_TallyVO[] $aRes */
|
226 |
+
$aRes = $this->getTallyProcessor()
|
227 |
+
->getQuerySelector()
|
228 |
+
->setColumnsToSelect( array( 'stat_key', 'tally' ) )
|
229 |
+
->query();
|
230 |
+
return $aRes;
|
231 |
}
|
232 |
|
233 |
/**
|
234 |
+
* TODO: Not properly implemented
|
235 |
* @return ICWP_WPSF_Processor_Statistics_Reporting
|
236 |
*/
|
237 |
protected function getReportingProcessor() {
|
src/processors/statistics_tally.php
CHANGED
@@ -21,7 +21,7 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
21 |
/**
|
22 |
* @return ICWP_WPSF_Query_Tally_Delete
|
23 |
*/
|
24 |
-
public function
|
25 |
$this->queryRequireLib( 'tally_delete.php' );
|
26 |
return ( new ICWP_WPSF_Query_Tally_Delete() )->setTable( $this->getTableName() );
|
27 |
}
|
@@ -29,23 +29,15 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
29 |
/**
|
30 |
* @return ICWP_WPSF_Query_Tally_Insert
|
31 |
*/
|
32 |
-
public function
|
33 |
$this->queryRequireLib( 'tally_insert.php' );
|
34 |
return ( new ICWP_WPSF_Query_Tally_Insert() )->setTable( $this->getTableName() );
|
35 |
}
|
36 |
|
37 |
-
/**
|
38 |
-
* @return ICWP_WPSF_Query_Tally_Update
|
39 |
-
*/
|
40 |
-
public function getUpdater() {
|
41 |
-
$this->queryRequireLib( 'tally_update.php' );
|
42 |
-
return ( new ICWP_WPSF_Query_Tally_Update() )->setTable( $this->getTableName() );
|
43 |
-
}
|
44 |
-
|
45 |
/**
|
46 |
* @return ICWP_WPSF_Query_Tally_Select
|
47 |
*/
|
48 |
-
public function
|
49 |
$this->queryRequireLib( 'tally_select.php' );
|
50 |
return ( new ICWP_WPSF_Query_Tally_Select() )
|
51 |
->setTable( $this->getTableName() )
|
@@ -53,6 +45,14 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
53 |
->setColumnsDefinition( $this->getTableColumnsByDefinition() );
|
54 |
}
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
public function onModuleShutdown() {
|
57 |
parent::onModuleShutdown();
|
58 |
if ( !$this->getMod()->isPluginDeleting() ) {
|
@@ -75,6 +75,9 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
75 |
if ( empty( $aEntries ) || !is_array( $aEntries ) ) {
|
76 |
return;
|
77 |
}
|
|
|
|
|
|
|
78 |
foreach ( $aEntries as $aCollection ) {
|
79 |
foreach ( $aCollection as $sStatKey => $nTally ) {
|
80 |
|
@@ -83,11 +86,15 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
83 |
list( $sStatKey, $sParentStatKey ) = explode( ':', $sStatKey, 2 );
|
84 |
}
|
85 |
|
86 |
-
$oStat = $this->
|
87 |
->retrieveStat( $sStatKey, $sParentStatKey );
|
88 |
|
89 |
if ( empty( $oStat ) ) {
|
90 |
-
$
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
else {
|
93 |
$this->getUpdater()->incrementTally( $oStat, $nTally );
|
@@ -124,7 +131,7 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
124 |
*/
|
125 |
protected function consolidateDuplicateKeys() {
|
126 |
/** @var ICWP_WPSF_TallyVO[] $aAll */
|
127 |
-
$aAll = $this->
|
128 |
->all();
|
129 |
|
130 |
$aKeys = array();
|
@@ -144,7 +151,7 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
144 |
|
145 |
foreach ( $aKeys as $sKey ) {
|
146 |
/** @var ICWP_WPSF_TallyVO[] $aAll */
|
147 |
-
$aAll = $this->
|
148 |
->filterByStatKey( $sKey )
|
149 |
->query();
|
150 |
$oPrimary = array_pop( $aAll );
|
@@ -152,7 +159,7 @@ class ICWP_WPSF_Processor_Statistics_Tally extends ICWP_WPSF_BaseDbProcessor {
|
|
152 |
$nAdditionalTally = 0;
|
153 |
foreach ( $aAll as $oTally ) {
|
154 |
$nAdditionalTally += $oTally->tally;
|
155 |
-
$this->
|
156 |
}
|
157 |
|
158 |
$this->getUpdater()->incrementTally( $oPrimary, $nAdditionalTally );
|
21 |
/**
|
22 |
* @return ICWP_WPSF_Query_Tally_Delete
|
23 |
*/
|
24 |
+
public function getQueryDeleter() {
|
25 |
$this->queryRequireLib( 'tally_delete.php' );
|
26 |
return ( new ICWP_WPSF_Query_Tally_Delete() )->setTable( $this->getTableName() );
|
27 |
}
|
29 |
/**
|
30 |
* @return ICWP_WPSF_Query_Tally_Insert
|
31 |
*/
|
32 |
+
public function getQueryInserter() {
|
33 |
$this->queryRequireLib( 'tally_insert.php' );
|
34 |
return ( new ICWP_WPSF_Query_Tally_Insert() )->setTable( $this->getTableName() );
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
* @return ICWP_WPSF_Query_Tally_Select
|
39 |
*/
|
40 |
+
public function getQuerySelector() {
|
41 |
$this->queryRequireLib( 'tally_select.php' );
|
42 |
return ( new ICWP_WPSF_Query_Tally_Select() )
|
43 |
->setTable( $this->getTableName() )
|
45 |
->setColumnsDefinition( $this->getTableColumnsByDefinition() );
|
46 |
}
|
47 |
|
48 |
+
/**
|
49 |
+
* @return ICWP_WPSF_Query_Tally_Update
|
50 |
+
*/
|
51 |
+
public function getUpdater() {
|
52 |
+
$this->queryRequireLib( 'tally_update.php' );
|
53 |
+
return ( new ICWP_WPSF_Query_Tally_Update() )->setTable( $this->getTableName() );
|
54 |
+
}
|
55 |
+
|
56 |
public function onModuleShutdown() {
|
57 |
parent::onModuleShutdown();
|
58 |
if ( !$this->getMod()->isPluginDeleting() ) {
|
75 |
if ( empty( $aEntries ) || !is_array( $aEntries ) ) {
|
76 |
return;
|
77 |
}
|
78 |
+
|
79 |
+
/** @var ICWP_WPSF_TallyVO $oStat */
|
80 |
+
$oSel = $this->getQuerySelector();
|
81 |
foreach ( $aEntries as $aCollection ) {
|
82 |
foreach ( $aCollection as $sStatKey => $nTally ) {
|
83 |
|
86 |
list( $sStatKey, $sParentStatKey ) = explode( ':', $sStatKey, 2 );
|
87 |
}
|
88 |
|
89 |
+
$oStat = $this->getQuerySelector()
|
90 |
->retrieveStat( $sStatKey, $sParentStatKey );
|
91 |
|
92 |
if ( empty( $oStat ) ) {
|
93 |
+
$oStat = $oSel->getVo();
|
94 |
+
$oStat->stat_key = $sStatKey;
|
95 |
+
$oStat->tally = $nTally;
|
96 |
+
$oStat->parent_stat_key = $sParentStatKey;
|
97 |
+
$this->getQueryInserter()->insert( $oStat );
|
98 |
}
|
99 |
else {
|
100 |
$this->getUpdater()->incrementTally( $oStat, $nTally );
|
131 |
*/
|
132 |
protected function consolidateDuplicateKeys() {
|
133 |
/** @var ICWP_WPSF_TallyVO[] $aAll */
|
134 |
+
$aAll = $this->getQuerySelector()
|
135 |
->all();
|
136 |
|
137 |
$aKeys = array();
|
151 |
|
152 |
foreach ( $aKeys as $sKey ) {
|
153 |
/** @var ICWP_WPSF_TallyVO[] $aAll */
|
154 |
+
$aAll = $this->getQuerySelector()
|
155 |
->filterByStatKey( $sKey )
|
156 |
->query();
|
157 |
$oPrimary = array_pop( $aAll );
|
159 |
$nAdditionalTally = 0;
|
160 |
foreach ( $aAll as $oTally ) {
|
161 |
$nAdditionalTally += $oTally->tally;
|
162 |
+
$this->getQueryDeleter()->deleteById( $oTally->id );
|
163 |
}
|
164 |
|
165 |
$this->getUpdater()->incrementTally( $oPrimary, $nAdditionalTally );
|
src/processors/traffic_logger.php
CHANGED
@@ -34,7 +34,7 @@ class ICWP_WPSF_Processor_TrafficLogger extends ICWP_WPSF_BaseDbProcessor {
|
|
34 |
/** @var ICWP_WPSF_FeatureHandler_Traffic $oFO */
|
35 |
$oFO = $this->getMod();
|
36 |
try {
|
37 |
-
$this->
|
38 |
->deleteExcess( $oFO->getMaxEntries() );
|
39 |
}
|
40 |
catch ( Exception $oE ) {
|
@@ -125,7 +125,8 @@ class ICWP_WPSF_Processor_TrafficLogger extends ICWP_WPSF_BaseDbProcessor {
|
|
125 |
|
126 |
protected function logTraffic() {
|
127 |
$oDP = $this->loadDP();
|
128 |
-
$oEntry
|
|
|
129 |
$oEntry->rid = $this->getController()->getShortRequestId();
|
130 |
$oEntry->uid = $this->loadWpUsers()->getCurrentWpUserId();
|
131 |
$oEntry->ip = inet_pton( $this->ip() );
|
@@ -135,51 +136,35 @@ class ICWP_WPSF_Processor_TrafficLogger extends ICWP_WPSF_BaseDbProcessor {
|
|
135 |
$oEntry->ua = (string)$oDP->server( 'HTTP_USER_AGENT' );
|
136 |
$oEntry->trans = $this->getIfIpTransgressed() ? 1 : 0;
|
137 |
|
138 |
-
$this->
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
-
* @return
|
143 |
-
*/
|
144 |
-
public function getTrafficInserter() {
|
145 |
-
$this->queryRequireLib( 'insert.php' );
|
146 |
-
return ( new ICWP_WPSF_Query_TrafficEntry_Insert() )->setTable( $this->getTableName() );
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* @return ICWP_WPSF_Query_TrafficEntry_Count
|
151 |
*/
|
152 |
-
public function
|
153 |
-
$this->queryRequireLib( '
|
154 |
-
return ( new
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
-
* @return
|
159 |
*/
|
160 |
-
public function
|
161 |
-
$this->queryRequireLib( '
|
162 |
-
return ( new
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
* @return ICWP_WPSF_Query_TrafficEntry_Select
|
167 |
*/
|
168 |
-
public function
|
169 |
$this->queryRequireLib( 'select.php' );
|
170 |
return ( new ICWP_WPSF_Query_TrafficEntry_Select() )
|
171 |
->setTable( $this->getTableName() )
|
172 |
->setResultsAsVo( true );
|
173 |
}
|
174 |
|
175 |
-
/**
|
176 |
-
* @return ICWP_WPSF_TrafficEntryVO
|
177 |
-
*/
|
178 |
-
protected function getTrafficEntryVO() {
|
179 |
-
$this->queryRequireLib( 'ICWP_WPSF_TrafficEntryVO.php' );
|
180 |
-
return new ICWP_WPSF_TrafficEntryVO();
|
181 |
-
}
|
182 |
-
|
183 |
/**
|
184 |
* @return int
|
185 |
*/
|
34 |
/** @var ICWP_WPSF_FeatureHandler_Traffic $oFO */
|
35 |
$oFO = $this->getMod();
|
36 |
try {
|
37 |
+
$this->getQueryDeleter()
|
38 |
->deleteExcess( $oFO->getMaxEntries() );
|
39 |
}
|
40 |
catch ( Exception $oE ) {
|
125 |
|
126 |
protected function logTraffic() {
|
127 |
$oDP = $this->loadDP();
|
128 |
+
/** @var ICWP_WPSF_TrafficEntryVO $oEntry */
|
129 |
+
$oEntry = $this->getQuerySelector()->getVo();
|
130 |
$oEntry->rid = $this->getController()->getShortRequestId();
|
131 |
$oEntry->uid = $this->loadWpUsers()->getCurrentWpUserId();
|
132 |
$oEntry->ip = inet_pton( $this->ip() );
|
136 |
$oEntry->ua = (string)$oDP->server( 'HTTP_USER_AGENT' );
|
137 |
$oEntry->trans = $this->getIfIpTransgressed() ? 1 : 0;
|
138 |
|
139 |
+
$this->getQueryInserter()->insert( $oEntry );
|
140 |
}
|
141 |
|
142 |
/**
|
143 |
+
* @return ICWP_WPSF_Query_TrafficEntry_Delete
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
*/
|
145 |
+
public function getQueryDeleter() {
|
146 |
+
$this->queryRequireLib( 'delete.php' );
|
147 |
+
return ( new ICWP_WPSF_Query_TrafficEntry_Delete() )->setTable( $this->getTableName() );
|
148 |
}
|
149 |
|
150 |
/**
|
151 |
+
* @return ICWP_WPSF_Query_TrafficEntry_Insert
|
152 |
*/
|
153 |
+
public function getQueryInserter() {
|
154 |
+
$this->queryRequireLib( 'insert.php' );
|
155 |
+
return ( new ICWP_WPSF_Query_TrafficEntry_Insert() )->setTable( $this->getTableName() );
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
* @return ICWP_WPSF_Query_TrafficEntry_Select
|
160 |
*/
|
161 |
+
public function getQuerySelector() {
|
162 |
$this->queryRequireLib( 'select.php' );
|
163 |
return ( new ICWP_WPSF_Query_TrafficEntry_Select() )
|
164 |
->setTable( $this->getTableName() )
|
165 |
->setResultsAsVo( true );
|
166 |
}
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
/**
|
169 |
* @return int
|
170 |
*/
|
src/processors/user_management.php
CHANGED
@@ -23,8 +23,6 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
23 |
add_filter( 'manage_users_columns', array( $this, 'fAddUserListLastLoginColumn' ) );
|
24 |
add_filter( 'wpmu_users_columns', array( $this, 'fAddUserListLastLoginColumn' ) );
|
25 |
|
26 |
-
add_action( 'init', array( $this, 'onWpInit' ) );
|
27 |
-
|
28 |
if ( $oFO->isPasswordPoliciesEnabled() ) {
|
29 |
$this->getProcessorPasswords()->run();
|
30 |
}
|
@@ -45,10 +43,11 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
45 |
/**
|
46 |
*/
|
47 |
public function onWpInit() {
|
|
|
|
|
48 |
$oWpUsers = $this->loadWpUsers();
|
49 |
if ( $oWpUsers->isUserLoggedIn() ) {
|
50 |
-
$
|
51 |
-
$this->setPasswordStartedAt( $oUser ); // used by Password Policies
|
52 |
}
|
53 |
}
|
54 |
|
23 |
add_filter( 'manage_users_columns', array( $this, 'fAddUserListLastLoginColumn' ) );
|
24 |
add_filter( 'wpmu_users_columns', array( $this, 'fAddUserListLastLoginColumn' ) );
|
25 |
|
|
|
|
|
26 |
if ( $oFO->isPasswordPoliciesEnabled() ) {
|
27 |
$this->getProcessorPasswords()->run();
|
28 |
}
|
43 |
/**
|
44 |
*/
|
45 |
public function onWpInit() {
|
46 |
+
parent::onWpInit();
|
47 |
+
|
48 |
$oWpUsers = $this->loadWpUsers();
|
49 |
if ( $oWpUsers->isUserLoggedIn() ) {
|
50 |
+
$this->setPasswordStartedAt( $oWpUsers->getCurrentWpUser() ); // used by Password Policies
|
|
|
51 |
}
|
52 |
}
|
53 |
|
src/query/VOs/ICWP_WPSF_AuditTrailEntryVO.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_AuditTrailEntryVO
|
7 |
+
* @property string ip
|
8 |
+
* @property string message
|
9 |
+
* @property string wp_username
|
10 |
+
* @property string rid
|
11 |
+
* @property string event
|
12 |
+
*/
|
13 |
+
class ICWP_WPSF_AuditTrailEntryVO extends ICWP_WPSF_BaseEntryVO {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
public function getIp() {
|
19 |
+
return (string)$this->ip;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getEvent() {
|
26 |
+
return (string)$this->event;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getMessage() {
|
33 |
+
return (string)$this->message;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getRid() {
|
40 |
+
return (string)$this->rid;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function getUsername() {
|
47 |
+
return (string)$this->wp_username;
|
48 |
+
}
|
49 |
+
}
|
src/query/VOs/ICWP_WPSF_BaseEntryVO.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ICWP_WPSF_BaseEntryVO
|
5 |
+
* @property int created_at
|
6 |
+
* @property int deleted_at
|
7 |
+
* @property int id
|
8 |
+
*/
|
9 |
+
class ICWP_WPSF_BaseEntryVO {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var stdClass
|
13 |
+
*/
|
14 |
+
protected $oRowData;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param stdClass $oRowData
|
18 |
+
*/
|
19 |
+
public function __construct( $oRowData = null ) {
|
20 |
+
$this->oRowData = ( $oRowData instanceof stdClass ) ? $oRowData : new stdClass();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return int
|
25 |
+
*/
|
26 |
+
public function getCreatedAt() {
|
27 |
+
return (int)$this->created_at;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return int
|
32 |
+
*/
|
33 |
+
public function getId() {
|
34 |
+
return (int)$this->id;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return bool
|
39 |
+
*/
|
40 |
+
public function isDeleted() {
|
41 |
+
return $this->deleted_at > 0;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return stdClass
|
46 |
+
*/
|
47 |
+
public function getRawData() {
|
48 |
+
return $this->oRowData;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param stdClass $oRowData
|
53 |
+
* @return $this
|
54 |
+
*/
|
55 |
+
public function setRawData( $oRowData ) {
|
56 |
+
$this->oRowData = $oRowData;
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param string $sKey
|
62 |
+
* @return mixed
|
63 |
+
*/
|
64 |
+
public function __get( $sKey ) {
|
65 |
+
$oD = $this->getRawData();
|
66 |
+
return isset( $oD->{$sKey} ) ? $oD->{$sKey} : null;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param string $sKey
|
71 |
+
* @return bool
|
72 |
+
*/
|
73 |
+
public function __isset( $sKey ) {
|
74 |
+
return isset( $this->getRawData()->{$sKey} );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param string $sKey
|
79 |
+
* @param mixed $mValue
|
80 |
+
* @return $this
|
81 |
+
*/
|
82 |
+
public function __set( $sKey, $mValue ) {
|
83 |
+
$this->getRawData()->{$sKey} = $mValue;
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
}
|
src/query/VOs/ICWP_WPSF_CommentsEntryVO.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_CommentsEntryVO
|
7 |
+
* @property int post_id
|
8 |
+
* @property string unique_token
|
9 |
+
* @property string ip
|
10 |
+
*/
|
11 |
+
class ICWP_WPSF_CommentsEntryVO extends ICWP_WPSF_BaseEntryVO {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function getIp() {
|
17 |
+
return (string)$this->ip;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return int
|
22 |
+
*/
|
23 |
+
public function getPostId() {
|
24 |
+
return (int)$this->post_id;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
public function getToken() {
|
31 |
+
return (string)$this->unique_token;
|
32 |
+
}
|
33 |
+
}
|
src/query/VOs/ICWP_WPSF_IpsEntryVO.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_IpsEntryVO
|
7 |
+
* @property string ip
|
8 |
+
* @property bool is_range
|
9 |
+
* @property string label
|
10 |
+
* @property string list
|
11 |
+
* @property int last_access_at
|
12 |
+
* @property int transgressions
|
13 |
+
*/
|
14 |
+
class ICWP_WPSF_IpsEntryVO extends ICWP_WPSF_BaseEntryVO {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getIp() {
|
20 |
+
return (string)$this->ip;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function getLabel() {
|
27 |
+
return (string)$this->label;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return int
|
32 |
+
*/
|
33 |
+
public function getLastAccessAt() {
|
34 |
+
return (int)$this->last_access_at;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getList() {
|
41 |
+
return (string)$this->list;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return int
|
46 |
+
*/
|
47 |
+
public function getTransgressions() {
|
48 |
+
return (int)$this->transgressions;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return bool
|
53 |
+
*/
|
54 |
+
public function hasTransgressions() {
|
55 |
+
return $this->getTransgressions() > 0;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function isIpRange() {
|
62 |
+
return (bool)$this->is_range;
|
63 |
+
}
|
64 |
+
}
|
src/query/VOs/ICWP_WPSF_NoteVO.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_NoteVO
|
7 |
+
* @property string note
|
8 |
+
* @property string wp_username
|
9 |
+
*/
|
10 |
+
class ICWP_WPSF_NoteVO extends ICWP_WPSF_BaseEntryVO {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getNote() {
|
16 |
+
return $this->note;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return int
|
21 |
+
*/
|
22 |
+
public function getUsername() {
|
23 |
+
return $this->wp_username;
|
24 |
+
}
|
25 |
+
}
|
src/query/VOs/ICWP_WPSF_SessionVO.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_SessionVO
|
7 |
+
* @property string ip
|
8 |
+
* @property string browser
|
9 |
+
* @property string wp_username
|
10 |
+
* @property int last_activity_at
|
11 |
+
* @property int logged_in_at
|
12 |
+
* @property int login_intent_expires_at
|
13 |
+
* @property string li_code_email
|
14 |
+
* @property string session_id
|
15 |
+
* @property int secadmin_at
|
16 |
+
*/
|
17 |
+
class ICWP_WPSF_SessionVO extends ICWP_WPSF_BaseEntryVO {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function getBrowser() {
|
23 |
+
return (string)$this->browser;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getIp() {
|
30 |
+
return (string)$this->ip;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return int
|
35 |
+
*/
|
36 |
+
public function getLastActivityAt() {
|
37 |
+
return (int)$this->last_activity_at;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return int
|
42 |
+
*/
|
43 |
+
public function getLoggedInAt() {
|
44 |
+
return (int)$this->logged_in_at;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return int
|
49 |
+
*/
|
50 |
+
public function getLoginIntentExpiresAt() {
|
51 |
+
return (int)$this->login_intent_expires_at;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getLoginIntentCodeEmail() {
|
58 |
+
return (string)$this->li_code_email;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getSessionId() {
|
65 |
+
return (string)$this->session_id;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @return int
|
70 |
+
*/
|
71 |
+
public function getSecAdminAt() {
|
72 |
+
return (int)$this->secadmin_at;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getUsername() {
|
79 |
+
return (string)$this->wp_username;
|
80 |
+
}
|
81 |
+
}
|
src/query/VOs/ICWP_WPSF_TallyVO.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( dirname( __FILE__ ).'/ICWP_WPSF_BaseEntryVO.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class ICWP_WPSF_TallyVO
|
7 |
+
* @property int id
|
8 |
+
* @property string stat_key
|
9 |
+
* @property string parent_stat_key
|
10 |
+
* @property int tally
|
11 |
+
* @property int modified_at
|
12 |
+
*/
|
13 |
+
class ICWP_WPSF_TallyVO extends ICWP_WPSF_BaseEntryVO {
|
14 |
+
}
|
src/query/{traffic → VOs}/ICWP_WPSF_TrafficEntryVO.php
RENAMED
File without changes
|
src/query/{statistics → VOs}/StatisticsReportingVO.php
RENAMED
File without changes
|
src/query/audittrail/ICWP_WPSF_AuditTrailEntryVO.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class ICWP_WPSF_AuditTrailEntryVO {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* @var stdClass
|
7 |
-
*/
|
8 |
-
protected $oRowData;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @param stdClass $oRowData
|
12 |
-
*/
|
13 |
-
public function __construct( $oRowData ) {
|
14 |
-
$this->oRowData = $oRowData;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return int
|
19 |
-
*/
|
20 |
-
public function getCreatedAt() {
|
21 |
-
return $this->getRowData()->created_at;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getIp() {
|
28 |
-
return $this->getRowData()->ip;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @return int
|
33 |
-
*/
|
34 |
-
public function getMessage() {
|
35 |
-
return $this->getRowData()->message;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @return int
|
40 |
-
*/
|
41 |
-
public function getUsername() {
|
42 |
-
return $this->getRowData()->wp_username;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @return int
|
47 |
-
*/
|
48 |
-
public function isDeleted() {
|
49 |
-
return $this->getRowData()->deleted_at > 0;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @return stdClass
|
54 |
-
*/
|
55 |
-
public function getRowData() {
|
56 |
-
return $this->oRowData;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @param stdClass $oRowData
|
61 |
-
* @return $this
|
62 |
-
*/
|
63 |
-
public function setRowData( $oRowData ) {
|
64 |
-
$this->oRowData = $oRowData;
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/audittrail/count.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_AuditTrail_Count', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( dirname( dirname( __FILE__ ) ).'/base/count.php' );
|
8 |
-
|
9 |
-
class ICWP_WPSF_Query_AuditTrail_Count extends ICWP_WPSF_Query_BaseCount {
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/audittrail/delete.php
CHANGED
@@ -9,11 +9,11 @@ require_once( dirname( dirname( __FILE__ ) ).'/base/delete.php' );
|
|
9 |
class ICWP_WPSF_Query_AuditTrail_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
-
protected function
|
15 |
-
require_once( dirname( __FILE__ ).'/
|
16 |
-
$oCounter = new
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
9 |
class ICWP_WPSF_Query_AuditTrail_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
+
* @return ICWP_WPSF_Query_AuditTrail_Select
|
13 |
*/
|
14 |
+
protected function getSelector() {
|
15 |
+
require_once( dirname( __FILE__ ).'/select.php' );
|
16 |
+
$oCounter = new ICWP_WPSF_Query_AuditTrail_Select();
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
src/query/audittrail/insert.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_AuditTrail_Insert', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/insert.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_AuditTrail_Insert extends ICWP_WPSF_Query_BaseInsert {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param ICWP_WPSF_AuditTrailEntryVO $oEntry
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function insert( $oEntry ) {
|
16 |
+
if ( !isset( $oEntry->ip ) ) {
|
17 |
+
$oEntry->ip = $this->loadIpService()->getRequestIp();
|
18 |
+
}
|
19 |
+
if ( is_array( $oEntry->message ) ) {
|
20 |
+
$oEntry->message = implode( ' ', $oEntry->message );
|
21 |
+
}
|
22 |
+
return parent::insert( $oEntry );
|
23 |
+
}
|
24 |
+
}
|
src/query/audittrail/select.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if ( class_exists( '
|
4 |
return;
|
5 |
}
|
6 |
|
@@ -8,23 +8,35 @@ require_once( dirname( dirname( __FILE__ ) ).'/base/select.php' );
|
|
8 |
|
9 |
class ICWP_WPSF_Query_AuditTrail_Select extends ICWP_WPSF_Query_BaseSelect {
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
/**
|
|
|
16 |
* @return ICWP_WPSF_AuditTrailEntryVO[]|stdClass[]
|
17 |
*/
|
18 |
-
public function
|
19 |
-
|
20 |
-
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
}
|
1 |
<?php
|
2 |
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_AuditTrail_Select', false ) ) {
|
4 |
return;
|
5 |
}
|
6 |
|
8 |
|
9 |
class ICWP_WPSF_Query_AuditTrail_Select extends ICWP_WPSF_Query_BaseSelect {
|
10 |
|
11 |
+
/**
|
12 |
+
* @param string $sContext
|
13 |
+
* @return $this
|
14 |
+
*/
|
15 |
+
public function filterByContext( $sContext ) {
|
16 |
+
return $this->addWhereEquals( 'context', $sContext );
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* @param string $sContext
|
21 |
* @return ICWP_WPSF_AuditTrailEntryVO[]|stdClass[]
|
22 |
*/
|
23 |
+
public function forContext( $sContext ) {
|
24 |
+
return $this->reset()
|
25 |
+
->addWhereEquals( 'context', $sContext )
|
26 |
+
->query();
|
27 |
+
}
|
28 |
|
29 |
+
/**
|
30 |
+
* @return int|stdClass[]|ICWP_WPSF_IpsEntryVO[]
|
31 |
+
*/
|
32 |
+
public function query() {
|
33 |
+
return parent::query();
|
34 |
+
}
|
35 |
|
36 |
+
/**
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
protected function getVoName() {
|
40 |
+
return 'ICWP_WPSF_AuditTrailEntryVO';
|
41 |
}
|
42 |
}
|
src/query/base/count.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_BaseSelect', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( dirname( __FILE__ ).'/query.php' );
|
8 |
-
|
9 |
-
class ICWP_WPSF_Query_BaseCount extends ICWP_WPSF_Query_BaseQuery {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @return int
|
13 |
-
*/
|
14 |
-
public function all() {
|
15 |
-
return $this->reset()
|
16 |
-
->query();
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
protected function getBaseQuery() {
|
23 |
-
return "SELECT COUNT(*) FROM `%s` WHERE %s %s";
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @return int
|
28 |
-
*/
|
29 |
-
public function query() {
|
30 |
-
return $this->loadDbProcessor()->getVar( $this->buildQuery() );
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/base/delete.php
CHANGED
@@ -9,9 +9,9 @@ require_once( dirname( __FILE__ ).'/query.php' );
|
|
9 |
abstract class ICWP_WPSF_Query_BaseDelete extends ICWP_WPSF_Query_BaseQuery {
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
-
abstract protected function
|
15 |
|
16 |
/**
|
17 |
* @return bool
|
@@ -47,9 +47,9 @@ abstract class ICWP_WPSF_Query_BaseDelete extends ICWP_WPSF_Query_BaseQuery {
|
|
47 |
$nEntriesDeleted = 0;
|
48 |
|
49 |
// The same WHEREs should apply
|
50 |
-
$nTotal = $this->
|
51 |
->setWheres( $this->getWheres() )
|
52 |
-
->
|
53 |
$nToDelete = $nTotal - $nMaxEntries;
|
54 |
|
55 |
if ( $nToDelete > 0 ) {
|
9 |
abstract class ICWP_WPSF_Query_BaseDelete extends ICWP_WPSF_Query_BaseQuery {
|
10 |
|
11 |
/**
|
12 |
+
* @return ICWP_WPSF_Query_BaseSelect
|
13 |
*/
|
14 |
+
abstract protected function getSelector();
|
15 |
|
16 |
/**
|
17 |
* @return bool
|
47 |
$nEntriesDeleted = 0;
|
48 |
|
49 |
// The same WHEREs should apply
|
50 |
+
$nTotal = $this->getSelector()
|
51 |
->setWheres( $this->getWheres() )
|
52 |
+
->count();
|
53 |
$nToDelete = $nTotal - $nMaxEntries;
|
54 |
|
55 |
if ( $nToDelete > 0 ) {
|
src/query/base/insert.php
CHANGED
@@ -20,6 +20,21 @@ class ICWP_WPSF_Query_BaseInsert extends ICWP_WPSF_Query_BaseQuery {
|
|
20 |
return is_array( $this->aInsertData ) ? $this->aInsertData : array();
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
* @param array $aInsertData
|
25 |
* @return $this
|
20 |
return is_array( $this->aInsertData ) ? $this->aInsertData : array();
|
21 |
}
|
22 |
|
23 |
+
/**
|
24 |
+
* @param ICWP_WPSF_BaseEntryVO $oEntry
|
25 |
+
* @return bool
|
26 |
+
*/
|
27 |
+
public function insert( $oEntry ) {
|
28 |
+
$oDP = $this->loadDP();
|
29 |
+
$aData = array_merge(
|
30 |
+
array(
|
31 |
+
'created_at' => $oDP->time(),
|
32 |
+
),
|
33 |
+
$oDP->convertStdClassToArray( $oEntry->getRawData() )
|
34 |
+
);
|
35 |
+
return $this->setInsertData( $aData )->query() === 1;
|
36 |
+
}
|
37 |
+
|
38 |
/**
|
39 |
* @param array $aInsertData
|
40 |
* @return $this
|
src/query/base/query.php
CHANGED
@@ -232,6 +232,13 @@ abstract class ICWP_WPSF_Query_BaseQuery extends ICWP_WPSF_Foundation {
|
|
232 |
return $this->getLimit() > 0;
|
233 |
}
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
/**
|
236 |
* @return bool
|
237 |
*/
|
@@ -325,6 +332,17 @@ abstract class ICWP_WPSF_Query_BaseQuery extends ICWP_WPSF_Foundation {
|
|
325 |
return $this;
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
/**
|
329 |
* Very basic
|
330 |
* @param string $sOp
|
@@ -333,7 +351,7 @@ abstract class ICWP_WPSF_Query_BaseQuery extends ICWP_WPSF_Foundation {
|
|
333 |
protected function isValidComparisonOperator( $sOp ) {
|
334 |
return in_array(
|
335 |
strtoupper( $sOp ),
|
336 |
-
array( '=', '<', '>', '!=', '<>', '<=', '>=', '<=>', 'LIKE' )
|
337 |
);
|
338 |
}
|
339 |
}
|
232 |
return $this->getLimit() > 0;
|
233 |
}
|
234 |
|
235 |
+
/**
|
236 |
+
* @return bool
|
237 |
+
*/
|
238 |
+
public function hasWheres() {
|
239 |
+
return count( $this->getWheres() ) > 0;
|
240 |
+
}
|
241 |
+
|
242 |
/**
|
243 |
* @return bool
|
244 |
*/
|
332 |
return $this;
|
333 |
}
|
334 |
|
335 |
+
/**
|
336 |
+
* @param ICWP_WPSF_BaseEntryVO $oVo
|
337 |
+
* @return $this
|
338 |
+
*/
|
339 |
+
public function setWheresFromVo( $oVo ) {
|
340 |
+
foreach ( $this->loadDP()->convertStdClassToArray( $oVo->getRawData() ) as $sCol => $mVal ) {
|
341 |
+
$this->addWhereEquals( $sCol, $mVal );
|
342 |
+
}
|
343 |
+
return $this;
|
344 |
+
}
|
345 |
+
|
346 |
/**
|
347 |
* Very basic
|
348 |
* @param string $sOp
|
351 |
protected function isValidComparisonOperator( $sOp ) {
|
352 |
return in_array(
|
353 |
strtoupper( $sOp ),
|
354 |
+
array( '=', '<', '>', '!=', '<>', '<=', '>=', '<=>', 'LIKE', 'NOT LIKE' )
|
355 |
);
|
356 |
}
|
357 |
}
|
src/query/base/select.php
CHANGED
@@ -18,6 +18,11 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
18 |
*/
|
19 |
protected $aColumnsDefinition;
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* @param string $sCol
|
23 |
* @return $this
|
@@ -32,8 +37,7 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
32 |
* @return stdClass[]
|
33 |
*/
|
34 |
public function all() {
|
35 |
-
return $this->reset()
|
36 |
-
->query();
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -47,21 +51,6 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
47 |
return array_shift( $aItems );
|
48 |
}
|
49 |
|
50 |
-
/**
|
51 |
-
* @return stdClass|null
|
52 |
-
*/
|
53 |
-
public function first() {
|
54 |
-
$aR = $this->query();
|
55 |
-
return empty( $aR ) ? null : array_shift( $aR );
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
protected function getBaseQuery() {
|
62 |
-
return "SELECT %s FROM `%s` WHERE %s %s";
|
63 |
-
}
|
64 |
-
|
65 |
/**
|
66 |
* @return string
|
67 |
*/
|
@@ -78,7 +67,36 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
78 |
* @return string
|
79 |
*/
|
80 |
protected function buildSelect() {
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
84 |
/**
|
@@ -95,6 +113,24 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
95 |
return is_array( $this->aColumnsDefinition ) ? $this->aColumnsDefinition : array();
|
96 |
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
/**
|
99 |
* @return bool
|
100 |
*/
|
@@ -103,13 +139,42 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
-
* @return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
*/
|
108 |
public function query() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
return $this->loadDbProcessor()
|
110 |
->selectCustom( $this->buildQuery(), OBJECT_K );
|
111 |
}
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
/**
|
114 |
* Verifies the given columns are valid and unique
|
115 |
* @param string[] $aColumns
|
@@ -139,4 +204,13 @@ class ICWP_WPSF_Query_BaseSelect extends ICWP_WPSF_Query_BaseQuery {
|
|
139 |
$this->aColumnsDefinition = $aColumns;
|
140 |
return $this;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
18 |
*/
|
19 |
protected $aColumnsDefinition;
|
20 |
|
21 |
+
/**
|
22 |
+
* @var bool
|
23 |
+
*/
|
24 |
+
protected $bIsCount = false;
|
25 |
+
|
26 |
/**
|
27 |
* @param string $sCol
|
28 |
* @return $this
|
37 |
* @return stdClass[]
|
38 |
*/
|
39 |
public function all() {
|
40 |
+
return $this->reset()->query();
|
|
|
41 |
}
|
42 |
|
43 |
/**
|
51 |
return array_shift( $aItems );
|
52 |
}
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
/**
|
55 |
* @return string
|
56 |
*/
|
67 |
* @return string
|
68 |
*/
|
69 |
protected function buildSelect() {
|
70 |
+
$sSubstitute = '*';
|
71 |
+
if ( $this->isCount() ) {
|
72 |
+
$sSubstitute = 'COUNT(*)';
|
73 |
+
}
|
74 |
+
else if ( $this->hasColumnsToSelect() ) {
|
75 |
+
$sSubstitute = implode( ',', $this->getColumnsToSelect() );
|
76 |
+
}
|
77 |
+
return $sSubstitute;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return int
|
82 |
+
*/
|
83 |
+
public function count() {
|
84 |
+
return $this->setIsCount( true )->query();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @return ICWP_WPSF_BaseEntryVO|stdClass|null
|
89 |
+
*/
|
90 |
+
public function first() {
|
91 |
+
$aR = $this->query();
|
92 |
+
return empty( $aR ) ? null : array_shift( $aR );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
protected function getBaseQuery() {
|
99 |
+
return "SELECT %s FROM `%s` WHERE %s %s";
|
100 |
}
|
101 |
|
102 |
/**
|
113 |
return is_array( $this->aColumnsDefinition ) ? $this->aColumnsDefinition : array();
|
114 |
}
|
115 |
|
116 |
+
/**
|
117 |
+
* @return ICWP_WPSF_BaseEntryVO
|
118 |
+
*/
|
119 |
+
public function getVo() {
|
120 |
+
$sClass = $this->getVoName();
|
121 |
+
if ( !class_exists( $sClass ) ) {
|
122 |
+
require_once( dirname( dirname( __FILE__ ) ).'/VOs/'.$sClass.'.php' );
|
123 |
+
}
|
124 |
+
return new $sClass();
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @return string
|
129 |
+
*/
|
130 |
+
protected function getVoName() {
|
131 |
+
return 'ICWP_WPSF_BaseEntryVO';
|
132 |
+
}
|
133 |
+
|
134 |
/**
|
135 |
* @return bool
|
136 |
*/
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
+
* @return bool
|
143 |
+
*/
|
144 |
+
public function isCount() {
|
145 |
+
return (bool)$this->bIsCount;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @return stdClass[]|int
|
150 |
*/
|
151 |
public function query() {
|
152 |
+
$mData = $this->isCount() ? $this->queryCount() : $this->querySelect();
|
153 |
+
|
154 |
+
if ( !$this->isCount() && $this->isResultsAsVo() ) {
|
155 |
+
foreach ( $mData as $nKey => $oAudit ) {
|
156 |
+
$mData[ $nKey ] = $this->getVo()->setRawData( $oAudit );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
return $mData;
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* @return stdClass[]
|
165 |
+
*/
|
166 |
+
protected function querySelect() {
|
167 |
return $this->loadDbProcessor()
|
168 |
->selectCustom( $this->buildQuery(), OBJECT_K );
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* @return int
|
173 |
+
*/
|
174 |
+
protected function queryCount() {
|
175 |
+
return $this->loadDbProcessor()->getVar( $this->buildQuery() );
|
176 |
+
}
|
177 |
+
|
178 |
/**
|
179 |
* Verifies the given columns are valid and unique
|
180 |
* @param string[] $aColumns
|
204 |
$this->aColumnsDefinition = $aColumns;
|
205 |
return $this;
|
206 |
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* @param bool $bIsCount
|
210 |
+
* @return $this
|
211 |
+
*/
|
212 |
+
public function setIsCount( $bIsCount ) {
|
213 |
+
$this->bIsCount = $bIsCount;
|
214 |
+
return $this;
|
215 |
+
}
|
216 |
}
|
src/query/base/update.php
CHANGED
@@ -44,6 +44,39 @@ class ICWP_WPSF_Query_BaseUpdate extends ICWP_WPSF_Query_BaseInsert {
|
|
44 |
return $this;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* @return int|false
|
49 |
*/
|
44 |
return $this;
|
45 |
}
|
46 |
|
47 |
+
/**
|
48 |
+
* @param int $nId
|
49 |
+
* @return $this
|
50 |
+
*/
|
51 |
+
public function setUpdateId( $nId ) {
|
52 |
+
$this->aUpdateWheres = array( 'id' => $nId );
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param ICWP_WPSF_BaseEntryVO $oEntry
|
58 |
+
* @param array $aUpdateData
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function updateEntry( $oEntry, $aUpdateData = array() ) {
|
62 |
+
$bSuccess = false;
|
63 |
+
|
64 |
+
if ( !empty( $aUpdateData ) && $oEntry instanceof ICWP_WPSF_BaseEntryVO ) {
|
65 |
+
$mResult = $this
|
66 |
+
->setUpdateId( $oEntry->getId() )
|
67 |
+
->setUpdateData( $aUpdateData )
|
68 |
+
->query();
|
69 |
+
|
70 |
+
if ( $mResult === 1 ) {
|
71 |
+
$bSuccess = true;
|
72 |
+
foreach ( $aUpdateData as $sCol => $mVal ) {
|
73 |
+
$oEntry->{$sCol} = $mVal;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
return $bSuccess;
|
78 |
+
}
|
79 |
+
|
80 |
/**
|
81 |
* @return int|false
|
82 |
*/
|
src/query/comments/delete.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Comments_Delete', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/delete.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Comments_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param ICWP_WPSF_CommentsEntryVO $oToken
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function deleteToken( $oToken ) {
|
16 |
+
return $this->deleteById( $oToken->getId() );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return ICWP_WPSF_Query_Comments_Select
|
21 |
+
*/
|
22 |
+
protected function getSelector() {
|
23 |
+
require_once( dirname( __FILE__ ).'/select.php' );
|
24 |
+
$oCounter = new ICWP_WPSF_Query_Comments_Select();
|
25 |
+
return $oCounter->setTable( $this->getTable() );
|
26 |
+
}
|
27 |
+
}
|
src/query/comments/insert.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Comments_Insert', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/insert.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Comments_Insert extends ICWP_WPSF_Query_BaseInsert {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param ICWP_WPSF_CommentsEntryVO $oToken
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function insert( $oToken ) {
|
16 |
+
if ( !isset( $oToken->ip ) ) {
|
17 |
+
$oToken->ip = $this->loadIpService()->getRequestIp();
|
18 |
+
}
|
19 |
+
return parent::insert( $oToken );
|
20 |
+
}
|
21 |
+
}
|
src/query/comments/select.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Comments_Select', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/select.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Comments_Select extends ICWP_WPSF_Query_BaseSelect {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $sToken
|
13 |
+
* @param string $nPostId
|
14 |
+
* @param string $sIp
|
15 |
+
* @return ICWP_WPSF_CommentsEntryVO|null
|
16 |
+
*/
|
17 |
+
public function getTokenForPost( $sToken, $nPostId, $sIp = null ) {
|
18 |
+
$oToken = null;
|
19 |
+
|
20 |
+
if ( !empty( $sToken ) && !empty( $nPostId ) ) {
|
21 |
+
$this->reset()
|
22 |
+
->addWhereEquals( 'unique_token', $sToken )
|
23 |
+
->addWhereEquals( 'post_id', (int)$nPostId );
|
24 |
+
if ( !empty( $sIp ) ) {
|
25 |
+
$this->addWhereEquals( 'ip', $sIp );
|
26 |
+
}
|
27 |
+
/** @var ICWP_WPSF_CommentsEntryVO $oToken */
|
28 |
+
$oToken = $this->first();
|
29 |
+
}
|
30 |
+
|
31 |
+
return $oToken;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return int|stdClass[]|ICWP_WPSF_CommentsEntryVO[]
|
36 |
+
*/
|
37 |
+
public function query() {
|
38 |
+
return parent::query();
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
protected function getVoName() {
|
45 |
+
return 'ICWP_WPSF_CommentsEntryVO';
|
46 |
+
}
|
47 |
+
}
|
src/query/ips/delete.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Ips_Delete', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/delete.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Ips_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $sIp
|
13 |
+
* @param string $sList
|
14 |
+
* @return bool
|
15 |
+
*/
|
16 |
+
public function deleteIpOnList( $sIp, $sList ) {
|
17 |
+
$this->reset();
|
18 |
+
if ( $this->loadIpService()->isValidIpOrRange( $sIp ) && !empty( $sList ) ) {
|
19 |
+
$this->addWhereEquals( 'ip', $sIp )
|
20 |
+
->addWhereEquals( 'list', $sList );
|
21 |
+
}
|
22 |
+
return $this->hasWheres() ? $this->query() : false;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return ICWP_WPSF_Query_Ips_Select
|
27 |
+
*/
|
28 |
+
protected function getSelector() {
|
29 |
+
require_once( dirname( __FILE__ ).'/select.php' );
|
30 |
+
$oCounter = new ICWP_WPSF_Query_Ips_Select();
|
31 |
+
return $oCounter->setTable( $this->getTable() );
|
32 |
+
}
|
33 |
+
}
|
src/query/ips/insert.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Ips_Insert', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/insert.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Ips_Insert extends ICWP_WPSF_Query_BaseInsert {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Requires IP and List to be set on VO.
|
13 |
+
* @param ICWP_WPSF_IpsEntryVO $oIp
|
14 |
+
* @return bool
|
15 |
+
*/
|
16 |
+
public function insert( $oIp ) {
|
17 |
+
$bSuccess = false;
|
18 |
+
if ( $this->loadIpService()->isValidIpOrRange( $oIp->ip ) && !empty( $oIp->list ) ) {
|
19 |
+
$oIp->is_range = strpos( $oIp->getIp(), '/' ) !== false;
|
20 |
+
$bSuccess = parent::insert( $oIp );
|
21 |
+
}
|
22 |
+
return $bSuccess;
|
23 |
+
}
|
24 |
+
}
|
src/query/ips/select.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Ips_Select', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/select.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Ips_Select extends ICWP_WPSF_Query_BaseSelect {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $sIp
|
13 |
+
* @return $this
|
14 |
+
*/
|
15 |
+
public function filterByIp( $sIp ) {
|
16 |
+
return $this->addWhereEquals( 'ip', $sIp );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param string $nLastAccessAfter
|
21 |
+
* @return $this
|
22 |
+
*/
|
23 |
+
public function filterByLastAccessAfter( $nLastAccessAfter ) {
|
24 |
+
return $this->addWhereNewerThan( $nLastAccessAfter, 'last_access_at' );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param string $sList
|
29 |
+
* @return $this
|
30 |
+
*/
|
31 |
+
public function filterByList( $sList ) {
|
32 |
+
return $this->addWhereEquals( 'list', $sList );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param string $sList
|
37 |
+
* @return ICWP_WPSF_IpsEntryVO[]
|
38 |
+
*/
|
39 |
+
public function allFromList( $sList ) {
|
40 |
+
/** @var ICWP_WPSF_IpsEntryVO[] $aRes */
|
41 |
+
$aRes = $this->reset()
|
42 |
+
->filterByList( $sList )
|
43 |
+
->query();
|
44 |
+
return $aRes;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
protected function getVoName() {
|
51 |
+
return 'ICWP_WPSF_IpsEntryVO';
|
52 |
+
}
|
53 |
+
}
|
src/query/ips/update.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'ICWP_WPSF_Query_Ips_Update', false ) ) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( dirname( dirname( __FILE__ ) ).'/base/update.php' );
|
8 |
+
|
9 |
+
class ICWP_WPSF_Query_Ips_Update extends ICWP_WPSF_Query_BaseUpdate {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Also updates last access at
|
13 |
+
* @param ICWP_WPSF_IpsEntryVO $oIp
|
14 |
+
* @return bool
|
15 |
+
*/
|
16 |
+
public function incrementTransgressions( $oIp ) {
|
17 |
+
return $this->updateIp(
|
18 |
+
$oIp,
|
19 |
+
array(
|
20 |
+
'transgressions' => $oIp->getTransgressions() + 1,
|
21 |
+
'last_access_at' => $this->loadDP()->time()
|
22 |
+
)
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param ICWP_WPSF_IpsEntryVO $oIp
|
28 |
+
* @param string $sLabel
|
29 |
+
* @return bool
|
30 |
+
*/
|
31 |
+
public function updateLabel( $oIp, $sLabel ) {
|
32 |
+
return $this->updateIp( $oIp, array( 'label' => $sLabel ) );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Also updates last access at
|
37 |
+
* @param ICWP_WPSF_IpsEntryVO $oIp
|
38 |
+
* @return bool
|
39 |
+
*/
|
40 |
+
public function updateLastAccessAt( $oIp ) {
|
41 |
+
return $this->updateIp(
|
42 |
+
$oIp,
|
43 |
+
array( 'last_access_at' => $this->loadDP()->time() )
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param ICWP_WPSF_IpsEntryVO $oIp
|
49 |
+
* @param array $aUpdateData
|
50 |
+
* @return bool
|
51 |
+
*/
|
52 |
+
public function updateIp( $oIp, $aUpdateData = array() ) {
|
53 |
+
return ( $oIp instanceof ICWP_WPSF_IpsEntryVO ) && parent::updateEntry( $oIp, $aUpdateData );
|
54 |
+
}
|
55 |
+
}
|
src/query/notes/ICWP_WPSF_NoteVO.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class ICWP_WPSF_NoteVO {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* @var stdClass
|
7 |
-
*/
|
8 |
-
protected $oRowData;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @param stdClass $oRowData
|
12 |
-
*/
|
13 |
-
public function __construct( $oRowData ) {
|
14 |
-
$this->oRowData = $oRowData;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return int
|
19 |
-
*/
|
20 |
-
public function getCreatedAt() {
|
21 |
-
return $this->getRowData()->created_at;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @return int
|
26 |
-
*/
|
27 |
-
public function getId() {
|
28 |
-
return $this->getRowData()->id;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @return string
|
33 |
-
*/
|
34 |
-
public function getNote() {
|
35 |
-
return $this->getRowData()->note;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @return int
|
40 |
-
*/
|
41 |
-
public function getUsername() {
|
42 |
-
return $this->getRowData()->wp_username;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @return int
|
47 |
-
*/
|
48 |
-
public function isDeleted() {
|
49 |
-
return $this->getRowData()->deleted_at > 0;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @return stdClass
|
54 |
-
*/
|
55 |
-
public function getRowData() {
|
56 |
-
return $this->oRowData;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @param stdClass $oRowData
|
61 |
-
* @return $this
|
62 |
-
*/
|
63 |
-
public function setRowData( $oRowData ) {
|
64 |
-
$this->oRowData = $oRowData;
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/notes/count.php
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_PluginNotes_Count', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( dirname( __DIR__ ).'/base/count.php' );
|
8 |
-
|
9 |
-
class ICWP_WPSF_Query_PluginNotes_Count extends ICWP_WPSF_Query_BaseCount {
|
10 |
-
|
11 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/notes/delete.php
CHANGED
@@ -9,11 +9,11 @@ require_once( dirname( __DIR__ ).'/base/delete.php' );
|
|
9 |
class ICWP_WPSF_Query_PluginNotes_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
-
protected function
|
15 |
-
require_once( __DIR__.'/
|
16 |
-
$oCounter = new
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
9 |
class ICWP_WPSF_Query_PluginNotes_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
+
* @return ICWP_WPSF_Query_PluginNotes_Select
|
13 |
*/
|
14 |
+
protected function getSelector() {
|
15 |
+
require_once( __DIR__.'/select.php' );
|
16 |
+
$oCounter = new ICWP_WPSF_Query_PluginNotes_Select();
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
src/query/notes/select.php
CHANGED
@@ -7,24 +7,10 @@ if ( class_exists( 'ICWP_WPSF_Query_PluginNotes_Select', false ) ) {
|
|
7 |
require_once( dirname( __DIR__ ).'/base/select.php' );
|
8 |
|
9 |
class ICWP_WPSF_Query_PluginNotes_Select extends ICWP_WPSF_Query_BaseSelect {
|
10 |
-
|
11 |
-
protected function customInit() {
|
12 |
-
require_once( __DIR__.'/ICWP_WPSF_NoteVO.php' );
|
13 |
-
}
|
14 |
-
|
15 |
/**
|
16 |
-
* @return
|
17 |
*/
|
18 |
-
|
19 |
-
|
20 |
-
$aData = parent::query();
|
21 |
-
|
22 |
-
if ( $this->isResultsAsVo() ) {
|
23 |
-
foreach ( $aData as $nKey => $oAudit ) {
|
24 |
-
$aData[ $nKey ] = new ICWP_WPSF_NoteVO( $oAudit );
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
return $aData;
|
29 |
}
|
30 |
}
|
7 |
require_once( dirname( __DIR__ ).'/base/select.php' );
|
8 |
|
9 |
class ICWP_WPSF_Query_PluginNotes_Select extends ICWP_WPSF_Query_BaseSelect {
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
+
* @return string
|
12 |
*/
|
13 |
+
protected function getVoName() {
|
14 |
+
return 'ICWP_WPSF_NoteVO';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
}
|
src/query/sessions/ICWP_WPSF_SessionVO.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class ICWP_WPSF_SessionVO {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* @var stdClass
|
7 |
-
*/
|
8 |
-
protected $oRowData;
|
9 |
-
|
10 |
-
/**
|
11 |
-
* @param stdClass $oRowData
|
12 |
-
*/
|
13 |
-
public function __construct( $oRowData ) {
|
14 |
-
$this->oRowData = $oRowData;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return int
|
19 |
-
*/
|
20 |
-
public function getCreatedAt() {
|
21 |
-
return $this->getRowData()->created_at;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getBrowser() {
|
28 |
-
return $this->getRowData()->browser;
|
29 |
-
}
|
30 |
-
/**
|
31 |
-
* @return int
|
32 |
-
*/
|
33 |
-
public function getId() {
|
34 |
-
return $this->getRowData()->id;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @return string
|
39 |
-
*/
|
40 |
-
public function getIp() {
|
41 |
-
return $this->getRowData()->ip;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @return int
|
46 |
-
*/
|
47 |
-
public function getLastActivityAt() {
|
48 |
-
return (int)$this->getRowData()->last_activity_at;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @return int
|
53 |
-
*/
|
54 |
-
public function getLoggedInAt() {
|
55 |
-
return (int)$this->getRowData()->logged_in_at;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @return int
|
60 |
-
*/
|
61 |
-
public function getLoginIntentExpiresAt() {
|
62 |
-
return (int)$this->getRowData()->login_intent_expires_at;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* @return string
|
67 |
-
*/
|
68 |
-
public function getLoginIntentCodeEmail() {
|
69 |
-
return (string)$this->getRowData()->li_code_email;
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @return int
|
74 |
-
*/
|
75 |
-
public function getSessionId() {
|
76 |
-
return $this->getRowData()->session_id;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* @return int
|
81 |
-
*/
|
82 |
-
public function getSecAdminAt() {
|
83 |
-
return (int)$this->getRowData()->secadmin_at;
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @return int
|
88 |
-
*/
|
89 |
-
public function getUsername() {
|
90 |
-
return $this->getRowData()->wp_username;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @return int
|
95 |
-
*/
|
96 |
-
public function isDeleted() {
|
97 |
-
return $this->getRowData()->deleted_at > 0;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @return stdClass
|
102 |
-
*/
|
103 |
-
public function getRowData() {
|
104 |
-
return $this->oRowData;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* @param stdClass $oRowData
|
109 |
-
* @return $this
|
110 |
-
*/
|
111 |
-
public function setRowData( $oRowData ) {
|
112 |
-
$this->oRowData = $oRowData;
|
113 |
-
return $this;
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/sessions/count.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_Sessions_Count', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( dirname( dirname( __FILE__ ) ).'/base/count.php' );
|
8 |
-
|
9 |
-
class ICWP_WPSF_Query_Sessions_Count extends ICWP_WPSF_Query_BaseCount {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @param string $sUsername
|
13 |
-
* @return int
|
14 |
-
*/
|
15 |
-
public function forUsername( $sUsername ) {
|
16 |
-
return $this->reset()
|
17 |
-
->addWhereEquals( 'wp_username', $sUsername )
|
18 |
-
->query();
|
19 |
-
}
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/sessions/delete.php
CHANGED
@@ -39,11 +39,11 @@ class ICWP_WPSF_Query_Sessions_Delete extends ICWP_WPSF_Query_BaseDelete {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* @return
|
43 |
*/
|
44 |
-
protected function
|
45 |
-
require_once( dirname( __FILE__ ).'/
|
46 |
-
$oCounter = new
|
47 |
return $oCounter->setTable( $this->getTable() );
|
48 |
}
|
49 |
}
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @return ICWP_WPSF_Query_Sessions_Select
|
43 |
*/
|
44 |
+
protected function getSelector() {
|
45 |
+
require_once( dirname( __FILE__ ).'/select.php' );
|
46 |
+
$oCounter = new ICWP_WPSF_Query_Sessions_Select();
|
47 |
return $oCounter->setTable( $this->getTable() );
|
48 |
}
|
49 |
}
|
src/query/sessions/select.php
CHANGED
@@ -16,12 +16,27 @@ class ICWP_WPSF_Query_Sessions_Select extends ICWP_WPSF_Query_BaseSelect {
|
|
16 |
}
|
17 |
|
18 |
/**
|
19 |
-
* @param
|
20 |
-
* @return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
*/
|
22 |
-
public function
|
23 |
-
return $this->addWhereEquals( 'wp_username', $
|
24 |
-
->query();
|
25 |
}
|
26 |
|
27 |
/**
|
@@ -47,40 +62,15 @@ class ICWP_WPSF_Query_Sessions_Select extends ICWP_WPSF_Query_BaseSelect {
|
|
47 |
$this->addWhereEquals( 'session_id', $sSessionId );
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
* @
|
56 |
-
* @return $this
|
57 |
-
*/
|
58 |
-
public function filterByLoginNotExpired( $nExpiredBoundary ) {
|
59 |
-
return $this->addWhereNewerThan( $nExpiredBoundary, 'logged_in_at' );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* @param int $nExpiredBoundary
|
64 |
-
* @return $this
|
65 |
*/
|
66 |
-
|
67 |
-
return
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* @return ICWP_WPSF_SessionVO[]|stdClass[]
|
72 |
-
*/
|
73 |
-
public function query() {
|
74 |
-
$aData = parent::query();
|
75 |
-
if ( $this->isResultsAsVo() ) {
|
76 |
-
foreach ( $aData as $nKey => $oSess ) {
|
77 |
-
$aData[ $nKey ] = new ICWP_WPSF_SessionVO( $oSess );
|
78 |
-
}
|
79 |
-
}
|
80 |
-
return $aData;
|
81 |
-
}
|
82 |
-
|
83 |
-
protected function customInit() {
|
84 |
-
require_once( dirname( __FILE__ ).'/ICWP_WPSF_SessionVO.php' );
|
85 |
}
|
86 |
}
|
16 |
}
|
17 |
|
18 |
/**
|
19 |
+
* @param int $nExpiredBoundary
|
20 |
+
* @return $this
|
21 |
+
*/
|
22 |
+
public function filterByLoginNotExpired( $nExpiredBoundary ) {
|
23 |
+
return $this->addWhereNewerThan( $nExpiredBoundary, 'logged_in_at' );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param int $nExpiredBoundary
|
28 |
+
* @return $this
|
29 |
+
*/
|
30 |
+
public function filterByLoginNotIdleExpired( $nExpiredBoundary ) {
|
31 |
+
return $this->addWhereNewerThan( $nExpiredBoundary, 'last_activity_at' );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param int $sUsername
|
36 |
+
* @return $this
|
37 |
*/
|
38 |
+
public function filterByUsername( $sUsername ) {
|
39 |
+
return $this->addWhereEquals( 'wp_username', $sUsername );
|
|
|
40 |
}
|
41 |
|
42 |
/**
|
62 |
$this->addWhereEquals( 'session_id', $sSessionId );
|
63 |
}
|
64 |
|
65 |
+
/** @var ICWP_WPSF_SessionVO[] $aRes */
|
66 |
+
$aRes = $this->setOrderBy( 'last_activity_at', 'DESC' )->query();
|
67 |
+
return $aRes;
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* @return string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
*/
|
73 |
+
protected function getVoName() {
|
74 |
+
return 'ICWP_WPSF_SessionVO';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
}
|
src/query/sessions/update.php
CHANGED
@@ -74,27 +74,6 @@ class ICWP_WPSF_Query_Sessions_Update extends ICWP_WPSF_Query_BaseUpdate {
|
|
74 |
* @return bool
|
75 |
*/
|
76 |
public function updateSession( $oSession, $aUpdateData = array() ) {
|
77 |
-
$
|
78 |
-
if ( !empty( $aUpdateData ) && $oSession instanceof ICWP_WPSF_SessionVO ) {
|
79 |
-
$mResult = $this
|
80 |
-
->setUpdateData( $aUpdateData )
|
81 |
-
->setUpdateWheres(
|
82 |
-
array(
|
83 |
-
'session_id' => $oSession->getSessionId(),
|
84 |
-
'wp_username' => $oSession->getUsername(),
|
85 |
-
'deleted_at' => 0
|
86 |
-
)
|
87 |
-
)
|
88 |
-
->query();
|
89 |
-
$bSuccess = is_numeric( $mResult ) && $mResult === 1;
|
90 |
-
|
91 |
-
if ( $bSuccess ) {
|
92 |
-
foreach ( $aUpdateData as $sColumn => $mValue ) {
|
93 |
-
$oSession->{$sColumn} = $mValue;
|
94 |
-
}
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
return $bSuccess;
|
99 |
}
|
100 |
}
|
74 |
* @return bool
|
75 |
*/
|
76 |
public function updateSession( $oSession, $aUpdateData = array() ) {
|
77 |
+
return ( $oSession instanceof ICWP_WPSF_SessionVO ) && parent::updateEntry( $oSession, $aUpdateData );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
}
|
src/query/statistics/ICWP_WPSF_TallyVO.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class ICWP_WPSF_TallyVO
|
5 |
-
* @property int id
|
6 |
-
* @property string stat_key
|
7 |
-
* @property string parent_stat_key
|
8 |
-
* @property int tally
|
9 |
-
* @property int created_at
|
10 |
-
* @property int modified_at
|
11 |
-
* @property int deleted_at
|
12 |
-
*/
|
13 |
-
class ICWP_WPSF_TallyVO {
|
14 |
-
|
15 |
-
use \FernleafSystems\Utilities\Data\Adapter\StdClassAdapter {
|
16 |
-
__get as __parentGet;
|
17 |
-
}
|
18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/statistics/tally_count.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_Tally_Count', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( dirname( __DIR__ ).'/base/count.php' );
|
8 |
-
|
9 |
-
class ICWP_WPSF_Query_Tally_Count extends ICWP_WPSF_Query_BaseCount {
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/statistics/tally_delete.php
CHANGED
@@ -9,11 +9,11 @@ require_once( dirname( __DIR__ ).'/base/delete.php' );
|
|
9 |
class ICWP_WPSF_Query_Tally_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
-
protected function
|
15 |
-
require_once( __DIR__.'/
|
16 |
-
$oCounter = new
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
9 |
class ICWP_WPSF_Query_Tally_Delete extends ICWP_WPSF_Query_BaseDelete {
|
10 |
|
11 |
/**
|
12 |
+
* @return ICWP_WPSF_Query_Tally_Select
|
13 |
*/
|
14 |
+
protected function getSelector() {
|
15 |
+
require_once( __DIR__.'/tally_select.php' );
|
16 |
+
$oCounter = new ICWP_WPSF_Query_Tally_Select();
|
17 |
return $oCounter->setTable( $this->getTable() );
|
18 |
}
|
19 |
}
|
src/query/statistics/tally_insert.php
CHANGED
@@ -8,13 +8,26 @@ require_once( dirname( __DIR__ ).'/base/insert.php' );
|
|
8 |
|
9 |
class ICWP_WPSF_Query_Tally_Insert extends ICWP_WPSF_Query_BaseInsert {
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
* @param string sStatKey
|
13 |
* @param string $sParent
|
14 |
* @param int $nTally
|
15 |
* @return bool
|
16 |
*/
|
17 |
-
public function
|
18 |
if ( !preg_match( '#[a-z]{1,}\.[a-z]{1,}#i', $sStatKey ) || empty( $nTally )
|
19 |
|| !is_numeric( $nTally ) || $nTally < 0 ) {
|
20 |
return false;
|
8 |
|
9 |
class ICWP_WPSF_Query_Tally_Insert extends ICWP_WPSF_Query_BaseInsert {
|
10 |
|
11 |
+
/**
|
12 |
+
* @param ICWP_WPSF_TallyVO $oTally
|
13 |
+
* @return bool
|
14 |
+
*/
|
15 |
+
public function insert( $oTally ) {
|
16 |
+
$bSuccess = false;
|
17 |
+
if ( preg_match( '#[a-z]{1,}\.[a-z]{1,}#i', $oTally->stat_key )
|
18 |
+
&& is_numeric( $oTally->tally ) && $oTally->tally > 0 ) {
|
19 |
+
$bSuccess = parent::insert( $oTally );
|
20 |
+
}
|
21 |
+
return $bSuccess;
|
22 |
+
}
|
23 |
+
|
24 |
/**
|
25 |
* @param string sStatKey
|
26 |
* @param string $sParent
|
27 |
* @param int $nTally
|
28 |
* @return bool
|
29 |
*/
|
30 |
+
public function create( $sStatKey, $nTally, $sParent = '' ) {
|
31 |
if ( !preg_match( '#[a-z]{1,}\.[a-z]{1,}#i', $sStatKey ) || empty( $nTally )
|
32 |
|| !is_numeric( $nTally ) || $nTally < 0 ) {
|
33 |
return false;
|
src/query/statistics/tally_select.php
CHANGED
@@ -40,22 +40,9 @@ class ICWP_WPSF_Query_Tally_Select extends ICWP_WPSF_Query_BaseSelect {
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* @return
|
44 |
*/
|
45 |
-
|
46 |
-
|
47 |
-
if ( $this->isResultsAsVo() ) {
|
48 |
-
$aData = array_map(
|
49 |
-
function ( $oResult ) {
|
50 |
-
return ( new ICWP_WPSF_TallyVO() )->setRawData( $oResult );
|
51 |
-
},
|
52 |
-
$aData
|
53 |
-
);
|
54 |
-
}
|
55 |
-
return $aData;
|
56 |
-
}
|
57 |
-
|
58 |
-
protected function customInit() {
|
59 |
-
require_once( dirname( __FILE__ ).'/ICWP_WPSF_TallyVO.php' );
|
60 |
}
|
61 |
}
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* @return string
|
44 |
*/
|
45 |
+
protected function getVoName() {
|
46 |
+
return 'ICWP_WPSF_TallyVO';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
}
|
src/query/statistics/tally_update.php
CHANGED
@@ -23,19 +23,6 @@ class ICWP_WPSF_Query_Tally_Update extends ICWP_WPSF_Query_BaseUpdate {
|
|
23 |
* @return bool
|
24 |
*/
|
25 |
public function updateStat( $oStat, $aUpdateData = array() ) {
|
26 |
-
$
|
27 |
-
if ( !empty( $aUpdateData ) && $oStat instanceof ICWP_WPSF_TallyVO ) {
|
28 |
-
$mResult = $this
|
29 |
-
->setUpdateData( $aUpdateData )
|
30 |
-
->setUpdateWheres(
|
31 |
-
array(
|
32 |
-
'stat_key' => $oStat->stat_key,
|
33 |
-
'parent_stat_key' => $oStat->parent_stat_key,
|
34 |
-
'deleted_at' => 0
|
35 |
-
)
|
36 |
-
)
|
37 |
-
->query();
|
38 |
-
}
|
39 |
-
return is_numeric( $mResult ) && $mResult === 1;
|
40 |
}
|
41 |
}
|
23 |
* @return bool
|
24 |
*/
|
25 |
public function updateStat( $oStat, $aUpdateData = array() ) {
|
26 |
+
return ( $oStat instanceof ICWP_WPSF_TallyVO ) && parent::updateEntry( $oStat, $aUpdateData );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
}
|
src/query/traffic/common.php
CHANGED
@@ -81,4 +81,11 @@ trait ICWP_WPSF_Query_TrafficEntry_Common {
|
|
81 |
}
|
82 |
return $this;
|
83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
81 |
}
|
82 |
return $this;
|
83 |
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @return string
|
87 |
+
*/
|
88 |
+
protected function getVoName() {
|
89 |
+
return 'ICWP_WPSF_TallyVO';
|
90 |
+
}
|
91 |
}
|
src/query/traffic/count.php
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( class_exists( 'ICWP_WPSF_Query_TrafficEntry_Count', false ) ) {
|
4 |
-
return;
|
5 |
-
}
|
6 |
-
|
7 |
-
require_once( __DIR__.'/common.php' );
|
8 |
-
require_once( dirname( __DIR__ ).'/base/count.php' );
|
9 |
-
|
10 |
-
class ICWP_WPSF_Query_TrafficEntry_Count extends ICWP_WPSF_Query_BaseCount {
|
11 |
-
|
12 |
-
use ICWP_WPSF_Query_TrafficEntry_Common;
|
13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/query/traffic/delete.php
CHANGED
@@ -12,11 +12,11 @@ class ICWP_WPSF_Query_TrafficEntry_Delete extends ICWP_WPSF_Query_BaseDelete {
|
|
12 |
use ICWP_WPSF_Query_TrafficEntry_Common;
|
13 |
|
14 |
/**
|
15 |
-
* @return
|
16 |
*/
|
17 |
-
protected function
|
18 |
-
require_once( __DIR__.'/
|
19 |
-
$oCounter = new
|
20 |
return $oCounter->setTable( $this->getTable() );
|
21 |
}
|
22 |
}
|
12 |
use ICWP_WPSF_Query_TrafficEntry_Common;
|
13 |
|
14 |
/**
|
15 |
+
* @return ICWP_WPSF_Query_TrafficEntry_Select
|
16 |
*/
|
17 |
+
protected function getSelector() {
|
18 |
+
require_once( __DIR__.'/select.php' );
|
19 |
+
$oCounter = new ICWP_WPSF_Query_TrafficEntry_Select();
|
20 |
return $oCounter->setTable( $this->getTable() );
|
21 |
}
|
22 |
}
|
src/query/traffic/select.php
CHANGED
@@ -11,26 +11,10 @@ class ICWP_WPSF_Query_TrafficEntry_Select extends ICWP_WPSF_Query_BaseSelect {
|
|
11 |
|
12 |
use ICWP_WPSF_Query_TrafficEntry_Common;
|
13 |
|
14 |
-
protected function customInit() {
|
15 |
-
require_once( __DIR__.'/ICWP_WPSF_TrafficEntryVO.php' );
|
16 |
-
}
|
17 |
-
|
18 |
/**
|
19 |
-
* @return
|
20 |
*/
|
21 |
-
|
22 |
-
|
23 |
-
$aData = parent::query();
|
24 |
-
|
25 |
-
if ( $this->isResultsAsVo() ) {
|
26 |
-
$aData = array_map(
|
27 |
-
function ( $oResult ) {
|
28 |
-
return ( new ICWP_WPSF_TrafficEntryVO() )->setRawData( $oResult );
|
29 |
-
},
|
30 |
-
$aData
|
31 |
-
);
|
32 |
-
}
|
33 |
-
|
34 |
-
return $aData;
|
35 |
}
|
36 |
}
|
11 |
|
12 |
use ICWP_WPSF_Query_TrafficEntry_Common;
|
13 |
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
+
* @return string
|
16 |
*/
|
17 |
+
protected function getVoName() {
|
18 |
+
return 'ICWP_WPSF_TrafficEntryVO';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
}
|
src/wizards/plugin.php
CHANGED
@@ -662,7 +662,7 @@ class ICWP_WPSF_Wizard_Plugin extends ICWP_WPSF_Wizard_BaseWpsf {
|
|
662 |
if ( $bDelete ) {
|
663 |
/** @var ICWP_WPSF_Processor_AuditTrail $oProc */
|
664 |
$oProc = $this->getPluginCon()->getModule( 'audit_trail' )->getProcessor();
|
665 |
-
$oDeleter = $oProc->
|
666 |
foreach ( $this->getGdprSearchItems() as $sItem ) {
|
667 |
$oDeleter->reset()
|
668 |
->addWhereSearch( 'wp_username', $sItem )
|
@@ -754,7 +754,7 @@ class ICWP_WPSF_Wizard_Plugin extends ICWP_WPSF_Wizard_BaseWpsf {
|
|
754 |
private function runGdprSearch() {
|
755 |
/** @var ICWP_WPSF_Processor_AuditTrail $oProc */
|
756 |
$oProc = $this->getPluginCon()->getModule( 'audit_trail' )->getProcessor();
|
757 |
-
$oFinder = $oProc->
|
758 |
->setResultsAsVo( false );
|
759 |
|
760 |
$aItems = array();
|
662 |
if ( $bDelete ) {
|
663 |
/** @var ICWP_WPSF_Processor_AuditTrail $oProc */
|
664 |
$oProc = $this->getPluginCon()->getModule( 'audit_trail' )->getProcessor();
|
665 |
+
$oDeleter = $oProc->getQueryDeleter();
|
666 |
foreach ( $this->getGdprSearchItems() as $sItem ) {
|
667 |
$oDeleter->reset()
|
668 |
->addWhereSearch( 'wp_username', $sItem )
|
754 |
private function runGdprSearch() {
|
755 |
/** @var ICWP_WPSF_Processor_AuditTrail $oProc */
|
756 |
$oProc = $this->getPluginCon()->getModule( 'audit_trail' )->getProcessor();
|
757 |
+
$oFinder = $oProc->getQuerySelector()
|
758 |
->setResultsAsVo( false );
|
759 |
|
760 |
$aItems = array();
|