Version Description
Current Release = Released: 13th May, 2019 - Release Notes
(v.0) NEW: [PRO] Manual/Automatic User Suspension
(v.0) NEW: Comment SPAM - Increase minimum number of approved comments before scanning is skipped
(v.0) NEW: [PRO] Comment SPAM - Trusted user roles where comments scanning is skipped
(v.0) IMPROVED: AntiBot JS was improperly included when not required.
(v.0) IMPROVED: Added a GeoIP caching table and removed bundled GeoIP database - greatly reduces download size.
(v.0) FIXED: Inconsistent behaviour when PWA plugin is active and it infinitely reloads pages.
(v.0) FIXED: Inconsistent behaviour with Anonymous API blocking.
(v.0) IMPROVED: Code improvements and refactoring.
(v.0) ADDED: Prep for upcoming malware scanner.
Release Info
Developer | paultgoodchild |
Plugin | Shield Security for WordPress |
Version | 7.4.0 |
Comparing to | |
See all releases |
Code changes from version 7.3.2 to 7.4.0
- icwp-plugin-controller.php +116 -103
- icwp-wpsf.php +1 -1
- plugin-spec.php +2 -2
- readme.txt +29 -17
- resources/db/GeoIp2/GeoLite2-Country.mmdb +0 -0
- src/common/wp-comments.php +27 -0
- src/config/feature-comments_filter.php +41 -2
- src/config/feature-hack_protect.php +70 -4
- src/config/feature-lockdown.php +1 -1
- src/config/feature-plugin.php +8 -0
- src/config/feature-user_management.php +19 -3
- src/features/admin_access_restriction.php +47 -47
- src/features/audit_trail.php +38 -38
- src/features/autoupdates.php +30 -30
- src/features/base.php +67 -71
- src/features/base_wpsf.php +23 -22
- src/features/comments_filter.php +130 -57
- src/features/firewall.php +16 -16
- src/features/hack_protect.php +142 -135
- src/features/headers.php +16 -16
- src/features/insights.php +142 -143
- src/features/ips.php +14 -20
- src/features/license.php +27 -27
- src/features/lockdown.php +22 -22
- src/features/login_protect.php +45 -88
- src/features/plugin.php +46 -46
- src/features/sessions.php +2 -2
- src/features/statistics.php +6 -6
- src/features/traffic.php +7 -8
- src/features/user_management.php +115 -68
- src/lib/src/Crons/StandardCron.php +2 -2
- src/lib/src/Databases/Base/BaseQuery.php +3 -3
- src/lib/src/Databases/Base/Select.php +1 -1
- src/lib/src/Databases/GeoIp/BaseGeoIp.php +30 -0
- src/lib/src/Databases/GeoIp/Delete.php +9 -0
- src/lib/src/Databases/GeoIp/EntryVO.php +70 -0
- src/lib/src/Databases/GeoIp/Handler.php +8 -0
- src/lib/src/Databases/GeoIp/Insert.php +8 -0
- src/lib/src/Databases/GeoIp/Select.php +34 -0
- src/lib/src/Modules/GeoIp/Lookup.php +70 -0
- src/lib/src/Modules/UserManagement/Suspend/Base.php +2 -2
- src/lib/src/Modules/UserManagement/Suspend/Idle.php +10 -24
- src/lib/src/Modules/UserManagement/Suspend/PasswordExpiry.php +5 -4
- src/lib/src/Modules/UserManagement/Suspend/Suspended.php +1 -1
- src/lib/src/Scans/Helpers/{WpCoreFileDownload.php → WpCoreFile.php} +29 -3
- src/lib/src/Scans/Mal/ConvertResultsToVos.php +23 -0
- src/lib/src/Scans/Mal/ConvertVosToResults.php +33 -0
- src/lib/src/Scans/Mal/Repair.php +49 -0
- src/lib/src/Scans/Mal/ResultItem.php +32 -0
- src/lib/src/Scans/Mal/ResultsSet.php +27 -0
- src/lib/src/Scans/Mal/Scanner.php +145 -0
- src/lib/src/Scans/Wcf/Repair.php +2 -20
- src/lib/src/Tables/Build/ScanMal.php +45 -0
- src/lib/src/Tables/Build/Traffic.php +18 -35
- src/lib/src/Users/ShieldUserMeta.php +21 -5
- src/lib/src/Utilities/VisitorIpDetection.php +2 -3
- src/lib/vendor/composer/autoload_classmap.php +35 -1
- src/lib/vendor/composer/autoload_static.php +35 -1
- src/lib/vendor/composer/installed.json +10 -10
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/AdminNotices.php +15 -14
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Comments.php +2 -2
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/CoreFileHashes.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Cron.php +4 -4
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/CustomHooks.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Db.php +9 -9
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php +14 -14
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/General.php +54 -54
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Includes.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Plugins.php +27 -27
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Request.php +5 -5
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Response.php +5 -5
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Themes.php +13 -13
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Track.php +5 -5
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Upgrades/BulkPluginUpgraderSkin.php +4 -4
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Upgrades/BulkThemeUpgraderSkin.php +3 -3
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Upgrades/PluginUpgrader.php +11 -11
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Upgrades/ThemeUpgrader.php +13 -13
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Upgrades/UpgraderSkin.php +2 -2
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Users.php +10 -10
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/VOs/WpHttpResponseVo.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Services.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/ClassicPress/Checksums.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Consumers/PluginConsumer.php +40 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Data.php +10 -10
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php +1 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Email.php +10 -10
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Encrypt/OpenSslEncrypt.php +2 -2
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/GeoIp.php +1 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/HttpRequest.php +4 -4
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/HttpUtil.php +49 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/IpUtils.php +13 -13
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Net/VisitorIpDetection.php +2 -3
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/PluginUserMeta.php +13 -17
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/Render.php +7 -8
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php +8 -8
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php +103 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/VersionsBase.php +63 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Core.php +6 -1
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Files.php +26 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php +81 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Versions.php +49 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Api.php +47 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Base.php +31 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Download.php +49 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Files.php +142 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php +62 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/VOs/PluginInfoVO.php +45 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Versions.php +92 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugins.php +10 -5
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Base.php +11 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Files.php +42 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php +76 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Versions.php +53 -0
- src/lib/vendor/nesbot/carbon/src/Carbon/Carbon.php +1 -1
- src/processors/admin_access_restriction.php +54 -54
- src/processors/adminaccess_whitelabel.php +6 -6
- src/processors/audit_trail_auditor.php +1 -1
- src/processors/audit_trail_emails.php +5 -5
- src/processors/audit_trail_plugins.php +3 -3
- src/processors/audit_trail_posts.php +11 -11
- src/processors/audit_trail_themes.php +2 -2
- src/processors/audit_trail_users.php +4 -4
- src/processors/audit_trail_wordpress.php +2 -2
- src/processors/audit_trail_wpsf.php +2 -1
- src/processors/autoupdates.php +22 -22
- src/processors/base.php +24 -10
- src/processors/base_commentsfilter.php +6 -6
- src/processors/base_plugin.php +26 -26
- src/processors/base_wpsf.php +10 -10
- src/processors/basedb.php +1 -1
- src/processors/comments_filter.php +13 -12
- src/processors/commentsfilter_antibotspam.php +11 -27
- src/processors/commentsfilter_googlerecaptcha.php +7 -6
- src/processors/commentsfilter_humanspam.php +42 -125
- src/processors/firewall.php +73 -104
- src/processors/hack_protect.php +88 -66
- src/processors/hackprotect_integrity.php +6 -17
- src/processors/hackprotect_scan_apc.php +4 -4
- src/processors/hackprotect_scan_mal.php +187 -0
- src/processors/hackprotect_scan_ptg.php +26 -26
- src/processors/hackprotect_scan_ufc.php +2 -2
- src/processors/hackprotect_scan_wcf.php +2 -2
- src/processors/hackprotect_scan_wpv.php +18 -19
- src/processors/hackprotect_scanner.php +19 -8
- src/processors/headers.php +23 -22
- src/processors/ips.php +18 -18
- src/processors/lockdown.php +14 -25
- src/processors/login_protect.php +51 -9
- src/processors/loginprotect_base.php +48 -36
- src/processors/loginprotect_gasp.php +4 -4
- src/processors/loginprotect_googlerecaptcha.php +2 -2
- src/processors/loginprotect_intent.php +14 -14
- src/processors/loginprotect_intentprovider_backup.php +10 -10
- src/processors/loginprotect_intentprovider_base.php +8 -8
- src/processors/loginprotect_intentprovider_email.php +10 -10
- src/processors/loginprotect_intentprovider_ga.php +13 -13
- src/processors/loginprotect_intentprovider_yubikey.php +8 -8
- src/processors/loginprotect_wplogin.php +11 -11
- src/processors/plugin.php +45 -35
- src/processors/plugin_badge.php +8 -8
- src/processors/plugin_badgewidget.php +9 -9
- src/processors/plugin_cronhourly.php +1 -0
- src/processors/plugin_geoip.php +54 -0
- src/processors/plugin_importexport.php +20 -20
- src/processors/plugin_notes.php +1 -1
- src/processors/plugin_tracking.php +15 -15
- src/processors/sessions.php +1 -1
- src/processors/statistics.php +28 -31
- src/processors/statistics_reporting.php +4 -4
- src/processors/user_management.php +22 -18
- src/processors/usermanagement_passwords.php +22 -23
- src/processors/usermanagement_sessions.php +4 -4
- src/processors/usermanagement_suspend.php +77 -34
- templates/php/index_header.php +1 -1
- templates/twig/snippets/user/profile/suspend.twig +23 -11
- templates/twig/wpadmin_pages/insights_new/scans/results/mal.twig +70 -0
- templates/twig/wpadmin_pages/insights_new/scans/scan_areas.twig +21 -3
- templates/twig/wpadmin_pages/insights_new/scans/scan_results.twig +0 -27
- templates/twig/wpadmin_pages/insights_new/scans/scan_start.twig +1 -4
@@ -83,7 +83,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
83 |
private $sConfigOptionsHashWhenLoaded;
|
84 |
|
85 |
/**
|
86 |
-
* @var
|
87 |
*/
|
88 |
private $bMeetsBasePermissions;
|
89 |
|
@@ -92,11 +92,6 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
92 |
*/
|
93 |
protected $sAdminNoticeError = '';
|
94 |
|
95 |
-
/**
|
96 |
-
* @var ICWP_WPSF_FeatureHandler_Plugin
|
97 |
-
*/
|
98 |
-
protected $oFeatureHandlerPlugin;
|
99 |
-
|
100 |
/**
|
101 |
* @var ICWP_WPSF_FeatureHandler_Base[]
|
102 |
*/
|
@@ -138,7 +133,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
138 |
* @throws \Exception
|
139 |
*/
|
140 |
private function readPluginSpecification() {
|
141 |
-
$aSpec =
|
142 |
$sContents = $this->loadDP()->readFileContentsUsingInclude( $this->getPathPluginSpec() );
|
143 |
if ( !empty( $sContents ) ) {
|
144 |
$aSpec = json_decode( $sContents, true );
|
@@ -180,8 +175,8 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
180 |
|
181 |
if ( !$bMeetsRequirements ) {
|
182 |
$this->aRequirementsMessages = $aRequirementsMessages;
|
183 |
-
add_action( 'admin_notices',
|
184 |
-
add_action( 'network_admin_notices',
|
185 |
throw new Exception( 'Plugin does not meet minimum requirements' );
|
186 |
}
|
187 |
}
|
@@ -191,16 +186,16 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
191 |
public function adminNoticeDoesNotMeetRequirements() {
|
192 |
$aMessages = $this->getRequirementsMessages();
|
193 |
if ( !empty( $aMessages ) && is_array( $aMessages ) ) {
|
194 |
-
$aDisplayData =
|
195 |
-
'strings' =>
|
196 |
'requirements' => $aMessages,
|
197 |
'summary_title' => sprintf( 'Web Hosting requirements for Plugin "%s" are not met and you should deactivate the plugin.', $this->getHumanName() ),
|
198 |
'more_information' => 'Click here for more information on requirements'
|
199 |
-
|
200 |
-
'hrefs' =>
|
201 |
'more_information' => sprintf( 'https://wordpress.org/plugins/%s/faq', $this->getTextDomain() )
|
202 |
-
|
203 |
-
|
204 |
|
205 |
$this->loadRenderer( $this->getPath_Templates() )
|
206 |
->setTemplate( 'notices/does-not-meet-requirements' )
|
@@ -212,12 +207,12 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
212 |
/**
|
213 |
*/
|
214 |
public function adminNoticePluginFailedToLoad() {
|
215 |
-
$aDisplayData =
|
216 |
-
'strings' =>
|
217 |
'summary_title' => 'Perhaps due to a failed upgrade, the Shield plugin failed to load certain component(s) - you should remove the plugin and reinstall.',
|
218 |
'more_information' => $this->sAdminNoticeError
|
219 |
-
|
220 |
-
|
221 |
$this->loadRenderer( $this->getPath_Templates() )
|
222 |
->setTemplate( 'notices/plugin-failed-to-load' )
|
223 |
->setRenderVars( $aDisplayData )
|
@@ -237,9 +232,9 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
237 |
*/
|
238 |
protected function getRequirementsMessages() {
|
239 |
if ( !isset( $this->aRequirementsMessages ) ) {
|
240 |
-
$this->aRequirementsMessages =
|
241 |
'<h4>Shield Security Plugin - minimum site requirements are not met:</h4>'
|
242 |
-
|
243 |
}
|
244 |
return $this->aRequirementsMessages;
|
245 |
}
|
@@ -305,41 +300,41 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
305 |
protected function doRegisterHooks() {
|
306 |
register_deactivation_hook( $this->getRootFile(), [ $this, 'onWpDeactivatePlugin' ] );
|
307 |
|
308 |
-
add_action( 'init',
|
309 |
-
add_action( 'admin_init',
|
310 |
-
add_action( 'wp_loaded',
|
311 |
|
312 |
-
add_action( 'admin_menu',
|
313 |
-
add_action( 'network_admin_menu',
|
314 |
|
315 |
if ( Services::WpGeneral()->isAjax() ) {
|
316 |
-
add_action( 'wp_ajax_'.$this->prefix(),
|
317 |
-
add_action( 'wp_ajax_nopriv_'.$this->prefix(),
|
318 |
}
|
319 |
|
320 |
$sBaseFile = $this->getPluginBaseFile();
|
321 |
-
add_filter( 'all_plugins',
|
322 |
-
add_filter( 'all_plugins',
|
323 |
-
add_filter( 'plugin_action_links_'.$sBaseFile,
|
324 |
-
add_filter( 'plugin_row_meta',
|
325 |
-
add_filter( 'site_transient_update_plugins',
|
326 |
-
add_action( 'in_plugin_update_message-'.$sBaseFile,
|
327 |
-
add_filter( 'site_transient_update_plugins',
|
328 |
-
add_filter( 'auto_update_plugin',
|
329 |
-
add_filter( 'set_site_transient_update_plugins',
|
330 |
-
|
331 |
-
add_action( 'shutdown',
|
332 |
-
add_action( 'wp_logout',
|
333 |
|
334 |
// GDPR
|
335 |
-
add_filter( 'wp_privacy_personal_data_exporters',
|
336 |
-
add_filter( 'wp_privacy_personal_data_erasers',
|
337 |
|
338 |
// outsource the collection of admin notices
|
339 |
if ( is_admin() ) {
|
340 |
$oNofics = $this->loadWpNotices();
|
341 |
$oNofics->setPrefix( $this->prefix() );
|
342 |
-
add_filter( $this->prefix( 'ajaxAuthAction' ),
|
343 |
}
|
344 |
|
345 |
/**
|
@@ -357,10 +352,10 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
357 |
*/
|
358 |
public function onWpAdminInit() {
|
359 |
if ( $this->getPluginSpec_Property( 'show_dashboard_widget' ) === true ) {
|
360 |
-
add_action( 'wp_dashboard_setup',
|
361 |
}
|
362 |
-
add_action( 'admin_enqueue_scripts',
|
363 |
-
add_action( 'admin_enqueue_scripts',
|
364 |
|
365 |
$this->runTests();
|
366 |
}
|
@@ -377,7 +372,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
377 |
*/
|
378 |
public function onWpInit() {
|
379 |
$this->getMeetsBasePermissions();
|
380 |
-
add_action( 'wp_enqueue_scripts',
|
381 |
}
|
382 |
|
383 |
/**
|
@@ -395,13 +390,13 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
395 |
wp_add_dashboard_widget(
|
396 |
$this->prefix( 'dashboard_widget' ),
|
397 |
apply_filters( $this->prefix( 'dashboard_widget_title' ), $this->getHumanName() ),
|
398 |
-
|
399 |
);
|
400 |
}
|
401 |
}
|
402 |
|
403 |
public function displayDashboardWidget() {
|
404 |
-
$aContent = apply_filters( $this->prefix( 'dashboard_widget_content' ),
|
405 |
echo implode( '', $aContent );
|
406 |
}
|
407 |
|
@@ -411,7 +406,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
411 |
|
412 |
$sAction = Services::WpUsers()->isUserLoggedIn() ? 'ajaxAuthAction' : 'ajaxNonAuthAction';
|
413 |
ob_start();
|
414 |
-
$aResponseData = apply_filters( $this->prefix( $sAction ),
|
415 |
if ( empty( $aResponseData ) ) {
|
416 |
$aResponseData = apply_filters( $this->prefix( 'ajaxAction' ), $aResponseData );
|
417 |
}
|
@@ -422,15 +417,15 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
422 |
}
|
423 |
else {
|
424 |
$bSuccess = false;
|
425 |
-
$aResponseData =
|
426 |
}
|
427 |
|
428 |
wp_send_json(
|
429 |
-
|
430 |
'success' => $bSuccess,
|
431 |
'data' => $aResponseData,
|
432 |
'noise' => $sNoise
|
433 |
-
|
434 |
);
|
435 |
}
|
436 |
|
@@ -439,7 +434,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
439 |
*/
|
440 |
public function getOptionsEncoding() {
|
441 |
$sEncoding = $this->getPluginSpec_Property( 'options_encoding' );
|
442 |
-
return in_array( $sEncoding,
|
443 |
}
|
444 |
|
445 |
/**
|
@@ -469,13 +464,13 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
469 |
$sMenuTitle,
|
470 |
$this->getBasePermissions(),
|
471 |
$sFullParentMenuId,
|
472 |
-
|
473 |
$sIconUrl
|
474 |
);
|
475 |
|
476 |
if ( $this->getPluginSpec_Menu( 'has_submenu' ) ) {
|
477 |
|
478 |
-
$aPluginMenuItems = apply_filters( $this->prefix( 'submenu_items' ),
|
479 |
if ( !empty( $aPluginMenuItems ) ) {
|
480 |
foreach ( $aPluginMenuItems as $sMenuTitle => $aMenu ) {
|
481 |
list( $sMenuItemText, $sMenuItemId, $aMenuCallBack, $bShowItem ) = $aMenu;
|
@@ -549,14 +544,14 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
549 |
$sLinkTemplate = '<a href="%s" target="%s" title="%s">%s</a>';
|
550 |
foreach ( $aLinksToAdd as $aLink ) {
|
551 |
$aLink = array_merge(
|
552 |
-
|
553 |
'highlight' => false,
|
554 |
'show' => 'always',
|
555 |
'name' => '',
|
556 |
'title' => '',
|
557 |
'href' => '',
|
558 |
'target' => '_top',
|
559 |
-
|
560 |
$aLink
|
561 |
);
|
562 |
|
@@ -577,7 +572,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
577 |
}
|
578 |
|
579 |
$aActionLinks = array_merge(
|
580 |
-
|
581 |
$aActionLinks
|
582 |
);
|
583 |
}
|
@@ -609,7 +604,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
609 |
$sUrl = $this->getPluginUrl_Js( $sAsset.'.js' );
|
610 |
if ( !empty( $sUrl ) ) {
|
611 |
$sUnique = $this->prefix( $sAsset );
|
612 |
-
wp_register_script( $sUnique, $sUrl, $sDep ?
|
613 |
wp_enqueue_script( $sUnique );
|
614 |
$sDep = $sUnique;
|
615 |
}
|
@@ -623,7 +618,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
623 |
foreach ( $aAdminJs[ 'js' ] as $sAsset ) {
|
624 |
|
625 |
// Built-in handles
|
626 |
-
if ( in_array( $sAsset,
|
627 |
if ( wp_script_is( $sAsset, 'registered' ) ) {
|
628 |
wp_enqueue_script( $sAsset );
|
629 |
$sDep = $sAsset;
|
@@ -634,7 +629,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
634 |
$sUrl = $this->getPluginUrl_Js( $sAsset.'.js' );
|
635 |
if ( !empty( $sUrl ) ) {
|
636 |
$sUnique = $this->prefix( $sAsset );
|
637 |
-
wp_register_script( $sUnique, $sUrl, $sDep ?
|
638 |
wp_enqueue_script( $sUnique );
|
639 |
$sDep = $sUnique;
|
640 |
}
|
@@ -731,7 +726,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
731 |
if ( !empty( $sNewVersion ) ) {
|
732 |
$oConOptions = $this->getPluginControllerOptions();
|
733 |
if ( !isset( $oConOptions->update_first_detected ) || ( count( $oConOptions->update_first_detected ) > 3 ) ) {
|
734 |
-
$oConOptions->update_first_detected =
|
735 |
}
|
736 |
if ( !isset( $oConOptions->update_first_detected[ $sNewVersion ] ) ) {
|
737 |
$oConOptions->update_first_detected[ $sNewVersion ] = Services::Request()->ts();
|
@@ -840,7 +835,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
840 |
$aLabels = array_map( 'stripslashes', apply_filters( $this->prefix( 'plugin_labels' ), $this->getPluginSpec_Labels() ) );
|
841 |
|
842 |
$oDP = $this->loadDP();
|
843 |
-
foreach (
|
844 |
$sKey = 'icon_url_'.$sSize;
|
845 |
if ( !empty( $aLabels[ $sKey ] ) && !$oDP->isValidUrl( $aLabels[ $sKey ] ) ) {
|
846 |
$aLabels[ $sKey ] = $this->getPluginUrl_Image( $aLabels[ $sKey ] );
|
@@ -905,9 +900,9 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
905 |
* from the WordPress Admin UI.
|
906 |
* In order to ensure that WordPress still checks for plugin updates it will not remove this plugin from
|
907 |
* the list of plugins if DOING_CRON is set to true.
|
908 |
-
* @uses $this->fHeadless if the plugin is headless, it is hidden
|
909 |
* @param StdClass $oPlugins
|
910 |
* @return StdClass
|
|
|
911 |
*/
|
912 |
public function filter_hidePluginUpdatesFromUI( $oPlugins ) {
|
913 |
|
@@ -986,7 +981,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
986 |
*/
|
987 |
protected function getPluginSpec_ActionLinks( $sKey ) {
|
988 |
$aData = $this->getPluginSpec()[ 'action_links' ];
|
989 |
-
return isset( $aData[ $sKey ] ) ? $aData[ $sKey ] :
|
990 |
}
|
991 |
|
992 |
/**
|
@@ -1004,7 +999,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1004 |
*/
|
1005 |
protected function getPluginSpec_Labels( $sKey = '' ) {
|
1006 |
$oSpec = $this->getPluginSpec();
|
1007 |
-
$aLabels = isset( $oSpec[ 'labels' ] ) ? $oSpec[ 'labels' ] :
|
1008 |
|
1009 |
if ( empty( $sKey ) ) {
|
1010 |
return $aLabels;
|
@@ -1045,7 +1040,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1045 |
*/
|
1046 |
protected function getPluginSpec_PluginMeta() {
|
1047 |
$aSpec = $this->getPluginSpec();
|
1048 |
-
return ( isset( $aSpec[ 'plugin_meta' ] ) && is_array( $aSpec[ 'plugin_meta' ] ) ) ? $aSpec[ 'plugin_meta' ] :
|
1049 |
}
|
1050 |
|
1051 |
/**
|
@@ -1269,7 +1264,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1269 |
* @return string
|
1270 |
*/
|
1271 |
public function getPluginUrl( $sPath = '' ) {
|
1272 |
-
return add_query_arg(
|
1273 |
}
|
1274 |
|
1275 |
/**
|
@@ -1483,6 +1478,14 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1483 |
return $this->getPluginSpec_Property( 'version' );
|
1484 |
}
|
1485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1486 |
/**
|
1487 |
* @return mixed|stdClass
|
1488 |
*/
|
@@ -1699,21 +1702,23 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1699 |
}
|
1700 |
|
1701 |
/**
|
1702 |
-
* We let the exception from the core plugin feature to bubble up because it's
|
1703 |
* @return ICWP_WPSF_FeatureHandler_Plugin
|
1704 |
-
* @throws Exception from loadFeatureHandler()
|
1705 |
*/
|
1706 |
public function &loadCorePluginFeatureHandler() {
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
|
|
|
|
1712 |
'load_priority' => 10
|
1713 |
-
|
1714 |
);
|
1715 |
}
|
1716 |
-
return $
|
1717 |
}
|
1718 |
|
1719 |
/**
|
@@ -1734,8 +1739,8 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1734 |
catch ( Exception $oE ) {
|
1735 |
if ( $this->isValidAdminArea() && $this->isPluginAdmin() ) {
|
1736 |
$this->sAdminNoticeError = $oE->getMessage();
|
1737 |
-
add_action( 'admin_notices',
|
1738 |
-
add_action( 'network_admin_notices',
|
1739 |
}
|
1740 |
}
|
1741 |
}
|
@@ -1751,7 +1756,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1751 |
*/
|
1752 |
public function getModule( $sSlug ) {
|
1753 |
if ( !is_array( $this->aModules ) ) {
|
1754 |
-
$this->aModules =
|
1755 |
}
|
1756 |
$oModule = isset( $this->aModules[ $sSlug ] ) ? $this->aModules[ $sSlug ] : null;
|
1757 |
if ( !is_null( $oModule ) && !( $oModule instanceof ICWP_WPSF_FeatureHandler_Base ) ) {
|
@@ -1771,7 +1776,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1771 |
* @return ICWP_WPSF_FeatureHandler_Base[]
|
1772 |
*/
|
1773 |
public function getModules() {
|
1774 |
-
return is_array( $this->aModules ) ? $this->aModules :
|
1775 |
}
|
1776 |
|
1777 |
/**
|
@@ -1812,7 +1817,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1812 |
}
|
1813 |
else {
|
1814 |
$sMessage = sprintf( 'Class "%s" is missing', $sClassName );
|
1815 |
-
throw new Exception( $sMessage );
|
1816 |
}
|
1817 |
|
1818 |
$this->aModules[ $sModSlug ] = $this->{$sOptionsVarName};
|
@@ -1820,7 +1825,7 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1820 |
}
|
1821 |
|
1822 |
/**
|
1823 |
-
* @return
|
1824 |
*/
|
1825 |
public function getCurrentUserMeta() {
|
1826 |
return $this->getUserMeta( Services::WpUsers()->getCurrentWpUser() );
|
@@ -1828,15 +1833,23 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1828 |
|
1829 |
/**
|
1830 |
* @param $oUser WP_User
|
1831 |
-
* @return
|
1832 |
*/
|
1833 |
public function getUserMeta( $oUser ) {
|
1834 |
$oMeta = null;
|
1835 |
try {
|
1836 |
if ( $oUser instanceof \WP_User ) {
|
1837 |
-
/** @var
|
1838 |
-
$oMeta =
|
1839 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1840 |
}
|
1841 |
}
|
1842 |
catch ( \Exception $oE ) {
|
@@ -1850,13 +1863,13 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1850 |
*/
|
1851 |
public function onWpPrivacyRegisterExporter( $aRegistered ) {
|
1852 |
if ( !is_array( $aRegistered ) ) {
|
1853 |
-
$aRegistered =
|
1854 |
}
|
1855 |
|
1856 |
-
$aRegistered[] =
|
1857 |
'exporter_friendly_name' => $this->getHumanName(),
|
1858 |
-
'callback' =>
|
1859 |
-
|
1860 |
return $aRegistered;
|
1861 |
}
|
1862 |
|
@@ -1866,13 +1879,13 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1866 |
*/
|
1867 |
public function onWpPrivacyRegisterEraser( $aRegistered ) {
|
1868 |
if ( !is_array( $aRegistered ) ) {
|
1869 |
-
$aRegistered =
|
1870 |
}
|
1871 |
|
1872 |
-
$aRegistered[] =
|
1873 |
'eraser_friendly_name' => $this->getHumanName(),
|
1874 |
-
'callback' =>
|
1875 |
-
|
1876 |
return $aRegistered;
|
1877 |
}
|
1878 |
|
@@ -1886,10 +1899,10 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1886 |
$bValid = Services::Data()->validEmail( $sEmail )
|
1887 |
&& ( Services::WpUsers()->getUserByEmail( $sEmail ) instanceof WP_User );
|
1888 |
|
1889 |
-
return
|
1890 |
-
'data' => $bValid ? apply_filters( $this->prefix( 'wpPrivacyExport' ),
|
1891 |
'done' => true,
|
1892 |
-
|
1893 |
}
|
1894 |
|
1895 |
/**
|
@@ -1902,12 +1915,12 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1902 |
$bValidUser = Services::Data()->validEmail( $sEmail )
|
1903 |
&& ( Services::WpUsers()->getUserByEmail( $sEmail ) instanceof WP_User );
|
1904 |
|
1905 |
-
$aResult =
|
1906 |
'items_removed' => $bValidUser,
|
1907 |
'items_retained' => false,
|
1908 |
-
'messages' => $bValidUser ?
|
1909 |
'done' => true,
|
1910 |
-
|
1911 |
if ( $bValidUser ) {
|
1912 |
$aResult = apply_filters( $this->prefix( 'wpPrivacyErase' ), $aResult, $sEmail, $nPage );
|
1913 |
}
|
@@ -1917,8 +1930,8 @@ class ICWP_WPSF_Plugin_Controller extends ICWP_WPSF_Foundation {
|
|
1917 |
/**
|
1918 |
* v5.4.1: Nasty looping bug in here where this function was called within the 'user_has_cap' filter
|
1919 |
* so we removed the "current_user_can()" or any such sub-call within this function
|
1920 |
-
* @deprecated v6.10.7
|
1921 |
* @return bool
|
|
|
1922 |
*/
|
1923 |
public function getHasPermissionToManage() {
|
1924 |
if ( apply_filters( $this->prefix( 'bypass_permission_to_manage' ), false ) ) {
|
83 |
private $sConfigOptionsHashWhenLoaded;
|
84 |
|
85 |
/**
|
86 |
+
* @var bool
|
87 |
*/
|
88 |
private $bMeetsBasePermissions;
|
89 |
|
92 |
*/
|
93 |
protected $sAdminNoticeError = '';
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
/**
|
96 |
* @var ICWP_WPSF_FeatureHandler_Base[]
|
97 |
*/
|
133 |
* @throws \Exception
|
134 |
*/
|
135 |
private function readPluginSpecification() {
|
136 |
+
$aSpec = [];
|
137 |
$sContents = $this->loadDP()->readFileContentsUsingInclude( $this->getPathPluginSpec() );
|
138 |
if ( !empty( $sContents ) ) {
|
139 |
$aSpec = json_decode( $sContents, true );
|
175 |
|
176 |
if ( !$bMeetsRequirements ) {
|
177 |
$this->aRequirementsMessages = $aRequirementsMessages;
|
178 |
+
add_action( 'admin_notices', [ $this, 'adminNoticeDoesNotMeetRequirements' ] );
|
179 |
+
add_action( 'network_admin_notices', [ $this, 'adminNoticeDoesNotMeetRequirements' ] );
|
180 |
throw new Exception( 'Plugin does not meet minimum requirements' );
|
181 |
}
|
182 |
}
|
186 |
public function adminNoticeDoesNotMeetRequirements() {
|
187 |
$aMessages = $this->getRequirementsMessages();
|
188 |
if ( !empty( $aMessages ) && is_array( $aMessages ) ) {
|
189 |
+
$aDisplayData = [
|
190 |
+
'strings' => [
|
191 |
'requirements' => $aMessages,
|
192 |
'summary_title' => sprintf( 'Web Hosting requirements for Plugin "%s" are not met and you should deactivate the plugin.', $this->getHumanName() ),
|
193 |
'more_information' => 'Click here for more information on requirements'
|
194 |
+
],
|
195 |
+
'hrefs' => [
|
196 |
'more_information' => sprintf( 'https://wordpress.org/plugins/%s/faq', $this->getTextDomain() )
|
197 |
+
]
|
198 |
+
];
|
199 |
|
200 |
$this->loadRenderer( $this->getPath_Templates() )
|
201 |
->setTemplate( 'notices/does-not-meet-requirements' )
|
207 |
/**
|
208 |
*/
|
209 |
public function adminNoticePluginFailedToLoad() {
|
210 |
+
$aDisplayData = [
|
211 |
+
'strings' => [
|
212 |
'summary_title' => 'Perhaps due to a failed upgrade, the Shield plugin failed to load certain component(s) - you should remove the plugin and reinstall.',
|
213 |
'more_information' => $this->sAdminNoticeError
|
214 |
+
]
|
215 |
+
];
|
216 |
$this->loadRenderer( $this->getPath_Templates() )
|
217 |
->setTemplate( 'notices/plugin-failed-to-load' )
|
218 |
->setRenderVars( $aDisplayData )
|
232 |
*/
|
233 |
protected function getRequirementsMessages() {
|
234 |
if ( !isset( $this->aRequirementsMessages ) ) {
|
235 |
+
$this->aRequirementsMessages = [
|
236 |
'<h4>Shield Security Plugin - minimum site requirements are not met:</h4>'
|
237 |
+
];
|
238 |
}
|
239 |
return $this->aRequirementsMessages;
|
240 |
}
|
300 |
protected function doRegisterHooks() {
|
301 |
register_deactivation_hook( $this->getRootFile(), [ $this, 'onWpDeactivatePlugin' ] );
|
302 |
|
303 |
+
add_action( 'init', [ $this, 'onWpInit' ], -1000 );
|
304 |
+
add_action( 'admin_init', [ $this, 'onWpAdminInit' ] );
|
305 |
+
add_action( 'wp_loaded', [ $this, 'onWpLoaded' ] );
|
306 |
|
307 |
+
add_action( 'admin_menu', [ $this, 'onWpAdminMenu' ] );
|
308 |
+
add_action( 'network_admin_menu', [ $this, 'onWpAdminMenu' ] );
|
309 |
|
310 |
if ( Services::WpGeneral()->isAjax() ) {
|
311 |
+
add_action( 'wp_ajax_'.$this->prefix(), [ $this, 'ajaxAction' ] );
|
312 |
+
add_action( 'wp_ajax_nopriv_'.$this->prefix(), [ $this, 'ajaxAction' ] );
|
313 |
}
|
314 |
|
315 |
$sBaseFile = $this->getPluginBaseFile();
|
316 |
+
add_filter( 'all_plugins', [ $this, 'filter_hidePluginFromTableList' ] );
|
317 |
+
add_filter( 'all_plugins', [ $this, 'doPluginLabels' ] );
|
318 |
+
add_filter( 'plugin_action_links_'.$sBaseFile, [ $this, 'onWpPluginActionLinks' ], 50, 1 );
|
319 |
+
add_filter( 'plugin_row_meta', [ $this, 'onPluginRowMeta' ], 50, 2 );
|
320 |
+
add_filter( 'site_transient_update_plugins', [ $this, 'filter_hidePluginUpdatesFromUI' ] );
|
321 |
+
add_action( 'in_plugin_update_message-'.$sBaseFile, [ $this, 'onWpPluginUpdateMessage' ] );
|
322 |
+
add_filter( 'site_transient_update_plugins', [ $this, 'blockIncompatibleUpdates' ] );
|
323 |
+
add_filter( 'auto_update_plugin', [ $this, 'onWpAutoUpdate' ], 500, 2 );
|
324 |
+
add_filter( 'set_site_transient_update_plugins', [ $this, 'setUpdateFirstDetectedAt' ] );
|
325 |
+
|
326 |
+
add_action( 'shutdown', [ $this, 'onWpShutdown' ] );
|
327 |
+
add_action( 'wp_logout', [ $this, 'onWpLogout' ] );
|
328 |
|
329 |
// GDPR
|
330 |
+
add_filter( 'wp_privacy_personal_data_exporters', [ $this, 'onWpPrivacyRegisterExporter' ] );
|
331 |
+
add_filter( 'wp_privacy_personal_data_erasers', [ $this, 'onWpPrivacyRegisterEraser' ] );
|
332 |
|
333 |
// outsource the collection of admin notices
|
334 |
if ( is_admin() ) {
|
335 |
$oNofics = $this->loadWpNotices();
|
336 |
$oNofics->setPrefix( $this->prefix() );
|
337 |
+
add_filter( $this->prefix( 'ajaxAuthAction' ), [ $oNofics, 'handleAuthAjax' ] );
|
338 |
}
|
339 |
|
340 |
/**
|
352 |
*/
|
353 |
public function onWpAdminInit() {
|
354 |
if ( $this->getPluginSpec_Property( 'show_dashboard_widget' ) === true ) {
|
355 |
+
add_action( 'wp_dashboard_setup', [ $this, 'onWpDashboardSetup' ] );
|
356 |
}
|
357 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'onWpEnqueueAdminCss' ], 100 );
|
358 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'onWpEnqueueAdminJs' ], 5 );
|
359 |
|
360 |
$this->runTests();
|
361 |
}
|
372 |
*/
|
373 |
public function onWpInit() {
|
374 |
$this->getMeetsBasePermissions();
|
375 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'onWpEnqueueFrontendCss' ], 99 );
|
376 |
}
|
377 |
|
378 |
/**
|
390 |
wp_add_dashboard_widget(
|
391 |
$this->prefix( 'dashboard_widget' ),
|
392 |
apply_filters( $this->prefix( 'dashboard_widget_title' ), $this->getHumanName() ),
|
393 |
+
[ $this, 'displayDashboardWidget' ]
|
394 |
);
|
395 |
}
|
396 |
}
|
397 |
|
398 |
public function displayDashboardWidget() {
|
399 |
+
$aContent = apply_filters( $this->prefix( 'dashboard_widget_content' ), [] );
|
400 |
echo implode( '', $aContent );
|
401 |
}
|
402 |
|
406 |
|
407 |
$sAction = Services::WpUsers()->isUserLoggedIn() ? 'ajaxAuthAction' : 'ajaxNonAuthAction';
|
408 |
ob_start();
|
409 |
+
$aResponseData = apply_filters( $this->prefix( $sAction ), [] );
|
410 |
if ( empty( $aResponseData ) ) {
|
411 |
$aResponseData = apply_filters( $this->prefix( 'ajaxAction' ), $aResponseData );
|
412 |
}
|
417 |
}
|
418 |
else {
|
419 |
$bSuccess = false;
|
420 |
+
$aResponseData = [];
|
421 |
}
|
422 |
|
423 |
wp_send_json(
|
424 |
+
[
|
425 |
'success' => $bSuccess,
|
426 |
'data' => $aResponseData,
|
427 |
'noise' => $sNoise
|
428 |
+
]
|
429 |
);
|
430 |
}
|
431 |
|
434 |
*/
|
435 |
public function getOptionsEncoding() {
|
436 |
$sEncoding = $this->getPluginSpec_Property( 'options_encoding' );
|
437 |
+
return in_array( $sEncoding, [ 'yaml', 'json' ] ) ? $sEncoding : 'yaml';
|
438 |
}
|
439 |
|
440 |
/**
|
464 |
$sMenuTitle,
|
465 |
$this->getBasePermissions(),
|
466 |
$sFullParentMenuId,
|
467 |
+
[ $this, $this->getPluginSpec_Menu( 'callback' ) ],
|
468 |
$sIconUrl
|
469 |
);
|
470 |
|
471 |
if ( $this->getPluginSpec_Menu( 'has_submenu' ) ) {
|
472 |
|
473 |
+
$aPluginMenuItems = apply_filters( $this->prefix( 'submenu_items' ), [] );
|
474 |
if ( !empty( $aPluginMenuItems ) ) {
|
475 |
foreach ( $aPluginMenuItems as $sMenuTitle => $aMenu ) {
|
476 |
list( $sMenuItemText, $sMenuItemId, $aMenuCallBack, $bShowItem ) = $aMenu;
|
544 |
$sLinkTemplate = '<a href="%s" target="%s" title="%s">%s</a>';
|
545 |
foreach ( $aLinksToAdd as $aLink ) {
|
546 |
$aLink = array_merge(
|
547 |
+
[
|
548 |
'highlight' => false,
|
549 |
'show' => 'always',
|
550 |
'name' => '',
|
551 |
'title' => '',
|
552 |
'href' => '',
|
553 |
'target' => '_top',
|
554 |
+
],
|
555 |
$aLink
|
556 |
);
|
557 |
|
572 |
}
|
573 |
|
574 |
$aActionLinks = array_merge(
|
575 |
+
[ $this->prefix( sanitize_key( $aLink[ 'name' ] ) ) => $sLink ],
|
576 |
$aActionLinks
|
577 |
);
|
578 |
}
|
604 |
$sUrl = $this->getPluginUrl_Js( $sAsset.'.js' );
|
605 |
if ( !empty( $sUrl ) ) {
|
606 |
$sUnique = $this->prefix( $sAsset );
|
607 |
+
wp_register_script( $sUnique, $sUrl, $sDep ? [ $sDep ] : [], $sVers );
|
608 |
wp_enqueue_script( $sUnique );
|
609 |
$sDep = $sUnique;
|
610 |
}
|
618 |
foreach ( $aAdminJs[ 'js' ] as $sAsset ) {
|
619 |
|
620 |
// Built-in handles
|
621 |
+
if ( in_array( $sAsset, [ 'jquery' ] ) ) {
|
622 |
if ( wp_script_is( $sAsset, 'registered' ) ) {
|
623 |
wp_enqueue_script( $sAsset );
|
624 |
$sDep = $sAsset;
|
629 |
$sUrl = $this->getPluginUrl_Js( $sAsset.'.js' );
|
630 |
if ( !empty( $sUrl ) ) {
|
631 |
$sUnique = $this->prefix( $sAsset );
|
632 |
+
wp_register_script( $sUnique, $sUrl, $sDep ? [ $sDep ] : [], $sVers );
|
633 |
wp_enqueue_script( $sUnique );
|
634 |
$sDep = $sUnique;
|
635 |
}
|
726 |
if ( !empty( $sNewVersion ) ) {
|
727 |
$oConOptions = $this->getPluginControllerOptions();
|
728 |
if ( !isset( $oConOptions->update_first_detected ) || ( count( $oConOptions->update_first_detected ) > 3 ) ) {
|
729 |
+
$oConOptions->update_first_detected = [];
|
730 |
}
|
731 |
if ( !isset( $oConOptions->update_first_detected[ $sNewVersion ] ) ) {
|
732 |
$oConOptions->update_first_detected[ $sNewVersion ] = Services::Request()->ts();
|
835 |
$aLabels = array_map( 'stripslashes', apply_filters( $this->prefix( 'plugin_labels' ), $this->getPluginSpec_Labels() ) );
|
836 |
|
837 |
$oDP = $this->loadDP();
|
838 |
+
foreach ( [ '16x16', '32x32', '128x128' ] as $sSize ) {
|
839 |
$sKey = 'icon_url_'.$sSize;
|
840 |
if ( !empty( $aLabels[ $sKey ] ) && !$oDP->isValidUrl( $aLabels[ $sKey ] ) ) {
|
841 |
$aLabels[ $sKey ] = $this->getPluginUrl_Image( $aLabels[ $sKey ] );
|
900 |
* from the WordPress Admin UI.
|
901 |
* In order to ensure that WordPress still checks for plugin updates it will not remove this plugin from
|
902 |
* the list of plugins if DOING_CRON is set to true.
|
|
|
903 |
* @param StdClass $oPlugins
|
904 |
* @return StdClass
|
905 |
+
* @uses $this->fHeadless if the plugin is headless, it is hidden
|
906 |
*/
|
907 |
public function filter_hidePluginUpdatesFromUI( $oPlugins ) {
|
908 |
|
981 |
*/
|
982 |
protected function getPluginSpec_ActionLinks( $sKey ) {
|
983 |
$aData = $this->getPluginSpec()[ 'action_links' ];
|
984 |
+
return isset( $aData[ $sKey ] ) ? $aData[ $sKey ] : [];
|
985 |
}
|
986 |
|
987 |
/**
|
999 |
*/
|
1000 |
protected function getPluginSpec_Labels( $sKey = '' ) {
|
1001 |
$oSpec = $this->getPluginSpec();
|
1002 |
+
$aLabels = isset( $oSpec[ 'labels' ] ) ? $oSpec[ 'labels' ] : [];
|
1003 |
|
1004 |
if ( empty( $sKey ) ) {
|
1005 |
return $aLabels;
|
1040 |
*/
|
1041 |
protected function getPluginSpec_PluginMeta() {
|
1042 |
$aSpec = $this->getPluginSpec();
|
1043 |
+
return ( isset( $aSpec[ 'plugin_meta' ] ) && is_array( $aSpec[ 'plugin_meta' ] ) ) ? $aSpec[ 'plugin_meta' ] : [];
|
1044 |
}
|
1045 |
|
1046 |
/**
|
1264 |
* @return string
|
1265 |
*/
|
1266 |
public function getPluginUrl( $sPath = '' ) {
|
1267 |
+
return add_query_arg( [ 'ver' => $this->getVersion() ], plugins_url( $sPath, $this->getRootFile() ) );
|
1268 |
}
|
1269 |
|
1270 |
/**
|
1478 |
return $this->getPluginSpec_Property( 'version' );
|
1479 |
}
|
1480 |
|
1481 |
+
/**
|
1482 |
+
* @return int
|
1483 |
+
*/
|
1484 |
+
public function getVersionNumeric() {
|
1485 |
+
$aParts = explode( '.', $this->getVersion() );
|
1486 |
+
return ( $aParts[ 0 ]*100 + $aParts[ 1 ]*10 + $aParts[ 2 ] );
|
1487 |
+
}
|
1488 |
+
|
1489 |
/**
|
1490 |
* @return mixed|stdClass
|
1491 |
*/
|
1702 |
}
|
1703 |
|
1704 |
/**
|
1705 |
+
* We let the exception from the core plugin feature to bubble up because it's critical.
|
1706 |
* @return ICWP_WPSF_FeatureHandler_Plugin
|
1707 |
+
* @throws \Exception from loadFeatureHandler()
|
1708 |
*/
|
1709 |
public function &loadCorePluginFeatureHandler() {
|
1710 |
+
$sSlug = 'plugin';
|
1711 |
+
$oMod = $this->getModule( $sSlug );
|
1712 |
+
if ( is_null( $oMod ) ) {
|
1713 |
+
$oMod = $this->loadFeatureHandler(
|
1714 |
+
[
|
1715 |
+
'slug' => $sSlug,
|
1716 |
+
'storage_key' => $sSlug,
|
1717 |
'load_priority' => 10
|
1718 |
+
]
|
1719 |
);
|
1720 |
}
|
1721 |
+
return $oMod;
|
1722 |
}
|
1723 |
|
1724 |
/**
|
1739 |
catch ( Exception $oE ) {
|
1740 |
if ( $this->isValidAdminArea() && $this->isPluginAdmin() ) {
|
1741 |
$this->sAdminNoticeError = $oE->getMessage();
|
1742 |
+
add_action( 'admin_notices', [ $this, 'adminNoticePluginFailedToLoad' ] );
|
1743 |
+
add_action( 'network_admin_notices', [ $this, 'adminNoticePluginFailedToLoad' ] );
|
1744 |
}
|
1745 |
}
|
1746 |
}
|
1756 |
*/
|
1757 |
public function getModule( $sSlug ) {
|
1758 |
if ( !is_array( $this->aModules ) ) {
|
1759 |
+
$this->aModules = [];
|
1760 |
}
|
1761 |
$oModule = isset( $this->aModules[ $sSlug ] ) ? $this->aModules[ $sSlug ] : null;
|
1762 |
if ( !is_null( $oModule ) && !( $oModule instanceof ICWP_WPSF_FeatureHandler_Base ) ) {
|
1776 |
* @return ICWP_WPSF_FeatureHandler_Base[]
|
1777 |
*/
|
1778 |
public function getModules() {
|
1779 |
+
return is_array( $this->aModules ) ? $this->aModules : [];
|
1780 |
}
|
1781 |
|
1782 |
/**
|
1817 |
}
|
1818 |
else {
|
1819 |
$sMessage = sprintf( 'Class "%s" is missing', $sClassName );
|
1820 |
+
throw new \Exception( $sMessage );
|
1821 |
}
|
1822 |
|
1823 |
$this->aModules[ $sModSlug ] = $this->{$sOptionsVarName};
|
1825 |
}
|
1826 |
|
1827 |
/**
|
1828 |
+
* @return Shield\Users\ShieldUserMeta
|
1829 |
*/
|
1830 |
public function getCurrentUserMeta() {
|
1831 |
return $this->getUserMeta( Services::WpUsers()->getCurrentWpUser() );
|
1833 |
|
1834 |
/**
|
1835 |
* @param $oUser WP_User
|
1836 |
+
* @return Shield\Users\ShieldUserMeta|mixed
|
1837 |
*/
|
1838 |
public function getUserMeta( $oUser ) {
|
1839 |
$oMeta = null;
|
1840 |
try {
|
1841 |
if ( $oUser instanceof \WP_User ) {
|
1842 |
+
/** @var Shield\Users\ShieldUserMeta $oMeta */
|
1843 |
+
$oMeta = Shield\Users\ShieldUserMeta::Load( $this->prefix(), $oUser->ID );
|
1844 |
+
if ( !$oMeta instanceof Shield\Users\ShieldUserMeta ) {
|
1845 |
+
// Weird: user reported an error where it wasn't of the correct type
|
1846 |
+
$oMeta = new Shield\Users\ShieldUserMeta( $this->prefix(), $oUser->ID );
|
1847 |
+
Shield\Users\ShieldUserMeta::AddToCache( $oMeta );
|
1848 |
+
}
|
1849 |
+
$oMeta->setPasswordStartedAt( $oUser->user_pass )
|
1850 |
+
->updateFirstSeenAt();
|
1851 |
+
Services::WpUsers()
|
1852 |
+
->updateUserMeta( $this->prefix( 'meta-version' ), $this->getVersionNumeric(), $oUser->ID );
|
1853 |
}
|
1854 |
}
|
1855 |
catch ( \Exception $oE ) {
|
1863 |
*/
|
1864 |
public function onWpPrivacyRegisterExporter( $aRegistered ) {
|
1865 |
if ( !is_array( $aRegistered ) ) {
|
1866 |
+
$aRegistered = []; // account for crap plugins that do-it-wrong.
|
1867 |
}
|
1868 |
|
1869 |
+
$aRegistered[] = [
|
1870 |
'exporter_friendly_name' => $this->getHumanName(),
|
1871 |
+
'callback' => [ $this, 'wpPrivacyExport' ],
|
1872 |
+
];
|
1873 |
return $aRegistered;
|
1874 |
}
|
1875 |
|
1879 |
*/
|
1880 |
public function onWpPrivacyRegisterEraser( $aRegistered ) {
|
1881 |
if ( !is_array( $aRegistered ) ) {
|
1882 |
+
$aRegistered = []; // account for crap plugins that do-it-wrong.
|
1883 |
}
|
1884 |
|
1885 |
+
$aRegistered[] = [
|
1886 |
'eraser_friendly_name' => $this->getHumanName(),
|
1887 |
+
'callback' => [ $this, 'wpPrivacyErase' ],
|
1888 |
+
];
|
1889 |
return $aRegistered;
|
1890 |
}
|
1891 |
|
1899 |
$bValid = Services::Data()->validEmail( $sEmail )
|
1900 |
&& ( Services::WpUsers()->getUserByEmail( $sEmail ) instanceof WP_User );
|
1901 |
|
1902 |
+
return [
|
1903 |
+
'data' => $bValid ? apply_filters( $this->prefix( 'wpPrivacyExport' ), [], $sEmail, $nPage ) : [],
|
1904 |
'done' => true,
|
1905 |
+
];
|
1906 |
}
|
1907 |
|
1908 |
/**
|
1915 |
$bValidUser = Services::Data()->validEmail( $sEmail )
|
1916 |
&& ( Services::WpUsers()->getUserByEmail( $sEmail ) instanceof WP_User );
|
1917 |
|
1918 |
+
$aResult = [
|
1919 |
'items_removed' => $bValidUser,
|
1920 |
'items_retained' => false,
|
1921 |
+
'messages' => $bValidUser ? [] : [ 'Email address not valid or does not belong to a user.' ],
|
1922 |
'done' => true,
|
1923 |
+
];
|
1924 |
if ( $bValidUser ) {
|
1925 |
$aResult = apply_filters( $this->prefix( 'wpPrivacyErase' ), $aResult, $sEmail, $nPage );
|
1926 |
}
|
1930 |
/**
|
1931 |
* v5.4.1: Nasty looping bug in here where this function was called within the 'user_has_cap' filter
|
1932 |
* so we removed the "current_user_can()" or any such sub-call within this function
|
|
|
1933 |
* @return bool
|
1934 |
+
* @deprecated v6.10.7
|
1935 |
*/
|
1936 |
public function getHasPermissionToManage() {
|
1937 |
if ( apply_filters( $this->prefix( 'bypass_permission_to_manage' ), false ) ) {
|
@@ -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: 7.
|
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: 7.4.0
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages/
|
9 |
* Author: One Dollar Plugin
|
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "7.
|
4 |
-
"release_timestamp":
|
5 |
"slug_parent": "icwp",
|
6 |
"slug_plugin": "wpsf",
|
7 |
"human_name": "Shield",
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "7.4.0",
|
4 |
+
"release_timestamp": 1557742354,
|
5 |
"slug_parent": "icwp",
|
6 |
"slug_plugin": "wpsf",
|
7 |
"human_name": "Shield",
|
@@ -1,36 +1,38 @@
|
|
1 |
-
=== Shield
|
2 |
Contributors: onedollarplugin, paultgoodchild
|
3 |
Donate link: https://icwp.io/bw
|
4 |
License: GPLv3
|
5 |
License URI: http://www.gnu.org/licenses/gpl.html
|
6 |
-
Tags: scan, firewall, two factor authentication, login protection,
|
7 |
Requires at least: 3.5.0
|
8 |
Requires PHP: 5.4.0
|
9 |
Recommended PHP: 7.0
|
10 |
Tested up to: 5.2
|
11 |
-
Stable tag: 7.
|
12 |
|
13 |
-
|
14 |
|
15 |
== Description ==
|
16 |
|
17 |
### The highest rated 5* Security Plugin for WordPress
|
18 |
|
19 |
-
Shield
|
20 |
|
21 |
-
####
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
|
|
|
|
34 |
|
35 |
#### Trust: Shield Does Exactly What It Says It Will Do
|
36 |
|
@@ -362,8 +364,21 @@ You will always be able to use Shield Security and its free features in-full.
|
|
362 |
|
363 |
[Go Pro for just $1/month](https://icwp.io/aa).
|
364 |
|
365 |
-
= 7.
|
366 |
-
*Released:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
|
368 |
* **(v.2)** IMPROVED: Provided inline links for new [Bot Signals](https://icwp.io/ez) options.
|
369 |
* **(v.2)** CHANGED: Added a workaround for WPML plugin using old, buggy version of TWIG library.
|
@@ -375,9 +390,6 @@ You will always be able to use Shield Security and its free features in-full.
|
|
375 |
* **(v.0)** FIX: Error displayed when deleting plugins in some cases.
|
376 |
* **(v.0)** UPDATED: Translations for Chinese, Finnish, Turkish, Dutch, Italian, and German.
|
377 |
|
378 |
-
= 7.3 - Series =
|
379 |
-
*Released: 15th April, 2019* - [Release Notes](https://icwp.io/f0)
|
380 |
-
|
381 |
= 7.2 - Series =
|
382 |
*Released: 7th March, 2019* - [Release Notes](https://icwp.io/ep)
|
383 |
|
1 |
+
=== Shield Security: Protection with Smarter Automation ===
|
2 |
Contributors: onedollarplugin, paultgoodchild
|
3 |
Donate link: https://icwp.io/bw
|
4 |
License: GPLv3
|
5 |
License URI: http://www.gnu.org/licenses/gpl.html
|
6 |
+
Tags: scan, firewall, two factor authentication, login protection, malware
|
7 |
Requires at least: 3.5.0
|
8 |
Requires PHP: 5.4.0
|
9 |
Recommended PHP: 7.0
|
10 |
Tested up to: 5.2
|
11 |
+
Stable tag: 7.4.0
|
12 |
|
13 |
+
Security protection from hackers through smarter automation. Powerful scanners, 2-Factor Auth, limit logins, auto IP blocks & more.
|
14 |
|
15 |
== Description ==
|
16 |
|
17 |
### The highest rated 5* Security Plugin for WordPress
|
18 |
|
19 |
+
Shield - highest average 5* rating for any WordPress security plugin (2019/05). [See what people are saying here](https://wordpress.org/support/plugin/wp-simple-firewall/reviews/?filter=5).
|
20 |
|
21 |
+
#### It's 2019 - Don't settle for just another security plugin. Get *smarter* security.
|
22 |
|
23 |
+
You don't need another 100 email notifications.
|
24 |
|
25 |
+
You **need** a security plugin that does **all** the heavy lifting for you, and only alerts you when you need to know.
|
26 |
|
27 |
+
And when you get an alert, you actually have steps to take, not just the position of "I have no clue what to do!"
|
28 |
|
29 |
+
### Security for WordPress *doesn't* have to be *hard*
|
30 |
|
31 |
+
There's no reason for security to be so darn complicated. It doesn't have to be this way any longer.
|
32 |
|
33 |
+
Shield is the easiest security plugin to setup - you simply activate it.
|
34 |
+
|
35 |
+
And you can gradually dig deeper, as you're ready.
|
36 |
|
37 |
#### Trust: Shield Does Exactly What It Says It Will Do
|
38 |
|
364 |
|
365 |
[Go Pro for just $1/month](https://icwp.io/aa).
|
366 |
|
367 |
+
= 7.4.0 - Current Release =
|
368 |
+
*Released: 13th May, 2019* - [Release Notes](https://icwp.io/fc)
|
369 |
+
|
370 |
+
* **(v.0)** NEW: [**PRO**] [Manual/Automatic User Suspension](https://icwp.io/fa)
|
371 |
+
* **(v.0)** NEW: Comment SPAM - Increase minimum number of approved comments before scanning is skipped
|
372 |
+
* **(v.0)** NEW: [**PRO**] Comment SPAM - Trusted user roles where comments scanning is skipped
|
373 |
+
* **(v.0)** IMPROVED: AntiBot JS was improperly included when not required.
|
374 |
+
* **(v.0)** IMPROVED: Added a GeoIP caching table and removed bundled GeoIP database - greatly reduces download size.
|
375 |
+
* **(v.0)** FIXED: Inconsistent behaviour when PWA plugin is active and it infinitely reloads pages.
|
376 |
+
* **(v.0)** FIXED: Inconsistent behaviour with Anonymous API blocking.
|
377 |
+
* **(v.0)** IMPROVED: Code improvements and refactoring.
|
378 |
+
* **(v.0)** ADDED: Prep for upcoming malware scanner.
|
379 |
+
|
380 |
+
= 7.3 - Series =
|
381 |
+
*Released: 15th April, 2019* - [Release Notes](https://icwp.io/f0)
|
382 |
|
383 |
* **(v.2)** IMPROVED: Provided inline links for new [Bot Signals](https://icwp.io/ez) options.
|
384 |
* **(v.2)** CHANGED: Added a workaround for WPML plugin using old, buggy version of TWIG library.
|
390 |
* **(v.0)** FIX: Error displayed when deleting plugins in some cases.
|
391 |
* **(v.0)** UPDATED: Translations for Chinese, Finnish, Turkish, Dutch, Italian, and German.
|
392 |
|
|
|
|
|
|
|
393 |
= 7.2 - Series =
|
394 |
*Released: 7th March, 2019* - [Release Notes](https://icwp.io/ep)
|
395 |
|
Binary file
|
@@ -73,6 +73,33 @@ class ICWP_WPSF_WpComments extends ICWP_WPSF_Foundation {
|
|
73 |
return $oDb->getVar( $sQuery ) == 1;
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
* @return bool
|
78 |
*/
|
73 |
return $oDb->getVar( $sQuery ) == 1;
|
74 |
}
|
75 |
|
76 |
+
/**
|
77 |
+
* @param string $sAuthorEmail
|
78 |
+
* @return bool
|
79 |
+
*/
|
80 |
+
public function countApproved( $sAuthorEmail ) {
|
81 |
+
$nCount = 0;
|
82 |
+
|
83 |
+
if ( $this->loadDP()->validEmail( $sAuthorEmail ) ) {
|
84 |
+
$oDb = $this->loadDbProcessor();
|
85 |
+
$sQuery = "
|
86 |
+
SELECT COUNT(*)
|
87 |
+
FROM %s
|
88 |
+
WHERE
|
89 |
+
comment_author_email = '%s'
|
90 |
+
AND comment_approved = 1
|
91 |
+
";
|
92 |
+
|
93 |
+
$sQuery = sprintf(
|
94 |
+
$sQuery,
|
95 |
+
$oDb->getTable_Comments(),
|
96 |
+
esc_sql( $sAuthorEmail )
|
97 |
+
);
|
98 |
+
$nCount = (int)$oDb->getVar( $sQuery );
|
99 |
+
}
|
100 |
+
return $nCount;
|
101 |
+
}
|
102 |
+
|
103 |
/**
|
104 |
* @return bool
|
105 |
*/
|
@@ -26,8 +26,16 @@
|
|
26 |
},
|
27 |
"sections": [
|
28 |
{
|
29 |
-
"slug": "
|
30 |
"primary": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
"title": "Automatic Bot Comment SPAM Protection Filter",
|
32 |
"title_short": "Bot SPAM",
|
33 |
"summary": [
|
@@ -90,6 +98,36 @@
|
|
90 |
"summary": "Enable (or Disable) The Comments SPAM Protection module",
|
91 |
"description": "Un-Checking this option will completely disable the Comments SPAM Protection module"
|
92 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
{
|
94 |
"key": "enable_comments_gasp_protection",
|
95 |
"section": "section_bot_comment_spam_protection_filter",
|
@@ -116,7 +154,7 @@
|
|
116 |
{
|
117 |
"key": "comments_default_action_spam_bot",
|
118 |
"section": "section_bot_comment_spam_protection_filter",
|
119 |
-
"default": "
|
120 |
"type": "select",
|
121 |
"value_options": [
|
122 |
{
|
@@ -338,6 +376,7 @@
|
|
338 |
}
|
339 |
],
|
340 |
"definitions": {
|
|
|
341 |
"spambot_comments_filter_table_name": "spambot_comments_filter",
|
342 |
"spambot_comments_filter_table_columns": [
|
343 |
"id",
|
26 |
},
|
27 |
"sections": [
|
28 |
{
|
29 |
+
"slug": "section_bot_comment_spam_common",
|
30 |
"primary": true,
|
31 |
+
"title": "Common Settings For All SPAM Scanning",
|
32 |
+
"title_short": "Common Settings",
|
33 |
+
"summary": [
|
34 |
+
"Purpose - Settings that apply to all comment SPAM scanning."
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"slug": "section_bot_comment_spam_protection_filter",
|
39 |
"title": "Automatic Bot Comment SPAM Protection Filter",
|
40 |
"title_short": "Bot SPAM",
|
41 |
"summary": [
|
98 |
"summary": "Enable (or Disable) The Comments SPAM Protection module",
|
99 |
"description": "Un-Checking this option will completely disable the Comments SPAM Protection module"
|
100 |
},
|
101 |
+
{
|
102 |
+
"key": "trusted_commenter_minimum",
|
103 |
+
"section": "section_bot_comment_spam_common",
|
104 |
+
"default": 1,
|
105 |
+
"min": 1,
|
106 |
+
"type": "integer",
|
107 |
+
"link_info": "",
|
108 |
+
"link_blog": "",
|
109 |
+
"name": "Trusted Commenter Minimum",
|
110 |
+
"summary": "Minimum Number Of Approved Comments Before Commenter Is Trusted",
|
111 |
+
"description": "Specify how many approved comments must exist before a commenter is trusted and their comments are no longer scanned."
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"key": "trusted_user_roles",
|
115 |
+
"section": "section_bot_comment_spam_common",
|
116 |
+
"premium": true,
|
117 |
+
"default": [
|
118 |
+
"administrator",
|
119 |
+
"editor",
|
120 |
+
"author",
|
121 |
+
"contributor",
|
122 |
+
"subscriber"
|
123 |
+
],
|
124 |
+
"type": "array",
|
125 |
+
"link_info": "",
|
126 |
+
"link_blog": "",
|
127 |
+
"name": "Trusted Users",
|
128 |
+
"summary": "Don't Scan Comments For Users With The Following Roles",
|
129 |
+
"description": "Shield doesn't normally scan comments from logged-in or registered users. Specify user roles here that shouldn't be scanned."
|
130 |
+
},
|
131 |
{
|
132 |
"key": "enable_comments_gasp_protection",
|
133 |
"section": "section_bot_comment_spam_protection_filter",
|
154 |
{
|
155 |
"key": "comments_default_action_spam_bot",
|
156 |
"section": "section_bot_comment_spam_protection_filter",
|
157 |
+
"default": "spam",
|
158 |
"type": "select",
|
159 |
"value_options": [
|
160 |
{
|
376 |
}
|
377 |
],
|
378 |
"definitions": {
|
379 |
+
"url_spam_blacklist_terms": "https://raw.githubusercontent.com/splorp/wordpress-comment-blacklist/master/blacklist.txt",
|
380 |
"spambot_comments_filter_table_name": "spambot_comments_filter",
|
381 |
"spambot_comments_filter_table_columns": [
|
382 |
"id",
|
@@ -25,6 +25,16 @@
|
|
25 |
"Purpose - Set how often the Hack Guard scans will run."
|
26 |
]
|
27 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
{
|
29 |
"slug": "section_realtime",
|
30 |
"title": "Realtime Protection",
|
@@ -394,6 +404,50 @@
|
|
394 |
"summary": "Scans For Critical Changes Made To User Accounts",
|
395 |
"description": "Detects changes made to critical user account information that were made directly on the database and outside of the WordPress system."
|
396 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
{
|
398 |
"key": "ptg_enable",
|
399 |
"section": "section_pluginthemes_guard",
|
@@ -448,6 +502,7 @@
|
|
448 |
{
|
449 |
"key": "ptg_reinstall_links",
|
450 |
"section": "section_pluginthemes_guard",
|
|
|
451 |
"type": "checkbox",
|
452 |
"default": "Y",
|
453 |
"link_info": "https://icwp.io/bp",
|
@@ -499,6 +554,13 @@
|
|
499 |
"type": "integer",
|
500 |
"default": 0
|
501 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
{
|
503 |
"key": "insights_last_scan_wcf_at",
|
504 |
"section": "section_non_ui",
|
@@ -534,6 +596,13 @@
|
|
534 |
"type": "integer",
|
535 |
"default": 0
|
536 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
{
|
538 |
"key": "next_scan_wcf_at",
|
539 |
"section": "section_non_ui",
|
@@ -606,11 +675,8 @@
|
|
606 |
"created_at",
|
607 |
"deleted_at"
|
608 |
],
|
|
|
609 |
"cron_all_scans": "all-scans",
|
610 |
-
"cron_scan_wpv": "wpvulnscan-notification",
|
611 |
-
"cron_scan_wcf": "core-checksum-notification",
|
612 |
-
"cron_scan_ufc": "unrecognised-scan-notification",
|
613 |
-
"cron_scan_ptg": "cron-pluginthemesguard",
|
614 |
"url_checksum_api": "https://api.wordpress.org/core/checksums/1.0/",
|
615 |
"url_wordress_core_svn": "https://core.svn.wordpress.org/",
|
616 |
"url_wordress_core_svn_il8n": "https://svn.automattic.com/wordpress-i18n/",
|
25 |
"Purpose - Set how often the Hack Guard scans will run."
|
26 |
]
|
27 |
},
|
28 |
+
{
|
29 |
+
"slug": "section_scan_malware",
|
30 |
+
"hidden": true,
|
31 |
+
"title": "Malware Scan",
|
32 |
+
"title_short": "Malware Scan",
|
33 |
+
"summary": [
|
34 |
+
"Purpose - Detect malicious changes to your themes and plugins.",
|
35 |
+
"Recommendation - Keep the Plugins/Theme Guard feature turned on."
|
36 |
+
]
|
37 |
+
},
|
38 |
{
|
39 |
"slug": "section_realtime",
|
40 |
"title": "Realtime Protection",
|
404 |
"summary": "Scans For Critical Changes Made To User Accounts",
|
405 |
"description": "Detects changes made to critical user account information that were made directly on the database and outside of the WordPress system."
|
406 |
},
|
407 |
+
{
|
408 |
+
"key": "mal_scan_enable",
|
409 |
+
"section": "section_scan_malware",
|
410 |
+
"premium": true,
|
411 |
+
"default": "disabled",
|
412 |
+
"type": "select",
|
413 |
+
"value_options": [
|
414 |
+
{
|
415 |
+
"value_key": "disabled",
|
416 |
+
"text": "Scan Disabled"
|
417 |
+
},
|
418 |
+
{
|
419 |
+
"value_key": "enabled",
|
420 |
+
"text": "Scan Enabled"
|
421 |
+
}
|
422 |
+
],
|
423 |
+
"link_info": "",
|
424 |
+
"link_blog": "",
|
425 |
+
"name": "Enable/Disable Malware Scan",
|
426 |
+
"summary": "Enable Malware File Scanner",
|
427 |
+
"description": "When enabled the Malware scanner will run automatically."
|
428 |
+
},
|
429 |
+
{
|
430 |
+
"key": "mal_autorepair_core",
|
431 |
+
"section": "section_scan_malware",
|
432 |
+
"type": "checkbox",
|
433 |
+
"default": "Y",
|
434 |
+
"link_info": "",
|
435 |
+
"link_blog": "",
|
436 |
+
"name": "Auto-Repair WP Core",
|
437 |
+
"summary": "Automatically Repair WordPress Core Files",
|
438 |
+
"description": "Automatically reinstall any core files found to have potential malware."
|
439 |
+
},
|
440 |
+
{
|
441 |
+
"key": "mal_autorepair_plugins",
|
442 |
+
"section": "section_scan_malware",
|
443 |
+
"type": "checkbox",
|
444 |
+
"default": "Y",
|
445 |
+
"link_info": "",
|
446 |
+
"link_blog": "",
|
447 |
+
"name": "Auto-Repair WP Plugins",
|
448 |
+
"summary": "Automatically Repair WordPress.org Plugins",
|
449 |
+
"description": "Automatically repair any plugin files found to have potential malware."
|
450 |
+
},
|
451 |
{
|
452 |
"key": "ptg_enable",
|
453 |
"section": "section_pluginthemes_guard",
|
502 |
{
|
503 |
"key": "ptg_reinstall_links",
|
504 |
"section": "section_pluginthemes_guard",
|
505 |
+
"premium": true,
|
506 |
"type": "checkbox",
|
507 |
"default": "Y",
|
508 |
"link_info": "https://icwp.io/bp",
|
554 |
"type": "integer",
|
555 |
"default": 0
|
556 |
},
|
557 |
+
{
|
558 |
+
"key": "insights_last_scan_mal_at",
|
559 |
+
"section": "section_non_ui",
|
560 |
+
"transferable": false,
|
561 |
+
"type": "integer",
|
562 |
+
"default": 0
|
563 |
+
},
|
564 |
{
|
565 |
"key": "insights_last_scan_wcf_at",
|
566 |
"section": "section_non_ui",
|
596 |
"type": "integer",
|
597 |
"default": 0
|
598 |
},
|
599 |
+
{
|
600 |
+
"key": "next_scan_mal_at",
|
601 |
+
"section": "section_non_ui",
|
602 |
+
"transferable": false,
|
603 |
+
"type": "integer",
|
604 |
+
"default": 0
|
605 |
+
},
|
606 |
{
|
607 |
"key": "next_scan_wcf_at",
|
608 |
"section": "section_non_ui",
|
675 |
"created_at",
|
676 |
"deleted_at"
|
677 |
],
|
678 |
+
"url_mal_sigs": "https://raw.githubusercontent.com/scr34m/php-malware-scanner/master/definitions/patterns_raw.txt",
|
679 |
"cron_all_scans": "all-scans",
|
|
|
|
|
|
|
|
|
680 |
"url_checksum_api": "https://api.wordpress.org/core/checksums/1.0/",
|
681 |
"url_wordress_core_svn": "https://core.svn.wordpress.org/",
|
682 |
"url_wordress_core_svn_il8n": "https://svn.automattic.com/wordpress-i18n/",
|
@@ -76,7 +76,7 @@
|
|
76 |
"default": "N",
|
77 |
"type": "checkbox",
|
78 |
"link_info": "https://icwp.io/e6",
|
79 |
-
"link_blog": "",
|
80 |
"name": "Disable XML-RPC",
|
81 |
"summary": "Disable The XML-RPC System",
|
82 |
"description": "Checking this option will completely turn off the whole XML-RPC system."
|
76 |
"default": "N",
|
77 |
"type": "checkbox",
|
78 |
"link_info": "https://icwp.io/e6",
|
79 |
+
"link_blog": "https://icwp.io/fb",
|
80 |
"name": "Disable XML-RPC",
|
81 |
"summary": "Disable The XML-RPC System",
|
82 |
"description": "Checking this option will completely turn off the whole XML-RPC system."
|
@@ -447,6 +447,14 @@
|
|
447 |
"created_at",
|
448 |
"deleted_at"
|
449 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
"active_plugin_features": [
|
451 |
{
|
452 |
"slug": "insights",
|
447 |
"created_at",
|
448 |
"deleted_at"
|
449 |
],
|
450 |
+
"geoip_table_name": "geoip",
|
451 |
+
"geoip_table_columns": [
|
452 |
+
"id",
|
453 |
+
"ip",
|
454 |
+
"meta",
|
455 |
+
"created_at",
|
456 |
+
"deleted_at"
|
457 |
+
],
|
458 |
"active_plugin_features": [
|
459 |
{
|
460 |
"slug": "insights",
|
@@ -39,7 +39,6 @@
|
|
39 |
},
|
40 |
{
|
41 |
"slug": "section_suspend",
|
42 |
-
"hidden": true,
|
43 |
"title": "Automatic And Manual User Suspension",
|
44 |
"title_short": "User Suspension",
|
45 |
"summary": [
|
@@ -146,6 +145,7 @@
|
|
146 |
"key": "session_username_concurrent_limit",
|
147 |
"section": "section_user_session_management",
|
148 |
"default": 0,
|
|
|
149 |
"type": "integer",
|
150 |
"link_info": "",
|
151 |
"link_blog": "",
|
@@ -251,7 +251,7 @@
|
|
251 |
"section": "section_suspend",
|
252 |
"premium": true,
|
253 |
"type": "checkbox",
|
254 |
-
"default": "
|
255 |
"link_info": "",
|
256 |
"link_blog": "",
|
257 |
"name": "Allow Manual User Suspension",
|
@@ -271,7 +271,7 @@
|
|
271 |
"description": "Suspend login by users and require password reset to unsuspend."
|
272 |
},
|
273 |
{
|
274 |
-
"key": "
|
275 |
"section": "section_suspend",
|
276 |
"premium": true,
|
277 |
"type": "integer",
|
@@ -283,6 +283,22 @@
|
|
283 |
"summary": "Automatically Suspend Idle User Accounts",
|
284 |
"description": "Prevent login by idle users and require password reset to unsuspend."
|
285 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
{
|
287 |
"key": "autoadd_sessions_started_at",
|
288 |
"section": "section_non_ui",
|
39 |
},
|
40 |
{
|
41 |
"slug": "section_suspend",
|
|
|
42 |
"title": "Automatic And Manual User Suspension",
|
43 |
"title_short": "User Suspension",
|
44 |
"summary": [
|
145 |
"key": "session_username_concurrent_limit",
|
146 |
"section": "section_user_session_management",
|
147 |
"default": 0,
|
148 |
+
"min": 0,
|
149 |
"type": "integer",
|
150 |
"link_info": "",
|
151 |
"link_blog": "",
|
251 |
"section": "section_suspend",
|
252 |
"premium": true,
|
253 |
"type": "checkbox",
|
254 |
+
"default": "N",
|
255 |
"link_info": "",
|
256 |
"link_blog": "",
|
257 |
"name": "Allow Manual User Suspension",
|
271 |
"description": "Suspend login by users and require password reset to unsuspend."
|
272 |
},
|
273 |
{
|
274 |
+
"key": "auto_idle_days",
|
275 |
"section": "section_suspend",
|
276 |
"premium": true,
|
277 |
"type": "integer",
|
283 |
"summary": "Automatically Suspend Idle User Accounts",
|
284 |
"description": "Prevent login by idle users and require password reset to unsuspend."
|
285 |
},
|
286 |
+
{
|
287 |
+
"key": "auto_idle_roles",
|
288 |
+
"section": "section_suspend",
|
289 |
+
"premium": true,
|
290 |
+
"type": "array",
|
291 |
+
"default": [
|
292 |
+
"administrator",
|
293 |
+
"editor",
|
294 |
+
"author"
|
295 |
+
],
|
296 |
+
"link_info": "",
|
297 |
+
"link_blog": "",
|
298 |
+
"name": "Auto-Suspend Idle Users",
|
299 |
+
"summary": "Automatically Suspend Idle User Accounts",
|
300 |
+
"description": "Prevent login by idle users and require password reset to unsuspend."
|
301 |
+
},
|
302 |
{
|
303 |
"key": "autoadd_sessions_started_at",
|
304 |
"section": "section_non_ui",
|
@@ -9,7 +9,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
9 |
/**
|
10 |
*/
|
11 |
protected function setupCustomHooks() {
|
12 |
-
add_action( $this->prefix( 'pre_deactivate_plugin' ),
|
13 |
}
|
14 |
|
15 |
/**
|
@@ -119,12 +119,12 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
119 |
protected function renderAdminAccessAjaxLoginForm( $sMessage = '' ) {
|
120 |
|
121 |
$aData = [
|
122 |
-
'ajax' =>
|
123 |
'sec_admin_login' => json_encode( $this->getSecAdminLoginAjaxData() )
|
124 |
-
|
125 |
-
'strings' =>
|
126 |
'access_message' => empty( $sMessage ) ? _wpsf__( 'Enter your Security Admin Access Key' ) : $sMessage
|
127 |
-
|
128 |
];
|
129 |
return $this->renderTemplate( 'snippets/admin_access_login', $aData );
|
130 |
}
|
@@ -169,8 +169,8 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
169 |
* @return array
|
170 |
*/
|
171 |
public function getAdminAccessArea( $sArea = 'plugins' ) {
|
172 |
-
$aSettings = $this->getOpt( 'admin_access_restrict_'.$sArea,
|
173 |
-
return !is_array( $aSettings ) ?
|
174 |
}
|
175 |
|
176 |
/**
|
@@ -178,15 +178,15 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
178 |
*/
|
179 |
public function getRestrictedOptions() {
|
180 |
$aOptions = $this->getDef( 'admin_access_options_to_restrict' );
|
181 |
-
return is_array( $aOptions ) ? $aOptions :
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
* @return array
|
186 |
*/
|
187 |
public function getSecurityAdminUsers() {
|
188 |
-
$aU = $this->getOpt( 'sec_admin_users',
|
189 |
-
return ( is_array( $aU ) && $this->isPremium() ) ? $aU :
|
190 |
}
|
191 |
|
192 |
/**
|
@@ -197,7 +197,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
197 |
public function getOptionsToRestrict( $sType = '' ) {
|
198 |
$sType = empty( $sType ) ? ( Services::WpGeneral()->isMultisite() ? 'wpms' : 'wp' ) : 'wp';
|
199 |
$aOptions = $this->getRestrictedOptions();
|
200 |
-
return ( isset( $aOptions[ $sType.'_options' ] ) && is_array( $aOptions[ $sType.'_options' ] ) ) ? $aOptions[ $sType.'_options' ] :
|
201 |
}
|
202 |
|
203 |
/**
|
@@ -207,7 +207,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
207 |
public function getOptionsPagesToRestrict( $sType = '' ) {
|
208 |
$sType = empty( $sType ) ? ( Services::WpGeneral()->isMultisite() ? 'wpms' : 'wp' ) : 'wp';
|
209 |
$aOptions = $this->getRestrictedOptions();
|
210 |
-
return ( isset( $aOptions[ $sType.'_pages' ] ) && is_array( $aOptions[ $sType.'_pages' ] ) ) ? $aOptions[ $sType.'_pages' ] :
|
211 |
}
|
212 |
|
213 |
/**
|
@@ -277,7 +277,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
277 |
$oDP = Services::Data();
|
278 |
$oWpUsers = Services::WpUsers();
|
279 |
|
280 |
-
$aFiltered =
|
281 |
foreach ( $aSecUsers as $nCurrentKey => $sUsernameOrEmail ) {
|
282 |
if ( $oDP->validEmail( $sUsernameOrEmail ) ) {
|
283 |
$oUser = $oWpUsers->getUserByEmail( $sUsernameOrEmail );
|
@@ -511,16 +511,16 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
511 |
wp_localize_script(
|
512 |
$this->prefix( 'plugin' ),
|
513 |
'icwp_wpsf_vars_secadmin',
|
514 |
-
|
515 |
'reqajax' => $this->getSecAdminCheckAjaxData(),
|
516 |
'is_sec_admin' => true, // if $nSecTimeLeft > 0
|
517 |
'timeleft' => $this->getSecAdminTimeLeft(), // JS uses milliseconds
|
518 |
-
'strings' =>
|
519 |
'confirm' => _wpsf__( 'Security Admin session has timed-out.' ).' '._wpsf__( 'Reload now?' ),
|
520 |
'nearly' => _wpsf__( 'Security Admin session has nearly timed-out.' ),
|
521 |
'expired' => _wpsf__( 'Security Admin session has timed-out.' )
|
522 |
-
|
523 |
-
|
524 |
);
|
525 |
}
|
526 |
}
|
@@ -530,20 +530,20 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
530 |
* @return array
|
531 |
*/
|
532 |
public function addInsightsConfigData( $aAllData ) {
|
533 |
-
$aThis =
|
534 |
-
'strings' =>
|
535 |
'title' => _wpsf__( 'Security Admin' ),
|
536 |
'sub' => sprintf( _wpsf__( 'Prevent Tampering With %s Settings' ), $this->getCon()->getHumanName() ),
|
537 |
-
|
538 |
-
'key_opts' =>
|
539 |
'href_options' => $this->getUrl_AdminPage()
|
540 |
-
|
541 |
|
542 |
if ( !$this->isEnabledForUiSummary() ) {
|
543 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
544 |
}
|
545 |
else {
|
546 |
-
$aThis[ 'key_opts' ][ 'mod' ] =
|
547 |
'name' => _wpsf__( 'Security Admin' ),
|
548 |
'enabled' => $this->isEnabledForUiSummary(),
|
549 |
'summary' => $this->isEnabledForUiSummary() ?
|
@@ -551,10 +551,10 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
551 |
: _wpsf__( 'Security plugin is vulnerable to tampering' ),
|
552 |
'weight' => 2,
|
553 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_key' ),
|
554 |
-
|
555 |
|
556 |
$bWpOpts = $this->getAdminAccessArea_Options();
|
557 |
-
$aThis[ 'key_opts' ][ 'wpopts' ] =
|
558 |
'name' => _wpsf__( 'Important Options' ),
|
559 |
'enabled' => $bWpOpts,
|
560 |
'summary' => $bWpOpts ?
|
@@ -562,10 +562,10 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
562 |
: _wpsf__( "Important WP options aren't protected against tampering" ),
|
563 |
'weight' => 2,
|
564 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_restrict_options' ),
|
565 |
-
|
566 |
|
567 |
$bUsers = $this->isAdminAccessAdminUsersEnabled();
|
568 |
-
$aThis[ 'key_opts' ][ 'adminusers' ] =
|
569 |
'name' => _wpsf__( 'WP Admins' ),
|
570 |
'enabled' => $bUsers,
|
571 |
'summary' => $bUsers ?
|
@@ -573,7 +573,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
573 |
: _wpsf__( "Admin users aren't protected against tampering" ),
|
574 |
'weight' => 1,
|
575 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_restrict_admin_users' ),
|
576 |
-
|
577 |
}
|
578 |
|
579 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -586,14 +586,14 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
586 |
*/
|
587 |
public function addInsightsNoticeData( $aAllNotices ) {
|
588 |
|
589 |
-
$aNotices =
|
590 |
'title' => _wpsf__( 'Security Admin Protection' ),
|
591 |
-
'messages' =>
|
592 |
-
|
593 |
|
594 |
{//sec admin
|
595 |
if ( !$this->isEnabledSecurityAdmin() ) {
|
596 |
-
$aNotices[ 'messages' ][ 'sec_admin' ] =
|
597 |
'title' => 'Security Plugin Unprotected',
|
598 |
'message' => sprintf(
|
599 |
_wpsf__( "The Security Admin protection is not active." ),
|
@@ -602,7 +602,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
602 |
'href' => $this->getUrl_AdminPage(),
|
603 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
604 |
'rec' => _wpsf__( 'Security Admin should be turned-on to protect your security settings.' )
|
605 |
-
|
606 |
}
|
607 |
}
|
608 |
|
@@ -632,35 +632,35 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
632 |
|
633 |
case 'section_enable_plugin_feature_admin_access_restriction' :
|
634 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
635 |
-
$aSummary =
|
636 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to this plugin preventing unauthorized changes to your security settings.' ) ),
|
637 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Security Admin' ) ) ),
|
638 |
sprintf( _wpsf__( 'You need to also enter a new Access Key to enable this feature.' ) ),
|
639 |
-
|
640 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
641 |
break;
|
642 |
|
643 |
case 'section_admin_access_restriction_settings' :
|
644 |
$sTitle = _wpsf__( 'Security Admin Restriction Settings' );
|
645 |
-
$aSummary =
|
646 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to this plugin preventing unauthorized changes to your security settings.' ) ),
|
647 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
648 |
-
|
649 |
$sTitleShort = _wpsf__( 'Security Admin Settings' );
|
650 |
break;
|
651 |
|
652 |
case 'section_admin_access_restriction_areas' :
|
653 |
$sTitle = _wpsf__( 'Security Admin Restriction Zones' );
|
654 |
-
$aSummary =
|
655 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to key WordPress areas for all users not authenticated with the Security Admin Access system.' ) ),
|
656 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
657 |
-
|
658 |
$sTitleShort = _wpsf__( 'Access Restriction Zones' );
|
659 |
break;
|
660 |
|
661 |
case 'section_whitelabel' :
|
662 |
$sTitle = _wpsf__( 'White Label' );
|
663 |
-
$aSummary =
|
664 |
sprintf( '%s - %s',
|
665 |
_wpsf__( 'Purpose' ),
|
666 |
sprintf( _wpsf__( 'Rename and re-brand the %s plugin for your client site installations.' ),
|
@@ -671,7 +671,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
671 |
sprintf( _wpsf__( 'The Security Admin system must be active for these settings to apply.' ),
|
672 |
$sPluginName )
|
673 |
)
|
674 |
-
|
675 |
$sTitleShort = _wpsf__( 'White Label' );
|
676 |
break;
|
677 |
|
@@ -679,7 +679,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
679 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $sSectionSlug ) );
|
680 |
}
|
681 |
$aOptionsParams[ 'title' ] = $sTitle;
|
682 |
-
$aOptionsParams[ 'summary' ] = ( isset( $aSummary ) && is_array( $aSummary ) ) ? $aSummary :
|
683 |
$aOptionsParams[ 'title_short' ] = $sTitleShort;
|
684 |
return $aOptionsParams;
|
685 |
}
|
@@ -852,11 +852,11 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
852 |
if ( in_array( 'activate_plugins', $aPluginsRestrictions ) ) {
|
853 |
$this->setOpt(
|
854 |
'admin_access_restrict_plugins',
|
855 |
-
array_unique( array_merge( $aPluginsRestrictions,
|
856 |
'install_plugins',
|
857 |
'update_plugins',
|
858 |
'delete_plugins'
|
859 |
-
|
860 |
);
|
861 |
}
|
862 |
|
@@ -865,11 +865,11 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
865 |
if ( in_array( 'switch_themes', $aThemesRestrictions ) && in_array( 'edit_theme_options', $aThemesRestrictions ) ) {
|
866 |
$this->setOpt(
|
867 |
'admin_access_restrict_themes',
|
868 |
-
array_unique( array_merge( $aThemesRestrictions,
|
869 |
'install_themes',
|
870 |
'update_themes',
|
871 |
'delete_themes'
|
872 |
-
|
873 |
);
|
874 |
}
|
875 |
|
@@ -877,7 +877,7 @@ class ICWP_WPSF_FeatureHandler_AdminAccessRestriction extends ICWP_WPSF_FeatureH
|
|
877 |
if ( in_array( 'edit', $aPostRestrictions ) ) {
|
878 |
$this->setOpt(
|
879 |
'admin_access_restrict_posts',
|
880 |
-
array_unique( array_merge( $aPostRestrictions,
|
881 |
);
|
882 |
}
|
883 |
}
|
9 |
/**
|
10 |
*/
|
11 |
protected function setupCustomHooks() {
|
12 |
+
add_action( $this->prefix( 'pre_deactivate_plugin' ), [ $this, 'preDeactivatePlugin' ] );
|
13 |
}
|
14 |
|
15 |
/**
|
119 |
protected function renderAdminAccessAjaxLoginForm( $sMessage = '' ) {
|
120 |
|
121 |
$aData = [
|
122 |
+
'ajax' => [
|
123 |
'sec_admin_login' => json_encode( $this->getSecAdminLoginAjaxData() )
|
124 |
+
],
|
125 |
+
'strings' => [
|
126 |
'access_message' => empty( $sMessage ) ? _wpsf__( 'Enter your Security Admin Access Key' ) : $sMessage
|
127 |
+
]
|
128 |
];
|
129 |
return $this->renderTemplate( 'snippets/admin_access_login', $aData );
|
130 |
}
|
169 |
* @return array
|
170 |
*/
|
171 |
public function getAdminAccessArea( $sArea = 'plugins' ) {
|
172 |
+
$aSettings = $this->getOpt( 'admin_access_restrict_'.$sArea, [] );
|
173 |
+
return !is_array( $aSettings ) ? [] : $aSettings;
|
174 |
}
|
175 |
|
176 |
/**
|
178 |
*/
|
179 |
public function getRestrictedOptions() {
|
180 |
$aOptions = $this->getDef( 'admin_access_options_to_restrict' );
|
181 |
+
return is_array( $aOptions ) ? $aOptions : [];
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
* @return array
|
186 |
*/
|
187 |
public function getSecurityAdminUsers() {
|
188 |
+
$aU = $this->getOpt( 'sec_admin_users', [] );
|
189 |
+
return ( is_array( $aU ) && $this->isPremium() ) ? $aU : [];
|
190 |
}
|
191 |
|
192 |
/**
|
197 |
public function getOptionsToRestrict( $sType = '' ) {
|
198 |
$sType = empty( $sType ) ? ( Services::WpGeneral()->isMultisite() ? 'wpms' : 'wp' ) : 'wp';
|
199 |
$aOptions = $this->getRestrictedOptions();
|
200 |
+
return ( isset( $aOptions[ $sType.'_options' ] ) && is_array( $aOptions[ $sType.'_options' ] ) ) ? $aOptions[ $sType.'_options' ] : [];
|
201 |
}
|
202 |
|
203 |
/**
|
207 |
public function getOptionsPagesToRestrict( $sType = '' ) {
|
208 |
$sType = empty( $sType ) ? ( Services::WpGeneral()->isMultisite() ? 'wpms' : 'wp' ) : 'wp';
|
209 |
$aOptions = $this->getRestrictedOptions();
|
210 |
+
return ( isset( $aOptions[ $sType.'_pages' ] ) && is_array( $aOptions[ $sType.'_pages' ] ) ) ? $aOptions[ $sType.'_pages' ] : [];
|
211 |
}
|
212 |
|
213 |
/**
|
277 |
$oDP = Services::Data();
|
278 |
$oWpUsers = Services::WpUsers();
|
279 |
|
280 |
+
$aFiltered = [];
|
281 |
foreach ( $aSecUsers as $nCurrentKey => $sUsernameOrEmail ) {
|
282 |
if ( $oDP->validEmail( $sUsernameOrEmail ) ) {
|
283 |
$oUser = $oWpUsers->getUserByEmail( $sUsernameOrEmail );
|
511 |
wp_localize_script(
|
512 |
$this->prefix( 'plugin' ),
|
513 |
'icwp_wpsf_vars_secadmin',
|
514 |
+
[
|
515 |
'reqajax' => $this->getSecAdminCheckAjaxData(),
|
516 |
'is_sec_admin' => true, // if $nSecTimeLeft > 0
|
517 |
'timeleft' => $this->getSecAdminTimeLeft(), // JS uses milliseconds
|
518 |
+
'strings' => [
|
519 |
'confirm' => _wpsf__( 'Security Admin session has timed-out.' ).' '._wpsf__( 'Reload now?' ),
|
520 |
'nearly' => _wpsf__( 'Security Admin session has nearly timed-out.' ),
|
521 |
'expired' => _wpsf__( 'Security Admin session has timed-out.' )
|
522 |
+
]
|
523 |
+
]
|
524 |
);
|
525 |
}
|
526 |
}
|
530 |
* @return array
|
531 |
*/
|
532 |
public function addInsightsConfigData( $aAllData ) {
|
533 |
+
$aThis = [
|
534 |
+
'strings' => [
|
535 |
'title' => _wpsf__( 'Security Admin' ),
|
536 |
'sub' => sprintf( _wpsf__( 'Prevent Tampering With %s Settings' ), $this->getCon()->getHumanName() ),
|
537 |
+
],
|
538 |
+
'key_opts' => [],
|
539 |
'href_options' => $this->getUrl_AdminPage()
|
540 |
+
];
|
541 |
|
542 |
if ( !$this->isEnabledForUiSummary() ) {
|
543 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
544 |
}
|
545 |
else {
|
546 |
+
$aThis[ 'key_opts' ][ 'mod' ] = [
|
547 |
'name' => _wpsf__( 'Security Admin' ),
|
548 |
'enabled' => $this->isEnabledForUiSummary(),
|
549 |
'summary' => $this->isEnabledForUiSummary() ?
|
551 |
: _wpsf__( 'Security plugin is vulnerable to tampering' ),
|
552 |
'weight' => 2,
|
553 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_key' ),
|
554 |
+
];
|
555 |
|
556 |
$bWpOpts = $this->getAdminAccessArea_Options();
|
557 |
+
$aThis[ 'key_opts' ][ 'wpopts' ] = [
|
558 |
'name' => _wpsf__( 'Important Options' ),
|
559 |
'enabled' => $bWpOpts,
|
560 |
'summary' => $bWpOpts ?
|
562 |
: _wpsf__( "Important WP options aren't protected against tampering" ),
|
563 |
'weight' => 2,
|
564 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_restrict_options' ),
|
565 |
+
];
|
566 |
|
567 |
$bUsers = $this->isAdminAccessAdminUsersEnabled();
|
568 |
+
$aThis[ 'key_opts' ][ 'adminusers' ] = [
|
569 |
'name' => _wpsf__( 'WP Admins' ),
|
570 |
'enabled' => $bUsers,
|
571 |
'summary' => $bUsers ?
|
573 |
: _wpsf__( "Admin users aren't protected against tampering" ),
|
574 |
'weight' => 1,
|
575 |
'href' => $this->getUrl_DirectLinkToOption( 'admin_access_restrict_admin_users' ),
|
576 |
+
];
|
577 |
}
|
578 |
|
579 |
$aAllData[ $this->getSlug() ] = $aThis;
|
586 |
*/
|
587 |
public function addInsightsNoticeData( $aAllNotices ) {
|
588 |
|
589 |
+
$aNotices = [
|
590 |
'title' => _wpsf__( 'Security Admin Protection' ),
|
591 |
+
'messages' => []
|
592 |
+
];
|
593 |
|
594 |
{//sec admin
|
595 |
if ( !$this->isEnabledSecurityAdmin() ) {
|
596 |
+
$aNotices[ 'messages' ][ 'sec_admin' ] = [
|
597 |
'title' => 'Security Plugin Unprotected',
|
598 |
'message' => sprintf(
|
599 |
_wpsf__( "The Security Admin protection is not active." ),
|
602 |
'href' => $this->getUrl_AdminPage(),
|
603 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
604 |
'rec' => _wpsf__( 'Security Admin should be turned-on to protect your security settings.' )
|
605 |
+
];
|
606 |
}
|
607 |
}
|
608 |
|
632 |
|
633 |
case 'section_enable_plugin_feature_admin_access_restriction' :
|
634 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
635 |
+
$aSummary = [
|
636 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to this plugin preventing unauthorized changes to your security settings.' ) ),
|
637 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Security Admin' ) ) ),
|
638 |
sprintf( _wpsf__( 'You need to also enter a new Access Key to enable this feature.' ) ),
|
639 |
+
];
|
640 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
641 |
break;
|
642 |
|
643 |
case 'section_admin_access_restriction_settings' :
|
644 |
$sTitle = _wpsf__( 'Security Admin Restriction Settings' );
|
645 |
+
$aSummary = [
|
646 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to this plugin preventing unauthorized changes to your security settings.' ) ),
|
647 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
648 |
+
];
|
649 |
$sTitleShort = _wpsf__( 'Security Admin Settings' );
|
650 |
break;
|
651 |
|
652 |
case 'section_admin_access_restriction_areas' :
|
653 |
$sTitle = _wpsf__( 'Security Admin Restriction Zones' );
|
654 |
+
$aSummary = [
|
655 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restricts access to key WordPress areas for all users not authenticated with the Security Admin Access system.' ) ),
|
656 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
657 |
+
];
|
658 |
$sTitleShort = _wpsf__( 'Access Restriction Zones' );
|
659 |
break;
|
660 |
|
661 |
case 'section_whitelabel' :
|
662 |
$sTitle = _wpsf__( 'White Label' );
|
663 |
+
$aSummary = [
|
664 |
sprintf( '%s - %s',
|
665 |
_wpsf__( 'Purpose' ),
|
666 |
sprintf( _wpsf__( 'Rename and re-brand the %s plugin for your client site installations.' ),
|
671 |
sprintf( _wpsf__( 'The Security Admin system must be active for these settings to apply.' ),
|
672 |
$sPluginName )
|
673 |
)
|
674 |
+
];
|
675 |
$sTitleShort = _wpsf__( 'White Label' );
|
676 |
break;
|
677 |
|
679 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $sSectionSlug ) );
|
680 |
}
|
681 |
$aOptionsParams[ 'title' ] = $sTitle;
|
682 |
+
$aOptionsParams[ 'summary' ] = ( isset( $aSummary ) && is_array( $aSummary ) ) ? $aSummary : [];
|
683 |
$aOptionsParams[ 'title_short' ] = $sTitleShort;
|
684 |
return $aOptionsParams;
|
685 |
}
|
852 |
if ( in_array( 'activate_plugins', $aPluginsRestrictions ) ) {
|
853 |
$this->setOpt(
|
854 |
'admin_access_restrict_plugins',
|
855 |
+
array_unique( array_merge( $aPluginsRestrictions, [
|
856 |
'install_plugins',
|
857 |
'update_plugins',
|
858 |
'delete_plugins'
|
859 |
+
] ) )
|
860 |
);
|
861 |
}
|
862 |
|
865 |
if ( in_array( 'switch_themes', $aThemesRestrictions ) && in_array( 'edit_theme_options', $aThemesRestrictions ) ) {
|
866 |
$this->setOpt(
|
867 |
'admin_access_restrict_themes',
|
868 |
+
array_unique( array_merge( $aThemesRestrictions, [
|
869 |
'install_themes',
|
870 |
'update_themes',
|
871 |
'delete_themes'
|
872 |
+
] ) )
|
873 |
);
|
874 |
}
|
875 |
|
877 |
if ( in_array( 'edit', $aPostRestrictions ) ) {
|
878 |
$this->setOpt(
|
879 |
'admin_access_restrict_posts',
|
880 |
+
array_unique( array_merge( $aPostRestrictions, [ 'create', 'publish', 'delete' ] ) )
|
881 |
);
|
882 |
}
|
883 |
}
|
@@ -75,10 +75,10 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
75 |
}
|
76 |
}
|
77 |
|
78 |
-
return
|
79 |
'success' => $bSuccess,
|
80 |
'message' => $sMessage
|
81 |
-
|
82 |
}
|
83 |
|
84 |
/**
|
@@ -92,10 +92,10 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
92 |
->setMod( $this )
|
93 |
->setDbHandler( $oPro->getSubProAuditor()->getDbHandler() );
|
94 |
|
95 |
-
return
|
96 |
'success' => true,
|
97 |
'html' => $oTableBuilder->buildTable()
|
98 |
-
|
99 |
}
|
100 |
|
101 |
/**
|
@@ -178,7 +178,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
178 |
* @return array
|
179 |
*/
|
180 |
public function getAllContexts() {
|
181 |
-
return
|
182 |
'all' => 'All', //special
|
183 |
'wpsf' => $this->getCon()->getHumanName(),
|
184 |
'wordpress' => 'WordPress',
|
@@ -187,7 +187,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
187 |
'plugins' => 'Plugins',
|
188 |
'themes' => 'Themes',
|
189 |
'emails' => 'Emails',
|
190 |
-
|
191 |
}
|
192 |
|
193 |
/**
|
@@ -196,7 +196,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
196 |
protected function getDisplayStrings() {
|
197 |
return $this->loadDP()->mergeArraysRecursive(
|
198 |
parent::getDisplayStrings(),
|
199 |
-
|
200 |
'at_users' => _wpsf__( 'Users' ),
|
201 |
'at_plugins' => _wpsf__( 'Plugins' ),
|
202 |
'at_themes' => _wpsf__( 'Themes' ),
|
@@ -211,7 +211,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
211 |
'at_ipaddress' => _wpsf__( 'IP Address' ),
|
212 |
'at_you' => _wpsf__( 'You' ),
|
213 |
'at_no_audit_entries' => _wpsf__( 'There are currently no audit entries this is section.' ),
|
214 |
-
|
215 |
);
|
216 |
}
|
217 |
|
@@ -278,12 +278,12 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
278 |
|
279 |
$oUser = Services::WpUsers()->getUserByEmail( $sEmail );
|
280 |
|
281 |
-
$aExportItem =
|
282 |
'group_id' => $this->prefix(),
|
283 |
'group_label' => sprintf( _wpsf__( '[%s] Audit Trail Entries' ), $this->getCon()->getHumanName() ),
|
284 |
'item_id' => $this->prefix( 'audit-trail' ),
|
285 |
-
'data' =>
|
286 |
-
|
287 |
|
288 |
try {
|
289 |
$oFinder = $oProc->getSubProAuditor()
|
@@ -295,11 +295,11 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
295 |
$oWp = Services::WpGeneral();
|
296 |
/** @var Shield\Databases\AuditTrail\EntryVO $oEntry */
|
297 |
foreach ( $oFinder->query() as $oEntry ) {
|
298 |
-
$aExportItem[ 'data' ][] =
|
299 |
$sTimeStamp = $oWp->getTimeStringForDisplay( $oEntry->getCreatedAt() ),
|
300 |
'name' => sprintf( '[%s] Audit Trail Entry', $sTimeStamp ),
|
301 |
'value' => sprintf( '[IP:%s] %s', $oEntry->ip, $oEntry->message )
|
302 |
-
|
303 |
}
|
304 |
|
305 |
if ( !empty( $aExportItem[ 'data' ] ) ) {
|
@@ -344,21 +344,21 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
344 |
* @return array
|
345 |
*/
|
346 |
public function addInsightsConfigData( $aAllData ) {
|
347 |
-
$aThis =
|
348 |
-
'strings' =>
|
349 |
'title' => _wpsf__( 'Activity Audit Log' ),
|
350 |
'sub' => _wpsf__( 'Track Activity: What, Who, When, Where' ),
|
351 |
-
|
352 |
-
'key_opts' =>
|
353 |
'href_options' => $this->getUrl_AdminPage()
|
354 |
-
|
355 |
|
356 |
if ( !$this->isModOptEnabled() ) {
|
357 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
358 |
}
|
359 |
else {
|
360 |
-
$aAudit =
|
361 |
-
$aNonAudit =
|
362 |
$this->isAuditShield() ? $aAudit[] = 'Shield' : $aNonAudit[] = 'Shield';
|
363 |
$this->isAuditUsers() ? $aAudit[] = _wpsf__( 'users' ) : $aNonAudit[] = _wpsf__( 'users' );
|
364 |
$this->isAuditPlugins() ? $aAudit[] = _wpsf__( 'plugins' ) : $aNonAudit[] = _wpsf__( 'plugins' );
|
@@ -368,22 +368,22 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
368 |
$this->isAuditWp() ? $aAudit[] = 'WP' : $aNonAudit[] = 'WP';
|
369 |
|
370 |
if ( empty( $aNonAudit ) ) {
|
371 |
-
$aThis[ 'key_opts' ][ 'audit' ] =
|
372 |
'name' => _wpsf__( 'Audit Areas' ),
|
373 |
'enabled' => true,
|
374 |
'summary' => _wpsf__( 'All important events on your site are being logged' ),
|
375 |
'weight' => 2,
|
376 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
377 |
-
|
378 |
}
|
379 |
else if ( empty( $aAudit ) ) {
|
380 |
-
$aThis[ 'key_opts' ][ 'audit' ] =
|
381 |
'name' => _wpsf__( 'Audit Areas' ),
|
382 |
'enabled' => false,
|
383 |
'summary' => sprintf( _wpsf__( 'No areas are set to be audited: %s' ), implode( ', ', $aAudit ) ),
|
384 |
'weight' => 2,
|
385 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
386 |
-
|
387 |
}
|
388 |
else {
|
389 |
// $aThis[ 'key_opts' ][ 'audit' ] = array(
|
@@ -393,22 +393,22 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
393 |
// 'weight' => 2,
|
394 |
// 'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
395 |
// );
|
396 |
-
$aThis[ 'key_opts' ][ 'nonaudit' ] =
|
397 |
'name' => _wpsf__( 'Audit Events' ),
|
398 |
'enabled' => false,
|
399 |
'summary' => sprintf( _wpsf__( "Important events aren't being audited: %s" ), implode( ', ', $aNonAudit ) ),
|
400 |
'weight' => 2,
|
401 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
402 |
-
|
403 |
}
|
404 |
|
405 |
-
$aThis[ 'key_opts' ][ 'length' ] =
|
406 |
'name' => _wpsf__( 'Audit Trail' ),
|
407 |
'enabled' => true,
|
408 |
'summary' => sprintf( _wpsf__( 'Maximum Audit Trail entries limited to %s' ), $this->getMaxEntries() ),
|
409 |
'weight' => 0,
|
410 |
'href' => $this->getUrl_DirectLinkToOption( 'audit_trail_max_entries' ),
|
411 |
-
|
412 |
}
|
413 |
|
414 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -427,28 +427,28 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
427 |
|
428 |
case 'section_enable_plugin_feature_audit_trail' :
|
429 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
430 |
-
$aSummary =
|
431 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Audit Trail is designed so you can look back on events and analyse what happened and what may have gone wrong.' ) ),
|
432 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Audit Trail' ) ) )
|
433 |
-
|
434 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
435 |
break;
|
436 |
|
437 |
case 'section_audit_trail_options' :
|
438 |
$sTitle = _wpsf__( 'Audit Trail Options' );
|
439 |
-
$aSummary =
|
440 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control over the audit trail itself.' ) ),
|
441 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'These settings are dependent on your requirements.' ) )
|
442 |
-
|
443 |
$sTitleShort = _wpsf__( 'Audit Trail Options' );
|
444 |
break;
|
445 |
|
446 |
case 'section_enable_audit_contexts' :
|
447 |
$sTitle = _wpsf__( 'Enable Audit Areas' );
|
448 |
-
$aSummary =
|
449 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Specify which types of actions on your site are logged.' ) ),
|
450 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'These settings are dependent on your requirements.' ) )
|
451 |
-
|
452 |
$sTitleShort = _wpsf__( 'Audit Areas' );
|
453 |
break;
|
454 |
|
@@ -457,21 +457,21 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
457 |
$sTitleShort = _wpsf__( 'Change Tracking' );
|
458 |
$aData = ( new Shield\ChangeTrack\Snapshot\Collate() )->run();
|
459 |
$sResult = (int)( strlen( base64_encode( WP_Http_Encoding::compress( json_encode( $aData ) ) ) )/1024 );
|
460 |
-
$aSummary =
|
461 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Track significant changes to your site.' ) )
|
462 |
.' '.sprintf( '%s - %s', _wpsf__( 'Note' ), _wpsf__( 'This is separate from the Audit Trail.' ) ),
|
463 |
sprintf( '%s - %s', _wpsf__( 'Considerations' ),
|
464 |
_wpsf__( 'Change Tracking uses snapshots that may use take up lot of data.' )
|
465 |
.' '.sprintf( 'Each snapshot will consume ~%sKB in your database', $sResult )
|
466 |
),
|
467 |
-
|
468 |
break;
|
469 |
|
470 |
default:
|
471 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $sSectionSlug ) );
|
472 |
}
|
473 |
$aOptionsParams[ 'title' ] = $sTitle;
|
474 |
-
$aOptionsParams[ 'summary' ] = ( isset( $aSummary ) && is_array( $aSummary ) ) ? $aSummary :
|
475 |
$aOptionsParams[ 'title_short' ] = $sTitleShort;
|
476 |
return $aOptionsParams;
|
477 |
}
|
@@ -502,7 +502,7 @@ class ICWP_WPSF_FeatureHandler_AuditTrail extends ICWP_WPSF_FeatureHandler_BaseW
|
|
502 |
|
503 |
case 'audit_trail_auto_clean' :
|
504 |
$sName = _wpsf__( 'Auto Clean' );
|
505 |
-
$sSummary = _wpsf__( '
|
506 |
$sDescription = _wpsf__( 'Events older than the number of days specified will be automatically cleaned from the database.' );
|
507 |
break;
|
508 |
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
return [
|
79 |
'success' => $bSuccess,
|
80 |
'message' => $sMessage
|
81 |
+
];
|
82 |
}
|
83 |
|
84 |
/**
|
92 |
->setMod( $this )
|
93 |
->setDbHandler( $oPro->getSubProAuditor()->getDbHandler() );
|
94 |
|
95 |
+
return [
|
96 |
'success' => true,
|
97 |
'html' => $oTableBuilder->buildTable()
|
98 |
+
];
|
99 |
}
|
100 |
|
101 |
/**
|
178 |
* @return array
|
179 |
*/
|
180 |
public function getAllContexts() {
|
181 |
+
return [
|
182 |
'all' => 'All', //special
|
183 |
'wpsf' => $this->getCon()->getHumanName(),
|
184 |
'wordpress' => 'WordPress',
|
187 |
'plugins' => 'Plugins',
|
188 |
'themes' => 'Themes',
|
189 |
'emails' => 'Emails',
|
190 |
+
];
|
191 |
}
|
192 |
|
193 |
/**
|
196 |
protected function getDisplayStrings() {
|
197 |
return $this->loadDP()->mergeArraysRecursive(
|
198 |
parent::getDisplayStrings(),
|
199 |
+
[
|
200 |
'at_users' => _wpsf__( 'Users' ),
|
201 |
'at_plugins' => _wpsf__( 'Plugins' ),
|
202 |
'at_themes' => _wpsf__( 'Themes' ),
|
211 |
'at_ipaddress' => _wpsf__( 'IP Address' ),
|
212 |
'at_you' => _wpsf__( 'You' ),
|
213 |
'at_no_audit_entries' => _wpsf__( 'There are currently no audit entries this is section.' ),
|
214 |
+
]
|
215 |
);
|
216 |
}
|
217 |
|
278 |
|
279 |
$oUser = Services::WpUsers()->getUserByEmail( $sEmail );
|
280 |
|
281 |
+
$aExportItem = [
|
282 |
'group_id' => $this->prefix(),
|
283 |
'group_label' => sprintf( _wpsf__( '[%s] Audit Trail Entries' ), $this->getCon()->getHumanName() ),
|
284 |
'item_id' => $this->prefix( 'audit-trail' ),
|
285 |
+
'data' => [],
|
286 |
+
];
|
287 |
|
288 |
try {
|
289 |
$oFinder = $oProc->getSubProAuditor()
|
295 |
$oWp = Services::WpGeneral();
|
296 |
/** @var Shield\Databases\AuditTrail\EntryVO $oEntry */
|
297 |
foreach ( $oFinder->query() as $oEntry ) {
|
298 |
+
$aExportItem[ 'data' ][] = [
|
299 |
$sTimeStamp = $oWp->getTimeStringForDisplay( $oEntry->getCreatedAt() ),
|
300 |
'name' => sprintf( '[%s] Audit Trail Entry', $sTimeStamp ),
|
301 |
'value' => sprintf( '[IP:%s] %s', $oEntry->ip, $oEntry->message )
|
302 |
+
];
|
303 |
}
|
304 |
|
305 |
if ( !empty( $aExportItem[ 'data' ] ) ) {
|
344 |
* @return array
|
345 |
*/
|
346 |
public function addInsightsConfigData( $aAllData ) {
|
347 |
+
$aThis = [
|
348 |
+
'strings' => [
|
349 |
'title' => _wpsf__( 'Activity Audit Log' ),
|
350 |
'sub' => _wpsf__( 'Track Activity: What, Who, When, Where' ),
|
351 |
+
],
|
352 |
+
'key_opts' => [],
|
353 |
'href_options' => $this->getUrl_AdminPage()
|
354 |
+
];
|
355 |
|
356 |
if ( !$this->isModOptEnabled() ) {
|
357 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
358 |
}
|
359 |
else {
|
360 |
+
$aAudit = [];
|
361 |
+
$aNonAudit = [];
|
362 |
$this->isAuditShield() ? $aAudit[] = 'Shield' : $aNonAudit[] = 'Shield';
|
363 |
$this->isAuditUsers() ? $aAudit[] = _wpsf__( 'users' ) : $aNonAudit[] = _wpsf__( 'users' );
|
364 |
$this->isAuditPlugins() ? $aAudit[] = _wpsf__( 'plugins' ) : $aNonAudit[] = _wpsf__( 'plugins' );
|
368 |
$this->isAuditWp() ? $aAudit[] = 'WP' : $aNonAudit[] = 'WP';
|
369 |
|
370 |
if ( empty( $aNonAudit ) ) {
|
371 |
+
$aThis[ 'key_opts' ][ 'audit' ] = [
|
372 |
'name' => _wpsf__( 'Audit Areas' ),
|
373 |
'enabled' => true,
|
374 |
'summary' => _wpsf__( 'All important events on your site are being logged' ),
|
375 |
'weight' => 2,
|
376 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
377 |
+
];
|
378 |
}
|
379 |
else if ( empty( $aAudit ) ) {
|
380 |
+
$aThis[ 'key_opts' ][ 'audit' ] = [
|
381 |
'name' => _wpsf__( 'Audit Areas' ),
|
382 |
'enabled' => false,
|
383 |
'summary' => sprintf( _wpsf__( 'No areas are set to be audited: %s' ), implode( ', ', $aAudit ) ),
|
384 |
'weight' => 2,
|
385 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
386 |
+
];
|
387 |
}
|
388 |
else {
|
389 |
// $aThis[ 'key_opts' ][ 'audit' ] = array(
|
393 |
// 'weight' => 2,
|
394 |
// 'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
395 |
// );
|
396 |
+
$aThis[ 'key_opts' ][ 'nonaudit' ] = [
|
397 |
'name' => _wpsf__( 'Audit Events' ),
|
398 |
'enabled' => false,
|
399 |
'summary' => sprintf( _wpsf__( "Important events aren't being audited: %s" ), implode( ', ', $aNonAudit ) ),
|
400 |
'weight' => 2,
|
401 |
'href' => $this->getUrl_DirectLinkToSection( 'section_enable_audit_contexts' ),
|
402 |
+
];
|
403 |
}
|
404 |
|
405 |
+
$aThis[ 'key_opts' ][ 'length' ] = [
|
406 |
'name' => _wpsf__( 'Audit Trail' ),
|
407 |
'enabled' => true,
|
408 |
'summary' => sprintf( _wpsf__( 'Maximum Audit Trail entries limited to %s' ), $this->getMaxEntries() ),
|
409 |
'weight' => 0,
|
410 |
'href' => $this->getUrl_DirectLinkToOption( 'audit_trail_max_entries' ),
|
411 |
+
];
|
412 |
}
|
413 |
|
414 |
$aAllData[ $this->getSlug() ] = $aThis;
|
427 |
|
428 |
case 'section_enable_plugin_feature_audit_trail' :
|
429 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
430 |
+
$aSummary = [
|
431 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Audit Trail is designed so you can look back on events and analyse what happened and what may have gone wrong.' ) ),
|
432 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Audit Trail' ) ) )
|
433 |
+
];
|
434 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
435 |
break;
|
436 |
|
437 |
case 'section_audit_trail_options' :
|
438 |
$sTitle = _wpsf__( 'Audit Trail Options' );
|
439 |
+
$aSummary = [
|
440 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control over the audit trail itself.' ) ),
|
441 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'These settings are dependent on your requirements.' ) )
|
442 |
+
];
|
443 |
$sTitleShort = _wpsf__( 'Audit Trail Options' );
|
444 |
break;
|
445 |
|
446 |
case 'section_enable_audit_contexts' :
|
447 |
$sTitle = _wpsf__( 'Enable Audit Areas' );
|
448 |
+
$aSummary = [
|
449 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Specify which types of actions on your site are logged.' ) ),
|
450 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'These settings are dependent on your requirements.' ) )
|
451 |
+
];
|
452 |
$sTitleShort = _wpsf__( 'Audit Areas' );
|
453 |
break;
|
454 |
|
457 |
$sTitleShort = _wpsf__( 'Change Tracking' );
|
458 |
$aData = ( new Shield\ChangeTrack\Snapshot\Collate() )->run();
|
459 |
$sResult = (int)( strlen( base64_encode( WP_Http_Encoding::compress( json_encode( $aData ) ) ) )/1024 );
|
460 |
+
$aSummary = [
|
461 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Track significant changes to your site.' ) )
|
462 |
.' '.sprintf( '%s - %s', _wpsf__( 'Note' ), _wpsf__( 'This is separate from the Audit Trail.' ) ),
|
463 |
sprintf( '%s - %s', _wpsf__( 'Considerations' ),
|
464 |
_wpsf__( 'Change Tracking uses snapshots that may use take up lot of data.' )
|
465 |
.' '.sprintf( 'Each snapshot will consume ~%sKB in your database', $sResult )
|
466 |
),
|
467 |
+
];
|
468 |
break;
|
469 |
|
470 |
default:
|
471 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $sSectionSlug ) );
|
472 |
}
|
473 |
$aOptionsParams[ 'title' ] = $sTitle;
|
474 |
+
$aOptionsParams[ 'summary' ] = ( isset( $aSummary ) && is_array( $aSummary ) ) ? $aSummary : [];
|
475 |
$aOptionsParams[ 'title_short' ] = $sTitleShort;
|
476 |
return $aOptionsParams;
|
477 |
}
|
502 |
|
503 |
case 'audit_trail_auto_clean' :
|
504 |
$sName = _wpsf__( 'Auto Clean' );
|
505 |
+
$sSummary = _wpsf__( 'Automatically Purge Audit Log Entries Older Than The Set Number Of Days' );
|
506 |
$sDescription = _wpsf__( 'Events older than the number of days specified will be automatically cleaned from the database.' );
|
507 |
break;
|
508 |
|
@@ -36,11 +36,11 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
36 |
$aTracking = [];
|
37 |
}
|
38 |
$aTracking = $this->loadDP()->mergeArraysRecursive(
|
39 |
-
|
40 |
'core' => [],
|
41 |
'plugins' => [],
|
42 |
'themes' => [],
|
43 |
-
|
44 |
$aTracking
|
45 |
);
|
46 |
$this->setOpt( 'delay_tracking', $aTracking );
|
@@ -153,10 +153,10 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
153 |
}
|
154 |
}
|
155 |
|
156 |
-
return
|
157 |
'success' => $bSuccess,
|
158 |
'message' => $sMessage,
|
159 |
-
|
160 |
}
|
161 |
|
162 |
/**
|
@@ -203,22 +203,22 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
203 |
* @return array
|
204 |
*/
|
205 |
public function addInsightsNoticeData( $aAllNotices ) {
|
206 |
-
$aNotices =
|
207 |
'title' => _wpsf__( 'Automatic Updates' ),
|
208 |
'messages' => []
|
209 |
-
|
210 |
{ //really disabled?
|
211 |
$oWp = Services::WpGeneral();
|
212 |
if ( $this->isModOptEnabled() ) {
|
213 |
if ( $this->isDisableAllAutoUpdates() && !$oWp->getWpAutomaticUpdater()->is_disabled() ) {
|
214 |
-
$aNotices[ 'messages' ][ 'disabled_auto' ] =
|
215 |
'title' => 'Auto Updates Not Really Disabled',
|
216 |
'message' => _wpsf__( 'Automatic Updates Are Not Disabled As Expected.' ),
|
217 |
'href' => $this->getUrl_DirectLinkToOption( 'enable_autoupdate_disable_all' ),
|
218 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
219 |
'rec' => sprintf( _wpsf__( 'A plugin/theme other than %s is affecting your automatic update settings.' ), $this->getCon()
|
220 |
->getHumanName() )
|
221 |
-
|
222 |
}
|
223 |
}
|
224 |
}
|
@@ -234,14 +234,14 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
234 |
* @return array
|
235 |
*/
|
236 |
public function addInsightsConfigData( $aAllData ) {
|
237 |
-
$aThis =
|
238 |
-
'strings' =>
|
239 |
'title' => _wpsf__( 'Automatic Updates' ),
|
240 |
'sub' => _wpsf__( 'Control WordPress Automatic Updates' ),
|
241 |
-
|
242 |
'key_opts' => [],
|
243 |
'href_options' => $this->getUrl_AdminPage()
|
244 |
-
|
245 |
|
246 |
if ( !$this->isModOptEnabled() ) {
|
247 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
@@ -250,7 +250,7 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
250 |
|
251 |
$bAllDisabled = $this->isDisableAllAutoUpdates();
|
252 |
if ( $bAllDisabled ) {
|
253 |
-
$aThis[ 'key_opts' ][ 'disabled' ] =
|
254 |
'name' => _wpsf__( 'Disabled All' ),
|
255 |
'enabled' => !$bAllDisabled,
|
256 |
'summary' => $bAllDisabled ?
|
@@ -258,12 +258,12 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
258 |
: _wpsf__( 'The automatic updates system is enabled' ),
|
259 |
'weight' => 2,
|
260 |
'href' => $this->getUrl_DirectLinkToOption( 'enable_autoupdate_disable_all' ),
|
261 |
-
|
262 |
}
|
263 |
else {
|
264 |
$oWp = $this->loadWp();
|
265 |
$bCanCore = $oWp->canCoreUpdateAutomatically();
|
266 |
-
$aThis[ 'key_opts' ][ 'core_minor' ] =
|
267 |
'name' => _wpsf__( 'Core Updates' ),
|
268 |
'enabled' => $bCanCore,
|
269 |
'summary' => $bCanCore ?
|
@@ -271,10 +271,10 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
271 |
: _wpsf__( 'Minor WP Core updates will not be installed automatically' ),
|
272 |
'weight' => 2,
|
273 |
'href' => $this->getUrl_DirectLinkToOption( 'autoupdate_core' ),
|
274 |
-
|
275 |
|
276 |
$bHasDelay = $this->isModOptEnabled() && $this->getDelayUpdatesPeriod();
|
277 |
-
$aThis[ 'key_opts' ][ 'delay' ] =
|
278 |
'name' => _wpsf__( 'Update Delay' ),
|
279 |
'enabled' => $bHasDelay,
|
280 |
'summary' => $bHasDelay ?
|
@@ -282,12 +282,12 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
282 |
: _wpsf__( 'Automatic updates are applied immediately' ),
|
283 |
'weight' => 1,
|
284 |
'href' => $this->getUrl_DirectLinkToOption( 'update_delay' ),
|
285 |
-
|
286 |
|
287 |
$sName = $this->getCon()->getHumanName();
|
288 |
$bSelfAuto = $this->isModOptEnabled()
|
289 |
&& in_array( $this->getSelfAutoUpdateOpt(), [ 'auto', 'immediate' ] );
|
290 |
-
$aThis[ 'key_opts' ][ 'self' ] =
|
291 |
'name' => _wpsf__( 'Self Auto-Update' ),
|
292 |
'enabled' => $bSelfAuto,
|
293 |
'summary' => $bSelfAuto ?
|
@@ -295,7 +295,7 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
295 |
: sprintf( _wpsf__( "%s isn't automatically updated" ), $sName ),
|
296 |
'weight' => 1,
|
297 |
'href' => $this->getUrl_DirectLinkToOption( 'autoupdate_plugin_self' ),
|
298 |
-
|
299 |
}
|
300 |
}
|
301 |
|
@@ -316,49 +316,49 @@ class ICWP_WPSF_FeatureHandler_Autoupdates extends ICWP_WPSF_FeatureHandler_Base
|
|
316 |
|
317 |
case 'section_enable_plugin_feature_automatic_updates_control' :
|
318 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
319 |
-
$aSummary =
|
320 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatic Updates lets you manage the WordPress automatic updates engine so you choose what exactly gets updated automatically.' ) ),
|
321 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Automatic Updates' ) ) )
|
322 |
-
|
323 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
324 |
break;
|
325 |
|
326 |
case 'section_disable_all_wordpress_automatic_updates' :
|
327 |
$sTitle = _wpsf__( 'Disable ALL WordPress Automatic Updates' );
|
328 |
-
$aSummary =
|
329 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'If you never want WordPress to automatically update anything on your site, turn on this option.' ) ),
|
330 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Do not turn on this option unless you really need to block updates.' ) )
|
331 |
-
|
332 |
$sTitleShort = _wpsf__( 'Turn Off' );
|
333 |
break;
|
334 |
|
335 |
case 'section_automatic_plugin_self_update' :
|
336 |
$sTitle = _wpsf__( 'Automatic Plugin Self-Update' );
|
337 |
-
$aSummary =
|
338 |
sprintf( '%s - %s',
|
339 |
_wpsf__( 'Purpose' ),
|
340 |
sprintf( _wpsf__( 'Allows the %s plugin to automatically update itself when an update is available.' ), $sPlugName )
|
341 |
),
|
342 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this option turned on.' ) )
|
343 |
-
|
344 |
$sTitleShort = _wpsf__( 'Self-Update' );
|
345 |
break;
|
346 |
|
347 |
case 'section_automatic_updates_for_wordpress_components' :
|
348 |
$sTitle = _wpsf__( 'Automatic Updates For WordPress Components' );
|
349 |
-
$aSummary =
|
350 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Control how automatic updates for each WordPress component is handled.' ) ),
|
351 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'You should at least allow minor updates for the WordPress core.' ) )
|
352 |
-
|
353 |
$sTitleShort = _wpsf__( 'WordPress Components' );
|
354 |
break;
|
355 |
|
356 |
case 'section_options' :
|
357 |
$sTitle = _wpsf__( 'Auto-Update Options' );
|
358 |
$sTitleShort = _wpsf__( 'Auto-Update Options' );
|
359 |
-
$aSummary =
|
360 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Make adjustments to how automatic updates are handled on your site.' ) ),
|
361 |
-
|
362 |
break;
|
363 |
|
364 |
default:
|
36 |
$aTracking = [];
|
37 |
}
|
38 |
$aTracking = $this->loadDP()->mergeArraysRecursive(
|
39 |
+
[
|
40 |
'core' => [],
|
41 |
'plugins' => [],
|
42 |
'themes' => [],
|
43 |
+
],
|
44 |
$aTracking
|
45 |
);
|
46 |
$this->setOpt( 'delay_tracking', $aTracking );
|
153 |
}
|
154 |
}
|
155 |
|
156 |
+
return [
|
157 |
'success' => $bSuccess,
|
158 |
'message' => $sMessage,
|
159 |
+
];
|
160 |
}
|
161 |
|
162 |
/**
|
203 |
* @return array
|
204 |
*/
|
205 |
public function addInsightsNoticeData( $aAllNotices ) {
|
206 |
+
$aNotices = [
|
207 |
'title' => _wpsf__( 'Automatic Updates' ),
|
208 |
'messages' => []
|
209 |
+
];
|
210 |
{ //really disabled?
|
211 |
$oWp = Services::WpGeneral();
|
212 |
if ( $this->isModOptEnabled() ) {
|
213 |
if ( $this->isDisableAllAutoUpdates() && !$oWp->getWpAutomaticUpdater()->is_disabled() ) {
|
214 |
+
$aNotices[ 'messages' ][ 'disabled_auto' ] = [
|
215 |
'title' => 'Auto Updates Not Really Disabled',
|
216 |
'message' => _wpsf__( 'Automatic Updates Are Not Disabled As Expected.' ),
|
217 |
'href' => $this->getUrl_DirectLinkToOption( 'enable_autoupdate_disable_all' ),
|
218 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
219 |
'rec' => sprintf( _wpsf__( 'A plugin/theme other than %s is affecting your automatic update settings.' ), $this->getCon()
|
220 |
->getHumanName() )
|
221 |
+
];
|
222 |
}
|
223 |
}
|
224 |
}
|
234 |
* @return array
|
235 |
*/
|
236 |
public function addInsightsConfigData( $aAllData ) {
|
237 |
+
$aThis = [
|
238 |
+
'strings' => [
|
239 |
'title' => _wpsf__( 'Automatic Updates' ),
|
240 |
'sub' => _wpsf__( 'Control WordPress Automatic Updates' ),
|
241 |
+
],
|
242 |
'key_opts' => [],
|
243 |
'href_options' => $this->getUrl_AdminPage()
|
244 |
+
];
|
245 |
|
246 |
if ( !$this->isModOptEnabled() ) {
|
247 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
250 |
|
251 |
$bAllDisabled = $this->isDisableAllAutoUpdates();
|
252 |
if ( $bAllDisabled ) {
|
253 |
+
$aThis[ 'key_opts' ][ 'disabled' ] = [
|
254 |
'name' => _wpsf__( 'Disabled All' ),
|
255 |
'enabled' => !$bAllDisabled,
|
256 |
'summary' => $bAllDisabled ?
|
258 |
: _wpsf__( 'The automatic updates system is enabled' ),
|
259 |
'weight' => 2,
|
260 |
'href' => $this->getUrl_DirectLinkToOption( 'enable_autoupdate_disable_all' ),
|
261 |
+
];
|
262 |
}
|
263 |
else {
|
264 |
$oWp = $this->loadWp();
|
265 |
$bCanCore = $oWp->canCoreUpdateAutomatically();
|
266 |
+
$aThis[ 'key_opts' ][ 'core_minor' ] = [
|
267 |
'name' => _wpsf__( 'Core Updates' ),
|
268 |
'enabled' => $bCanCore,
|
269 |
'summary' => $bCanCore ?
|
271 |
: _wpsf__( 'Minor WP Core updates will not be installed automatically' ),
|
272 |
'weight' => 2,
|
273 |
'href' => $this->getUrl_DirectLinkToOption( 'autoupdate_core' ),
|
274 |
+
];
|
275 |
|
276 |
$bHasDelay = $this->isModOptEnabled() && $this->getDelayUpdatesPeriod();
|
277 |
+
$aThis[ 'key_opts' ][ 'delay' ] = [
|
278 |
'name' => _wpsf__( 'Update Delay' ),
|
279 |
'enabled' => $bHasDelay,
|
280 |
'summary' => $bHasDelay ?
|
282 |
: _wpsf__( 'Automatic updates are applied immediately' ),
|
283 |
'weight' => 1,
|
284 |
'href' => $this->getUrl_DirectLinkToOption( 'update_delay' ),
|
285 |
+
];
|
286 |
|
287 |
$sName = $this->getCon()->getHumanName();
|
288 |
$bSelfAuto = $this->isModOptEnabled()
|
289 |
&& in_array( $this->getSelfAutoUpdateOpt(), [ 'auto', 'immediate' ] );
|
290 |
+
$aThis[ 'key_opts' ][ 'self' ] = [
|
291 |
'name' => _wpsf__( 'Self Auto-Update' ),
|
292 |
'enabled' => $bSelfAuto,
|
293 |
'summary' => $bSelfAuto ?
|
295 |
: sprintf( _wpsf__( "%s isn't automatically updated" ), $sName ),
|
296 |
'weight' => 1,
|
297 |
'href' => $this->getUrl_DirectLinkToOption( 'autoupdate_plugin_self' ),
|
298 |
+
];
|
299 |
}
|
300 |
}
|
301 |
|
316 |
|
317 |
case 'section_enable_plugin_feature_automatic_updates_control' :
|
318 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
319 |
+
$aSummary = [
|
320 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatic Updates lets you manage the WordPress automatic updates engine so you choose what exactly gets updated automatically.' ) ),
|
321 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Automatic Updates' ) ) )
|
322 |
+
];
|
323 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
324 |
break;
|
325 |
|
326 |
case 'section_disable_all_wordpress_automatic_updates' :
|
327 |
$sTitle = _wpsf__( 'Disable ALL WordPress Automatic Updates' );
|
328 |
+
$aSummary = [
|
329 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'If you never want WordPress to automatically update anything on your site, turn on this option.' ) ),
|
330 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Do not turn on this option unless you really need to block updates.' ) )
|
331 |
+
];
|
332 |
$sTitleShort = _wpsf__( 'Turn Off' );
|
333 |
break;
|
334 |
|
335 |
case 'section_automatic_plugin_self_update' :
|
336 |
$sTitle = _wpsf__( 'Automatic Plugin Self-Update' );
|
337 |
+
$aSummary = [
|
338 |
sprintf( '%s - %s',
|
339 |
_wpsf__( 'Purpose' ),
|
340 |
sprintf( _wpsf__( 'Allows the %s plugin to automatically update itself when an update is available.' ), $sPlugName )
|
341 |
),
|
342 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this option turned on.' ) )
|
343 |
+
];
|
344 |
$sTitleShort = _wpsf__( 'Self-Update' );
|
345 |
break;
|
346 |
|
347 |
case 'section_automatic_updates_for_wordpress_components' :
|
348 |
$sTitle = _wpsf__( 'Automatic Updates For WordPress Components' );
|
349 |
+
$aSummary = [
|
350 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Control how automatic updates for each WordPress component is handled.' ) ),
|
351 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'You should at least allow minor updates for the WordPress core.' ) )
|
352 |
+
];
|
353 |
$sTitleShort = _wpsf__( 'WordPress Components' );
|
354 |
break;
|
355 |
|
356 |
case 'section_options' :
|
357 |
$sTitle = _wpsf__( 'Auto-Update Options' );
|
358 |
$sTitleShort = _wpsf__( 'Auto-Update Options' );
|
359 |
+
$aSummary = [
|
360 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Make adjustments to how automatic updates are handled on your site.' ) ),
|
361 |
+
];
|
362 |
break;
|
363 |
|
364 |
default:
|
@@ -85,38 +85,37 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
85 |
$oReq = Services::Request();
|
86 |
|
87 |
$nRunPriority = isset( $aModProps[ 'load_priority' ] ) ? $aModProps[ 'load_priority' ] : 100;
|
88 |
-
add_action( $this->prefix( 'run_processors' ),
|
89 |
-
add_action( 'init',
|
90 |
-
add_action( $this->prefix( 'import_options' ),
|
91 |
|
92 |
if ( $this->isModuleRequest() ) {
|
93 |
-
add_action( $this->prefix( 'form_submit' ),
|
94 |
-
add_filter( $this->prefix( 'ajaxAction' ),
|
95 |
-
add_filter( $this->prefix( 'ajaxAuthAction' ),
|
96 |
-
add_filter( $this->prefix( 'ajaxNonAuthAction' ),
|
97 |
|
98 |
if ( $oReq->request( 'action' ) == $this->prefix()
|
99 |
&& check_admin_referer( $oReq->request( 'exec' ), 'exec_nonce' )
|
100 |
) {
|
101 |
-
add_action( $this->prefix( 'mod_request' ),
|
102 |
}
|
103 |
}
|
104 |
|
105 |
$nMenuPri = isset( $aModProps[ 'menu_priority' ] ) ? $aModProps[ 'menu_priority' ] : 100;
|
106 |
-
add_filter( $this->prefix( 'submenu_items' ),
|
107 |
-
add_filter( $this->prefix( 'collect_mod_summary' ),
|
108 |
-
add_filter( $this->prefix( 'collect_notices' ),
|
109 |
-
add_filter( $this->prefix( 'collect_summary' ),
|
110 |
-
add_action( $this->prefix( 'plugin_shutdown' ),
|
111 |
-
add_action( $this->prefix( 'deactivate_plugin' ),
|
112 |
-
add_action( $this->prefix( 'delete_plugin' ),
|
113 |
-
add_filter( $this->prefix( 'aggregate_all_plugin_options' ),
|
114 |
|
115 |
-
add_filter( $this->prefix( 'register_admin_notices' ),
|
116 |
-
add_filter( $this->prefix( 'gather_options_for_export' ),
|
117 |
|
118 |
-
add_action( '
|
119 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'onWpEnqueueAdminJs' ), 100 );
|
120 |
|
121 |
// if ( $this->isAdminOptionsPage() ) {
|
122 |
// add_action( 'current_screen', array( $this, 'onSetCurrentScreen' ) );
|
@@ -202,12 +201,12 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
202 |
protected function normaliseAjaxResponse( $aAjaxResponse ) {
|
203 |
if ( !empty( $aAjaxResponse ) ) {
|
204 |
$aAjaxResponse = array_merge(
|
205 |
-
|
206 |
'success' => false,
|
207 |
'page_reload' => false,
|
208 |
'message' => 'Unknown',
|
209 |
'html' => '',
|
210 |
-
|
211 |
$aAjaxResponse
|
212 |
);
|
213 |
}
|
@@ -332,8 +331,8 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
332 |
|
333 |
// GDPR
|
334 |
if ( $this->isPremium() ) {
|
335 |
-
add_filter( $this->prefix( 'wpPrivacyExport' ),
|
336 |
-
add_filter( $this->prefix( 'wpPrivacyErase' ),
|
337 |
}
|
338 |
}
|
339 |
|
@@ -343,7 +342,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
343 |
*/
|
344 |
public function onSetCurrentScreen() {
|
345 |
global $page_hook;
|
346 |
-
add_action( 'load-'.$page_hook,
|
347 |
}
|
348 |
|
349 |
/**
|
@@ -493,7 +492,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
493 |
*/
|
494 |
public function getEmailHandler() {
|
495 |
if ( is_null( self::$oEmailHandler ) ) {
|
496 |
-
self::$oEmailHandler = $this->getCon()->loadFeatureHandler(
|
497 |
}
|
498 |
return self::$oEmailHandler;
|
499 |
}
|
@@ -604,12 +603,12 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
604 |
}
|
605 |
|
606 |
$sMenuPageTitle = $sMenuTitleName.' - '.$sHumanName;
|
607 |
-
$aItems[ $sMenuPageTitle ] =
|
608 |
$sMenuTitleName,
|
609 |
$this->getModSlug(),
|
610 |
[ $this, 'displayModuleAdminPage' ],
|
611 |
$this->getIfShowModuleMenuItem()
|
612 |
-
|
613 |
|
614 |
$aAdditionalItems = $this->getOptionsVo()->getAdditionalMenuItems();
|
615 |
if ( !empty( $aAdditionalItems ) && is_array( $aAdditionalItems ) ) {
|
@@ -621,11 +620,11 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
621 |
}
|
622 |
|
623 |
$sMenuPageTitle = $sHumanName.' - '.$aMenuItem[ 'title' ];
|
624 |
-
$aItems[ $sMenuPageTitle ] =
|
625 |
$aMenuItem[ 'title' ],
|
626 |
$this->prefix( $aMenuItem[ 'slug' ] ),
|
627 |
-
|
628 |
-
|
629 |
}
|
630 |
}
|
631 |
}
|
@@ -678,7 +677,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
678 |
$aSections[ $sSlug ] = $this->loadStrings_SectionTitles( $aSection );
|
679 |
}
|
680 |
|
681 |
-
$aSummary =
|
682 |
'enabled' => $this->isEnabledForUiSummary(),
|
683 |
'active' => $this->isThisModulePage(),
|
684 |
'slug' => $this->getSlug(),
|
@@ -686,7 +685,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
686 |
'menu_title' => empty( $sMenuTitle ) ? $this->getMainFeatureName() : $sMenuTitle,
|
687 |
'href' => network_admin_url( 'admin.php?page='.$this->getModSlug() ),
|
688 |
'sections' => $aSections,
|
689 |
-
|
690 |
$aSummary[ 'content' ] = $this->renderTemplate( 'snippets/summary_single', $aSummary );
|
691 |
return $aSummary;
|
692 |
}
|
@@ -811,7 +810,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
811 |
public function setLastErrors( $mErrors = [] ) {
|
812 |
if ( !is_array( $mErrors ) ) {
|
813 |
if ( is_string( $mErrors ) ) {
|
814 |
-
$mErrors =
|
815 |
}
|
816 |
else {
|
817 |
$mErrors = [];
|
@@ -866,12 +865,12 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
866 |
* @return array
|
867 |
*/
|
868 |
public function getNonceActionData( $sAction = '' ) {
|
869 |
-
return
|
870 |
'action' => $this->prefix(), //wp ajax doesn't work without this.
|
871 |
'exec' => $sAction,
|
872 |
'exec_nonce' => $this->genNonce( $sAction ),
|
873 |
'mod_slug' => $this->getModSlug(),
|
874 |
-
|
875 |
}
|
876 |
|
877 |
/**
|
@@ -1074,12 +1073,12 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1074 |
break;
|
1075 |
}
|
1076 |
|
1077 |
-
$aParams =
|
1078 |
'value' => is_scalar( $mCurrent ) ? esc_attr( $mCurrent ) : $mCurrent,
|
1079 |
'disabled' => !$this->isPremium() && ( isset( $aOptParams[ 'premium' ] ) && $aOptParams[ 'premium' ] ),
|
1080 |
-
|
1081 |
$aParams[ 'enabled' ] = !$aParams[ 'disabled' ];
|
1082 |
-
$aOptParams = array_merge(
|
1083 |
|
1084 |
// add strings
|
1085 |
return $this->loadStrings_Options( $aOptParams );
|
@@ -1336,7 +1335,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1336 |
}
|
1337 |
|
1338 |
// Prevent overwriting of non-editable fields
|
1339 |
-
if ( !in_array( $sOptType,
|
1340 |
$this->setOpt( $sKey, $sOptionValue );
|
1341 |
}
|
1342 |
}
|
@@ -1459,11 +1458,11 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1459 |
$aData = $this->loadDP()
|
1460 |
->mergeArraysRecursive(
|
1461 |
$this->getBaseDisplayData( false ),
|
1462 |
-
|
1463 |
-
'ajax' =>
|
1464 |
'restricted_access' => $this->getAjaxActionData( 'restricted_access' )
|
1465 |
-
|
1466 |
-
|
1467 |
);
|
1468 |
return $this->renderTemplate( 'access_restricted.php', $aData );
|
1469 |
}
|
@@ -1475,7 +1474,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1475 |
protected function getBaseDisplayData( $bRenderEmbeddedContent = false ) {
|
1476 |
$oCon = $this->getCon();
|
1477 |
|
1478 |
-
$aData =
|
1479 |
'sPluginName' => $oCon->getHumanName(),
|
1480 |
'sFeatureName' => $this->getMainFeatureName(),
|
1481 |
'bFeatureEnabled' => $this->isModuleEnabled(),
|
@@ -1484,7 +1483,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1484 |
'form_action' => 'admin.php?page='.$this->getModSlug(),
|
1485 |
'nOptionsPerRow' => 1,
|
1486 |
'aPluginLabels' => $oCon->getLabels(),
|
1487 |
-
'help_video' =>
|
1488 |
'auto_show' => $this->getIfAutoShowHelpVideo(),
|
1489 |
'iframe_url' => $this->getHelpVideoUrl( $this->getHelpVideoId() ),
|
1490 |
'display_id' => 'ShieldHelpVideo'.$this->getSlug(),
|
@@ -1493,23 +1492,23 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1493 |
'show' => $this->isHelpVideoDisplayable() && !$this->getHelpVideoHasBeenClosed(),
|
1494 |
'width' => 772,
|
1495 |
'height' => 454,
|
1496 |
-
|
1497 |
'aSummaryData' => $this->getModulesSummaryData(),
|
1498 |
|
1499 |
// 'sPageTitle' => sprintf( '%s: %s', $oCon->getHumanName(), $this->getMainFeatureName() ),
|
1500 |
'sPageTitle' => $this->getMainFeatureName(),
|
1501 |
-
'data' =>
|
1502 |
'form_nonce' => $this->genNonce( '' ),
|
1503 |
'mod_slug' => $this->getModSlug( true ),
|
1504 |
'mod_slug_short' => $this->getModSlug( false ),
|
1505 |
'all_options' => $this->buildOptions(),
|
1506 |
'hidden_options' => $this->getOptionsVo()->getHiddenOptions()
|
1507 |
-
|
1508 |
-
'ajax' =>
|
1509 |
'mod_options' => $this->getAjaxActionData( 'mod_options' ),
|
1510 |
-
|
1511 |
'strings' => $this->getDisplayStrings(),
|
1512 |
-
'flags' =>
|
1513 |
'access_restricted' => !$this->canDisplayOptionsForm(),
|
1514 |
'show_ads' => $this->getIsShowMarketing(),
|
1515 |
'wrap_page_content' => true,
|
@@ -1517,30 +1516,30 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1517 |
'show_content_help' => true,
|
1518 |
'show_alt_content' => false,
|
1519 |
'has_wizard' => $this->hasWizard(),
|
1520 |
-
|
1521 |
-
'hrefs' =>
|
1522 |
'back_to_dashboard' => $this->getCon()->getModule( 'insights' )->getUrl_AdminPage(),
|
1523 |
'go_pro' => 'https://icwp.io/shieldgoprofeature',
|
1524 |
'goprofooter' => 'https://icwp.io/goprofooter',
|
1525 |
'wizard_link' => $this->getUrl_WizardLanding(),
|
1526 |
'wizard_landing' => $this->getUrl_WizardLanding()
|
1527 |
-
|
1528 |
-
'content' =>
|
1529 |
'options_form' => '',
|
1530 |
'alt' => '',
|
1531 |
'actions' => '',
|
1532 |
'help' => '',
|
1533 |
'wizard_landing' => ''
|
1534 |
-
|
1535 |
-
|
1536 |
|
1537 |
if ( $bRenderEmbeddedContent ) { // prevents recursive loops
|
1538 |
-
$aData[ 'content' ] =
|
1539 |
'options_form' => 'no form',
|
1540 |
'alt' => '',
|
1541 |
'help' => $this->getContentHelp(),
|
1542 |
'wizard_landing' => $this->getContentWizardLanding()
|
1543 |
-
|
1544 |
$aData[ 'flags' ][ 'show_content_help' ] = strpos( $aData[ 'content' ][ 'help' ], 'Error:' ) !== 0;
|
1545 |
}
|
1546 |
return $aData;
|
@@ -1550,7 +1549,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1550 |
* @return array
|
1551 |
*/
|
1552 |
protected function getDisplayStrings() {
|
1553 |
-
return
|
1554 |
'go_to_settings' => __( 'Settings' ),
|
1555 |
'on' => __( 'On' ),
|
1556 |
'off' => __( 'Off' ),
|
@@ -1562,7 +1561,7 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1562 |
'btn_options' => __( 'Options' ),
|
1563 |
'btn_help' => __( 'Help' ),
|
1564 |
'btn_wizards' => $this->hasWizard() ? __( 'Wizards' ) : __( 'No Wizards' ),
|
1565 |
-
|
1566 |
}
|
1567 |
|
1568 |
/**
|
@@ -1589,11 +1588,11 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1589 |
}
|
1590 |
$screen = get_current_screen();
|
1591 |
//$screen->remove_help_tabs();
|
1592 |
-
$screen->add_help_tab(
|
1593 |
'id' => 'my-plugin-default',
|
1594 |
'title' => __( 'Default' ),
|
1595 |
'content' => 'This is where I would provide tabbed help to the user on how everything in my admin panel works. Formatted HTML works fine in here too'
|
1596 |
-
|
1597 |
//add more help tabs as needed with unique id's
|
1598 |
|
1599 |
// Help sidebars are optional
|
@@ -1625,12 +1624,12 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1625 |
}
|
1626 |
|
1627 |
return add_query_arg(
|
1628 |
-
|
1629 |
'page' => $this->getModSlug(),
|
1630 |
'shield_action' => 'wizard',
|
1631 |
'wizard' => $sWizardSlug,
|
1632 |
'nonwizard' => wp_create_nonce( 'wizard'.$sWizardSlug )
|
1633 |
-
|
1634 |
$sUrl
|
1635 |
);
|
1636 |
}
|
@@ -1724,9 +1723,6 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1724 |
return $this->getOptionsVo()->isAccessRestricted() ? $this->getCon()->isPluginAdmin() : true;
|
1725 |
}
|
1726 |
|
1727 |
-
public function onWpEnqueueJs() {
|
1728 |
-
}
|
1729 |
-
|
1730 |
public function onWpEnqueueAdminJs() {
|
1731 |
$this->insertCustomJsVars_Admin();
|
1732 |
}
|
@@ -1884,11 +1880,11 @@ abstract class ICWP_WPSF_FeatureHandler_Base extends ICWP_WPSF_Foundation {
|
|
1884 |
protected function getHelpVideoOptions() {
|
1885 |
$aOptions = $this->getOpt( 'help_video_options', [] );
|
1886 |
if ( is_null( $aOptions ) || !is_array( $aOptions ) ) {
|
1887 |
-
$aOptions =
|
1888 |
'closed' => false,
|
1889 |
'displayed' => false,
|
1890 |
'played' => false,
|
1891 |
-
|
1892 |
$this->setOpt( 'help_video_options', $aOptions );
|
1893 |
}
|
1894 |
return $aOptions;
|
85 |
$oReq = Services::Request();
|
86 |
|
87 |
$nRunPriority = isset( $aModProps[ 'load_priority' ] ) ? $aModProps[ 'load_priority' ] : 100;
|
88 |
+
add_action( $this->prefix( 'run_processors' ), [ $this, 'onRunProcessors' ], $nRunPriority );
|
89 |
+
add_action( 'init', [ $this, 'onWpInit' ], 1 );
|
90 |
+
add_action( $this->prefix( 'import_options' ), [ $this, 'processImportOptions' ] );
|
91 |
|
92 |
if ( $this->isModuleRequest() ) {
|
93 |
+
add_action( $this->prefix( 'form_submit' ), [ $this, 'handleOptionsSubmit' ] );
|
94 |
+
add_filter( $this->prefix( 'ajaxAction' ), [ $this, 'handleAjax' ] );
|
95 |
+
add_filter( $this->prefix( 'ajaxAuthAction' ), [ $this, 'handleAuthAjax' ] );
|
96 |
+
add_filter( $this->prefix( 'ajaxNonAuthAction' ), [ $this, 'handleNonAuthAjax' ] );
|
97 |
|
98 |
if ( $oReq->request( 'action' ) == $this->prefix()
|
99 |
&& check_admin_referer( $oReq->request( 'exec' ), 'exec_nonce' )
|
100 |
) {
|
101 |
+
add_action( $this->prefix( 'mod_request' ), [ $this, 'handleModRequest' ] );
|
102 |
}
|
103 |
}
|
104 |
|
105 |
$nMenuPri = isset( $aModProps[ 'menu_priority' ] ) ? $aModProps[ 'menu_priority' ] : 100;
|
106 |
+
add_filter( $this->prefix( 'submenu_items' ), [ $this, 'supplySubMenuItem' ], $nMenuPri );
|
107 |
+
add_filter( $this->prefix( 'collect_mod_summary' ), [ $this, 'addModuleSummaryData' ], $nMenuPri );
|
108 |
+
add_filter( $this->prefix( 'collect_notices' ), [ $this, 'addInsightsNoticeData' ] );
|
109 |
+
add_filter( $this->prefix( 'collect_summary' ), [ $this, 'addInsightsConfigData' ], $nRunPriority );
|
110 |
+
add_action( $this->prefix( 'plugin_shutdown' ), [ $this, 'action_doFeatureShutdown' ] );
|
111 |
+
add_action( $this->prefix( 'deactivate_plugin' ), [ $this, 'deactivatePlugin' ] );
|
112 |
+
add_action( $this->prefix( 'delete_plugin' ), [ $this, 'deletePluginOptions' ] );
|
113 |
+
add_filter( $this->prefix( 'aggregate_all_plugin_options' ), [ $this, 'aggregateOptionsValues' ] );
|
114 |
|
115 |
+
add_filter( $this->prefix( 'register_admin_notices' ), [ $this, 'fRegisterAdminNotices' ] );
|
116 |
+
add_filter( $this->prefix( 'gather_options_for_export' ), [ $this, 'exportTransferableOptions' ] );
|
117 |
|
118 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'onWpEnqueueAdminJs' ], 100 );
|
|
|
119 |
|
120 |
// if ( $this->isAdminOptionsPage() ) {
|
121 |
// add_action( 'current_screen', array( $this, 'onSetCurrentScreen' ) );
|
201 |
protected function normaliseAjaxResponse( $aAjaxResponse ) {
|
202 |
if ( !empty( $aAjaxResponse ) ) {
|
203 |
$aAjaxResponse = array_merge(
|
204 |
+
[
|
205 |
'success' => false,
|
206 |
'page_reload' => false,
|
207 |
'message' => 'Unknown',
|
208 |
'html' => '',
|
209 |
+
],
|
210 |
$aAjaxResponse
|
211 |
);
|
212 |
}
|
331 |
|
332 |
// GDPR
|
333 |
if ( $this->isPremium() ) {
|
334 |
+
add_filter( $this->prefix( 'wpPrivacyExport' ), [ $this, 'onWpPrivacyExport' ], 10, 3 );
|
335 |
+
add_filter( $this->prefix( 'wpPrivacyErase' ), [ $this, 'onWpPrivacyErase' ], 10, 3 );
|
336 |
}
|
337 |
}
|
338 |
|
342 |
*/
|
343 |
public function onSetCurrentScreen() {
|
344 |
global $page_hook;
|
345 |
+
add_action( 'load-'.$page_hook, [ $this, 'onLoadOptionsScreen' ] );
|
346 |
}
|
347 |
|
348 |
/**
|
492 |
*/
|
493 |
public function getEmailHandler() {
|
494 |
if ( is_null( self::$oEmailHandler ) ) {
|
495 |
+
self::$oEmailHandler = $this->getCon()->loadFeatureHandler( [ 'slug' => 'email' ] );
|
496 |
}
|
497 |
return self::$oEmailHandler;
|
498 |
}
|
603 |
}
|
604 |
|
605 |
$sMenuPageTitle = $sMenuTitleName.' - '.$sHumanName;
|
606 |
+
$aItems[ $sMenuPageTitle ] = [
|
607 |
$sMenuTitleName,
|
608 |
$this->getModSlug(),
|
609 |
[ $this, 'displayModuleAdminPage' ],
|
610 |
$this->getIfShowModuleMenuItem()
|
611 |
+
];
|
612 |
|
613 |
$aAdditionalItems = $this->getOptionsVo()->getAdditionalMenuItems();
|
614 |
if ( !empty( $aAdditionalItems ) && is_array( $aAdditionalItems ) ) {
|
620 |
}
|
621 |
|
622 |
$sMenuPageTitle = $sHumanName.' - '.$aMenuItem[ 'title' ];
|
623 |
+
$aItems[ $sMenuPageTitle ] = [
|
624 |
$aMenuItem[ 'title' ],
|
625 |
$this->prefix( $aMenuItem[ 'slug' ] ),
|
626 |
+
[ $this, $aMenuItem[ 'callback' ] ]
|
627 |
+
];
|
628 |
}
|
629 |
}
|
630 |
}
|
677 |
$aSections[ $sSlug ] = $this->loadStrings_SectionTitles( $aSection );
|
678 |
}
|
679 |
|
680 |
+
$aSummary = [
|
681 |
'enabled' => $this->isEnabledForUiSummary(),
|
682 |
'active' => $this->isThisModulePage(),
|
683 |
'slug' => $this->getSlug(),
|
685 |
'menu_title' => empty( $sMenuTitle ) ? $this->getMainFeatureName() : $sMenuTitle,
|
686 |
'href' => network_admin_url( 'admin.php?page='.$this->getModSlug() ),
|
687 |
'sections' => $aSections,
|
688 |
+
];
|
689 |
$aSummary[ 'content' ] = $this->renderTemplate( 'snippets/summary_single', $aSummary );
|
690 |
return $aSummary;
|
691 |
}
|
810 |
public function setLastErrors( $mErrors = [] ) {
|
811 |
if ( !is_array( $mErrors ) ) {
|
812 |
if ( is_string( $mErrors ) ) {
|
813 |
+
$mErrors = [ $mErrors ];
|
814 |
}
|
815 |
else {
|
816 |
$mErrors = [];
|
865 |
* @return array
|
866 |
*/
|
867 |
public function getNonceActionData( $sAction = '' ) {
|
868 |
+
return [
|
869 |
'action' => $this->prefix(), //wp ajax doesn't work without this.
|
870 |
'exec' => $sAction,
|
871 |
'exec_nonce' => $this->genNonce( $sAction ),
|
872 |
'mod_slug' => $this->getModSlug(),
|
873 |
+
];
|
874 |
}
|
875 |
|
876 |
/**
|
1073 |
break;
|
1074 |
}
|
1075 |
|
1076 |
+
$aParams = [
|
1077 |
'value' => is_scalar( $mCurrent ) ? esc_attr( $mCurrent ) : $mCurrent,
|
1078 |
'disabled' => !$this->isPremium() && ( isset( $aOptParams[ 'premium' ] ) && $aOptParams[ 'premium' ] ),
|
1079 |
+
];
|
1080 |
$aParams[ 'enabled' ] = !$aParams[ 'disabled' ];
|
1081 |
+
$aOptParams = array_merge( [ 'rows' => 2 ], $aOptParams, $aParams );
|
1082 |
|
1083 |
// add strings
|
1084 |
return $this->loadStrings_Options( $aOptParams );
|
1335 |
}
|
1336 |
|
1337 |
// Prevent overwriting of non-editable fields
|
1338 |
+
if ( !in_array( $sOptType, [ 'noneditable_text' ] ) ) {
|
1339 |
$this->setOpt( $sKey, $sOptionValue );
|
1340 |
}
|
1341 |
}
|
1458 |
$aData = $this->loadDP()
|
1459 |
->mergeArraysRecursive(
|
1460 |
$this->getBaseDisplayData( false ),
|
1461 |
+
[
|
1462 |
+
'ajax' => [
|
1463 |
'restricted_access' => $this->getAjaxActionData( 'restricted_access' )
|
1464 |
+
]
|
1465 |
+
]
|
1466 |
);
|
1467 |
return $this->renderTemplate( 'access_restricted.php', $aData );
|
1468 |
}
|
1474 |
protected function getBaseDisplayData( $bRenderEmbeddedContent = false ) {
|
1475 |
$oCon = $this->getCon();
|
1476 |
|
1477 |
+
$aData = [
|
1478 |
'sPluginName' => $oCon->getHumanName(),
|
1479 |
'sFeatureName' => $this->getMainFeatureName(),
|
1480 |
'bFeatureEnabled' => $this->isModuleEnabled(),
|
1483 |
'form_action' => 'admin.php?page='.$this->getModSlug(),
|
1484 |
'nOptionsPerRow' => 1,
|
1485 |
'aPluginLabels' => $oCon->getLabels(),
|
1486 |
+
'help_video' => [
|
1487 |
'auto_show' => $this->getIfAutoShowHelpVideo(),
|
1488 |
'iframe_url' => $this->getHelpVideoUrl( $this->getHelpVideoId() ),
|
1489 |
'display_id' => 'ShieldHelpVideo'.$this->getSlug(),
|
1492 |
'show' => $this->isHelpVideoDisplayable() && !$this->getHelpVideoHasBeenClosed(),
|
1493 |
'width' => 772,
|
1494 |
'height' => 454,
|
1495 |
+
],
|
1496 |
'aSummaryData' => $this->getModulesSummaryData(),
|
1497 |
|
1498 |
// 'sPageTitle' => sprintf( '%s: %s', $oCon->getHumanName(), $this->getMainFeatureName() ),
|
1499 |
'sPageTitle' => $this->getMainFeatureName(),
|
1500 |
+
'data' => [
|
1501 |
'form_nonce' => $this->genNonce( '' ),
|
1502 |
'mod_slug' => $this->getModSlug( true ),
|
1503 |
'mod_slug_short' => $this->getModSlug( false ),
|
1504 |
'all_options' => $this->buildOptions(),
|
1505 |
'hidden_options' => $this->getOptionsVo()->getHiddenOptions()
|
1506 |
+
],
|
1507 |
+
'ajax' => [
|
1508 |
'mod_options' => $this->getAjaxActionData( 'mod_options' ),
|
1509 |
+
],
|
1510 |
'strings' => $this->getDisplayStrings(),
|
1511 |
+
'flags' => [
|
1512 |
'access_restricted' => !$this->canDisplayOptionsForm(),
|
1513 |
'show_ads' => $this->getIsShowMarketing(),
|
1514 |
'wrap_page_content' => true,
|
1516 |
'show_content_help' => true,
|
1517 |
'show_alt_content' => false,
|
1518 |
'has_wizard' => $this->hasWizard(),
|
1519 |
+
],
|
1520 |
+
'hrefs' => [
|
1521 |
'back_to_dashboard' => $this->getCon()->getModule( 'insights' )->getUrl_AdminPage(),
|
1522 |
'go_pro' => 'https://icwp.io/shieldgoprofeature',
|
1523 |
'goprofooter' => 'https://icwp.io/goprofooter',
|
1524 |
'wizard_link' => $this->getUrl_WizardLanding(),
|
1525 |
'wizard_landing' => $this->getUrl_WizardLanding()
|
1526 |
+
],
|
1527 |
+
'content' => [
|
1528 |
'options_form' => '',
|
1529 |
'alt' => '',
|
1530 |
'actions' => '',
|
1531 |
'help' => '',
|
1532 |
'wizard_landing' => ''
|
1533 |
+
]
|
1534 |
+
];
|
1535 |
|
1536 |
if ( $bRenderEmbeddedContent ) { // prevents recursive loops
|
1537 |
+
$aData[ 'content' ] = [
|
1538 |
'options_form' => 'no form',
|
1539 |
'alt' => '',
|
1540 |
'help' => $this->getContentHelp(),
|
1541 |
'wizard_landing' => $this->getContentWizardLanding()
|
1542 |
+
];
|
1543 |
$aData[ 'flags' ][ 'show_content_help' ] = strpos( $aData[ 'content' ][ 'help' ], 'Error:' ) !== 0;
|
1544 |
}
|
1545 |
return $aData;
|
1549 |
* @return array
|
1550 |
*/
|
1551 |
protected function getDisplayStrings() {
|
1552 |
+
return [
|
1553 |
'go_to_settings' => __( 'Settings' ),
|
1554 |
'on' => __( 'On' ),
|
1555 |
'off' => __( 'Off' ),
|
1561 |
'btn_options' => __( 'Options' ),
|
1562 |
'btn_help' => __( 'Help' ),
|
1563 |
'btn_wizards' => $this->hasWizard() ? __( 'Wizards' ) : __( 'No Wizards' ),
|
1564 |
+
];
|
1565 |
}
|
1566 |
|
1567 |
/**
|
1588 |
}
|
1589 |
$screen = get_current_screen();
|
1590 |
//$screen->remove_help_tabs();
|
1591 |
+
$screen->add_help_tab( [
|
1592 |
'id' => 'my-plugin-default',
|
1593 |
'title' => __( 'Default' ),
|
1594 |
'content' => 'This is where I would provide tabbed help to the user on how everything in my admin panel works. Formatted HTML works fine in here too'
|
1595 |
+
] );
|
1596 |
//add more help tabs as needed with unique id's
|
1597 |
|
1598 |
// Help sidebars are optional
|
1624 |
}
|
1625 |
|
1626 |
return add_query_arg(
|
1627 |
+
[
|
1628 |
'page' => $this->getModSlug(),
|
1629 |
'shield_action' => 'wizard',
|
1630 |
'wizard' => $sWizardSlug,
|
1631 |
'nonwizard' => wp_create_nonce( 'wizard'.$sWizardSlug )
|
1632 |
+
],
|
1633 |
$sUrl
|
1634 |
);
|
1635 |
}
|
1723 |
return $this->getOptionsVo()->isAccessRestricted() ? $this->getCon()->isPluginAdmin() : true;
|
1724 |
}
|
1725 |
|
|
|
|
|
|
|
1726 |
public function onWpEnqueueAdminJs() {
|
1727 |
$this->insertCustomJsVars_Admin();
|
1728 |
}
|
1880 |
protected function getHelpVideoOptions() {
|
1881 |
$aOptions = $this->getOpt( 'help_video_options', [] );
|
1882 |
if ( is_null( $aOptions ) || !is_array( $aOptions ) ) {
|
1883 |
+
$aOptions = [
|
1884 |
'closed' => false,
|
1885 |
'displayed' => false,
|
1886 |
'played' => false,
|
1887 |
+
];
|
1888 |
$this->setOpt( 'help_video_options', $aOptions );
|
1889 |
}
|
1890 |
return $aOptions;
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use FernleafSystems\Wordpress\Services\Services;
|
4 |
|
5 |
class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
@@ -27,7 +28,7 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
* @return
|
31 |
*/
|
32 |
public function getSession() {
|
33 |
$oP = $this->getSessionsProcessor();
|
@@ -60,11 +61,11 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
60 |
$aConfig = [];
|
61 |
}
|
62 |
$aConfig = array_merge(
|
63 |
-
|
64 |
'key' => '',
|
65 |
'secret' => '',
|
66 |
'style' => 'light',
|
67 |
-
|
68 |
$aConfig
|
69 |
);
|
70 |
if ( !$this->isPremium() && $aConfig[ 'style' ] != 'light' ) {
|
@@ -152,11 +153,11 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
152 |
|
153 |
return $this->loadDP()->mergeArraysRecursive(
|
154 |
parent::getBaseDisplayData( $bRenderEmbeddedContent ),
|
155 |
-
|
156 |
-
'ajax' =>
|
157 |
'sec_admin_login' => $this->getSecAdminLoginAjaxData(),
|
158 |
-
|
159 |
-
'strings' =>
|
160 |
'go_to_settings' => _wpsf__( 'Settings' ),
|
161 |
'on' => _wpsf__( 'On' ),
|
162 |
'off' => _wpsf__( 'Off' ),
|
@@ -179,17 +180,17 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
179 |
'aar_enter_access_key' => _wpsf__( 'Enter Access Key' ),
|
180 |
'aar_submit_access_key' => _wpsf__( 'Submit Security Admin Key' ),
|
181 |
'aar_forget_key' => _wpsf__( "Forgotten Key" ),
|
182 |
-
|
183 |
-
'flags' =>
|
184 |
'has_session' => $this->hasSession()
|
185 |
-
|
186 |
-
'hrefs' =>
|
187 |
'aar_forget_key' => $sHelpUrl
|
188 |
-
|
189 |
-
'classes' =>
|
190 |
'top_container' => $this->isPremium() ? 'is-pro' : 'is-not-pro'
|
191 |
-
|
192 |
-
|
193 |
);
|
194 |
}
|
195 |
|
@@ -199,7 +200,7 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
199 |
protected function getDisplayStrings() {
|
200 |
return $this->loadDP()->mergeArraysRecursive(
|
201 |
parent::getDisplayStrings(),
|
202 |
-
|
203 |
'back_to_dashboard' => sprintf( _wpsf__( 'Back To %s Dashboard' ), $this->getCon()->getHumanName() ),
|
204 |
'go_to_settings' => _wpsf__( 'Settings' ),
|
205 |
'on' => _wpsf__( 'On' ),
|
@@ -221,7 +222,7 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
221 |
'aar_enter_access_key' => _wpsf__( 'Enter Access Key' ),
|
222 |
'aar_submit_access_key' => _wpsf__( 'Submit Security Admin Key' ),
|
223 |
'aar_forget_key' => _wpsf__( "Forgotten Key" )
|
224 |
-
|
225 |
);
|
226 |
}
|
227 |
|
@@ -233,10 +234,10 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
233 |
}
|
234 |
|
235 |
protected function getTranslatedString( $sKey, $sDefault ) {
|
236 |
-
$aStrings =
|
237 |
'nonce_failed_empty' => _wpsf__( 'Nonce security checking failed - the nonce value was empty.' ),
|
238 |
'nonce_failed_supplied' => _wpsf__( 'Nonce security checking failed - the nonce supplied was "%s".' ),
|
239 |
-
|
240 |
return ( isset( $aStrings[ $sKey ] ) ? $aStrings[ $sKey ] : $sDefault );
|
241 |
}
|
242 |
|
@@ -364,18 +365,18 @@ class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
|
364 |
case 'section_user_messages' :
|
365 |
$sTitle = _wpsf__( 'User Messages' );
|
366 |
$sTitleShort = _wpsf__( 'User Messages' );
|
367 |
-
$aSummary =
|
368 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Customize the messages displayed to the user.' ) ),
|
369 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use this section if you need to communicate to the user in a particular manner.' ) ),
|
370 |
sprintf( '%s: %s', _wpsf__( 'Hint' ), sprintf( _wpsf__( 'To reset any message to its default, enter the text exactly: %s' ), 'default' ) )
|
371 |
-
|
372 |
break;
|
373 |
|
374 |
default:
|
375 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $aOptionsParams[ 'slug' ] ) );
|
376 |
}
|
377 |
|
378 |
-
return
|
379 |
}
|
380 |
|
381 |
/**
|
1 |
<?php
|
2 |
|
3 |
+
use FernleafSystems\Wordpress\Plugin\Shield;
|
4 |
use FernleafSystems\Wordpress\Services\Services;
|
5 |
|
6 |
class ICWP_WPSF_FeatureHandler_BaseWpsf extends ICWP_WPSF_FeatureHandler_Base {
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* @return Shield\Databases\Session\EntryVO|null
|
32 |
*/
|
33 |
public function getSession() {
|
34 |
$oP = $this->getSessionsProcessor();
|
61 |
$aConfig = [];
|
62 |
}
|
63 |
$aConfig = array_merge(
|
64 |
+
[
|
65 |
'key' => '',
|
66 |
'secret' => '',
|
67 |
'style' => 'light',
|
68 |
+
],
|
69 |
$aConfig
|
70 |
);
|
71 |
if ( !$this->isPremium() && $aConfig[ 'style' ] != 'light' ) {
|
153 |
|
154 |
return $this->loadDP()->mergeArraysRecursive(
|
155 |
parent::getBaseDisplayData( $bRenderEmbeddedContent ),
|
156 |
+
[
|
157 |
+
'ajax' => [
|
158 |
'sec_admin_login' => $this->getSecAdminLoginAjaxData(),
|
159 |
+
],
|
160 |
+
'strings' => [
|
161 |
'go_to_settings' => _wpsf__( 'Settings' ),
|
162 |
'on' => _wpsf__( 'On' ),
|
163 |
'off' => _wpsf__( 'Off' ),
|
180 |
'aar_enter_access_key' => _wpsf__( 'Enter Access Key' ),
|
181 |
'aar_submit_access_key' => _wpsf__( 'Submit Security Admin Key' ),
|
182 |
'aar_forget_key' => _wpsf__( "Forgotten Key" ),
|
183 |
+
],
|
184 |
+
'flags' => [
|
185 |
'has_session' => $this->hasSession()
|
186 |
+
],
|
187 |
+
'hrefs' => [
|
188 |
'aar_forget_key' => $sHelpUrl
|
189 |
+
],
|
190 |
+
'classes' => [
|
191 |
'top_container' => $this->isPremium() ? 'is-pro' : 'is-not-pro'
|
192 |
+
],
|
193 |
+
]
|
194 |
);
|
195 |
}
|
196 |
|
200 |
protected function getDisplayStrings() {
|
201 |
return $this->loadDP()->mergeArraysRecursive(
|
202 |
parent::getDisplayStrings(),
|
203 |
+
[
|
204 |
'back_to_dashboard' => sprintf( _wpsf__( 'Back To %s Dashboard' ), $this->getCon()->getHumanName() ),
|
205 |
'go_to_settings' => _wpsf__( 'Settings' ),
|
206 |
'on' => _wpsf__( 'On' ),
|
222 |
'aar_enter_access_key' => _wpsf__( 'Enter Access Key' ),
|
223 |
'aar_submit_access_key' => _wpsf__( 'Submit Security Admin Key' ),
|
224 |
'aar_forget_key' => _wpsf__( "Forgotten Key" )
|
225 |
+
]
|
226 |
);
|
227 |
}
|
228 |
|
234 |
}
|
235 |
|
236 |
protected function getTranslatedString( $sKey, $sDefault ) {
|
237 |
+
$aStrings = [
|
238 |
'nonce_failed_empty' => _wpsf__( 'Nonce security checking failed - the nonce value was empty.' ),
|
239 |
'nonce_failed_supplied' => _wpsf__( 'Nonce security checking failed - the nonce supplied was "%s".' ),
|
240 |
+
];
|
241 |
return ( isset( $aStrings[ $sKey ] ) ? $aStrings[ $sKey ] : $sDefault );
|
242 |
}
|
243 |
|
365 |
case 'section_user_messages' :
|
366 |
$sTitle = _wpsf__( 'User Messages' );
|
367 |
$sTitleShort = _wpsf__( 'User Messages' );
|
368 |
+
$aSummary = [
|
369 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Customize the messages displayed to the user.' ) ),
|
370 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use this section if you need to communicate to the user in a particular manner.' ) ),
|
371 |
sprintf( '%s: %s', _wpsf__( 'Hint' ), sprintf( _wpsf__( 'To reset any message to its default, enter the text exactly: %s' ), 'default' ) )
|
372 |
+
];
|
373 |
break;
|
374 |
|
375 |
default:
|
376 |
throw new \Exception( sprintf( 'A section slug was defined but with no associated strings. Slug: "%s".', $aOptionsParams[ 'slug' ] ) );
|
377 |
}
|
378 |
|
379 |
+
return [ $sTitle, $sTitleShort, $aSummary ];
|
380 |
}
|
381 |
|
382 |
/**
|
@@ -5,51 +5,50 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
5 |
class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
6 |
|
7 |
/**
|
8 |
-
* @
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
/**
|
13 |
-
*/
|
14 |
-
protected function setupCustomHooks() {
|
15 |
-
add_filter( 'preprocess_comment', array( $this, 'gatherRawCommentData' ), 1 );
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @param array $aRawCommentData
|
20 |
-
* @return array
|
21 |
*/
|
22 |
-
public function
|
23 |
-
$
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* @
|
|
|
29 |
*/
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
* @param string $sKey
|
36 |
-
* @return array|mixed
|
37 |
-
*/
|
38 |
-
public function getCommentItem( $sKey ) {
|
39 |
-
$aD = $this->getCommentData();
|
40 |
-
return isset( $aD[ $sKey ] ) ? $aD[ $sKey ] : null;
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
*
|
|
|
|
|
|
|
45 |
*/
|
46 |
-
public function
|
47 |
-
$
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
&& ( !$oWpComments->getIfAllowCommentsByPreviouslyApproved() || !$oWpComments->isAuthorApproved( $this->getCommentItem( 'comment_author_email' ) ) );
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -84,6 +83,24 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
84 |
return $sStyle;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
/**
|
88 |
* @param string $sOptKey
|
89 |
* @return string
|
@@ -120,12 +137,24 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
120 |
if ( empty( $aCommentsFilters ) || !is_array( $aCommentsFilters ) ) {
|
121 |
$this->getOptionsVo()->resetOptToDefault( 'enable_comments_human_spam_filter_items' );
|
122 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
/**
|
126 |
-
*
|
127 |
*/
|
128 |
-
|
|
|
|
|
129 |
}
|
130 |
|
131 |
/**
|
@@ -133,20 +162,20 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
133 |
* @return array
|
134 |
*/
|
135 |
public function addInsightsConfigData( $aAllData ) {
|
136 |
-
$aThis =
|
137 |
-
'strings' =>
|
138 |
'title' => _wpsf__( 'SPAM Blocking' ),
|
139 |
'sub' => _wpsf__( 'Block Bot & Human Comment SPAM' ),
|
140 |
-
|
141 |
'key_opts' => [],
|
142 |
'href_options' => $this->getUrl_AdminPage()
|
143 |
-
|
144 |
|
145 |
if ( !$this->isModOptEnabled() ) {
|
146 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
147 |
}
|
148 |
else {
|
149 |
-
$aThis[ 'key_opts' ][ 'bot' ] =
|
150 |
'name' => _wpsf__( 'Bot SPAM' ),
|
151 |
'enabled' => $this->isEnabledGaspCheck() || $this->isGoogleRecaptchaEnabled(),
|
152 |
'summary' => ( $this->isEnabledGaspCheck() || $this->isGoogleRecaptchaEnabled() ) ?
|
@@ -154,8 +183,8 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
154 |
: _wpsf__( 'There is no protection against Bot SPAM comments' ),
|
155 |
'weight' => 2,
|
156 |
'href' => $this->getUrl_DirectLinkToSection( 'section_bot_comment_spam_protection_filter' ),
|
157 |
-
|
158 |
-
$aThis[ 'key_opts' ][ 'human' ] =
|
159 |
'name' => _wpsf__( 'Human SPAM' ),
|
160 |
'enabled' => $this->isEnabledHumanCheck(),
|
161 |
'summary' => $this->isEnabledHumanCheck() ?
|
@@ -163,13 +192,36 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
163 |
: _wpsf__( "Comments posted by humans aren't checked for SPAM" ),
|
164 |
'weight' => 1,
|
165 |
'href' => $this->getUrl_DirectLinkToSection( 'section_human_spam_filter' ),
|
166 |
-
|
167 |
}
|
168 |
|
169 |
$aAllData[ $this->getSlug() ] = $aThis;
|
170 |
return $aAllData;
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
/**
|
174 |
* @param array $aOptionsParams
|
175 |
* @return array
|
@@ -182,42 +234,46 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
182 |
|
183 |
case 'section_enable_plugin_feature_spam_comments_protection_filter' :
|
184 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), _wpsf__( 'Comments SPAM Protection' ) );
|
185 |
-
$aSummary =
|
186 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Comments Filter can block 100% of automated spam bots and also offer the option to analyse human-generated spam.' ) ),
|
187 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Comments Filter' ) ) )
|
188 |
-
|
189 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
190 |
break;
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
case 'section_bot_comment_spam_protection_filter' :
|
193 |
$sTitle = sprintf( _wpsf__( '%s Comment SPAM Protection' ), _wpsf__( 'Automatic Bot' ) );
|
194 |
-
$aSummary =
|
195 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Blocks 100% of all automated bot-generated comment SPAM.' ) ),
|
196 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
197 |
-
|
198 |
$sTitleShort = _wpsf__( 'Bot SPAM' );
|
199 |
break;
|
200 |
|
201 |
case 'section_recaptcha' :
|
202 |
$sTitle = 'Google reCAPTCHA';
|
203 |
$sTitleShort = 'reCAPTCHA';
|
204 |
-
$aSummary =
|
205 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Adds Google reCAPTCHA to the Comment Forms.' ) ),
|
206 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this turned on.' ) ),
|
207 |
-
|
208 |
-
_wpsf__( "You'll need to supply your Google reCAPTCHA keys." ),
|
209 |
-
sprintf( '<a href="%s" target="_blank">%s</a>', $oPlugin->getUrl_DirectLinkToSection( 'section_third_party_google' ), _wpsf__( "Enter Google reCAPTCHA keys" ) )
|
210 |
-
),
|
211 |
-
);
|
212 |
break;
|
213 |
|
214 |
case 'section_human_spam_filter' :
|
215 |
$sTitle = sprintf( _wpsf__( '%s Comment SPAM Protection Filter' ), _wpsf__( 'Human' ) );
|
216 |
-
$aSummary =
|
217 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Uses a 3rd party SPAM dictionary to detect human-based comment SPAM.' ) ),
|
218 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
219 |
_wpsf__( 'This tool, unlike other SPAM tools such as Akismet, will not send your comment data to 3rd party services for analysis.' )
|
220 |
-
|
221 |
$sTitleShort = _wpsf__( 'Human SPAM' );
|
222 |
break;
|
223 |
|
@@ -276,6 +332,23 @@ class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_B
|
|
276 |
$sDescription = sprintf( _wpsf__( 'Un-Checking this option will completely disable the %s module.' ), _wpsf__( 'Comment SPAM Protection' ) );
|
277 |
break;
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
case 'enable_comments_human_spam_filter' :
|
280 |
$sName = _wpsf__( 'Human SPAM Filter' );
|
281 |
$sSummary = sprintf( _wpsf__( 'Enable (or Disable) The %s Feature' ), _wpsf__( 'Human SPAM Filter' ) );
|
5 |
class ICWP_WPSF_FeatureHandler_CommentsFilter extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
6 |
|
7 |
/**
|
8 |
+
* @param int $nPostId
|
9 |
+
* @param string $sCommentEmail
|
10 |
+
* @return bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
*/
|
12 |
+
public function getIfDoCommentsCheck( $nPostId, $sCommentEmail ) {
|
13 |
+
$oWpComm = $this->loadWpComments();
|
14 |
+
|
15 |
+
$oPost = Services::WpPost()->getById( $nPostId );
|
16 |
+
return ( $oPost instanceof WP_Post ) && $oWpComm->isCommentsOpen( $oPost )
|
17 |
+
&& !$this->isTrustedCommenter( $sCommentEmail );
|
18 |
+
// Removed 20190425 - v7.4 Compatibility with shoutbox WP Wall Plugin http://wordpress.org/plugins/wp-wall/
|
19 |
+
// && !( function_exists( 'WPWall_Init' ) && !is_null( Services::Request()->post( 'submit_wall_post' ) ) );
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* @param string $sCommentEmail
|
24 |
+
* @return bool
|
25 |
*/
|
26 |
+
private function isTrustedCommenter( $sCommentEmail ) {
|
27 |
+
$bTrusted = $this->loadWpComments()->countApproved( $sCommentEmail ) >= $this->getApprovedMinimum();
|
28 |
+
|
29 |
+
$aTrustedRoles = $this->getTrustedRoles();
|
30 |
+
if ( !$bTrusted && !empty( $aTrustedRoles ) ) {
|
31 |
+
$oUser = Services::WpUsers()->getUserByEmail( $sCommentEmail );
|
32 |
+
if ( $oUser instanceof \WP_User ) {
|
33 |
+
$bTrusted = count( array_intersect( $aTrustedRoles, array_map( 'strtolower', $oUser->roles ) ) ) > 0;
|
34 |
+
}
|
35 |
+
}
|
36 |
|
37 |
+
return $bTrusted;
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* This is the same as isTrustedCommenter() except with an optimization in the order of the tests
|
42 |
+
* since we already have a User object loaded and testing roles is quicker than querying for approved comments
|
43 |
+
* @param \WP_User $oUser
|
44 |
+
* @return bool
|
45 |
*/
|
46 |
+
public function isUserTrusted( $oUser ) {
|
47 |
+
return ( $oUser instanceof \WP_User )
|
48 |
+
&& (
|
49 |
+
count( array_intersect( $this->getTrustedRoles(), array_map( 'strtolower', $oUser->roles ) ) ) > 0
|
50 |
+
|| $this->loadWpComments()->countApproved( $oUser->user_email ) >= $this->getApprovedMinimum()
|
51 |
+
);
|
|
|
52 |
}
|
53 |
|
54 |
/**
|
83 |
return $sStyle;
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* @return bool
|
88 |
+
*/
|
89 |
+
public function getApprovedMinimum() {
|
90 |
+
return $this->getOpt( 'trusted_commenter_minimum', 1 );
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @return string[]
|
95 |
+
*/
|
96 |
+
public function getTrustedRoles() {
|
97 |
+
$aRoles = [];
|
98 |
+
if ( $this->isPremium() ) {
|
99 |
+
$aRoles = $this->getOpt( 'trusted_user_roles', [] );
|
100 |
+
}
|
101 |
+
return is_array( $aRoles ) ? $aRoles : [];
|
102 |
+
}
|
103 |
+
|
104 |
/**
|
105 |
* @param string $sOptKey
|
106 |
* @return string
|
137 |
if ( empty( $aCommentsFilters ) || !is_array( $aCommentsFilters ) ) {
|
138 |
$this->getOptionsVo()->resetOptToDefault( 'enable_comments_human_spam_filter_items' );
|
139 |
}
|
140 |
+
|
141 |
+
// clean roles
|
142 |
+
$this->setOpt( 'trusted_user_roles',
|
143 |
+
array_unique( array_filter( array_map(
|
144 |
+
function ( $sRole ) {
|
145 |
+
return preg_replace( '#[^\sa-z0-9_-]#i', '', trim( strtolower( $sRole ) ) );
|
146 |
+
},
|
147 |
+
$this->getTrustedRoles()
|
148 |
+
) ) )
|
149 |
+
);
|
150 |
}
|
151 |
|
152 |
/**
|
153 |
+
* @return string[]
|
154 |
*/
|
155 |
+
public function getHumanSpamFilterItems() {
|
156 |
+
$aItems = $this->getOpt( 'enable_comments_human_spam_filter_items' );
|
157 |
+
return is_array( $aItems ) ? $aItems : [];
|
158 |
}
|
159 |
|
160 |
/**
|
162 |
* @return array
|
163 |
*/
|
164 |
public function addInsightsConfigData( $aAllData ) {
|
165 |
+
$aThis = [
|
166 |
+
'strings' => [
|
167 |
'title' => _wpsf__( 'SPAM Blocking' ),
|
168 |
'sub' => _wpsf__( 'Block Bot & Human Comment SPAM' ),
|
169 |
+
],
|
170 |
'key_opts' => [],
|
171 |
'href_options' => $this->getUrl_AdminPage()
|
172 |
+
];
|
173 |
|
174 |
if ( !$this->isModOptEnabled() ) {
|
175 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
176 |
}
|
177 |
else {
|
178 |
+
$aThis[ 'key_opts' ][ 'bot' ] = [
|
179 |
'name' => _wpsf__( 'Bot SPAM' ),
|
180 |
'enabled' => $this->isEnabledGaspCheck() || $this->isGoogleRecaptchaEnabled(),
|
181 |
'summary' => ( $this->isEnabledGaspCheck() || $this->isGoogleRecaptchaEnabled() ) ?
|
183 |
: _wpsf__( 'There is no protection against Bot SPAM comments' ),
|
184 |
'weight' => 2,
|
185 |
'href' => $this->getUrl_DirectLinkToSection( 'section_bot_comment_spam_protection_filter' ),
|
186 |
+
];
|
187 |
+
$aThis[ 'key_opts' ][ 'human' ] = [
|
188 |
'name' => _wpsf__( 'Human SPAM' ),
|
189 |
'enabled' => $this->isEnabledHumanCheck(),
|
190 |
'summary' => $this->isEnabledHumanCheck() ?
|
192 |
: _wpsf__( "Comments posted by humans aren't checked for SPAM" ),
|
193 |
'weight' => 1,
|
194 |
'href' => $this->getUrl_DirectLinkToSection( 'section_human_spam_filter' ),
|
195 |
+
];
|
196 |
}
|
197 |
|
198 |
$aAllData[ $this->getSlug() ] = $aThis;
|
199 |
return $aAllData;
|
200 |
}
|
201 |
|
202 |
+
/**
|
203 |
+
* @param string $sSection
|
204 |
+
* @return array
|
205 |
+
*/
|
206 |
+
protected function getSectionWarnings( $sSection ) {
|
207 |
+
$aWarnings = [];
|
208 |
+
|
209 |
+
switch ( $sSection ) {
|
210 |
+
case 'section_recaptcha':
|
211 |
+
/** @var ICWP_WPSF_FeatureHandler_Plugin $oP */
|
212 |
+
$oP = $this->getCon()->getModule( 'plugin' );
|
213 |
+
if ( !$oP->isGoogleRecaptchaReady() ) {
|
214 |
+
$aWarnings[] = sprintf(
|
215 |
+
_wpsf__( 'Please remember to supply reCAPTCHA keys: %s' ),
|
216 |
+
sprintf( '<a href="%s" target="_blank">%s</a>', $oP->getUrl_DirectLinkToSection( 'section_third_party_google' ), __( 'reCAPTCHA Settings' ) )
|
217 |
+
);
|
218 |
+
}
|
219 |
+
break;
|
220 |
+
}
|
221 |
+
|
222 |
+
return $aWarnings;
|
223 |
+
}
|
224 |
+
|
225 |
/**
|
226 |
* @param array $aOptionsParams
|
227 |
* @return array
|
234 |
|
235 |
case 'section_enable_plugin_feature_spam_comments_protection_filter' :
|
236 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), _wpsf__( 'Comments SPAM Protection' ) );
|
237 |
+
$aSummary = [
|
238 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Comments Filter can block 100% of automated spam bots and also offer the option to analyse human-generated spam.' ) ),
|
239 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Comments Filter' ) ) )
|
240 |
+
];
|
241 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
242 |
break;
|
243 |
|
244 |
+
case 'section_bot_comment_spam_common' :
|
245 |
+
$sTitleShort = _wpsf__( 'Common Settings' );
|
246 |
+
$sTitle = _wpsf__( 'Common Settings For All SPAM Scanning' );
|
247 |
+
$aSummary = [
|
248 |
+
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Settings that apply to all comment SPAM scanning.' ) ),
|
249 |
+
];
|
250 |
+
break;
|
251 |
+
|
252 |
case 'section_bot_comment_spam_protection_filter' :
|
253 |
$sTitle = sprintf( _wpsf__( '%s Comment SPAM Protection' ), _wpsf__( 'Automatic Bot' ) );
|
254 |
+
$aSummary = [
|
255 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Blocks 100% of all automated bot-generated comment SPAM.' ) ),
|
256 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
257 |
+
];
|
258 |
$sTitleShort = _wpsf__( 'Bot SPAM' );
|
259 |
break;
|
260 |
|
261 |
case 'section_recaptcha' :
|
262 |
$sTitle = 'Google reCAPTCHA';
|
263 |
$sTitleShort = 'reCAPTCHA';
|
264 |
+
$aSummary = [
|
265 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Adds Google reCAPTCHA to the Comment Forms.' ) ),
|
266 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this turned on.' ) ),
|
267 |
+
];
|
|
|
|
|
|
|
|
|
268 |
break;
|
269 |
|
270 |
case 'section_human_spam_filter' :
|
271 |
$sTitle = sprintf( _wpsf__( '%s Comment SPAM Protection Filter' ), _wpsf__( 'Human' ) );
|
272 |
+
$aSummary = [
|
273 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Uses a 3rd party SPAM dictionary to detect human-based comment SPAM.' ) ),
|
274 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
275 |
_wpsf__( 'This tool, unlike other SPAM tools such as Akismet, will not send your comment data to 3rd party services for analysis.' )
|
276 |
+
];
|
277 |
$sTitleShort = _wpsf__( 'Human SPAM' );
|
278 |
break;
|
279 |
|
332 |
$sDescription = sprintf( _wpsf__( 'Un-Checking this option will completely disable the %s module.' ), _wpsf__( 'Comment SPAM Protection' ) );
|
333 |
break;
|
334 |
|
335 |
+
case 'trusted_commenter_minimum' :
|
336 |
+
$sName = _wpsf__( 'Trusted Commenter Minimum' );
|
337 |
+
$sSummary = _wpsf__( 'Minimum Number Of Approved Comments Before Commenter Is Trusted' );
|
338 |
+
$sDescription = _wpsf__( 'Specify how many approved comments must exist before a commenter is trusted and their comments are no longer scanned.' )
|
339 |
+
.'<br />'._wpsf__( 'Normally WordPress will trust after 1 comment.' );
|
340 |
+
break;
|
341 |
+
|
342 |
+
case 'trusted_user_roles' :
|
343 |
+
$sName = _wpsf__( 'Trusted Users' );
|
344 |
+
$sSummary = _wpsf__( "Comments By Users With The Following Roles Will Never Be Scanned" );
|
345 |
+
$sDescription = _wpsf__( "Shield doesn't normally scan comments from logged-in or registered users." )
|
346 |
+
.'<br />'._wpsf__( "Specify user roles here that shouldn't be scanned." )
|
347 |
+
.'<br/>'.sprintf( '%s: %s', _wpsf__( 'Important' ), _wpsf__( 'Take a new line for each user role.' ) )
|
348 |
+
.'<br/>'.sprintf( '%s: %s', _wpsf__( 'Available Roles' ), implode( ', ', Services::WpUsers()
|
349 |
+
->getAvailableUserRoles() ) );
|
350 |
+
break;
|
351 |
+
|
352 |
case 'enable_comments_human_spam_filter' :
|
353 |
$sName = _wpsf__( 'Human SPAM Filter' );
|
354 |
$sSummary = sprintf( _wpsf__( 'Enable (or Disable) The %s Feature' ), _wpsf__( 'Human SPAM Filter' ) );
|
@@ -79,20 +79,20 @@ class ICWP_WPSF_FeatureHandler_Firewall extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
79 |
* @return array
|
80 |
*/
|
81 |
public function addInsightsConfigData( $aAllData ) {
|
82 |
-
$aThis =
|
83 |
-
'strings' =>
|
84 |
'title' => _wpsf__( 'Firewall' ),
|
85 |
'sub' => _wpsf__( 'Block Malicious Requests' ),
|
86 |
-
|
87 |
'key_opts' => [],
|
88 |
'href_options' => $this->getUrl_AdminPage()
|
89 |
-
|
90 |
|
91 |
if ( !$this->isModOptEnabled() ) {
|
92 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
93 |
}
|
94 |
else {
|
95 |
-
$aThis[ 'key_opts' ][ 'mod' ] =
|
96 |
'name' => _wpsf__( 'Firewall' ),
|
97 |
'enabled' => $this->isModOptEnabled(),
|
98 |
'summary' => $this->isModOptEnabled() ?
|
@@ -100,11 +100,11 @@ class ICWP_WPSF_FeatureHandler_Firewall extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
100 |
: _wpsf__( 'Your site is not protected against malicious requests' ),
|
101 |
'weight' => 2,
|
102 |
'href' => $this->getUrl_DirectLinkToOption( $this->getEnableModOptKey() ),
|
103 |
-
|
104 |
|
105 |
//ignoring admin isn't a good idea
|
106 |
$bAdminIncluded = !$this->isIgnoreAdmin();
|
107 |
-
$aThis[ 'key_opts' ][ 'admin' ] =
|
108 |
'name' => _wpsf__( 'Ignore Admins' ),
|
109 |
'enabled' => $bAdminIncluded,
|
110 |
'summary' => $bAdminIncluded ?
|
@@ -112,7 +112,7 @@ class ICWP_WPSF_FeatureHandler_Firewall extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
112 |
: _wpsf__( "Firewall rules aren't applied to admins" ),
|
113 |
'weight' => 1,
|
114 |
'href' => $this->getUrl_DirectLinkToOption( 'whitelist_admins' ),
|
115 |
-
|
116 |
}
|
117 |
|
118 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -130,39 +130,39 @@ class ICWP_WPSF_FeatureHandler_Firewall extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
130 |
|
131 |
case 'section_enable_plugin_feature_wordpress_firewall' :
|
132 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
133 |
-
$aSummary =
|
134 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Firewall is designed to analyse data sent to your website and block any requests that appear to be malicious.' ) ),
|
135 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Firewall' ) ) )
|
136 |
-
|
137 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
138 |
break;
|
139 |
|
140 |
case 'section_firewall_blocking_options' :
|
141 |
$sTitle = _wpsf__( 'Firewall Blocking Options' );
|
142 |
-
$aSummary =
|
143 |
_wpsf__( 'Here you choose what kind of malicious data to scan for.' ),
|
144 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ),
|
145 |
_wpsf__( 'Turn on as many options here as you can.' ) )
|
146 |
.' '._wpsf__( 'If you find an incompatibility or something stops working, un-check 1 option at a time until you find the problem or review the Audit Trail.' ),
|
147 |
-
|
148 |
$sTitleShort = _wpsf__( 'Firewall Blocking' );
|
149 |
break;
|
150 |
|
151 |
case 'section_choose_firewall_block_response' :
|
152 |
$sTitle = _wpsf__( 'Choose Firewall Block Response' );
|
153 |
-
$aSummary =
|
154 |
_wpsf__( 'Here you choose how the plugin will respond when it detects malicious data.' ),
|
155 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Choose the option "%s".' ), _wpsf__( 'Die With Message' ) ) )
|
156 |
-
|
157 |
$sTitleShort = _wpsf__( 'Firewall Response' );
|
158 |
break;
|
159 |
|
160 |
case 'section_whitelist' :
|
161 |
$sTitle = _wpsf__( 'Whitelists - Pages, Parameters, and Users that by-pass the Firewall' );
|
162 |
-
$aSummary =
|
163 |
_wpsf__( 'In principle you should not need to whitelist anything or anyone unless you have discovered a collision with another plugin.' ),
|
164 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Do not whitelist anything unless you are confident in what you are doing.' ) )
|
165 |
-
|
166 |
$sTitleShort = _wpsf__( 'Whitelist' );
|
167 |
break;
|
168 |
|
79 |
* @return array
|
80 |
*/
|
81 |
public function addInsightsConfigData( $aAllData ) {
|
82 |
+
$aThis = [
|
83 |
+
'strings' => [
|
84 |
'title' => _wpsf__( 'Firewall' ),
|
85 |
'sub' => _wpsf__( 'Block Malicious Requests' ),
|
86 |
+
],
|
87 |
'key_opts' => [],
|
88 |
'href_options' => $this->getUrl_AdminPage()
|
89 |
+
];
|
90 |
|
91 |
if ( !$this->isModOptEnabled() ) {
|
92 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
93 |
}
|
94 |
else {
|
95 |
+
$aThis[ 'key_opts' ][ 'mod' ] = [
|
96 |
'name' => _wpsf__( 'Firewall' ),
|
97 |
'enabled' => $this->isModOptEnabled(),
|
98 |
'summary' => $this->isModOptEnabled() ?
|
100 |
: _wpsf__( 'Your site is not protected against malicious requests' ),
|
101 |
'weight' => 2,
|
102 |
'href' => $this->getUrl_DirectLinkToOption( $this->getEnableModOptKey() ),
|
103 |
+
];
|
104 |
|
105 |
//ignoring admin isn't a good idea
|
106 |
$bAdminIncluded = !$this->isIgnoreAdmin();
|
107 |
+
$aThis[ 'key_opts' ][ 'admin' ] = [
|
108 |
'name' => _wpsf__( 'Ignore Admins' ),
|
109 |
'enabled' => $bAdminIncluded,
|
110 |
'summary' => $bAdminIncluded ?
|
112 |
: _wpsf__( "Firewall rules aren't applied to admins" ),
|
113 |
'weight' => 1,
|
114 |
'href' => $this->getUrl_DirectLinkToOption( 'whitelist_admins' ),
|
115 |
+
];
|
116 |
}
|
117 |
|
118 |
$aAllData[ $this->getSlug() ] = $aThis;
|
130 |
|
131 |
case 'section_enable_plugin_feature_wordpress_firewall' :
|
132 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
133 |
+
$aSummary = [
|
134 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Firewall is designed to analyse data sent to your website and block any requests that appear to be malicious.' ) ),
|
135 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Firewall' ) ) )
|
136 |
+
];
|
137 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
138 |
break;
|
139 |
|
140 |
case 'section_firewall_blocking_options' :
|
141 |
$sTitle = _wpsf__( 'Firewall Blocking Options' );
|
142 |
+
$aSummary = [
|
143 |
_wpsf__( 'Here you choose what kind of malicious data to scan for.' ),
|
144 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ),
|
145 |
_wpsf__( 'Turn on as many options here as you can.' ) )
|
146 |
.' '._wpsf__( 'If you find an incompatibility or something stops working, un-check 1 option at a time until you find the problem or review the Audit Trail.' ),
|
147 |
+
];
|
148 |
$sTitleShort = _wpsf__( 'Firewall Blocking' );
|
149 |
break;
|
150 |
|
151 |
case 'section_choose_firewall_block_response' :
|
152 |
$sTitle = _wpsf__( 'Choose Firewall Block Response' );
|
153 |
+
$aSummary = [
|
154 |
_wpsf__( 'Here you choose how the plugin will respond when it detects malicious data.' ),
|
155 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Choose the option "%s".' ), _wpsf__( 'Die With Message' ) ) )
|
156 |
+
];
|
157 |
$sTitleShort = _wpsf__( 'Firewall Response' );
|
158 |
break;
|
159 |
|
160 |
case 'section_whitelist' :
|
161 |
$sTitle = _wpsf__( 'Whitelists - Pages, Parameters, and Users that by-pass the Firewall' );
|
162 |
+
$aSummary = [
|
163 |
_wpsf__( 'In principle you should not need to whitelist anything or anyone unless you have discovered a collision with another plugin.' ),
|
164 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Do not whitelist anything unless you are confident in what you are doing.' ) )
|
165 |
+
];
|
166 |
$sTitleShort = _wpsf__( 'Whitelist' );
|
167 |
break;
|
168 |
|
@@ -12,9 +12,8 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
12 |
/**
|
13 |
*/
|
14 |
protected function updateHandler() {
|
15 |
-
$this->
|
16 |
// ->setPtgRebuildSelfRequired( true ) // this is permanently required until a better solution is found
|
17 |
-
->setPtgUpdateStoreFormat( true );
|
18 |
}
|
19 |
|
20 |
/**
|
@@ -77,7 +76,7 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* @param
|
81 |
* @return string
|
82 |
*/
|
83 |
public function createFileDownloadLink( $oEntryVo ) {
|
@@ -115,7 +114,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
115 |
*/
|
116 |
protected function doExtraSubmitProcessing() {
|
117 |
$this->clearIcSnapshots();
|
118 |
-
$this->clearCrons();
|
119 |
$this->cleanFileExclusions();
|
120 |
$this->cleanPtgFileExtensions();
|
121 |
|
@@ -128,24 +126,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
128 |
$this->resetRtBackupFiles();
|
129 |
}
|
130 |
|
131 |
-
/**
|
132 |
-
* @return $this
|
133 |
-
*/
|
134 |
-
protected function clearCrons() {
|
135 |
-
$aCrons = array(
|
136 |
-
$this->getIcCronName(),
|
137 |
-
$this->getUfcCronName(),
|
138 |
-
$this->getWcfCronName(),
|
139 |
-
$this->getWpvCronName(),
|
140 |
-
$this->getPtgCronName()
|
141 |
-
);
|
142 |
-
$oCron = $this->loadWpCronProcessor();
|
143 |
-
foreach ( $aCrons as $sCron ) {
|
144 |
-
$oCron->deleteCronJob( $sCron );
|
145 |
-
}
|
146 |
-
return $this;
|
147 |
-
}
|
148 |
-
|
149 |
/**
|
150 |
* @param string $sScan ptg, wcf, ufc, wpv
|
151 |
* @return int
|
@@ -169,7 +149,7 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
169 |
public function getScanHasProblem( $sScan ) {
|
170 |
/** @var ICWP_WPSF_Processor_HackProtect $oPro */
|
171 |
$oPro = $this->getProcessor();
|
172 |
-
/** @var
|
173 |
$oSel = $oPro->getSubProScanner()
|
174 |
->getDbHandler()
|
175 |
->getQuerySelector();
|
@@ -224,10 +204,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
224 |
$this->loadWpCronProcessor()
|
225 |
->addNewSchedule(
|
226 |
$this->prefix( sprintf( 'per-day-%s', $nFreq ) ),
|
227 |
-
|
228 |
'interval' => DAY_IN_SECONDS/$nFreq,
|
229 |
'display' => sprintf( _wpsf__( '%s per day' ), $nFreq )
|
230 |
-
|
231 |
);
|
232 |
return $this;
|
233 |
}
|
@@ -253,13 +233,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
253 |
return $this->isOpt( 'ic_users', 'Y' );
|
254 |
}
|
255 |
|
256 |
-
/**
|
257 |
-
* @return string
|
258 |
-
*/
|
259 |
-
public function getIcCronName() {
|
260 |
-
return $this->prefix( $this->getDef( 'cron_name_integrity_check' ) );
|
261 |
-
}
|
262 |
-
|
263 |
/**
|
264 |
* @param array[] $aUsers
|
265 |
* @return $this
|
@@ -275,13 +248,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
275 |
return $this->getOpt( 'enable_unrecognised_file_cleaner_scan', 'disabled' );
|
276 |
}
|
277 |
|
278 |
-
/**
|
279 |
-
* @return string
|
280 |
-
*/
|
281 |
-
public function getUfcCronName() {
|
282 |
-
return $this->prefix( $this->getDef( 'cron_scan_ufc' ) );
|
283 |
-
}
|
284 |
-
|
285 |
/**
|
286 |
* @return array
|
287 |
*/
|
@@ -341,10 +307,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
341 |
* @return string
|
342 |
*/
|
343 |
public function isUfcDeleteFiles() {
|
344 |
-
return in_array( $this->getUnrecognisedFileScannerOption(),
|
345 |
'enabled_delete_only',
|
346 |
'enabled_delete_report'
|
347 |
-
|
348 |
}
|
349 |
|
350 |
/**
|
@@ -365,17 +331,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
365 |
* @return string
|
366 |
*/
|
367 |
public function isUfcSendReport() {
|
368 |
-
return in_array( $this->getUnrecognisedFileScannerOption(),
|
369 |
'enabled_report_only',
|
370 |
'enabled_delete_report'
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
/**
|
375 |
-
* @return string
|
376 |
-
*/
|
377 |
-
public function getWcfCronName() {
|
378 |
-
return $this->prefix( $this->getDef( 'cron_scan_wcf' ) );
|
379 |
}
|
380 |
|
381 |
/**
|
@@ -415,13 +374,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
415 |
return $this->isPremium() && !$this->isOpt( 'enable_wpvuln_scan', 'disabled' );
|
416 |
}
|
417 |
|
418 |
-
/**
|
419 |
-
* @return string
|
420 |
-
*/
|
421 |
-
public function getWpvCronName() {
|
422 |
-
return $this->prefix( $this->getDef( 'cron_scan_wpv' ) );
|
423 |
-
}
|
424 |
-
|
425 |
/**
|
426 |
* @return bool
|
427 |
*/
|
@@ -489,13 +441,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
489 |
);
|
490 |
}
|
491 |
|
492 |
-
/**
|
493 |
-
* @return bool
|
494 |
-
*/
|
495 |
-
public function getPtgCronName() {
|
496 |
-
return $this->prefix( $this->getDef( 'cron_scan_ptg' ) );
|
497 |
-
}
|
498 |
-
|
499 |
/**
|
500 |
* @return string[]
|
501 |
*/
|
@@ -627,6 +572,27 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
627 |
return $this->isOpt( 'enabled_scan_apc', 'enabled_email' );
|
628 |
}
|
629 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
630 |
public function insertCustomJsVars_Admin() {
|
631 |
parent::insertCustomJsVars_Admin();
|
632 |
|
@@ -634,10 +600,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
634 |
wp_localize_script(
|
635 |
$this->prefix( 'global-plugin' ),
|
636 |
'icwp_wpsf_vars_hp',
|
637 |
-
|
638 |
'ajax_plugin_reinstall' => $this->getAjaxActionData( 'plugin_reinstall' ),
|
639 |
'reinstallable' => Services::WpPlugins()->getInstalledWpOrgPluginFiles()
|
640 |
-
|
641 |
);
|
642 |
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
|
643 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
@@ -668,6 +634,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
668 |
$nTime = $this->getLastScanAt( 'wpv' );
|
669 |
break;
|
670 |
|
|
|
|
|
|
|
|
|
671 |
default:
|
672 |
$nTime = null;
|
673 |
break;
|
@@ -691,6 +661,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
691 |
$oTableBuilder = new Shield\Tables\Build\ScanApc();
|
692 |
break;
|
693 |
|
|
|
|
|
|
|
|
|
694 |
case 'wcf':
|
695 |
$oTableBuilder = new Shield\Tables\Build\ScanWcf();
|
696 |
break;
|
@@ -723,12 +697,15 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
723 |
->buildTable();
|
724 |
}
|
725 |
|
726 |
-
return
|
727 |
'success' => !empty( $oTableBuilder ),
|
728 |
'html' => $sHtml
|
729 |
-
|
730 |
}
|
731 |
|
|
|
|
|
|
|
732 |
private function ajaxExec_StartScans() {
|
733 |
$bSuccess = false;
|
734 |
$bPageReload = false;
|
@@ -787,7 +764,7 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
787 |
}
|
788 |
else {
|
789 |
if ( empty( $aItemIds ) ) {
|
790 |
-
$aItemIds =
|
791 |
}
|
792 |
|
793 |
try {
|
@@ -799,8 +776,6 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
799 |
}
|
800 |
}
|
801 |
|
802 |
-
$bSuccess = true;
|
803 |
-
|
804 |
if ( count( $aSuccessfulItems ) === count( $aItemIds ) ) {
|
805 |
$bSuccess = true;
|
806 |
$sMessage = 'Successfully completed. Re-scanning and reloading ...';
|
@@ -815,11 +790,11 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
815 |
}
|
816 |
}
|
817 |
|
818 |
-
return
|
819 |
'success' => $bSuccess,
|
820 |
'page_reload' => in_array( $sScannerSlug, [ 'apc', 'ptg' ] ),
|
821 |
'message' => $sMessage,
|
822 |
-
|
823 |
}
|
824 |
|
825 |
/**
|
@@ -834,6 +809,9 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
834 |
case 'apc':
|
835 |
$oScannerPro = $oScanPro->getSubProcessorApc();
|
836 |
break;
|
|
|
|
|
|
|
837 |
case 'ptg':
|
838 |
$oScannerPro = $oScanPro->getSubProcessorPtg();
|
839 |
break;
|
@@ -1049,113 +1027,113 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1049 |
* @return array
|
1050 |
*/
|
1051 |
public function addInsightsNoticeData( $aAllNotices ) {
|
1052 |
-
$aNotices =
|
1053 |
'title' => _wpsf__( 'Scans' ),
|
1054 |
'messages' => []
|
1055 |
-
|
1056 |
|
1057 |
{// Core files
|
1058 |
if ( !$this->isWcfScanEnabled() ) {
|
1059 |
-
$aNotices[ 'messages' ][ 'wcf' ] =
|
1060 |
'title' => 'WP Core Files',
|
1061 |
'message' => _wpsf__( 'Core File scanner is not enabled.' ),
|
1062 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1063 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1064 |
'rec' => _wpsf__( 'Automatic WordPress Core File scanner should be turned-on.' )
|
1065 |
-
|
1066 |
}
|
1067 |
else if ( $this->getScanHasProblem( 'wcf' ) ) {
|
1068 |
-
$aNotices[ 'messages' ][ 'wcf' ] =
|
1069 |
'title' => 'WP Core Files',
|
1070 |
'message' => _wpsf__( 'Modified WordPress core files found.' ),
|
1071 |
'href' => $this->getUrlManualScan(),
|
1072 |
'action' => _wpsf__( 'Run Scan' ),
|
1073 |
'rec' => _wpsf__( 'Scan WP core files and repair any files that are flagged as modified.' )
|
1074 |
-
|
1075 |
}
|
1076 |
}
|
1077 |
|
1078 |
{// Unrecognised
|
1079 |
if ( !$this->isUfcEnabled() ) {
|
1080 |
-
$aNotices[ 'messages' ][ 'ufc' ] =
|
1081 |
'title' => 'Unrecognised Files',
|
1082 |
'message' => _wpsf__( 'Unrecognised File scanner is not enabled.' ),
|
1083 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1084 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1085 |
'rec' => _wpsf__( 'Automatic scanning for non-WordPress core files is recommended.' )
|
1086 |
-
|
1087 |
}
|
1088 |
else if ( $this->getScanHasProblem( 'ufc' ) ) {
|
1089 |
-
$aNotices[ 'messages' ][ 'ufc' ] =
|
1090 |
'title' => 'Unrecognised Files',
|
1091 |
'message' => _wpsf__( 'Unrecognised files found in WordPress Core directory.' ),
|
1092 |
'href' => $this->getUrlManualScan(),
|
1093 |
'action' => _wpsf__( 'Run Scan' ),
|
1094 |
'rec' => _wpsf__( 'Scan and remove any files that are not meant to be in the WP core directories.' )
|
1095 |
-
|
1096 |
}
|
1097 |
}
|
1098 |
|
1099 |
{// Plugin/Theme Guard
|
1100 |
if ( !$this->isPtgEnabled() ) {
|
1101 |
-
$aNotices[ 'messages' ][ 'ptg' ] =
|
1102 |
'title' => 'Plugin/Theme Guard',
|
1103 |
'message' => _wpsf__( 'Automatic Plugin/Themes Guard is not enabled.' ),
|
1104 |
'href' => $this->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
1105 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1106 |
'rec' => _wpsf__( 'Automatic detection of plugin/theme modifications is recommended.' )
|
1107 |
-
|
1108 |
}
|
1109 |
else if ( $this->getScanHasProblem( 'ptg' ) ) {
|
1110 |
-
$aNotices[ 'messages' ][ 'ptg' ] =
|
1111 |
'title' => 'Plugin/Theme Guard',
|
1112 |
'message' => _wpsf__( 'A plugin/theme was found to have been modified.' ),
|
1113 |
'href' => $this->getUrlManualScan(),
|
1114 |
'action' => _wpsf__( 'Run Scan' ),
|
1115 |
'rec' => _wpsf__( 'Reviewing modifications to your plugins/themes is recommended.' )
|
1116 |
-
|
1117 |
}
|
1118 |
}
|
1119 |
|
1120 |
{// Vulnerability Scanner
|
1121 |
if ( !$this->isWpvulnEnabled() ) {
|
1122 |
-
$aNotices[ 'messages' ][ 'wpv' ] =
|
1123 |
'title' => 'Vulnerability Scanner',
|
1124 |
'message' => _wpsf__( 'Vulnerability Scanner is not enabled.' ),
|
1125 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1126 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1127 |
'rec' => _wpsf__( 'Automatic detection of vulnerabilities is recommended.' )
|
1128 |
-
|
1129 |
}
|
1130 |
else if ( $this->getScanHasProblem( 'wpv' ) ) {
|
1131 |
-
$aNotices[ 'messages' ][ 'wpv' ] =
|
1132 |
'title' => 'Vulnerable Items',
|
1133 |
'message' => _wpsf__( 'At least 1 item has known vulnerabilities.' ),
|
1134 |
'href' => $this->getUrlManualScan(),
|
1135 |
'action' => _wpsf__( 'Run Scan' ),
|
1136 |
'rec' => _wpsf__( 'Items with known vulnerabilities should be updated, removed, or replaced.' )
|
1137 |
-
|
1138 |
}
|
1139 |
}
|
1140 |
|
1141 |
{// Abandoned Plugins
|
1142 |
if ( !$this->isApcEnabled() ) {
|
1143 |
-
$aNotices[ 'messages' ][ 'apc' ] =
|
1144 |
'title' => 'Abandoned Plugins Scanner',
|
1145 |
'message' => _wpsf__( 'Abandoned Plugins Scanner is not enabled.' ),
|
1146 |
'href' => $this->getUrl_DirectLinkToSection( 'section_scan_apc' ),
|
1147 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1148 |
'rec' => _wpsf__( 'Automatic detection of abandoned plugins is recommended.' )
|
1149 |
-
|
1150 |
}
|
1151 |
else if ( $this->getScanHasProblem( 'apc' ) ) {
|
1152 |
-
$aNotices[ 'messages' ][ 'apc' ] =
|
1153 |
'title' => 'Abandoned Plugins',
|
1154 |
'message' => _wpsf__( 'At least 1 plugin on your site is abandoned.' ),
|
1155 |
'href' => $this->getUrlManualScan(),
|
1156 |
'action' => _wpsf__( 'Run Scan' ),
|
1157 |
'rec' => _wpsf__( 'Plugins that have been abandoned represent a potential risk to your site.' )
|
1158 |
-
|
1159 |
}
|
1160 |
}
|
1161 |
|
@@ -1170,21 +1148,21 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1170 |
* @return array
|
1171 |
*/
|
1172 |
public function addInsightsConfigData( $aAllData ) {
|
1173 |
-
$aThis =
|
1174 |
-
'strings' =>
|
1175 |
'title' => _wpsf__( 'Hack Guard' ),
|
1176 |
'sub' => _wpsf__( 'Threats/Intrusions Detection & Repair' ),
|
1177 |
-
|
1178 |
'key_opts' => [],
|
1179 |
'href_options' => $this->getUrl_AdminPage()
|
1180 |
-
|
1181 |
|
1182 |
if ( !$this->isModOptEnabled() ) {
|
1183 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
1184 |
}
|
1185 |
else {
|
1186 |
$bGoodFrequency = $this->getScanFrequency() > 1;
|
1187 |
-
$aThis[ 'key_opts' ][ 'frequency' ] =
|
1188 |
'name' => _wpsf__( 'Scan Frequency' ),
|
1189 |
'enabled' => $bGoodFrequency,
|
1190 |
'summary' => $bGoodFrequency ?
|
@@ -1192,10 +1170,10 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1192 |
: _wpsf__( "Automatic scanners only run once per day" ),
|
1193 |
'weight' => 1,
|
1194 |
'href' => $this->getUrl_DirectLinkToSection( 'section_scan_options' ),
|
1195 |
-
|
1196 |
|
1197 |
$bCore = $this->isWcfScanEnabled();
|
1198 |
-
$aThis[ 'key_opts' ][ 'wcf' ] =
|
1199 |
'name' => _wpsf__( 'WP Core File Scan' ),
|
1200 |
'enabled' => $bCore,
|
1201 |
'summary' => $bCore ?
|
@@ -1203,9 +1181,9 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1203 |
: _wpsf__( "Core files are never scanned for hacks!" ),
|
1204 |
'weight' => 2,
|
1205 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1206 |
-
|
1207 |
if ( $bCore && !$this->isWcfScanAutoRepair() ) {
|
1208 |
-
$aThis[ 'key_opts' ][ 'wcf_repair' ] =
|
1209 |
'name' => _wpsf__( 'WP Core File Repair' ),
|
1210 |
'enabled' => $this->isWcfScanAutoRepair(),
|
1211 |
'summary' => $this->isWcfScanAutoRepair() ?
|
@@ -1213,11 +1191,11 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1213 |
: _wpsf__( "Core files aren't automatically repaired!" ),
|
1214 |
'weight' => 1,
|
1215 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1216 |
-
|
1217 |
}
|
1218 |
|
1219 |
$bUcf = $this->isUfcEnabled();
|
1220 |
-
$aThis[ 'key_opts' ][ 'ufc' ] =
|
1221 |
'name' => _wpsf__( 'Unrecognised Files' ),
|
1222 |
'enabled' => $bUcf,
|
1223 |
'summary' => $bUcf ?
|
@@ -1225,9 +1203,9 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1225 |
: _wpsf__( "WP Core is never scanned for unrecognised files!" ),
|
1226 |
'weight' => 2,
|
1227 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1228 |
-
|
1229 |
if ( $bUcf && !$this->isUfcDeleteFiles() ) {
|
1230 |
-
$aThis[ 'key_opts' ][ 'ufc_repair' ] =
|
1231 |
'name' => _wpsf__( 'Unrecognised Files Removal' ),
|
1232 |
'enabled' => $this->isUfcDeleteFiles(),
|
1233 |
'summary' => $this->isUfcDeleteFiles() ?
|
@@ -1235,11 +1213,11 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1235 |
: _wpsf__( "Unrecognised files aren't automatically removed!" ),
|
1236 |
'weight' => 1,
|
1237 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1238 |
-
|
1239 |
}
|
1240 |
|
1241 |
$bWpv = $this->isWpvulnEnabled();
|
1242 |
-
$aThis[ 'key_opts' ][ 'wpv' ] =
|
1243 |
'name' => _wpsf__( 'Vulnerability Scan' ),
|
1244 |
'enabled' => $bWpv,
|
1245 |
'summary' => $bWpv ?
|
@@ -1247,9 +1225,9 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1247 |
: _wpsf__( "Plugins/Themes never scanned for vulnerabilities!" ),
|
1248 |
'weight' => 2,
|
1249 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1250 |
-
|
1251 |
if ( $bWpv && !$this->isWpvulnAutoupdatesEnabled() ) {
|
1252 |
-
$aThis[ 'key_opts' ][ 'wpv_repair' ] =
|
1253 |
'name' => _wpsf__( 'Auto Update' ),
|
1254 |
'enabled' => $this->isWpvulnAutoupdatesEnabled(),
|
1255 |
'summary' => $this->isWpvulnAutoupdatesEnabled() ?
|
@@ -1257,11 +1235,11 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1257 |
: _wpsf__( "Vulnerable items aren't automatically updated!" ),
|
1258 |
'weight' => 1,
|
1259 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1260 |
-
|
1261 |
}
|
1262 |
|
1263 |
$bPtg = $this->isPtgEnabled();
|
1264 |
-
$aThis[ 'key_opts' ][ 'ptg' ] =
|
1265 |
'name' => _wpsf__( 'Plugin/Theme Guard' ),
|
1266 |
'enabled' => $bPtg,
|
1267 |
'summary' => $bPtg ?
|
@@ -1269,7 +1247,7 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1269 |
: _wpsf__( "Plugins and Themes are never scanned for tampering!" ),
|
1270 |
'weight' => 2,
|
1271 |
'href' => $this->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
1272 |
-
|
1273 |
}
|
1274 |
|
1275 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -1299,92 +1277,101 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1299 |
case 'section_scan_options' :
|
1300 |
$sTitle = _wpsf__( 'Scan Options' );
|
1301 |
$sTitleShort = _wpsf__( 'Scan Options' );
|
1302 |
-
$aSummary =
|
1303 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Set how frequently the Hack Guard scans will run.' ) )
|
1304 |
-
|
1305 |
break;
|
1306 |
|
1307 |
case 'section_realtime' :
|
1308 |
$sTitle = _wpsf__( 'Realtime Site Protection' );
|
1309 |
$sTitleShort = _wpsf__( 'Realtime Protection' );
|
1310 |
-
$aSummary =
|
1311 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides realtime protection for certain key files.' ) ),
|
1312 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep realtime protection turned on to protect key files.' ) ),
|
1313 |
-
|
1314 |
break;
|
1315 |
|
1316 |
case 'section_enable_plugin_feature_hack_protection_tools' :
|
1317 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
1318 |
-
$aSummary =
|
1319 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Hack Guard is a set of tools to warn you and protect you against hacks on your site.' ) ),
|
1320 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Hack Guard' ) ) )
|
1321 |
-
|
1322 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
1323 |
break;
|
1324 |
|
1325 |
case 'section_wpvuln_scan' :
|
1326 |
$sTitle = _wpsf__( 'Vulnerabilities Scanner' );
|
1327 |
-
$aSummary =
|
1328 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your WordPress plugins and themes for known security vulnerabilities.' ) ),
|
1329 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Vulnerabilities Scanner' ) ) ),
|
1330 |
_wpsf__( 'Ensure this is turned on and you will always know if any of your assets have known security vulnerabilities.' )
|
1331 |
-
|
1332 |
$sTitleShort = _wpsf__( 'Vulnerabilities Scanner' );
|
1333 |
break;
|
1334 |
|
1335 |
case 'section_plugin_vulnerabilities_scan' :
|
1336 |
$sTitle = _wpsf__( 'Vulnerabilities Scanner' );
|
1337 |
-
$aSummary =
|
1338 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your plugins against a database of known vulnerabilities.' ) ),
|
1339 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Vulnerabilities Scanner' ) ) )
|
1340 |
-
|
1341 |
$sTitleShort = _wpsf__( 'Vulnerabilities' );
|
1342 |
break;
|
1343 |
|
1344 |
case 'section_core_file_integrity_scan' :
|
1345 |
$sTitle = _wpsf__( 'WordPress Core File Scanner' );
|
1346 |
-
$aSummary =
|
1347 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your WordPress core files for changes compared to official WordPress files.' ) ),
|
1348 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $sTitle ) )
|
1349 |
-
|
1350 |
$sTitleShort = _wpsf__( 'WP Core File Scanner' );
|
1351 |
break;
|
1352 |
|
1353 |
case 'section_unrecognised_file_scan' :
|
1354 |
$sTitle = _wpsf__( 'Unrecognised Files Scanner' );
|
1355 |
-
$aSummary =
|
1356 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( "Regularly scan your WordPress core folders for files that don't belong." ) ),
|
1357 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $sTitle ) )
|
1358 |
-
|
1359 |
$sTitleShort = _wpsf__( 'Unrecognised Files Scanner' );
|
1360 |
break;
|
1361 |
|
1362 |
case 'section_scan_apc' :
|
1363 |
$sTitle = _wpsf__( 'Enable The Abandoned Plugin Scanner' );
|
1364 |
$sTitleShort = _wpsf__( 'Abandoned Plugin Scanner' );
|
1365 |
-
$aSummary =
|
1366 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ),
|
1367 |
_wpsf__( 'Monitor your site for plugins that have been abandoned by their authors and are no longer maintained.' ) ),
|
1368 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable this to alert you to your site running unmaintained code.' ) )
|
1369 |
-
|
1370 |
break;
|
1371 |
|
1372 |
case 'section_pluginthemes_guard' :
|
1373 |
$sTitle = _wpsf__( 'Plugins and Themes Guard' );
|
1374 |
$sTitleShort = _wpsf__( 'Plugins/Themes Guard' );
|
1375 |
-
$aSummary =
|
1376 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Detect malicious changes to your themes and plugins.' ) ),
|
1377 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep the Plugins/Theme Guard feature turned on.' ) ),
|
1378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1379 |
break;
|
1380 |
|
1381 |
case 'section_integrity_checking' :
|
1382 |
$sTitle = _wpsf__( 'Integrity Checks' );
|
1383 |
$sTitleShort = _wpsf__( 'Integrity Checks' );
|
1384 |
-
$aSummary =
|
1385 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Monitor for unrecognised changes to your system.' ) ),
|
1386 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable these to prevent unauthorized changes to your WordPress site.' ) )
|
1387 |
-
|
1388 |
break;
|
1389 |
|
1390 |
default:
|
@@ -1545,6 +1532,26 @@ class ICWP_WPSF_FeatureHandler_HackProtect extends ICWP_WPSF_FeatureHandler_Base
|
|
1545 |
$sDescription = _wpsf__( "Abandoned plugins will be highlighted on the main plugins page." );
|
1546 |
break;
|
1547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1548 |
case 'rt_file_wpconfig' :
|
1549 |
$sName = _wpsf__( 'WP Config' );
|
1550 |
$sSummary = _wpsf__( 'Realtime Protection For WP Config File' );
|
12 |
/**
|
13 |
*/
|
14 |
protected function updateHandler() {
|
15 |
+
$this->setPtgUpdateStoreFormat( true );
|
16 |
// ->setPtgRebuildSelfRequired( true ) // this is permanently required until a better solution is found
|
|
|
17 |
}
|
18 |
|
19 |
/**
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* @param Shield\Databases\Scanner\EntryVO $oEntryVo
|
80 |
* @return string
|
81 |
*/
|
82 |
public function createFileDownloadLink( $oEntryVo ) {
|
114 |
*/
|
115 |
protected function doExtraSubmitProcessing() {
|
116 |
$this->clearIcSnapshots();
|
|
|
117 |
$this->cleanFileExclusions();
|
118 |
$this->cleanPtgFileExtensions();
|
119 |
|
126 |
$this->resetRtBackupFiles();
|
127 |
}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
/**
|
130 |
* @param string $sScan ptg, wcf, ufc, wpv
|
131 |
* @return int
|
149 |
public function getScanHasProblem( $sScan ) {
|
150 |
/** @var ICWP_WPSF_Processor_HackProtect $oPro */
|
151 |
$oPro = $this->getProcessor();
|
152 |
+
/** @var Shield\Databases\Scanner\Select $oSel */
|
153 |
$oSel = $oPro->getSubProScanner()
|
154 |
->getDbHandler()
|
155 |
->getQuerySelector();
|
204 |
$this->loadWpCronProcessor()
|
205 |
->addNewSchedule(
|
206 |
$this->prefix( sprintf( 'per-day-%s', $nFreq ) ),
|
207 |
+
[
|
208 |
'interval' => DAY_IN_SECONDS/$nFreq,
|
209 |
'display' => sprintf( _wpsf__( '%s per day' ), $nFreq )
|
210 |
+
]
|
211 |
);
|
212 |
return $this;
|
213 |
}
|
233 |
return $this->isOpt( 'ic_users', 'Y' );
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
/**
|
237 |
* @param array[] $aUsers
|
238 |
* @return $this
|
248 |
return $this->getOpt( 'enable_unrecognised_file_cleaner_scan', 'disabled' );
|
249 |
}
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
/**
|
252 |
* @return array
|
253 |
*/
|
307 |
* @return string
|
308 |
*/
|
309 |
public function isUfcDeleteFiles() {
|
310 |
+
return in_array( $this->getUnrecognisedFileScannerOption(), [
|
311 |
'enabled_delete_only',
|
312 |
'enabled_delete_report'
|
313 |
+
] );
|
314 |
}
|
315 |
|
316 |
/**
|
331 |
* @return string
|
332 |
*/
|
333 |
public function isUfcSendReport() {
|
334 |
+
return in_array( $this->getUnrecognisedFileScannerOption(), [
|
335 |
'enabled_report_only',
|
336 |
'enabled_delete_report'
|
337 |
+
] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
|
340 |
/**
|
374 |
return $this->isPremium() && !$this->isOpt( 'enable_wpvuln_scan', 'disabled' );
|
375 |
}
|
376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
/**
|
378 |
* @return bool
|
379 |
*/
|
441 |
);
|
442 |
}
|
443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
/**
|
445 |
* @return string[]
|
446 |
*/
|
572 |
return $this->isOpt( 'enabled_scan_apc', 'enabled_email' );
|
573 |
}
|
574 |
|
575 |
+
/**
|
576 |
+
* @return bool
|
577 |
+
*/
|
578 |
+
public function isMalScanEnabled() {
|
579 |
+
return !$this->isOpt( 'mal_scan_enable', 'disabled' );
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* @return bool
|
584 |
+
*/
|
585 |
+
public function isMalAutoRepairCore() {
|
586 |
+
return $this->isOpt( 'mal_autorepair_core', 'Y' );
|
587 |
+
}
|
588 |
+
|
589 |
+
/**
|
590 |
+
* @return bool
|
591 |
+
*/
|
592 |
+
public function isMalAutoRepairPlugins() {
|
593 |
+
return $this->isOpt( 'mal_autorepair_plugins', 'Y' );
|
594 |
+
}
|
595 |
+
|
596 |
public function insertCustomJsVars_Admin() {
|
597 |
parent::insertCustomJsVars_Admin();
|
598 |
|
600 |
wp_localize_script(
|
601 |
$this->prefix( 'global-plugin' ),
|
602 |
'icwp_wpsf_vars_hp',
|
603 |
+
[
|
604 |
'ajax_plugin_reinstall' => $this->getAjaxActionData( 'plugin_reinstall' ),
|
605 |
'reinstallable' => Services::WpPlugins()->getInstalledWpOrgPluginFiles()
|
606 |
+
]
|
607 |
);
|
608 |
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
|
609 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
634 |
$nTime = $this->getLastScanAt( 'wpv' );
|
635 |
break;
|
636 |
|
637 |
+
case 'section_scan_malware':
|
638 |
+
$nTime = $this->getLastScanAt( 'mal' );
|
639 |
+
break;
|
640 |
+
|
641 |
default:
|
642 |
$nTime = null;
|
643 |
break;
|
661 |
$oTableBuilder = new Shield\Tables\Build\ScanApc();
|
662 |
break;
|
663 |
|
664 |
+
case 'mal':
|
665 |
+
$oTableBuilder = new Shield\Tables\Build\ScanMal();
|
666 |
+
break;
|
667 |
+
|
668 |
case 'wcf':
|
669 |
$oTableBuilder = new Shield\Tables\Build\ScanWcf();
|
670 |
break;
|
697 |
->buildTable();
|
698 |
}
|
699 |
|
700 |
+
return [
|
701 |
'success' => !empty( $oTableBuilder ),
|
702 |
'html' => $sHtml
|
703 |
+
];
|
704 |
}
|
705 |
|
706 |
+
/**
|
707 |
+
* @return array
|
708 |
+
*/
|
709 |
private function ajaxExec_StartScans() {
|
710 |
$bSuccess = false;
|
711 |
$bPageReload = false;
|
764 |
}
|
765 |
else {
|
766 |
if ( empty( $aItemIds ) ) {
|
767 |
+
$aItemIds = [ $sItemId ];
|
768 |
}
|
769 |
|
770 |
try {
|
776 |
}
|
777 |
}
|
778 |
|
|
|
|
|
779 |
if ( count( $aSuccessfulItems ) === count( $aItemIds ) ) {
|
780 |
$bSuccess = true;
|
781 |
$sMessage = 'Successfully completed. Re-scanning and reloading ...';
|
790 |
}
|
791 |
}
|
792 |
|
793 |
+
return [
|
794 |
'success' => $bSuccess,
|
795 |
'page_reload' => in_array( $sScannerSlug, [ 'apc', 'ptg' ] ),
|
796 |
'message' => $sMessage,
|
797 |
+
];
|
798 |
}
|
799 |
|
800 |
/**
|
809 |
case 'apc':
|
810 |
$oScannerPro = $oScanPro->getSubProcessorApc();
|
811 |
break;
|
812 |
+
case 'mal':
|
813 |
+
$oScannerPro = $oScanPro->getSubProcessorMal();
|
814 |
+
break;
|
815 |
case 'ptg':
|
816 |
$oScannerPro = $oScanPro->getSubProcessorPtg();
|
817 |
break;
|
1027 |
* @return array
|
1028 |
*/
|
1029 |
public function addInsightsNoticeData( $aAllNotices ) {
|
1030 |
+
$aNotices = [
|
1031 |
'title' => _wpsf__( 'Scans' ),
|
1032 |
'messages' => []
|
1033 |
+
];
|
1034 |
|
1035 |
{// Core files
|
1036 |
if ( !$this->isWcfScanEnabled() ) {
|
1037 |
+
$aNotices[ 'messages' ][ 'wcf' ] = [
|
1038 |
'title' => 'WP Core Files',
|
1039 |
'message' => _wpsf__( 'Core File scanner is not enabled.' ),
|
1040 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1041 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1042 |
'rec' => _wpsf__( 'Automatic WordPress Core File scanner should be turned-on.' )
|
1043 |
+
];
|
1044 |
}
|
1045 |
else if ( $this->getScanHasProblem( 'wcf' ) ) {
|
1046 |
+
$aNotices[ 'messages' ][ 'wcf' ] = [
|
1047 |
'title' => 'WP Core Files',
|
1048 |
'message' => _wpsf__( 'Modified WordPress core files found.' ),
|
1049 |
'href' => $this->getUrlManualScan(),
|
1050 |
'action' => _wpsf__( 'Run Scan' ),
|
1051 |
'rec' => _wpsf__( 'Scan WP core files and repair any files that are flagged as modified.' )
|
1052 |
+
];
|
1053 |
}
|
1054 |
}
|
1055 |
|
1056 |
{// Unrecognised
|
1057 |
if ( !$this->isUfcEnabled() ) {
|
1058 |
+
$aNotices[ 'messages' ][ 'ufc' ] = [
|
1059 |
'title' => 'Unrecognised Files',
|
1060 |
'message' => _wpsf__( 'Unrecognised File scanner is not enabled.' ),
|
1061 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1062 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1063 |
'rec' => _wpsf__( 'Automatic scanning for non-WordPress core files is recommended.' )
|
1064 |
+
];
|
1065 |
}
|
1066 |
else if ( $this->getScanHasProblem( 'ufc' ) ) {
|
1067 |
+
$aNotices[ 'messages' ][ 'ufc' ] = [
|
1068 |
'title' => 'Unrecognised Files',
|
1069 |
'message' => _wpsf__( 'Unrecognised files found in WordPress Core directory.' ),
|
1070 |
'href' => $this->getUrlManualScan(),
|
1071 |
'action' => _wpsf__( 'Run Scan' ),
|
1072 |
'rec' => _wpsf__( 'Scan and remove any files that are not meant to be in the WP core directories.' )
|
1073 |
+
];
|
1074 |
}
|
1075 |
}
|
1076 |
|
1077 |
{// Plugin/Theme Guard
|
1078 |
if ( !$this->isPtgEnabled() ) {
|
1079 |
+
$aNotices[ 'messages' ][ 'ptg' ] = [
|
1080 |
'title' => 'Plugin/Theme Guard',
|
1081 |
'message' => _wpsf__( 'Automatic Plugin/Themes Guard is not enabled.' ),
|
1082 |
'href' => $this->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
1083 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1084 |
'rec' => _wpsf__( 'Automatic detection of plugin/theme modifications is recommended.' )
|
1085 |
+
];
|
1086 |
}
|
1087 |
else if ( $this->getScanHasProblem( 'ptg' ) ) {
|
1088 |
+
$aNotices[ 'messages' ][ 'ptg' ] = [
|
1089 |
'title' => 'Plugin/Theme Guard',
|
1090 |
'message' => _wpsf__( 'A plugin/theme was found to have been modified.' ),
|
1091 |
'href' => $this->getUrlManualScan(),
|
1092 |
'action' => _wpsf__( 'Run Scan' ),
|
1093 |
'rec' => _wpsf__( 'Reviewing modifications to your plugins/themes is recommended.' )
|
1094 |
+
];
|
1095 |
}
|
1096 |
}
|
1097 |
|
1098 |
{// Vulnerability Scanner
|
1099 |
if ( !$this->isWpvulnEnabled() ) {
|
1100 |
+
$aNotices[ 'messages' ][ 'wpv' ] = [
|
1101 |
'title' => 'Vulnerability Scanner',
|
1102 |
'message' => _wpsf__( 'Vulnerability Scanner is not enabled.' ),
|
1103 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1104 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1105 |
'rec' => _wpsf__( 'Automatic detection of vulnerabilities is recommended.' )
|
1106 |
+
];
|
1107 |
}
|
1108 |
else if ( $this->getScanHasProblem( 'wpv' ) ) {
|
1109 |
+
$aNotices[ 'messages' ][ 'wpv' ] = [
|
1110 |
'title' => 'Vulnerable Items',
|
1111 |
'message' => _wpsf__( 'At least 1 item has known vulnerabilities.' ),
|
1112 |
'href' => $this->getUrlManualScan(),
|
1113 |
'action' => _wpsf__( 'Run Scan' ),
|
1114 |
'rec' => _wpsf__( 'Items with known vulnerabilities should be updated, removed, or replaced.' )
|
1115 |
+
];
|
1116 |
}
|
1117 |
}
|
1118 |
|
1119 |
{// Abandoned Plugins
|
1120 |
if ( !$this->isApcEnabled() ) {
|
1121 |
+
$aNotices[ 'messages' ][ 'apc' ] = [
|
1122 |
'title' => 'Abandoned Plugins Scanner',
|
1123 |
'message' => _wpsf__( 'Abandoned Plugins Scanner is not enabled.' ),
|
1124 |
'href' => $this->getUrl_DirectLinkToSection( 'section_scan_apc' ),
|
1125 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
1126 |
'rec' => _wpsf__( 'Automatic detection of abandoned plugins is recommended.' )
|
1127 |
+
];
|
1128 |
}
|
1129 |
else if ( $this->getScanHasProblem( 'apc' ) ) {
|
1130 |
+
$aNotices[ 'messages' ][ 'apc' ] = [
|
1131 |
'title' => 'Abandoned Plugins',
|
1132 |
'message' => _wpsf__( 'At least 1 plugin on your site is abandoned.' ),
|
1133 |
'href' => $this->getUrlManualScan(),
|
1134 |
'action' => _wpsf__( 'Run Scan' ),
|
1135 |
'rec' => _wpsf__( 'Plugins that have been abandoned represent a potential risk to your site.' )
|
1136 |
+
];
|
1137 |
}
|
1138 |
}
|
1139 |
|
1148 |
* @return array
|
1149 |
*/
|
1150 |
public function addInsightsConfigData( $aAllData ) {
|
1151 |
+
$aThis = [
|
1152 |
+
'strings' => [
|
1153 |
'title' => _wpsf__( 'Hack Guard' ),
|
1154 |
'sub' => _wpsf__( 'Threats/Intrusions Detection & Repair' ),
|
1155 |
+
],
|
1156 |
'key_opts' => [],
|
1157 |
'href_options' => $this->getUrl_AdminPage()
|
1158 |
+
];
|
1159 |
|
1160 |
if ( !$this->isModOptEnabled() ) {
|
1161 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
1162 |
}
|
1163 |
else {
|
1164 |
$bGoodFrequency = $this->getScanFrequency() > 1;
|
1165 |
+
$aThis[ 'key_opts' ][ 'frequency' ] = [
|
1166 |
'name' => _wpsf__( 'Scan Frequency' ),
|
1167 |
'enabled' => $bGoodFrequency,
|
1168 |
'summary' => $bGoodFrequency ?
|
1170 |
: _wpsf__( "Automatic scanners only run once per day" ),
|
1171 |
'weight' => 1,
|
1172 |
'href' => $this->getUrl_DirectLinkToSection( 'section_scan_options' ),
|
1173 |
+
];
|
1174 |
|
1175 |
$bCore = $this->isWcfScanEnabled();
|
1176 |
+
$aThis[ 'key_opts' ][ 'wcf' ] = [
|
1177 |
'name' => _wpsf__( 'WP Core File Scan' ),
|
1178 |
'enabled' => $bCore,
|
1179 |
'summary' => $bCore ?
|
1181 |
: _wpsf__( "Core files are never scanned for hacks!" ),
|
1182 |
'weight' => 2,
|
1183 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1184 |
+
];
|
1185 |
if ( $bCore && !$this->isWcfScanAutoRepair() ) {
|
1186 |
+
$aThis[ 'key_opts' ][ 'wcf_repair' ] = [
|
1187 |
'name' => _wpsf__( 'WP Core File Repair' ),
|
1188 |
'enabled' => $this->isWcfScanAutoRepair(),
|
1189 |
'summary' => $this->isWcfScanAutoRepair() ?
|
1191 |
: _wpsf__( "Core files aren't automatically repaired!" ),
|
1192 |
'weight' => 1,
|
1193 |
'href' => $this->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' ),
|
1194 |
+
];
|
1195 |
}
|
1196 |
|
1197 |
$bUcf = $this->isUfcEnabled();
|
1198 |
+
$aThis[ 'key_opts' ][ 'ufc' ] = [
|
1199 |
'name' => _wpsf__( 'Unrecognised Files' ),
|
1200 |
'enabled' => $bUcf,
|
1201 |
'summary' => $bUcf ?
|
1203 |
: _wpsf__( "WP Core is never scanned for unrecognised files!" ),
|
1204 |
'weight' => 2,
|
1205 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1206 |
+
];
|
1207 |
if ( $bUcf && !$this->isUfcDeleteFiles() ) {
|
1208 |
+
$aThis[ 'key_opts' ][ 'ufc_repair' ] = [
|
1209 |
'name' => _wpsf__( 'Unrecognised Files Removal' ),
|
1210 |
'enabled' => $this->isUfcDeleteFiles(),
|
1211 |
'summary' => $this->isUfcDeleteFiles() ?
|
1213 |
: _wpsf__( "Unrecognised files aren't automatically removed!" ),
|
1214 |
'weight' => 1,
|
1215 |
'href' => $this->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' ),
|
1216 |
+
];
|
1217 |
}
|
1218 |
|
1219 |
$bWpv = $this->isWpvulnEnabled();
|
1220 |
+
$aThis[ 'key_opts' ][ 'wpv' ] = [
|
1221 |
'name' => _wpsf__( 'Vulnerability Scan' ),
|
1222 |
'enabled' => $bWpv,
|
1223 |
'summary' => $bWpv ?
|
1225 |
: _wpsf__( "Plugins/Themes never scanned for vulnerabilities!" ),
|
1226 |
'weight' => 2,
|
1227 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1228 |
+
];
|
1229 |
if ( $bWpv && !$this->isWpvulnAutoupdatesEnabled() ) {
|
1230 |
+
$aThis[ 'key_opts' ][ 'wpv_repair' ] = [
|
1231 |
'name' => _wpsf__( 'Auto Update' ),
|
1232 |
'enabled' => $this->isWpvulnAutoupdatesEnabled(),
|
1233 |
'summary' => $this->isWpvulnAutoupdatesEnabled() ?
|
1235 |
: _wpsf__( "Vulnerable items aren't automatically updated!" ),
|
1236 |
'weight' => 1,
|
1237 |
'href' => $this->getUrl_DirectLinkToSection( 'section_wpvuln_scan' ),
|
1238 |
+
];
|
1239 |
}
|
1240 |
|
1241 |
$bPtg = $this->isPtgEnabled();
|
1242 |
+
$aThis[ 'key_opts' ][ 'ptg' ] = [
|
1243 |
'name' => _wpsf__( 'Plugin/Theme Guard' ),
|
1244 |
'enabled' => $bPtg,
|
1245 |
'summary' => $bPtg ?
|
1247 |
: _wpsf__( "Plugins and Themes are never scanned for tampering!" ),
|
1248 |
'weight' => 2,
|
1249 |
'href' => $this->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
1250 |
+
];
|
1251 |
}
|
1252 |
|
1253 |
$aAllData[ $this->getSlug() ] = $aThis;
|
1277 |
case 'section_scan_options' :
|
1278 |
$sTitle = _wpsf__( 'Scan Options' );
|
1279 |
$sTitleShort = _wpsf__( 'Scan Options' );
|
1280 |
+
$aSummary = [
|
1281 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Set how frequently the Hack Guard scans will run.' ) )
|
1282 |
+
];
|
1283 |
break;
|
1284 |
|
1285 |
case 'section_realtime' :
|
1286 |
$sTitle = _wpsf__( 'Realtime Site Protection' );
|
1287 |
$sTitleShort = _wpsf__( 'Realtime Protection' );
|
1288 |
+
$aSummary = [
|
1289 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides realtime protection for certain key files.' ) ),
|
1290 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep realtime protection turned on to protect key files.' ) ),
|
1291 |
+
];
|
1292 |
break;
|
1293 |
|
1294 |
case 'section_enable_plugin_feature_hack_protection_tools' :
|
1295 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
1296 |
+
$aSummary = [
|
1297 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Hack Guard is a set of tools to warn you and protect you against hacks on your site.' ) ),
|
1298 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Hack Guard' ) ) )
|
1299 |
+
];
|
1300 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
1301 |
break;
|
1302 |
|
1303 |
case 'section_wpvuln_scan' :
|
1304 |
$sTitle = _wpsf__( 'Vulnerabilities Scanner' );
|
1305 |
+
$aSummary = [
|
1306 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your WordPress plugins and themes for known security vulnerabilities.' ) ),
|
1307 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Vulnerabilities Scanner' ) ) ),
|
1308 |
_wpsf__( 'Ensure this is turned on and you will always know if any of your assets have known security vulnerabilities.' )
|
1309 |
+
];
|
1310 |
$sTitleShort = _wpsf__( 'Vulnerabilities Scanner' );
|
1311 |
break;
|
1312 |
|
1313 |
case 'section_plugin_vulnerabilities_scan' :
|
1314 |
$sTitle = _wpsf__( 'Vulnerabilities Scanner' );
|
1315 |
+
$aSummary = [
|
1316 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your plugins against a database of known vulnerabilities.' ) ),
|
1317 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Vulnerabilities Scanner' ) ) )
|
1318 |
+
];
|
1319 |
$sTitleShort = _wpsf__( 'Vulnerabilities' );
|
1320 |
break;
|
1321 |
|
1322 |
case 'section_core_file_integrity_scan' :
|
1323 |
$sTitle = _wpsf__( 'WordPress Core File Scanner' );
|
1324 |
+
$aSummary = [
|
1325 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Regularly scan your WordPress core files for changes compared to official WordPress files.' ) ),
|
1326 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $sTitle ) )
|
1327 |
+
];
|
1328 |
$sTitleShort = _wpsf__( 'WP Core File Scanner' );
|
1329 |
break;
|
1330 |
|
1331 |
case 'section_unrecognised_file_scan' :
|
1332 |
$sTitle = _wpsf__( 'Unrecognised Files Scanner' );
|
1333 |
+
$aSummary = [
|
1334 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( "Regularly scan your WordPress core folders for files that don't belong." ) ),
|
1335 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $sTitle ) )
|
1336 |
+
];
|
1337 |
$sTitleShort = _wpsf__( 'Unrecognised Files Scanner' );
|
1338 |
break;
|
1339 |
|
1340 |
case 'section_scan_apc' :
|
1341 |
$sTitle = _wpsf__( 'Enable The Abandoned Plugin Scanner' );
|
1342 |
$sTitleShort = _wpsf__( 'Abandoned Plugin Scanner' );
|
1343 |
+
$aSummary = [
|
1344 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ),
|
1345 |
_wpsf__( 'Monitor your site for plugins that have been abandoned by their authors and are no longer maintained.' ) ),
|
1346 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable this to alert you to your site running unmaintained code.' ) )
|
1347 |
+
];
|
1348 |
break;
|
1349 |
|
1350 |
case 'section_pluginthemes_guard' :
|
1351 |
$sTitle = _wpsf__( 'Plugins and Themes Guard' );
|
1352 |
$sTitleShort = _wpsf__( 'Plugins/Themes Guard' );
|
1353 |
+
$aSummary = [
|
1354 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Detect malicious changes to your themes and plugins.' ) ),
|
1355 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep the Plugins/Theme Guard feature turned on.' ) ),
|
1356 |
+
];
|
1357 |
+
break;
|
1358 |
+
|
1359 |
+
case 'section_scan_malware' :
|
1360 |
+
$sTitle = _wpsf__( 'Malware Scanner' );
|
1361 |
+
$sTitleShort = _wpsf__( 'Malware Scanner' );
|
1362 |
+
$aSummary = [
|
1363 |
+
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Monitor and detect presence of Malware signatures.' ) ),
|
1364 |
+
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable this scanner to automatically detect infected files.' ) )
|
1365 |
+
];
|
1366 |
break;
|
1367 |
|
1368 |
case 'section_integrity_checking' :
|
1369 |
$sTitle = _wpsf__( 'Integrity Checks' );
|
1370 |
$sTitleShort = _wpsf__( 'Integrity Checks' );
|
1371 |
+
$aSummary = [
|
1372 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Monitor for unrecognised changes to your system.' ) ),
|
1373 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable these to prevent unauthorized changes to your WordPress site.' ) )
|
1374 |
+
];
|
1375 |
break;
|
1376 |
|
1377 |
default:
|
1532 |
$sDescription = _wpsf__( "Abandoned plugins will be highlighted on the main plugins page." );
|
1533 |
break;
|
1534 |
|
1535 |
+
case 'mal_scan_enable' :
|
1536 |
+
$sName = _wpsf__( 'Malware Scanner' );
|
1537 |
+
$sSummary = _wpsf__( 'Enable Malware Scanner' );
|
1538 |
+
$sDescription = _wpsf__( "Enabled detection of files infected with malware signatures." );
|
1539 |
+
break;
|
1540 |
+
|
1541 |
+
case 'mal_autorepair_core' :
|
1542 |
+
$sName = _wpsf__( 'Auto-Repair WP Core' );
|
1543 |
+
$sSummary = _wpsf__( 'Automatically Repair WordPress Core Files' );
|
1544 |
+
$sDescription = _wpsf__( "Automatically reinstall any core files found to have potential malware." );
|
1545 |
+
break;
|
1546 |
+
|
1547 |
+
case 'mal_autorepair_plugins' :
|
1548 |
+
$sName = _wpsf__( 'Auto-Repair WP Plugins' );
|
1549 |
+
$sSummary = _wpsf__( 'Automatically Repair WordPress.org Plugins' );
|
1550 |
+
$sDescription = _wpsf__( "Automatically repair any plugin files found to have potential malware." )
|
1551 |
+
.'<br />'.sprintf( '%s: %s', _wpsf__( 'Important' ), _wpsf__( 'Only applies to plugins installed from WordPress.org.' ) )
|
1552 |
+
.'<br />'.sprintf( '%s: %s', _wpsf__( 'Important' ), _wpsf__( "Also deletes files if they're found to not be originally distributed with the plugin." ) );
|
1553 |
+
break;
|
1554 |
+
|
1555 |
case 'rt_file_wpconfig' :
|
1556 |
$sName = _wpsf__( 'WP Config' );
|
1557 |
$sSummary = _wpsf__( 'Realtime Protection For WP Config File' );
|
@@ -20,7 +20,7 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
20 |
* @return bool
|
21 |
*/
|
22 |
public function isEnabledXFrame() {
|
23 |
-
return in_array( $this->getOpt( 'x_frame' ),
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -44,7 +44,7 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
44 |
*/
|
45 |
public function getReferrerPolicyValue() {
|
46 |
$sValue = $this->getOpt( 'x_referrer_policy' );
|
47 |
-
return in_array( $sValue,
|
48 |
}
|
49 |
|
50 |
/**
|
@@ -126,14 +126,14 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
126 |
* @return array
|
127 |
*/
|
128 |
public function addInsightsConfigData( $aAllData ) {
|
129 |
-
$aThis =
|
130 |
-
'strings' =>
|
131 |
'title' => _wpsf__( 'HTTP Security Headers' ),
|
132 |
'sub' => _wpsf__( 'Protect Visitors With Powerful HTTP Headers' ),
|
133 |
-
|
134 |
'key_opts' => [],
|
135 |
'href_options' => $this->getUrl_AdminPage()
|
136 |
-
|
137 |
|
138 |
if ( !$this->isModOptEnabled() ) {
|
139 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
@@ -141,7 +141,7 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
141 |
else {
|
142 |
$bAllEnabled = $this->isEnabledXFrame() && $this->isEnabledXssProtection()
|
143 |
&& $this->isEnabledContentTypeHeader() && $this->isReferrerPolicyEnabled();
|
144 |
-
$aThis[ 'key_opts' ][ 'all' ] =
|
145 |
'name' => _wpsf__( 'HTTP Headers' ),
|
146 |
'enabled' => $bAllEnabled,
|
147 |
'summary' => $bAllEnabled ?
|
@@ -149,9 +149,9 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
149 |
: _wpsf__( "At least one of the HTTP Headers hasn't been set" ),
|
150 |
'weight' => 2,
|
151 |
'href' => $this->getUrl_DirectLinkToSection( 'section_security_headers' ),
|
152 |
-
|
153 |
$bCsp = $this->isContentSecurityPolicyEnabled();
|
154 |
-
$aThis[ 'key_opts' ][ 'csp' ] =
|
155 |
'name' => _wpsf__( 'Content Security Policies' ),
|
156 |
'enabled' => $bCsp,
|
157 |
'summary' => $bCsp ?
|
@@ -159,7 +159,7 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
159 |
: _wpsf__( "Content Security Policies aren't active" ),
|
160 |
'weight' => 1,
|
161 |
'href' => $this->getUrl_DirectLinkToSection( 'section_content_security_policy' ),
|
162 |
-
|
163 |
}
|
164 |
|
165 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -178,28 +178,28 @@ class ICWP_WPSF_FeatureHandler_Headers extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
178 |
|
179 |
case 'section_enable_plugin_feature_headers' :
|
180 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
181 |
-
$aSummary =
|
182 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Protect visitors to your site by implementing increased security response headers.' ) ),
|
183 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
184 |
-
|
185 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
186 |
break;
|
187 |
|
188 |
case 'section_security_headers' :
|
189 |
$sTitle = _wpsf__( 'Advanced Security Headers' );
|
190 |
-
$aSummary =
|
191 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Protect visitors to your site by implementing increased security response headers.' ) ),
|
192 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
193 |
-
|
194 |
$sTitleShort = _wpsf__( 'Security Headers' );
|
195 |
break;
|
196 |
|
197 |
case 'section_content_security_policy' :
|
198 |
$sTitle = _wpsf__( 'Content Security Policy' );
|
199 |
-
$aSummary =
|
200 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restrict the sources and types of content that may be loaded and processed by visitor browsers.' ) ),
|
201 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
202 |
-
|
203 |
$sTitleShort = _wpsf__( 'Content Security Policy' );
|
204 |
break;
|
205 |
|
20 |
* @return bool
|
21 |
*/
|
22 |
public function isEnabledXFrame() {
|
23 |
+
return in_array( $this->getOpt( 'x_frame' ), [ 'on_sameorigin', 'on_deny' ] );
|
24 |
}
|
25 |
|
26 |
/**
|
44 |
*/
|
45 |
public function getReferrerPolicyValue() {
|
46 |
$sValue = $this->getOpt( 'x_referrer_policy' );
|
47 |
+
return in_array( $sValue, [ 'empty', 'disabled' ] ) ? '' : $sValue;
|
48 |
}
|
49 |
|
50 |
/**
|
126 |
* @return array
|
127 |
*/
|
128 |
public function addInsightsConfigData( $aAllData ) {
|
129 |
+
$aThis = [
|
130 |
+
'strings' => [
|
131 |
'title' => _wpsf__( 'HTTP Security Headers' ),
|
132 |
'sub' => _wpsf__( 'Protect Visitors With Powerful HTTP Headers' ),
|
133 |
+
],
|
134 |
'key_opts' => [],
|
135 |
'href_options' => $this->getUrl_AdminPage()
|
136 |
+
];
|
137 |
|
138 |
if ( !$this->isModOptEnabled() ) {
|
139 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
141 |
else {
|
142 |
$bAllEnabled = $this->isEnabledXFrame() && $this->isEnabledXssProtection()
|
143 |
&& $this->isEnabledContentTypeHeader() && $this->isReferrerPolicyEnabled();
|
144 |
+
$aThis[ 'key_opts' ][ 'all' ] = [
|
145 |
'name' => _wpsf__( 'HTTP Headers' ),
|
146 |
'enabled' => $bAllEnabled,
|
147 |
'summary' => $bAllEnabled ?
|
149 |
: _wpsf__( "At least one of the HTTP Headers hasn't been set" ),
|
150 |
'weight' => 2,
|
151 |
'href' => $this->getUrl_DirectLinkToSection( 'section_security_headers' ),
|
152 |
+
];
|
153 |
$bCsp = $this->isContentSecurityPolicyEnabled();
|
154 |
+
$aThis[ 'key_opts' ][ 'csp' ] = [
|
155 |
'name' => _wpsf__( 'Content Security Policies' ),
|
156 |
'enabled' => $bCsp,
|
157 |
'summary' => $bCsp ?
|
159 |
: _wpsf__( "Content Security Policies aren't active" ),
|
160 |
'weight' => 1,
|
161 |
'href' => $this->getUrl_DirectLinkToSection( 'section_content_security_policy' ),
|
162 |
+
];
|
163 |
}
|
164 |
|
165 |
$aAllData[ $this->getSlug() ] = $aThis;
|
178 |
|
179 |
case 'section_enable_plugin_feature_headers' :
|
180 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
181 |
+
$aSummary = [
|
182 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Protect visitors to your site by implementing increased security response headers.' ) ),
|
183 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
184 |
+
];
|
185 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
186 |
break;
|
187 |
|
188 |
case 'section_security_headers' :
|
189 |
$sTitle = _wpsf__( 'Advanced Security Headers' );
|
190 |
+
$aSummary = [
|
191 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Protect visitors to your site by implementing increased security response headers.' ) ),
|
192 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
193 |
+
];
|
194 |
$sTitleShort = _wpsf__( 'Security Headers' );
|
195 |
break;
|
196 |
|
197 |
case 'section_content_security_policy' :
|
198 |
$sTitle = _wpsf__( 'Content Security Policy' );
|
199 |
+
$aSummary = [
|
200 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Restrict the sources and types of content that may be loaded and processed by visitor browsers.' ) ),
|
201 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling these features are advised, but you must test them on your site thoroughly.' ) )
|
202 |
+
];
|
203 |
$sTitleShort = _wpsf__( 'Content Security Policy' );
|
204 |
break;
|
205 |
|
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
use FernleafSystems\Wordpress\Services\Services;
|
4 |
|
5 |
class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
@@ -15,6 +16,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
15 |
|
16 |
/**
|
17 |
* @param array $aData
|
|
|
18 |
*/
|
19 |
protected function renderModulePage( $aData = [] ) {
|
20 |
$oCon = $this->getCon();
|
@@ -32,7 +34,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
32 |
$oTrafficMod = $oCon->getModule( 'traffic' );
|
33 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
34 |
$oTrafficPro = $oTrafficMod->getProcessor();
|
35 |
-
/** @var
|
36 |
$oTrafficSelector = $oTrafficPro->getProcessorLogger()
|
37 |
->getDbHandler()
|
38 |
->getQuerySelector();
|
@@ -41,7 +43,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
41 |
$oAuditMod = $oCon->getModule( 'audit_trail' );
|
42 |
/** @var ICWP_WPSF_Processor_AuditTrail $oAuditPro */
|
43 |
$oAuditPro = $oAuditMod->getProcessor();
|
44 |
-
/** @var
|
45 |
$oAuditSelect = $oAuditPro->getSubProAuditor()->getDbHandler()->getQuerySelector();
|
46 |
|
47 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oIpMod */
|
@@ -49,7 +51,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
49 |
|
50 |
/** @var ICWP_WPSF_Processor_Sessions $oProSessions */
|
51 |
$oProSessions = $oCon->getModule( 'sessions' )->getProcessor();
|
52 |
-
/** @var
|
53 |
$oSessionSelect = $oProSessions->getDbHandler()->getQuerySelector();
|
54 |
|
55 |
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oModUsers */
|
@@ -69,34 +71,34 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
69 |
switch ( $sNavSection ) {
|
70 |
|
71 |
case 'audit':
|
72 |
-
$aData =
|
73 |
-
'ajax' =>
|
74 |
'render_table_audittrail' => $oAuditMod->getAjaxActionData( 'render_table_audittrail', true ),
|
75 |
'item_addparamwhite' => $oAuditMod->getAjaxActionData( 'item_addparamwhite', true )
|
76 |
-
|
77 |
'flags' => [],
|
78 |
-
'strings' =>
|
79 |
'title_filter_form' => _wpsf__( 'Audit Trail Filters' ),
|
80 |
-
|
81 |
-
'vars' =>
|
82 |
'contexts_for_select' => $oAuditMod->getAllContexts(),
|
83 |
'unique_ips' => $oAuditSelect->getDistinctIps(),
|
84 |
'unique_users' => $oAuditSelect->getDistinctUsernames(),
|
85 |
-
|
86 |
-
|
87 |
break;
|
88 |
|
89 |
case 'ips':
|
90 |
-
$aData =
|
91 |
-
'ajax' =>
|
92 |
'render_table_ip' => $oIpMod->getAjaxActionData( 'render_table_ip', true ),
|
93 |
'item_insert' => $oIpMod->getAjaxActionData( 'ip_insert', true ),
|
94 |
'item_delete' => $oIpMod->getAjaxActionData( 'ip_delete', true ),
|
95 |
-
|
96 |
-
'flags' =>
|
97 |
'can_blacklist' => $bIsPro
|
98 |
-
|
99 |
-
'strings' =>
|
100 |
'trans_limit' => sprintf(
|
101 |
'Transgressions required for IP block: %s',
|
102 |
sprintf( '<a href="%s" target="_blank">%s</a>', $oIpMod->getUrl_DirectLinkToOption( 'transgression_limit' ), $oIpMod->getOptTransgressionLimit() )
|
@@ -113,47 +115,47 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
113 |
'title_blacklist' => _wpsf__( 'IP Blacklist' ),
|
114 |
'summary_whitelist' => sprintf( _wpsf__( 'IP addresses that are never blocked by %s.' ), $nPluginName ),
|
115 |
'summary_blacklist' => sprintf( _wpsf__( 'IP addresses that have tripped %s defenses.' ), $nPluginName ),
|
116 |
-
|
117 |
'vars' => [],
|
118 |
-
|
119 |
break;
|
120 |
|
121 |
case 'notes':
|
122 |
-
$aData =
|
123 |
'vars' => [],
|
124 |
-
'ajax' =>
|
125 |
'render_table_adminnotes' => $oModPlugin->getAjaxActionData( 'render_table_adminnotes', true ),
|
126 |
'item_delete' => $oModPlugin->getAjaxActionData( 'note_delete', true ),
|
127 |
'item_insert' => $oModPlugin->getAjaxActionData( 'note_insert', true ),
|
128 |
'bulk_action' => $oModPlugin->getAjaxActionData( 'bulk_action', true ),
|
129 |
-
|
130 |
-
'flags' =>
|
131 |
'can_adminnotes' => $bIsPro,
|
132 |
-
|
133 |
-
|
134 |
break;
|
135 |
|
136 |
case 'traffic':
|
137 |
-
$aData =
|
138 |
-
'ajax' =>
|
139 |
'render_table_traffic' => $oTrafficMod->getAjaxActionData( 'render_table_traffic', true )
|
140 |
-
|
141 |
-
'flags' =>
|
142 |
'can_traffic' => $bIsPro,
|
143 |
'is_enabled' => $oTrafficMod->isModOptEnabled(),
|
144 |
-
|
145 |
-
'hrefs' =>
|
146 |
'please_enable' => $oTrafficMod->getUrl_DirectLinkToOption( 'enable_traffic' ),
|
147 |
-
|
148 |
-
'strings' =>
|
149 |
'title_filter_form' => _wpsf__( 'Traffic Table Filters' ),
|
150 |
-
|
151 |
-
'vars' =>
|
152 |
'unique_ips' => $oTrafficSelector->getDistinctIps(),
|
153 |
'unique_responses' => $oTrafficSelector->getDistinctCodes(),
|
154 |
'unique_users' => $oTrafficSelector->getDistinctUsernames(),
|
155 |
-
|
156 |
-
|
157 |
break;
|
158 |
|
159 |
case 'license':
|
@@ -169,60 +171,60 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
169 |
break;
|
170 |
|
171 |
case 'users':
|
172 |
-
$aData =
|
173 |
-
'ajax' =>
|
174 |
'render_table_sessions' => $oModUsers->getAjaxActionData( 'render_table_sessions', true ),
|
175 |
'item_delete' => $oModUsers->getAjaxActionData( 'session_delete', true ),
|
176 |
'bulk_action' => $oModUsers->getAjaxActionData( 'bulk_action', true ),
|
177 |
|
178 |
-
|
179 |
'flags' => [],
|
180 |
-
'strings' =>
|
181 |
'title_filter_form' => _wpsf__( 'Sessions Table Filters' ),
|
182 |
-
|
183 |
-
'vars' =>
|
184 |
'unique_ips' => $oSessionSelect->getDistinctIps(),
|
185 |
'unique_users' => $oSessionSelect->getDistinctUsernames(),
|
186 |
-
|
187 |
-
|
188 |
break;
|
189 |
|
190 |
case 'insights':
|
191 |
case 'index':
|
192 |
default:
|
193 |
$sNavSection = 'insights';
|
194 |
-
$aData =
|
195 |
-
'vars' =>
|
196 |
'config_cards' => $this->getConfigCardsData(),
|
197 |
'summary' => $this->getInsightsModsSummary(),
|
198 |
'insight_events' => $this->getRecentEvents(),
|
199 |
'insight_notices' => $aSecNotices,
|
200 |
'insight_notices_count' => $nNoticesCount,
|
201 |
'insight_stats' => $this->getStats(),
|
202 |
-
|
203 |
-
'inputs' =>
|
204 |
-
'license_key' =>
|
205 |
'name' => $this->prefixOptionKey( 'license_key' ),
|
206 |
'maxlength' => $this->getDef( 'license_key_length' ),
|
207 |
-
|
208 |
-
|
209 |
'ajax' => [],
|
210 |
-
'hrefs' =>
|
211 |
'shield_pro_url' => 'https://icwp.io/shieldpro',
|
212 |
'shield_pro_more_info_url' => 'https://icwp.io/shld1',
|
213 |
-
|
214 |
-
'flags' =>
|
215 |
'show_ads' => false,
|
216 |
'show_standard_options' => false,
|
217 |
'show_alt_content' => true,
|
218 |
'is_pro' => $bIsPro,
|
219 |
'has_notices' => count( $aSecNotices ) > 0,
|
220 |
-
|
221 |
-
|
222 |
break;
|
223 |
}
|
224 |
|
225 |
-
$aTopNav =
|
226 |
'insights' => _wpsf__( 'Overview' ),
|
227 |
'scans' => _wpsf__( 'Scans' ),
|
228 |
'ips' => _wpsf__( 'IP Lists' ),
|
@@ -232,48 +234,48 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
232 |
'traffic' => _wpsf__( 'Traffic' ),
|
233 |
'notes' => _wpsf__( 'Notes' ),
|
234 |
'importexport' => sprintf( '%s/%s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) ),
|
235 |
-
|
236 |
if ( $bIsPro ) {
|
237 |
unset( $aTopNav[ 'license' ] );
|
238 |
$aTopNav[ 'license' ] = _wpsf__( 'Pro' );
|
239 |
}
|
240 |
|
241 |
array_walk( $aTopNav, function ( &$sName, $sKey ) use ( $sNavSection ) {
|
242 |
-
$sName =
|
243 |
'href' => add_query_arg( [ 'inav' => $sKey ], $this->getUrl_AdminPage() ),
|
244 |
'name' => $sName,
|
245 |
'active' => $sKey === $sNavSection
|
246 |
-
|
247 |
} );
|
248 |
|
249 |
-
$aTopNav[ 'full_options' ] =
|
250 |
'href' => $this->getCon()->getModule( 'plugin' )->getUrl_AdminPage(),
|
251 |
'name' => _wpsf__( 'Settings' ),
|
252 |
'active' => false
|
253 |
-
|
254 |
|
255 |
$oDp = Services::DataManipulation();
|
256 |
$aData = $oDp->mergeArraysRecursive(
|
257 |
$this->getBaseDisplayData( false ),
|
258 |
-
|
259 |
-
'classes' =>
|
260 |
'page_container' => 'page-insights page-'.$sNavSection
|
261 |
-
|
262 |
-
'flags' =>
|
263 |
'show_promo' => !$bIsPro,
|
264 |
'show_guided_tour' => $oModPlugin->getIfShowIntroVideo(),
|
265 |
-
|
266 |
-
'hrefs' =>
|
267 |
'go_pro' => 'https://icwp.io/shieldgoprofeature',
|
268 |
'nav_home' => $this->getUrl_AdminPage(),
|
269 |
'top_nav' => $aTopNav,
|
270 |
'img_banner' => $oCon->getPluginUrl_Image( 'pluginlogo_banner-170x40.png' )
|
271 |
-
|
272 |
'strings' => $this->getDisplayStrings(),
|
273 |
'vars' => [
|
274 |
'changelog_id' => $oCon->getPluginSpec()[ 'meta' ][ 'headway_changelog_id' ],
|
275 |
],
|
276 |
-
|
277 |
$aData
|
278 |
);
|
279 |
return $this->renderTemplate( sprintf( '/wpadmin_pages/insights_new/%s/index.twig', $sNavSection ), $aData, true );
|
@@ -285,7 +287,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
285 |
if ( $this->isThisModulePage() ) {
|
286 |
|
287 |
$oConn = $this->getCon();
|
288 |
-
$aStdDeps =
|
289 |
$sNav = Services::Request()->query( 'inav' );
|
290 |
switch ( $sNav ) {
|
291 |
|
@@ -368,7 +370,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
368 |
$sName = $this->getCon()->getHumanName();
|
369 |
return $this->loadDP()->mergeArraysRecursive(
|
370 |
parent::getDisplayStrings(),
|
371 |
-
|
372 |
'page_title' => sprintf( _wpsf__( '%s Security Insights' ), $sName ),
|
373 |
'recommendation' => ucfirst( _wpsf__( 'recommendation' ) ),
|
374 |
'suggestion' => ucfirst( _wpsf__( 'suggestion' ) ),
|
@@ -383,7 +385,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
383 |
'please_upgrade' => _wpsf__( 'You can activate this feature (along with many others) and support development of this plugin for just $12.' ),
|
384 |
'please_enable' => _wpsf__( 'Please turn on this feature in the options.' ),
|
385 |
'only_1_dollar' => _wpsf__( 'for just $1/month' ),
|
386 |
-
|
387 |
);
|
388 |
}
|
389 |
|
@@ -393,7 +395,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
393 |
protected function getInsightsModsSummary() {
|
394 |
$aMods = [];
|
395 |
foreach ( $this->getModulesSummaryData() as $aMod ) {
|
396 |
-
if ( !in_array( $aMod[ 'slug' ],
|
397 |
$aMods[] = $aMod;
|
398 |
}
|
399 |
}
|
@@ -404,7 +406,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
404 |
* @return array[]
|
405 |
*/
|
406 |
protected function getConfigCardsData() {
|
407 |
-
return apply_filters( $this->prefix( 'collect_summary' ),
|
408 |
}
|
409 |
|
410 |
/**
|
@@ -413,26 +415,26 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
413 |
protected function getNotices() {
|
414 |
$aAll = apply_filters(
|
415 |
$this->prefix( 'collect_notices' ),
|
416 |
-
|
417 |
'plugins' => $this->getNoticesPlugins(),
|
418 |
'themes' => $this->getNoticesThemes(),
|
419 |
'core' => $this->getNoticesCore(),
|
420 |
-
|
421 |
);
|
422 |
|
423 |
// order and then remove empties
|
424 |
return array_filter(
|
425 |
array_merge(
|
426 |
-
|
427 |
-
'site' =>
|
428 |
-
'sec_admin' =>
|
429 |
-
'scans' =>
|
430 |
-
'core' =>
|
431 |
-
'plugins' =>
|
432 |
-
'themes' =>
|
433 |
-
'users' =>
|
434 |
-
'lockdown' =>
|
435 |
-
|
436 |
$aAll
|
437 |
),
|
438 |
function ( $aSection ) {
|
@@ -444,10 +446,10 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
444 |
protected function getNoticesSite() {
|
445 |
$oSslService = $this->loadSslService();
|
446 |
|
447 |
-
$aNotices =
|
448 |
'title' => _wpsf__( 'Site' ),
|
449 |
-
'messages' =>
|
450 |
-
|
451 |
|
452 |
// SSL Expires
|
453 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
@@ -475,21 +477,21 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
475 |
$sMess = sprintf( _wpsf__( 'SSL certificate will expire soon (in %s days)' ), $nDaysLeft );
|
476 |
}
|
477 |
|
478 |
-
$aMessage =
|
479 |
'title' => 'SSL Cert Expiration',
|
480 |
'message' => $sMess,
|
481 |
'href' => '',
|
482 |
'rec' => _wpsf__( 'Check or renew your SSL certificate.' )
|
483 |
-
|
484 |
}
|
485 |
}
|
486 |
}
|
487 |
catch ( \Exception $oE ) {
|
488 |
-
$aMessage =
|
489 |
'title' => 'SSL Cert Expiration',
|
490 |
'message' => 'Failed to retrieve a valid SSL certificate.',
|
491 |
'href' => ''
|
492 |
-
|
493 |
}
|
494 |
|
495 |
if ( !empty( $aMessage ) ) {
|
@@ -500,12 +502,12 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
500 |
{ // db password strength
|
501 |
$nStrength = ( new \ZxcvbnPhp\Zxcvbn() )->passwordStrength( DB_PASSWORD )[ 'score' ];
|
502 |
if ( $nStrength < 4 ) {
|
503 |
-
$aNotices[ 'messages' ][ 'db_strength' ] =
|
504 |
'title' => 'DB Password',
|
505 |
'message' => _wpsf__( 'DB Password appears to be weak.' ),
|
506 |
'href' => '',
|
507 |
'rec' => _wpsf__( 'The database password should be strong.' )
|
508 |
-
|
509 |
}
|
510 |
}
|
511 |
|
@@ -518,34 +520,34 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
518 |
*/
|
519 |
protected function getNoticesPlugins() {
|
520 |
$oWpPlugins = $this->loadWpPlugins();
|
521 |
-
$aNotices =
|
522 |
'title' => _wpsf__( 'Plugins' ),
|
523 |
-
'messages' =>
|
524 |
-
|
525 |
|
526 |
{// Inactive
|
527 |
$nCount = count( $oWpPlugins->getPlugins() ) - count( $oWpPlugins->getActivePlugins() );
|
528 |
if ( $nCount > 0 ) {
|
529 |
-
$aNotices[ 'messages' ][ 'inactive' ] =
|
530 |
'title' => 'Inactive',
|
531 |
'message' => sprintf( _wpsf__( '%s inactive plugin(s)' ), $nCount ),
|
532 |
'href' => $this->loadWp()->getAdminUrl_Plugins( true ),
|
533 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Plugins' ) ),
|
534 |
'rec' => _wpsf__( 'Unused plugins should be removed.' )
|
535 |
-
|
536 |
}
|
537 |
}
|
538 |
|
539 |
{// updates
|
540 |
$nCount = count( $oWpPlugins->getUpdates() );
|
541 |
if ( $nCount > 0 ) {
|
542 |
-
$aNotices[ 'messages' ][ 'updates' ] =
|
543 |
'title' => 'Updates',
|
544 |
'message' => sprintf( _wpsf__( '%s plugin update(s)' ), $nCount ),
|
545 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
546 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
547 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
548 |
-
|
549 |
}
|
550 |
}
|
551 |
|
@@ -558,34 +560,34 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
558 |
*/
|
559 |
protected function getNoticesThemes() {
|
560 |
$oWpT = $this->loadWpThemes();
|
561 |
-
$aNotices =
|
562 |
'title' => _wpsf__( 'Themes' ),
|
563 |
-
'messages' =>
|
564 |
-
|
565 |
|
566 |
{// Inactive
|
567 |
$nInactive = count( $oWpT->getThemes() ) - ( $oWpT->isActiveThemeAChild() ? 2 : 1 );
|
568 |
if ( $nInactive > 0 ) {
|
569 |
-
$aNotices[ 'messages' ][ 'inactive' ] =
|
570 |
'title' => 'Inactive',
|
571 |
'message' => sprintf( _wpsf__( '%s inactive themes(s)' ), $nInactive ),
|
572 |
'href' => $this->loadWp()->getAdminUrl_Themes( true ),
|
573 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Themes' ) ),
|
574 |
'rec' => _wpsf__( 'Unused themes should be removed.' )
|
575 |
-
|
576 |
}
|
577 |
}
|
578 |
|
579 |
{// updates
|
580 |
$nCount = count( $oWpT->getUpdates() );
|
581 |
if ( $nCount > 0 ) {
|
582 |
-
$aNotices[ 'messages' ][ 'updates' ] =
|
583 |
'title' => 'Updates',
|
584 |
'message' => sprintf( _wpsf__( '%s theme update(s)' ), $nCount ),
|
585 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
586 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
587 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
588 |
-
|
589 |
}
|
590 |
}
|
591 |
|
@@ -598,32 +600,32 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
598 |
*/
|
599 |
protected function getNoticesCore() {
|
600 |
$oWp = $this->loadWp();
|
601 |
-
$aNotices =
|
602 |
'title' => _wpsf__( 'WordPress Core' ),
|
603 |
-
'messages' =>
|
604 |
-
|
605 |
|
606 |
{// updates
|
607 |
if ( $oWp->hasCoreUpdate() ) {
|
608 |
-
$aNotices[ 'messages' ][ 'updates' ] =
|
609 |
'title' => 'Updates',
|
610 |
'message' => _wpsf__( 'WordPress Core has an update available.' ),
|
611 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
612 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
613 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
614 |
-
|
615 |
}
|
616 |
}
|
617 |
|
618 |
{// autoupdates
|
619 |
if ( !$oWp->canCoreUpdateAutomatically() ) {
|
620 |
-
$aNotices[ 'messages' ][ 'updates_auto' ] =
|
621 |
'title' => 'Auto Updates',
|
622 |
'message' => _wpsf__( 'WordPress does not automatically install updates.' ),
|
623 |
'href' => $this->getCon()->getModule( 'autoupdates' )->getUrl_AdminPage(),
|
624 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
625 |
'rec' => _wpsf__( 'Minor WordPress upgrades should be applied automatically.' )
|
626 |
-
|
627 |
}
|
628 |
}
|
629 |
|
@@ -636,49 +638,47 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
636 |
*/
|
637 |
protected function getStats() {
|
638 |
$oConn = $this->getCon();
|
639 |
-
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oModUsers */
|
640 |
-
$oModUsers = $oConn->getModule( 'user_management' );
|
641 |
/** @var ICWP_WPSF_Processor_Statistics $oStats */
|
642 |
$oStats = $oConn->getModule( 'statistics' )->getProcessor();
|
643 |
|
644 |
/** @var ICWP_WPSF_Processor_Ips $oIPs */
|
645 |
$oIPs = $oConn->getModule( 'ips' )->getProcessor();
|
646 |
-
/** @var
|
647 |
$oSelect = $oIPs->getDbHandler()->getQuerySelector();
|
648 |
|
649 |
$aStats = $oStats->getInsightsStats();
|
650 |
-
return
|
651 |
-
'login' =>
|
652 |
'title' => _wpsf__( 'Login Blocks' ),
|
653 |
'val' => $aStats[ 'login.blocked.all' ],
|
654 |
'tooltip' => _wpsf__( 'Total login attempts blocked.' )
|
655 |
-
|
656 |
-
'firewall' =>
|
657 |
'title' => _wpsf__( 'Firewall Blocks' ),
|
658 |
'val' => $aStats[ 'firewall.blocked.all' ],
|
659 |
'tooltip' => _wpsf__( 'Total requests blocked by firewall rules.' )
|
660 |
-
|
661 |
-
'comments' =>
|
662 |
'title' => _wpsf__( 'Comment Blocks' ),
|
663 |
'val' => $aStats[ 'comments.blocked.all' ],
|
664 |
'tooltip' => _wpsf__( 'Total SPAM comments blocked.' )
|
665 |
-
|
666 |
// 'sessions' => array(
|
667 |
// 'title' => _wpsf__( 'Active Sessions' ),
|
668 |
// 'val' => $oProUsers->getProcessorSessions()->countActiveSessions(),
|
669 |
// 'tooltip' => _wpsf__( 'Currently active user sessions.' )
|
670 |
// ),
|
671 |
-
'transgressions' =>
|
672 |
'title' => _wpsf__( 'Transgressions' ),
|
673 |
'val' => $aStats[ 'ip.transgression.incremented' ],
|
674 |
'tooltip' => _wpsf__( 'Total transgression against the site.' )
|
675 |
-
|
676 |
-
'ip_blocks' =>
|
677 |
'title' => _wpsf__( 'IP Blocks' ),
|
678 |
'val' => $aStats[ 'ip.connection.killed' ],
|
679 |
'tooltip' => _wpsf__( 'Total connections blocked/killed after too many transgressions.' )
|
680 |
-
|
681 |
-
'blackips' =>
|
682 |
'title' => _wpsf__( 'Blacklist IPs' ),
|
683 |
'val' => $oSelect
|
684 |
->filterByLists(
|
@@ -688,34 +688,33 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
688 |
]
|
689 |
)->count(),
|
690 |
'tooltip' => _wpsf__( 'Current IP addresses with transgressions against the site.' )
|
691 |
-
|
692 |
// 'pro' => array(
|
693 |
// 'title' => _wpsf__( 'Pro' ),
|
694 |
// 'val' => $this->isPremium() ? _wpsf__( 'Yes' ) : _wpsf__( 'No' ),
|
695 |
// 'tooltip' => sprintf( _wpsf__( 'Is this site running %s Pro' ), $oConn->getHumanName() )
|
696 |
// ),
|
697 |
-
|
698 |
}
|
699 |
|
700 |
/**
|
701 |
* @return array
|
702 |
*/
|
703 |
protected function getRecentEvents() {
|
704 |
-
$oConn = $this->getCon();
|
705 |
|
706 |
-
$aStats =
|
707 |
-
foreach ( $
|
708 |
/** @var ICWP_WPSF_FeatureHandler_BaseWpsf $oModule */
|
709 |
$aStats = array_merge( $aStats, $oModule->getInsightsOpts() );
|
710 |
}
|
711 |
|
712 |
-
$oWP =
|
713 |
$aNames = $this->getInsightStatNames();
|
714 |
foreach ( $aStats as $sStatKey => $nValue ) {
|
715 |
-
$aStats[ $sStatKey ] =
|
716 |
'name' => $aNames[ $sStatKey ],
|
717 |
'val' => ( $nValue > 0 ) ? $oWP->getTimeStringForDisplay( $nValue ) : _wpsf__( 'Not yet recorded' ),
|
718 |
-
|
719 |
}
|
720 |
|
721 |
return $aStats;
|
@@ -725,7 +724,7 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
725 |
* @return string[]
|
726 |
*/
|
727 |
private function getInsightStatNames() {
|
728 |
-
return
|
729 |
'insights_test_cron_last_run_at' => _wpsf__( 'Simple Test Cron' ),
|
730 |
'insights_last_scan_ufc_at' => _wpsf__( 'Unrecognised Files Scan' ),
|
731 |
'insights_last_scan_apc_at' => _wpsf__( 'Abandoned Plugins Scan' ),
|
@@ -745,6 +744,6 @@ class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
745 |
'insights_last_transgression_at' => sprintf( _wpsf__( '%s Transgression' ), $this->getCon()
|
746 |
->getHumanName() ),
|
747 |
'insights_last_ip_block_at' => _wpsf__( 'IP Connection Blocked' ),
|
748 |
-
|
749 |
}
|
750 |
}
|
1 |
<?php
|
2 |
|
3 |
+
use FernleafSystems\Wordpress\Plugin\Shield;
|
4 |
use FernleafSystems\Wordpress\Services\Services;
|
5 |
|
6 |
class ICWP_WPSF_FeatureHandler_Insights extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
16 |
|
17 |
/**
|
18 |
* @param array $aData
|
19 |
+
* @return string
|
20 |
*/
|
21 |
protected function renderModulePage( $aData = [] ) {
|
22 |
$oCon = $this->getCon();
|
34 |
$oTrafficMod = $oCon->getModule( 'traffic' );
|
35 |
/** @var ICWP_WPSF_Processor_Traffic $oTrafficPro */
|
36 |
$oTrafficPro = $oTrafficMod->getProcessor();
|
37 |
+
/** @var Shield\Databases\Traffic\Select $oTrafficSelector */
|
38 |
$oTrafficSelector = $oTrafficPro->getProcessorLogger()
|
39 |
->getDbHandler()
|
40 |
->getQuerySelector();
|
43 |
$oAuditMod = $oCon->getModule( 'audit_trail' );
|
44 |
/** @var ICWP_WPSF_Processor_AuditTrail $oAuditPro */
|
45 |
$oAuditPro = $oAuditMod->getProcessor();
|
46 |
+
/** @var Shield\Databases\AuditTrail\Select $oAuditSelect */
|
47 |
$oAuditSelect = $oAuditPro->getSubProAuditor()->getDbHandler()->getQuerySelector();
|
48 |
|
49 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oIpMod */
|
51 |
|
52 |
/** @var ICWP_WPSF_Processor_Sessions $oProSessions */
|
53 |
$oProSessions = $oCon->getModule( 'sessions' )->getProcessor();
|
54 |
+
/** @var Shield\Databases\Session\Select $oSessionSelect */
|
55 |
$oSessionSelect = $oProSessions->getDbHandler()->getQuerySelector();
|
56 |
|
57 |
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oModUsers */
|
71 |
switch ( $sNavSection ) {
|
72 |
|
73 |
case 'audit':
|
74 |
+
$aData = [
|
75 |
+
'ajax' => [
|
76 |
'render_table_audittrail' => $oAuditMod->getAjaxActionData( 'render_table_audittrail', true ),
|
77 |
'item_addparamwhite' => $oAuditMod->getAjaxActionData( 'item_addparamwhite', true )
|
78 |
+
],
|
79 |
'flags' => [],
|
80 |
+
'strings' => [
|
81 |
'title_filter_form' => _wpsf__( 'Audit Trail Filters' ),
|
82 |
+
],
|
83 |
+
'vars' => [
|
84 |
'contexts_for_select' => $oAuditMod->getAllContexts(),
|
85 |
'unique_ips' => $oAuditSelect->getDistinctIps(),
|
86 |
'unique_users' => $oAuditSelect->getDistinctUsernames(),
|
87 |
+
],
|
88 |
+
];
|
89 |
break;
|
90 |
|
91 |
case 'ips':
|
92 |
+
$aData = [
|
93 |
+
'ajax' => [
|
94 |
'render_table_ip' => $oIpMod->getAjaxActionData( 'render_table_ip', true ),
|
95 |
'item_insert' => $oIpMod->getAjaxActionData( 'ip_insert', true ),
|
96 |
'item_delete' => $oIpMod->getAjaxActionData( 'ip_delete', true ),
|
97 |
+
],
|
98 |
+
'flags' => [
|
99 |
'can_blacklist' => $bIsPro
|
100 |
+
],
|
101 |
+
'strings' => [
|
102 |
'trans_limit' => sprintf(
|
103 |
'Transgressions required for IP block: %s',
|
104 |
sprintf( '<a href="%s" target="_blank">%s</a>', $oIpMod->getUrl_DirectLinkToOption( 'transgression_limit' ), $oIpMod->getOptTransgressionLimit() )
|
115 |
'title_blacklist' => _wpsf__( 'IP Blacklist' ),
|
116 |
'summary_whitelist' => sprintf( _wpsf__( 'IP addresses that are never blocked by %s.' ), $nPluginName ),
|
117 |
'summary_blacklist' => sprintf( _wpsf__( 'IP addresses that have tripped %s defenses.' ), $nPluginName ),
|
118 |
+
],
|
119 |
'vars' => [],
|
120 |
+
];
|
121 |
break;
|
122 |
|
123 |
case 'notes':
|
124 |
+
$aData = [
|
125 |
'vars' => [],
|
126 |
+
'ajax' => [
|
127 |
'render_table_adminnotes' => $oModPlugin->getAjaxActionData( 'render_table_adminnotes', true ),
|
128 |
'item_delete' => $oModPlugin->getAjaxActionData( 'note_delete', true ),
|
129 |
'item_insert' => $oModPlugin->getAjaxActionData( 'note_insert', true ),
|
130 |
'bulk_action' => $oModPlugin->getAjaxActionData( 'bulk_action', true ),
|
131 |
+
],
|
132 |
+
'flags' => [
|
133 |
'can_adminnotes' => $bIsPro,
|
134 |
+
]
|
135 |
+
];
|
136 |
break;
|
137 |
|
138 |
case 'traffic':
|
139 |
+
$aData = [
|
140 |
+
'ajax' => [
|
141 |
'render_table_traffic' => $oTrafficMod->getAjaxActionData( 'render_table_traffic', true )
|
142 |
+
],
|
143 |
+
'flags' => [
|
144 |
'can_traffic' => $bIsPro,
|
145 |
'is_enabled' => $oTrafficMod->isModOptEnabled(),
|
146 |
+
],
|
147 |
+
'hrefs' => [
|
148 |
'please_enable' => $oTrafficMod->getUrl_DirectLinkToOption( 'enable_traffic' ),
|
149 |
+
],
|
150 |
+
'strings' => [
|
151 |
'title_filter_form' => _wpsf__( 'Traffic Table Filters' ),
|
152 |
+
],
|
153 |
+
'vars' => [
|
154 |
'unique_ips' => $oTrafficSelector->getDistinctIps(),
|
155 |
'unique_responses' => $oTrafficSelector->getDistinctCodes(),
|
156 |
'unique_users' => $oTrafficSelector->getDistinctUsernames(),
|
157 |
+
],
|
158 |
+
];
|
159 |
break;
|
160 |
|
161 |
case 'license':
|
171 |
break;
|
172 |
|
173 |
case 'users':
|
174 |
+
$aData = [
|
175 |
+
'ajax' => [
|
176 |
'render_table_sessions' => $oModUsers->getAjaxActionData( 'render_table_sessions', true ),
|
177 |
'item_delete' => $oModUsers->getAjaxActionData( 'session_delete', true ),
|
178 |
'bulk_action' => $oModUsers->getAjaxActionData( 'bulk_action', true ),
|
179 |
|
180 |
+
],
|
181 |
'flags' => [],
|
182 |
+
'strings' => [
|
183 |
'title_filter_form' => _wpsf__( 'Sessions Table Filters' ),
|
184 |
+
],
|
185 |
+
'vars' => [
|
186 |
'unique_ips' => $oSessionSelect->getDistinctIps(),
|
187 |
'unique_users' => $oSessionSelect->getDistinctUsernames(),
|
188 |
+
],
|
189 |
+
];
|
190 |
break;
|
191 |
|
192 |
case 'insights':
|
193 |
case 'index':
|
194 |
default:
|
195 |
$sNavSection = 'insights';
|
196 |
+
$aData = [
|
197 |
+
'vars' => [
|
198 |
'config_cards' => $this->getConfigCardsData(),
|
199 |
'summary' => $this->getInsightsModsSummary(),
|
200 |
'insight_events' => $this->getRecentEvents(),
|
201 |
'insight_notices' => $aSecNotices,
|
202 |
'insight_notices_count' => $nNoticesCount,
|
203 |
'insight_stats' => $this->getStats(),
|
204 |
+
],
|
205 |
+
'inputs' => [
|
206 |
+
'license_key' => [
|
207 |
'name' => $this->prefixOptionKey( 'license_key' ),
|
208 |
'maxlength' => $this->getDef( 'license_key_length' ),
|
209 |
+
]
|
210 |
+
],
|
211 |
'ajax' => [],
|
212 |
+
'hrefs' => [
|
213 |
'shield_pro_url' => 'https://icwp.io/shieldpro',
|
214 |
'shield_pro_more_info_url' => 'https://icwp.io/shld1',
|
215 |
+
],
|
216 |
+
'flags' => [
|
217 |
'show_ads' => false,
|
218 |
'show_standard_options' => false,
|
219 |
'show_alt_content' => true,
|
220 |
'is_pro' => $bIsPro,
|
221 |
'has_notices' => count( $aSecNotices ) > 0,
|
222 |
+
],
|
223 |
+
];
|
224 |
break;
|
225 |
}
|
226 |
|
227 |
+
$aTopNav = [
|
228 |
'insights' => _wpsf__( 'Overview' ),
|
229 |
'scans' => _wpsf__( 'Scans' ),
|
230 |
'ips' => _wpsf__( 'IP Lists' ),
|
234 |
'traffic' => _wpsf__( 'Traffic' ),
|
235 |
'notes' => _wpsf__( 'Notes' ),
|
236 |
'importexport' => sprintf( '%s/%s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) ),
|
237 |
+
];
|
238 |
if ( $bIsPro ) {
|
239 |
unset( $aTopNav[ 'license' ] );
|
240 |
$aTopNav[ 'license' ] = _wpsf__( 'Pro' );
|
241 |
}
|
242 |
|
243 |
array_walk( $aTopNav, function ( &$sName, $sKey ) use ( $sNavSection ) {
|
244 |
+
$sName = [
|
245 |
'href' => add_query_arg( [ 'inav' => $sKey ], $this->getUrl_AdminPage() ),
|
246 |
'name' => $sName,
|
247 |
'active' => $sKey === $sNavSection
|
248 |
+
];
|
249 |
} );
|
250 |
|
251 |
+
$aTopNav[ 'full_options' ] = [
|
252 |
'href' => $this->getCon()->getModule( 'plugin' )->getUrl_AdminPage(),
|
253 |
'name' => _wpsf__( 'Settings' ),
|
254 |
'active' => false
|
255 |
+
];
|
256 |
|
257 |
$oDp = Services::DataManipulation();
|
258 |
$aData = $oDp->mergeArraysRecursive(
|
259 |
$this->getBaseDisplayData( false ),
|
260 |
+
[
|
261 |
+
'classes' => [
|
262 |
'page_container' => 'page-insights page-'.$sNavSection
|
263 |
+
],
|
264 |
+
'flags' => [
|
265 |
'show_promo' => !$bIsPro,
|
266 |
'show_guided_tour' => $oModPlugin->getIfShowIntroVideo(),
|
267 |
+
],
|
268 |
+
'hrefs' => [
|
269 |
'go_pro' => 'https://icwp.io/shieldgoprofeature',
|
270 |
'nav_home' => $this->getUrl_AdminPage(),
|
271 |
'top_nav' => $aTopNav,
|
272 |
'img_banner' => $oCon->getPluginUrl_Image( 'pluginlogo_banner-170x40.png' )
|
273 |
+
],
|
274 |
'strings' => $this->getDisplayStrings(),
|
275 |
'vars' => [
|
276 |
'changelog_id' => $oCon->getPluginSpec()[ 'meta' ][ 'headway_changelog_id' ],
|
277 |
],
|
278 |
+
],
|
279 |
$aData
|
280 |
);
|
281 |
return $this->renderTemplate( sprintf( '/wpadmin_pages/insights_new/%s/index.twig', $sNavSection ), $aData, true );
|
287 |
if ( $this->isThisModulePage() ) {
|
288 |
|
289 |
$oConn = $this->getCon();
|
290 |
+
$aStdDeps = [ $this->prefix( 'plugin' ) ];
|
291 |
$sNav = Services::Request()->query( 'inav' );
|
292 |
switch ( $sNav ) {
|
293 |
|
370 |
$sName = $this->getCon()->getHumanName();
|
371 |
return $this->loadDP()->mergeArraysRecursive(
|
372 |
parent::getDisplayStrings(),
|
373 |
+
[
|
374 |
'page_title' => sprintf( _wpsf__( '%s Security Insights' ), $sName ),
|
375 |
'recommendation' => ucfirst( _wpsf__( 'recommendation' ) ),
|
376 |
'suggestion' => ucfirst( _wpsf__( 'suggestion' ) ),
|
385 |
'please_upgrade' => _wpsf__( 'You can activate this feature (along with many others) and support development of this plugin for just $12.' ),
|
386 |
'please_enable' => _wpsf__( 'Please turn on this feature in the options.' ),
|
387 |
'only_1_dollar' => _wpsf__( 'for just $1/month' ),
|
388 |
+
]
|
389 |
);
|
390 |
}
|
391 |
|
395 |
protected function getInsightsModsSummary() {
|
396 |
$aMods = [];
|
397 |
foreach ( $this->getModulesSummaryData() as $aMod ) {
|
398 |
+
if ( !in_array( $aMod[ 'slug' ], [ 'insights' ] ) ) {
|
399 |
$aMods[] = $aMod;
|
400 |
}
|
401 |
}
|
406 |
* @return array[]
|
407 |
*/
|
408 |
protected function getConfigCardsData() {
|
409 |
+
return apply_filters( $this->prefix( 'collect_summary' ), [] );
|
410 |
}
|
411 |
|
412 |
/**
|
415 |
protected function getNotices() {
|
416 |
$aAll = apply_filters(
|
417 |
$this->prefix( 'collect_notices' ),
|
418 |
+
[
|
419 |
'plugins' => $this->getNoticesPlugins(),
|
420 |
'themes' => $this->getNoticesThemes(),
|
421 |
'core' => $this->getNoticesCore(),
|
422 |
+
]
|
423 |
);
|
424 |
|
425 |
// order and then remove empties
|
426 |
return array_filter(
|
427 |
array_merge(
|
428 |
+
[
|
429 |
+
'site' => [],
|
430 |
+
'sec_admin' => [],
|
431 |
+
'scans' => [],
|
432 |
+
'core' => [],
|
433 |
+
'plugins' => [],
|
434 |
+
'themes' => [],
|
435 |
+
'users' => [],
|
436 |
+
'lockdown' => [],
|
437 |
+
],
|
438 |
$aAll
|
439 |
),
|
440 |
function ( $aSection ) {
|
446 |
protected function getNoticesSite() {
|
447 |
$oSslService = $this->loadSslService();
|
448 |
|
449 |
+
$aNotices = [
|
450 |
'title' => _wpsf__( 'Site' ),
|
451 |
+
'messages' => []
|
452 |
+
];
|
453 |
|
454 |
// SSL Expires
|
455 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
477 |
$sMess = sprintf( _wpsf__( 'SSL certificate will expire soon (in %s days)' ), $nDaysLeft );
|
478 |
}
|
479 |
|
480 |
+
$aMessage = [
|
481 |
'title' => 'SSL Cert Expiration',
|
482 |
'message' => $sMess,
|
483 |
'href' => '',
|
484 |
'rec' => _wpsf__( 'Check or renew your SSL certificate.' )
|
485 |
+
];
|
486 |
}
|
487 |
}
|
488 |
}
|
489 |
catch ( \Exception $oE ) {
|
490 |
+
$aMessage = [
|
491 |
'title' => 'SSL Cert Expiration',
|
492 |
'message' => 'Failed to retrieve a valid SSL certificate.',
|
493 |
'href' => ''
|
494 |
+
];
|
495 |
}
|
496 |
|
497 |
if ( !empty( $aMessage ) ) {
|
502 |
{ // db password strength
|
503 |
$nStrength = ( new \ZxcvbnPhp\Zxcvbn() )->passwordStrength( DB_PASSWORD )[ 'score' ];
|
504 |
if ( $nStrength < 4 ) {
|
505 |
+
$aNotices[ 'messages' ][ 'db_strength' ] = [
|
506 |
'title' => 'DB Password',
|
507 |
'message' => _wpsf__( 'DB Password appears to be weak.' ),
|
508 |
'href' => '',
|
509 |
'rec' => _wpsf__( 'The database password should be strong.' )
|
510 |
+
];
|
511 |
}
|
512 |
}
|
513 |
|
520 |
*/
|
521 |
protected function getNoticesPlugins() {
|
522 |
$oWpPlugins = $this->loadWpPlugins();
|
523 |
+
$aNotices = [
|
524 |
'title' => _wpsf__( 'Plugins' ),
|
525 |
+
'messages' => []
|
526 |
+
];
|
527 |
|
528 |
{// Inactive
|
529 |
$nCount = count( $oWpPlugins->getPlugins() ) - count( $oWpPlugins->getActivePlugins() );
|
530 |
if ( $nCount > 0 ) {
|
531 |
+
$aNotices[ 'messages' ][ 'inactive' ] = [
|
532 |
'title' => 'Inactive',
|
533 |
'message' => sprintf( _wpsf__( '%s inactive plugin(s)' ), $nCount ),
|
534 |
'href' => $this->loadWp()->getAdminUrl_Plugins( true ),
|
535 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Plugins' ) ),
|
536 |
'rec' => _wpsf__( 'Unused plugins should be removed.' )
|
537 |
+
];
|
538 |
}
|
539 |
}
|
540 |
|
541 |
{// updates
|
542 |
$nCount = count( $oWpPlugins->getUpdates() );
|
543 |
if ( $nCount > 0 ) {
|
544 |
+
$aNotices[ 'messages' ][ 'updates' ] = [
|
545 |
'title' => 'Updates',
|
546 |
'message' => sprintf( _wpsf__( '%s plugin update(s)' ), $nCount ),
|
547 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
548 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
549 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
550 |
+
];
|
551 |
}
|
552 |
}
|
553 |
|
560 |
*/
|
561 |
protected function getNoticesThemes() {
|
562 |
$oWpT = $this->loadWpThemes();
|
563 |
+
$aNotices = [
|
564 |
'title' => _wpsf__( 'Themes' ),
|
565 |
+
'messages' => []
|
566 |
+
];
|
567 |
|
568 |
{// Inactive
|
569 |
$nInactive = count( $oWpT->getThemes() ) - ( $oWpT->isActiveThemeAChild() ? 2 : 1 );
|
570 |
if ( $nInactive > 0 ) {
|
571 |
+
$aNotices[ 'messages' ][ 'inactive' ] = [
|
572 |
'title' => 'Inactive',
|
573 |
'message' => sprintf( _wpsf__( '%s inactive themes(s)' ), $nInactive ),
|
574 |
'href' => $this->loadWp()->getAdminUrl_Themes( true ),
|
575 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Themes' ) ),
|
576 |
'rec' => _wpsf__( 'Unused themes should be removed.' )
|
577 |
+
];
|
578 |
}
|
579 |
}
|
580 |
|
581 |
{// updates
|
582 |
$nCount = count( $oWpT->getUpdates() );
|
583 |
if ( $nCount > 0 ) {
|
584 |
+
$aNotices[ 'messages' ][ 'updates' ] = [
|
585 |
'title' => 'Updates',
|
586 |
'message' => sprintf( _wpsf__( '%s theme update(s)' ), $nCount ),
|
587 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
588 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
589 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
590 |
+
];
|
591 |
}
|
592 |
}
|
593 |
|
600 |
*/
|
601 |
protected function getNoticesCore() {
|
602 |
$oWp = $this->loadWp();
|
603 |
+
$aNotices = [
|
604 |
'title' => _wpsf__( 'WordPress Core' ),
|
605 |
+
'messages' => []
|
606 |
+
];
|
607 |
|
608 |
{// updates
|
609 |
if ( $oWp->hasCoreUpdate() ) {
|
610 |
+
$aNotices[ 'messages' ][ 'updates' ] = [
|
611 |
'title' => 'Updates',
|
612 |
'message' => _wpsf__( 'WordPress Core has an update available.' ),
|
613 |
'href' => $this->loadWp()->getAdminUrl_Updates( true ),
|
614 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Updates' ) ),
|
615 |
'rec' => _wpsf__( 'Updates should be applied as early as possible.' )
|
616 |
+
];
|
617 |
}
|
618 |
}
|
619 |
|
620 |
{// autoupdates
|
621 |
if ( !$oWp->canCoreUpdateAutomatically() ) {
|
622 |
+
$aNotices[ 'messages' ][ 'updates_auto' ] = [
|
623 |
'title' => 'Auto Updates',
|
624 |
'message' => _wpsf__( 'WordPress does not automatically install updates.' ),
|
625 |
'href' => $this->getCon()->getModule( 'autoupdates' )->getUrl_AdminPage(),
|
626 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
627 |
'rec' => _wpsf__( 'Minor WordPress upgrades should be applied automatically.' )
|
628 |
+
];
|
629 |
}
|
630 |
}
|
631 |
|
638 |
*/
|
639 |
protected function getStats() {
|
640 |
$oConn = $this->getCon();
|
|
|
|
|
641 |
/** @var ICWP_WPSF_Processor_Statistics $oStats */
|
642 |
$oStats = $oConn->getModule( 'statistics' )->getProcessor();
|
643 |
|
644 |
/** @var ICWP_WPSF_Processor_Ips $oIPs */
|
645 |
$oIPs = $oConn->getModule( 'ips' )->getProcessor();
|
646 |
+
/** @var Shield\Databases\IPs\Select $oSelect */
|
647 |
$oSelect = $oIPs->getDbHandler()->getQuerySelector();
|
648 |
|
649 |
$aStats = $oStats->getInsightsStats();
|
650 |
+
return [
|
651 |
+
'login' => [
|
652 |
'title' => _wpsf__( 'Login Blocks' ),
|
653 |
'val' => $aStats[ 'login.blocked.all' ],
|
654 |
'tooltip' => _wpsf__( 'Total login attempts blocked.' )
|
655 |
+
],
|
656 |
+
'firewall' => [
|
657 |
'title' => _wpsf__( 'Firewall Blocks' ),
|
658 |
'val' => $aStats[ 'firewall.blocked.all' ],
|
659 |
'tooltip' => _wpsf__( 'Total requests blocked by firewall rules.' )
|
660 |
+
],
|
661 |
+
'comments' => [
|
662 |
'title' => _wpsf__( 'Comment Blocks' ),
|
663 |
'val' => $aStats[ 'comments.blocked.all' ],
|
664 |
'tooltip' => _wpsf__( 'Total SPAM comments blocked.' )
|
665 |
+
],
|
666 |
// 'sessions' => array(
|
667 |
// 'title' => _wpsf__( 'Active Sessions' ),
|
668 |
// 'val' => $oProUsers->getProcessorSessions()->countActiveSessions(),
|
669 |
// 'tooltip' => _wpsf__( 'Currently active user sessions.' )
|
670 |
// ),
|
671 |
+
'transgressions' => [
|
672 |
'title' => _wpsf__( 'Transgressions' ),
|
673 |
'val' => $aStats[ 'ip.transgression.incremented' ],
|
674 |
'tooltip' => _wpsf__( 'Total transgression against the site.' )
|
675 |
+
],
|
676 |
+
'ip_blocks' => [
|
677 |
'title' => _wpsf__( 'IP Blocks' ),
|
678 |
'val' => $aStats[ 'ip.connection.killed' ],
|
679 |
'tooltip' => _wpsf__( 'Total connections blocked/killed after too many transgressions.' )
|
680 |
+
],
|
681 |
+
'blackips' => [
|
682 |
'title' => _wpsf__( 'Blacklist IPs' ),
|
683 |
'val' => $oSelect
|
684 |
->filterByLists(
|
688 |
]
|
689 |
)->count(),
|
690 |
'tooltip' => _wpsf__( 'Current IP addresses with transgressions against the site.' )
|
691 |
+
],
|
692 |
// 'pro' => array(
|
693 |
// 'title' => _wpsf__( 'Pro' ),
|
694 |
// 'val' => $this->isPremium() ? _wpsf__( 'Yes' ) : _wpsf__( 'No' ),
|
695 |
// 'tooltip' => sprintf( _wpsf__( 'Is this site running %s Pro' ), $oConn->getHumanName() )
|
696 |
// ),
|
697 |
+
];
|
698 |
}
|
699 |
|
700 |
/**
|
701 |
* @return array
|
702 |
*/
|
703 |
protected function getRecentEvents() {
|
|
|
704 |
|
705 |
+
$aStats = [];
|
706 |
+
foreach ( $this->getCon()->getModules() as $oModule ) {
|
707 |
/** @var ICWP_WPSF_FeatureHandler_BaseWpsf $oModule */
|
708 |
$aStats = array_merge( $aStats, $oModule->getInsightsOpts() );
|
709 |
}
|
710 |
|
711 |
+
$oWP = Services::WpGeneral();
|
712 |
$aNames = $this->getInsightStatNames();
|
713 |
foreach ( $aStats as $sStatKey => $nValue ) {
|
714 |
+
$aStats[ $sStatKey ] = [
|
715 |
'name' => $aNames[ $sStatKey ],
|
716 |
'val' => ( $nValue > 0 ) ? $oWP->getTimeStringForDisplay( $nValue ) : _wpsf__( 'Not yet recorded' ),
|
717 |
+
];
|
718 |
}
|
719 |
|
720 |
return $aStats;
|
724 |
* @return string[]
|
725 |
*/
|
726 |
private function getInsightStatNames() {
|
727 |
+
return [
|
728 |
'insights_test_cron_last_run_at' => _wpsf__( 'Simple Test Cron' ),
|
729 |
'insights_last_scan_ufc_at' => _wpsf__( 'Unrecognised Files Scan' ),
|
730 |
'insights_last_scan_apc_at' => _wpsf__( 'Abandoned Plugins Scan' ),
|
744 |
'insights_last_transgression_at' => sprintf( _wpsf__( '%s Transgression' ), $this->getCon()
|
745 |
->getHumanName() ),
|
746 |
'insights_last_ip_block_at' => _wpsf__( 'IP Connection Blocked' ),
|
747 |
+
];
|
748 |
}
|
749 |
}
|
@@ -9,12 +9,6 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
9 |
const LIST_MANUAL_BLACK = 'MB';
|
10 |
const LIST_AUTO_BLACK = 'AB';
|
11 |
|
12 |
-
protected function updateHandler() {
|
13 |
-
if ( $this->isOpt( 'track_404', 'assign-transgression' ) ) {
|
14 |
-
$this->setOpt( 'track_404', 'transgression-single' ); // fix for older options values
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
/**
|
19 |
* @return bool
|
20 |
*/
|
@@ -89,10 +83,10 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
89 |
$sMessage = _wpsf__( "IP address wasn't deleted from the list" );
|
90 |
}
|
91 |
|
92 |
-
return
|
93 |
'success' => $bSuccess,
|
94 |
'message' => $sMessage,
|
95 |
-
|
96 |
}
|
97 |
|
98 |
protected function ajaxExec_AddIp() {
|
@@ -162,10 +156,10 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
162 |
}
|
163 |
}
|
164 |
|
165 |
-
return
|
166 |
'success' => $bSuccess,
|
167 |
'message' => $sMessage,
|
168 |
-
|
169 |
}
|
170 |
|
171 |
/**
|
@@ -182,14 +176,14 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
182 |
->setMod( $this )
|
183 |
->setDbHandler( $oPro->getDbHandler() );
|
184 |
|
185 |
-
return
|
186 |
'success' => true,
|
187 |
'html' => $oTableBuilder->buildTable()
|
188 |
-
|
189 |
}
|
190 |
|
191 |
protected function doExtraSubmitProcessing() {
|
192 |
-
if ( !in_array( $this->getOpt( 'auto_expire' ),
|
193 |
$this->getOptionsVo()->resetOptToDefault( 'auto_expire' );
|
194 |
}
|
195 |
|
@@ -410,32 +404,32 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
410 |
|
411 |
case 'section_enable_plugin_feature_ips' :
|
412 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
413 |
-
$aSummary =
|
414 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The IP Manager allows you to whitelist, blacklist and configure auto-blacklist rules.' ) ),
|
415 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'IP Manager' ) ) )
|
416 |
.'<br />'._wpsf__( 'You should also carefully review the automatic black list settings.' )
|
417 |
-
|
418 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
419 |
break;
|
420 |
|
421 |
case 'section_auto_black_list' :
|
422 |
$sTitle = _wpsf__( 'Auto IP Blocking Rules' );
|
423 |
$sTitleShort = _wpsf__( 'Auto IP Blocking Rules' );
|
424 |
-
$aSummary =
|
425 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Automatic IP Black List system will block the IP addresses of naughty visitors after a specified number of transgressions.' ) ),
|
426 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Automatic IP Black List' ) ) ),
|
427 |
_wpsf__( "Think of 'transgressions' as just a counter for the number of times a visitor does something bad." )
|
428 |
.' '.sprintf( _wpsf__( 'When the counter reaches the limit below (default: 10), %s will block that completely IP.' ), $sName )
|
429 |
-
|
430 |
break;
|
431 |
|
432 |
case 'section_enable_plugin_feature_bottrap' :
|
433 |
$sTitle = _wpsf__( 'Identify And Capture Bots Based On Their Site Activity' );
|
434 |
-
$aSummary =
|
435 |
_wpsf__( "A bot doesn't know what's real and what's not, so it probes many different avenues until it finds something it recognises." ),
|
436 |
_wpsf__( "Bot-Trap monitors a set of typical bot behaviours to help identify probing bots." ),
|
437 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable as many mouse traps as possible.' ) )
|
438 |
-
|
439 |
$sTitleShort = _wpsf__( 'Bot-Trap' );
|
440 |
break;
|
441 |
|
@@ -666,8 +660,8 @@ class ICWP_WPSF_FeatureHandler_Ips extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
|
666 |
}
|
667 |
|
668 |
/**
|
669 |
-
* @deprecated
|
670 |
* @return bool
|
|
|
671 |
*/
|
672 |
public function isAutoBlackListFeatureEnabled() {
|
673 |
return $this->isAutoBlackListEnabled();
|
9 |
const LIST_MANUAL_BLACK = 'MB';
|
10 |
const LIST_AUTO_BLACK = 'AB';
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @return bool
|
14 |
*/
|
83 |
$sMessage = _wpsf__( "IP address wasn't deleted from the list" );
|
84 |
}
|
85 |
|
86 |
+
return [
|
87 |
'success' => $bSuccess,
|
88 |
'message' => $sMessage,
|
89 |
+
];
|
90 |
}
|
91 |
|
92 |
protected function ajaxExec_AddIp() {
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
return [
|
160 |
'success' => $bSuccess,
|
161 |
'message' => $sMessage,
|
162 |
+
];
|
163 |
}
|
164 |
|
165 |
/**
|
176 |
->setMod( $this )
|
177 |
->setDbHandler( $oPro->getDbHandler() );
|
178 |
|
179 |
+
return [
|
180 |
'success' => true,
|
181 |
'html' => $oTableBuilder->buildTable()
|
182 |
+
];
|
183 |
}
|
184 |
|
185 |
protected function doExtraSubmitProcessing() {
|
186 |
+
if ( !in_array( $this->getOpt( 'auto_expire' ), [ 'minute', 'hour', 'day', 'week' ] ) ) {
|
187 |
$this->getOptionsVo()->resetOptToDefault( 'auto_expire' );
|
188 |
}
|
189 |
|
404 |
|
405 |
case 'section_enable_plugin_feature_ips' :
|
406 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
407 |
+
$aSummary = [
|
408 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The IP Manager allows you to whitelist, blacklist and configure auto-blacklist rules.' ) ),
|
409 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'IP Manager' ) ) )
|
410 |
.'<br />'._wpsf__( 'You should also carefully review the automatic black list settings.' )
|
411 |
+
];
|
412 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
413 |
break;
|
414 |
|
415 |
case 'section_auto_black_list' :
|
416 |
$sTitle = _wpsf__( 'Auto IP Blocking Rules' );
|
417 |
$sTitleShort = _wpsf__( 'Auto IP Blocking Rules' );
|
418 |
+
$aSummary = [
|
419 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'The Automatic IP Black List system will block the IP addresses of naughty visitors after a specified number of transgressions.' ) ),
|
420 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Automatic IP Black List' ) ) ),
|
421 |
_wpsf__( "Think of 'transgressions' as just a counter for the number of times a visitor does something bad." )
|
422 |
.' '.sprintf( _wpsf__( 'When the counter reaches the limit below (default: 10), %s will block that completely IP.' ), $sName )
|
423 |
+
];
|
424 |
break;
|
425 |
|
426 |
case 'section_enable_plugin_feature_bottrap' :
|
427 |
$sTitle = _wpsf__( 'Identify And Capture Bots Based On Their Site Activity' );
|
428 |
+
$aSummary = [
|
429 |
_wpsf__( "A bot doesn't know what's real and what's not, so it probes many different avenues until it finds something it recognises." ),
|
430 |
_wpsf__( "Bot-Trap monitors a set of typical bot behaviours to help identify probing bots." ),
|
431 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enable as many mouse traps as possible.' ) )
|
432 |
+
];
|
433 |
$sTitleShort = _wpsf__( 'Bot-Trap' );
|
434 |
break;
|
435 |
|
660 |
}
|
661 |
|
662 |
/**
|
|
|
663 |
* @return bool
|
664 |
+
* @deprecated
|
665 |
*/
|
666 |
public function isAutoBlackListFeatureEnabled() {
|
667 |
return $this->isAutoBlackListEnabled();
|
@@ -36,7 +36,7 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
36 |
protected function getDisplayStrings() {
|
37 |
return Services::DataManipulation()->mergeArraysRecursive(
|
38 |
parent::getDisplayStrings(),
|
39 |
-
|
40 |
'product_name' => _wpsf__( 'Name' ),
|
41 |
'license_active' => _wpsf__( 'Active' ),
|
42 |
'license_status' => _wpsf__( 'Status' ),
|
@@ -45,7 +45,7 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
45 |
'license_email' => _wpsf__( 'Owner' ),
|
46 |
'last_checked' => _wpsf__( 'Checked' ),
|
47 |
'last_errors' => _wpsf__( 'Error' ),
|
48 |
-
|
49 |
);
|
50 |
}
|
51 |
|
@@ -138,10 +138,10 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
138 |
$this->deactivate( 'User submitted deactivation' );
|
139 |
}
|
140 |
|
141 |
-
return
|
142 |
'success' => $bSuccess,
|
143 |
'message' => $sMessage,
|
144 |
-
|
145 |
}
|
146 |
|
147 |
/**
|
@@ -325,11 +325,11 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
325 |
|
326 |
if ( $bCanSend ) {
|
327 |
$this->setOptAt( 'last_warning_email_sent_at' )->savePluginOptions();
|
328 |
-
$aMessage =
|
329 |
_wpsf__( 'Attempts to verify Shield Pro license has just failed.' ),
|
330 |
sprintf( _wpsf__( 'Please check your license on-site: %s' ), $this->getUrl_AdminPage() ),
|
331 |
sprintf( _wpsf__( 'If this problem persists, please contact support: %s' ), 'https://support.onedollarplugin.com/' )
|
332 |
-
|
333 |
$this->getEmailProcessor()
|
334 |
->sendEmailWithWrap(
|
335 |
$this->getPluginDefaultRecipientAddress(),
|
@@ -346,11 +346,11 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
346 |
|
347 |
if ( ( $nNow - $this->getOpt( 'last_deactivated_email_sent_at' ) ) > DAY_IN_SECONDS ) {
|
348 |
$this->setOptAt( 'last_deactivated_email_sent_at' )->savePluginOptions();
|
349 |
-
$aMessage =
|
350 |
_wpsf__( 'All attempts to verify Shield Pro license have failed.' ),
|
351 |
sprintf( _wpsf__( 'Please check your license on-site: %s' ), $this->getUrl_AdminPage() ),
|
352 |
sprintf( _wpsf__( 'If this problem persists, please contact support: %s' ), 'https://support.onedollarplugin.com/' )
|
353 |
-
|
354 |
$this->getEmailProcessor()
|
355 |
->sendEmailWithWrap(
|
356 |
$this->getPluginDefaultRecipientAddress(),
|
@@ -372,7 +372,7 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
372 |
->savePluginOptions();
|
373 |
|
374 |
$oLicense = $this->loadEdd()
|
375 |
-
->setRequestParams(
|
376 |
->activateLicenseKeyless( $this->getLicenseStoreUrl(), $this->getLicenseItemId() );
|
377 |
|
378 |
// clear the handshake data
|
@@ -656,39 +656,39 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
656 |
$sChecked = $oCarbon->setTimestamp( $nLastReqAt )->diffForHumans()
|
657 |
.sprintf( '<br/><small>%s</small>', $oWp->getTimeStampForDisplay( $nLastReqAt ) );
|
658 |
}
|
659 |
-
$aLicenseTableVars =
|
660 |
'product_name' => $this->getLicenseItemName(),
|
661 |
'license_active' => $this->hasValidWorkingLicense() ? _wpsf__( 'Yes' ) : _wpsf__( 'Not Active' ),
|
662 |
'license_expires' => $sExpiresAt,
|
663 |
'license_email' => $oCurrent->getCustomerEmail(),
|
664 |
'last_checked' => $sChecked,
|
665 |
'last_errors' => $this->hasLastErrors() ? $this->getLastErrors() : ''
|
666 |
-
|
667 |
if ( !$this->isKeyless() ) {
|
668 |
$aLicenseTableVars[ 'license_key' ] = $this->hasLicenseKey() ? $this->getLicenseKey() : 'n/a';
|
669 |
}
|
670 |
-
$aData =
|
671 |
-
'vars' =>
|
672 |
'license_table' => $aLicenseTableVars,
|
673 |
'activation_url' => $oWp->getHomeUrl()
|
674 |
-
|
675 |
-
'inputs' =>
|
676 |
-
'license_key' =>
|
677 |
'name' => $this->prefixOptionKey( 'license_key' ),
|
678 |
'maxlength' => $this->getDef( 'license_key_length' ),
|
679 |
-
|
680 |
-
|
681 |
-
'ajax' =>
|
682 |
'license_handling' => $this->getAjaxActionData( 'license_handling' ),
|
683 |
'connection_debug' => $this->getAjaxActionData( 'connection_debug' )
|
684 |
-
|
685 |
-
'aHrefs' =>
|
686 |
'shield_pro_url' => 'https://icwp.io/shieldpro',
|
687 |
'shield_pro_more_info_url' => 'https://icwp.io/shld1',
|
688 |
'iframe_url' => $this->getDef( 'landing_page_url' ),
|
689 |
'keyless_cp' => $this->getDef( 'keyless_cp' ),
|
690 |
-
|
691 |
-
'flags' =>
|
692 |
'show_key' => !$this->isKeyless(),
|
693 |
'has_license_key' => $this->isLicenseKeyValidFormat(),
|
694 |
'show_ads' => false,
|
@@ -696,9 +696,9 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
696 |
'button_enabled_remove' => $this->isLicenseKeyValidFormat(),
|
697 |
'show_standard_options' => false,
|
698 |
'show_alt_content' => true,
|
699 |
-
|
700 |
'strings' => $this->getDisplayStrings(),
|
701 |
-
|
702 |
return $aData;
|
703 |
}
|
704 |
|
@@ -715,10 +715,10 @@ class ICWP_WPSF_FeatureHandler_License extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
715 |
case 'section_license_options' :
|
716 |
$sTitle = _wpsf__( 'License Options' );
|
717 |
$sTitleShort = _wpsf__( 'License Options' );
|
718 |
-
$aSummary =
|
719 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), sprintf( _wpsf__( 'Activate %s Pro Extensions.' ), $sName ) ),
|
720 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'TODO.' ) )
|
721 |
-
|
722 |
break;
|
723 |
|
724 |
default:
|
36 |
protected function getDisplayStrings() {
|
37 |
return Services::DataManipulation()->mergeArraysRecursive(
|
38 |
parent::getDisplayStrings(),
|
39 |
+
[
|
40 |
'product_name' => _wpsf__( 'Name' ),
|
41 |
'license_active' => _wpsf__( 'Active' ),
|
42 |
'license_status' => _wpsf__( 'Status' ),
|
45 |
'license_email' => _wpsf__( 'Owner' ),
|
46 |
'last_checked' => _wpsf__( 'Checked' ),
|
47 |
'last_errors' => _wpsf__( 'Error' ),
|
48 |
+
]
|
49 |
);
|
50 |
}
|
51 |
|
138 |
$this->deactivate( 'User submitted deactivation' );
|
139 |
}
|
140 |
|
141 |
+
return [
|
142 |
'success' => $bSuccess,
|
143 |
'message' => $sMessage,
|
144 |
+
];
|
145 |
}
|
146 |
|
147 |
/**
|
325 |
|
326 |
if ( $bCanSend ) {
|
327 |
$this->setOptAt( 'last_warning_email_sent_at' )->savePluginOptions();
|
328 |
+
$aMessage = [
|
329 |
_wpsf__( 'Attempts to verify Shield Pro license has just failed.' ),
|
330 |
sprintf( _wpsf__( 'Please check your license on-site: %s' ), $this->getUrl_AdminPage() ),
|
331 |
sprintf( _wpsf__( 'If this problem persists, please contact support: %s' ), 'https://support.onedollarplugin.com/' )
|
332 |
+
];
|
333 |
$this->getEmailProcessor()
|
334 |
->sendEmailWithWrap(
|
335 |
$this->getPluginDefaultRecipientAddress(),
|
346 |
|
347 |
if ( ( $nNow - $this->getOpt( 'last_deactivated_email_sent_at' ) ) > DAY_IN_SECONDS ) {
|
348 |
$this->setOptAt( 'last_deactivated_email_sent_at' )->savePluginOptions();
|
349 |
+
$aMessage = [
|
350 |
_wpsf__( 'All attempts to verify Shield Pro license have failed.' ),
|
351 |
sprintf( _wpsf__( 'Please check your license on-site: %s' ), $this->getUrl_AdminPage() ),
|
352 |
sprintf( _wpsf__( 'If this problem persists, please contact support: %s' ), 'https://support.onedollarplugin.com/' )
|
353 |
+
];
|
354 |
$this->getEmailProcessor()
|
355 |
->sendEmailWithWrap(
|
356 |
$this->getPluginDefaultRecipientAddress(),
|
372 |
->savePluginOptions();
|
373 |
|
374 |
$oLicense = $this->loadEdd()
|
375 |
+
->setRequestParams( [ 'nonce' => $sPass ] )
|
376 |
->activateLicenseKeyless( $this->getLicenseStoreUrl(), $this->getLicenseItemId() );
|
377 |
|
378 |
// clear the handshake data
|
656 |
$sChecked = $oCarbon->setTimestamp( $nLastReqAt )->diffForHumans()
|
657 |
.sprintf( '<br/><small>%s</small>', $oWp->getTimeStampForDisplay( $nLastReqAt ) );
|
658 |
}
|
659 |
+
$aLicenseTableVars = [
|
660 |
'product_name' => $this->getLicenseItemName(),
|
661 |
'license_active' => $this->hasValidWorkingLicense() ? _wpsf__( 'Yes' ) : _wpsf__( 'Not Active' ),
|
662 |
'license_expires' => $sExpiresAt,
|
663 |
'license_email' => $oCurrent->getCustomerEmail(),
|
664 |
'last_checked' => $sChecked,
|
665 |
'last_errors' => $this->hasLastErrors() ? $this->getLastErrors() : ''
|
666 |
+
];
|
667 |
if ( !$this->isKeyless() ) {
|
668 |
$aLicenseTableVars[ 'license_key' ] = $this->hasLicenseKey() ? $this->getLicenseKey() : 'n/a';
|
669 |
}
|
670 |
+
$aData = [
|
671 |
+
'vars' => [
|
672 |
'license_table' => $aLicenseTableVars,
|
673 |
'activation_url' => $oWp->getHomeUrl()
|
674 |
+
],
|
675 |
+
'inputs' => [
|
676 |
+
'license_key' => [
|
677 |
'name' => $this->prefixOptionKey( 'license_key' ),
|
678 |
'maxlength' => $this->getDef( 'license_key_length' ),
|
679 |
+
]
|
680 |
+
],
|
681 |
+
'ajax' => [
|
682 |
'license_handling' => $this->getAjaxActionData( 'license_handling' ),
|
683 |
'connection_debug' => $this->getAjaxActionData( 'connection_debug' )
|
684 |
+
],
|
685 |
+
'aHrefs' => [
|
686 |
'shield_pro_url' => 'https://icwp.io/shieldpro',
|
687 |
'shield_pro_more_info_url' => 'https://icwp.io/shld1',
|
688 |
'iframe_url' => $this->getDef( 'landing_page_url' ),
|
689 |
'keyless_cp' => $this->getDef( 'keyless_cp' ),
|
690 |
+
],
|
691 |
+
'flags' => [
|
692 |
'show_key' => !$this->isKeyless(),
|
693 |
'has_license_key' => $this->isLicenseKeyValidFormat(),
|
694 |
'show_ads' => false,
|
696 |
'button_enabled_remove' => $this->isLicenseKeyValidFormat(),
|
697 |
'show_standard_options' => false,
|
698 |
'show_alt_content' => true,
|
699 |
+
],
|
700 |
'strings' => $this->getDisplayStrings(),
|
701 |
+
];
|
702 |
return $aData;
|
703 |
}
|
704 |
|
715 |
case 'section_license_options' :
|
716 |
$sTitle = _wpsf__( 'License Options' );
|
717 |
$sTitleShort = _wpsf__( 'License Options' );
|
718 |
+
$aSummary = [
|
719 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), sprintf( _wpsf__( 'Activate %s Pro Extensions.' ), $sName ) ),
|
720 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'TODO.' ) )
|
721 |
+
];
|
722 |
break;
|
723 |
|
724 |
default:
|
@@ -65,21 +65,21 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
65 |
* @return array
|
66 |
*/
|
67 |
public function addInsightsNoticeData( $aAllNotices ) {
|
68 |
-
$aNotices =
|
69 |
'title' => _wpsf__( 'Lockdown' ),
|
70 |
'messages' => []
|
71 |
-
|
72 |
|
73 |
{ //edit plugins
|
74 |
$bEditingDisabled = $this->isOptFileEditingDisabled() || !current_user_can( 'edit_plugins' );
|
75 |
if ( !$bEditingDisabled ) { //assumes current user is admin
|
76 |
-
$aNotices[ 'messages' ][ 'disallow_file_edit' ] =
|
77 |
'title' => 'Code Editor',
|
78 |
'message' => _wpsf__( 'Direct editing of plugin/theme files is permitted.' ),
|
79 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_file_editing' ),
|
80 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
81 |
'rec' => _wpsf__( 'WP Plugin file editing should be disabled.' )
|
82 |
-
|
83 |
}
|
84 |
}
|
85 |
|
@@ -94,21 +94,21 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
94 |
* @return array
|
95 |
*/
|
96 |
public function addInsightsConfigData( $aAllData ) {
|
97 |
-
$aThis =
|
98 |
-
'strings' =>
|
99 |
'title' => _wpsf__( 'WordPress Lockdown' ),
|
100 |
'sub' => _wpsf__( 'Restrict WP Functionality e.g. XMLRPC & REST API' ),
|
101 |
-
|
102 |
'key_opts' => [],
|
103 |
'href_options' => $this->getUrl_AdminPage()
|
104 |
-
|
105 |
|
106 |
if ( !$this->isModOptEnabled() ) {
|
107 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
108 |
}
|
109 |
else {
|
110 |
$bEditingDisabled = $this->isOptFileEditingDisabled() || !current_user_can( 'edit_plugins' );
|
111 |
-
$aThis[ 'key_opts' ][ 'editing' ] =
|
112 |
'name' => _wpsf__( 'WP File Editing' ),
|
113 |
'enabled' => $bEditingDisabled,
|
114 |
'summary' => $bEditingDisabled ?
|
@@ -116,10 +116,10 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
116 |
: _wpsf__( "File editing is permitted through WP admin" ),
|
117 |
'weight' => 2,
|
118 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_file_editing' ),
|
119 |
-
|
120 |
|
121 |
$bXml = $this->isXmlrpcDisabled();
|
122 |
-
$aThis[ 'key_opts' ][ 'xml' ] =
|
123 |
'name' => _wpsf__( 'XML-RPC' ),
|
124 |
'enabled' => $bXml,
|
125 |
'summary' => $bXml ?
|
@@ -127,10 +127,10 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
127 |
: _wpsf__( "XML-RPC is not blocked" ),
|
128 |
'weight' => 1,
|
129 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_xmlrpc' ),
|
130 |
-
|
131 |
|
132 |
$bApi = $this->isRestApiAnonymousAccessDisabled();
|
133 |
-
$aThis[ 'key_opts' ][ 'api' ] =
|
134 |
'name' => _wpsf__( 'REST API' ),
|
135 |
'enabled' => $bApi,
|
136 |
'summary' => $bApi ?
|
@@ -138,7 +138,7 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
138 |
: _wpsf__( "Anonymous REST API is allowed" ),
|
139 |
'weight' => 1,
|
140 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_anonymous_restapi' ),
|
141 |
-
|
142 |
}
|
143 |
|
144 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -157,37 +157,37 @@ class ICWP_WPSF_FeatureHandler_Lockdown extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
157 |
|
158 |
case 'section_enable_plugin_feature_wordpress_lockdown' :
|
159 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
160 |
-
$aSummary =
|
161 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Lockdown helps secure-up certain loosely-controlled WordPress settings on your site.' ) ),
|
162 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Lockdown' ) ) )
|
163 |
-
|
164 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
165 |
break;
|
166 |
|
167 |
case 'section_apixml' :
|
168 |
$sTitle = _wpsf__( 'API & XML-RPC' );
|
169 |
-
$aSummary =
|
170 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Lockdown certain core WordPress system features.' ) ),
|
171 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'This depends on your usage and needs for certain WordPress functions and features.' ) )
|
172 |
-
|
173 |
$sTitleShort = _wpsf__( 'API & XML-RPC' );
|
174 |
break;
|
175 |
|
176 |
case 'section_permission_access_options' :
|
177 |
$sTitle = _wpsf__( 'Permissions and Access Options' );
|
178 |
-
$aSummary =
|
179 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control of certain WordPress permissions.' ) ),
|
180 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Only enable SSL if you have a valid certificate installed.' ) )
|
181 |
-
|
182 |
$sTitleShort = _wpsf__( 'Permissions' );
|
183 |
break;
|
184 |
|
185 |
case 'section_wordpress_obscurity_options' :
|
186 |
$sTitle = _wpsf__( 'WordPress Obscurity Options' );
|
187 |
-
$aSummary =
|
188 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Obscures certain WordPress settings from public view.' ) ),
|
189 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Obscurity is not true security and so these settings are down to your personal tastes.' ) )
|
190 |
-
|
191 |
$sTitleShort = _wpsf__( 'Obscurity' );
|
192 |
break;
|
193 |
|
65 |
* @return array
|
66 |
*/
|
67 |
public function addInsightsNoticeData( $aAllNotices ) {
|
68 |
+
$aNotices = [
|
69 |
'title' => _wpsf__( 'Lockdown' ),
|
70 |
'messages' => []
|
71 |
+
];
|
72 |
|
73 |
{ //edit plugins
|
74 |
$bEditingDisabled = $this->isOptFileEditingDisabled() || !current_user_can( 'edit_plugins' );
|
75 |
if ( !$bEditingDisabled ) { //assumes current user is admin
|
76 |
+
$aNotices[ 'messages' ][ 'disallow_file_edit' ] = [
|
77 |
'title' => 'Code Editor',
|
78 |
'message' => _wpsf__( 'Direct editing of plugin/theme files is permitted.' ),
|
79 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_file_editing' ),
|
80 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
81 |
'rec' => _wpsf__( 'WP Plugin file editing should be disabled.' )
|
82 |
+
];
|
83 |
}
|
84 |
}
|
85 |
|
94 |
* @return array
|
95 |
*/
|
96 |
public function addInsightsConfigData( $aAllData ) {
|
97 |
+
$aThis = [
|
98 |
+
'strings' => [
|
99 |
'title' => _wpsf__( 'WordPress Lockdown' ),
|
100 |
'sub' => _wpsf__( 'Restrict WP Functionality e.g. XMLRPC & REST API' ),
|
101 |
+
],
|
102 |
'key_opts' => [],
|
103 |
'href_options' => $this->getUrl_AdminPage()
|
104 |
+
];
|
105 |
|
106 |
if ( !$this->isModOptEnabled() ) {
|
107 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
108 |
}
|
109 |
else {
|
110 |
$bEditingDisabled = $this->isOptFileEditingDisabled() || !current_user_can( 'edit_plugins' );
|
111 |
+
$aThis[ 'key_opts' ][ 'editing' ] = [
|
112 |
'name' => _wpsf__( 'WP File Editing' ),
|
113 |
'enabled' => $bEditingDisabled,
|
114 |
'summary' => $bEditingDisabled ?
|
116 |
: _wpsf__( "File editing is permitted through WP admin" ),
|
117 |
'weight' => 2,
|
118 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_file_editing' ),
|
119 |
+
];
|
120 |
|
121 |
$bXml = $this->isXmlrpcDisabled();
|
122 |
+
$aThis[ 'key_opts' ][ 'xml' ] = [
|
123 |
'name' => _wpsf__( 'XML-RPC' ),
|
124 |
'enabled' => $bXml,
|
125 |
'summary' => $bXml ?
|
127 |
: _wpsf__( "XML-RPC is not blocked" ),
|
128 |
'weight' => 1,
|
129 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_xmlrpc' ),
|
130 |
+
];
|
131 |
|
132 |
$bApi = $this->isRestApiAnonymousAccessDisabled();
|
133 |
+
$aThis[ 'key_opts' ][ 'api' ] = [
|
134 |
'name' => _wpsf__( 'REST API' ),
|
135 |
'enabled' => $bApi,
|
136 |
'summary' => $bApi ?
|
138 |
: _wpsf__( "Anonymous REST API is allowed" ),
|
139 |
'weight' => 1,
|
140 |
'href' => $this->getUrl_DirectLinkToOption( 'disable_anonymous_restapi' ),
|
141 |
+
];
|
142 |
}
|
143 |
|
144 |
$aAllData[ $this->getSlug() ] = $aThis;
|
157 |
|
158 |
case 'section_enable_plugin_feature_wordpress_lockdown' :
|
159 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
160 |
+
$aSummary = [
|
161 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Lockdown helps secure-up certain loosely-controlled WordPress settings on your site.' ) ),
|
162 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Lockdown' ) ) )
|
163 |
+
];
|
164 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
165 |
break;
|
166 |
|
167 |
case 'section_apixml' :
|
168 |
$sTitle = _wpsf__( 'API & XML-RPC' );
|
169 |
+
$aSummary = [
|
170 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Lockdown certain core WordPress system features.' ) ),
|
171 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'This depends on your usage and needs for certain WordPress functions and features.' ) )
|
172 |
+
];
|
173 |
$sTitleShort = _wpsf__( 'API & XML-RPC' );
|
174 |
break;
|
175 |
|
176 |
case 'section_permission_access_options' :
|
177 |
$sTitle = _wpsf__( 'Permissions and Access Options' );
|
178 |
+
$aSummary = [
|
179 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control of certain WordPress permissions.' ) ),
|
180 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Only enable SSL if you have a valid certificate installed.' ) )
|
181 |
+
];
|
182 |
$sTitleShort = _wpsf__( 'Permissions' );
|
183 |
break;
|
184 |
|
185 |
case 'section_wordpress_obscurity_options' :
|
186 |
$sTitle = _wpsf__( 'WordPress Obscurity Options' );
|
187 |
+
$aSummary = [
|
188 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Obscures certain WordPress settings from public view.' ) ),
|
189 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Obscurity is not true security and so these settings are down to your personal tastes.' ) )
|
190 |
+
];
|
191 |
$sTitleShort = _wpsf__( 'Obscurity' );
|
192 |
break;
|
193 |
|
@@ -88,11 +88,11 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
88 |
$sEmail = get_bloginfo( 'admin_email' );
|
89 |
}
|
90 |
|
91 |
-
$aMessage =
|
92 |
_wpsf__( 'Before enabling 2-factor email authentication for your WordPress site, you must verify you can receive this email.' ),
|
93 |
_wpsf__( 'This verifies your website can send email and that your account can receive emails sent from your site.' ),
|
94 |
''
|
95 |
-
|
96 |
|
97 |
if ( $bSendAsLink ) {
|
98 |
$aMessage[] = sprintf( _wpsf__( 'Click the verify link: %s' ), $this->generateCanSendEmailVerifyLink() );
|
@@ -165,14 +165,14 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
165 |
* @return array
|
166 |
*/
|
167 |
protected function getOptEmailTwoFactorRolesDefaults( $bAsOptDefaults = true ) {
|
168 |
-
$aTwoAuthRoles =
|
169 |
'type' => 'multiple_select',
|
170 |
0 => _wpsf__( 'Subscribers' ),
|
171 |
1 => _wpsf__( 'Contributors' ),
|
172 |
2 => _wpsf__( 'Authors' ),
|
173 |
3 => _wpsf__( 'Editors' ),
|
174 |
8 => _wpsf__( 'Administrators' )
|
175 |
-
|
176 |
if ( $bAsOptDefaults ) {
|
177 |
unset( $aTwoAuthRoles[ 'type' ] );
|
178 |
unset( $aTwoAuthRoles[ 0 ] );
|
@@ -516,11 +516,11 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
516 |
* @return string
|
517 |
*/
|
518 |
protected function getPremiumOnlyIntegration() {
|
519 |
-
$aIntegrations =
|
520 |
'WooCommerce' => 'WooCommerce',
|
521 |
'Easy_Digital_Downloads' => 'Easy Digital Downloads',
|
522 |
'BuddyPress' => 'BuddyPress',
|
523 |
-
|
524 |
|
525 |
$sIntegration = '';
|
526 |
foreach ( $aIntegrations as $sInt => $sName ) {
|
@@ -590,14 +590,14 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
590 |
->getProcessorBackupCodes()
|
591 |
->resetSecret( Services::WpUsers()->getCurrentWpUser() );
|
592 |
|
593 |
-
foreach (
|
594 |
$sPass = substr_replace( $sPass, '-', $nPos, 0 );
|
595 |
}
|
596 |
|
597 |
-
return
|
598 |
'code' => $sPass,
|
599 |
'success' => true
|
600 |
-
|
601 |
}
|
602 |
|
603 |
/**
|
@@ -617,49 +617,6 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
617 |
return is_array( $aIds ) ? $aIds : [];
|
618 |
}
|
619 |
|
620 |
-
public function onWpEnqueueJs() {
|
621 |
-
parent::onWpEnqueueJs();
|
622 |
-
|
623 |
-
if ( $this->isEnabledBotJs() ) {
|
624 |
-
$oConn = $this->getCon();
|
625 |
-
|
626 |
-
$sAsset = 'shield-antibot';
|
627 |
-
$sUnique = $this->prefix( $sAsset );
|
628 |
-
wp_register_script(
|
629 |
-
$sUnique,
|
630 |
-
$oConn->getPluginUrl_Js( $sAsset.'.js' ),
|
631 |
-
array( 'jquery' ),
|
632 |
-
$oConn->getVersion(),
|
633 |
-
true
|
634 |
-
);
|
635 |
-
wp_enqueue_script( $sUnique );
|
636 |
-
|
637 |
-
wp_localize_script(
|
638 |
-
$sUnique,
|
639 |
-
'icwp_wpsf_vars_lpantibot',
|
640 |
-
array(
|
641 |
-
'form_selectors' => implode( ',', $this->getAntiBotFormSelectors() ),
|
642 |
-
'uniq' => preg_replace( '#[^a-zA-Z0-9]#', '', apply_filters( 'icwp_shield_lp_gasp_uniqid', uniqid() ) ),
|
643 |
-
'cbname' => $this->getGaspKey(),
|
644 |
-
'strings' => array(
|
645 |
-
'label' => $this->getTextImAHuman(),
|
646 |
-
'alert' => $this->getTextPleaseCheckBox(),
|
647 |
-
),
|
648 |
-
'flags' => array(
|
649 |
-
'gasp' => $this->isEnabledGaspCheck(),
|
650 |
-
'recap' => $this->isGoogleRecaptchaEnabled(),
|
651 |
-
)
|
652 |
-
)
|
653 |
-
);
|
654 |
-
|
655 |
-
if ( $this->isGoogleRecaptchaEnabled() ) {
|
656 |
-
/** @var ICWP_WPSF_Processor_LoginProtect $oPro */
|
657 |
-
$oPro = $this->getProcessor();
|
658 |
-
$oPro->setRecaptchaToEnqueue();
|
659 |
-
}
|
660 |
-
}
|
661 |
-
}
|
662 |
-
|
663 |
/**
|
664 |
* @return array
|
665 |
*/
|
@@ -671,9 +628,9 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
671 |
->getProcessorBackupCodes()
|
672 |
->deleteSecret( Services::WpUsers()->getCurrentWpUser() );
|
673 |
$this->setFlashAdminNotice( _wpsf__( 'Multi-factor login backup code has been removed from your profile' ) );
|
674 |
-
return
|
675 |
'success' => true
|
676 |
-
|
677 |
}
|
678 |
|
679 |
/**
|
@@ -681,11 +638,11 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
681 |
*/
|
682 |
private function ajaxExec_Disable2faEmail() {
|
683 |
$this->setEnabled2FaEmail( false );
|
684 |
-
return
|
685 |
'success' => true,
|
686 |
'message' => _wpsf__( '2FA by email has been disabled' ),
|
687 |
'page_reload' => true
|
688 |
-
|
689 |
}
|
690 |
|
691 |
/**
|
@@ -707,10 +664,10 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
707 |
->sendEmailVerifyCanSend();
|
708 |
}
|
709 |
|
710 |
-
return
|
711 |
'success' => $bSuccess,
|
712 |
'message' => $sMessage
|
713 |
-
|
714 |
}
|
715 |
|
716 |
public function insertCustomJsVars_Admin() {
|
@@ -719,10 +676,10 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
719 |
wp_localize_script(
|
720 |
$this->prefix( 'global-plugin' ),
|
721 |
'icwp_wpsf_vars_lg',
|
722 |
-
|
723 |
'ajax_gen_backup_codes' => $this->getAjaxActionData( 'gen_backup_codes' ),
|
724 |
'ajax_del_backup_codes' => $this->getAjaxActionData( 'del_backup_codes' ),
|
725 |
-
|
726 |
);
|
727 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
728 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
@@ -733,14 +690,14 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
733 |
* @return array
|
734 |
*/
|
735 |
public function addInsightsConfigData( $aAllData ) {
|
736 |
-
$aThis =
|
737 |
-
'strings' =>
|
738 |
'title' => _wpsf__( 'Login Guard' ),
|
739 |
'sub' => _wpsf__( 'Brute Force Protection & Identity Verification' ),
|
740 |
-
|
741 |
'key_opts' => [],
|
742 |
'href_options' => $this->getUrl_AdminPage()
|
743 |
-
|
744 |
|
745 |
if ( !$this->isModOptEnabled() ) {
|
746 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
@@ -751,7 +708,7 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
751 |
$bBotLogin = $bHasBotCheck && $this->isProtectLogin();
|
752 |
$bBotRegister = $bHasBotCheck && $this->isProtectRegister();
|
753 |
$bBotPassword = $bHasBotCheck && $this->isProtectLostPassword();
|
754 |
-
$aThis[ 'key_opts' ][ 'bot_login' ] =
|
755 |
'name' => _wpsf__( 'Brute Force Login' ),
|
756 |
'enabled' => $bBotLogin,
|
757 |
'summary' => $bBotLogin ?
|
@@ -759,8 +716,8 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
759 |
: _wpsf__( 'Login forms are not protected against brute force bot attacks' ),
|
760 |
'weight' => 2,
|
761 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
762 |
-
|
763 |
-
$aThis[ 'key_opts' ][ 'bot_register' ] =
|
764 |
'name' => _wpsf__( 'Bot User Register' ),
|
765 |
'enabled' => $bBotRegister,
|
766 |
'summary' => $bBotRegister ?
|
@@ -768,8 +725,8 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
768 |
: _wpsf__( 'Registration forms are not protected against automated bots' ),
|
769 |
'weight' => 2,
|
770 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
771 |
-
|
772 |
-
$aThis[ 'key_opts' ][ 'bot_password' ] =
|
773 |
'name' => _wpsf__( 'Brute Force Lost Password' ),
|
774 |
'enabled' => $bBotPassword,
|
775 |
'summary' => $bBotPassword ?
|
@@ -777,11 +734,11 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
777 |
: _wpsf__( 'Lost Password forms are not protected against automated bots' ),
|
778 |
'weight' => 2,
|
779 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
780 |
-
|
781 |
|
782 |
$bHas2Fa = $this->isEmailAuthenticationActive()
|
783 |
|| $this->isEnabledGoogleAuthenticator() || $this->isYubikeyActive();
|
784 |
-
$aThis[ 'key_opts' ][ '2fa' ] =
|
785 |
'name' => _wpsf__( 'Identity Verification' ),
|
786 |
'enabled' => $bHas2Fa,
|
787 |
'summary' => $bHas2Fa ?
|
@@ -789,7 +746,7 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
789 |
: _wpsf__( 'No 2FA options, such as Google Authenticator, are active' ),
|
790 |
'weight' => 2,
|
791 |
'href' => $this->getUrl_DirectLinkToSection( 'section_2fa_email' ),
|
792 |
-
|
793 |
}
|
794 |
|
795 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -808,75 +765,75 @@ class ICWP_WPSF_FeatureHandler_LoginProtect extends ICWP_WPSF_FeatureHandler_Bas
|
|
808 |
case 'section_enable_plugin_feature_login_protection' :
|
809 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
810 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
811 |
-
$aSummary =
|
812 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Login Guard blocks all automated and brute force attempts to log in to your site.' ) ),
|
813 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Login Guard' ) ) )
|
814 |
-
|
815 |
break;
|
816 |
|
817 |
case 'section_recaptcha' :
|
818 |
$sTitle = 'Google reCAPTCHA';
|
819 |
$sTitleShort = 'reCAPTCHA';
|
820 |
-
$aSummary =
|
821 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Adds Google reCAPTCHA to the Login Forms.' ) ),
|
822 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this turned on.' ) ),
|
823 |
sprintf( '%s - %s', _wpsf__( 'Note' ), _wpsf__( "You will need to register for Google reCAPTCHA keys and store them in the Shield 'Dashboard' settings." ) ),
|
824 |
-
|
825 |
break;
|
826 |
|
827 |
case 'section_rename_wplogin' :
|
828 |
$sTitle = _wpsf__( 'Hide WordPress Login Page' );
|
829 |
$sTitleShort = _wpsf__( 'Hide Login Page' );
|
830 |
-
$aSummary =
|
831 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'To hide your wp-login.php page from brute force attacks and hacking attempts - if your login page cannot be found, no-one can login.' ) ),
|
832 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'This is not required for complete security and if your site has irregular or inconsistent configuration it may not work for you.' ) )
|
833 |
-
|
834 |
break;
|
835 |
|
836 |
case 'section_multifactor_authentication' :
|
837 |
$sTitle = _wpsf__( 'Multi-Factor Authentication' );
|
838 |
$sTitleShort = _wpsf__( 'Multi-Factor Auth' );
|
839 |
-
$aSummary =
|
840 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site - i.e. they are who they say they are.' ) ),
|
841 |
_wpsf__( 'You may combine multiple authentication factors for increased security.' )
|
842 |
-
|
843 |
break;
|
844 |
|
845 |
case 'section_2fa_email' :
|
846 |
$sTitle = _wpsf__( 'Email Two-Factor Authentication' );
|
847 |
$sTitleShort = _wpsf__( '2FA - Email' );
|
848 |
-
$aSummary =
|
849 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using email-based one-time-passwords.' ) ),
|
850 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ).' '._wpsf__( 'However, if your host blocks email sending you may lock yourself out.' ) ),
|
851 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
852 |
-
|
853 |
break;
|
854 |
|
855 |
case 'section_2fa_ga' :
|
856 |
$sTitle = _wpsf__( 'Google Authenticator Two-Factor Authentication' );
|
857 |
$sTitleShort = _wpsf__( '2FA - Google Authenticator' );
|
858 |
-
$aSummary =
|
859 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using Google Authenticator one-time-passwords.' ) ),
|
860 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
861 |
-
|
862 |
break;
|
863 |
|
864 |
case 'section_brute_force_login_protection' :
|
865 |
$sTitle = _wpsf__( 'Brute Force Login Protection' );
|
866 |
$sTitleShort = _wpsf__( 'reCAPTCHA & Bots' );
|
867 |
-
$aSummary =
|
868 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Blocks brute force hacking attacks against your login and registration pages.' ) ),
|
869 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
870 |
-
|
871 |
break;
|
872 |
|
873 |
case 'section_yubikey_authentication' :
|
874 |
$sTitle = _wpsf__( 'Yubikey Two-Factor Authentication' );
|
875 |
$sTitleShort = _wpsf__( '2FA -Yubikey' );
|
876 |
-
$aSummary =
|
877 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using Yubikey one-time-passwords.' ) ),
|
878 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
879 |
-
|
880 |
break;
|
881 |
|
882 |
default:
|
88 |
$sEmail = get_bloginfo( 'admin_email' );
|
89 |
}
|
90 |
|
91 |
+
$aMessage = [
|
92 |
_wpsf__( 'Before enabling 2-factor email authentication for your WordPress site, you must verify you can receive this email.' ),
|
93 |
_wpsf__( 'This verifies your website can send email and that your account can receive emails sent from your site.' ),
|
94 |
''
|
95 |
+
];
|
96 |
|
97 |
if ( $bSendAsLink ) {
|
98 |
$aMessage[] = sprintf( _wpsf__( 'Click the verify link: %s' ), $this->generateCanSendEmailVerifyLink() );
|
165 |
* @return array
|
166 |
*/
|
167 |
protected function getOptEmailTwoFactorRolesDefaults( $bAsOptDefaults = true ) {
|
168 |
+
$aTwoAuthRoles = [
|
169 |
'type' => 'multiple_select',
|
170 |
0 => _wpsf__( 'Subscribers' ),
|
171 |
1 => _wpsf__( 'Contributors' ),
|
172 |
2 => _wpsf__( 'Authors' ),
|
173 |
3 => _wpsf__( 'Editors' ),
|
174 |
8 => _wpsf__( 'Administrators' )
|
175 |
+
];
|
176 |
if ( $bAsOptDefaults ) {
|
177 |
unset( $aTwoAuthRoles[ 'type' ] );
|
178 |
unset( $aTwoAuthRoles[ 0 ] );
|
516 |
* @return string
|
517 |
*/
|
518 |
protected function getPremiumOnlyIntegration() {
|
519 |
+
$aIntegrations = [
|
520 |
'WooCommerce' => 'WooCommerce',
|
521 |
'Easy_Digital_Downloads' => 'Easy Digital Downloads',
|
522 |
'BuddyPress' => 'BuddyPress',
|
523 |
+
];
|
524 |
|
525 |
$sIntegration = '';
|
526 |
foreach ( $aIntegrations as $sInt => $sName ) {
|
590 |
->getProcessorBackupCodes()
|
591 |
->resetSecret( Services::WpUsers()->getCurrentWpUser() );
|
592 |
|
593 |
+
foreach ( [ 20, 15, 10, 5 ] as $nPos ) {
|
594 |
$sPass = substr_replace( $sPass, '-', $nPos, 0 );
|
595 |
}
|
596 |
|
597 |
+
return [
|
598 |
'code' => $sPass,
|
599 |
'success' => true
|
600 |
+
];
|
601 |
}
|
602 |
|
603 |
/**
|
617 |
return is_array( $aIds ) ? $aIds : [];
|
618 |
}
|
619 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
620 |
/**
|
621 |
* @return array
|
622 |
*/
|
628 |
->getProcessorBackupCodes()
|
629 |
->deleteSecret( Services::WpUsers()->getCurrentWpUser() );
|
630 |
$this->setFlashAdminNotice( _wpsf__( 'Multi-factor login backup code has been removed from your profile' ) );
|
631 |
+
return [
|
632 |
'success' => true
|
633 |
+
];
|
634 |
}
|
635 |
|
636 |
/**
|
638 |
*/
|
639 |
private function ajaxExec_Disable2faEmail() {
|
640 |
$this->setEnabled2FaEmail( false );
|
641 |
+
return [
|
642 |
'success' => true,
|
643 |
'message' => _wpsf__( '2FA by email has been disabled' ),
|
644 |
'page_reload' => true
|
645 |
+
];
|
646 |
}
|
647 |
|
648 |
/**
|
664 |
->sendEmailVerifyCanSend();
|
665 |
}
|
666 |
|
667 |
+
return [
|
668 |
'success' => $bSuccess,
|
669 |
'message' => $sMessage
|
670 |
+
];
|
671 |
}
|
672 |
|
673 |
public function insertCustomJsVars_Admin() {
|
676 |
wp_localize_script(
|
677 |
$this->prefix( 'global-plugin' ),
|
678 |
'icwp_wpsf_vars_lg',
|
679 |
+
[
|
680 |
'ajax_gen_backup_codes' => $this->getAjaxActionData( 'gen_backup_codes' ),
|
681 |
'ajax_del_backup_codes' => $this->getAjaxActionData( 'del_backup_codes' ),
|
682 |
+
]
|
683 |
);
|
684 |
wp_enqueue_script( 'jquery-ui-dialog' );
|
685 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
690 |
* @return array
|
691 |
*/
|
692 |
public function addInsightsConfigData( $aAllData ) {
|
693 |
+
$aThis = [
|
694 |
+
'strings' => [
|
695 |
'title' => _wpsf__( 'Login Guard' ),
|
696 |
'sub' => _wpsf__( 'Brute Force Protection & Identity Verification' ),
|
697 |
+
],
|
698 |
'key_opts' => [],
|
699 |
'href_options' => $this->getUrl_AdminPage()
|
700 |
+
];
|
701 |
|
702 |
if ( !$this->isModOptEnabled() ) {
|
703 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
708 |
$bBotLogin = $bHasBotCheck && $this->isProtectLogin();
|
709 |
$bBotRegister = $bHasBotCheck && $this->isProtectRegister();
|
710 |
$bBotPassword = $bHasBotCheck && $this->isProtectLostPassword();
|
711 |
+
$aThis[ 'key_opts' ][ 'bot_login' ] = [
|
712 |
'name' => _wpsf__( 'Brute Force Login' ),
|
713 |
'enabled' => $bBotLogin,
|
714 |
'summary' => $bBotLogin ?
|
716 |
: _wpsf__( 'Login forms are not protected against brute force bot attacks' ),
|
717 |
'weight' => 2,
|
718 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
719 |
+
];
|
720 |
+
$aThis[ 'key_opts' ][ 'bot_register' ] = [
|
721 |
'name' => _wpsf__( 'Bot User Register' ),
|
722 |
'enabled' => $bBotRegister,
|
723 |
'summary' => $bBotRegister ?
|
725 |
: _wpsf__( 'Registration forms are not protected against automated bots' ),
|
726 |
'weight' => 2,
|
727 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
728 |
+
];
|
729 |
+
$aThis[ 'key_opts' ][ 'bot_password' ] = [
|
730 |
'name' => _wpsf__( 'Brute Force Lost Password' ),
|
731 |
'enabled' => $bBotPassword,
|
732 |
'summary' => $bBotPassword ?
|
734 |
: _wpsf__( 'Lost Password forms are not protected against automated bots' ),
|
735 |
'weight' => 2,
|
736 |
'href' => $this->getUrl_DirectLinkToOption( 'bot_protection_locations' ),
|
737 |
+
];
|
738 |
|
739 |
$bHas2Fa = $this->isEmailAuthenticationActive()
|
740 |
|| $this->isEnabledGoogleAuthenticator() || $this->isYubikeyActive();
|
741 |
+
$aThis[ 'key_opts' ][ '2fa' ] = [
|
742 |
'name' => _wpsf__( 'Identity Verification' ),
|
743 |
'enabled' => $bHas2Fa,
|
744 |
'summary' => $bHas2Fa ?
|
746 |
: _wpsf__( 'No 2FA options, such as Google Authenticator, are active' ),
|
747 |
'weight' => 2,
|
748 |
'href' => $this->getUrl_DirectLinkToSection( 'section_2fa_email' ),
|
749 |
+
];
|
750 |
}
|
751 |
|
752 |
$aAllData[ $this->getSlug() ] = $aThis;
|
765 |
case 'section_enable_plugin_feature_login_protection' :
|
766 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
767 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
768 |
+
$aSummary = [
|
769 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Login Guard blocks all automated and brute force attempts to log in to your site.' ) ),
|
770 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'Login Guard' ) ) )
|
771 |
+
];
|
772 |
break;
|
773 |
|
774 |
case 'section_recaptcha' :
|
775 |
$sTitle = 'Google reCAPTCHA';
|
776 |
$sTitleShort = 'reCAPTCHA';
|
777 |
+
$aSummary = [
|
778 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Adds Google reCAPTCHA to the Login Forms.' ) ),
|
779 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Keep this turned on.' ) ),
|
780 |
sprintf( '%s - %s', _wpsf__( 'Note' ), _wpsf__( "You will need to register for Google reCAPTCHA keys and store them in the Shield 'Dashboard' settings." ) ),
|
781 |
+
];
|
782 |
break;
|
783 |
|
784 |
case 'section_rename_wplogin' :
|
785 |
$sTitle = _wpsf__( 'Hide WordPress Login Page' );
|
786 |
$sTitleShort = _wpsf__( 'Hide Login Page' );
|
787 |
+
$aSummary = [
|
788 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'To hide your wp-login.php page from brute force attacks and hacking attempts - if your login page cannot be found, no-one can login.' ) ),
|
789 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'This is not required for complete security and if your site has irregular or inconsistent configuration it may not work for you.' ) )
|
790 |
+
];
|
791 |
break;
|
792 |
|
793 |
case 'section_multifactor_authentication' :
|
794 |
$sTitle = _wpsf__( 'Multi-Factor Authentication' );
|
795 |
$sTitleShort = _wpsf__( 'Multi-Factor Auth' );
|
796 |
+
$aSummary = [
|
797 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site - i.e. they are who they say they are.' ) ),
|
798 |
_wpsf__( 'You may combine multiple authentication factors for increased security.' )
|
799 |
+
];
|
800 |
break;
|
801 |
|
802 |
case 'section_2fa_email' :
|
803 |
$sTitle = _wpsf__( 'Email Two-Factor Authentication' );
|
804 |
$sTitleShort = _wpsf__( '2FA - Email' );
|
805 |
+
$aSummary = [
|
806 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using email-based one-time-passwords.' ) ),
|
807 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ).' '._wpsf__( 'However, if your host blocks email sending you may lock yourself out.' ) ),
|
808 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
809 |
+
];
|
810 |
break;
|
811 |
|
812 |
case 'section_2fa_ga' :
|
813 |
$sTitle = _wpsf__( 'Google Authenticator Two-Factor Authentication' );
|
814 |
$sTitleShort = _wpsf__( '2FA - Google Authenticator' );
|
815 |
+
$aSummary = [
|
816 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using Google Authenticator one-time-passwords.' ) ),
|
817 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
818 |
+
];
|
819 |
break;
|
820 |
|
821 |
case 'section_brute_force_login_protection' :
|
822 |
$sTitle = _wpsf__( 'Brute Force Login Protection' );
|
823 |
$sTitleShort = _wpsf__( 'reCAPTCHA & Bots' );
|
824 |
+
$aSummary = [
|
825 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Blocks brute force hacking attacks against your login and registration pages.' ) ),
|
826 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
827 |
+
];
|
828 |
break;
|
829 |
|
830 |
case 'section_yubikey_authentication' :
|
831 |
$sTitle = _wpsf__( 'Yubikey Two-Factor Authentication' );
|
832 |
$sTitleShort = _wpsf__( '2FA -Yubikey' );
|
833 |
+
$aSummary = [
|
834 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site using Yubikey one-time-passwords.' ) ),
|
835 |
sprintf( '%s: %s', _wpsf__( 'Note' ), _wpsf__( 'You may combine multiple authentication factors for increased security.' ) )
|
836 |
+
];
|
837 |
break;
|
838 |
|
839 |
default:
|
@@ -280,10 +280,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
280 |
$sMessage = _wpsf__( 'Selected items were deleted.' );
|
281 |
}
|
282 |
|
283 |
-
return
|
284 |
'success' => $bSuccess,
|
285 |
'message' => $sMessage,
|
286 |
-
|
287 |
}
|
288 |
|
289 |
/**
|
@@ -297,10 +297,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
297 |
DAY_IN_SECONDS
|
298 |
);
|
299 |
$sMessage = $bSuccess ? 'Badge Closed' : 'Badge Not Closed';
|
300 |
-
return
|
301 |
'success' => $bSuccess,
|
302 |
'message' => $sMessage
|
303 |
-
|
304 |
}
|
305 |
|
306 |
/**
|
@@ -308,7 +308,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
308 |
*/
|
309 |
public function ajaxExec_SetPluginTrackingPerm() {
|
310 |
$this->setPluginTrackingPermission( (bool)Services::Request()->query( 'agree', false ) );
|
311 |
-
return
|
312 |
}
|
313 |
|
314 |
/**
|
@@ -327,7 +327,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
327 |
'Shield Deactivation Survey',
|
328 |
implode( "\n<br/>", $aResults )
|
329 |
);
|
330 |
-
return
|
331 |
}
|
332 |
|
333 |
/**
|
@@ -340,7 +340,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
340 |
if ( $bStillActive ) {
|
341 |
$this->setFlashAdminNotice( _wpsf__( 'File could not be automatically removed.' ), true );
|
342 |
}
|
343 |
-
return
|
344 |
}
|
345 |
|
346 |
/**
|
@@ -373,10 +373,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
373 |
}
|
374 |
}
|
375 |
|
376 |
-
return
|
377 |
'success' => true,
|
378 |
'message' => $sMessage
|
379 |
-
|
380 |
}
|
381 |
|
382 |
private function ajaxExec_ImportFromSite() {
|
@@ -407,10 +407,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
407 |
$bSuccess = $nCode == 0;
|
408 |
$sMessage = $bSuccess ? _wpsf__( 'Options imported successfully' ) : _wpsf__( 'Options failed to import' );
|
409 |
}
|
410 |
-
return
|
411 |
'success' => $bSuccess,
|
412 |
'message' => $sMessage
|
413 |
-
|
414 |
}
|
415 |
|
416 |
/**
|
@@ -437,10 +437,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
437 |
$bSuccess = $oInserter->create( $sNote );
|
438 |
$sMessage = $bSuccess ? _wpsf__( 'Note created successfully.' ) : _wpsf__( 'Note could not be created.' );
|
439 |
}
|
440 |
-
return
|
441 |
'success' => $bSuccess,
|
442 |
'message' => $sMessage
|
443 |
-
|
444 |
}
|
445 |
|
446 |
/**
|
@@ -453,10 +453,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
453 |
->setMod( $this )
|
454 |
->setDbHandler( $oPro->getSubProcessorNotes()->getDbHandler() );
|
455 |
|
456 |
-
return
|
457 |
'success' => true,
|
458 |
'html' => $oTableBuilder->buildTable()
|
459 |
-
|
460 |
}
|
461 |
|
462 |
/**
|
@@ -474,11 +474,11 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
474 |
* @return array
|
475 |
*/
|
476 |
public function supplyGoogleRecaptchaConfig() {
|
477 |
-
return
|
478 |
'key' => $this->getOpt( 'google_recaptcha_site_key' ),
|
479 |
'secret' => $this->getOpt( 'google_recaptcha_secret_key' ),
|
480 |
'style' => $this->getOpt( 'google_recaptcha_style' ),
|
481 |
-
|
482 |
}
|
483 |
|
484 |
/**
|
@@ -521,7 +521,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
521 |
*/
|
522 |
public function getLinkToTrackingDataDump() {
|
523 |
return add_query_arg(
|
524 |
-
|
525 |
Services::WpGeneral()->getAdminUrl()
|
526 |
);
|
527 |
}
|
@@ -970,11 +970,11 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
970 |
public function renderPluginBadge() {
|
971 |
$oCon = $this->getCon();
|
972 |
|
973 |
-
$aData =
|
974 |
-
'ajax' =>
|
975 |
'plugin_badge_close' => $this->getAjaxActionData( 'plugin_badge_close', true ),
|
976 |
-
|
977 |
-
|
978 |
$sContents = $this->loadRenderer( $oCon->getPath_Templates() )
|
979 |
->setTemplateEnginePhp()
|
980 |
->clearRenderVars()
|
@@ -1005,10 +1005,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1005 |
protected function getDisplayStrings() {
|
1006 |
return Services::DataManipulation()->mergeArraysRecursive(
|
1007 |
parent::getDisplayStrings(),
|
1008 |
-
|
1009 |
'actions_title' => _wpsf__( 'Plugin Actions' ),
|
1010 |
'actions_summary' => _wpsf__( 'E.g. Import/Export' ),
|
1011 |
-
|
1012 |
);
|
1013 |
}
|
1014 |
|
@@ -1048,15 +1048,15 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1048 |
wp_localize_script(
|
1049 |
$this->prefix( 'global-plugin' ),
|
1050 |
'icwp_wpsf_vars_plugin',
|
1051 |
-
|
1052 |
'file' => $sFile,
|
1053 |
-
'ajax' =>
|
1054 |
'send_deactivate_survey' => $this->getAjaxActionData( 'send_deactivate_survey' ),
|
1055 |
-
|
1056 |
-
'hrefs' =>
|
1057 |
'deactivate' => Services::WpPlugins()->getUrl_Deactivate( $sFile ),
|
1058 |
-
|
1059 |
-
|
1060 |
);
|
1061 |
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
|
1062 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
@@ -1068,30 +1068,30 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1068 |
* @return array
|
1069 |
*/
|
1070 |
public function addInsightsConfigData( $aAllData ) {
|
1071 |
-
$aThis =
|
1072 |
-
'strings' =>
|
1073 |
'title' => _wpsf__( 'General Settings' ),
|
1074 |
'sub' => sprintf( _wpsf__( 'General %s Settings' ), $this->getCon()->getHumanName() ),
|
1075 |
-
|
1076 |
'key_opts' => [],
|
1077 |
'href_options' => $this->getUrl_AdminPage()
|
1078 |
-
|
1079 |
|
1080 |
if ( $this->isModOptEnabled() ) {
|
1081 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
1082 |
}
|
1083 |
else {
|
1084 |
$sSource = $this->getOptionsVo()->getSelectOptionValueText( 'visitor_address_source' );
|
1085 |
-
$aThis[ 'key_opts' ][ 'editing' ] =
|
1086 |
'name' => _wpsf__( 'Visitor IP' ),
|
1087 |
'enabled' => true,
|
1088 |
'summary' => sprintf( _wpsf__( 'Visitor IP address source is: %s' ), $sSource ),
|
1089 |
'weight' => 0,
|
1090 |
'href' => $this->getUrl_DirectLinkToOption( 'visitor_address_source' ),
|
1091 |
-
|
1092 |
|
1093 |
$bHasSupportEmail = Services::Data()->validEmail( $this->supplyPluginReportEmail() );
|
1094 |
-
$aThis[ 'key_opts' ][ 'reports' ] =
|
1095 |
'name' => _wpsf__( 'Reporting Email' ),
|
1096 |
'enabled' => $bHasSupportEmail,
|
1097 |
'summary' => $bHasSupportEmail ?
|
@@ -1100,10 +1100,10 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1100 |
->getSiteAdminEmail() ),
|
1101 |
'weight' => 0,
|
1102 |
'href' => $this->getUrl_DirectLinkToOption( 'block_send_email_address' ),
|
1103 |
-
|
1104 |
|
1105 |
$bRecap = $this->isGoogleRecaptchaReady();
|
1106 |
-
$aThis[ 'key_opts' ][ 'recap' ] =
|
1107 |
'name' => _wpsf__( 'reCAPTCHA' ),
|
1108 |
'enabled' => $bRecap,
|
1109 |
'summary' => $bRecap ?
|
@@ -1111,7 +1111,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1111 |
: _wpsf__( "Google reCAPTCHA keys haven't been provided" ),
|
1112 |
'weight' => 1,
|
1113 |
'href' => $this->getUrl_DirectLinkToOption( 'block_send_email_address' ),
|
1114 |
-
|
1115 |
}
|
1116 |
|
1117 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -1136,17 +1136,17 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1136 |
case 'section_defaults' :
|
1137 |
$sTitle = _wpsf__( 'Plugin Defaults' );
|
1138 |
$sTitleShort = _wpsf__( 'Plugin Defaults' );
|
1139 |
-
$aSummary =
|
1140 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Important default settings used throughout the plugin.' ) ),
|
1141 |
-
|
1142 |
break;
|
1143 |
|
1144 |
case 'section_importexport' :
|
1145 |
$sTitle = sprintf( '%s / %s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) );
|
1146 |
-
$aSummary =
|
1147 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatically import options, and deploy configurations across your entire network.' ) ),
|
1148 |
sprintf( _wpsf__( 'This is a Pro-only feature.' ) ),
|
1149 |
-
|
1150 |
$sTitleShort = sprintf( '%s / %s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) );
|
1151 |
break;
|
1152 |
|
@@ -1158,7 +1158,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1158 |
case 'section_third_party_google' :
|
1159 |
$sTitle = _wpsf__( 'Google' );
|
1160 |
$sTitleShort = _wpsf__( 'Google' );
|
1161 |
-
$aSummary =
|
1162 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), sprintf( _wpsf__( 'Setup Google reCAPTCHA for use across %s.' ), $sName ) ),
|
1163 |
sprintf( '%s - %s',
|
1164 |
_wpsf__( 'Recommendation' ),
|
@@ -1168,7 +1168,7 @@ class ICWP_WPSF_FeatureHandler_Plugin extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
1168 |
.sprintf( '<br/><a href="%s" target="_blank">%s</a>', 'https://www.google.com/recaptcha/admin', _wpsf__( 'API Keys' ) )
|
1169 |
),
|
1170 |
sprintf( '%s - %s', _wpsf__( 'Note' ), sprintf( _wpsf__( 'Invisible Google reCAPTCHA is available with %s Pro.' ), $sName ) )
|
1171 |
-
|
1172 |
break;
|
1173 |
|
1174 |
case 'section_third_party_duo' :
|
280 |
$sMessage = _wpsf__( 'Selected items were deleted.' );
|
281 |
}
|
282 |
|
283 |
+
return [
|
284 |
'success' => $bSuccess,
|
285 |
'message' => $sMessage,
|
286 |
+
];
|
287 |
}
|
288 |
|
289 |
/**
|
297 |
DAY_IN_SECONDS
|
298 |
);
|
299 |
$sMessage = $bSuccess ? 'Badge Closed' : 'Badge Not Closed';
|
300 |
+
return [
|
301 |
'success' => $bSuccess,
|
302 |
'message' => $sMessage
|
303 |
+
];
|
304 |
}
|
305 |
|
306 |
/**
|
308 |
*/
|
309 |
public function ajaxExec_SetPluginTrackingPerm() {
|
310 |
$this->setPluginTrackingPermission( (bool)Services::Request()->query( 'agree', false ) );
|
311 |
+
return [ 'success' => true ];
|
312 |
}
|
313 |
|
314 |
/**
|
327 |
'Shield Deactivation Survey',
|
328 |
implode( "\n<br/>", $aResults )
|
329 |
);
|
330 |
+
return [ 'success' => true ];
|
331 |
}
|
332 |
|
333 |
/**
|
340 |
if ( $bStillActive ) {
|
341 |
$this->setFlashAdminNotice( _wpsf__( 'File could not be automatically removed.' ), true );
|
342 |
}
|
343 |
+
return [ 'success' => !$bStillActive ];
|
344 |
}
|
345 |
|
346 |
/**
|
373 |
}
|
374 |
}
|
375 |
|
376 |
+
return [
|
377 |
'success' => true,
|
378 |
'message' => $sMessage
|
379 |
+
];
|
380 |
}
|
381 |
|
382 |
private function ajaxExec_ImportFromSite() {
|
407 |
$bSuccess = $nCode == 0;
|
408 |
$sMessage = $bSuccess ? _wpsf__( 'Options imported successfully' ) : _wpsf__( 'Options failed to import' );
|
409 |
}
|
410 |
+
return [
|
411 |
'success' => $bSuccess,
|
412 |
'message' => $sMessage
|
413 |
+
];
|
414 |
}
|
415 |
|
416 |
/**
|
437 |
$bSuccess = $oInserter->create( $sNote );
|
438 |
$sMessage = $bSuccess ? _wpsf__( 'Note created successfully.' ) : _wpsf__( 'Note could not be created.' );
|
439 |
}
|
440 |
+
return [
|
441 |
'success' => $bSuccess,
|
442 |
'message' => $sMessage
|
443 |
+
];
|
444 |
}
|
445 |
|
446 |
/**
|
453 |
->setMod( $this )
|
454 |
->setDbHandler( $oPro->getSubProcessorNotes()->getDbHandler() );
|
455 |
|
456 |
+
return [
|
457 |
'success' => true,
|
458 |
'html' => $oTableBuilder->buildTable()
|
459 |
+
];
|
460 |
}
|
461 |
|
462 |
/**
|
474 |
* @return array
|
475 |
*/
|
476 |
public function supplyGoogleRecaptchaConfig() {
|
477 |
+
return [
|
478 |
'key' => $this->getOpt( 'google_recaptcha_site_key' ),
|
479 |
'secret' => $this->getOpt( 'google_recaptcha_secret_key' ),
|
480 |
'style' => $this->getOpt( 'google_recaptcha_style' ),
|
481 |
+
];
|
482 |
}
|
483 |
|
484 |
/**
|
521 |
*/
|
522 |
public function getLinkToTrackingDataDump() {
|
523 |
return add_query_arg(
|
524 |
+
[ 'shield_action' => 'dump_tracking_data' ],
|
525 |
Services::WpGeneral()->getAdminUrl()
|
526 |
);
|
527 |
}
|
970 |
public function renderPluginBadge() {
|
971 |
$oCon = $this->getCon();
|
972 |
|
973 |
+
$aData = [
|
974 |
+
'ajax' => [
|
975 |
'plugin_badge_close' => $this->getAjaxActionData( 'plugin_badge_close', true ),
|
976 |
+
]
|
977 |
+
];
|
978 |
$sContents = $this->loadRenderer( $oCon->getPath_Templates() )
|
979 |
->setTemplateEnginePhp()
|
980 |
->clearRenderVars()
|
1005 |
protected function getDisplayStrings() {
|
1006 |
return Services::DataManipulation()->mergeArraysRecursive(
|
1007 |
parent::getDisplayStrings(),
|
1008 |
+
[
|
1009 |
'actions_title' => _wpsf__( 'Plugin Actions' ),
|
1010 |
'actions_summary' => _wpsf__( 'E.g. Import/Export' ),
|
1011 |
+
]
|
1012 |
);
|
1013 |
}
|
1014 |
|
1048 |
wp_localize_script(
|
1049 |
$this->prefix( 'global-plugin' ),
|
1050 |
'icwp_wpsf_vars_plugin',
|
1051 |
+
[
|
1052 |
'file' => $sFile,
|
1053 |
+
'ajax' => [
|
1054 |
'send_deactivate_survey' => $this->getAjaxActionData( 'send_deactivate_survey' ),
|
1055 |
+
],
|
1056 |
+
'hrefs' => [
|
1057 |
'deactivate' => Services::WpPlugins()->getUrl_Deactivate( $sFile ),
|
1058 |
+
],
|
1059 |
+
]
|
1060 |
);
|
1061 |
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
|
1062 |
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
1068 |
* @return array
|
1069 |
*/
|
1070 |
public function addInsightsConfigData( $aAllData ) {
|
1071 |
+
$aThis = [
|
1072 |
+
'strings' => [
|
1073 |
'title' => _wpsf__( 'General Settings' ),
|
1074 |
'sub' => sprintf( _wpsf__( 'General %s Settings' ), $this->getCon()->getHumanName() ),
|
1075 |
+
],
|
1076 |
'key_opts' => [],
|
1077 |
'href_options' => $this->getUrl_AdminPage()
|
1078 |
+
];
|
1079 |
|
1080 |
if ( $this->isModOptEnabled() ) {
|
1081 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
1082 |
}
|
1083 |
else {
|
1084 |
$sSource = $this->getOptionsVo()->getSelectOptionValueText( 'visitor_address_source' );
|
1085 |
+
$aThis[ 'key_opts' ][ 'editing' ] = [
|
1086 |
'name' => _wpsf__( 'Visitor IP' ),
|
1087 |
'enabled' => true,
|
1088 |
'summary' => sprintf( _wpsf__( 'Visitor IP address source is: %s' ), $sSource ),
|
1089 |
'weight' => 0,
|
1090 |
'href' => $this->getUrl_DirectLinkToOption( 'visitor_address_source' ),
|
1091 |
+
];
|
1092 |
|
1093 |
$bHasSupportEmail = Services::Data()->validEmail( $this->supplyPluginReportEmail() );
|
1094 |
+
$aThis[ 'key_opts' ][ 'reports' ] = [
|
1095 |
'name' => _wpsf__( 'Reporting Email' ),
|
1096 |
'enabled' => $bHasSupportEmail,
|
1097 |
'summary' => $bHasSupportEmail ?
|
1100 |
->getSiteAdminEmail() ),
|
1101 |
'weight' => 0,
|
1102 |
'href' => $this->getUrl_DirectLinkToOption( 'block_send_email_address' ),
|
1103 |
+
];
|
1104 |
|
1105 |
$bRecap = $this->isGoogleRecaptchaReady();
|
1106 |
+
$aThis[ 'key_opts' ][ 'recap' ] = [
|
1107 |
'name' => _wpsf__( 'reCAPTCHA' ),
|
1108 |
'enabled' => $bRecap,
|
1109 |
'summary' => $bRecap ?
|
1111 |
: _wpsf__( "Google reCAPTCHA keys haven't been provided" ),
|
1112 |
'weight' => 1,
|
1113 |
'href' => $this->getUrl_DirectLinkToOption( 'block_send_email_address' ),
|
1114 |
+
];
|
1115 |
}
|
1116 |
|
1117 |
$aAllData[ $this->getSlug() ] = $aThis;
|
1136 |
case 'section_defaults' :
|
1137 |
$sTitle = _wpsf__( 'Plugin Defaults' );
|
1138 |
$sTitleShort = _wpsf__( 'Plugin Defaults' );
|
1139 |
+
$aSummary = [
|
1140 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Important default settings used throughout the plugin.' ) ),
|
1141 |
+
];
|
1142 |
break;
|
1143 |
|
1144 |
case 'section_importexport' :
|
1145 |
$sTitle = sprintf( '%s / %s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) );
|
1146 |
+
$aSummary = [
|
1147 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatically import options, and deploy configurations across your entire network.' ) ),
|
1148 |
sprintf( _wpsf__( 'This is a Pro-only feature.' ) ),
|
1149 |
+
];
|
1150 |
$sTitleShort = sprintf( '%s / %s', _wpsf__( 'Import' ), _wpsf__( 'Export' ) );
|
1151 |
break;
|
1152 |
|
1158 |
case 'section_third_party_google' :
|
1159 |
$sTitle = _wpsf__( 'Google' );
|
1160 |
$sTitleShort = _wpsf__( 'Google' );
|
1161 |
+
$aSummary = [
|
1162 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), sprintf( _wpsf__( 'Setup Google reCAPTCHA for use across %s.' ), $sName ) ),
|
1163 |
sprintf( '%s - %s',
|
1164 |
_wpsf__( 'Recommendation' ),
|
1168 |
.sprintf( '<br/><a href="%s" target="_blank">%s</a>', 'https://www.google.com/recaptcha/admin', _wpsf__( 'API Keys' ) )
|
1169 |
),
|
1170 |
sprintf( '%s - %s', _wpsf__( 'Note' ), sprintf( _wpsf__( 'Invisible Google reCAPTCHA is available with %s Pro.' ), $sName ) )
|
1171 |
+
];
|
1172 |
break;
|
1173 |
|
1174 |
case 'section_third_party_duo' :
|
@@ -39,10 +39,10 @@ class ICWP_WPSF_FeatureHandler_Sessions extends ICWP_WPSF_FeatureHandler_BaseWps
|
|
39 |
|
40 |
case 'section_enable_plugin_feature_sessions' :
|
41 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
42 |
-
$aSummary =
|
43 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Creates and Manages User Sessions.' ) ),
|
44 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'User Management' ) ) )
|
45 |
-
|
46 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
47 |
break;
|
48 |
|
39 |
|
40 |
case 'section_enable_plugin_feature_sessions' :
|
41 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
42 |
+
$aSummary = [
|
43 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Creates and Manages User Sessions.' ) ),
|
44 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'User Management' ) ) )
|
45 |
+
];
|
46 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
47 |
break;
|
48 |
|
@@ -28,30 +28,30 @@ class ICWP_WPSF_FeatureHandler_Statistics extends ICWP_WPSF_FeatureHandler_BaseW
|
|
28 |
|
29 |
case 'section_enable_plugin_feature_statistics' :
|
30 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
31 |
-
$aSummary =
|
32 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Helps you see at a glance how effective the plugin has been.' ) ),
|
33 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $this->getMainFeatureName() ) )
|
34 |
-
|
35 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
36 |
break;
|
37 |
|
38 |
case 'section_enable_plugin_feature_reporting' :
|
39 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
40 |
-
$aSummary =
|
41 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'To track stats and issue reports.' ) ),
|
42 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $this->getMainFeatureName() ) )
|
43 |
-
|
44 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
45 |
break;
|
46 |
|
47 |
case 'section_stats_sharing' :
|
48 |
$sTitle = _wpsf__( 'Statistics Sharing' );
|
49 |
-
$aSummary =
|
50 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Help us to provide globally accessible statistics on the effectiveness of the plugin.' ) ),
|
51 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling this option helps us improve our plugin over time.' ) )
|
52 |
._wpsf__( 'All statistics data collection is 100% anonymous.' )._wpsf__( 'Neither we nor anyone else will be able to trace the data back to the originating site.' )
|
53 |
|
54 |
-
|
55 |
$sTitleShort = _wpsf__( 'Sharing' );
|
56 |
break;
|
57 |
|
28 |
|
29 |
case 'section_enable_plugin_feature_statistics' :
|
30 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
31 |
+
$aSummary = [
|
32 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Helps you see at a glance how effective the plugin has been.' ) ),
|
33 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $this->getMainFeatureName() ) )
|
34 |
+
];
|
35 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
36 |
break;
|
37 |
|
38 |
case 'section_enable_plugin_feature_reporting' :
|
39 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
40 |
+
$aSummary = [
|
41 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'To track stats and issue reports.' ) ),
|
42 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), $this->getMainFeatureName() ) )
|
43 |
+
];
|
44 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
45 |
break;
|
46 |
|
47 |
case 'section_stats_sharing' :
|
48 |
$sTitle = _wpsf__( 'Statistics Sharing' );
|
49 |
+
$aSummary = [
|
50 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Help us to provide globally accessible statistics on the effectiveness of the plugin.' ) ),
|
51 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Enabling this option helps us improve our plugin over time.' ) )
|
52 |
._wpsf__( 'All statistics data collection is 100% anonymous.' )._wpsf__( 'Neither we nor anyone else will be able to trace the data back to the originating site.' )
|
53 |
|
54 |
+
];
|
55 |
$sTitleShort = _wpsf__( 'Sharing' );
|
56 |
break;
|
57 |
|
@@ -188,13 +188,12 @@ class ICWP_WPSF_FeatureHandler_Traffic extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
188 |
$oPro = $this->getProcessor();
|
189 |
$oTableBuilder = ( new Shield\Tables\Build\Traffic() )
|
190 |
->setMod( $this )
|
191 |
-
->setDbHandler( $oPro->getProcessorLogger()->getDbHandler() )
|
192 |
-
->setGeoIpDbSource( $this->getCon()->getPath_Assets( 'db/GeoIp2/GeoLite2-Country.mmdb' ) );
|
193 |
|
194 |
-
return
|
195 |
'success' => true,
|
196 |
'html' => $oTableBuilder->buildTable()
|
197 |
-
|
198 |
}
|
199 |
|
200 |
/**
|
@@ -209,19 +208,19 @@ class ICWP_WPSF_FeatureHandler_Traffic extends ICWP_WPSF_FeatureHandler_BaseWpsf
|
|
209 |
|
210 |
case 'section_enable_plugin_feature_traffic' :
|
211 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
212 |
-
$aSummary =
|
213 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Monitor and review all requests to your site.' ) ),
|
214 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Required only if you need to review and investigate and monitor requests to your site' ) ) )
|
215 |
-
|
216 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
217 |
break;
|
218 |
|
219 |
case 'section_traffic_options' :
|
220 |
$sTitle = _wpsf__( 'Traffic Watch Options' );
|
221 |
-
$aSummary =
|
222 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control over the Traffic Watch system.' ) ),
|
223 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'These settings are dependent on your requirements.' ), _wpsf__( 'User Management' ) ) )
|
224 |
-
|
225 |
$sTitleShort = _wpsf__( 'Traffic Logging Options' );
|
226 |
break;
|
227 |
|
188 |
$oPro = $this->getProcessor();
|
189 |
$oTableBuilder = ( new Shield\Tables\Build\Traffic() )
|
190 |
->setMod( $this )
|
191 |
+
->setDbHandler( $oPro->getProcessorLogger()->getDbHandler() );
|
|
|
192 |
|
193 |
+
return [
|
194 |
'success' => true,
|
195 |
'html' => $oTableBuilder->buildTable()
|
196 |
+
];
|
197 |
}
|
198 |
|
199 |
/**
|
208 |
|
209 |
case 'section_enable_plugin_feature_traffic' :
|
210 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
211 |
+
$aSummary = [
|
212 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Monitor and review all requests to your site.' ) ),
|
213 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Required only if you need to review and investigate and monitor requests to your site' ) ) )
|
214 |
+
];
|
215 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
216 |
break;
|
217 |
|
218 |
case 'section_traffic_options' :
|
219 |
$sTitle = _wpsf__( 'Traffic Watch Options' );
|
220 |
+
$aSummary = [
|
221 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Provides finer control over the Traffic Watch system.' ) ),
|
222 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'These settings are dependent on your requirements.' ), _wpsf__( 'User Management' ) ) )
|
223 |
+
];
|
224 |
$sTitleShort = _wpsf__( 'Traffic Logging Options' );
|
225 |
break;
|
226 |
|
@@ -5,6 +5,8 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
5 |
|
6 |
class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
7 |
|
|
|
|
|
8 |
/**
|
9 |
* @param array $aAjaxResponse
|
10 |
* @return array
|
@@ -74,10 +76,10 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
74 |
}
|
75 |
}
|
76 |
|
77 |
-
return
|
78 |
'success' => $bSuccess,
|
79 |
'message' => $sMessage,
|
80 |
-
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -103,10 +105,10 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
103 |
$sMessage = _wpsf__( "User session wasn't deleted" );
|
104 |
}
|
105 |
|
106 |
-
return
|
107 |
'success' => $bSuccess,
|
108 |
'message' => $sMessage,
|
109 |
-
|
110 |
}
|
111 |
|
112 |
private function ajaxExec_BuildTableTraffic() {
|
@@ -124,10 +126,10 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
124 |
->setDbHandler( $this->getSessionsProcessor()->getDbHandler() )
|
125 |
->setSecAdminUsers( $oSecAdminMod->getSecurityAdminUsers() );
|
126 |
|
127 |
-
return
|
128 |
'success' => true,
|
129 |
'html' => $oTableBuilder->buildTable()
|
130 |
-
|
131 |
}
|
132 |
|
133 |
/**
|
@@ -167,22 +169,22 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
167 |
}
|
168 |
|
169 |
protected function doExtraSubmitProcessing() {
|
170 |
-
|
171 |
-
if ( !Services::Data()->validEmail( $sAdminEmail ) ) {
|
172 |
$this->getOptionsVo()->resetOptToDefault( 'enable_admin_login_email_notification' );
|
173 |
}
|
174 |
|
175 |
-
if ( $this->getOpt( 'session_username_concurrent_limit' ) < 0 ) {
|
176 |
-
$this->getOptionsVo()->resetOptToDefault( 'session_username_concurrent_limit' );
|
177 |
-
}
|
178 |
-
|
179 |
-
if ( $this->getOpt( 'session_timeout_interval' ) < 1 ) {
|
180 |
-
$this->getOptionsVo()->resetOptToDefault( 'session_timeout_interval' );
|
181 |
-
}
|
182 |
-
|
183 |
if ( $this->getIdleTimeoutInterval() > $this->getMaxSessionTime() ) {
|
184 |
$this->setOpt( 'session_idle_timeout_interval', $this->getOpt( 'session_timeout_interval' )*24 );
|
185 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
}
|
187 |
|
188 |
/**
|
@@ -205,7 +207,7 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
205 |
protected function getDisplayStrings() {
|
206 |
return $this->loadDP()->mergeArraysRecursive(
|
207 |
parent::getDisplayStrings(),
|
208 |
-
|
209 |
'um_current_user_settings' => _wpsf__( 'Current User Sessions' ),
|
210 |
'um_username' => _wpsf__( 'Username' ),
|
211 |
'um_logged_in_at' => _wpsf__( 'Logged In At' ),
|
@@ -213,7 +215,7 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
213 |
'um_last_activity_uri' => _wpsf__( 'Last Activity URI' ),
|
214 |
'um_login_ip' => _wpsf__( 'Login IP' ),
|
215 |
'um_need_to_enable_user_management' => _wpsf__( 'You need to enable the User Management feature to view and manage user sessions.' ),
|
216 |
-
|
217 |
);
|
218 |
}
|
219 |
|
@@ -283,13 +285,13 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
283 |
* @return int
|
284 |
*/
|
285 |
public function getPassStrengthName( $nStrength ) {
|
286 |
-
$aMap =
|
287 |
_wpsf__( 'Very Weak' ),
|
288 |
_wpsf__( 'Weak' ),
|
289 |
_wpsf__( 'Medium' ),
|
290 |
_wpsf__( 'Strong' ),
|
291 |
_wpsf__( 'Very Strong' ),
|
292 |
-
|
293 |
return $aMap[ max( 0, min( 4, $nStrength ) ) ];
|
294 |
}
|
295 |
|
@@ -322,11 +324,15 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
322 |
return $this->isOpt( 'pass_prevent_pwned', 'Y' );
|
323 |
}
|
324 |
|
|
|
|
|
|
|
325 |
public function isSuspendEnabled() {
|
326 |
-
return
|
|
|
327 |
|| $this->isSuspendAutoIdleEnabled()
|
328 |
|| $this->isSuspendAutoPasswordEnabled()
|
329 |
-
)
|
330 |
}
|
331 |
|
332 |
/**
|
@@ -340,14 +346,23 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
340 |
* @return int
|
341 |
*/
|
342 |
public function getSuspendAutoIdleTime() {
|
343 |
-
return $this->getOpt( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
* @return bool
|
348 |
*/
|
349 |
public function isSuspendAutoIdleEnabled() {
|
350 |
-
return $this->getSuspendAutoIdleTime() > 0
|
|
|
351 |
}
|
352 |
|
353 |
/**
|
@@ -359,18 +374,40 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
359 |
}
|
360 |
|
361 |
/**
|
362 |
-
* @param int $
|
363 |
* @param bool $bAdd - set true to add, false to remove
|
364 |
* @return $this
|
365 |
*/
|
366 |
-
public function addRemoveHardSuspendUserId( $
|
|
|
|
|
367 |
$aIds = $this->getOpt( 'hard_suspended_userids', [] );
|
368 |
-
if ( $
|
369 |
-
$aIds
|
370 |
}
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
}
|
|
|
374 |
return $this->setOpt( 'hard_suspended_userids', $aIds );
|
375 |
}
|
376 |
|
@@ -388,32 +425,32 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
388 |
*/
|
389 |
public function addInsightsNoticeData( $aAllNotices ) {
|
390 |
|
391 |
-
$aNotices =
|
392 |
'title' => _wpsf__( 'Users' ),
|
393 |
'messages' => []
|
394 |
-
|
395 |
|
396 |
{ //admin user
|
397 |
$oAdmin = Services::WpUsers()->getUserByUsername( 'admin' );
|
398 |
if ( !empty( $oAdmin ) && user_can( $oAdmin, 'manage_options' ) ) {
|
399 |
-
$aNotices[ 'messages' ][ 'admin' ] =
|
400 |
'title' => 'Admin User',
|
401 |
'message' => sprintf( _wpsf__( "Default 'admin' user still available." ) ),
|
402 |
'href' => '',
|
403 |
'rec' => _wpsf__( "Default 'admin' user should be disabled or removed." )
|
404 |
-
|
405 |
}
|
406 |
}
|
407 |
|
408 |
{//password policies
|
409 |
if ( !$this->isPasswordPoliciesEnabled() ) {
|
410 |
-
$aNotices[ 'messages' ][ 'password' ] =
|
411 |
'title' => 'Password Policies',
|
412 |
'message' => _wpsf__( "Strong password policies are not enforced." ),
|
413 |
'href' => $this->getUrl_DirectLinkToSection( 'section_passwords' ),
|
414 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
415 |
'rec' => _wpsf__( 'Password policies should be turned-on.' )
|
416 |
-
|
417 |
}
|
418 |
}
|
419 |
|
@@ -428,21 +465,21 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
428 |
* @return array
|
429 |
*/
|
430 |
public function addInsightsConfigData( $aAllData ) {
|
431 |
-
$aThis =
|
432 |
-
'strings' =>
|
433 |
'title' => _wpsf__( 'User Management' ),
|
434 |
'sub' => _wpsf__( 'Sessions Control & Password Policies' ),
|
435 |
-
|
436 |
'key_opts' => [],
|
437 |
'href_options' => $this->getUrl_AdminPage()
|
438 |
-
|
439 |
|
440 |
if ( !$this->isModOptEnabled() ) {
|
441 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
442 |
}
|
443 |
else {
|
444 |
$bHasIdle = $this->hasSessionIdleTimeout();
|
445 |
-
$aThis[ 'key_opts' ][ 'idle' ] =
|
446 |
'name' => _wpsf__( 'Idle Users' ),
|
447 |
'enabled' => $bHasIdle,
|
448 |
'summary' => $bHasIdle ?
|
@@ -450,10 +487,10 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
450 |
: _wpsf__( 'Idle sessions wont be terminated' ),
|
451 |
'weight' => 2,
|
452 |
'href' => $this->getUrl_DirectLinkToOption( 'session_idle_timeout_interval' ),
|
453 |
-
|
454 |
|
455 |
$bLocked = $this->isLockToIp();
|
456 |
-
$aThis[ 'key_opts' ][ 'lock' ] =
|
457 |
'name' => _wpsf__( 'Lock To IP' ),
|
458 |
'enabled' => $bLocked,
|
459 |
'summary' => $bLocked ?
|
@@ -461,12 +498,12 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
461 |
: _wpsf__( "Sessions aren't locked to IP address" ),
|
462 |
'weight' => 1,
|
463 |
'href' => $this->getUrl_DirectLinkToOption( 'session_lock_location' ),
|
464 |
-
|
465 |
|
466 |
$bPolicies = $this->isPasswordPoliciesEnabled();
|
467 |
|
468 |
$bPwned = $bPolicies && $this->isPassPreventPwned();
|
469 |
-
$aThis[ 'key_opts' ][ 'pwned' ] =
|
470 |
'name' => _wpsf__( 'Pwned Passwords' ),
|
471 |
'enabled' => $bPwned,
|
472 |
'summary' => $bPwned ?
|
@@ -474,10 +511,10 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
474 |
: _wpsf__( 'Pwned passwords are allowed on this site' ),
|
475 |
'weight' => 2,
|
476 |
'href' => $this->getUrl_DirectLinkToOption( 'pass_prevent_pwned' ),
|
477 |
-
|
478 |
|
479 |
$bIndepthPolices = $bPolicies && $this->isPremium();
|
480 |
-
$aThis[ 'key_opts' ][ 'policies' ] =
|
481 |
'name' => _wpsf__( 'Password Policies' ),
|
482 |
'enabled' => $bIndepthPolices,
|
483 |
'summary' => $bIndepthPolices ?
|
@@ -485,7 +522,7 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
485 |
: _wpsf__( 'Limited or no password polices are active' ),
|
486 |
'weight' => 2,
|
487 |
'href' => $this->getUrl_DirectLinkToSection( 'section_passwords' ),
|
488 |
-
|
489 |
}
|
490 |
|
491 |
$aAllData[ $this->getSlug() ] = $aThis;
|
@@ -504,57 +541,57 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
504 |
|
505 |
case 'section_enable_plugin_feature_user_accounts_management' :
|
506 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
507 |
-
$aSummary =
|
508 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'User Management offers real user sessions, finer control over user session time-out, and ensures users have logged-in in a correct manner.' ) ),
|
509 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'User Management' ) ) )
|
510 |
-
|
511 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
512 |
break;
|
513 |
|
514 |
case 'section_passwords' :
|
515 |
$sTitle = _wpsf__( 'Password Policies' );
|
516 |
$sTitleShort = _wpsf__( 'Password Policies' );
|
517 |
-
$aSummary =
|
518 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Have full control over passwords used by users on the site.' ) ),
|
519 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
520 |
sprintf( '%s - %s', _wpsf__( 'Requirements' ), sprintf( 'WordPress v%s+', '4.4.0' ) ),
|
521 |
-
|
522 |
break;
|
523 |
|
524 |
case 'section_admin_login_notification' :
|
525 |
$sTitle = _wpsf__( 'Admin Login Notification' );
|
526 |
-
$aSummary =
|
527 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'So you can be made aware of when a WordPress administrator has logged into your site when you are not expecting it.' ) ),
|
528 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
529 |
-
|
530 |
$sTitleShort = _wpsf__( 'Notifications' );
|
531 |
break;
|
532 |
|
533 |
case 'section_multifactor_authentication' :
|
534 |
$sTitle = _wpsf__( 'Multi-Factor User Authentication' );
|
535 |
-
$aSummary =
|
536 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site - i.e. they are who they say they are.' ) ),
|
537 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ).' '._wpsf__( 'However, if your host blocks email sending you may lock yourself out.' ) )
|
538 |
-
|
539 |
$sTitleShort = _wpsf__( 'Multi-Factor Authentication' );
|
540 |
break;
|
541 |
|
542 |
case 'section_user_session_management' :
|
543 |
$sTitle = _wpsf__( 'User Session Management' );
|
544 |
-
$aSummary =
|
545 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Allows you to better control user sessions on your site and expire idle sessions and prevent account sharing.' ) ),
|
546 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
547 |
-
|
548 |
$sTitleShort = _wpsf__( 'Session Options' );
|
549 |
break;
|
550 |
|
551 |
case 'section_suspend' :
|
552 |
$sTitleShort = _wpsf__( 'User Suspension' );
|
553 |
$sTitle = _wpsf__( 'Automatic And Manual User Suspension' );
|
554 |
-
$aSummary =
|
555 |
-
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatically
|
556 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
557 |
-
|
558 |
break;
|
559 |
|
560 |
default:
|
@@ -573,8 +610,8 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
573 |
*/
|
574 |
protected function loadStrings_Options( $aOptionsParams ) {
|
575 |
|
576 |
-
$
|
577 |
-
switch ( $
|
578 |
|
579 |
case 'enable_user_management' :
|
580 |
$sName = sprintf( _wpsf__( 'Enable %s Module' ), $this->getMainFeatureName() );
|
@@ -668,13 +705,13 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
668 |
case 'manual_suspend' :
|
669 |
$sName = _wpsf__( 'Allow Manual User Suspension' );
|
670 |
$sSummary = _wpsf__( 'Manually Suspend User Accounts To Prevent Login' );
|
671 |
-
$sDescription = _wpsf__( 'Users may be
|
672 |
break;
|
673 |
|
674 |
case 'auto_password' :
|
675 |
$sName = _wpsf__( 'Auto-Suspend Expired Passwords' );
|
676 |
$sSummary = _wpsf__( 'Automatically Suspend Users With Expired Passwords' );
|
677 |
-
$sDescription = _wpsf__( 'Automatically
|
678 |
.'<br/>'.sprintf(
|
679 |
'<strong>%s</strong> - %s',
|
680 |
_wpsf__( 'Important' ),
|
@@ -682,16 +719,26 @@ class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_B
|
|
682 |
);
|
683 |
break;
|
684 |
|
685 |
-
case '
|
686 |
$sName = _wpsf__( 'Auto-Suspend Idle Users' );
|
687 |
$sSummary = _wpsf__( 'Automatically Suspend Idle User Accounts' );
|
688 |
-
$sDescription = _wpsf__( 'Automatically
|
689 |
.'<br/>'._wpsf__( 'Specify the number of days since last login to consider a user as idle.' )
|
690 |
.'<br/>'._wpsf__( 'Set to Zero(0) to disable.' );
|
691 |
break;
|
692 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
default:
|
694 |
-
throw new \Exception( sprintf( 'An option has been defined but without strings assigned to it. Option key: "%s".', $
|
695 |
}
|
696 |
|
697 |
$aOptionsParams[ 'name' ] = $sName;
|
5 |
|
6 |
class ICWP_WPSF_FeatureHandler_UserManagement extends ICWP_WPSF_FeatureHandler_BaseWpsf {
|
7 |
|
8 |
+
use Shield\AuditTrail\Auditor;
|
9 |
+
|
10 |
/**
|
11 |
* @param array $aAjaxResponse
|
12 |
* @return array
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
return [
|
80 |
'success' => $bSuccess,
|
81 |
'message' => $sMessage,
|
82 |
+
];
|
83 |
}
|
84 |
|
85 |
/**
|
105 |
$sMessage = _wpsf__( "User session wasn't deleted" );
|
106 |
}
|
107 |
|
108 |
+
return [
|
109 |
'success' => $bSuccess,
|
110 |
'message' => $sMessage,
|
111 |
+
];
|
112 |
}
|
113 |
|
114 |
private function ajaxExec_BuildTableTraffic() {
|
126 |
->setDbHandler( $this->getSessionsProcessor()->getDbHandler() )
|
127 |
->setSecAdminUsers( $oSecAdminMod->getSecurityAdminUsers() );
|
128 |
|
129 |
+
return [
|
130 |
'success' => true,
|
131 |
'html' => $oTableBuilder->buildTable()
|
132 |
+
];
|
133 |
}
|
134 |
|
135 |
/**
|
169 |
}
|
170 |
|
171 |
protected function doExtraSubmitProcessing() {
|
172 |
+
if ( !Services::Data()->validEmail( $this->getAdminLoginNotificationEmail() ) ) {
|
|
|
173 |
$this->getOptionsVo()->resetOptToDefault( 'enable_admin_login_email_notification' );
|
174 |
}
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
if ( $this->getIdleTimeoutInterval() > $this->getMaxSessionTime() ) {
|
177 |
$this->setOpt( 'session_idle_timeout_interval', $this->getOpt( 'session_timeout_interval' )*24 );
|
178 |
}
|
179 |
+
|
180 |
+
$this->setOpt( 'auto_idle_roles',
|
181 |
+
array_unique( array_filter( array_map(
|
182 |
+
function ( $sRole ) {
|
183 |
+
return preg_replace( '#[^\sa-z0-9_-]#i', '', trim( strtolower( $sRole ) ) );
|
184 |
+
},
|
185 |
+
$this->getSuspendAutoIdleUserRoles()
|
186 |
+
) ) )
|
187 |
+
);
|
188 |
}
|
189 |
|
190 |
/**
|
207 |
protected function getDisplayStrings() {
|
208 |
return $this->loadDP()->mergeArraysRecursive(
|
209 |
parent::getDisplayStrings(),
|
210 |
+
[
|
211 |
'um_current_user_settings' => _wpsf__( 'Current User Sessions' ),
|
212 |
'um_username' => _wpsf__( 'Username' ),
|
213 |
'um_logged_in_at' => _wpsf__( 'Logged In At' ),
|
215 |
'um_last_activity_uri' => _wpsf__( 'Last Activity URI' ),
|
216 |
'um_login_ip' => _wpsf__( 'Login IP' ),
|
217 |
'um_need_to_enable_user_management' => _wpsf__( 'You need to enable the User Management feature to view and manage user sessions.' ),
|
218 |
+
]
|
219 |
);
|
220 |
}
|
221 |
|
285 |
* @return int
|
286 |
*/
|
287 |
public function getPassStrengthName( $nStrength ) {
|
288 |
+
$aMap = [
|
289 |
_wpsf__( 'Very Weak' ),
|
290 |
_wpsf__( 'Weak' ),
|
291 |
_wpsf__( 'Medium' ),
|
292 |
_wpsf__( 'Strong' ),
|
293 |
_wpsf__( 'Very Strong' ),
|
294 |
+
];
|
295 |
return $aMap[ max( 0, min( 4, $nStrength ) ) ];
|
296 |
}
|
297 |
|
324 |
return $this->isOpt( 'pass_prevent_pwned', 'Y' );
|
325 |
}
|
326 |
|
327 |
+
/**
|
328 |
+
* @return bool
|
329 |
+
*/
|
330 |
public function isSuspendEnabled() {
|
331 |
+
return $this->isPremium() &&
|
332 |
+
( $this->isSuspendManualEnabled()
|
333 |
|| $this->isSuspendAutoIdleEnabled()
|
334 |
|| $this->isSuspendAutoPasswordEnabled()
|
335 |
+
);
|
336 |
}
|
337 |
|
338 |
/**
|
346 |
* @return int
|
347 |
*/
|
348 |
public function getSuspendAutoIdleTime() {
|
349 |
+
return $this->getOpt( 'auto_idle_days', 0 )*DAY_IN_SECONDS;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* @return array
|
354 |
+
*/
|
355 |
+
public function getSuspendAutoIdleUserRoles() {
|
356 |
+
$aRoles = $this->getOpt( 'auto_idle_roles', [] );
|
357 |
+
return is_array( $aRoles ) ? $aRoles : [];
|
358 |
}
|
359 |
|
360 |
/**
|
361 |
* @return bool
|
362 |
*/
|
363 |
public function isSuspendAutoIdleEnabled() {
|
364 |
+
return ( $this->getSuspendAutoIdleTime() > 0 )
|
365 |
+
&& ( count( $this->getSuspendAutoIdleUserRoles() ) > 0 );
|
366 |
}
|
367 |
|
368 |
/**
|
374 |
}
|
375 |
|
376 |
/**
|
377 |
+
* @param int $nUserId
|
378 |
* @param bool $bAdd - set true to add, false to remove
|
379 |
* @return $this
|
380 |
*/
|
381 |
+
public function addRemoveHardSuspendUserId( $nUserId, $bAdd = true ) {
|
382 |
+
$sAdminUser = Services::WpUsers()->getCurrentWpUsername();
|
383 |
+
|
384 |
$aIds = $this->getOpt( 'hard_suspended_userids', [] );
|
385 |
+
if ( !is_array( $aIds ) ) {
|
386 |
+
$aIds = [];
|
387 |
}
|
388 |
+
|
389 |
+
$bIdSuspended = isset( $aIds[ $nUserId ] );
|
390 |
+
$oMeta = $this->getCon()->getUserMeta( Services::WpUsers()->getUserById( $nUserId ) );
|
391 |
+
|
392 |
+
if ( $bAdd && !$bIdSuspended ) {
|
393 |
+
$oMeta->hard_suspended_at = Services::Request()->ts();
|
394 |
+
$aIds[ $nUserId ] = $oMeta->hard_suspended_at;
|
395 |
+
$this->createNewAudit(
|
396 |
+
'wpsf',
|
397 |
+
sprintf( _wpsf__( 'User ID %s suspended by admin (%s)' ), $nUserId, $sAdminUser ),
|
398 |
+
1, 'suspend_user'
|
399 |
+
);
|
400 |
+
}
|
401 |
+
else if ( !$bAdd && $bIdSuspended ) {
|
402 |
+
$oMeta->hard_suspended_at = 0;
|
403 |
+
unset( $aIds[ $nUserId ] );
|
404 |
+
$this->createNewAudit(
|
405 |
+
'wpsf',
|
406 |
+
sprintf( _wpsf__( 'User ID %s unsuspended by admin (%s)' ), $nUserId, $sAdminUser ),
|
407 |
+
1, 'unsuspend_user'
|
408 |
+
);
|
409 |
}
|
410 |
+
|
411 |
return $this->setOpt( 'hard_suspended_userids', $aIds );
|
412 |
}
|
413 |
|
425 |
*/
|
426 |
public function addInsightsNoticeData( $aAllNotices ) {
|
427 |
|
428 |
+
$aNotices = [
|
429 |
'title' => _wpsf__( 'Users' ),
|
430 |
'messages' => []
|
431 |
+
];
|
432 |
|
433 |
{ //admin user
|
434 |
$oAdmin = Services::WpUsers()->getUserByUsername( 'admin' );
|
435 |
if ( !empty( $oAdmin ) && user_can( $oAdmin, 'manage_options' ) ) {
|
436 |
+
$aNotices[ 'messages' ][ 'admin' ] = [
|
437 |
'title' => 'Admin User',
|
438 |
'message' => sprintf( _wpsf__( "Default 'admin' user still available." ) ),
|
439 |
'href' => '',
|
440 |
'rec' => _wpsf__( "Default 'admin' user should be disabled or removed." )
|
441 |
+
];
|
442 |
}
|
443 |
}
|
444 |
|
445 |
{//password policies
|
446 |
if ( !$this->isPasswordPoliciesEnabled() ) {
|
447 |
+
$aNotices[ 'messages' ][ 'password' ] = [
|
448 |
'title' => 'Password Policies',
|
449 |
'message' => _wpsf__( "Strong password policies are not enforced." ),
|
450 |
'href' => $this->getUrl_DirectLinkToSection( 'section_passwords' ),
|
451 |
'action' => sprintf( 'Go To %s', _wpsf__( 'Options' ) ),
|
452 |
'rec' => _wpsf__( 'Password policies should be turned-on.' )
|
453 |
+
];
|
454 |
}
|
455 |
}
|
456 |
|
465 |
* @return array
|
466 |
*/
|
467 |
public function addInsightsConfigData( $aAllData ) {
|
468 |
+
$aThis = [
|
469 |
+
'strings' => [
|
470 |
'title' => _wpsf__( 'User Management' ),
|
471 |
'sub' => _wpsf__( 'Sessions Control & Password Policies' ),
|
472 |
+
],
|
473 |
'key_opts' => [],
|
474 |
'href_options' => $this->getUrl_AdminPage()
|
475 |
+
];
|
476 |
|
477 |
if ( !$this->isModOptEnabled() ) {
|
478 |
$aThis[ 'key_opts' ][ 'mod' ] = $this->getModDisabledInsight();
|
479 |
}
|
480 |
else {
|
481 |
$bHasIdle = $this->hasSessionIdleTimeout();
|
482 |
+
$aThis[ 'key_opts' ][ 'idle' ] = [
|
483 |
'name' => _wpsf__( 'Idle Users' ),
|
484 |
'enabled' => $bHasIdle,
|
485 |
'summary' => $bHasIdle ?
|
487 |
: _wpsf__( 'Idle sessions wont be terminated' ),
|
488 |
'weight' => 2,
|
489 |
'href' => $this->getUrl_DirectLinkToOption( 'session_idle_timeout_interval' ),
|
490 |
+
];
|
491 |
|
492 |
$bLocked = $this->isLockToIp();
|
493 |
+
$aThis[ 'key_opts' ][ 'lock' ] = [
|
494 |
'name' => _wpsf__( 'Lock To IP' ),
|
495 |
'enabled' => $bLocked,
|
496 |
'summary' => $bLocked ?
|
498 |
: _wpsf__( "Sessions aren't locked to IP address" ),
|
499 |
'weight' => 1,
|
500 |
'href' => $this->getUrl_DirectLinkToOption( 'session_lock_location' ),
|
501 |
+
];
|
502 |
|
503 |
$bPolicies = $this->isPasswordPoliciesEnabled();
|
504 |
|
505 |
$bPwned = $bPolicies && $this->isPassPreventPwned();
|
506 |
+
$aThis[ 'key_opts' ][ 'pwned' ] = [
|
507 |
'name' => _wpsf__( 'Pwned Passwords' ),
|
508 |
'enabled' => $bPwned,
|
509 |
'summary' => $bPwned ?
|
511 |
: _wpsf__( 'Pwned passwords are allowed on this site' ),
|
512 |
'weight' => 2,
|
513 |
'href' => $this->getUrl_DirectLinkToOption( 'pass_prevent_pwned' ),
|
514 |
+
];
|
515 |
|
516 |
$bIndepthPolices = $bPolicies && $this->isPremium();
|
517 |
+
$aThis[ 'key_opts' ][ 'policies' ] = [
|
518 |
'name' => _wpsf__( 'Password Policies' ),
|
519 |
'enabled' => $bIndepthPolices,
|
520 |
'summary' => $bIndepthPolices ?
|
522 |
: _wpsf__( 'Limited or no password polices are active' ),
|
523 |
'weight' => 2,
|
524 |
'href' => $this->getUrl_DirectLinkToSection( 'section_passwords' ),
|
525 |
+
];
|
526 |
}
|
527 |
|
528 |
$aAllData[ $this->getSlug() ] = $aThis;
|
541 |
|
542 |
case 'section_enable_plugin_feature_user_accounts_management' :
|
543 |
$sTitle = sprintf( _wpsf__( 'Enable Module: %s' ), $this->getMainFeatureName() );
|
544 |
+
$aSummary = [
|
545 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'User Management offers real user sessions, finer control over user session time-out, and ensures users have logged-in in a correct manner.' ) ),
|
546 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), sprintf( _wpsf__( 'Keep the %s feature turned on.' ), _wpsf__( 'User Management' ) ) )
|
547 |
+
];
|
548 |
$sTitleShort = sprintf( _wpsf__( '%s/%s Module' ), _wpsf__( 'Enable' ), _wpsf__( 'Disable' ) );
|
549 |
break;
|
550 |
|
551 |
case 'section_passwords' :
|
552 |
$sTitle = _wpsf__( 'Password Policies' );
|
553 |
$sTitleShort = _wpsf__( 'Password Policies' );
|
554 |
+
$aSummary = [
|
555 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Have full control over passwords used by users on the site.' ) ),
|
556 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) ),
|
557 |
sprintf( '%s - %s', _wpsf__( 'Requirements' ), sprintf( 'WordPress v%s+', '4.4.0' ) ),
|
558 |
+
];
|
559 |
break;
|
560 |
|
561 |
case 'section_admin_login_notification' :
|
562 |
$sTitle = _wpsf__( 'Admin Login Notification' );
|
563 |
+
$aSummary = [
|
564 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'So you can be made aware of when a WordPress administrator has logged into your site when you are not expecting it.' ) ),
|
565 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
566 |
+
];
|
567 |
$sTitleShort = _wpsf__( 'Notifications' );
|
568 |
break;
|
569 |
|
570 |
case 'section_multifactor_authentication' :
|
571 |
$sTitle = _wpsf__( 'Multi-Factor User Authentication' );
|
572 |
+
$aSummary = [
|
573 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Verifies the identity of users who log in to your site - i.e. they are who they say they are.' ) ),
|
574 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ).' '._wpsf__( 'However, if your host blocks email sending you may lock yourself out.' ) )
|
575 |
+
];
|
576 |
$sTitleShort = _wpsf__( 'Multi-Factor Authentication' );
|
577 |
break;
|
578 |
|
579 |
case 'section_user_session_management' :
|
580 |
$sTitle = _wpsf__( 'User Session Management' );
|
581 |
+
$aSummary = [
|
582 |
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Allows you to better control user sessions on your site and expire idle sessions and prevent account sharing.' ) ),
|
583 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
584 |
+
];
|
585 |
$sTitleShort = _wpsf__( 'Session Options' );
|
586 |
break;
|
587 |
|
588 |
case 'section_suspend' :
|
589 |
$sTitleShort = _wpsf__( 'User Suspension' );
|
590 |
$sTitle = _wpsf__( 'Automatic And Manual User Suspension' );
|
591 |
+
$aSummary = [
|
592 |
+
sprintf( '%s - %s', _wpsf__( 'Purpose' ), _wpsf__( 'Automatically suspends accounts to prevent login by certain users.' ) ),
|
593 |
sprintf( '%s - %s', _wpsf__( 'Recommendation' ), _wpsf__( 'Use of this feature is highly recommend.' ) )
|
594 |
+
];
|
595 |
break;
|
596 |
|
597 |
default:
|
610 |
*/
|
611 |
protected function loadStrings_Options( $aOptionsParams ) {
|
612 |
|
613 |
+
$oOptsVo = $this->getOptionsVo();
|
614 |
+
switch ( $aOptionsParams[ 'key' ] ) {
|
615 |
|
616 |
case 'enable_user_management' :
|
617 |
$sName = sprintf( _wpsf__( 'Enable %s Module' ), $this->getMainFeatureName() );
|
705 |
case 'manual_suspend' :
|
706 |
$sName = _wpsf__( 'Allow Manual User Suspension' );
|
707 |
$sSummary = _wpsf__( 'Manually Suspend User Accounts To Prevent Login' );
|
708 |
+
$sDescription = _wpsf__( 'Users may be suspended by administrators to prevent future login.' );
|
709 |
break;
|
710 |
|
711 |
case 'auto_password' :
|
712 |
$sName = _wpsf__( 'Auto-Suspend Expired Passwords' );
|
713 |
$sSummary = _wpsf__( 'Automatically Suspend Users With Expired Passwords' );
|
714 |
+
$sDescription = _wpsf__( 'Automatically suspends login by users and requires password reset to unsuspend.' )
|
715 |
.'<br/>'.sprintf(
|
716 |
'<strong>%s</strong> - %s',
|
717 |
_wpsf__( 'Important' ),
|
719 |
);
|
720 |
break;
|
721 |
|
722 |
+
case 'auto_idle_days' :
|
723 |
$sName = _wpsf__( 'Auto-Suspend Idle Users' );
|
724 |
$sSummary = _wpsf__( 'Automatically Suspend Idle User Accounts' );
|
725 |
+
$sDescription = _wpsf__( 'Automatically suspends login for idle accounts and requires password reset to unsuspend.' )
|
726 |
.'<br/>'._wpsf__( 'Specify the number of days since last login to consider a user as idle.' )
|
727 |
.'<br/>'._wpsf__( 'Set to Zero(0) to disable.' );
|
728 |
break;
|
729 |
|
730 |
+
case 'auto_idle_roles' :
|
731 |
+
$sName = _wpsf__( 'Auto-Suspend Idle User Roles' );
|
732 |
+
$sSummary = _wpsf__( 'Apply Automatic Suspension To Accounts With These Roles' );
|
733 |
+
$sDescription = _wpsf__( 'Automatic suspension for idle accounts applies only to the roles you specify.' )
|
734 |
+
.'<br/>'.sprintf( '%s: %s', _wpsf__( 'Important' ), _wpsf__( 'Take a new line for each user role.' ) )
|
735 |
+
.'<br/>'.sprintf( '%s: %s', _wpsf__( 'Available Roles' ), implode( ', ', Services::WpUsers()
|
736 |
+
->getAvailableUserRoles() ) )
|
737 |
+
.'<br/>'.sprintf( '%s: %s', _wpsf__( 'Default' ), implode( ', ', $oOptsVo->getOptDefault( 'auto_idle_roles' ) ) );
|
738 |
+
break;
|
739 |
+
|
740 |
default:
|
741 |
+
throw new \Exception( sprintf( 'An option has been defined but without strings assigned to it. Option key: "%s".', $aOptionsParams[ 'key' ] ) );
|
742 |
}
|
743 |
|
744 |
$aOptionsParams[ 'name' ] = $sName;
|
@@ -16,11 +16,11 @@ trait StandardCron {
|
|
16 |
Services::WpCron()
|
17 |
->setRecurrence( $this->getCronRecurrence() )
|
18 |
->setNextRun( $this->getFirstRunTimestamp() )
|
19 |
-
->createCronJob( $this->getCronName(),
|
20 |
}
|
21 |
catch ( \Exception $oE ) {
|
22 |
}
|
23 |
-
add_action( $this->prefix( 'deactivate_plugin' ),
|
24 |
}
|
25 |
|
26 |
/**
|
16 |
Services::WpCron()
|
17 |
->setRecurrence( $this->getCronRecurrence() )
|
18 |
->setNextRun( $this->getFirstRunTimestamp() )
|
19 |
+
->createCronJob( $this->getCronName(), [ $this, 'runCron' ] );
|
20 |
}
|
21 |
catch ( \Exception $oE ) {
|
22 |
}
|
23 |
+
add_action( $this->prefix( 'deactivate_plugin' ), [ $this, 'deleteCron' ] );
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -130,11 +130,11 @@ abstract class BaseQuery {
|
|
130 |
*/
|
131 |
public function buildExtras() {
|
132 |
$aExtras = array_filter(
|
133 |
-
|
134 |
$this->getOrderBy(),
|
135 |
$this->buildLimitPhrase(),
|
136 |
$this->buildOffsetPhrase(),
|
137 |
-
|
138 |
);
|
139 |
return implode( "\n", $aExtras );
|
140 |
}
|
@@ -359,7 +359,7 @@ abstract class BaseQuery {
|
|
359 |
protected function isValidComparisonOperator( $sOp ) {
|
360 |
return in_array(
|
361 |
strtoupper( $sOp ),
|
362 |
-
|
363 |
);
|
364 |
}
|
365 |
}
|
130 |
*/
|
131 |
public function buildExtras() {
|
132 |
$aExtras = array_filter(
|
133 |
+
[
|
134 |
$this->getOrderBy(),
|
135 |
$this->buildLimitPhrase(),
|
136 |
$this->buildOffsetPhrase(),
|
137 |
+
]
|
138 |
);
|
139 |
return implode( "\n", $aExtras );
|
140 |
}
|
359 |
protected function isValidComparisonOperator( $sOp ) {
|
360 |
return in_array(
|
361 |
strtoupper( $sOp ),
|
362 |
+
[ '=', '<', '>', '!=', '<>', '<=', '>=', '<=>', 'IN', 'LIKE', 'NOT LIKE' ]
|
363 |
);
|
364 |
}
|
365 |
}
|
@@ -97,7 +97,7 @@ class Select extends BaseQuery {
|
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
-
* @return EntryVO|\stdClass|null
|
101 |
*/
|
102 |
public function first() {
|
103 |
$aR = $this->query();
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
+
* @return EntryVO|\stdClass|mixed|null
|
101 |
*/
|
102 |
public function first() {
|
103 |
$aR = $this->query();
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
trait BaseGeoIp {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Will test whether the Binary IP can be converted back before applying filter.
|
9 |
+
* @param mixed $bBinaryIp - IP has already been converted using inet_pton
|
10 |
+
* @return $this
|
11 |
+
*/
|
12 |
+
public function filterByIp( $bBinaryIp ) {
|
13 |
+
if ( inet_ntop( $bBinaryIp ) !== false ) {
|
14 |
+
$this->addWhereEquals( 'ip', $bBinaryIp );
|
15 |
+
}
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Will test whether the Binary IP can be converted back before applying filter.
|
21 |
+
* @param mixed $bBinaryIp - IP has already been converted using inet_pton
|
22 |
+
* @return $this
|
23 |
+
*/
|
24 |
+
public function filterByNotIp( $bBinaryIp ) {
|
25 |
+
if ( inet_ntop( $bBinaryIp ) !== false ) {
|
26 |
+
$this->addWhere( 'ip', $bBinaryIp, '!=' );
|
27 |
+
}
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
}
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Base;
|
6 |
+
|
7 |
+
class Delete extends Base\Delete {
|
8 |
+
use BaseGeoIp;
|
9 |
+
}
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Base;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class EntryVO
|
9 |
+
* @property string rid
|
10 |
+
* @property int uid
|
11 |
+
* @property string ip
|
12 |
+
* @property string path
|
13 |
+
* @property string code
|
14 |
+
* @property string ua
|
15 |
+
* @property string verb
|
16 |
+
* @property bool trans
|
17 |
+
*/
|
18 |
+
class EntryVO extends Base\EntryVO {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getCountryCode() {
|
24 |
+
return isset( $this->meta[ 'countryCode' ] ) ? $this->meta[ 'countryCode' ] : '';
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
public function getCountryName() {
|
31 |
+
return isset( $this->meta[ 'countryName' ] ) ? $this->meta[ 'countryName' ] : '';
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param string $sProperty
|
36 |
+
* @return mixed
|
37 |
+
*/
|
38 |
+
public function __get( $sProperty ) {
|
39 |
+
switch ( $sProperty ) {
|
40 |
+
|
41 |
+
case 'ip':
|
42 |
+
$mVal = inet_ntop( parent::__get( $sProperty ) );
|
43 |
+
break;
|
44 |
+
|
45 |
+
default:
|
46 |
+
$mVal = parent::__get( $sProperty );
|
47 |
+
}
|
48 |
+
return $mVal;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param string $sProperty
|
53 |
+
* @param mixed $mValue
|
54 |
+
* @return $this
|
55 |
+
*/
|
56 |
+
public function __set( $sProperty, $mValue ) {
|
57 |
+
|
58 |
+
switch ( $sProperty ) {
|
59 |
+
|
60 |
+
case 'ip':
|
61 |
+
$mValue = inet_pton( $mValue );
|
62 |
+
break;
|
63 |
+
|
64 |
+
default:
|
65 |
+
break;
|
66 |
+
}
|
67 |
+
|
68 |
+
return parent::__set( $sProperty, $mValue );
|
69 |
+
}
|
70 |
+
}
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Base;
|
6 |
+
|
7 |
+
class Handler extends Base\Handler {
|
8 |
+
}
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Base;
|
6 |
+
|
7 |
+
class Insert extends Base\Insert {
|
8 |
+
}
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Base;
|
6 |
+
|
7 |
+
class Select extends Base\Select {
|
8 |
+
|
9 |
+
use BaseGeoIp;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $sIp
|
13 |
+
* @return EntryVO
|
14 |
+
*/
|
15 |
+
public function byIp( $sIp ) {
|
16 |
+
return $this->filterByIp( inet_pton( $sIp ) )
|
17 |
+
->setResultsAsVo( true )
|
18 |
+
->first();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string[]
|
23 |
+
*/
|
24 |
+
public function getDistinctIps() {
|
25 |
+
$aIps = array_filter( array_map(
|
26 |
+
function ( $sIp ) {
|
27 |
+
return inet_ntop( $sIp );
|
28 |
+
},
|
29 |
+
$this->getDistinctForColumn( 'ip' )
|
30 |
+
) );
|
31 |
+
asort( $aIps );
|
32 |
+
return $aIps;
|
33 |
+
}
|
34 |
+
}
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\GeoIp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases;
|
6 |
+
use FernleafSystems\Wordpress\Services\Services;
|
7 |
+
|
8 |
+
class Lookup {
|
9 |
+
|
10 |
+
const URL_REDIRECTLI = 'https://api.redirect.li/v1/ip/';
|
11 |
+
use Databases\Base\HandlerConsumer;
|
12 |
+
|
13 |
+
private $aIps = [];
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @param string $sIp
|
17 |
+
* @return Databases\GeoIp\EntryVO|null
|
18 |
+
*/
|
19 |
+
public function lookupIp( $sIp ) {
|
20 |
+
// Small optimization so we don't SQL it every time.
|
21 |
+
if ( isset( $this->aIps[ $sIp ] ) ) {
|
22 |
+
return $this->aIps[ $sIp ];
|
23 |
+
}
|
24 |
+
|
25 |
+
/** @var Databases\GeoIp\Handler $oDbH */
|
26 |
+
$oDbH = $this->getDbHandler();
|
27 |
+
/** @var Databases\GeoIp\Select $oSel */
|
28 |
+
$oSel = $oDbH->getQuerySelector();
|
29 |
+
$oIp = $oSel->byIp( $sIp );
|
30 |
+
|
31 |
+
/**
|
32 |
+
* We look up the IP and if the request fails, we store it anyway so that we don't repeatedly
|
33 |
+
* bombard the API. The address will eventually be expired over time and lookup will process
|
34 |
+
* again at a later date, as required
|
35 |
+
*/
|
36 |
+
if ( empty( $oIp ) ) {
|
37 |
+
$oIp = new Databases\GeoIp\EntryVO();
|
38 |
+
$oIp->ip = $sIp;
|
39 |
+
$oIp->meta = $this->redirectliIpLookup( $sIp );
|
40 |
+
/** @var Databases\GeoIp\Insert $oIsrt */
|
41 |
+
$oDbH->getQueryInserter()->insert( $oIp );
|
42 |
+
}
|
43 |
+
|
44 |
+
$this->aIps[ $sIp ] = $oIp;
|
45 |
+
return $oIp;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param string $sIp
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
private function redirectliIpLookup( $sIp ) {
|
53 |
+
$oHttp = Services::HttpRequest();
|
54 |
+
$aIpData = @json_decode( $oHttp->getContent( self::URL_REDIRECTLI.$sIp ), true );
|
55 |
+
if ( empty( $aIpData ) || !is_array( $aIpData ) ) {
|
56 |
+
$aIpData = [];
|
57 |
+
}
|
58 |
+
|
59 |
+
return array_intersect_key(
|
60 |
+
$aIpData,
|
61 |
+
[
|
62 |
+
'countryCode' => '',
|
63 |
+
'countryName' => '',
|
64 |
+
'timeZone' => '',
|
65 |
+
'latitude' => '',
|
66 |
+
'longitude' => '',
|
67 |
+
]
|
68 |
+
);
|
69 |
+
}
|
70 |
+
}
|
@@ -2,12 +2,12 @@
|
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\UserManagement\Suspend;
|
4 |
|
5 |
-
use FernleafSystems\Wordpress\Plugin\Shield\Modules\
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Users\ShieldUserMeta;
|
7 |
|
8 |
abstract class Base {
|
9 |
|
10 |
-
use
|
11 |
const HOOK_PRIORITY = 1000; // so only authenticated user is notified of account state.
|
12 |
|
13 |
public function run() {
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\UserManagement\Suspend;
|
4 |
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Users\ShieldUserMeta;
|
7 |
|
8 |
abstract class Base {
|
9 |
|
10 |
+
use ModConsumer;
|
11 |
const HOOK_PRIORITY = 1000; // so only authenticated user is notified of account state.
|
12 |
|
13 |
public function run() {
|
@@ -7,21 +7,21 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
7 |
|
8 |
class Idle extends Base {
|
9 |
|
10 |
-
/**
|
11 |
-
* @var int
|
12 |
-
*/
|
13 |
-
private $nVerifiedExpired;
|
14 |
-
|
15 |
/**
|
16 |
* @param \WP_User $oUser
|
17 |
* @param ShieldUserMeta $oMeta
|
18 |
* @return \WP_Error|\WP_User
|
19 |
*/
|
20 |
protected function processUser( $oUser, $oMeta ) {
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
$oUser = new \WP_Error(
|
23 |
$this->getCon()->prefix( 'pass-expired' ),
|
24 |
-
'Sorry, this account is suspended due to in-activity. Please reset your password to
|
25 |
);
|
26 |
}
|
27 |
return $oUser;
|
@@ -32,22 +32,8 @@ class Idle extends Base {
|
|
32 |
* @return bool
|
33 |
*/
|
34 |
protected function isLastVerifiedAtExpired( $oMeta ) {
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @return int
|
40 |
-
*/
|
41 |
-
public function getVerifiedExpires() {
|
42 |
-
return (int)$this->nVerifiedExpired;
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @param int $nVerifiedExpired
|
47 |
-
* @return $this
|
48 |
-
*/
|
49 |
-
public function setVerifiedExpires( $nVerifiedExpired ) {
|
50 |
-
$this->nVerifiedExpired = $nVerifiedExpired;
|
51 |
-
return $this;
|
52 |
}
|
53 |
}
|
7 |
|
8 |
class Idle extends Base {
|
9 |
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* @param \WP_User $oUser
|
12 |
* @param ShieldUserMeta $oMeta
|
13 |
* @return \WP_Error|\WP_User
|
14 |
*/
|
15 |
protected function processUser( $oUser, $oMeta ) {
|
16 |
+
/** @var \ICWP_WPSF_FeatureHandler_UserManagement $oMod */
|
17 |
+
$oMod = $this->getMod();
|
18 |
+
|
19 |
+
$aRoles = array_intersect( $oMod->getSuspendAutoIdleUserRoles(), array_map( 'strtolower', $oUser->roles ) );
|
20 |
+
|
21 |
+
if ( count( $aRoles ) > 0 && $this->isLastVerifiedAtExpired( $oMeta ) ) {
|
22 |
$oUser = new \WP_Error(
|
23 |
$this->getCon()->prefix( 'pass-expired' ),
|
24 |
+
'Sorry, this account is suspended due to in-activity. Please reset your password to regain access to your account.'
|
25 |
);
|
26 |
}
|
27 |
return $oUser;
|
32 |
* @return bool
|
33 |
*/
|
34 |
protected function isLastVerifiedAtExpired( $oMeta ) {
|
35 |
+
/** @var \ICWP_WPSF_FeatureHandler_UserManagement $oMod */
|
36 |
+
$oMod = $this->getMod();
|
37 |
+
return ( Services::Request()->ts() - $oMeta->getLastVerifiedAt() > $oMod->getSuspendAutoIdleTime() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
}
|
@@ -36,11 +36,12 @@ class PasswordExpiry extends Base {
|
|
36 |
* @return bool
|
37 |
*/
|
38 |
private function isPassExpired( $oMeta ) {
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
}
|
43 |
-
return ( Services::Request()->ts() - $oMeta->pass_started_at > $
|
44 |
}
|
45 |
|
46 |
/**
|
36 |
* @return bool
|
37 |
*/
|
38 |
private function isPassExpired( $oMeta ) {
|
39 |
+
/** @var \ICWP_WPSF_FeatureHandler_UserManagement $oMod */
|
40 |
+
$oMod = $this->getMod();
|
41 |
+
if ( empty( $oMeta->pass_started_at ) ) {
|
42 |
+
$oMeta->pass_started_at = $oMeta->first_seen_at;
|
43 |
}
|
44 |
+
return ( Services::Request()->ts() - $oMeta->pass_started_at > $oMod->getPassExpireTimeout() );
|
45 |
}
|
46 |
|
47 |
/**
|
@@ -17,7 +17,7 @@ class Suspended extends Base {
|
|
17 |
if ( $oMeta->hard_suspended_at > 0 ) {
|
18 |
$oUser = new \WP_Error(
|
19 |
$this->getCon()->prefix( 'hard-suspended' ),
|
20 |
-
'Sorry, this account is suspended. Please contact your website administrator
|
21 |
);
|
22 |
}
|
23 |
return $oUser;
|
17 |
if ( $oMeta->hard_suspended_at > 0 ) {
|
18 |
$oUser = new \WP_Error(
|
19 |
$this->getCon()->prefix( 'hard-suspended' ),
|
20 |
+
'Sorry, this account is suspended. Please contact your website administrator.'
|
21 |
);
|
22 |
}
|
23 |
return $oUser;
|
@@ -3,12 +3,13 @@
|
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Helpers;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
|
|
6 |
|
7 |
/**
|
8 |
* Class WpCoreFileDownload
|
9 |
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Helpers
|
10 |
*/
|
11 |
-
class
|
12 |
|
13 |
const URL_WP_CORE = 'https://core.svn.wordpress.org';
|
14 |
const URL_WP_CORE_IL8N = 'https://i18n.svn.wordpress.org';
|
@@ -20,18 +21,43 @@ class WpCoreFileDownload {
|
|
20 |
*/
|
21 |
protected $sVersion;
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
* @param string $sPath
|
25 |
* @param bool $bUseLocale
|
26 |
* @return string - path to downloaded file
|
|
|
27 |
*/
|
28 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
29 |
$sLocale = Services::WpGeneral()->getLocaleForChecksums();
|
30 |
$bUseInternational = $bUseLocale && ( $sLocale != 'en_US' );
|
31 |
|
32 |
$sTmpFile = download_url( $this->getFileUrl( $sPath, $bUseLocale ) );
|
33 |
if ( $bUseInternational && empty( $sTmpFile ) ) {
|
34 |
-
$sTmpFile = $this->
|
35 |
} // try international retrieval and if it fails, we resort to en_US.
|
36 |
|
37 |
return ( !is_wp_error( $sTmpFile ) && Services::WpFs()->exists( $sTmpFile ) ) ? $sTmpFile : null;
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Helpers;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
+
use FernleafSystems\Wordpress\Services\Utilities\WpOrg;
|
7 |
|
8 |
/**
|
9 |
* Class WpCoreFileDownload
|
10 |
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Helpers
|
11 |
*/
|
12 |
+
class WpCoreFile {
|
13 |
|
14 |
const URL_WP_CORE = 'https://core.svn.wordpress.org';
|
15 |
const URL_WP_CORE_IL8N = 'https://i18n.svn.wordpress.org';
|
21 |
*/
|
22 |
protected $sVersion;
|
23 |
|
24 |
+
/**
|
25 |
+
* @param string $sPath
|
26 |
+
* @return bool
|
27 |
+
* @throws \InvalidArgumentException
|
28 |
+
*/
|
29 |
+
public function replace( $sPath ) {
|
30 |
+
$bSuccess = false;
|
31 |
+
$oWp = Services::WpGeneral();
|
32 |
+
if ( Services::CoreFileHashes()->isCoreFile( $sPath ) ) {
|
33 |
+
$oFiles = $oWp->isClassicPress() ? new WpOrg\Cp\Files() : new WpOrg\Wp\Files();
|
34 |
+
try {
|
35 |
+
$oFiles->replaceFileFromVcs( $sPath );
|
36 |
+
}
|
37 |
+
catch ( \InvalidArgumentException $oE ) {
|
38 |
+
}
|
39 |
+
}
|
40 |
+
return $bSuccess;
|
41 |
+
}
|
42 |
+
|
43 |
/**
|
44 |
* @param string $sPath
|
45 |
* @param bool $bUseLocale
|
46 |
* @return string - path to downloaded file
|
47 |
+
* @throws \InvalidArgumentException
|
48 |
*/
|
49 |
+
public function download( $sPath, $bUseLocale = true ) {
|
50 |
+
$oHashes = Services::CoreFileHashes();
|
51 |
+
if ( !$oHashes->isCoreFile( $sPath ) ) {
|
52 |
+
throw new \InvalidArgumentException( sprintf( 'Core file "%s" is not an official WordPress core file.', $sPath ) );
|
53 |
+
}
|
54 |
+
|
55 |
$sLocale = Services::WpGeneral()->getLocaleForChecksums();
|
56 |
$bUseInternational = $bUseLocale && ( $sLocale != 'en_US' );
|
57 |
|
58 |
$sTmpFile = download_url( $this->getFileUrl( $sPath, $bUseLocale ) );
|
59 |
if ( $bUseInternational && empty( $sTmpFile ) ) {
|
60 |
+
$sTmpFile = $this->download( $sPath, false );
|
61 |
} // try international retrieval and if it fails, we resort to en_US.
|
62 |
|
63 |
return ( !is_wp_error( $sTmpFile ) && Services::WpFs()->exists( $sTmpFile ) ) ? $sTmpFile : null;
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Scanner\EntryVO;
|
6 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class ConvertResultsToVos
|
10 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
11 |
+
*/
|
12 |
+
class ConvertResultsToVos extends Scans\Base\BaseConvertResultsToVos {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param ResultItem $oIt
|
16 |
+
* @return EntryVO
|
17 |
+
*/
|
18 |
+
public function convertItem( $oIt ) {
|
19 |
+
$oVo = parent::convertItem( $oIt );
|
20 |
+
$oVo->scan = $oIt::SCAN_RESULT_TYPE;
|
21 |
+
return $oVo;
|
22 |
+
}
|
23 |
+
}
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\Scanner\EntryVO;
|
6 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class ConvertVosToResults
|
10 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
11 |
+
*/
|
12 |
+
class ConvertVosToResults extends Scans\Base\BaseConvertVosToResults {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param EntryVO[] $oVos
|
16 |
+
* @return ResultsSet
|
17 |
+
*/
|
18 |
+
public function convert( $oVos ) {
|
19 |
+
$oRes = new ResultsSet();
|
20 |
+
foreach ( $oVos as $oVo ) {
|
21 |
+
$oRes->addItem( $this->convertItem( $oVo ) );
|
22 |
+
}
|
23 |
+
return $oRes;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param EntryVO $oVo
|
28 |
+
* @return ResultItem
|
29 |
+
*/
|
30 |
+
public function convertItem( $oVo ) {
|
31 |
+
return ( new ResultItem() )->applyFromArray( $oVo->meta );
|
32 |
+
}
|
33 |
+
}
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans;
|
6 |
+
use FernleafSystems\Wordpress\Services;
|
7 |
+
use FernleafSystems\Wordpress\Services\Utilities\WpOrg;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Repair
|
11 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
12 |
+
*/
|
13 |
+
class Repair extends Scans\Base\BaseRepair {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @param ResultItem $oItem
|
17 |
+
* @return bool
|
18 |
+
*/
|
19 |
+
public function repairItem( $oItem ) {
|
20 |
+
$bSuccess = false;
|
21 |
+
|
22 |
+
if ( Services\Services::CoreFileHashes()->isCoreFile( $oItem->path_fragment ) ) {
|
23 |
+
$oFiles = Services\Services::WpGeneral()->isClassicPress() ? new WpOrg\Cp\Files() : new WpOrg\Wp\Files();
|
24 |
+
try {
|
25 |
+
$oFiles->replaceFileFromVcs( $oItem->path_fragment );
|
26 |
+
}
|
27 |
+
catch ( \InvalidArgumentException $oE ) {
|
28 |
+
}
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
$oFiles = new WpOrg\Plugin\Files();
|
32 |
+
try {
|
33 |
+
$oPlugin = $oFiles->findPluginFromFile( $oItem->path_fragment );
|
34 |
+
if ( $oPlugin instanceof Services\Core\VOs\WpPluginVo ) {
|
35 |
+
if ( $oFiles->isValidFileFromPlugin( $oItem->path_fragment ) ) {
|
36 |
+
$bSuccess = $oFiles->replaceFileFromVcs( $oItem->path_fragment );
|
37 |
+
}
|
38 |
+
else {
|
39 |
+
$bSuccess = Services\Services::WpFs()->deleteFile( $oItem->path_full );
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
catch ( \InvalidArgumentException $oE ) {
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $bSuccess;
|
48 |
+
}
|
49 |
+
}
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans\Base;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class ResultItem
|
9 |
+
* @property string path_full
|
10 |
+
* @property string path_fragment - relative to ABSPATH
|
11 |
+
* @property bool is_mal
|
12 |
+
* @property string mal_sig
|
13 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
14 |
+
*/
|
15 |
+
class ResultItem extends Base\BaseResultItem {
|
16 |
+
|
17 |
+
const SCAN_RESULT_TYPE = 'mal';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function generateHash() {
|
23 |
+
return md5( $this->path_full );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return bool
|
28 |
+
*/
|
29 |
+
public function isReady() {
|
30 |
+
return !empty( $this->path_full ) && !empty( $this->md5_file_wp ) && !empty( $this->path_fragment );
|
31 |
+
}
|
32 |
+
}
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans\Base;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class ResultsSet
|
9 |
+
* @property ResultItem[] $aItems
|
10 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
11 |
+
*/
|
12 |
+
class ResultsSet extends Base\BaseResultsSet {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param ResultItem[] $aItems
|
16 |
+
* @return string[]
|
17 |
+
*/
|
18 |
+
public function filterItemsForPaths( $aItems ) {
|
19 |
+
return array_map(
|
20 |
+
function ( $oItem ) {
|
21 |
+
/** @var ResultItem $oItem */
|
22 |
+
return $oItem->path_fragment;
|
23 |
+
},
|
24 |
+
$aItems
|
25 |
+
);
|
26 |
+
}
|
27 |
+
}
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Scans\Helpers;
|
6 |
+
use FernleafSystems\Wordpress\Services\Services;
|
7 |
+
use FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugins;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Scanner
|
11 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Scans\Mal
|
12 |
+
*/
|
13 |
+
class Scanner {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string[]
|
17 |
+
*/
|
18 |
+
private $aMalSigs;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return ResultsSet
|
22 |
+
*/
|
23 |
+
public function run() {
|
24 |
+
$oFs = Services::WpFs();
|
25 |
+
$oResultSet = new ResultsSet();
|
26 |
+
|
27 |
+
try {
|
28 |
+
/**
|
29 |
+
* The filter handles the bulk of the file inclusions and exclusions
|
30 |
+
* We can set the types (extensions) of the files to include
|
31 |
+
* useful for the upload directory where we're only interested in JS and PHP
|
32 |
+
* The filter will also be responsible (in this case) for filtering out
|
33 |
+
* WP Core files from the collection of files to be assessed
|
34 |
+
*/
|
35 |
+
$oDirIt = Helpers\StandardDirectoryIterator::create( ABSPATH, 0, [ 'php', 'php5', 'js' ], false );
|
36 |
+
|
37 |
+
$aSigs = $this->getMalSigs();
|
38 |
+
foreach ( $oDirIt as $oFsItem ) {
|
39 |
+
/** @var \SplFileInfo $oFsItem */
|
40 |
+
$sFullPath = wp_normalize_path( $oFsItem->getPathname() );
|
41 |
+
|
42 |
+
$sContent = $oFs->getFileContent( $sFullPath );
|
43 |
+
if ( !empty( $sContent ) ) {
|
44 |
+
foreach ( $aSigs as $sSig ) {
|
45 |
+
if ( strpos( $sContent, $sSig ) !== false ) {
|
46 |
+
|
47 |
+
if ( $this->canExcludeFile( $sFullPath ) ) {
|
48 |
+
continue;
|
49 |
+
}
|
50 |
+
|
51 |
+
$oResultItem = new ResultItem();
|
52 |
+
$oResultItem->path_full = wp_normalize_path( $sFullPath );
|
53 |
+
$oResultItem->path_fragment = str_replace( wp_normalize_path( ABSPATH ), '', $oResultItem->path_full );
|
54 |
+
$oResultItem->is_mal = true;
|
55 |
+
$oResultItem->mal_sig = base64_encode( $sSig );
|
56 |
+
$oResultSet->addItem( $oResultItem );
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
catch ( \Exception $oE ) {
|
64 |
+
error_log(
|
65 |
+
sprintf( 'Shield file scanner attempted to read directory but there was error: "%s".', $oE->getMessage() )
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $oResultSet;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param string $sFullPath - normalized
|
74 |
+
* @return bool
|
75 |
+
*/
|
76 |
+
private function canExcludeFile( $sFullPath ) {
|
77 |
+
return $this->isValidCoreFile( $sFullPath ) || $this->isValidPluginFile( $sFullPath );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @param string $sFullPath - normalized
|
82 |
+
* @return bool
|
83 |
+
*/
|
84 |
+
private function isValidPluginFile( $sFullPath ) {
|
85 |
+
$bCanExclude = false;
|
86 |
+
|
87 |
+
$sPluginsDir = wp_normalize_path( WP_PLUGIN_DIR );
|
88 |
+
$oWpPlugins = Services::WpPlugins();
|
89 |
+
$oWpFs = Services::WpFs();
|
90 |
+
|
91 |
+
if ( strpos( $sFullPath, $sPluginsDir ) === 0 ) {
|
92 |
+
|
93 |
+
$sFragment = ltrim( str_replace( $sPluginsDir, '', $sFullPath ), '/' );
|
94 |
+
$aParts = explode( '/', $sFragment );
|
95 |
+
$sDir = array_shift( $aParts );
|
96 |
+
$sRemainder = implode( '/', $aParts );
|
97 |
+
|
98 |
+
foreach ( $oWpPlugins->getInstalledPluginFiles() as $sPluginFile ) {
|
99 |
+
if ( $sDir == dirname( $sPluginFile ) ) {
|
100 |
+
$oThePlugin = $oWpPlugins->getPluginAsVo( $sPluginFile );
|
101 |
+
try {
|
102 |
+
$sTmpFile = ( new Plugins() )
|
103 |
+
->setWorkingSlug( $oThePlugin->slug )
|
104 |
+
->fileFromVersion( $oThePlugin->Version, $sRemainder );
|
105 |
+
if ( $oWpFs->exists( $sTmpFile ) && md5_file( $sTmpFile ) === md5_file( $sFullPath ) ) {
|
106 |
+
$bCanExclude = true;
|
107 |
+
}
|
108 |
+
$oWpFs->deleteFile( $sTmpFile );
|
109 |
+
}
|
110 |
+
catch ( \Exception $oE ) {
|
111 |
+
}
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return $bCanExclude;
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @param string $sFullPath
|
122 |
+
* @return bool
|
123 |
+
*/
|
124 |
+
private function isValidCoreFile( $sFullPath ) {
|
125 |
+
$oCoreHashes = Services::CoreFileHashes();
|
126 |
+
$sCoreHash = $oCoreHashes->getFileHash( $sFullPath );
|
127 |
+
return ( !empty( $sCoreHash ) && $sCoreHash === md5_file( $sFullPath ) );
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @return string[]
|
132 |
+
*/
|
133 |
+
public function getMalSigs() {
|
134 |
+
return $this->aMalSigs;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @param string[] $sFilePathMalSigs
|
139 |
+
* @return $this
|
140 |
+
*/
|
141 |
+
public function setMalSigs( $sFilePathMalSigs ) {
|
142 |
+
$this->aMalSigs = $sFilePathMalSigs;
|
143 |
+
return $this;
|
144 |
+
}
|
145 |
+
}
|
@@ -3,7 +3,6 @@
|
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Wcf;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Scans;
|
6 |
-
use FernleafSystems\Wordpress\Services\Services;
|
7 |
|
8 |
/**
|
9 |
* Class Repair
|
@@ -14,27 +13,10 @@ class Repair extends Scans\Base\BaseRepair {
|
|
14 |
/**
|
15 |
* @param ResultItem $oItem
|
16 |
* @return bool
|
17 |
-
* @throws \
|
18 |
*/
|
19 |
public function repairItem( $oItem ) {
|
20 |
-
$bSuccess = false;
|
21 |
-
|
22 |
$sPath = trim( wp_normalize_path( $oItem->path_fragment ), '/' );
|
23 |
-
|
24 |
-
if ( !$oHashes->isCoreFile( $sPath ) ) {
|
25 |
-
throw new \Exception( sprintf( 'Core file "%s" is not an official WordPress core file.', $sPath ) );
|
26 |
-
}
|
27 |
-
|
28 |
-
$sFullPath = $oHashes->getAbsolutePathFromFragment( $sPath );
|
29 |
-
$sFile = ( new Scans\Helpers\WpCoreFileDownload() )->run( $sPath, true );
|
30 |
-
if ( !empty( $sFile ) ) {
|
31 |
-
$oFs = Services::WpFs();
|
32 |
-
$oFs->mkdir( dirname( $sFullPath ) );
|
33 |
-
clearstatcache();
|
34 |
-
$bSuccess = $oFs->move( $sFile, $sFullPath )
|
35 |
-
&& ( $oHashes->getFileHash( $sPath ) === md5_file( $sFullPath ) );
|
36 |
-
}
|
37 |
-
|
38 |
-
return $bSuccess;
|
39 |
}
|
40 |
}
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Scans\Wcf;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Scans;
|
|
|
6 |
|
7 |
/**
|
8 |
* Class Repair
|
13 |
/**
|
14 |
* @param ResultItem $oItem
|
15 |
* @return bool
|
16 |
+
* @throws \InvalidArgumentException
|
17 |
*/
|
18 |
public function repairItem( $oItem ) {
|
|
|
|
|
19 |
$sPath = trim( wp_normalize_path( $oItem->path_fragment ), '/' );
|
20 |
+
return ( new Scans\Helpers\WpCoreFile() )->replace( $sPath );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
}
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Tables\Build;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield;
|
6 |
+
use FernleafSystems\Wordpress\Services\Services;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class ScanMal
|
10 |
+
* @package FernleafSystems\Wordpress\Plugin\Shield\Tables\Build
|
11 |
+
*/
|
12 |
+
class ScanMal extends ScanBase {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return array[]
|
16 |
+
*/
|
17 |
+
protected function getEntriesFormatted() {
|
18 |
+
$aEntries = [];
|
19 |
+
|
20 |
+
/** @var \ICWP_WPSF_FeatureHandler_HackProtect $oMod */
|
21 |
+
$oMod = $this->getMod();
|
22 |
+
|
23 |
+
$nTs = Services::Request()->ts();
|
24 |
+
foreach ( $this->getEntriesRaw() as $nKey => $oEntry ) {
|
25 |
+
/** @var Shield\Databases\Scanner\EntryVO $oEntry */
|
26 |
+
$oIt = ( new Shield\Scans\Ufc\ConvertVosToResults() )->convertItem( $oEntry );
|
27 |
+
$aE = $oEntry->getRawDataAsArray();
|
28 |
+
$aE[ 'path' ] = $oIt->path_fragment;
|
29 |
+
$aE[ 'status' ] = 'Unrecognised File';
|
30 |
+
$aE[ 'ignored' ] = ( $oEntry->ignored_at > 0 && $nTs > $oEntry->ignored_at ) ? 'Yes' : 'No';
|
31 |
+
$aE[ 'created_at' ] = $this->formatTimestampField( $oEntry->created_at );
|
32 |
+
$aE[ 'href_download' ] = $oMod->createFileDownloadLink( $oEntry );
|
33 |
+
$aEntries[ $nKey ] = $aE;
|
34 |
+
}
|
35 |
+
|
36 |
+
return $aEntries;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return Shield\Tables\Render\ScanUfc
|
41 |
+
*/
|
42 |
+
protected function getTableRenderer() {
|
43 |
+
return new Shield\Tables\Render\ScanUfc();
|
44 |
+
}
|
45 |
+
}
|
@@ -3,6 +3,7 @@
|
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Tables\Build;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Databases;
|
|
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Tables;
|
7 |
use FernleafSystems\Wordpress\Services\Services;
|
8 |
|
@@ -12,11 +13,6 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
12 |
*/
|
13 |
class Traffic extends BaseBuild {
|
14 |
|
15 |
-
/**
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
private $sGeoIpDbSource;
|
19 |
-
|
20 |
/**
|
21 |
* Override this to apply table-specific query filters.
|
22 |
* @return $this
|
@@ -61,7 +57,7 @@ class Traffic extends BaseBuild {
|
|
61 |
* @return array
|
62 |
*/
|
63 |
protected function getCustomParams() {
|
64 |
-
return
|
65 |
'fIp' => '',
|
66 |
'fUsername' => '',
|
67 |
'fLoggedIn' => -1,
|
@@ -69,7 +65,7 @@ class Traffic extends BaseBuild {
|
|
69 |
'fTransgression' => -1,
|
70 |
'fResponse' => '',
|
71 |
'fExludeYou' => '',
|
72 |
-
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -78,10 +74,13 @@ class Traffic extends BaseBuild {
|
|
78 |
protected function getEntriesFormatted() {
|
79 |
$aEntries = [];
|
80 |
|
|
|
|
|
|
|
81 |
$oWpUsers = Services::WpUsers();
|
82 |
-
$
|
83 |
-
$
|
84 |
-
$sYou = $
|
85 |
|
86 |
$aUsers = [ 0 => _wpsf__( 'No' ) ];
|
87 |
foreach ( $this->getEntriesRaw() as $nKey => $oEntry ) {
|
@@ -122,33 +121,33 @@ class Traffic extends BaseBuild {
|
|
122 |
}
|
123 |
}
|
124 |
|
125 |
-
$
|
126 |
-
|
|
|
127 |
$sCountry = _wpsf__( 'Unknown' );
|
128 |
}
|
129 |
else {
|
130 |
-
$sCountryIso = $oGeo->countryIso( $sIp );
|
131 |
$sFlag = sprintf( 'https://www.countryflags.io/%s/flat/16.png', strtolower( $sCountryIso ) );
|
132 |
-
$sCountry = sprintf( '<img class="icon-flag" src="%s" alt="%s"/> %s', $sFlag, $sCountryIso, $
|
133 |
}
|
134 |
|
135 |
$sIpLink = sprintf( '<a href="%s" target="_blank" title="IP Whois">%s</a>%s',
|
136 |
-
$
|
137 |
$aEntry[ 'is_you' ] ? ' <span style="font-size: smaller;">('._wpsf__( 'You' ).')</span>' : ''
|
138 |
);
|
139 |
|
140 |
-
$aDetails =
|
141 |
sprintf( '%s: %s', _wpsf__( 'IP' ), $sIpLink ),
|
142 |
sprintf( '%s: %s', _wpsf__( 'Logged-In' ), $aUsers[ $oEntry->uid ] ),
|
143 |
sprintf( '%s: %s', _wpsf__( 'Location' ), $sCountry ),
|
144 |
esc_html( esc_js( sprintf( '%s - %s', _wpsf__( 'User Agent' ), $oEntry->ua ) ) )
|
145 |
-
|
146 |
$aEntry[ 'visitor' ] = '<div>'.implode( '</div><div>', $aDetails ).'</div>';
|
147 |
|
148 |
-
$aInfo =
|
149 |
sprintf( '%s: %s', _wpsf__( 'Response' ), $aEntry[ 'code' ] ),
|
150 |
sprintf( '%s: %s', _wpsf__( 'Transgression' ), $aEntry[ 'trans' ] ),
|
151 |
-
|
152 |
$aEntry[ 'request_info' ] = '<div>'.implode( '</div><div>', $aInfo ).'</div>';
|
153 |
$aEntries[ $nKey ] = $aEntry;
|
154 |
}
|
@@ -161,20 +160,4 @@ class Traffic extends BaseBuild {
|
|
161 |
protected function getTableRenderer() {
|
162 |
return new Tables\Render\Traffic();
|
163 |
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* @return string
|
167 |
-
*/
|
168 |
-
public function getGeoIpDbSource() {
|
169 |
-
return $this->sGeoIpDbSource;
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* @param string $sGeoIpDbSource
|
174 |
-
* @return $this
|
175 |
-
*/
|
176 |
-
public function setGeoIpDbSource( $sGeoIpDbSource ) {
|
177 |
-
$this->sGeoIpDbSource = $sGeoIpDbSource;
|
178 |
-
return $this;
|
179 |
-
}
|
180 |
}
|
3 |
namespace FernleafSystems\Wordpress\Plugin\Shield\Tables\Build;
|
4 |
|
5 |
use FernleafSystems\Wordpress\Plugin\Shield\Databases;
|
6 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Modules\GeoIp\Lookup;
|
7 |
use FernleafSystems\Wordpress\Plugin\Shield\Tables;
|
8 |
use FernleafSystems\Wordpress\Services\Services;
|
9 |
|
13 |
*/
|
14 |
class Traffic extends BaseBuild {
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* Override this to apply table-specific query filters.
|
18 |
* @return $this
|
57 |
* @return array
|
58 |
*/
|
59 |
protected function getCustomParams() {
|
60 |
+
return [
|
61 |
'fIp' => '',
|
62 |
'fUsername' => '',
|
63 |
'fLoggedIn' => -1,
|
65 |
'fTransgression' => -1,
|
66 |
'fResponse' => '',
|
67 |
'fExludeYou' => '',
|
68 |
+
];
|
69 |
}
|
70 |
|
71 |
/**
|
74 |
protected function getEntriesFormatted() {
|
75 |
$aEntries = [];
|
76 |
|
77 |
+
/** @var \ICWP_WPSF_Processor_Plugin $oPluginPro */
|
78 |
+
$oPluginPro = $this->getCon()->getModule( 'plugin' )->getProcessor();
|
79 |
+
|
80 |
$oWpUsers = Services::WpUsers();
|
81 |
+
$oGeoIpLookup = ( new Lookup() )->setDbHandler( $oPluginPro->getSubProGeoip()->getDbHandler() );
|
82 |
+
$oIpSrv = Services::IP();
|
83 |
+
$sYou = $oIpSrv->getRequestIp();
|
84 |
|
85 |
$aUsers = [ 0 => _wpsf__( 'No' ) ];
|
86 |
foreach ( $this->getEntriesRaw() as $nKey => $oEntry ) {
|
121 |
}
|
122 |
}
|
123 |
|
124 |
+
$oGeoIp = $oGeoIpLookup->lookupIp( $sIp );
|
125 |
+
$sCountryIso = $oGeoIp->getCountryCode();
|
126 |
+
if ( empty( $sCountryIso ) ) {
|
127 |
$sCountry = _wpsf__( 'Unknown' );
|
128 |
}
|
129 |
else {
|
|
|
130 |
$sFlag = sprintf( 'https://www.countryflags.io/%s/flat/16.png', strtolower( $sCountryIso ) );
|
131 |
+
$sCountry = sprintf( '<img class="icon-flag" src="%s" alt="%s"/> %s', $sFlag, $sCountryIso, $oGeoIp->getCountryName() );
|
132 |
}
|
133 |
|
134 |
$sIpLink = sprintf( '<a href="%s" target="_blank" title="IP Whois">%s</a>%s',
|
135 |
+
$oIpSrv->getIpWhoisLookup( $sIp ), $sIp,
|
136 |
$aEntry[ 'is_you' ] ? ' <span style="font-size: smaller;">('._wpsf__( 'You' ).')</span>' : ''
|
137 |
);
|
138 |
|
139 |
+
$aDetails = [
|
140 |
sprintf( '%s: %s', _wpsf__( 'IP' ), $sIpLink ),
|
141 |
sprintf( '%s: %s', _wpsf__( 'Logged-In' ), $aUsers[ $oEntry->uid ] ),
|
142 |
sprintf( '%s: %s', _wpsf__( 'Location' ), $sCountry ),
|
143 |
esc_html( esc_js( sprintf( '%s - %s', _wpsf__( 'User Agent' ), $oEntry->ua ) ) )
|
144 |
+
];
|
145 |
$aEntry[ 'visitor' ] = '<div>'.implode( '</div><div>', $aDetails ).'</div>';
|
146 |
|
147 |
+
$aInfo = [
|
148 |
sprintf( '%s: %s', _wpsf__( 'Response' ), $aEntry[ 'code' ] ),
|
149 |
sprintf( '%s: %s', _wpsf__( 'Transgression' ), $aEntry[ 'trans' ] ),
|
150 |
+
];
|
151 |
$aEntry[ 'request_info' ] = '<div>'.implode( '</div><div>', $aInfo ).'</div>';
|
152 |
$aEntries[ $nKey ] = $aEntry;
|
153 |
}
|
160 |
protected function getTableRenderer() {
|
161 |
return new Tables\Render\Traffic();
|
162 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
@@ -15,6 +15,8 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
15 |
* @property bool $ga_validated
|
16 |
* @property array $hash_loginmfa
|
17 |
* @property string $pass_hash
|
|
|
|
|
18 |
* @property int $pass_started_at
|
19 |
* @property int $pass_reset_last_redirect_at
|
20 |
* @property int $pass_check_failed_at
|
@@ -30,11 +32,7 @@ class ShieldUserMeta extends \FernleafSystems\Wordpress\Services\Utilities\Plugi
|
|
30 |
* @return int
|
31 |
*/
|
32 |
public function getLastVerifiedAt() {
|
33 |
-
|
34 |
-
if ( $nLastVerified < 1 ) {
|
35 |
-
$nLastVerified = Services::Request()->ts();
|
36 |
-
}
|
37 |
-
return $nLastVerified;
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -49,4 +47,22 @@ class ShieldUserMeta extends \FernleafSystems\Wordpress\Services\Utilities\Plugi
|
|
49 |
}
|
50 |
return $this;
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
15 |
* @property bool $ga_validated
|
16 |
* @property array $hash_loginmfa
|
17 |
* @property string $pass_hash
|
18 |
+
* @property int $first_seen_at
|
19 |
+
* @property int $last_verified_at
|
20 |
* @property int $pass_started_at
|
21 |
* @property int $pass_reset_last_redirect_at
|
22 |
* @property int $pass_check_failed_at
|
32 |
* @return int
|
33 |
*/
|
34 |
public function getLastVerifiedAt() {
|
35 |
+
return (int)max( [ $this->last_login_at, $this->pass_started_at, $this->first_seen_at ] );
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
47 |
}
|
48 |
return $this;
|
49 |
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return $this
|
53 |
+
*/
|
54 |
+
public function updateFirstSeenAt() {
|
55 |
+
if ( empty( $this->first_seen_at ) ) {
|
56 |
+
$this->first_seen_at = max(
|
57 |
+
0,
|
58 |
+
min( array_filter( [
|
59 |
+
Services::Request()->ts(),
|
60 |
+
(int)$this->pass_started_at,
|
61 |
+
(int)$this->last_login_at,
|
62 |
+
(int)$this->pass_check_failed_at
|
63 |
+
] ) )
|
64 |
+
);
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
}
|
@@ -52,7 +52,6 @@ class VisitorIpDetection {
|
|
52 |
}
|
53 |
array_shift( $aHostIps );
|
54 |
$this->setPotentialHostIps( $aHostIps );
|
55 |
-
|
56 |
} while ( empty( $sIp ) );
|
57 |
|
58 |
return $sIp;
|
@@ -166,7 +165,7 @@ class VisitorIpDetection {
|
|
166 |
* @return string[]
|
167 |
*/
|
168 |
private function getIpSourceOptions() {
|
169 |
-
return
|
170 |
'REMOTE_ADDR',
|
171 |
'HTTP_CF_CONNECTING_IP',
|
172 |
'HTTP_X_FORWARDED_FOR',
|
@@ -177,6 +176,6 @@ class VisitorIpDetection {
|
|
177 |
'HTTP_X_SP_FORWARDED_IP',
|
178 |
'HTTP_FORWARDED',
|
179 |
'HTTP_CLIENT_IP'
|
180 |
-
|
181 |
}
|
182 |
}
|
52 |
}
|
53 |
array_shift( $aHostIps );
|
54 |
$this->setPotentialHostIps( $aHostIps );
|
|
|
55 |
} while ( empty( $sIp ) );
|
56 |
|
57 |
return $sIp;
|
165 |
* @return string[]
|
166 |
*/
|
167 |
private function getIpSourceOptions() {
|
168 |
+
return [
|
169 |
'REMOTE_ADDR',
|
170 |
'HTTP_CF_CONNECTING_IP',
|
171 |
'HTTP_X_FORWARDED_FOR',
|
176 |
'HTTP_X_SP_FORWARDED_IP',
|
177 |
'HTTP_FORWARDED',
|
178 |
'HTTP_CLIENT_IP'
|
179 |
+
];
|
180 |
}
|
181 |
}
|
@@ -76,6 +76,12 @@ return array(
|
|
76 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Handler' => $baseDir . '/src/Databases/Comments/Handler.php',
|
77 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Insert' => $baseDir . '/src/Databases/Comments/Insert.php',
|
78 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Select' => $baseDir . '/src/Databases/Comments/Select.php',
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\CommonFilters' => $baseDir . '/src/Databases/IPs/CommonFilters.php',
|
80 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\Delete' => $baseDir . '/src/Databases/IPs/Delete.php',
|
81 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\EntryVO' => $baseDir . '/src/Databases/IPs/EntryVO.php',
|
@@ -108,6 +114,7 @@ return array(
|
|
108 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Insert' => $baseDir . '/src/Databases/Traffic/Insert.php',
|
109 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Select' => $baseDir . '/src/Databases/Traffic/Select.php',
|
110 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => $baseDir . '/src/License/EddLicenseVO.php',
|
|
|
111 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Base' => $baseDir . '/src/Modules/IPs/BotTrack/Base.php',
|
112 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Track404' => $baseDir . '/src/Modules/IPs/BotTrack/Track404.php',
|
113 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\TrackFakeWebCrawler' => $baseDir . '/src/Modules/IPs/BotTrack/TrackFakeWebCrawler.php',
|
@@ -143,7 +150,13 @@ return array(
|
|
143 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\CopyResultsSets' => $baseDir . '/src/Scans/Helpers/CopyResultsSets.php',
|
144 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\ScannerRecursiveFilterIterator' => $baseDir . '/src/Scans/Helpers/ScannerRecursiveFilterIterator.php',
|
145 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\StandardDirectoryIterator' => $baseDir . '/src/Scans/Helpers/StandardDirectoryIterator.php',
|
146 |
-
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertResultsToVos' => $baseDir . '/src/Scans/Ptg/ConvertResultsToVos.php',
|
148 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertVosToResults' => $baseDir . '/src/Scans/Ptg/ConvertVosToResults.php',
|
149 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\DiffHashes' => $baseDir . '/src/Scans/Ptg/DiffHashes.php',
|
@@ -188,6 +201,7 @@ return array(
|
|
188 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\Ip' => $baseDir . '/src/Tables/Build/Ip.php',
|
189 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanApc' => $baseDir . '/src/Tables/Build/ScanApc.php',
|
190 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanBase' => $baseDir . '/src/Tables/Build/ScanBase.php',
|
|
|
191 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanPtg' => $baseDir . '/src/Tables/Build/ScanPtg.php',
|
192 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanUfc' => $baseDir . '/src/Tables/Build/ScanUfc.php',
|
193 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanWcf' => $baseDir . '/src/Tables/Build/ScanWcf.php',
|
@@ -238,6 +252,7 @@ return array(
|
|
238 |
'FernleafSystems\\Wordpress\\Services\\Core\\VOs\\WpPluginVo' => $vendorDir . '/fernleafsystems/wordpress-services/src/Core/VOs/WpPluginVo.php',
|
239 |
'FernleafSystems\\Wordpress\\Services\\Services' => $vendorDir . '/fernleafsystems/wordpress-services/src/Services.php',
|
240 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ClassicPress\\Checksums' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ClassicPress/Checksums.php',
|
|
|
241 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Data' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Data.php',
|
242 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\DataManipulation' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php',
|
243 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Email' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Email.php',
|
@@ -248,14 +263,31 @@ return array(
|
|
248 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\WriteDataToFileEncrypted' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/WriteDataToFileEncrypted.php',
|
249 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\GeoIp' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/GeoIp.php',
|
250 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpRequest' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/HttpRequest.php',
|
|
|
251 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\IpUtils' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/IpUtils.php',
|
252 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Iterators\\WpUserIterator' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Iterators/WpUserIterator.php',
|
253 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Net\\VisitorIpDetection' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Net/VisitorIpDetection.php',
|
254 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\PluginUserMeta' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/PluginUserMeta.php',
|
255 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
|
256 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
|
|
|
|
|
257 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Core' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Core.php',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugins' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugins.php',
|
|
|
|
|
|
|
|
|
259 |
'GeoIp2\\Database\\Reader' => $vendorDir . '/geoip2/geoip2/src/Database/Reader.php',
|
260 |
'GeoIp2\\Exception\\AddressNotFoundException' => $vendorDir . '/geoip2/geoip2/src/Exception/AddressNotFoundException.php',
|
261 |
'GeoIp2\\Exception\\AuthenticationException' => $vendorDir . '/geoip2/geoip2/src/Exception/AuthenticationException.php',
|
@@ -351,6 +383,7 @@ return array(
|
|
351 |
'ICWP_WPSF_Processor_HackProtect' => $baseDir . '/../processors/hack_protect.php',
|
352 |
'ICWP_WPSF_Processor_HackProtect_Apc' => $baseDir . '/../processors/hackprotect_scan_apc.php',
|
353 |
'ICWP_WPSF_Processor_HackProtect_Integrity' => $baseDir . '/../processors/hackprotect_integrity.php',
|
|
|
354 |
'ICWP_WPSF_Processor_HackProtect_Ptg' => $baseDir . '/../processors/hackprotect_scan_ptg.php',
|
355 |
'ICWP_WPSF_Processor_HackProtect_Realtime' => $baseDir . '/../processors/hackprotect_realtime.php',
|
356 |
'ICWP_WPSF_Processor_HackProtect_ScanAssetsBase' => $baseDir . '/../processors/hackprotect_scan_assets_base.php',
|
@@ -381,6 +414,7 @@ return array(
|
|
381 |
'ICWP_WPSF_Processor_Plugin_BadgeWidget' => $baseDir . '/../processors/plugin_badgewidget.php',
|
382 |
'ICWP_WPSF_Processor_Plugin_CronDaily' => $baseDir . '/../processors/plugin_crondaily.php',
|
383 |
'ICWP_WPSF_Processor_Plugin_CronHourly' => $baseDir . '/../processors/plugin_cronhourly.php',
|
|
|
384 |
'ICWP_WPSF_Processor_Plugin_ImportExport' => $baseDir . '/../processors/plugin_importexport.php',
|
385 |
'ICWP_WPSF_Processor_Plugin_Notes' => $baseDir . '/../processors/plugin_notes.php',
|
386 |
'ICWP_WPSF_Processor_Plugin_Tracking' => $baseDir . '/../processors/plugin_tracking.php',
|
76 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Handler' => $baseDir . '/src/Databases/Comments/Handler.php',
|
77 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Insert' => $baseDir . '/src/Databases/Comments/Insert.php',
|
78 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Select' => $baseDir . '/src/Databases/Comments/Select.php',
|
79 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\BaseGeoIp' => $baseDir . '/src/Databases/GeoIp/BaseGeoIp.php',
|
80 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Delete' => $baseDir . '/src/Databases/GeoIp/Delete.php',
|
81 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\EntryVO' => $baseDir . '/src/Databases/GeoIp/EntryVO.php',
|
82 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Handler' => $baseDir . '/src/Databases/GeoIp/Handler.php',
|
83 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Insert' => $baseDir . '/src/Databases/GeoIp/Insert.php',
|
84 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Select' => $baseDir . '/src/Databases/GeoIp/Select.php',
|
85 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\CommonFilters' => $baseDir . '/src/Databases/IPs/CommonFilters.php',
|
86 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\Delete' => $baseDir . '/src/Databases/IPs/Delete.php',
|
87 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\EntryVO' => $baseDir . '/src/Databases/IPs/EntryVO.php',
|
114 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Insert' => $baseDir . '/src/Databases/Traffic/Insert.php',
|
115 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Select' => $baseDir . '/src/Databases/Traffic/Select.php',
|
116 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => $baseDir . '/src/License/EddLicenseVO.php',
|
117 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\GeoIp\\Lookup' => $baseDir . '/src/Modules/GeoIp/Lookup.php',
|
118 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Base' => $baseDir . '/src/Modules/IPs/BotTrack/Base.php',
|
119 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Track404' => $baseDir . '/src/Modules/IPs/BotTrack/Track404.php',
|
120 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\TrackFakeWebCrawler' => $baseDir . '/src/Modules/IPs/BotTrack/TrackFakeWebCrawler.php',
|
150 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\CopyResultsSets' => $baseDir . '/src/Scans/Helpers/CopyResultsSets.php',
|
151 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\ScannerRecursiveFilterIterator' => $baseDir . '/src/Scans/Helpers/ScannerRecursiveFilterIterator.php',
|
152 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\StandardDirectoryIterator' => $baseDir . '/src/Scans/Helpers/StandardDirectoryIterator.php',
|
153 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\WpCoreFile' => $baseDir . '/src/Scans/Helpers/WpCoreFile.php',
|
154 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ConvertResultsToVos' => $baseDir . '/src/Scans/Mal/ConvertResultsToVos.php',
|
155 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ConvertVosToResults' => $baseDir . '/src/Scans/Mal/ConvertVosToResults.php',
|
156 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\Repair' => $baseDir . '/src/Scans/Mal/Repair.php',
|
157 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ResultItem' => $baseDir . '/src/Scans/Mal/ResultItem.php',
|
158 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ResultsSet' => $baseDir . '/src/Scans/Mal/ResultsSet.php',
|
159 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\Scanner' => $baseDir . '/src/Scans/Mal/Scanner.php',
|
160 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertResultsToVos' => $baseDir . '/src/Scans/Ptg/ConvertResultsToVos.php',
|
161 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertVosToResults' => $baseDir . '/src/Scans/Ptg/ConvertVosToResults.php',
|
162 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\DiffHashes' => $baseDir . '/src/Scans/Ptg/DiffHashes.php',
|
201 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\Ip' => $baseDir . '/src/Tables/Build/Ip.php',
|
202 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanApc' => $baseDir . '/src/Tables/Build/ScanApc.php',
|
203 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanBase' => $baseDir . '/src/Tables/Build/ScanBase.php',
|
204 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanMal' => $baseDir . '/src/Tables/Build/ScanMal.php',
|
205 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanPtg' => $baseDir . '/src/Tables/Build/ScanPtg.php',
|
206 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanUfc' => $baseDir . '/src/Tables/Build/ScanUfc.php',
|
207 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanWcf' => $baseDir . '/src/Tables/Build/ScanWcf.php',
|
252 |
'FernleafSystems\\Wordpress\\Services\\Core\\VOs\\WpPluginVo' => $vendorDir . '/fernleafsystems/wordpress-services/src/Core/VOs/WpPluginVo.php',
|
253 |
'FernleafSystems\\Wordpress\\Services\\Services' => $vendorDir . '/fernleafsystems/wordpress-services/src/Services.php',
|
254 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ClassicPress\\Checksums' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ClassicPress/Checksums.php',
|
255 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\Consumers\\PluginConsumer' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Consumers/PluginConsumer.php',
|
256 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Data' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Data.php',
|
257 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\DataManipulation' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php',
|
258 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Email' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Email.php',
|
263 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\WriteDataToFileEncrypted' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/WriteDataToFileEncrypted.php',
|
264 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\GeoIp' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/GeoIp.php',
|
265 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpRequest' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/HttpRequest.php',
|
266 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpUtil' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/HttpUtil.php',
|
267 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\IpUtils' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/IpUtils.php',
|
268 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Iterators\\WpUserIterator' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Iterators/WpUserIterator.php',
|
269 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Net\\VisitorIpDetection' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Net/VisitorIpDetection.php',
|
270 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\PluginUserMeta' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/PluginUserMeta.php',
|
271 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
|
272 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
|
273 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\RepoBase' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php',
|
274 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\VersionsBase' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/VersionsBase.php',
|
275 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Core' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Core.php',
|
276 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Files' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Files.php',
|
277 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Repo' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php',
|
278 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Versions' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Versions.php',
|
279 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Api' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Api.php',
|
280 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Base' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Base.php',
|
281 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Download' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Download.php',
|
282 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Files' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Files.php',
|
283 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Repo' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php',
|
284 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\VOs\\PluginInfoVO' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/VOs/PluginInfoVO.php',
|
285 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Versions' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Versions.php',
|
286 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugins' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugins.php',
|
287 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Base' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Base.php',
|
288 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Files' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Files.php',
|
289 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Repo' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php',
|
290 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Versions' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Versions.php',
|
291 |
'GeoIp2\\Database\\Reader' => $vendorDir . '/geoip2/geoip2/src/Database/Reader.php',
|
292 |
'GeoIp2\\Exception\\AddressNotFoundException' => $vendorDir . '/geoip2/geoip2/src/Exception/AddressNotFoundException.php',
|
293 |
'GeoIp2\\Exception\\AuthenticationException' => $vendorDir . '/geoip2/geoip2/src/Exception/AuthenticationException.php',
|
383 |
'ICWP_WPSF_Processor_HackProtect' => $baseDir . '/../processors/hack_protect.php',
|
384 |
'ICWP_WPSF_Processor_HackProtect_Apc' => $baseDir . '/../processors/hackprotect_scan_apc.php',
|
385 |
'ICWP_WPSF_Processor_HackProtect_Integrity' => $baseDir . '/../processors/hackprotect_integrity.php',
|
386 |
+
'ICWP_WPSF_Processor_HackProtect_Mal' => $baseDir . '/../processors/hackprotect_scan_mal.php',
|
387 |
'ICWP_WPSF_Processor_HackProtect_Ptg' => $baseDir . '/../processors/hackprotect_scan_ptg.php',
|
388 |
'ICWP_WPSF_Processor_HackProtect_Realtime' => $baseDir . '/../processors/hackprotect_realtime.php',
|
389 |
'ICWP_WPSF_Processor_HackProtect_ScanAssetsBase' => $baseDir . '/../processors/hackprotect_scan_assets_base.php',
|
414 |
'ICWP_WPSF_Processor_Plugin_BadgeWidget' => $baseDir . '/../processors/plugin_badgewidget.php',
|
415 |
'ICWP_WPSF_Processor_Plugin_CronDaily' => $baseDir . '/../processors/plugin_crondaily.php',
|
416 |
'ICWP_WPSF_Processor_Plugin_CronHourly' => $baseDir . '/../processors/plugin_cronhourly.php',
|
417 |
+
'ICWP_WPSF_Processor_Plugin_Geoip' => $baseDir . '/../processors/plugin_geoip.php',
|
418 |
'ICWP_WPSF_Processor_Plugin_ImportExport' => $baseDir . '/../processors/plugin_importexport.php',
|
419 |
'ICWP_WPSF_Processor_Plugin_Notes' => $baseDir . '/../processors/plugin_notes.php',
|
420 |
'ICWP_WPSF_Processor_Plugin_Tracking' => $baseDir . '/../processors/plugin_tracking.php',
|
@@ -237,6 +237,12 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
237 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Handler' => __DIR__ . '/../..' . '/src/Databases/Comments/Handler.php',
|
238 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Insert' => __DIR__ . '/../..' . '/src/Databases/Comments/Insert.php',
|
239 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Select' => __DIR__ . '/../..' . '/src/Databases/Comments/Select.php',
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\CommonFilters' => __DIR__ . '/../..' . '/src/Databases/IPs/CommonFilters.php',
|
241 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\Delete' => __DIR__ . '/../..' . '/src/Databases/IPs/Delete.php',
|
242 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\EntryVO' => __DIR__ . '/../..' . '/src/Databases/IPs/EntryVO.php',
|
@@ -269,6 +275,7 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
269 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Insert' => __DIR__ . '/../..' . '/src/Databases/Traffic/Insert.php',
|
270 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Select' => __DIR__ . '/../..' . '/src/Databases/Traffic/Select.php',
|
271 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => __DIR__ . '/../..' . '/src/License/EddLicenseVO.php',
|
|
|
272 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Base' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/Base.php',
|
273 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Track404' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/Track404.php',
|
274 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\TrackFakeWebCrawler' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/TrackFakeWebCrawler.php',
|
@@ -304,7 +311,13 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
304 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\CopyResultsSets' => __DIR__ . '/../..' . '/src/Scans/Helpers/CopyResultsSets.php',
|
305 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\ScannerRecursiveFilterIterator' => __DIR__ . '/../..' . '/src/Scans/Helpers/ScannerRecursiveFilterIterator.php',
|
306 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\StandardDirectoryIterator' => __DIR__ . '/../..' . '/src/Scans/Helpers/StandardDirectoryIterator.php',
|
307 |
-
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertResultsToVos' => __DIR__ . '/../..' . '/src/Scans/Ptg/ConvertResultsToVos.php',
|
309 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertVosToResults' => __DIR__ . '/../..' . '/src/Scans/Ptg/ConvertVosToResults.php',
|
310 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\DiffHashes' => __DIR__ . '/../..' . '/src/Scans/Ptg/DiffHashes.php',
|
@@ -349,6 +362,7 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
349 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\Ip' => __DIR__ . '/../..' . '/src/Tables/Build/Ip.php',
|
350 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanApc' => __DIR__ . '/../..' . '/src/Tables/Build/ScanApc.php',
|
351 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanBase' => __DIR__ . '/../..' . '/src/Tables/Build/ScanBase.php',
|
|
|
352 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanPtg' => __DIR__ . '/../..' . '/src/Tables/Build/ScanPtg.php',
|
353 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanUfc' => __DIR__ . '/../..' . '/src/Tables/Build/ScanUfc.php',
|
354 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanWcf' => __DIR__ . '/../..' . '/src/Tables/Build/ScanWcf.php',
|
@@ -399,6 +413,7 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
399 |
'FernleafSystems\\Wordpress\\Services\\Core\\VOs\\WpPluginVo' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Core/VOs/WpPluginVo.php',
|
400 |
'FernleafSystems\\Wordpress\\Services\\Services' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Services.php',
|
401 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ClassicPress\\Checksums' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ClassicPress/Checksums.php',
|
|
|
402 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Data' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Data.php',
|
403 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\DataManipulation' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php',
|
404 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Email' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Email.php',
|
@@ -409,14 +424,31 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
409 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\WriteDataToFileEncrypted' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/WriteDataToFileEncrypted.php',
|
410 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\GeoIp' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/GeoIp.php',
|
411 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpRequest' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/HttpRequest.php',
|
|
|
412 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\IpUtils' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/IpUtils.php',
|
413 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Iterators\\WpUserIterator' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Iterators/WpUserIterator.php',
|
414 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Net\\VisitorIpDetection' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Net/VisitorIpDetection.php',
|
415 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\PluginUserMeta' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/PluginUserMeta.php',
|
416 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
|
417 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
|
|
|
|
|
418 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Core' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Core.php',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugins' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugins.php',
|
|
|
|
|
|
|
|
|
420 |
'GeoIp2\\Database\\Reader' => __DIR__ . '/..' . '/geoip2/geoip2/src/Database/Reader.php',
|
421 |
'GeoIp2\\Exception\\AddressNotFoundException' => __DIR__ . '/..' . '/geoip2/geoip2/src/Exception/AddressNotFoundException.php',
|
422 |
'GeoIp2\\Exception\\AuthenticationException' => __DIR__ . '/..' . '/geoip2/geoip2/src/Exception/AuthenticationException.php',
|
@@ -512,6 +544,7 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
512 |
'ICWP_WPSF_Processor_HackProtect' => __DIR__ . '/../..' . '/../processors/hack_protect.php',
|
513 |
'ICWP_WPSF_Processor_HackProtect_Apc' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_apc.php',
|
514 |
'ICWP_WPSF_Processor_HackProtect_Integrity' => __DIR__ . '/../..' . '/../processors/hackprotect_integrity.php',
|
|
|
515 |
'ICWP_WPSF_Processor_HackProtect_Ptg' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_ptg.php',
|
516 |
'ICWP_WPSF_Processor_HackProtect_Realtime' => __DIR__ . '/../..' . '/../processors/hackprotect_realtime.php',
|
517 |
'ICWP_WPSF_Processor_HackProtect_ScanAssetsBase' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_assets_base.php',
|
@@ -542,6 +575,7 @@ class ComposerStaticInit18a31866e67f0a0bfffdc031786ecae1
|
|
542 |
'ICWP_WPSF_Processor_Plugin_BadgeWidget' => __DIR__ . '/../..' . '/../processors/plugin_badgewidget.php',
|
543 |
'ICWP_WPSF_Processor_Plugin_CronDaily' => __DIR__ . '/../..' . '/../processors/plugin_crondaily.php',
|
544 |
'ICWP_WPSF_Processor_Plugin_CronHourly' => __DIR__ . '/../..' . '/../processors/plugin_cronhourly.php',
|
|
|
545 |
'ICWP_WPSF_Processor_Plugin_ImportExport' => __DIR__ . '/../..' . '/../processors/plugin_importexport.php',
|
546 |
'ICWP_WPSF_Processor_Plugin_Notes' => __DIR__ . '/../..' . '/../processors/plugin_notes.php',
|
547 |
'ICWP_WPSF_Processor_Plugin_Tracking' => __DIR__ . '/../..' . '/../processors/plugin_tracking.php',
|
237 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Handler' => __DIR__ . '/../..' . '/src/Databases/Comments/Handler.php',
|
238 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Insert' => __DIR__ . '/../..' . '/src/Databases/Comments/Insert.php',
|
239 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Comments\\Select' => __DIR__ . '/../..' . '/src/Databases/Comments/Select.php',
|
240 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\BaseGeoIp' => __DIR__ . '/../..' . '/src/Databases/GeoIp/BaseGeoIp.php',
|
241 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Delete' => __DIR__ . '/../..' . '/src/Databases/GeoIp/Delete.php',
|
242 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\EntryVO' => __DIR__ . '/../..' . '/src/Databases/GeoIp/EntryVO.php',
|
243 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Handler' => __DIR__ . '/../..' . '/src/Databases/GeoIp/Handler.php',
|
244 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Insert' => __DIR__ . '/../..' . '/src/Databases/GeoIp/Insert.php',
|
245 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\GeoIp\\Select' => __DIR__ . '/../..' . '/src/Databases/GeoIp/Select.php',
|
246 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\CommonFilters' => __DIR__ . '/../..' . '/src/Databases/IPs/CommonFilters.php',
|
247 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\Delete' => __DIR__ . '/../..' . '/src/Databases/IPs/Delete.php',
|
248 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\IPs\\EntryVO' => __DIR__ . '/../..' . '/src/Databases/IPs/EntryVO.php',
|
275 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Insert' => __DIR__ . '/../..' . '/src/Databases/Traffic/Insert.php',
|
276 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Databases\\Traffic\\Select' => __DIR__ . '/../..' . '/src/Databases/Traffic/Select.php',
|
277 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\License\\EddLicenseVO' => __DIR__ . '/../..' . '/src/License/EddLicenseVO.php',
|
278 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\GeoIp\\Lookup' => __DIR__ . '/../..' . '/src/Modules/GeoIp/Lookup.php',
|
279 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Base' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/Base.php',
|
280 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\Track404' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/Track404.php',
|
281 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\IPs\\BotTrack\\TrackFakeWebCrawler' => __DIR__ . '/../..' . '/src/Modules/IPs/BotTrack/TrackFakeWebCrawler.php',
|
311 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\CopyResultsSets' => __DIR__ . '/../..' . '/src/Scans/Helpers/CopyResultsSets.php',
|
312 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\ScannerRecursiveFilterIterator' => __DIR__ . '/../..' . '/src/Scans/Helpers/ScannerRecursiveFilterIterator.php',
|
313 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\StandardDirectoryIterator' => __DIR__ . '/../..' . '/src/Scans/Helpers/StandardDirectoryIterator.php',
|
314 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Helpers\\WpCoreFile' => __DIR__ . '/../..' . '/src/Scans/Helpers/WpCoreFile.php',
|
315 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ConvertResultsToVos' => __DIR__ . '/../..' . '/src/Scans/Mal/ConvertResultsToVos.php',
|
316 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ConvertVosToResults' => __DIR__ . '/../..' . '/src/Scans/Mal/ConvertVosToResults.php',
|
317 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\Repair' => __DIR__ . '/../..' . '/src/Scans/Mal/Repair.php',
|
318 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ResultItem' => __DIR__ . '/../..' . '/src/Scans/Mal/ResultItem.php',
|
319 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\ResultsSet' => __DIR__ . '/../..' . '/src/Scans/Mal/ResultsSet.php',
|
320 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Mal\\Scanner' => __DIR__ . '/../..' . '/src/Scans/Mal/Scanner.php',
|
321 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertResultsToVos' => __DIR__ . '/../..' . '/src/Scans/Ptg/ConvertResultsToVos.php',
|
322 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\ConvertVosToResults' => __DIR__ . '/../..' . '/src/Scans/Ptg/ConvertVosToResults.php',
|
323 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Scans\\Ptg\\DiffHashes' => __DIR__ . '/../..' . '/src/Scans/Ptg/DiffHashes.php',
|
362 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\Ip' => __DIR__ . '/../..' . '/src/Tables/Build/Ip.php',
|
363 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanApc' => __DIR__ . '/../..' . '/src/Tables/Build/ScanApc.php',
|
364 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanBase' => __DIR__ . '/../..' . '/src/Tables/Build/ScanBase.php',
|
365 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanMal' => __DIR__ . '/../..' . '/src/Tables/Build/ScanMal.php',
|
366 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanPtg' => __DIR__ . '/../..' . '/src/Tables/Build/ScanPtg.php',
|
367 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanUfc' => __DIR__ . '/../..' . '/src/Tables/Build/ScanUfc.php',
|
368 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Tables\\Build\\ScanWcf' => __DIR__ . '/../..' . '/src/Tables/Build/ScanWcf.php',
|
413 |
'FernleafSystems\\Wordpress\\Services\\Core\\VOs\\WpPluginVo' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Core/VOs/WpPluginVo.php',
|
414 |
'FernleafSystems\\Wordpress\\Services\\Services' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Services.php',
|
415 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ClassicPress\\Checksums' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ClassicPress/Checksums.php',
|
416 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\Consumers\\PluginConsumer' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Consumers/PluginConsumer.php',
|
417 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Data' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Data.php',
|
418 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\DataManipulation' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php',
|
419 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Email' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Email.php',
|
424 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\WriteDataToFileEncrypted' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/WriteDataToFileEncrypted.php',
|
425 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\GeoIp' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/GeoIp.php',
|
426 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpRequest' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/HttpRequest.php',
|
427 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\HttpUtil' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/HttpUtil.php',
|
428 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\IpUtils' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/IpUtils.php',
|
429 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Iterators\\WpUserIterator' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Iterators/WpUserIterator.php',
|
430 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Net\\VisitorIpDetection' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Net/VisitorIpDetection.php',
|
431 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\PluginUserMeta' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/PluginUserMeta.php',
|
432 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
|
433 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
|
434 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\RepoBase' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php',
|
435 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\VersionsBase' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/VersionsBase.php',
|
436 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Core' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Core.php',
|
437 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Files' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Files.php',
|
438 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Repo' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php',
|
439 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Cp\\Versions' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Versions.php',
|
440 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Api' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Api.php',
|
441 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Base' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Base.php',
|
442 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Download' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Download.php',
|
443 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Files' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Files.php',
|
444 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Repo' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php',
|
445 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\VOs\\PluginInfoVO' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/VOs/PluginInfoVO.php',
|
446 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugin\\Versions' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Versions.php',
|
447 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Plugins' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugins.php',
|
448 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Base' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Base.php',
|
449 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Files' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Files.php',
|
450 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Repo' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php',
|
451 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Wp\\Versions' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Versions.php',
|
452 |
'GeoIp2\\Database\\Reader' => __DIR__ . '/..' . '/geoip2/geoip2/src/Database/Reader.php',
|
453 |
'GeoIp2\\Exception\\AddressNotFoundException' => __DIR__ . '/..' . '/geoip2/geoip2/src/Exception/AddressNotFoundException.php',
|
454 |
'GeoIp2\\Exception\\AuthenticationException' => __DIR__ . '/..' . '/geoip2/geoip2/src/Exception/AuthenticationException.php',
|
544 |
'ICWP_WPSF_Processor_HackProtect' => __DIR__ . '/../..' . '/../processors/hack_protect.php',
|
545 |
'ICWP_WPSF_Processor_HackProtect_Apc' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_apc.php',
|
546 |
'ICWP_WPSF_Processor_HackProtect_Integrity' => __DIR__ . '/../..' . '/../processors/hackprotect_integrity.php',
|
547 |
+
'ICWP_WPSF_Processor_HackProtect_Mal' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_mal.php',
|
548 |
'ICWP_WPSF_Processor_HackProtect_Ptg' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_ptg.php',
|
549 |
'ICWP_WPSF_Processor_HackProtect_Realtime' => __DIR__ . '/../..' . '/../processors/hackprotect_realtime.php',
|
550 |
'ICWP_WPSF_Processor_HackProtect_ScanAssetsBase' => __DIR__ . '/../..' . '/../processors/hackprotect_scan_assets_base.php',
|
575 |
'ICWP_WPSF_Processor_Plugin_BadgeWidget' => __DIR__ . '/../..' . '/../processors/plugin_badgewidget.php',
|
576 |
'ICWP_WPSF_Processor_Plugin_CronDaily' => __DIR__ . '/../..' . '/../processors/plugin_crondaily.php',
|
577 |
'ICWP_WPSF_Processor_Plugin_CronHourly' => __DIR__ . '/../..' . '/../processors/plugin_cronhourly.php',
|
578 |
+
'ICWP_WPSF_Processor_Plugin_Geoip' => __DIR__ . '/../..' . '/../processors/plugin_geoip.php',
|
579 |
'ICWP_WPSF_Processor_Plugin_ImportExport' => __DIR__ . '/../..' . '/../processors/plugin_importexport.php',
|
580 |
'ICWP_WPSF_Processor_Plugin_Notes' => __DIR__ . '/../..' . '/../processors/plugin_notes.php',
|
581 |
'ICWP_WPSF_Processor_Plugin_Tracking' => __DIR__ . '/../..' . '/../processors/plugin_tracking.php',
|
@@ -190,12 +190,12 @@
|
|
190 |
"source": {
|
191 |
"type": "git",
|
192 |
"url": "https://bitbucket.org/FernleafSystems/wordpress-services.git",
|
193 |
-
"reference": "
|
194 |
},
|
195 |
"dist": {
|
196 |
"type": "zip",
|
197 |
-
"url": "https://bitbucket.org/FernleafSystems/wordpress-services/get/
|
198 |
-
"reference": "
|
199 |
"shasum": ""
|
200 |
},
|
201 |
"require": {
|
@@ -208,7 +208,7 @@
|
|
208 |
"symfony/yaml": "~2.0||~3.0",
|
209 |
"twig/twig": "^1.0"
|
210 |
},
|
211 |
-
"time": "2019-
|
212 |
"type": "library",
|
213 |
"installation-source": "source",
|
214 |
"autoload": {
|
@@ -434,17 +434,17 @@
|
|
434 |
},
|
435 |
{
|
436 |
"name": "nesbot/carbon",
|
437 |
-
"version": "1.
|
438 |
-
"version_normalized": "1.
|
439 |
"source": {
|
440 |
"type": "git",
|
441 |
"url": "https://github.com/briannesbitt/Carbon.git",
|
442 |
-
"reference": "
|
443 |
},
|
444 |
"dist": {
|
445 |
"type": "zip",
|
446 |
-
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/
|
447 |
-
"reference": "
|
448 |
"shasum": ""
|
449 |
},
|
450 |
"require": {
|
@@ -458,7 +458,7 @@
|
|
458 |
"friendsofphp/php-cs-fixer": "Needed for the `composer phpcs` command. Allow to automatically fix code style.",
|
459 |
"phpstan/phpstan": "Needed for the `composer phpstan` command. Allow to detect potential errors."
|
460 |
},
|
461 |
-
"time": "
|
462 |
"type": "library",
|
463 |
"extra": {
|
464 |
"laravel": {
|
190 |
"source": {
|
191 |
"type": "git",
|
192 |
"url": "https://bitbucket.org/FernleafSystems/wordpress-services.git",
|
193 |
+
"reference": "9cb818f7abd9406b1d231090b21c98d887de64cf"
|
194 |
},
|
195 |
"dist": {
|
196 |
"type": "zip",
|
197 |
+
"url": "https://bitbucket.org/FernleafSystems/wordpress-services/get/9cb818f7abd9406b1d231090b21c98d887de64cf.zip",
|
198 |
+
"reference": "9cb818f7abd9406b1d231090b21c98d887de64cf",
|
199 |
"shasum": ""
|
200 |
},
|
201 |
"require": {
|
208 |
"symfony/yaml": "~2.0||~3.0",
|
209 |
"twig/twig": "^1.0"
|
210 |
},
|
211 |
+
"time": "2019-05-12T14:53:47+00:00",
|
212 |
"type": "library",
|
213 |
"installation-source": "source",
|
214 |
"autoload": {
|
434 |
},
|
435 |
{
|
436 |
"name": "nesbot/carbon",
|
437 |
+
"version": "1.37.1",
|
438 |
+
"version_normalized": "1.37.1.0",
|
439 |
"source": {
|
440 |
"type": "git",
|
441 |
"url": "https://github.com/briannesbitt/Carbon.git",
|
442 |
+
"reference": "5be4fdf97076a685b23efdedfc2b73ad0c5eab70"
|
443 |
},
|
444 |
"dist": {
|
445 |
"type": "zip",
|
446 |
+
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/5be4fdf97076a685b23efdedfc2b73ad0c5eab70",
|
447 |
+
"reference": "5be4fdf97076a685b23efdedfc2b73ad0c5eab70",
|
448 |
"shasum": ""
|
449 |
},
|
450 |
"require": {
|
458 |
"friendsofphp/php-cs-fixer": "Needed for the `composer phpcs` command. Allow to automatically fix code style.",
|
459 |
"phpstan/phpstan": "Needed for the `composer phpstan` command. Allow to detect potential errors."
|
460 |
},
|
461 |
+
"time": "2019-04-19T10:27:42+00:00",
|
462 |
"type": "library",
|
463 |
"extra": {
|
464 |
"laravel": {
|
@@ -24,18 +24,18 @@ class AdminNotices {
|
|
24 |
protected $sActionPrefix = '';
|
25 |
|
26 |
public function __construct() {
|
27 |
-
add_action( 'admin_notices',
|
28 |
-
add_action( 'network_admin_notices',
|
29 |
-
add_action( 'wp_loaded',
|
30 |
|
31 |
if ( Services::WpGeneral()->getIsAjax() ) {
|
32 |
-
add_action( 'wp_ajax_icwp_DismissAdminNotice',
|
33 |
}
|
34 |
}
|
35 |
|
36 |
public function onWpAdminNotices() {
|
37 |
do_action( $this->getActionPrefix().'generate_admin_notices' );
|
38 |
-
foreach( $this->getNotices() as $sKey => $sAdminNoticeContent ) {
|
39 |
echo $sAdminNoticeContent;
|
40 |
}
|
41 |
$this->flashNotice();
|
@@ -47,7 +47,7 @@ class AdminNotices {
|
|
47 |
if ( $bSuccess ) {
|
48 |
// Get all notices and if this notice exists, we set it to "hidden"
|
49 |
$sNoticeId = sanitize_key( Services::Request()->query( 'notice_id', '' ) );
|
50 |
-
$aNotices = apply_filters( $this->getActionPrefix().'register_admin_notices',
|
51 |
if ( !empty( $sNoticeId ) && array_key_exists( $sNoticeId, $aNotices ) ) {
|
52 |
$this->setAdminNoticeAsDismissed( $aNotices[ $sNoticeId ] );
|
53 |
}
|
@@ -76,7 +76,7 @@ class AdminNotices {
|
|
76 |
* @param array $aNotice
|
77 |
*/
|
78 |
public function setAdminNoticeAsDismissed( $aNotice ) {
|
79 |
-
Services::WpUsers()->updateUserMeta( $this->getActionPrefix().$aNotice['id'], 'Y' );
|
80 |
}
|
81 |
|
82 |
/**
|
@@ -97,15 +97,15 @@ class AdminNotices {
|
|
97 |
}
|
98 |
|
99 |
// At this stage we haven't returned after success so we failed the nonce check
|
100 |
-
$this->sendAjaxResponse( false,
|
101 |
return false; //unreachable
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
-
* @param
|
106 |
* @param array $aData
|
107 |
*/
|
108 |
-
protected function sendAjaxResponse( $bSuccess, $aData =
|
109 |
$bSuccess ? wp_send_json_success( $aData ) : wp_send_json_error( $aData );
|
110 |
}
|
111 |
|
@@ -130,7 +130,7 @@ class AdminNotices {
|
|
130 |
*/
|
131 |
protected function getNotices() {
|
132 |
if ( !isset( $this->aAdminNotices ) || !is_array( $this->aAdminNotices ) ) {
|
133 |
-
$this->aAdminNotices =
|
134 |
}
|
135 |
return $this->aAdminNotices;
|
136 |
}
|
@@ -166,9 +166,9 @@ class AdminNotices {
|
|
166 |
/**
|
167 |
* Provides the basic HTML template for printing a WordPress Admin Notices
|
168 |
*
|
169 |
-
* @param $sNotice
|
170 |
* @param $sMessageClass - either error or updated
|
171 |
-
* @param $bPrint
|
172 |
*
|
173 |
* @return boolean|string
|
174 |
*/
|
@@ -178,7 +178,8 @@ class AdminNotices {
|
|
178 |
if ( $bPrint ) {
|
179 |
echo $sFullNotice;
|
180 |
return true;
|
181 |
-
}
|
|
|
182 |
return $sFullNotice;
|
183 |
}
|
184 |
}
|
24 |
protected $sActionPrefix = '';
|
25 |
|
26 |
public function __construct() {
|
27 |
+
add_action( 'admin_notices', [ $this, 'onWpAdminNotices' ] );
|
28 |
+
add_action( 'network_admin_notices', [ $this, 'onWpAdminNotices' ] );
|
29 |
+
add_action( 'wp_loaded', [ $this, 'flushFlashMessage' ] );
|
30 |
|
31 |
if ( Services::WpGeneral()->getIsAjax() ) {
|
32 |
+
add_action( 'wp_ajax_icwp_DismissAdminNotice', [ $this, 'ajaxDismissAdminNotice' ] );
|
33 |
}
|
34 |
}
|
35 |
|
36 |
public function onWpAdminNotices() {
|
37 |
do_action( $this->getActionPrefix().'generate_admin_notices' );
|
38 |
+
foreach ( $this->getNotices() as $sKey => $sAdminNoticeContent ) {
|
39 |
echo $sAdminNoticeContent;
|
40 |
}
|
41 |
$this->flashNotice();
|
47 |
if ( $bSuccess ) {
|
48 |
// Get all notices and if this notice exists, we set it to "hidden"
|
49 |
$sNoticeId = sanitize_key( Services::Request()->query( 'notice_id', '' ) );
|
50 |
+
$aNotices = apply_filters( $this->getActionPrefix().'register_admin_notices', [] );
|
51 |
if ( !empty( $sNoticeId ) && array_key_exists( $sNoticeId, $aNotices ) ) {
|
52 |
$this->setAdminNoticeAsDismissed( $aNotices[ $sNoticeId ] );
|
53 |
}
|
76 |
* @param array $aNotice
|
77 |
*/
|
78 |
public function setAdminNoticeAsDismissed( $aNotice ) {
|
79 |
+
Services::WpUsers()->updateUserMeta( $this->getActionPrefix().$aNotice[ 'id' ], 'Y' );
|
80 |
}
|
81 |
|
82 |
/**
|
97 |
}
|
98 |
|
99 |
// At this stage we haven't returned after success so we failed the nonce check
|
100 |
+
$this->sendAjaxResponse( false, [ 'message' => $sMessage ] );
|
101 |
return false; //unreachable
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
+
* @param $bSuccess
|
106 |
* @param array $aData
|
107 |
*/
|
108 |
+
protected function sendAjaxResponse( $bSuccess, $aData = [] ) {
|
109 |
$bSuccess ? wp_send_json_success( $aData ) : wp_send_json_error( $aData );
|
110 |
}
|
111 |
|
130 |
*/
|
131 |
protected function getNotices() {
|
132 |
if ( !isset( $this->aAdminNotices ) || !is_array( $this->aAdminNotices ) ) {
|
133 |
+
$this->aAdminNotices = [];
|
134 |
}
|
135 |
return $this->aAdminNotices;
|
136 |
}
|
166 |
/**
|
167 |
* Provides the basic HTML template for printing a WordPress Admin Notices
|
168 |
*
|
169 |
+
* @param $sNotice - The message to be displayed.
|
170 |
* @param $sMessageClass - either error or updated
|
171 |
+
* @param $bPrint - if true, will echo. false will return the string
|
172 |
*
|
173 |
* @return boolean|string
|
174 |
*/
|
178 |
if ( $bPrint ) {
|
179 |
echo $sFullNotice;
|
180 |
return true;
|
181 |
+
}
|
182 |
+
else {
|
183 |
return $sFullNotice;
|
184 |
}
|
185 |
}
|
@@ -112,13 +112,13 @@ class Comments {
|
|
112 |
* @return array
|
113 |
*/
|
114 |
public function getCommentSubmissionComponents() {
|
115 |
-
return
|
116 |
'comment_post_ID',
|
117 |
'author',
|
118 |
'email',
|
119 |
'url',
|
120 |
'comment',
|
121 |
'comment_parent',
|
122 |
-
|
123 |
}
|
124 |
}
|
112 |
* @return array
|
113 |
*/
|
114 |
public function getCommentSubmissionComponents() {
|
115 |
+
return [
|
116 |
'comment_post_ID',
|
117 |
'author',
|
118 |
'email',
|
119 |
'url',
|
120 |
'comment',
|
121 |
'comment_parent',
|
122 |
+
];
|
123 |
}
|
124 |
}
|
@@ -21,7 +21,7 @@ class CoreFileHashes {
|
|
21 |
public function getHashes() {
|
22 |
if ( !isset( $this->aHashes ) ) {
|
23 |
$aHash = Services::WpGeneral()->getCoreChecksums();
|
24 |
-
$this->aHashes = is_array( $aHash ) ? $aHash :
|
25 |
}
|
26 |
return $this->aHashes;
|
27 |
}
|
21 |
public function getHashes() {
|
22 |
if ( !isset( $this->aHashes ) ) {
|
23 |
$aHash = Services::WpGeneral()->getCoreChecksums();
|
24 |
+
$this->aHashes = is_array( $aHash ) ? $aHash : [];
|
25 |
}
|
26 |
return $this->aHashes;
|
27 |
}
|
@@ -22,7 +22,7 @@ class Cron {
|
|
22 |
protected $aSchedules;
|
23 |
|
24 |
public function __construct() {
|
25 |
-
add_filter( 'cron_schedules',
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -48,11 +48,11 @@ class Cron {
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* @deprecated uses undocumented private WP function
|
52 |
* @return array
|
|
|
53 |
*/
|
54 |
public function getCrons() {
|
55 |
-
return function_exists( '_get_cron_array' ) && is_array( _get_cron_array() ) ? _get_cron_array() :
|
56 |
}
|
57 |
|
58 |
/**
|
@@ -60,7 +60,7 @@ class Cron {
|
|
60 |
*/
|
61 |
protected function getSchedules() {
|
62 |
if ( !is_array( $this->aSchedules ) ) {
|
63 |
-
$this->aSchedules =
|
64 |
}
|
65 |
return $this->aSchedules;
|
66 |
}
|
22 |
protected $aSchedules;
|
23 |
|
24 |
public function __construct() {
|
25 |
+
add_filter( 'cron_schedules', [ $this, 'addSchedules' ] );
|
26 |
}
|
27 |
|
28 |
/**
|
48 |
}
|
49 |
|
50 |
/**
|
|
|
51 |
* @return array
|
52 |
+
* @deprecated uses undocumented private WP function
|
53 |
*/
|
54 |
public function getCrons() {
|
55 |
+
return function_exists( '_get_cron_array' ) && is_array( _get_cron_array() ) ? _get_cron_array() : [];
|
56 |
}
|
57 |
|
58 |
/**
|
60 |
*/
|
61 |
protected function getSchedules() {
|
62 |
if ( !is_array( $this->aSchedules ) ) {
|
63 |
+
$this->aSchedules = [];
|
64 |
}
|
65 |
return $this->aSchedules;
|
66 |
}
|
@@ -11,7 +11,7 @@ class CustomHooks {
|
|
11 |
const HOOK_PREFIX = 'odp_';
|
12 |
|
13 |
public function __construct() {
|
14 |
-
add_action( 'upgrader_process_complete',
|
15 |
}
|
16 |
|
17 |
/**
|
11 |
const HOOK_PREFIX = 'odp_';
|
12 |
|
13 |
public function __construct() {
|
14 |
+
add_action( 'upgrader_process_complete', [ $this, 'onUpgraderProcessComplete' ], 100, 2 );
|
15 |
}
|
16 |
|
17 |
/**
|
@@ -17,13 +17,13 @@ class Db {
|
|
17 |
* @return array
|
18 |
*/
|
19 |
public function dbDelta( $sSQL ) {
|
20 |
-
require_once( ABSPATH
|
21 |
return dbDelta( $sSQL );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
* @param string $sTable
|
26 |
-
* @param array
|
27 |
* @return false|int
|
28 |
*/
|
29 |
public function deleteRowsFromTableWhere( $sTable, $aWhere ) {
|
@@ -37,7 +37,7 @@ class Db {
|
|
37 |
* @return bool|int
|
38 |
*/
|
39 |
public function doDropTable( $sTable ) {
|
40 |
-
$sQuery = sprintf( 'DROP TABLE IF EXISTS `%s`', $sTable )
|
41 |
return $this->doSql( $sQuery );
|
42 |
}
|
43 |
|
@@ -94,7 +94,7 @@ class Db {
|
|
94 |
* @return array
|
95 |
*/
|
96 |
public function getColumnsForTable( $sTableName, $sArrayMapCallBack = '' ) {
|
97 |
-
$aColumns = $this->loadWpdb()->get_col( "DESCRIBE "
|
98 |
|
99 |
if ( !empty( $sArrayMapCallBack ) && function_exists( $sArrayMapCallBack ) ) {
|
100 |
return array_map( $sArrayMapCallBack, $aColumns );
|
@@ -143,7 +143,7 @@ class Db {
|
|
143 |
|
144 |
/**
|
145 |
* @param string $sTable
|
146 |
-
* @param array
|
147 |
*
|
148 |
* @return int|boolean
|
149 |
*/
|
@@ -164,7 +164,7 @@ class Db {
|
|
164 |
|
165 |
/**
|
166 |
* @param string $sQuery
|
167 |
-
* @param
|
168 |
* @return array|boolean
|
169 |
*/
|
170 |
public function selectCustom( $sQuery, $nFormat = ARRAY_A ) {
|
@@ -172,7 +172,7 @@ class Db {
|
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
-
* @param
|
176 |
* @param string $nFormat
|
177 |
*
|
178 |
* @return null|object|array
|
@@ -183,8 +183,8 @@ class Db {
|
|
183 |
|
184 |
/**
|
185 |
* @param string $sTable
|
186 |
-
* @param array
|
187 |
-
* @param array
|
188 |
*
|
189 |
* @return integer|boolean (number of rows affected)
|
190 |
*/
|
17 |
* @return array
|
18 |
*/
|
19 |
public function dbDelta( $sSQL ) {
|
20 |
+
require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
|
21 |
return dbDelta( $sSQL );
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
* @param string $sTable
|
26 |
+
* @param array $aWhere - delete where (associative array)
|
27 |
* @return false|int
|
28 |
*/
|
29 |
public function deleteRowsFromTableWhere( $sTable, $aWhere ) {
|
37 |
* @return bool|int
|
38 |
*/
|
39 |
public function doDropTable( $sTable ) {
|
40 |
+
$sQuery = sprintf( 'DROP TABLE IF EXISTS `%s`', $sTable );
|
41 |
return $this->doSql( $sQuery );
|
42 |
}
|
43 |
|
94 |
* @return array
|
95 |
*/
|
96 |
public function getColumnsForTable( $sTableName, $sArrayMapCallBack = '' ) {
|
97 |
+
$aColumns = $this->loadWpdb()->get_col( "DESCRIBE ".$sTableName, 0 );
|
98 |
|
99 |
if ( !empty( $sArrayMapCallBack ) && function_exists( $sArrayMapCallBack ) ) {
|
100 |
return array_map( $sArrayMapCallBack, $aColumns );
|
143 |
|
144 |
/**
|
145 |
* @param string $sTable
|
146 |
+
* @param array $aData
|
147 |
*
|
148 |
* @return int|boolean
|
149 |
*/
|
164 |
|
165 |
/**
|
166 |
* @param string $sQuery
|
167 |
+
* @param $nFormat
|
168 |
* @return array|boolean
|
169 |
*/
|
170 |
public function selectCustom( $sQuery, $nFormat = ARRAY_A ) {
|
172 |
}
|
173 |
|
174 |
/**
|
175 |
+
* @param $sQuery
|
176 |
* @param string $nFormat
|
177 |
*
|
178 |
* @return null|object|array
|
183 |
|
184 |
/**
|
185 |
* @param string $sTable
|
186 |
+
* @param array $aData - new insert data (associative array, column=>data)
|
187 |
+
* @param array $aWhere - insert where (associative array)
|
188 |
*
|
189 |
* @return integer|boolean (number of rows affected)
|
190 |
*/
|
@@ -96,7 +96,7 @@ class Fs {
|
|
96 |
* @return string[]
|
97 |
*/
|
98 |
public function getAllFilesInDir( $sDir, $bIncludeDirs = true ) {
|
99 |
-
$aFiles =
|
100 |
if ( $this->canAccessDirectory( $sDir ) ) {
|
101 |
foreach ( $this->getDirIterator( $sDir ) as $oFileItem ) {
|
102 |
if ( !$oFileItem->isDot() && ( $oFileItem->isFile() || $bIncludeDirs ) ) {
|
@@ -104,7 +104,7 @@ class Fs {
|
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
-
return ( empty( $aFiles ) ?
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -152,11 +152,11 @@ class Fs {
|
|
152 |
*/
|
153 |
public function getCanWpRemoteGet() {
|
154 |
$bCan = false;
|
155 |
-
$aUrlsToTest =
|
156 |
'https://www.microsoft.com',
|
157 |
'https://www.google.com',
|
158 |
'https://www.facebook.com'
|
159 |
-
|
160 |
foreach ( $aUrlsToTest as $sUrl ) {
|
161 |
if ( Services::HttpRequest()->get( $sUrl ) ) {
|
162 |
$bCan = true;
|
@@ -293,7 +293,7 @@ class Fs {
|
|
293 |
* @return \SplFileInfo[]
|
294 |
*/
|
295 |
public function getFilesInDir( $sDir, $nMaxDepth = 1, $oDirIterator = null ) {
|
296 |
-
$aList =
|
297 |
|
298 |
try {
|
299 |
if ( empty( $oDirIterator ) ) {
|
@@ -476,48 +476,48 @@ class Fs {
|
|
476 |
}
|
477 |
|
478 |
/**
|
479 |
-
* @deprecated
|
480 |
* @param string $sUrl
|
481 |
* @param array $aRequestArgs
|
482 |
* @return array|bool
|
|
|
483 |
*/
|
484 |
-
public function requestUrl( $sUrl, $aRequestArgs =
|
485 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs );
|
486 |
}
|
487 |
|
488 |
/**
|
489 |
-
* @deprecated
|
490 |
* @param string $sUrl
|
491 |
* @param array $aRequestArgs
|
492 |
* @return array|false
|
|
|
493 |
*/
|
494 |
-
public function getUrl( $sUrl, $aRequestArgs =
|
495 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs, 'GET' );
|
496 |
}
|
497 |
|
498 |
/**
|
499 |
-
* @deprecated
|
500 |
* @param string $sUrl
|
501 |
* @param array $aRequestArgs
|
502 |
* @return false|string
|
|
|
503 |
*/
|
504 |
-
public function getUrlContent( $sUrl, $aRequestArgs =
|
505 |
return Services::HttpRequest()->getContent( $sUrl, $aRequestArgs );
|
506 |
}
|
507 |
|
508 |
/**
|
509 |
-
* @deprecated
|
510 |
* @param string $sUrl
|
511 |
* @param array $aRequestArgs
|
512 |
* @return array|false
|
|
|
513 |
*/
|
514 |
-
public function postUrl( $sUrl, $aRequestArgs =
|
515 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs, 'POST' );
|
516 |
}
|
517 |
|
518 |
/**
|
519 |
-
* @deprecated
|
520 |
* @return string
|
|
|
521 |
*/
|
522 |
public function getWpConfigPath() {
|
523 |
return Services::WpGeneral()->getPath_WpConfig();
|
96 |
* @return string[]
|
97 |
*/
|
98 |
public function getAllFilesInDir( $sDir, $bIncludeDirs = true ) {
|
99 |
+
$aFiles = [];
|
100 |
if ( $this->canAccessDirectory( $sDir ) ) {
|
101 |
foreach ( $this->getDirIterator( $sDir ) as $oFileItem ) {
|
102 |
if ( !$oFileItem->isDot() && ( $oFileItem->isFile() || $bIncludeDirs ) ) {
|
104 |
}
|
105 |
}
|
106 |
}
|
107 |
+
return ( empty( $aFiles ) ? [] : $aFiles );
|
108 |
}
|
109 |
|
110 |
/**
|
152 |
*/
|
153 |
public function getCanWpRemoteGet() {
|
154 |
$bCan = false;
|
155 |
+
$aUrlsToTest = [
|
156 |
'https://www.microsoft.com',
|
157 |
'https://www.google.com',
|
158 |
'https://www.facebook.com'
|
159 |
+
];
|
160 |
foreach ( $aUrlsToTest as $sUrl ) {
|
161 |
if ( Services::HttpRequest()->get( $sUrl ) ) {
|
162 |
$bCan = true;
|
293 |
* @return \SplFileInfo[]
|
294 |
*/
|
295 |
public function getFilesInDir( $sDir, $nMaxDepth = 1, $oDirIterator = null ) {
|
296 |
+
$aList = [];
|
297 |
|
298 |
try {
|
299 |
if ( empty( $oDirIterator ) ) {
|
476 |
}
|
477 |
|
478 |
/**
|
|
|
479 |
* @param string $sUrl
|
480 |
* @param array $aRequestArgs
|
481 |
* @return array|bool
|
482 |
+
* @deprecated
|
483 |
*/
|
484 |
+
public function requestUrl( $sUrl, $aRequestArgs = [] ) {
|
485 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs );
|
486 |
}
|
487 |
|
488 |
/**
|
|
|
489 |
* @param string $sUrl
|
490 |
* @param array $aRequestArgs
|
491 |
* @return array|false
|
492 |
+
* @deprecated
|
493 |
*/
|
494 |
+
public function getUrl( $sUrl, $aRequestArgs = [] ) {
|
495 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs, 'GET' );
|
496 |
}
|
497 |
|
498 |
/**
|
|
|
499 |
* @param string $sUrl
|
500 |
* @param array $aRequestArgs
|
501 |
* @return false|string
|
502 |
+
* @deprecated
|
503 |
*/
|
504 |
+
public function getUrlContent( $sUrl, $aRequestArgs = [] ) {
|
505 |
return Services::HttpRequest()->getContent( $sUrl, $aRequestArgs );
|
506 |
}
|
507 |
|
508 |
/**
|
|
|
509 |
* @param string $sUrl
|
510 |
* @param array $aRequestArgs
|
511 |
* @return array|false
|
512 |
+
* @deprecated
|
513 |
*/
|
514 |
+
public function postUrl( $sUrl, $aRequestArgs = [] ) {
|
515 |
return Services::HttpRequest()->requestUrl( $sUrl, $aRequestArgs, 'POST' );
|
516 |
}
|
517 |
|
518 |
/**
|
|
|
519 |
* @return string
|
520 |
+
* @deprecated
|
521 |
*/
|
522 |
public function getWpConfigPath() {
|
523 |
return Services::WpGeneral()->getPath_WpConfig();
|
@@ -88,11 +88,11 @@ class General {
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
* @see wp_redirect_admin_locations()
|
92 |
* @return array
|
|
|
93 |
*/
|
94 |
public function getAutoRedirectLocations() {
|
95 |
-
return
|
96 |
}
|
97 |
|
98 |
/**
|
@@ -118,17 +118,17 @@ class General {
|
|
118 |
* @return string[]
|
119 |
*/
|
120 |
private function getCoreChecksums_WP() {
|
121 |
-
$aChecksumData =
|
122 |
|
123 |
include_once( ABSPATH.'/wp-admin/includes/update.php' );
|
124 |
if ( function_exists( 'get_core_checksums' ) ) { // if it's loaded, we use it.
|
125 |
$aChecksumData = get_core_checksums( $this->getVersion(), $this->getLocaleForChecksums() );
|
126 |
}
|
127 |
else {
|
128 |
-
$aQueryArgs =
|
129 |
'version' => $this->getVersion(),
|
130 |
'locale' => $this->getLocaleForChecksums()
|
131 |
-
|
132 |
$sQueryUrl = add_query_arg( $aQueryArgs, 'https://api.wordpress.org/core/checksums/1.0/' );
|
133 |
$sResponse = Services::HttpRequest()->getContent( $sQueryUrl );
|
134 |
if ( !empty( $sResponse ) ) {
|
@@ -259,7 +259,7 @@ class General {
|
|
259 |
*/
|
260 |
public function getWordpressUpdates( $sType = 'plugins' ) {
|
261 |
$oCurrent = $this->getTransient( 'update_'.$sType );
|
262 |
-
return ( isset( $oCurrent->response ) && is_array( $oCurrent->response ) ) ? $oCurrent->response :
|
263 |
}
|
264 |
|
265 |
/**
|
@@ -422,9 +422,9 @@ class General {
|
|
422 |
if ( $sPage == 'admin.php' ) {
|
423 |
$sSubPage = Services::Request()->query( 'page' );
|
424 |
if ( !empty( $sSubPage ) ) {
|
425 |
-
$aQueryArgs =
|
426 |
'page' => $sSubPage,
|
427 |
-
|
428 |
$sUrl = add_query_arg( $aQueryArgs, $sUrl );
|
429 |
}
|
430 |
}
|
@@ -455,9 +455,9 @@ class General {
|
|
455 |
}
|
456 |
|
457 |
/**
|
458 |
-
* @deprecated
|
459 |
* @param $sTermSlug
|
460 |
* @return bool
|
|
|
461 |
*/
|
462 |
public function getDoesWpPostSlugExist( $sTermSlug ) {
|
463 |
return Services::WpPost()->getDoesWpPostSlugExist( $sTermSlug );
|
@@ -736,327 +736,327 @@ class General {
|
|
736 |
}
|
737 |
|
738 |
/**
|
739 |
-
* @deprecated
|
740 |
* @param string $sPluginFile
|
741 |
* @return array
|
|
|
742 |
*/
|
743 |
public function doPluginUpgrade( $sPluginFile ) {
|
744 |
return Services::WpPlugins()->update( $sPluginFile );
|
745 |
}
|
746 |
|
747 |
/**
|
748 |
-
* @deprecated
|
749 |
* @return array
|
|
|
750 |
*/
|
751 |
public function getWordpressUpdates_Plugins() {
|
752 |
return Services::WpPlugins()->getUpdates();
|
753 |
}
|
754 |
|
755 |
/**
|
756 |
-
* @deprecated
|
757 |
* @param string $sCompareString
|
758 |
* @param string $sKey
|
759 |
* @return bool|string
|
|
|
760 |
*/
|
761 |
public function getIsPluginInstalled( $sCompareString, $sKey = 'Name' ) {
|
762 |
return Services::WpPlugins()->isInstalled( Services::WpPlugins()->findPluginBy( $sCompareString, $sKey ) );
|
763 |
}
|
764 |
|
765 |
/**
|
766 |
-
* @deprecated
|
767 |
* @param string $sPluginBaseFile
|
768 |
* @return bool
|
|
|
769 |
*/
|
770 |
public function getIsPluginInstalledByFile( $sPluginBaseFile ) {
|
771 |
return Services::WpPlugins()->isInstalled( $sPluginBaseFile );
|
772 |
}
|
773 |
|
774 |
/**
|
775 |
-
* @deprecated
|
776 |
* @return array
|
|
|
777 |
*/
|
778 |
public function getThemes() {
|
779 |
return Services::WpThemes()->getThemes();
|
780 |
}
|
781 |
|
782 |
/**
|
783 |
-
* @deprecated
|
784 |
* @param string $sPluginFile
|
785 |
* @return string
|
|
|
786 |
*/
|
787 |
public function getPluginActivateLink( $sPluginFile ) {
|
788 |
return Services::WpPlugins()->getLinkPluginActivate( $sPluginFile );
|
789 |
}
|
790 |
|
791 |
/**
|
792 |
-
* @deprecated
|
793 |
* @param string $sPluginFile
|
794 |
* @return string
|
|
|
795 |
*/
|
796 |
public function getPluginDeactivateLink( $sPluginFile ) {
|
797 |
return Services::WpPlugins()->getLinkPluginDeactivate( $sPluginFile );
|
798 |
}
|
799 |
|
800 |
/**
|
801 |
-
* @deprecated
|
802 |
* @param string $sPluginFile
|
803 |
* @return string
|
|
|
804 |
*/
|
805 |
public function getPluginUpgradeLink( $sPluginFile ) {
|
806 |
return Services::WpPlugins()->getLinkPluginUpgrade( $sPluginFile );
|
807 |
}
|
808 |
|
809 |
/**
|
810 |
-
* @deprecated
|
811 |
* @param string $sPluginFile
|
812 |
* @return int
|
|
|
813 |
*/
|
814 |
public function getActivePluginLoadPosition( $sPluginFile ) {
|
815 |
return Services::WpPlugins()->getActivePluginLoadPosition( $sPluginFile );
|
816 |
}
|
817 |
|
818 |
/**
|
819 |
-
* @deprecated
|
820 |
* @return array
|
|
|
821 |
*/
|
822 |
public function getActivePlugins() {
|
823 |
return Services::WpPlugins()->getActivePlugins();
|
824 |
}
|
825 |
|
826 |
/**
|
827 |
-
* @deprecated
|
828 |
* @return array
|
|
|
829 |
*/
|
830 |
public function getPlugins() {
|
831 |
return Services::WpPlugins()->getPlugins();
|
832 |
}
|
833 |
|
834 |
/**
|
835 |
-
* @deprecated
|
836 |
* @param string $sRootPluginFile - the full path to the root plugin file
|
837 |
* @return array
|
|
|
838 |
*/
|
839 |
public function getPluginData( $sRootPluginFile ) {
|
840 |
return Services::WpPlugins()->getExtendedData( $sRootPluginFile );
|
841 |
}
|
842 |
|
843 |
/**
|
844 |
-
* @deprecated
|
845 |
* @param string $sPluginFile
|
846 |
* @return \stdClass|null
|
|
|
847 |
*/
|
848 |
public function getPluginUpdateInfo( $sPluginFile ) {
|
849 |
return Services::WpPlugins()->getUpdateInfo( $sPluginFile );
|
850 |
}
|
851 |
|
852 |
/**
|
853 |
-
* @deprecated
|
854 |
* @param string $sPluginFile
|
855 |
* @return string
|
|
|
856 |
*/
|
857 |
public function getPluginUpdateNewVersion( $sPluginFile ) {
|
858 |
return Services::WpPlugins()->getUpdateNewVersion( $sPluginFile );
|
859 |
}
|
860 |
|
861 |
/**
|
862 |
-
* @deprecated
|
863 |
* @param string $sPluginFile
|
864 |
* @return boolean|\stdClass
|
|
|
865 |
*/
|
866 |
public function getIsPluginUpdateAvailable( $sPluginFile ) {
|
867 |
return Services::WpPlugins()->isUpdateAvailable( $sPluginFile );
|
868 |
}
|
869 |
|
870 |
/**
|
871 |
-
* @deprecated
|
872 |
* @param string $sCompareString
|
873 |
* @param string $sKey
|
874 |
* @return bool
|
|
|
875 |
*/
|
876 |
public function getIsPluginActive( $sCompareString, $sKey = 'Name' ) {
|
877 |
return Services::WpPlugins()->isActive( Services::WpPlugins()->findPluginBy( $sCompareString, $sKey ) );
|
878 |
}
|
879 |
|
880 |
/**
|
881 |
-
* @deprecated
|
882 |
* @param string $sPluginFile
|
883 |
* @param int $nDesiredPosition
|
|
|
884 |
*/
|
885 |
public function setActivePluginLoadPosition( $sPluginFile, $nDesiredPosition = 0 ) {
|
886 |
Services::WpPlugins()->setActivePluginLoadPosition( $sPluginFile, $nDesiredPosition );
|
887 |
}
|
888 |
|
889 |
/**
|
890 |
-
* @deprecated
|
891 |
* @param string $sPluginBaseFilename
|
892 |
* @return null|\stdClass
|
|
|
893 |
*/
|
894 |
public function getPluginDataAsObject( $sPluginBaseFilename ) {
|
895 |
return Services::WpPlugins()->getPluginDataAsObject( $sPluginBaseFilename );
|
896 |
}
|
897 |
|
898 |
/**
|
899 |
-
* @deprecated
|
900 |
* @param string $sPluginFile
|
|
|
901 |
*/
|
902 |
public function setActivePluginLoadFirst( $sPluginFile ) {
|
903 |
Services::WpPlugins()->setActivePluginLoadFirst( $sPluginFile );
|
904 |
}
|
905 |
|
906 |
/**
|
907 |
-
* @deprecated
|
908 |
* @param string $sPluginFile
|
|
|
909 |
*/
|
910 |
public function setActivePluginLoadLast( $sPluginFile ) {
|
911 |
Services::WpPlugins()->setActivePluginLoadPosition( $sPluginFile, 1000 );
|
912 |
}
|
913 |
|
914 |
/**
|
915 |
-
* @deprecated
|
916 |
* @return array
|
|
|
917 |
*/
|
918 |
public function getWordpressUpdates_Themes() {
|
919 |
return Services::WpThemes()->getUpdates();
|
920 |
}
|
921 |
|
922 |
/**
|
923 |
-
* @deprecated
|
924 |
* @return string
|
|
|
925 |
*/
|
926 |
public function getWordpressVersion() {
|
927 |
return $this->getVersion();
|
928 |
}
|
929 |
|
930 |
/**
|
931 |
-
* @deprecated getAdminUrl()
|
932 |
* @return string
|
|
|
933 |
*/
|
934 |
public function getUrl_WpAdmin() {
|
935 |
return get_admin_url();
|
936 |
}
|
937 |
|
938 |
/**
|
939 |
-
* @deprecated
|
940 |
* @return bool
|
|
|
941 |
*/
|
942 |
public function getIsLoginRequest() {
|
943 |
return $this->isLoginRequest();
|
944 |
}
|
945 |
|
946 |
/**
|
947 |
-
* @deprecated
|
948 |
* @return bool
|
|
|
949 |
*/
|
950 |
public function getIsRegisterRequest() {
|
951 |
return $this->isRegisterRequest();
|
952 |
}
|
953 |
|
954 |
/**
|
955 |
-
* @deprecated
|
956 |
* @return bool
|
|
|
957 |
*/
|
958 |
public function getIsLoginUrl() {
|
959 |
return $this->isLoginUrl();
|
960 |
}
|
961 |
|
962 |
/**
|
963 |
-
* @deprecated
|
964 |
* @return bool
|
|
|
965 |
*/
|
966 |
public function getIsPermalinksEnabled() {
|
967 |
return $this->isPermalinksEnabled();
|
968 |
}
|
969 |
|
970 |
/**
|
971 |
-
* @deprecated
|
972 |
* @return string
|
|
|
973 |
*/
|
974 |
public function getCurrentPage() {
|
975 |
return Services::WpPost()->getCurrentPage();
|
976 |
}
|
977 |
|
978 |
/**
|
979 |
-
* @deprecated
|
980 |
* @return \WP_Post
|
|
|
981 |
*/
|
982 |
public function getCurrentPost() {
|
983 |
return Services::WpPost()->getCurrentPost();
|
984 |
}
|
985 |
|
986 |
/**
|
987 |
-
* @deprecated
|
988 |
* @return int
|
|
|
989 |
*/
|
990 |
public function getCurrentPostId() {
|
991 |
return Services::WpPost()->getCurrentPostId();
|
992 |
}
|
993 |
|
994 |
/**
|
995 |
-
* @deprecated
|
996 |
* @param $nPostId
|
997 |
* @return false|\WP_Post
|
|
|
998 |
*/
|
999 |
public function getPostById( $nPostId ) {
|
1000 |
return Services::WpPost()->getById( $nPostId );
|
1001 |
}
|
1002 |
|
1003 |
/**
|
1004 |
-
* @deprecated
|
1005 |
* @return boolean
|
|
|
1006 |
*/
|
1007 |
public function getIsAjax() {
|
1008 |
return $this->isAjax();
|
1009 |
}
|
1010 |
|
1011 |
/**
|
1012 |
-
* @deprecated
|
1013 |
* @return boolean
|
|
|
1014 |
*/
|
1015 |
public function getIsCron() {
|
1016 |
return $this->isCron();
|
1017 |
}
|
1018 |
|
1019 |
/**
|
1020 |
-
* @deprecated
|
1021 |
* @return bool
|
|
|
1022 |
*/
|
1023 |
public function getIsXmlrpc() {
|
1024 |
return $this->isXmlrpc();
|
1025 |
}
|
1026 |
|
1027 |
/**
|
1028 |
-
* @deprecated
|
1029 |
* @return bool
|
|
|
1030 |
*/
|
1031 |
public function getIsMobile() {
|
1032 |
return $this->isMobile();
|
1033 |
}
|
1034 |
|
1035 |
/**
|
1036 |
-
* @deprecated
|
1037 |
* @return array
|
|
|
1038 |
*/
|
1039 |
public function getAllUserLoginUsernames() {
|
1040 |
return Services::WpUsers()->getAllUserLoginUsernames();
|
1041 |
}
|
1042 |
|
1043 |
/**
|
1044 |
-
* @deprecated
|
1045 |
* @param string
|
1046 |
* @return string
|
|
|
1047 |
*/
|
1048 |
public function getIsCurrentPage( $sPage ) {
|
1049 |
return Services::WpPost()->isCurrentPage( $sPage );
|
1050 |
}
|
1051 |
|
1052 |
/**
|
1053 |
-
* @deprecated
|
1054 |
* @param string $sUrl
|
1055 |
* @param array $aQueryParams
|
1056 |
* @param bool $bSafe
|
1057 |
* @param bool $bProtectAgainstInfiniteLoops - if false, ignores the redirect loop protection
|
|
|
1058 |
*/
|
1059 |
-
public function doRedirect( $sUrl, $aQueryParams =
|
1060 |
Services::Response()->redirect( $sUrl, $aQueryParams, $bSafe, $bProtectAgainstInfiniteLoops );
|
1061 |
}
|
1062 |
|
@@ -1068,26 +1068,26 @@ class General {
|
|
1068 |
}
|
1069 |
|
1070 |
/**
|
1071 |
-
* @deprecated
|
1072 |
* @param array $aQueryParams
|
|
|
1073 |
*/
|
1074 |
-
public function redirectToLogin( $aQueryParams =
|
1075 |
Services::Response()->redirectToLogin( $aQueryParams );
|
1076 |
}
|
1077 |
|
1078 |
/**
|
1079 |
-
* @deprecated
|
1080 |
* @param array $aQueryParams
|
|
|
1081 |
*/
|
1082 |
-
public function redirectToAdmin( $aQueryParams =
|
1083 |
Services::Response()->redirectToAdmin( $aQueryParams );
|
1084 |
}
|
1085 |
|
1086 |
/**
|
1087 |
-
* @deprecated
|
1088 |
* @param array $aQueryParams
|
|
|
1089 |
*/
|
1090 |
-
public function redirectToHome( $aQueryParams =
|
1091 |
Services::Response()->redirectToHome( $aQueryParams );
|
1092 |
}
|
1093 |
}
|
88 |
}
|
89 |
|
90 |
/**
|
|
|
91 |
* @return array
|
92 |
+
* @see wp_redirect_admin_locations()
|
93 |
*/
|
94 |
public function getAutoRedirectLocations() {
|
95 |
+
return [ 'wp-admin', 'dashboard', 'admin', 'login', 'wp-login.php' ];
|
96 |
}
|
97 |
|
98 |
/**
|
118 |
* @return string[]
|
119 |
*/
|
120 |
private function getCoreChecksums_WP() {
|
121 |
+
$aChecksumData = [];
|
122 |
|
123 |
include_once( ABSPATH.'/wp-admin/includes/update.php' );
|
124 |
if ( function_exists( 'get_core_checksums' ) ) { // if it's loaded, we use it.
|
125 |
$aChecksumData = get_core_checksums( $this->getVersion(), $this->getLocaleForChecksums() );
|
126 |
}
|
127 |
else {
|
128 |
+
$aQueryArgs = [
|
129 |
'version' => $this->getVersion(),
|
130 |
'locale' => $this->getLocaleForChecksums()
|
131 |
+
];
|
132 |
$sQueryUrl = add_query_arg( $aQueryArgs, 'https://api.wordpress.org/core/checksums/1.0/' );
|
133 |
$sResponse = Services::HttpRequest()->getContent( $sQueryUrl );
|
134 |
if ( !empty( $sResponse ) ) {
|
259 |
*/
|
260 |
public function getWordpressUpdates( $sType = 'plugins' ) {
|
261 |
$oCurrent = $this->getTransient( 'update_'.$sType );
|
262 |
+
return ( isset( $oCurrent->response ) && is_array( $oCurrent->response ) ) ? $oCurrent->response : [];
|
263 |
}
|
264 |
|
265 |
/**
|
422 |
if ( $sPage == 'admin.php' ) {
|
423 |
$sSubPage = Services::Request()->query( 'page' );
|
424 |
if ( !empty( $sSubPage ) ) {
|
425 |
+
$aQueryArgs = [
|
426 |
'page' => $sSubPage,
|
427 |
+
];
|
428 |
$sUrl = add_query_arg( $aQueryArgs, $sUrl );
|
429 |
}
|
430 |
}
|
455 |
}
|
456 |
|
457 |
/**
|
|
|
458 |
* @param $sTermSlug
|
459 |
* @return bool
|
460 |
+
* @deprecated
|
461 |
*/
|
462 |
public function getDoesWpPostSlugExist( $sTermSlug ) {
|
463 |
return Services::WpPost()->getDoesWpPostSlugExist( $sTermSlug );
|
736 |
}
|
737 |
|
738 |
/**
|
|
|
739 |
* @param string $sPluginFile
|
740 |
* @return array
|
741 |
+
* @deprecated
|
742 |
*/
|
743 |
public function doPluginUpgrade( $sPluginFile ) {
|
744 |
return Services::WpPlugins()->update( $sPluginFile );
|
745 |
}
|
746 |
|
747 |
/**
|
|
|
748 |
* @return array
|
749 |
+
* @deprecated
|
750 |
*/
|
751 |
public function getWordpressUpdates_Plugins() {
|
752 |
return Services::WpPlugins()->getUpdates();
|
753 |
}
|
754 |
|
755 |
/**
|
|
|
756 |
* @param string $sCompareString
|
757 |
* @param string $sKey
|
758 |
* @return bool|string
|
759 |
+
* @deprecated
|
760 |
*/
|
761 |
public function getIsPluginInstalled( $sCompareString, $sKey = 'Name' ) {
|
762 |
return Services::WpPlugins()->isInstalled( Services::WpPlugins()->findPluginBy( $sCompareString, $sKey ) );
|
763 |
}
|
764 |
|
765 |
/**
|
|
|
766 |
* @param string $sPluginBaseFile
|
767 |
* @return bool
|
768 |
+
* @deprecated
|
769 |
*/
|
770 |
public function getIsPluginInstalledByFile( $sPluginBaseFile ) {
|
771 |
return Services::WpPlugins()->isInstalled( $sPluginBaseFile );
|
772 |
}
|
773 |
|
774 |
/**
|
|
|
775 |
* @return array
|
776 |
+
* @deprecated
|
777 |
*/
|
778 |
public function getThemes() {
|
779 |
return Services::WpThemes()->getThemes();
|
780 |
}
|
781 |
|
782 |
/**
|
|
|
783 |
* @param string $sPluginFile
|
784 |
* @return string
|
785 |
+
* @deprecated
|
786 |
*/
|
787 |
public function getPluginActivateLink( $sPluginFile ) {
|
788 |
return Services::WpPlugins()->getLinkPluginActivate( $sPluginFile );
|
789 |
}
|
790 |
|
791 |
/**
|
|
|
792 |
* @param string $sPluginFile
|
793 |
* @return string
|
794 |
+
* @deprecated
|
795 |
*/
|
796 |
public function getPluginDeactivateLink( $sPluginFile ) {
|
797 |
return Services::WpPlugins()->getLinkPluginDeactivate( $sPluginFile );
|
798 |
}
|
799 |
|
800 |
/**
|
|
|
801 |
* @param string $sPluginFile
|
802 |
* @return string
|
803 |
+
* @deprecated
|
804 |
*/
|
805 |
public function getPluginUpgradeLink( $sPluginFile ) {
|
806 |
return Services::WpPlugins()->getLinkPluginUpgrade( $sPluginFile );
|
807 |
}
|
808 |
|
809 |
/**
|
|
|
810 |
* @param string $sPluginFile
|
811 |
* @return int
|
812 |
+
* @deprecated
|
813 |
*/
|
814 |
public function getActivePluginLoadPosition( $sPluginFile ) {
|
815 |
return Services::WpPlugins()->getActivePluginLoadPosition( $sPluginFile );
|
816 |
}
|
817 |
|
818 |
/**
|
|
|
819 |
* @return array
|
820 |
+
* @deprecated
|
821 |
*/
|
822 |
public function getActivePlugins() {
|
823 |
return Services::WpPlugins()->getActivePlugins();
|
824 |
}
|
825 |
|
826 |
/**
|
|
|
827 |
* @return array
|
828 |
+
* @deprecated
|
829 |
*/
|
830 |
public function getPlugins() {
|
831 |
return Services::WpPlugins()->getPlugins();
|
832 |
}
|
833 |
|
834 |
/**
|
|
|
835 |
* @param string $sRootPluginFile - the full path to the root plugin file
|
836 |
* @return array
|
837 |
+
* @deprecated
|
838 |
*/
|
839 |
public function getPluginData( $sRootPluginFile ) {
|
840 |
return Services::WpPlugins()->getExtendedData( $sRootPluginFile );
|
841 |
}
|
842 |
|
843 |
/**
|
|
|
844 |
* @param string $sPluginFile
|
845 |
* @return \stdClass|null
|
846 |
+
* @deprecated
|
847 |
*/
|
848 |
public function getPluginUpdateInfo( $sPluginFile ) {
|
849 |
return Services::WpPlugins()->getUpdateInfo( $sPluginFile );
|
850 |
}
|
851 |
|
852 |
/**
|
|
|
853 |
* @param string $sPluginFile
|
854 |
* @return string
|
855 |
+
* @deprecated
|
856 |
*/
|
857 |
public function getPluginUpdateNewVersion( $sPluginFile ) {
|
858 |
return Services::WpPlugins()->getUpdateNewVersion( $sPluginFile );
|
859 |
}
|
860 |
|
861 |
/**
|
|
|
862 |
* @param string $sPluginFile
|
863 |
* @return boolean|\stdClass
|
864 |
+
* @deprecated
|
865 |
*/
|
866 |
public function getIsPluginUpdateAvailable( $sPluginFile ) {
|
867 |
return Services::WpPlugins()->isUpdateAvailable( $sPluginFile );
|
868 |
}
|
869 |
|
870 |
/**
|
|
|
871 |
* @param string $sCompareString
|
872 |
* @param string $sKey
|
873 |
* @return bool
|
874 |
+
* @deprecated
|
875 |
*/
|
876 |
public function getIsPluginActive( $sCompareString, $sKey = 'Name' ) {
|
877 |
return Services::WpPlugins()->isActive( Services::WpPlugins()->findPluginBy( $sCompareString, $sKey ) );
|
878 |
}
|
879 |
|
880 |
/**
|
|
|
881 |
* @param string $sPluginFile
|
882 |
* @param int $nDesiredPosition
|
883 |
+
* @deprecated
|
884 |
*/
|
885 |
public function setActivePluginLoadPosition( $sPluginFile, $nDesiredPosition = 0 ) {
|
886 |
Services::WpPlugins()->setActivePluginLoadPosition( $sPluginFile, $nDesiredPosition );
|
887 |
}
|
888 |
|
889 |
/**
|
|
|
890 |
* @param string $sPluginBaseFilename
|
891 |
* @return null|\stdClass
|
892 |
+
* @deprecated
|
893 |
*/
|
894 |
public function getPluginDataAsObject( $sPluginBaseFilename ) {
|
895 |
return Services::WpPlugins()->getPluginDataAsObject( $sPluginBaseFilename );
|
896 |
}
|
897 |
|
898 |
/**
|
|
|
899 |
* @param string $sPluginFile
|
900 |
+
* @deprecated
|
901 |
*/
|
902 |
public function setActivePluginLoadFirst( $sPluginFile ) {
|
903 |
Services::WpPlugins()->setActivePluginLoadFirst( $sPluginFile );
|
904 |
}
|
905 |
|
906 |
/**
|
|
|
907 |
* @param string $sPluginFile
|
908 |
+
* @deprecated
|
909 |
*/
|
910 |
public function setActivePluginLoadLast( $sPluginFile ) {
|
911 |
Services::WpPlugins()->setActivePluginLoadPosition( $sPluginFile, 1000 );
|
912 |
}
|
913 |
|
914 |
/**
|
|
|
915 |
* @return array
|
916 |
+
* @deprecated
|
917 |
*/
|
918 |
public function getWordpressUpdates_Themes() {
|
919 |
return Services::WpThemes()->getUpdates();
|
920 |
}
|
921 |
|
922 |
/**
|
|
|
923 |
* @return string
|
924 |
+
* @deprecated
|
925 |
*/
|
926 |
public function getWordpressVersion() {
|
927 |
return $this->getVersion();
|
928 |
}
|
929 |
|
930 |
/**
|
|
|
931 |
* @return string
|
932 |
+
* @deprecated getAdminUrl()
|
933 |
*/
|
934 |
public function getUrl_WpAdmin() {
|
935 |
return get_admin_url();
|
936 |
}
|
937 |
|
938 |
/**
|
|
|
939 |
* @return bool
|
940 |
+
* @deprecated
|
941 |
*/
|
942 |
public function getIsLoginRequest() {
|
943 |
return $this->isLoginRequest();
|
944 |
}
|
945 |
|
946 |
/**
|
|
|
947 |
* @return bool
|
948 |
+
* @deprecated
|
949 |
*/
|
950 |
public function getIsRegisterRequest() {
|
951 |
return $this->isRegisterRequest();
|
952 |
}
|
953 |
|
954 |
/**
|
|
|
955 |
* @return bool
|
956 |
+
* @deprecated
|
957 |
*/
|
958 |
public function getIsLoginUrl() {
|
959 |
return $this->isLoginUrl();
|
960 |
}
|
961 |
|
962 |
/**
|
|
|
963 |
* @return bool
|
964 |
+
* @deprecated
|
965 |
*/
|
966 |
public function getIsPermalinksEnabled() {
|
967 |
return $this->isPermalinksEnabled();
|
968 |
}
|
969 |
|
970 |
/**
|
|
|
971 |
* @return string
|
972 |
+
* @deprecated
|
973 |
*/
|
974 |
public function getCurrentPage() {
|
975 |
return Services::WpPost()->getCurrentPage();
|
976 |
}
|
977 |
|
978 |
/**
|
|
|
979 |
* @return \WP_Post
|
980 |
+
* @deprecated
|
981 |
*/
|
982 |
public function getCurrentPost() {
|
983 |
return Services::WpPost()->getCurrentPost();
|
984 |
}
|
985 |
|
986 |
/**
|
|
|
987 |
* @return int
|
988 |
+
* @deprecated
|
989 |
*/
|
990 |
public function getCurrentPostId() {
|
991 |
return Services::WpPost()->getCurrentPostId();
|
992 |
}
|
993 |
|
994 |
/**
|
|
|
995 |
* @param $nPostId
|
996 |
* @return false|\WP_Post
|
997 |
+
* @deprecated
|
998 |
*/
|
999 |
public function getPostById( $nPostId ) {
|
1000 |
return Services::WpPost()->getById( $nPostId );
|
1001 |
}
|
1002 |
|
1003 |
/**
|
|
|
1004 |
* @return boolean
|
1005 |
+
* @deprecated
|
1006 |
*/
|
1007 |
public function getIsAjax() {
|
1008 |
return $this->isAjax();
|
1009 |
}
|
1010 |
|
1011 |
/**
|
|
|
1012 |
* @return boolean
|
1013 |
+
* @deprecated
|
1014 |
*/
|
1015 |
public function getIsCron() {
|
1016 |
return $this->isCron();
|
1017 |
}
|
1018 |
|
1019 |
/**
|
|
|
1020 |
* @return bool
|
1021 |
+
* @deprecated
|
1022 |
*/
|
1023 |
public function getIsXmlrpc() {
|
1024 |
return $this->isXmlrpc();
|
1025 |
}
|
1026 |
|
1027 |
/**
|
|
|
1028 |
* @return bool
|
1029 |
+
* @deprecated
|
1030 |
*/
|
1031 |
public function getIsMobile() {
|
1032 |
return $this->isMobile();
|
1033 |
}
|
1034 |
|
1035 |
/**
|
|
|
1036 |
* @return array
|
1037 |
+
* @deprecated
|
1038 |
*/
|
1039 |
public function getAllUserLoginUsernames() {
|
1040 |
return Services::WpUsers()->getAllUserLoginUsernames();
|
1041 |
}
|
1042 |
|
1043 |
/**
|
|
|
1044 |
* @param string
|
1045 |
* @return string
|
1046 |
+
* @deprecated
|
1047 |
*/
|
1048 |
public function getIsCurrentPage( $sPage ) {
|
1049 |
return Services::WpPost()->isCurrentPage( $sPage );
|
1050 |
}
|
1051 |
|
1052 |
/**
|
|
|
1053 |
* @param string $sUrl
|
1054 |
* @param array $aQueryParams
|
1055 |
* @param bool $bSafe
|
1056 |
* @param bool $bProtectAgainstInfiniteLoops - if false, ignores the redirect loop protection
|
1057 |
+
* @deprecated
|
1058 |
*/
|
1059 |
+
public function doRedirect( $sUrl, $aQueryParams = [], $bSafe = true, $bProtectAgainstInfiniteLoops = true ) {
|
1060 |
Services::Response()->redirect( $sUrl, $aQueryParams, $bSafe, $bProtectAgainstInfiniteLoops );
|
1061 |
}
|
1062 |
|
1068 |
}
|
1069 |
|
1070 |
/**
|
|
|
1071 |
* @param array $aQueryParams
|
1072 |
+
* @deprecated
|
1073 |
*/
|
1074 |
+
public function redirectToLogin( $aQueryParams = [] ) {
|
1075 |
Services::Response()->redirectToLogin( $aQueryParams );
|
1076 |
}
|
1077 |
|
1078 |
/**
|
|
|
1079 |
* @param array $aQueryParams
|
1080 |
+
* @deprecated
|
1081 |
*/
|
1082 |
+
public function redirectToAdmin( $aQueryParams = [] ) {
|
1083 |
Services::Response()->redirectToAdmin( $aQueryParams );
|
1084 |
}
|
1085 |
|
1086 |
/**
|
|
|
1087 |
* @param array $aQueryParams
|
1088 |
+
* @deprecated
|
1089 |
*/
|
1090 |
+
public function redirectToHome( $aQueryParams = [] ) {
|
1091 |
Services::Response()->redirectToHome( $aQueryParams );
|
1092 |
}
|
1093 |
}
|
@@ -41,6 +41,6 @@ class Includes {
|
|
41 |
*/
|
42 |
public function addIncludeModifiedParam( $sUrl, $sInclude ) {
|
43 |
$nTime = Services::WpFs()->getModifiedTime( path_join( ABSPATH, $sInclude ) );
|
44 |
-
return add_query_arg(
|
45 |
}
|
46 |
}
|
41 |
*/
|
42 |
public function addIncludeModifiedParam( $sUrl, $sInclude ) {
|
43 |
$nTime = Services::WpFs()->getModifiedTime( path_join( ABSPATH, $sInclude ) );
|
44 |
+
return add_query_arg( [ 'mtime' => $nTime ], $sUrl );
|
45 |
}
|
46 |
}
|
@@ -78,11 +78,11 @@ class Plugins {
|
|
78 |
*/
|
79 |
public function install( $sUrlToInstall, $bOverwrite = true, $bMaintenanceMode = false ) {
|
80 |
|
81 |
-
$aResult =
|
82 |
'successful' => true,
|
83 |
'plugin_info' => '',
|
84 |
-
'errors' =>
|
85 |
-
|
86 |
|
87 |
$oUpgraderSkin = new Upgrades\UpgraderSkin();
|
88 |
$oUpgrader = new Upgrades\PluginUpgrader( $oUpgraderSkin );
|
@@ -122,12 +122,12 @@ class Plugins {
|
|
122 |
public function installFromWpOrg( $sSlug ) {
|
123 |
include_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
|
124 |
|
125 |
-
$api = plugins_api( 'plugin_information',
|
126 |
'slug' => $sSlug,
|
127 |
-
'fields' =>
|
128 |
'sections' => false,
|
129 |
-
|
130 |
-
|
131 |
|
132 |
if ( !is_wp_error( $api ) ) {
|
133 |
return $this->install( $api->download_link, true, true );
|
@@ -180,14 +180,14 @@ class Plugins {
|
|
180 |
*/
|
181 |
public function update( $sFile ) {
|
182 |
|
183 |
-
$aResult =
|
184 |
'successful' => 1,
|
185 |
-
'errors' =>
|
186 |
-
|
187 |
|
188 |
$oUpgraderSkin = new Upgrades\BulkPluginUpgraderSkin();
|
189 |
ob_start();
|
190 |
-
( new Upgrades\PluginUpgrader( $oUpgraderSkin ) )->bulk_upgrade(
|
191 |
if ( ob_get_contents() ) {
|
192 |
// for some reason this errors with no buffer present
|
193 |
ob_end_clean();
|
@@ -274,11 +274,11 @@ class Plugins {
|
|
274 |
*/
|
275 |
public function getLinkPluginActivate( $sPluginFile ) {
|
276 |
$sUrl = self_admin_url( 'plugins.php' );
|
277 |
-
$aQueryArgs =
|
278 |
'action' => 'activate',
|
279 |
'plugin' => urlencode( $sPluginFile ),
|
280 |
'_wpnonce' => wp_create_nonce( 'activate-plugin_'.$sPluginFile )
|
281 |
-
|
282 |
return add_query_arg( $aQueryArgs, $sUrl );
|
283 |
}
|
284 |
|
@@ -288,11 +288,11 @@ class Plugins {
|
|
288 |
*/
|
289 |
public function getLinkPluginDeactivate( $sPluginFile ) {
|
290 |
$sUrl = self_admin_url( 'plugins.php' );
|
291 |
-
$aQueryArgs =
|
292 |
'action' => 'deactivate',
|
293 |
'plugin' => urlencode( $sPluginFile ),
|
294 |
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_'.$sPluginFile )
|
295 |
-
|
296 |
return add_query_arg( $aQueryArgs, $sUrl );
|
297 |
}
|
298 |
|
@@ -302,11 +302,11 @@ class Plugins {
|
|
302 |
*/
|
303 |
public function getLinkPluginUpgrade( $sPluginFile ) {
|
304 |
$sUrl = self_admin_url( 'update.php' );
|
305 |
-
$aQueryArgs =
|
306 |
'action' => 'upgrade-plugin',
|
307 |
'plugin' => urlencode( $sPluginFile ),
|
308 |
'_wpnonce' => wp_create_nonce( 'upgrade-plugin_'.$sPluginFile )
|
309 |
-
|
310 |
return add_query_arg( $aQueryArgs, $sUrl );
|
311 |
}
|
312 |
|
@@ -392,7 +392,7 @@ class Plugins {
|
|
392 |
if ( !function_exists( 'get_plugins' ) ) {
|
393 |
require_once( ABSPATH.'wp-admin/includes/plugin.php' );
|
394 |
}
|
395 |
-
return function_exists( 'get_plugins' ) ? get_plugins() :
|
396 |
}
|
397 |
|
398 |
/**
|
@@ -415,8 +415,8 @@ class Plugins {
|
|
415 |
public function getAllExtendedData() {
|
416 |
$oData = Services::WpGeneral()->getTransient( 'update_plugins' );
|
417 |
return array_merge(
|
418 |
-
isset( $oData->no_update ) ? $oData->no_update :
|
419 |
-
isset( $oData->response ) ? $oData->response :
|
420 |
);
|
421 |
}
|
422 |
|
@@ -426,14 +426,14 @@ class Plugins {
|
|
426 |
*/
|
427 |
public function getExtendedData( $sBaseFile ) {
|
428 |
$aData = $this->getAllExtendedData();
|
429 |
-
return isset( $aData[ $sBaseFile ] ) ? $aData[ $sBaseFile ] :
|
430 |
}
|
431 |
|
432 |
/**
|
433 |
* @return array
|
434 |
*/
|
435 |
public function getAllSlugs() {
|
436 |
-
$aSlugs =
|
437 |
|
438 |
foreach ( $this->getAllExtendedData() as $sBaseName => $oPlugData ) {
|
439 |
if ( isset( $oPlugData->slug ) ) {
|
@@ -490,7 +490,7 @@ class Plugins {
|
|
490 |
$this->checkForUpdates();
|
491 |
}
|
492 |
$aUpdates = Services::WpGeneral()->getWordpressUpdates( 'plugins' );
|
493 |
-
return is_array( $aUpdates ) ? $aUpdates :
|
494 |
}
|
495 |
|
496 |
/**
|
@@ -514,11 +514,11 @@ class Plugins {
|
|
514 |
* @return string
|
515 |
*/
|
516 |
public function getUrl_Upgrade( $sPluginFile ) {
|
517 |
-
$aQueryArgs =
|
518 |
'action' => 'upgrade-plugin',
|
519 |
'plugin' => urlencode( $sPluginFile ),
|
520 |
'_wpnonce' => wp_create_nonce( 'upgrade-plugin_'.$sPluginFile )
|
521 |
-
|
522 |
return add_query_arg( $aQueryArgs, self_admin_url( 'update.php' ) );
|
523 |
}
|
524 |
|
@@ -529,11 +529,11 @@ class Plugins {
|
|
529 |
*/
|
530 |
protected function getUrl_Action( $sPluginFile, $sAction ) {
|
531 |
return add_query_arg(
|
532 |
-
|
533 |
'action' => $sAction,
|
534 |
'plugin' => urlencode( $sPluginFile ),
|
535 |
'_wpnonce' => wp_create_nonce( $sAction.'-plugin_'.$sPluginFile )
|
536 |
-
|
537 |
self_admin_url( 'plugins.php' )
|
538 |
);
|
539 |
}
|
78 |
*/
|
79 |
public function install( $sUrlToInstall, $bOverwrite = true, $bMaintenanceMode = false ) {
|
80 |
|
81 |
+
$aResult = [
|
82 |
'successful' => true,
|
83 |
'plugin_info' => '',
|
84 |
+
'errors' => []
|
85 |
+
];
|
86 |
|
87 |
$oUpgraderSkin = new Upgrades\UpgraderSkin();
|
88 |
$oUpgrader = new Upgrades\PluginUpgrader( $oUpgraderSkin );
|
122 |
public function installFromWpOrg( $sSlug ) {
|
123 |
include_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
|
124 |
|
125 |
+
$api = plugins_api( 'plugin_information', [
|
126 |
'slug' => $sSlug,
|
127 |
+
'fields' => [
|
128 |
'sections' => false,
|
129 |
+
],
|
130 |
+
] );
|
131 |
|
132 |
if ( !is_wp_error( $api ) ) {
|
133 |
return $this->install( $api->download_link, true, true );
|
180 |
*/
|
181 |
public function update( $sFile ) {
|
182 |
|
183 |
+
$aResult = [
|
184 |
'successful' => 1,
|
185 |
+
'errors' => []
|
186 |
+
];
|
187 |
|
188 |
$oUpgraderSkin = new Upgrades\BulkPluginUpgraderSkin();
|
189 |
ob_start();
|
190 |
+
( new Upgrades\PluginUpgrader( $oUpgraderSkin ) )->bulk_upgrade( [ $sFile ] );
|
191 |
if ( ob_get_contents() ) {
|
192 |
// for some reason this errors with no buffer present
|
193 |
ob_end_clean();
|
274 |
*/
|
275 |
public function getLinkPluginActivate( $sPluginFile ) {
|
276 |
$sUrl = self_admin_url( 'plugins.php' );
|
277 |
+
$aQueryArgs = [
|
278 |
'action' => 'activate',
|
279 |
'plugin' => urlencode( $sPluginFile ),
|
280 |
'_wpnonce' => wp_create_nonce( 'activate-plugin_'.$sPluginFile )
|
281 |
+
];
|
282 |
return add_query_arg( $aQueryArgs, $sUrl );
|
283 |
}
|
284 |
|
288 |
*/
|
289 |
public function getLinkPluginDeactivate( $sPluginFile ) {
|
290 |
$sUrl = self_admin_url( 'plugins.php' );
|
291 |
+
$aQueryArgs = [
|
292 |
'action' => 'deactivate',
|
293 |
'plugin' => urlencode( $sPluginFile ),
|
294 |
'_wpnonce' => wp_create_nonce( 'deactivate-plugin_'.$sPluginFile )
|
295 |
+
];
|
296 |
return add_query_arg( $aQueryArgs, $sUrl );
|
297 |
}
|
298 |
|
302 |
*/
|
303 |
public function getLinkPluginUpgrade( $sPluginFile ) {
|
304 |
$sUrl = self_admin_url( 'update.php' );
|
305 |
+
$aQueryArgs = [
|
306 |
'action' => 'upgrade-plugin',
|
307 |
'plugin' => urlencode( $sPluginFile ),
|
308 |
'_wpnonce' => wp_create_nonce( 'upgrade-plugin_'.$sPluginFile )
|
309 |
+
];
|
310 |
return add_query_arg( $aQueryArgs, $sUrl );
|
311 |
}
|
312 |
|
392 |
if ( !function_exists( 'get_plugins' ) ) {
|
393 |
require_once( ABSPATH.'wp-admin/includes/plugin.php' );
|
394 |
}
|
395 |
+
return function_exists( 'get_plugins' ) ? get_plugins() : [];
|
396 |
}
|
397 |
|
398 |
/**
|
415 |
public function getAllExtendedData() {
|
416 |
$oData = Services::WpGeneral()->getTransient( 'update_plugins' );
|
417 |
return array_merge(
|
418 |
+
isset( $oData->no_update ) ? $oData->no_update : [],
|
419 |
+
isset( $oData->response ) ? $oData->response : []
|
420 |
);
|
421 |
}
|
422 |
|
426 |
*/
|
427 |
public function getExtendedData( $sBaseFile ) {
|
428 |
$aData = $this->getAllExtendedData();
|
429 |
+
return isset( $aData[ $sBaseFile ] ) ? $aData[ $sBaseFile ] : [];
|
430 |
}
|
431 |
|
432 |
/**
|
433 |
* @return array
|
434 |
*/
|
435 |
public function getAllSlugs() {
|
436 |
+
$aSlugs = [];
|
437 |
|
438 |
foreach ( $this->getAllExtendedData() as $sBaseName => $oPlugData ) {
|
439 |
if ( isset( $oPlugData->slug ) ) {
|
490 |
$this->checkForUpdates();
|
491 |
}
|
492 |
$aUpdates = Services::WpGeneral()->getWordpressUpdates( 'plugins' );
|
493 |
+
return is_array( $aUpdates ) ? $aUpdates : [];
|
494 |
}
|
495 |
|
496 |
/**
|
514 |
* @return string
|
515 |
*/
|
516 |
public function getUrl_Upgrade( $sPluginFile ) {
|
517 |
+
$aQueryArgs = [
|
518 |
'action' => 'upgrade-plugin',
|
519 |
'plugin' => urlencode( $sPluginFile ),
|
520 |
'_wpnonce' => wp_create_nonce( 'upgrade-plugin_'.$sPluginFile )
|
521 |
+
];
|
522 |
return add_query_arg( $aQueryArgs, self_admin_url( 'update.php' ) );
|
523 |
}
|
524 |
|
529 |
*/
|
530 |
protected function getUrl_Action( $sPluginFile, $sAction ) {
|
531 |
return add_query_arg(
|
532 |
+
[
|
533 |
'action' => $sAction,
|
534 |
'plugin' => urlencode( $sPluginFile ),
|
535 |
'_wpnonce' => wp_create_nonce( $sAction.'-plugin_'.$sPluginFile )
|
536 |
+
],
|
537 |
self_admin_url( 'plugins.php' )
|
538 |
);
|
539 |
}
|
@@ -275,41 +275,41 @@ class Request {
|
|
275 |
}
|
276 |
|
277 |
/**
|
278 |
-
* @deprecated
|
279 |
* @return int
|
|
|
280 |
*/
|
281 |
public function time() {
|
282 |
return $this->ts();
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
-
* @deprecated
|
287 |
* @param bool $bMicro
|
288 |
* @return int
|
|
|
289 |
*/
|
290 |
public function getRequestTime( $bMicro = false ) {
|
291 |
return $this->mts( $bMicro );
|
292 |
}
|
293 |
|
294 |
/**
|
295 |
-
* @deprecated
|
296 |
* @return string
|
|
|
297 |
*/
|
298 |
public function getRequestPath() {
|
299 |
return $this->getPath();
|
300 |
}
|
301 |
|
302 |
/**
|
303 |
-
* @deprecated
|
304 |
* @return string
|
|
|
305 |
*/
|
306 |
public function getRequestUri() {
|
307 |
return $this->server( 'REQUEST_URI', '' );
|
308 |
}
|
309 |
|
310 |
/**
|
311 |
-
* @deprecated
|
312 |
* @return array|false
|
|
|
313 |
*/
|
314 |
public function getRequestUriParts() {
|
315 |
return $this->getUriParts();
|
275 |
}
|
276 |
|
277 |
/**
|
|
|
278 |
* @return int
|
279 |
+
* @deprecated
|
280 |
*/
|
281 |
public function time() {
|
282 |
return $this->ts();
|
283 |
}
|
284 |
|
285 |
/**
|
|
|
286 |
* @param bool $bMicro
|
287 |
* @return int
|
288 |
+
* @deprecated
|
289 |
*/
|
290 |
public function getRequestTime( $bMicro = false ) {
|
291 |
return $this->mts( $bMicro );
|
292 |
}
|
293 |
|
294 |
/**
|
|
|
295 |
* @return string
|
296 |
+
* @deprecated
|
297 |
*/
|
298 |
public function getRequestPath() {
|
299 |
return $this->getPath();
|
300 |
}
|
301 |
|
302 |
/**
|
|
|
303 |
* @return string
|
304 |
+
* @deprecated
|
305 |
*/
|
306 |
public function getRequestUri() {
|
307 |
return $this->server( 'REQUEST_URI', '' );
|
308 |
}
|
309 |
|
310 |
/**
|
|
|
311 |
* @return array|false
|
312 |
+
* @deprecated
|
313 |
*/
|
314 |
public function getRequestUriParts() {
|
315 |
return $this->getUriParts();
|
@@ -36,7 +36,7 @@ class Response {
|
|
36 |
* @param bool $bSafe
|
37 |
* @param bool $bProtectAgainstInfiniteLoops - if false, ignores the redirect loop protection
|
38 |
*/
|
39 |
-
public function redirect( $sUrl, $aQueryParams =
|
40 |
$sUrl = empty( $aQueryParams ) ? $sUrl : add_query_arg( $aQueryParams, $sUrl );
|
41 |
|
42 |
// we prevent any repetitive redirect loops
|
@@ -59,28 +59,28 @@ class Response {
|
|
59 |
/**
|
60 |
* @param array $aQueryParams
|
61 |
*/
|
62 |
-
public function redirectHere( $aQueryParams =
|
63 |
$this->redirect( Services::Request()->getUri(), $aQueryParams );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* @param array $aQueryParams
|
68 |
*/
|
69 |
-
public function redirectToLogin( $aQueryParams =
|
70 |
$this->redirect( wp_login_url(), $aQueryParams );
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
* @param array $aQueryParams
|
75 |
*/
|
76 |
-
public function redirectToAdmin( $aQueryParams =
|
77 |
$this->redirect( is_multisite() ? get_admin_url() : admin_url(), $aQueryParams );
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
* @param array $aQueryParams
|
82 |
*/
|
83 |
-
public function redirectToHome( $aQueryParams =
|
84 |
$this->redirect( home_url(), $aQueryParams );
|
85 |
}
|
86 |
|
36 |
* @param bool $bSafe
|
37 |
* @param bool $bProtectAgainstInfiniteLoops - if false, ignores the redirect loop protection
|
38 |
*/
|
39 |
+
public function redirect( $sUrl, $aQueryParams = [], $bSafe = true, $bProtectAgainstInfiniteLoops = true ) {
|
40 |
$sUrl = empty( $aQueryParams ) ? $sUrl : add_query_arg( $aQueryParams, $sUrl );
|
41 |
|
42 |
// we prevent any repetitive redirect loops
|
59 |
/**
|
60 |
* @param array $aQueryParams
|
61 |
*/
|
62 |
+
public function redirectHere( $aQueryParams = [] ) {
|
63 |
$this->redirect( Services::Request()->getUri(), $aQueryParams );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* @param array $aQueryParams
|
68 |
*/
|
69 |
+
public function redirectToLogin( $aQueryParams = [] ) {
|
70 |
$this->redirect( wp_login_url(), $aQueryParams );
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
* @param array $aQueryParams
|
75 |
*/
|
76 |
+
public function redirectToAdmin( $aQueryParams = [] ) {
|
77 |
$this->redirect( is_multisite() ? get_admin_url() : admin_url(), $aQueryParams );
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
* @param array $aQueryParams
|
82 |
*/
|
83 |
+
public function redirectToHome( $aQueryParams = [] ) {
|
84 |
$this->redirect( home_url(), $aQueryParams );
|
85 |
}
|
86 |
|
@@ -70,11 +70,11 @@ class Themes {
|
|
70 |
*/
|
71 |
public function install( $sUrlToInstall, $bOverwrite = true, $bMaintenanceMode = false ) {
|
72 |
|
73 |
-
$aResult =
|
74 |
'successful' => true,
|
75 |
'plugin_info' => '',
|
76 |
-
'errors' =>
|
77 |
-
|
78 |
|
79 |
$oUpgraderSkin = new Upgrades\UpgraderSkin();
|
80 |
$oUpgrader = new Upgrades\ThemeUpgrader( $oUpgraderSkin );
|
@@ -149,15 +149,15 @@ class Themes {
|
|
149 |
*/
|
150 |
public function update( $sFile ) {
|
151 |
|
152 |
-
$aResult =
|
153 |
'successful' => 1,
|
154 |
-
'errors' =>
|
155 |
-
|
156 |
|
157 |
$oUpgraderSkin = new Upgrades\BulkThemeUpgraderSkin();
|
158 |
$oUpgrader = new Upgrades\ThemeUpgrader( $oUpgraderSkin );
|
159 |
ob_start();
|
160 |
-
$oUpgrader->bulk_upgrade(
|
161 |
if ( ob_get_contents() ) {
|
162 |
// for some reason this errors with no buffer present
|
163 |
ob_end_clean();
|
@@ -243,7 +243,7 @@ class Themes {
|
|
243 |
$this->checkForUpdates();
|
244 |
}
|
245 |
$aUpdates = Services::WpGeneral()->getWordpressUpdates( 'themes' );
|
246 |
-
return is_array( $aUpdates ) ? $aUpdates :
|
247 |
}
|
248 |
|
249 |
/**
|
@@ -260,12 +260,12 @@ class Themes {
|
|
260 |
public function getExtendedData( $sBase ) {
|
261 |
include_once( ABSPATH.'wp-admin/includes/theme.php' );
|
262 |
|
263 |
-
$oApi = themes_api( 'theme_information',
|
264 |
'slug' => $sBase,
|
265 |
-
'fields' =>
|
266 |
'sections' => false,
|
267 |
-
|
268 |
-
|
269 |
return $oApi;
|
270 |
}
|
271 |
|
@@ -355,6 +355,6 @@ class Themes {
|
|
355 |
* @return array
|
356 |
*/
|
357 |
public function wpmsGetSiteAllowedThemes() {
|
358 |
-
return ( function_exists( 'get_site_allowed_themes' ) ? get_site_allowed_themes() :
|
359 |
}
|
360 |
}
|
70 |
*/
|
71 |
public function install( $sUrlToInstall, $bOverwrite = true, $bMaintenanceMode = false ) {
|
72 |
|
73 |
+
$aResult = [
|
74 |
'successful' => true,
|
75 |
'plugin_info' => '',
|
76 |
+
'errors' => []
|
77 |
+
];
|
78 |
|
79 |
$oUpgraderSkin = new Upgrades\UpgraderSkin();
|
80 |
$oUpgrader = new Upgrades\ThemeUpgrader( $oUpgraderSkin );
|
149 |
*/
|
150 |
public function update( $sFile ) {
|
151 |
|
152 |
+
$aResult = [
|
153 |
'successful' => 1,
|
154 |
+
'errors' => []
|
155 |
+
];
|
156 |
|
157 |
$oUpgraderSkin = new Upgrades\BulkThemeUpgraderSkin();
|
158 |
$oUpgrader = new Upgrades\ThemeUpgrader( $oUpgraderSkin );
|
159 |
ob_start();
|
160 |
+
$oUpgrader->bulk_upgrade( [ $sFile ] );
|
161 |
if ( ob_get_contents() ) {
|
162 |
// for some reason this errors with no buffer present
|
163 |
ob_end_clean();
|
243 |
$this->checkForUpdates();
|
244 |
}
|
245 |
$aUpdates = Services::WpGeneral()->getWordpressUpdates( 'themes' );
|
246 |
+
return is_array( $aUpdates ) ? $aUpdates : [];
|
247 |
}
|
248 |
|
249 |
/**
|
260 |
public function getExtendedData( $sBase ) {
|
261 |
include_once( ABSPATH.'wp-admin/includes/theme.php' );
|
262 |
|
263 |
+
$oApi = themes_api( 'theme_information', [
|
264 |
'slug' => $sBase,
|
265 |
+
'fields' => [
|
266 |
'sections' => false,
|
267 |
+
],
|
268 |
+
] );
|
269 |
return $oApi;
|
270 |
}
|
271 |
|
355 |
* @return array
|
356 |
*/
|
357 |
public function wpmsGetSiteAllowedThemes() {
|
358 |
+
return ( function_exists( 'get_site_allowed_themes' ) ? get_site_allowed_themes() : [] );
|
359 |
}
|
360 |
}
|
@@ -9,12 +9,12 @@ class Track {
|
|
9 |
/**
|
10 |
* @var array
|
11 |
*/
|
12 |
-
protected $aFiredWpActions =
|
13 |
|
14 |
public function __construct() {
|
15 |
-
$aActions =
|
16 |
-
foreach( $aActions as $sAction ) {
|
17 |
-
add_action( $sAction,
|
18 |
}
|
19 |
}
|
20 |
|
@@ -33,7 +33,7 @@ class Track {
|
|
33 |
*/
|
34 |
public function setWpActionHasFired( $sAction ) {
|
35 |
if ( !isset( $this->aFiredWpActions ) || !is_array( $this->aFiredWpActions ) ) {
|
36 |
-
$this->aFiredWpActions =
|
37 |
}
|
38 |
$this->aFiredWpActions[ $sAction ] = microtime();
|
39 |
return $this;
|
9 |
/**
|
10 |
* @var array
|
11 |
*/
|
12 |
+
protected $aFiredWpActions = [];
|
13 |
|
14 |
public function __construct() {
|
15 |
+
$aActions = [ 'plugins_loaded', 'init', 'admin_init', 'wp_loaded', 'wp', 'wp_head', 'shutdown' ];
|
16 |
+
foreach ( $aActions as $sAction ) {
|
17 |
+
add_action( $sAction, [ $this, 'trackAction' ], 0 );
|
18 |
}
|
19 |
}
|
20 |
|
33 |
*/
|
34 |
public function setWpActionHasFired( $sAction ) {
|
35 |
if ( !isset( $this->aFiredWpActions ) || !is_array( $this->aFiredWpActions ) ) {
|
36 |
+
$this->aFiredWpActions = [];
|
37 |
}
|
38 |
$this->aFiredWpActions[ $sAction ] = microtime();
|
39 |
return $this;
|
@@ -21,10 +21,10 @@ class BulkPluginUpgraderSkin extends \Bulk_Plugin_Upgrader_Skin {
|
|
21 |
* BulkPluginUpgraderSkin constructor.
|
22 |
* @param array $args
|
23 |
*/
|
24 |
-
public function __construct( $args =
|
25 |
parent::__construct( array_merge( $args, compact( 'nonce', 'url' ) ) );
|
26 |
-
$this->aErrors =
|
27 |
-
$this->aFeedback =
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -73,7 +73,7 @@ class BulkPluginUpgraderSkin extends \Bulk_Plugin_Upgrader_Skin {
|
|
73 |
* @return array
|
74 |
*/
|
75 |
public function getErrors() {
|
76 |
-
return is_array( $this->aErrors ) ? $this->aErrors :
|
77 |
}
|
78 |
|
79 |
/**
|
21 |
* BulkPluginUpgraderSkin constructor.
|
22 |
* @param array $args
|
23 |
*/
|
24 |
+
public function __construct( $args = [] ) {
|
25 |
parent::__construct( array_merge( $args, compact( 'nonce', 'url' ) ) );
|
26 |
+
$this->aErrors = [];
|
27 |
+
$this->aFeedback = [];
|
28 |
}
|
29 |
|
30 |
/**
|
73 |
* @return array
|
74 |
*/
|
75 |
public function getErrors() {
|
76 |
+
return is_array( $this->aErrors ) ? $this->aErrors : [];
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -21,8 +21,8 @@ class BulkThemeUpgraderSkin extends \Bulk_Theme_Upgrader_Skin {
|
|
21 |
*/
|
22 |
public function __construct() {
|
23 |
parent::__construct( compact( 'title', 'nonce', 'url', 'theme' ) );
|
24 |
-
$this->aErrors =
|
25 |
-
$this->aFeedback =
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -50,7 +50,7 @@ class BulkThemeUpgraderSkin extends \Bulk_Theme_Upgrader_Skin {
|
|
50 |
* @return array
|
51 |
*/
|
52 |
public function getErrors() {
|
53 |
-
return is_array( $this->aErrors ) ? $this->aErrors :
|
54 |
}
|
55 |
|
56 |
/**
|
21 |
*/
|
22 |
public function __construct() {
|
23 |
parent::__construct( compact( 'title', 'nonce', 'url', 'theme' ) );
|
24 |
+
$this->aErrors = [];
|
25 |
+
$this->aFeedback = [];
|
26 |
}
|
27 |
|
28 |
/**
|
50 |
* @return array
|
51 |
*/
|
52 |
public function getErrors() {
|
53 |
+
return is_array( $this->aErrors ) ? $this->aErrors : [];
|
54 |
}
|
55 |
|
56 |
/**
|
@@ -14,33 +14,33 @@ class PluginUpgrader extends \Plugin_Upgrader {
|
|
14 |
* @param array $args
|
15 |
* @return array|bool|\WP_Error
|
16 |
*/
|
17 |
-
public function install( $package, $args =
|
18 |
|
19 |
-
$defaults =
|
20 |
'clear_update_cache' => true,
|
21 |
-
|
22 |
$parsed_args = wp_parse_args( $args, $defaults );
|
23 |
|
24 |
$this->init();
|
25 |
$this->install_strings();
|
26 |
|
27 |
-
add_filter( 'upgrader_source_selection',
|
28 |
-
add_filter( 'upgrader_clear_destination',
|
29 |
|
30 |
-
$oResult = $this->run(
|
31 |
'package' => $package,
|
32 |
'destination' => WP_PLUGIN_DIR,
|
33 |
'clear_destination' => $this->getOverwriteMode(),
|
34 |
// key to overwrite and why we're extending the native wordpress class
|
35 |
'clear_working' => true,
|
36 |
-
'hook_extra' =>
|
37 |
'type' => 'plugin',
|
38 |
'action' => 'install',
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
remove_filter( 'upgrader_source_selection',
|
43 |
-
remove_filter( 'upgrader_clear_destination',
|
44 |
|
45 |
if ( !$this->result || is_wp_error( $this->result ) ) {
|
46 |
return $this->result;
|
14 |
* @param array $args
|
15 |
* @return array|bool|\WP_Error
|
16 |
*/
|
17 |
+
public function install( $package, $args = [] ) {
|
18 |
|
19 |
+
$defaults = [
|
20 |
'clear_update_cache' => true,
|
21 |
+
];
|
22 |
$parsed_args = wp_parse_args( $args, $defaults );
|
23 |
|
24 |
$this->init();
|
25 |
$this->install_strings();
|
26 |
|
27 |
+
add_filter( 'upgrader_source_selection', [ $this, 'check_package' ] );
|
28 |
+
add_filter( 'upgrader_clear_destination', [ $this, 'clearStatCache' ] );
|
29 |
|
30 |
+
$oResult = $this->run( [
|
31 |
'package' => $package,
|
32 |
'destination' => WP_PLUGIN_DIR,
|
33 |
'clear_destination' => $this->getOverwriteMode(),
|
34 |
// key to overwrite and why we're extending the native wordpress class
|
35 |
'clear_working' => true,
|
36 |
+
'hook_extra' => [
|
37 |
'type' => 'plugin',
|
38 |
'action' => 'install',
|
39 |
+
]
|
40 |
+
] );
|
41 |
|
42 |
+
remove_filter( 'upgrader_source_selection', [ $this, 'check_package' ] );
|
43 |
+
remove_filter( 'upgrader_clear_destination', [ $this, 'clearStatCache' ] );
|
44 |
|
45 |
if ( !$this->result || is_wp_error( $this->result ) ) {
|
46 |
return $this->result;
|
@@ -14,34 +14,34 @@ class ThemeUpgrader extends \Theme_Upgrader {
|
|
14 |
* @param array $args
|
15 |
* @return array|bool|\WP_Error
|
16 |
*/
|
17 |
-
public function install( $package, $args =
|
18 |
|
19 |
-
$defaults =
|
20 |
'clear_update_cache' => true,
|
21 |
-
|
22 |
$parsed_args = wp_parse_args( $args, $defaults );
|
23 |
|
24 |
$this->init();
|
25 |
$this->install_strings();
|
26 |
|
27 |
-
add_filter( 'upgrader_source_selection',
|
28 |
-
add_filter( 'upgrader_post_install',
|
29 |
-
add_filter( 'upgrader_clear_destination',
|
30 |
|
31 |
-
$this->run(
|
32 |
'package' => $package,
|
33 |
'destination' => get_theme_root(),
|
34 |
'clear_destination' => $this->getOverwriteMode(),
|
35 |
'clear_working' => true,
|
36 |
-
'hook_extra' =>
|
37 |
'type' => 'theme',
|
38 |
'action' => 'install',
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
remove_filter( 'upgrader_source_selection',
|
43 |
-
remove_filter( 'upgrader_post_install',
|
44 |
-
remove_filter( 'upgrader_clear_destination',
|
45 |
|
46 |
if ( !$this->result || is_wp_error( $this->result ) ) {
|
47 |
return $this->result;
|
14 |
* @param array $args
|
15 |
* @return array|bool|\WP_Error
|
16 |
*/
|
17 |
+
public function install( $package, $args = [] ) {
|
18 |
|
19 |
+
$defaults = [
|
20 |
'clear_update_cache' => true,
|
21 |
+
];
|
22 |
$parsed_args = wp_parse_args( $args, $defaults );
|
23 |
|
24 |
$this->init();
|
25 |
$this->install_strings();
|
26 |
|
27 |
+
add_filter( 'upgrader_source_selection', [ $this, 'check_package' ] );
|
28 |
+
add_filter( 'upgrader_post_install', [ $this, 'check_parent_theme_filter' ], 10, 3 );
|
29 |
+
add_filter( 'upgrader_clear_destination', [ $this, 'clearStatCache' ] );
|
30 |
|
31 |
+
$this->run( [
|
32 |
'package' => $package,
|
33 |
'destination' => get_theme_root(),
|
34 |
'clear_destination' => $this->getOverwriteMode(),
|
35 |
'clear_working' => true,
|
36 |
+
'hook_extra' => [
|
37 |
'type' => 'theme',
|
38 |
'action' => 'install',
|
39 |
+
],
|
40 |
+
] );
|
41 |
|
42 |
+
remove_filter( 'upgrader_source_selection', [ $this, 'check_package' ] );
|
43 |
+
remove_filter( 'upgrader_post_install', [ $this, 'check_parent_theme_filter' ] );
|
44 |
+
remove_filter( 'upgrader_clear_destination', [ $this, 'clearStatCache' ] );
|
45 |
|
46 |
if ( !$this->result || is_wp_error( $this->result ) ) {
|
47 |
return $this->result;
|
@@ -26,14 +26,14 @@ class UpgraderSkin extends \WP_Upgrader_Skin {
|
|
26 |
* @return array
|
27 |
*/
|
28 |
public function getErrors() {
|
29 |
-
return is_array( $this->aErrors ) ? $this->aErrors :
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
* @return array
|
34 |
*/
|
35 |
public function getFeedback() {
|
36 |
-
return is_array( $this->aFeedback ) ? $this->aFeedback :
|
37 |
}
|
38 |
|
39 |
function error( $errors ) {
|
26 |
* @return array
|
27 |
*/
|
28 |
public function getErrors() {
|
29 |
+
return is_array( $this->aErrors ) ? $this->aErrors : [];
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
* @return array
|
34 |
*/
|
35 |
public function getFeedback() {
|
36 |
+
return is_array( $this->aFeedback ) ? $this->aFeedback : [];
|
37 |
}
|
38 |
|
39 |
function error( $errors ) {
|
@@ -41,7 +41,7 @@ class Users {
|
|
41 |
/**
|
42 |
* @param array $aLoginUrlParams
|
43 |
*/
|
44 |
-
public function forceUserRelogin( $aLoginUrlParams =
|
45 |
$this->logoutUser();
|
46 |
Services::Response()->redirectToLogin( $aLoginUrlParams );
|
47 |
}
|
@@ -64,10 +64,10 @@ class Users {
|
|
64 |
* @param array $aArgs
|
65 |
* @return \WP_User[]
|
66 |
*/
|
67 |
-
public function getAllUsers( $aArgs =
|
68 |
$aArgs = wp_parse_args(
|
69 |
$aArgs,
|
70 |
-
|
71 |
'blog_id' => 0,
|
72 |
// 'fields' => array(
|
73 |
// 'ID',
|
@@ -75,9 +75,9 @@ class Users {
|
|
75 |
// 'user_email',
|
76 |
// 'user_pass',
|
77 |
// )
|
78 |
-
|
79 |
);
|
80 |
-
return function_exists( 'get_users' ) ? get_users( $aArgs ) :
|
81 |
}
|
82 |
|
83 |
/**
|
@@ -104,13 +104,13 @@ class Users {
|
|
104 |
* @return array
|
105 |
*/
|
106 |
public function getLevelToRoleMap() {
|
107 |
-
return
|
108 |
0 => 'subscriber',
|
109 |
1 => 'contributor',
|
110 |
2 => 'author',
|
111 |
3 => 'editor',
|
112 |
8 => 'administrator'
|
113 |
-
|
114 |
}
|
115 |
|
116 |
/**
|
@@ -220,9 +220,9 @@ class Users {
|
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
-
* @see wp-login.php
|
224 |
* @param \WP_User $oUser
|
225 |
* @return string|null
|
|
|
226 |
*/
|
227 |
public function getPasswordResetUrl( $oUser ) {
|
228 |
$sUrl = null;
|
@@ -230,11 +230,11 @@ class Users {
|
|
230 |
$sResetKey = get_password_reset_key( $oUser );
|
231 |
if ( !is_wp_error( $sResetKey ) ) {
|
232 |
$sUrl = add_query_arg(
|
233 |
-
|
234 |
'action' => 'rp',
|
235 |
'key' => $sResetKey,
|
236 |
'login' => $oUser->user_login,
|
237 |
-
|
238 |
wp_login_url()
|
239 |
);
|
240 |
}
|
41 |
/**
|
42 |
* @param array $aLoginUrlParams
|
43 |
*/
|
44 |
+
public function forceUserRelogin( $aLoginUrlParams = [] ) {
|
45 |
$this->logoutUser();
|
46 |
Services::Response()->redirectToLogin( $aLoginUrlParams );
|
47 |
}
|
64 |
* @param array $aArgs
|
65 |
* @return \WP_User[]
|
66 |
*/
|
67 |
+
public function getAllUsers( $aArgs = [] ) {
|
68 |
$aArgs = wp_parse_args(
|
69 |
$aArgs,
|
70 |
+
[
|
71 |
'blog_id' => 0,
|
72 |
// 'fields' => array(
|
73 |
// 'ID',
|
75 |
// 'user_email',
|
76 |
// 'user_pass',
|
77 |
// )
|
78 |
+
]
|
79 |
);
|
80 |
+
return function_exists( 'get_users' ) ? get_users( $aArgs ) : [];
|
81 |
}
|
82 |
|
83 |
/**
|
104 |
* @return array
|
105 |
*/
|
106 |
public function getLevelToRoleMap() {
|
107 |
+
return [
|
108 |
0 => 'subscriber',
|
109 |
1 => 'contributor',
|
110 |
2 => 'author',
|
111 |
3 => 'editor',
|
112 |
8 => 'administrator'
|
113 |
+
];
|
114 |
}
|
115 |
|
116 |
/**
|
220 |
}
|
221 |
|
222 |
/**
|
|
|
223 |
* @param \WP_User $oUser
|
224 |
* @return string|null
|
225 |
+
* @see wp-login.php
|
226 |
*/
|
227 |
public function getPasswordResetUrl( $oUser ) {
|
228 |
$sUrl = null;
|
230 |
$sResetKey = get_password_reset_key( $oUser );
|
231 |
if ( !is_wp_error( $sResetKey ) ) {
|
232 |
$sUrl = add_query_arg(
|
233 |
+
[
|
234 |
'action' => 'rp',
|
235 |
'key' => $sResetKey,
|
236 |
'login' => $oUser->user_login,
|
237 |
+
],
|
238 |
wp_login_url()
|
239 |
);
|
240 |
}
|
@@ -6,7 +6,7 @@ use FernleafSystems\Utilities\Data\Adapter\StdClassAdapter;
|
|
6 |
|
7 |
/**
|
8 |
* Class WpHttpResponseVo
|
9 |
-
* @see
|
10 |
* @package FernleafSystems\Wordpress\Services\Core\VOs
|
11 |
* @property string $body
|
12 |
* @property string $headers
|
6 |
|
7 |
/**
|
8 |
* Class WpHttpResponseVo
|
9 |
+
* @see class-wp-http-requests-response.php to_array()
|
10 |
* @package FernleafSystems\Wordpress\Services\Core\VOs
|
11 |
* @property string $body
|
12 |
* @property string $headers
|
@@ -324,7 +324,7 @@ class Services {
|
|
324 |
static protected function getObj( $sKeyFunction ) {
|
325 |
$sFullKey = 'service_'.strtolower( $sKeyFunction );
|
326 |
if ( !is_array( self::$aItems ) ) {
|
327 |
-
self::$aItems =
|
328 |
}
|
329 |
if ( !isset( self::$aItems[ $sFullKey ] ) ) {
|
330 |
self::$aItems[ $sFullKey ] = self::$oDic[ $sFullKey ];
|
324 |
static protected function getObj( $sKeyFunction ) {
|
325 |
$sFullKey = 'service_'.strtolower( $sKeyFunction );
|
326 |
if ( !is_array( self::$aItems ) ) {
|
327 |
+
self::$aItems = [];
|
328 |
}
|
329 |
if ( !isset( self::$aItems[ $sFullKey ] ) ) {
|
330 |
self::$aItems[ $sFullKey ] = self::$oDic[ $sFullKey ];
|
@@ -36,7 +36,7 @@ class Checksums {
|
|
36 |
$aCs = $oWp->getTransient( $sKey );
|
37 |
if ( empty( $aCs ) || !is_array( $aCs ) ) {
|
38 |
$aCs = $this->buildChecksums();
|
39 |
-
$oWp->setTransient( $sKey, $aCs, WEEK_IN_SECONDS
|
40 |
}
|
41 |
|
42 |
return $aCs;
|
36 |
$aCs = $oWp->getTransient( $sKey );
|
37 |
if ( empty( $aCs ) || !is_array( $aCs ) ) {
|
38 |
$aCs = $this->buildChecksums();
|
39 |
+
$oWp->setTransient( $sKey, $aCs, WEEK_IN_SECONDS*6 );
|
40 |
}
|
41 |
|
42 |
return $aCs;
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\Consumers;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services\Core\VOs\WpPluginVo;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Trait PluginConsumer
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\Consumers
|
10 |
+
*/
|
11 |
+
trait PluginConsumer {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var WpPluginVo
|
15 |
+
*/
|
16 |
+
private $oWorkingPlugin;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @return WpPluginVo
|
20 |
+
*/
|
21 |
+
public function getWorkingPlugin() {
|
22 |
+
return $this->oWorkingPlugin;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return bool
|
27 |
+
*/
|
28 |
+
public function hasWorkingPlugin() {
|
29 |
+
return $this->oWorkingPlugin instanceof WpPluginVo;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param WpPluginVo $oPlugin
|
34 |
+
* @return $this
|
35 |
+
*/
|
36 |
+
public function setWorkingPlugin( $oPlugin ) {
|
37 |
+
$this->oWorkingPlugin = $oPlugin;
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
@@ -45,7 +45,7 @@ class Data {
|
|
45 |
*/
|
46 |
protected function findViableVisitorIp() {
|
47 |
|
48 |
-
$aAddressSourceOptions =
|
49 |
'HTTP_CF_CONNECTING_IP',
|
50 |
'HTTP_X_FORWARDED_FOR',
|
51 |
'HTTP_X_FORWARDED',
|
@@ -55,7 +55,7 @@ class Data {
|
|
55 |
'HTTP_FORWARDED',
|
56 |
'HTTP_CLIENT_IP',
|
57 |
'REMOTE_ADDR'
|
58 |
-
|
59 |
|
60 |
$sIpToReturn = false;
|
61 |
$oReq = Services::Request();
|
@@ -156,7 +156,7 @@ class Data {
|
|
156 |
|
157 |
$sUrl = trim( $this->urlStripQueryPart( $sUrl ) );
|
158 |
if ( filter_var( $sUrl, FILTER_VALIDATE_URL ) ) { // we have a scheme+host
|
159 |
-
if ( in_array( parse_url( $sUrl, PHP_URL_SCHEME ),
|
160 |
$sValidatedUrl = rtrim( $sUrl, '/' );
|
161 |
}
|
162 |
}
|
@@ -178,13 +178,13 @@ class Data {
|
|
178 |
*/
|
179 |
public function extractCommaSeparatedList( $sRawList = '' ) {
|
180 |
|
181 |
-
$aRawList =
|
182 |
if ( empty( $sRawList ) ) {
|
183 |
return $aRawList;
|
184 |
}
|
185 |
|
186 |
$aRawList = array_map( 'trim', preg_split( '/\r\n|\r|\n/', $sRawList ) );
|
187 |
-
$aNewList =
|
188 |
$bHadStar = false;
|
189 |
foreach ( $aRawList as $sKey => $sRawLine ) {
|
190 |
|
@@ -208,7 +208,7 @@ class Data {
|
|
208 |
}
|
209 |
}
|
210 |
|
211 |
-
$aParams = empty( $aParts[ 1 ] ) ?
|
212 |
$aNewList[ $aParts[ 0 ] ] = $aParams;
|
213 |
}
|
214 |
return $aNewList;
|
@@ -264,7 +264,7 @@ class Data {
|
|
264 |
continue;
|
265 |
}
|
266 |
$aParts[ 1 ] = substr( $aParts[ 1 ], 0, 12 );
|
267 |
-
$aKeys[ $nIndex ] =
|
268 |
}
|
269 |
return $aKeys;
|
270 |
}
|
@@ -279,7 +279,7 @@ class Data {
|
|
279 |
* @return string
|
280 |
*/
|
281 |
static public function GenerateRandomString( $nLength = 10, $nStrength = 7, $bIgnoreAmb = true ) {
|
282 |
-
$aChars =
|
283 |
|
284 |
if ( $nStrength & 2 ) {
|
285 |
$aChars[] = '023456789';
|
@@ -336,9 +336,9 @@ class Data {
|
|
336 |
}
|
337 |
|
338 |
/**
|
339 |
-
* @deprecated
|
340 |
* @param string $sRequestedUrl
|
341 |
* @param string $sBaseUrl
|
|
|
342 |
*/
|
343 |
public function doSendApache404( $sRequestedUrl, $sBaseUrl ) {
|
344 |
Services::Response()->sendApache404();
|
@@ -502,9 +502,9 @@ class Data {
|
|
502 |
}
|
503 |
|
504 |
/**
|
505 |
-
* @deprecated
|
506 |
* @param string $sStringContent
|
507 |
* @param string $sFilename
|
|
|
508 |
*/
|
509 |
public function downloadStringAsFile( $sStringContent, $sFilename ) {
|
510 |
Services::Response()->downloadStringAsFile( $sStringContent, $sFilename );
|
45 |
*/
|
46 |
protected function findViableVisitorIp() {
|
47 |
|
48 |
+
$aAddressSourceOptions = [
|
49 |
'HTTP_CF_CONNECTING_IP',
|
50 |
'HTTP_X_FORWARDED_FOR',
|
51 |
'HTTP_X_FORWARDED',
|
55 |
'HTTP_FORWARDED',
|
56 |
'HTTP_CLIENT_IP',
|
57 |
'REMOTE_ADDR'
|
58 |
+
];
|
59 |
|
60 |
$sIpToReturn = false;
|
61 |
$oReq = Services::Request();
|
156 |
|
157 |
$sUrl = trim( $this->urlStripQueryPart( $sUrl ) );
|
158 |
if ( filter_var( $sUrl, FILTER_VALIDATE_URL ) ) { // we have a scheme+host
|
159 |
+
if ( in_array( parse_url( $sUrl, PHP_URL_SCHEME ), [ 'http', 'https' ] ) ) {
|
160 |
$sValidatedUrl = rtrim( $sUrl, '/' );
|
161 |
}
|
162 |
}
|
178 |
*/
|
179 |
public function extractCommaSeparatedList( $sRawList = '' ) {
|
180 |
|
181 |
+
$aRawList = [];
|
182 |
if ( empty( $sRawList ) ) {
|
183 |
return $aRawList;
|
184 |
}
|
185 |
|
186 |
$aRawList = array_map( 'trim', preg_split( '/\r\n|\r|\n/', $sRawList ) );
|
187 |
+
$aNewList = [];
|
188 |
$bHadStar = false;
|
189 |
foreach ( $aRawList as $sKey => $sRawLine ) {
|
190 |
|
208 |
}
|
209 |
}
|
210 |
|
211 |
+
$aParams = empty( $aParts[ 1 ] ) ? [] : explode( ',', $aParts[ 1 ] );
|
212 |
$aNewList[ $aParts[ 0 ] ] = $aParams;
|
213 |
}
|
214 |
return $aNewList;
|
264 |
continue;
|
265 |
}
|
266 |
$aParts[ 1 ] = substr( $aParts[ 1 ], 0, 12 );
|
267 |
+
$aKeys[ $nIndex ] = [ $aParts[ 0 ] => $aParts[ 1 ] ];
|
268 |
}
|
269 |
return $aKeys;
|
270 |
}
|
279 |
* @return string
|
280 |
*/
|
281 |
static public function GenerateRandomString( $nLength = 10, $nStrength = 7, $bIgnoreAmb = true ) {
|
282 |
+
$aChars = [ 'abcdefghijkmnopqrstuvwxyz' ];
|
283 |
|
284 |
if ( $nStrength & 2 ) {
|
285 |
$aChars[] = '023456789';
|
336 |
}
|
337 |
|
338 |
/**
|
|
|
339 |
* @param string $sRequestedUrl
|
340 |
* @param string $sBaseUrl
|
341 |
+
* @deprecated
|
342 |
*/
|
343 |
public function doSendApache404( $sRequestedUrl, $sBaseUrl ) {
|
344 |
Services::Response()->sendApache404();
|
502 |
}
|
503 |
|
504 |
/**
|
|
|
505 |
* @param string $sStringContent
|
506 |
* @param string $sFilename
|
507 |
+
* @deprecated
|
508 |
*/
|
509 |
public function downloadStringAsFile( $sStringContent, $sFilename ) {
|
510 |
Services::Response()->downloadStringAsFile( $sStringContent, $sFilename );
|
@@ -97,7 +97,7 @@ class DataManipulation {
|
|
97 |
* @return array
|
98 |
*/
|
99 |
public function removeFromArrayByValue( $aArray, $mValue, $bFirstOnly = false ) {
|
100 |
-
$aKeys =
|
101 |
|
102 |
if ( $bFirstOnly ) {
|
103 |
$mKey = array_search( $mValue, $aArray, true );
|
97 |
* @return array
|
98 |
*/
|
99 |
public function removeFromArrayByValue( $aArray, $mValue, $bFirstOnly = false ) {
|
100 |
+
$aKeys = [];
|
101 |
|
102 |
if ( $bFirstOnly ) {
|
103 |
$mKey = array_search( $mValue, $aArray, true );
|
@@ -50,16 +50,16 @@ class Email {
|
|
50 |
*/
|
51 |
protected function emailFilters( $bAdd ) {
|
52 |
if ( $bAdd ) {
|
53 |
-
add_action( 'phpmailer_init',
|
54 |
-
add_filter( 'wp_mail_from',
|
55 |
-
add_filter( 'wp_mail_from_name',
|
56 |
-
add_filter( 'wp_mail_content_type',
|
57 |
}
|
58 |
else {
|
59 |
-
remove_action( 'phpmailer_init',
|
60 |
-
remove_filter( 'wp_mail_from',
|
61 |
-
remove_filter( 'wp_mail_from_name',
|
62 |
-
remove_filter( 'wp_mail_content_type',
|
63 |
}
|
64 |
return $this;
|
65 |
}
|
@@ -142,12 +142,12 @@ class Email {
|
|
142 |
*/
|
143 |
protected function getContentFooter() {
|
144 |
$sUrl = Services::WpGeneral()->getHomeUrl();
|
145 |
-
return
|
146 |
'----',
|
147 |
sprintf( __( 'Email sent from %s' ), sprintf( '<a href="%s">%s</a>', $sUrl, $sUrl ) ),
|
148 |
__( 'Note: Email delays are caused by website hosting and email providers.' ),
|
149 |
sprintf( __( 'Time Sent: %s' ), Services::WpGeneral()->getTimeStampForDisplay() )
|
150 |
-
|
151 |
}
|
152 |
|
153 |
/**
|
50 |
*/
|
51 |
protected function emailFilters( $bAdd ) {
|
52 |
if ( $bAdd ) {
|
53 |
+
add_action( 'phpmailer_init', [ $this, 'onPhpMailerInit' ], PHP_INT_MAX, 1 );
|
54 |
+
add_filter( 'wp_mail_from', [ $this, 'filterMailFrom' ], 100 );
|
55 |
+
add_filter( 'wp_mail_from_name', [ $this, 'filterMailFromName' ], 100 );
|
56 |
+
add_filter( 'wp_mail_content_type', [ $this, 'filterMailContentType' ], 100, 0 );
|
57 |
}
|
58 |
else {
|
59 |
+
remove_action( 'phpmailer_init', [ $this, 'onPhpMailerInit' ], PHP_INT_MAX );
|
60 |
+
remove_filter( 'wp_mail_from', [ $this, 'filterMailFrom' ], 100 );
|
61 |
+
remove_filter( 'wp_mail_from_name', [ $this, 'filterMailFromName' ], 100 );
|
62 |
+
remove_filter( 'wp_mail_content_type', [ $this, 'filterMailContentType' ], 100 );
|
63 |
}
|
64 |
return $this;
|
65 |
}
|
142 |
*/
|
143 |
protected function getContentFooter() {
|
144 |
$sUrl = Services::WpGeneral()->getHomeUrl();
|
145 |
+
return [
|
146 |
'----',
|
147 |
sprintf( __( 'Email sent from %s' ), sprintf( '<a href="%s">%s</a>', $sUrl, $sUrl ) ),
|
148 |
__( 'Note: Email delays are caused by website hosting and email providers.' ),
|
149 |
sprintf( __( 'Time Sent: %s' ), Services::WpGeneral()->getTimeStampForDisplay() )
|
150 |
+
];
|
151 |
}
|
152 |
|
153 |
/**
|
@@ -103,8 +103,8 @@ class OpenSslEncrypt {
|
|
103 |
$oVo->json_encoded = false;
|
104 |
}
|
105 |
|
106 |
-
$aPasswordKeys =
|
107 |
-
$nResult = openssl_seal( $mDataToEncrypt, $sEncryptedData, $aPasswordKeys,
|
108 |
|
109 |
$oVo->result = $nResult;
|
110 |
$oVo->success = is_int( $nResult ) && $nResult > 0 && !is_null( $sEncryptedData );
|
103 |
$oVo->json_encoded = false;
|
104 |
}
|
105 |
|
106 |
+
$aPasswordKeys = [];
|
107 |
+
$nResult = openssl_seal( $mDataToEncrypt, $sEncryptedData, $aPasswordKeys, [ $sPublicKey ] );
|
108 |
|
109 |
$oVo->result = $nResult;
|
110 |
$oVo->success = is_int( $nResult ) && $nResult > 0 && !is_null( $sEncryptedData );
|
@@ -10,6 +10,7 @@ use GeoIp2\Database\Reader;
|
|
10 |
* @package FernleafSystems\Wordpress\Services\Utilities
|
11 |
*/
|
12 |
class GeoIp {
|
|
|
13 |
/**
|
14 |
* @var Reader
|
15 |
*/
|
10 |
* @package FernleafSystems\Wordpress\Services\Utilities
|
11 |
*/
|
12 |
class GeoIp {
|
13 |
+
|
14 |
/**
|
15 |
* @var Reader
|
16 |
*/
|
@@ -22,7 +22,7 @@ class HttpRequest {
|
|
22 |
* @param array $aArg
|
23 |
* @return bool
|
24 |
*/
|
25 |
-
public function get( $sUrl, $aArg =
|
26 |
return $this->request( $sUrl, $aArg, 'GET' )->isSuccess();
|
27 |
}
|
28 |
|
@@ -31,7 +31,7 @@ class HttpRequest {
|
|
31 |
* @param array $aArg
|
32 |
* @return string
|
33 |
*/
|
34 |
-
public function getContent( $sUrl, $aArg =
|
35 |
return $this->get( $sUrl, $aArg ) ? trim( $this->lastResponse->body ) : '';
|
36 |
}
|
37 |
|
@@ -40,7 +40,7 @@ class HttpRequest {
|
|
40 |
* @param array $aArg
|
41 |
* @return bool
|
42 |
*/
|
43 |
-
public function post( $sUrl, $aArg =
|
44 |
return $this->request( $sUrl, $aArg, 'POST' )->isSuccess();
|
45 |
}
|
46 |
|
@@ -58,7 +58,7 @@ class HttpRequest {
|
|
58 |
* @param string $sMethod
|
59 |
* @return array|false
|
60 |
*/
|
61 |
-
public function requestUrl( $sUrl, $aRequestArgs =
|
62 |
return $this->request( $sUrl, $aRequestArgs, $sMethod )->isSuccess() ?
|
63 |
$this->lastResponse->getRawDataAsArray() : false;
|
64 |
}
|
22 |
* @param array $aArg
|
23 |
* @return bool
|
24 |
*/
|
25 |
+
public function get( $sUrl, $aArg = [] ) {
|
26 |
return $this->request( $sUrl, $aArg, 'GET' )->isSuccess();
|
27 |
}
|
28 |
|
31 |
* @param array $aArg
|
32 |
* @return string
|
33 |
*/
|
34 |
+
public function getContent( $sUrl, $aArg = [] ) {
|
35 |
return $this->get( $sUrl, $aArg ) ? trim( $this->lastResponse->body ) : '';
|
36 |
}
|
37 |
|
40 |
* @param array $aArg
|
41 |
* @return bool
|
42 |
*/
|
43 |
+
public function post( $sUrl, $aArg = [] ) {
|
44 |
return $this->request( $sUrl, $aArg, 'POST' )->isSuccess();
|
45 |
}
|
46 |
|
58 |
* @param string $sMethod
|
59 |
* @return array|false
|
60 |
*/
|
61 |
+
public function requestUrl( $sUrl, $aRequestArgs = [], $sMethod = 'GET' ) {
|
62 |
return $this->request( $sUrl, $aRequestArgs, $sMethod )->isSuccess() ?
|
63 |
$this->lastResponse->getRawDataAsArray() : false;
|
64 |
}
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class HttpUtil
|
7 |
+
* @package FernleafSystems\Wordpress\Services\Utilities
|
8 |
+
*/
|
9 |
+
class HttpUtil {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* TODO: use HTTPRequest
|
13 |
+
* @param string $sUrl
|
14 |
+
* @param array $aValidResponseCodes
|
15 |
+
* @return $this
|
16 |
+
* @throws \Exception
|
17 |
+
*/
|
18 |
+
public function checkUrl( $sUrl, $aValidResponseCodes = [ 200 ] ) {
|
19 |
+
$aResponse = wp_remote_head( $sUrl );
|
20 |
+
if ( is_wp_error( $aResponse ) ) {
|
21 |
+
throw new \Exception( $aResponse->get_error_message() );
|
22 |
+
}
|
23 |
+
|
24 |
+
/** @var \WP_HTTP_Requests_Response $oResp */
|
25 |
+
$oResp = $aResponse[ 'http_response' ];
|
26 |
+
if ( !in_array( $oResp->get_response_object()->status_code, $aValidResponseCodes ) ) {
|
27 |
+
throw new \Exception( 'Head Request Failed. Likely the version does not exist.' );
|
28 |
+
}
|
29 |
+
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param string $sUrl
|
35 |
+
* @return string
|
36 |
+
* @throws \Exception
|
37 |
+
*/
|
38 |
+
public function downloadUrl( $sUrl ) {
|
39 |
+
/** @var string|\WP_Error $sFile */
|
40 |
+
$sFile = download_url( $sUrl );
|
41 |
+
if ( is_wp_error( $sFile ) ) {
|
42 |
+
throw new \Exception( $sFile->get_error_message() );
|
43 |
+
}
|
44 |
+
if ( !realpath( $sFile ) ) {
|
45 |
+
throw new \Exception( 'Downloaded could not be found' );
|
46 |
+
}
|
47 |
+
return $sFile;
|
48 |
+
}
|
49 |
+
}
|
@@ -46,7 +46,7 @@ class IpUtils {
|
|
46 |
*/
|
47 |
public static function checkIp( $requestIp, $ips ) {
|
48 |
if ( !is_array( $ips ) ) {
|
49 |
-
$ips =
|
50 |
}
|
51 |
$method = substr_count( $requestIp, ':' ) > 1 ? 'checkIp6' : 'checkIp4';
|
52 |
foreach ( $ips as $ip ) {
|
@@ -84,12 +84,12 @@ class IpUtils {
|
|
84 |
/**
|
85 |
* Compares two IPv6 addresses.
|
86 |
* In case a subnet is given, it checks if it contains the request IP.
|
87 |
-
* @author David Soria Parra <dsp at php dot net>
|
88 |
-
* @see https://github.com/dsp/v6tools
|
89 |
* @param string $requestIp IPv6 address to check
|
90 |
* @param string $ip IPv6 address or subnet in CIDR notation
|
91 |
* @return bool Whether the IP is valid
|
92 |
* @throws \Exception When IPV6 support is not enabled
|
|
|
|
|
93 |
*/
|
94 |
public static function checkIp6( $requestIp, $ip ) {
|
95 |
if ( !( ( extension_loaded( 'sockets' ) && defined( 'AF_INET6' ) ) || @inet_pton( '::1' ) ) ) {
|
@@ -350,17 +350,17 @@ class IpUtils {
|
|
350 |
}
|
351 |
}
|
352 |
|
353 |
-
return
|
354 |
'source' => $sSource,
|
355 |
'ip' => $sIpToReturn
|
356 |
-
|
357 |
}
|
358 |
|
359 |
/**
|
360 |
* @return string[]
|
361 |
*/
|
362 |
protected function getIpSourceOptions() {
|
363 |
-
return
|
364 |
'REMOTE_ADDR',
|
365 |
'HTTP_CF_CONNECTING_IP',
|
366 |
'HTTP_X_FORWARDED_FOR',
|
@@ -371,14 +371,14 @@ class IpUtils {
|
|
371 |
'HTTP_X_SP_FORWARDED_IP',
|
372 |
'HTTP_FORWARDED',
|
373 |
'HTTP_CLIENT_IP'
|
374 |
-
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
* @return string[]
|
379 |
*/
|
380 |
protected function getCloudFlareIpsV4() {
|
381 |
-
return
|
382 |
'103.21.244.0/22',
|
383 |
'103.22.200.0/22',
|
384 |
'103.31.4.0/22',
|
@@ -393,14 +393,14 @@ class IpUtils {
|
|
393 |
'190.93.240.0/20',
|
394 |
'197.234.240.0/22',
|
395 |
'198.41.128.0/17'
|
396 |
-
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* @return string[]
|
401 |
*/
|
402 |
protected function getCloudFlareIpsV6() {
|
403 |
-
return
|
404 |
'2400:cb00::/32',
|
405 |
'2405:8100::/32',
|
406 |
'2405:b500::/32',
|
@@ -408,7 +408,7 @@ class IpUtils {
|
|
408 |
'2803:f800::/32',
|
409 |
'2c0f:f248::/32',
|
410 |
'2a06:98c0::/29'
|
411 |
-
|
412 |
}
|
413 |
|
414 |
/**
|
@@ -424,7 +424,7 @@ class IpUtils {
|
|
424 |
* @return string[]
|
425 |
*/
|
426 |
public function getServiceIps_StatusCake() {
|
427 |
-
$aIps =
|
428 |
$aData = @json_decode( Services::HttpRequest()
|
429 |
->getContent( 'https://app.statuscake.com/Workfloor/Locations.php?format=json' ), true );
|
430 |
if ( is_array( $aData ) ) {
|
@@ -464,7 +464,7 @@ class IpUtils {
|
|
464 |
|
465 |
// We check the useragent if available
|
466 |
if ( is_null( $sUserAgent ) || stripos( $sUserAgent, 'DuckDuckBot' ) !== false ) {
|
467 |
-
$bIsBot = in_array( $sIp,
|
468 |
}
|
469 |
return $bIsBot;
|
470 |
}
|
46 |
*/
|
47 |
public static function checkIp( $requestIp, $ips ) {
|
48 |
if ( !is_array( $ips ) ) {
|
49 |
+
$ips = [ $ips ];
|
50 |
}
|
51 |
$method = substr_count( $requestIp, ':' ) > 1 ? 'checkIp6' : 'checkIp4';
|
52 |
foreach ( $ips as $ip ) {
|
84 |
/**
|
85 |
* Compares two IPv6 addresses.
|
86 |
* In case a subnet is given, it checks if it contains the request IP.
|
|
|
|
|
87 |
* @param string $requestIp IPv6 address to check
|
88 |
* @param string $ip IPv6 address or subnet in CIDR notation
|
89 |
* @return bool Whether the IP is valid
|
90 |
* @throws \Exception When IPV6 support is not enabled
|
91 |
+
* @author David Soria Parra <dsp at php dot net>
|
92 |
+
* @see https://github.com/dsp/v6tools
|
93 |
*/
|
94 |
public static function checkIp6( $requestIp, $ip ) {
|
95 |
if ( !( ( extension_loaded( 'sockets' ) && defined( 'AF_INET6' ) ) || @inet_pton( '::1' ) ) ) {
|
350 |
}
|
351 |
}
|
352 |
|
353 |
+
return [
|
354 |
'source' => $sSource,
|
355 |
'ip' => $sIpToReturn
|
356 |
+
];
|
357 |
}
|
358 |
|
359 |
/**
|
360 |
* @return string[]
|
361 |
*/
|
362 |
protected function getIpSourceOptions() {
|
363 |
+
return [
|
364 |
'REMOTE_ADDR',
|
365 |
'HTTP_CF_CONNECTING_IP',
|
366 |
'HTTP_X_FORWARDED_FOR',
|
371 |
'HTTP_X_SP_FORWARDED_IP',
|
372 |
'HTTP_FORWARDED',
|
373 |
'HTTP_CLIENT_IP'
|
374 |
+
];
|
375 |
}
|
376 |
|
377 |
/**
|
378 |
* @return string[]
|
379 |
*/
|
380 |
protected function getCloudFlareIpsV4() {
|
381 |
+
return [
|
382 |
'103.21.244.0/22',
|
383 |
'103.22.200.0/22',
|
384 |
'103.31.4.0/22',
|
393 |
'190.93.240.0/20',
|
394 |
'197.234.240.0/22',
|
395 |
'198.41.128.0/17'
|
396 |
+
];
|
397 |
}
|
398 |
|
399 |
/**
|
400 |
* @return string[]
|
401 |
*/
|
402 |
protected function getCloudFlareIpsV6() {
|
403 |
+
return [
|
404 |
'2400:cb00::/32',
|
405 |
'2405:8100::/32',
|
406 |
'2405:b500::/32',
|
408 |
'2803:f800::/32',
|
409 |
'2c0f:f248::/32',
|
410 |
'2a06:98c0::/29'
|
411 |
+
];
|
412 |
}
|
413 |
|
414 |
/**
|
424 |
* @return string[]
|
425 |
*/
|
426 |
public function getServiceIps_StatusCake() {
|
427 |
+
$aIps = [];
|
428 |
$aData = @json_decode( Services::HttpRequest()
|
429 |
->getContent( 'https://app.statuscake.com/Workfloor/Locations.php?format=json' ), true );
|
430 |
if ( is_array( $aData ) ) {
|
464 |
|
465 |
// We check the useragent if available
|
466 |
if ( is_null( $sUserAgent ) || stripos( $sUserAgent, 'DuckDuckBot' ) !== false ) {
|
467 |
+
$bIsBot = in_array( $sIp, [ '107.20.237.51', '23.21.226.191', '107.21.1.8', '54.208.102.37' ] );
|
468 |
}
|
469 |
return $bIsBot;
|
470 |
}
|
@@ -52,7 +52,6 @@ class VisitorIpDetection {
|
|
52 |
}
|
53 |
array_shift( $aHostIps );
|
54 |
$this->setPotentialHostIps( $aHostIps );
|
55 |
-
|
56 |
} while ( empty( $sIp ) );
|
57 |
|
58 |
return $sIp;
|
@@ -166,7 +165,7 @@ class VisitorIpDetection {
|
|
166 |
* @return string[]
|
167 |
*/
|
168 |
private function getIpSourceOptions() {
|
169 |
-
return
|
170 |
'REMOTE_ADDR',
|
171 |
'HTTP_CF_CONNECTING_IP',
|
172 |
'HTTP_X_FORWARDED_FOR',
|
@@ -177,6 +176,6 @@ class VisitorIpDetection {
|
|
177 |
'HTTP_X_SP_FORWARDED_IP',
|
178 |
'HTTP_FORWARDED',
|
179 |
'HTTP_CLIENT_IP'
|
180 |
-
|
181 |
}
|
182 |
}
|
52 |
}
|
53 |
array_shift( $aHostIps );
|
54 |
$this->setPotentialHostIps( $aHostIps );
|
|
|
55 |
} while ( empty( $sIp ) );
|
56 |
|
57 |
return $sIp;
|
165 |
* @return string[]
|
166 |
*/
|
167 |
private function getIpSourceOptions() {
|
168 |
+
return [
|
169 |
'REMOTE_ADDR',
|
170 |
'HTTP_CF_CONNECTING_IP',
|
171 |
'HTTP_X_FORWARDED_FOR',
|
176 |
'HTTP_X_SP_FORWARDED_IP',
|
177 |
'HTTP_FORWARDED',
|
178 |
'HTTP_CLIENT_IP'
|
179 |
+
];
|
180 |
}
|
181 |
}
|
@@ -31,7 +31,7 @@ class PluginUserMeta {
|
|
31 |
*/
|
32 |
static public function Load( $sPrefix, $nUserId = 0 ) {
|
33 |
if ( !is_array( self::$aMetas ) ) {
|
34 |
-
self::$aMetas =
|
35 |
}
|
36 |
if ( empty( $nUserId ) ) {
|
37 |
$nUserId = Services::WpUsers()->getCurrentWpUserId();
|
@@ -40,37 +40,33 @@ class PluginUserMeta {
|
|
40 |
throw new \Exception( 'Attempting to get meta of non-logged in user.' );
|
41 |
}
|
42 |
|
43 |
-
if ( !isset( self::$aMetas[ $nUserId ] ) ) {
|
44 |
-
|
45 |
}
|
46 |
|
47 |
-
return self::$aMetas[ $nUserId ];
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* @param
|
52 |
-
* @param int $nUserId
|
53 |
*/
|
54 |
-
public function
|
55 |
-
$
|
56 |
-
add_action( 'shutdown', array( $this, 'save' ) );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
*
|
61 |
-
* @param int
|
62 |
-
* @param int $nUserId
|
63 |
-
* @return $this
|
64 |
*/
|
65 |
-
|
66 |
$aStore = Services::WpUsers()->getUserMeta( $sPrefix.'-meta', $nUserId );
|
67 |
if ( !is_array( $aStore ) ) {
|
68 |
-
$aStore =
|
69 |
}
|
70 |
$this->applyFromArray( $aStore );
|
71 |
$this->prefix = $sPrefix;
|
72 |
$this->user_id = $nUserId;
|
73 |
-
|
74 |
}
|
75 |
|
76 |
/**
|
@@ -79,7 +75,7 @@ class PluginUserMeta {
|
|
79 |
public function delete() {
|
80 |
if ( $this->user_id > 0 ) {
|
81 |
Services::WpUsers()->deleteUserMeta( $this->getStorageKey(), $this->user_id );
|
82 |
-
remove_action( 'shutdown',
|
83 |
}
|
84 |
return $this;
|
85 |
}
|
31 |
*/
|
32 |
static public function Load( $sPrefix, $nUserId = 0 ) {
|
33 |
if ( !is_array( self::$aMetas ) ) {
|
34 |
+
self::$aMetas = [];
|
35 |
}
|
36 |
if ( empty( $nUserId ) ) {
|
37 |
$nUserId = Services::WpUsers()->getCurrentWpUserId();
|
40 |
throw new \Exception( 'Attempting to get meta of non-logged in user.' );
|
41 |
}
|
42 |
|
43 |
+
if ( !isset( self::$aMetas[ $sPrefix.$nUserId ] ) ) {
|
44 |
+
static::AddToCache( new static( $sPrefix, $nUserId ) );
|
45 |
}
|
46 |
|
47 |
+
return self::$aMetas[ $sPrefix.$nUserId ];
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @param static $oMeta
|
|
|
52 |
*/
|
53 |
+
static public function AddToCache( $oMeta ) {
|
54 |
+
self::$aMetas[ $oMeta->prefix.$oMeta->user_id ] = $oMeta;
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* @param string $sPrefix
|
59 |
+
* @param int $nUserId
|
|
|
|
|
60 |
*/
|
61 |
+
public function __construct( $sPrefix, $nUserId = 0 ) {
|
62 |
$aStore = Services::WpUsers()->getUserMeta( $sPrefix.'-meta', $nUserId );
|
63 |
if ( !is_array( $aStore ) ) {
|
64 |
+
$aStore = [];
|
65 |
}
|
66 |
$this->applyFromArray( $aStore );
|
67 |
$this->prefix = $sPrefix;
|
68 |
$this->user_id = $nUserId;
|
69 |
+
add_action( 'shutdown', [ $this, 'save' ] );
|
70 |
}
|
71 |
|
72 |
/**
|
75 |
public function delete() {
|
76 |
if ( $this->user_id > 0 ) {
|
77 |
Services::WpUsers()->deleteUserMeta( $this->getStorageKey(), $this->user_id );
|
78 |
+
remove_action( 'shutdown', [ $this, 'save' ] );
|
79 |
}
|
80 |
return $this;
|
81 |
}
|
@@ -106,7 +106,7 @@ class Render {
|
|
106 |
* @return $this
|
107 |
*/
|
108 |
public function clearRenderVars() {
|
109 |
-
return $this->setRenderVars(
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -115,10 +115,10 @@ class Render {
|
|
115 |
protected function getTwigEnvironment() {
|
116 |
return new \Twig_Environment(
|
117 |
new \Twig_Loader_Filesystem( $this->getTemplateRoots() ),
|
118 |
-
|
119 |
'debug' => true,
|
120 |
'strict_variables' => true,
|
121 |
-
|
122 |
);
|
123 |
}
|
124 |
|
@@ -135,11 +135,11 @@ class Render {
|
|
135 |
*/
|
136 |
public function getTemplateEngine() {
|
137 |
if ( !isset( $this->nTemplateEngine )
|
138 |
-
|| !in_array( $this->nTemplateEngine,
|
139 |
self::TEMPLATE_ENGINE_TWIG,
|
140 |
self::TEMPLATE_ENGINE_PHP,
|
141 |
self::TEMPLATE_ENGINE_HTML
|
142 |
-
|
143 |
$this->nTemplateEngine = self::TEMPLATE_ENGINE_PHP;
|
144 |
}
|
145 |
return $this->nTemplateEngine;
|
@@ -187,17 +187,16 @@ class Render {
|
|
187 |
*/
|
188 |
private function getTemplateRootsPlain() {
|
189 |
if ( !is_array( $this->aTemplateRoots ) ) {
|
190 |
-
$this->aTemplateRoots =
|
191 |
}
|
192 |
return $this->aTemplateRoots;
|
193 |
}
|
194 |
|
195 |
-
|
196 |
/**
|
197 |
* @return array
|
198 |
*/
|
199 |
public function getRenderVars() {
|
200 |
-
return is_array( $this->aRenderVars ) ? $this->aRenderVars :
|
201 |
}
|
202 |
|
203 |
/**
|
106 |
* @return $this
|
107 |
*/
|
108 |
public function clearRenderVars() {
|
109 |
+
return $this->setRenderVars( [] );
|
110 |
}
|
111 |
|
112 |
/**
|
115 |
protected function getTwigEnvironment() {
|
116 |
return new \Twig_Environment(
|
117 |
new \Twig_Loader_Filesystem( $this->getTemplateRoots() ),
|
118 |
+
[
|
119 |
'debug' => true,
|
120 |
'strict_variables' => true,
|
121 |
+
]
|
122 |
);
|
123 |
}
|
124 |
|
135 |
*/
|
136 |
public function getTemplateEngine() {
|
137 |
if ( !isset( $this->nTemplateEngine )
|
138 |
+
|| !in_array( $this->nTemplateEngine, [
|
139 |
self::TEMPLATE_ENGINE_TWIG,
|
140 |
self::TEMPLATE_ENGINE_PHP,
|
141 |
self::TEMPLATE_ENGINE_HTML
|
142 |
+
] ) ) {
|
143 |
$this->nTemplateEngine = self::TEMPLATE_ENGINE_PHP;
|
144 |
}
|
145 |
return $this->nTemplateEngine;
|
187 |
*/
|
188 |
private function getTemplateRootsPlain() {
|
189 |
if ( !is_array( $this->aTemplateRoots ) ) {
|
190 |
+
$this->aTemplateRoots = [];
|
191 |
}
|
192 |
return $this->aTemplateRoots;
|
193 |
}
|
194 |
|
|
|
195 |
/**
|
196 |
* @return array
|
197 |
*/
|
198 |
public function getRenderVars() {
|
199 |
+
return is_array( $this->aRenderVars ) ? $this->aRenderVars : [];
|
200 |
}
|
201 |
|
202 |
/**
|
@@ -43,10 +43,10 @@ class ServiceProviders {
|
|
43 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_cloudflare' );
|
44 |
$aIps = $oWp->getTransient( $sStoreKey );
|
45 |
if ( empty( $aIps ) ) {
|
46 |
-
$aIps =
|
47 |
4 => $this->downloadServiceIps_Cloudflare( 4 ),
|
48 |
6 => $this->downloadServiceIps_Cloudflare( 6 )
|
49 |
-
|
50 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
51 |
}
|
52 |
return $aIps;
|
@@ -72,7 +72,7 @@ class ServiceProviders {
|
|
72 |
* @return string[]
|
73 |
*/
|
74 |
public function getIps_DuckDuckGo() {
|
75 |
-
return
|
76 |
}
|
77 |
|
78 |
/**
|
@@ -117,10 +117,10 @@ class ServiceProviders {
|
|
117 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_pingdom' );
|
118 |
$aIps = $oWp->getTransient( $sStoreKey );
|
119 |
if ( empty( $aIps ) ) {
|
120 |
-
$aIps =
|
121 |
4 => $this->downloadServiceIps_Pingdom( 4 ),
|
122 |
6 => $this->downloadServiceIps_Pingdom( 6 )
|
123 |
-
|
124 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
125 |
}
|
126 |
return $bFlat ? array_merge( $aIps[ 4 ], $aIps[ 6 ] ) : $aIps;
|
@@ -160,10 +160,10 @@ class ServiceProviders {
|
|
160 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_uptimerobot' );
|
161 |
$aIps = $oWp->getTransient( $sStoreKey );
|
162 |
if ( empty( $aIps ) ) {
|
163 |
-
$aIps =
|
164 |
4 => $this->downloadServiceIps_UptimeRobot( 4 ),
|
165 |
6 => $this->downloadServiceIps_UptimeRobot( 6 )
|
166 |
-
|
167 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
168 |
}
|
169 |
return $bFlat ? array_merge( $aIps[ 4 ], $aIps[ 6 ] ) : $aIps;
|
@@ -504,7 +504,7 @@ class ServiceProviders {
|
|
504 |
*/
|
505 |
private function downloadServiceIps_Standard( $sSourceUrl, $sIpVersion = null ) {
|
506 |
if ( !is_null( $sIpVersion ) ) {
|
507 |
-
if ( !in_array( (int)$sIpVersion,
|
508 |
$sIpVersion = 4;
|
509 |
}
|
510 |
$sSourceUrl = Services::HttpRequest()->getContent( sprintf( $sSourceUrl, $sIpVersion ) );
|
43 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_cloudflare' );
|
44 |
$aIps = $oWp->getTransient( $sStoreKey );
|
45 |
if ( empty( $aIps ) ) {
|
46 |
+
$aIps = [
|
47 |
4 => $this->downloadServiceIps_Cloudflare( 4 ),
|
48 |
6 => $this->downloadServiceIps_Cloudflare( 6 )
|
49 |
+
];
|
50 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
51 |
}
|
52 |
return $aIps;
|
72 |
* @return string[]
|
73 |
*/
|
74 |
public function getIps_DuckDuckGo() {
|
75 |
+
return [ '107.20.237.51', '23.21.226.191', '107.21.1.8', '54.208.102.37' ];
|
76 |
}
|
77 |
|
78 |
/**
|
117 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_pingdom' );
|
118 |
$aIps = $oWp->getTransient( $sStoreKey );
|
119 |
if ( empty( $aIps ) ) {
|
120 |
+
$aIps = [
|
121 |
4 => $this->downloadServiceIps_Pingdom( 4 ),
|
122 |
6 => $this->downloadServiceIps_Pingdom( 6 )
|
123 |
+
];
|
124 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
125 |
}
|
126 |
return $bFlat ? array_merge( $aIps[ 4 ], $aIps[ 6 ] ) : $aIps;
|
160 |
$sStoreKey = $this->getPrefixedStoreKey( 'serviceips_uptimerobot' );
|
161 |
$aIps = $oWp->getTransient( $sStoreKey );
|
162 |
if ( empty( $aIps ) ) {
|
163 |
+
$aIps = [
|
164 |
4 => $this->downloadServiceIps_UptimeRobot( 4 ),
|
165 |
6 => $this->downloadServiceIps_UptimeRobot( 6 )
|
166 |
+
];
|
167 |
$oWp->setTransient( $sStoreKey, $aIps, WEEK_IN_SECONDS*4 );
|
168 |
}
|
169 |
return $bFlat ? array_merge( $aIps[ 4 ], $aIps[ 6 ] ) : $aIps;
|
504 |
*/
|
505 |
private function downloadServiceIps_Standard( $sSourceUrl, $sIpVersion = null ) {
|
506 |
if ( !is_null( $sIpVersion ) ) {
|
507 |
+
if ( !in_array( (int)$sIpVersion, [ 4, 6 ] ) ) {
|
508 |
$sIpVersion = 4;
|
509 |
}
|
510 |
$sSourceUrl = Services::HttpRequest()->getContent( sprintf( $sSourceUrl, $sIpVersion ) );
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class RepoBase
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base
|
10 |
+
*/
|
11 |
+
abstract class RepoBase {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string[]
|
15 |
+
*/
|
16 |
+
private $aDownloadedFiles;
|
17 |
+
|
18 |
+
public function __construct() {
|
19 |
+
$this->autoDelete();
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Must be setup when the object is instantiated ie constructor
|
24 |
+
*/
|
25 |
+
protected function autoDelete() {
|
26 |
+
add_action( 'shutdown', function () {
|
27 |
+
$oFs = Services\Services::WpFs();
|
28 |
+
foreach ( $this->getDownloadedFiles() as $sFile ) {
|
29 |
+
if ( $oFs->exists( $sFile ) ) {
|
30 |
+
$oFs->deleteFile( $sFile );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
} );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param string $sFileFragment
|
38 |
+
* @param string $sVersion
|
39 |
+
* @param bool $bUseSiteLocale
|
40 |
+
* @return string|null
|
41 |
+
*/
|
42 |
+
public function downloadFromVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
43 |
+
$sUrl = $this->getVcsUrlForFileAndVersion( $sFileFragment, $sVersion, $bUseSiteLocale );
|
44 |
+
try {
|
45 |
+
$sTmpFile = ( new Services\Utilities\HttpUtil() )
|
46 |
+
->checkUrl( $sUrl )
|
47 |
+
->downloadUrl( $sUrl );
|
48 |
+
$this->addToDownloadedFiles( $sTmpFile );
|
49 |
+
}
|
50 |
+
catch ( \Exception $oE ) {
|
51 |
+
$sTmpFile = null;
|
52 |
+
}
|
53 |
+
return $sTmpFile;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param string $sFileFragment - path relative to the root dir of the object being tested. E.g. ABSPATH for
|
58 |
+
* WordPress or the plugin dir if it's a plugin.
|
59 |
+
* @param string $sVersion - leave empty to use the current version
|
60 |
+
* @param bool $bUseSiteLocale
|
61 |
+
* @return bool
|
62 |
+
*/
|
63 |
+
public function existsInVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
64 |
+
$sUrl = $this->getVcsUrlForFileAndVersion( $sFileFragment, $sVersion, $bUseSiteLocale );
|
65 |
+
try {
|
66 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( $sUrl );
|
67 |
+
$bExists = true;
|
68 |
+
}
|
69 |
+
catch ( \Exception $oE ) {
|
70 |
+
$bExists = false;
|
71 |
+
}
|
72 |
+
return $bExists;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param string $sFileFragment
|
77 |
+
* @param string $sVersion
|
78 |
+
* @param bool $bUseSiteLocale
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
abstract protected function getVcsUrlForFileAndVersion( $sFileFragment, $sVersion, $bUseSiteLocale = true );
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param string $sFile
|
85 |
+
* @return $this
|
86 |
+
*/
|
87 |
+
private function addToDownloadedFiles( $sFile ) {
|
88 |
+
$aFiles = $this->getDownloadedFiles();
|
89 |
+
$aFiles[] = $sFile;
|
90 |
+
$this->aDownloadedFiles = $aFiles;
|
91 |
+
return $this;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @return string[]
|
96 |
+
*/
|
97 |
+
private function getDownloadedFiles() {
|
98 |
+
if ( !is_array( $this->aDownloadedFiles ) ) {
|
99 |
+
$this->aDownloadedFiles = [];
|
100 |
+
}
|
101 |
+
return array_filter( $this->aDownloadedFiles );
|
102 |
+
}
|
103 |
+
}
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class VersionsBase
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Base
|
10 |
+
*/
|
11 |
+
abstract class VersionsBase {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var string[]
|
15 |
+
*/
|
16 |
+
private $aWpVersions;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @return string[]
|
20 |
+
*/
|
21 |
+
public function all() {
|
22 |
+
if ( empty( $this->aWpVersions ) ) {
|
23 |
+
$this->aWpVersions = $this->downloadVersions();
|
24 |
+
usort( $this->aWpVersions, 'version_compare' );
|
25 |
+
}
|
26 |
+
return $this->aWpVersions;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $sVersionBranch - leave empty to use the current WP Version
|
31 |
+
* @return string
|
32 |
+
* @throws \Exception
|
33 |
+
*/
|
34 |
+
public function getLatestVersionForBranch( $sVersionBranch = null ) {
|
35 |
+
if ( empty( $sVersionBranch ) ) {
|
36 |
+
$sVersionBranch = Services\Services::WpGeneral()->getVersion();
|
37 |
+
}
|
38 |
+
$aParts = explode( '.', $sVersionBranch );
|
39 |
+
if ( count( $aParts ) < 2 ) {
|
40 |
+
throw new \Exception( sprintf( 'Invalid version "%s" provided.', $sVersionBranch ) );
|
41 |
+
}
|
42 |
+
|
43 |
+
$sThisBranch = $aParts[ 0 ].'.'.$aParts[ 1 ];
|
44 |
+
|
45 |
+
$aPossible = array_filter(
|
46 |
+
$this->all(),
|
47 |
+
function ( $sVersion ) use ( $sThisBranch ) {
|
48 |
+
return strpos( $sVersion, $sThisBranch ) === 0;
|
49 |
+
}
|
50 |
+
);
|
51 |
+
return end( $aPossible );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function latest() {
|
58 |
+
$aVs = $this->all();
|
59 |
+
return end( $aVs );
|
60 |
+
}
|
61 |
+
|
62 |
+
abstract protected function downloadVersions();
|
63 |
+
}
|
@@ -4,6 +4,11 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
class Core {
|
8 |
|
9 |
const URL_SVN_ROOT = 'https://core.svn.wordpress.org';
|
@@ -60,7 +65,7 @@ class Core {
|
|
60 |
* @return array
|
61 |
*/
|
62 |
protected function downloadVersions() {
|
63 |
-
$aV =
|
64 |
$sSvnVersionsContent = Services::HttpRequest()->getContent(
|
65 |
sprintf( '%s/%s/', static::URL_SVN_ROOT, 'tags' )
|
66 |
);
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
7 |
+
/**
|
8 |
+
* @deprecated
|
9 |
+
* Class Core
|
10 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg
|
11 |
+
*/
|
12 |
class Core {
|
13 |
|
14 |
const URL_SVN_ROOT = 'https://core.svn.wordpress.org';
|
65 |
* @return array
|
66 |
*/
|
67 |
protected function downloadVersions() {
|
68 |
+
$aV = [];
|
69 |
$sSvnVersionsContent = Services::HttpRequest()->getContent(
|
70 |
sprintf( '%s/%s/', static::URL_SVN_ROOT, 'tags' )
|
71 |
);
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Files
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp
|
10 |
+
*/
|
11 |
+
class Files extends Services\Utilities\WpOrg\Wp\Files {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param string $sFilePath
|
15 |
+
* @return string|null
|
16 |
+
* @throws \InvalidArgumentException
|
17 |
+
*/
|
18 |
+
public function getOriginalFileFromVcs( $sFilePath ) {
|
19 |
+
$sTmpFile = null;
|
20 |
+
$oHashes = Services\Services::CoreFileHashes();
|
21 |
+
if ( !$oHashes->isCoreFile( $sFilePath ) ) {
|
22 |
+
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
23 |
+
}
|
24 |
+
return ( new Repo() )->downloadFromVcs( $oHashes->getFileFragment( $sFilePath ) );
|
25 |
+
}
|
26 |
+
}
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Repo
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp
|
10 |
+
*/
|
11 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
12 |
+
|
13 |
+
const URL_VCS_ROOT = 'https://raw.githubusercontent.com/ClassicPress/ClassicPress-release';
|
14 |
+
const URL_VCS_ROOT_IL8N = self::URL_VCS_ROOT;
|
15 |
+
const URL_VCS_VERSIONS = 'https://api.github.com/repos/ClassicPress/ClassicPress-release/releases';
|
16 |
+
const URL_VCS_VERSION = 'https://github.com/ClassicPress/ClassicPress-release/releases/tag';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param string $sVersion
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
static public function GetUrlForVersion( $sVersion ) {
|
23 |
+
return sprintf( '%s/%s', static::URL_VCS_VERSION, $sVersion );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string $sVersion
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
static public function GetUrlForFiles( $sVersion ) {
|
31 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $sVersion );
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
static public function GetUrlForVersions() {
|
38 |
+
return static::URL_VCS_VERSIONS;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param string $sFileFragment
|
43 |
+
* @param string $sVersion
|
44 |
+
* @param bool $bUseSiteLocale
|
45 |
+
* @return string|null
|
46 |
+
*/
|
47 |
+
public function downloadFromVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
48 |
+
$sFile = parent::downloadFromVcs( $sFileFragment, $sVersion, $bUseSiteLocale );
|
49 |
+
if ( $bUseSiteLocale && empty( $sFile ) ) {
|
50 |
+
$sFile = parent::downloadFromVcs( $sFileFragment, $sVersion, false );
|
51 |
+
}
|
52 |
+
return $sFile;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $sFileFragment
|
57 |
+
* @param string $sVersion - leave empty to use the current version
|
58 |
+
* @param bool $bUseSiteLocale
|
59 |
+
* @return bool
|
60 |
+
*/
|
61 |
+
public function existsInVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
62 |
+
$sFile = parent::existsInVcs( $sFileFragment, $sVersion, $bUseSiteLocale );
|
63 |
+
if ( $bUseSiteLocale && empty( $sFile ) ) {
|
64 |
+
$sFile = parent::existsInVcs( $sFileFragment, $sVersion, false );
|
65 |
+
}
|
66 |
+
return $sFile;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @param string $sFileFragment
|
71 |
+
* @param string $sVersion
|
72 |
+
* @param bool $bUseSiteLocale - not yet used for ClassicPress
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
protected function getVcsUrlForFileAndVersion( $sFileFragment, $sVersion, $bUseSiteLocale = true ) {
|
76 |
+
if ( empty( $sVersion ) ) {
|
77 |
+
$sVersion = Services\Services::WpGeneral()->getVersion();
|
78 |
+
}
|
79 |
+
return sprintf( '%s/%s', static::GetUrlForFiles( $sVersion ), ltrim( $sFileFragment, '/' ) );
|
80 |
+
}
|
81 |
+
}
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Versions
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Cp
|
10 |
+
*/
|
11 |
+
class Versions extends Services\Utilities\WpOrg\Base\VersionsBase {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param string $sVersion
|
15 |
+
* @param bool $bVerifyUrl
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
public function exists( $sVersion, $bVerifyUrl = false ) {
|
19 |
+
$bExists = in_array( $sVersion, $this->all() );
|
20 |
+
if ( $bExists && $bVerifyUrl ) {
|
21 |
+
try {
|
22 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $sVersion ) );
|
23 |
+
}
|
24 |
+
catch ( \Exception $oE ) {
|
25 |
+
$bExists = false;
|
26 |
+
};
|
27 |
+
}
|
28 |
+
return $bExists;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
protected function downloadVersions() {
|
35 |
+
$aV = [];
|
36 |
+
$aVersions = @json_decode( Services\Services::HttpRequest()
|
37 |
+
->getContent( Repo::GetUrlForVersions() ), true );
|
38 |
+
if ( is_array( $aVersions ) ) {
|
39 |
+
$aV = array_map(
|
40 |
+
function ( $aVersData ) {
|
41 |
+
return $aVersData[ 'tag_name' ];
|
42 |
+
},
|
43 |
+
$aVersions
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
return $aV;
|
48 |
+
}
|
49 |
+
}
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Utilities\Data\Adapter\StdClassAdapter;
|
6 |
+
use FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin\VOs\PluginInfoVO;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Api
|
10 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
11 |
+
* @property array $fields
|
12 |
+
*/
|
13 |
+
class Api {
|
14 |
+
|
15 |
+
use Base,
|
16 |
+
StdClassAdapter;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @return PluginInfoVO
|
20 |
+
* @throws \Exception
|
21 |
+
*/
|
22 |
+
public function getPluginInfo() {
|
23 |
+
return $this->run( 'plugin_information' );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string $sCmd
|
28 |
+
* @return PluginInfoVO
|
29 |
+
* @throws \Exception
|
30 |
+
*/
|
31 |
+
public function run( $sCmd ) {
|
32 |
+
include_once( ABSPATH.'wp-admin/includes/plugin-install.php' );
|
33 |
+
|
34 |
+
$aParams = $this->getRawDataAsArray();
|
35 |
+
$aParams[ 'slug' ] = $this->getWorkingSlug();
|
36 |
+
$oResponse = \plugins_api( $sCmd, $aParams );
|
37 |
+
|
38 |
+
if ( \is_wp_error( $oResponse ) ) {
|
39 |
+
throw new \Exception( sprintf( '[PluginsApi Error] %s', $oResponse->get_error_message() ) );
|
40 |
+
}
|
41 |
+
else if ( !\is_object( $oResponse ) ) {
|
42 |
+
throw new \Exception( sprintf( '[PluginsApi Error] %s', 'Did not return an expected Object' ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
return ( new PluginInfoVO() )->applyFromArray( (array)$oResponse );
|
46 |
+
}
|
47 |
+
}
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Base
|
7 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
8 |
+
*/
|
9 |
+
trait Base {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
private $sWorkingPluginSlug;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getWorkingSlug() {
|
20 |
+
return $this->sWorkingPluginSlug;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param string $sSlug
|
25 |
+
* @return $this
|
26 |
+
*/
|
27 |
+
public function setWorkingSlug( $sSlug ) {
|
28 |
+
$this->sWorkingPluginSlug = $sSlug;
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
}
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
6 |
+
|
7 |
+
class Download {
|
8 |
+
|
9 |
+
use Base;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return string|null
|
13 |
+
* @throws \Exception
|
14 |
+
*/
|
15 |
+
public function latest() {
|
16 |
+
try {
|
17 |
+
$sUrl = ( new Api() )
|
18 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
19 |
+
->getPluginInfo()
|
20 |
+
->download_link;
|
21 |
+
$sTmpFile = ( new HttpUtil() )->downloadUrl( $sUrl );
|
22 |
+
}
|
23 |
+
catch ( \Exception $oE ) {
|
24 |
+
$sTmpFile = null;
|
25 |
+
}
|
26 |
+
return $sTmpFile;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $sVersion
|
31 |
+
* @return string
|
32 |
+
* @throws \Exception
|
33 |
+
*/
|
34 |
+
public function version( $sVersion ) {
|
35 |
+
$sTmpFile = null;
|
36 |
+
try {
|
37 |
+
$aVersions = ( new Api() )
|
38 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
39 |
+
->getPluginInfo()
|
40 |
+
->versions;
|
41 |
+
if ( !empty( $aVersions[ $sVersion ] ) ) {
|
42 |
+
$sTmpFile = ( new HttpUtil() )->downloadUrl( $aVersions[ $sVersion ] );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
catch ( \Exception $oE ) {
|
46 |
+
}
|
47 |
+
return $sTmpFile;
|
48 |
+
}
|
49 |
+
}
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Files
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
10 |
+
*/
|
11 |
+
class Files {
|
12 |
+
|
13 |
+
use Base;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Given a full root path on the file system for a file, locate the plugin to which this file belongs.
|
17 |
+
* @param string $sFullFilePath
|
18 |
+
* @return Services\Core\VOs\WpPluginVo|null
|
19 |
+
*/
|
20 |
+
public function findPluginFromFile( $sFullFilePath ) {
|
21 |
+
$oThePlugin = null;
|
22 |
+
|
23 |
+
$sFragment = $this->getPluginPathFragmentFromPath( $sFullFilePath );
|
24 |
+
$oWpPlugins = Services\Services::WpPlugins();
|
25 |
+
|
26 |
+
if ( !empty( $sFragment ) && strpos( $sFragment, '/' ) > 0 ) {
|
27 |
+
list( $sThisPluginDir, $sPluginPathFragment ) = explode( '/', $sFragment, 2 );
|
28 |
+
foreach ( $oWpPlugins->getInstalledPluginFiles() as $sPluginFile ) {
|
29 |
+
if ( $sThisPluginDir == dirname( $sPluginFile ) ) {
|
30 |
+
$oThePlugin = $oWpPlugins->getPluginAsVo( $sPluginFile );
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return $oThePlugin;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
40 |
+
* @param string $sFullFilePath
|
41 |
+
* @return bool
|
42 |
+
* @throws \InvalidArgumentException
|
43 |
+
*/
|
44 |
+
public function isValidFileFromPlugin( $sFullFilePath ) {
|
45 |
+
|
46 |
+
$oThePlugin = $this->findPluginFromFile( $sFullFilePath );
|
47 |
+
if ( !$oThePlugin instanceof Services\Core\VOs\WpPluginVo ) {
|
48 |
+
throw new \InvalidArgumentException( 'Not actually a plugin file.', 1 );
|
49 |
+
}
|
50 |
+
if ( !$oThePlugin->isWpOrg() ) {
|
51 |
+
throw new \InvalidArgumentException( 'Not a WordPress.org plugin.', 2 );
|
52 |
+
}
|
53 |
+
|
54 |
+
return ( new Repo() )
|
55 |
+
->setWorkingSlug( $oThePlugin->slug )
|
56 |
+
->existsInVcs( $this->getRelativeFilePathFromItsPluginDir( $sFullFilePath ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param string $sFullFilePath
|
61 |
+
* @return bool
|
62 |
+
* @throws \InvalidArgumentException
|
63 |
+
*/
|
64 |
+
public function replaceFileFromVcs( $sFullFilePath ) {
|
65 |
+
$sTmpFile = $this->getOriginalFileFromVcs( $sFullFilePath );
|
66 |
+
return !empty( $sTmpFile ) && Services\Services::WpFs()->move( $sTmpFile, $sFullFilePath );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
71 |
+
* @param string $sFullFilePath
|
72 |
+
* @return bool
|
73 |
+
* @throws \InvalidArgumentException - not actually a plugin file / not a WordPress.org plugin
|
74 |
+
*/
|
75 |
+
public function verifyFileContents( $sFullFilePath ) {
|
76 |
+
$bVerified = false;
|
77 |
+
if ( $this->isValidFileFromPlugin( $sFullFilePath ) ) {
|
78 |
+
$sTmpFile = $this->getOriginalFileFromVcs( $sFullFilePath );
|
79 |
+
if ( !empty( $sTmpFile ) ) {
|
80 |
+
$bVerified = $this->getOriginalFileMd5FromVcs( $sFullFilePath ) === md5_file( $sFullFilePath );
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return $bVerified;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @param string $sFullFilePath
|
88 |
+
* @return string|null
|
89 |
+
* @throws \InvalidArgumentException
|
90 |
+
*/
|
91 |
+
public function getOriginalFileFromVcs( $sFullFilePath ) {
|
92 |
+
$sTmpFile = null;
|
93 |
+
if ( $this->isValidFileFromPlugin( $sFullFilePath ) ) {
|
94 |
+
$oThePlugin = $this->findPluginFromFile( $sFullFilePath );
|
95 |
+
$sTmpFile = ( new Repo() )
|
96 |
+
->setWorkingSlug( $oThePlugin->slug )
|
97 |
+
->downloadFromVcs( $this->getRelativeFilePathFromItsPluginDir( $sFullFilePath ) );
|
98 |
+
}
|
99 |
+
return $sTmpFile;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @param string $sFullFilePath
|
104 |
+
* @return string
|
105 |
+
* @throws \InvalidArgumentException
|
106 |
+
*/
|
107 |
+
public function getOriginalFileMd5FromVcs( $sFullFilePath ) {
|
108 |
+
$sFile = $this->getOriginalFileFromVcs( $sFullFilePath );
|
109 |
+
return empty( $sFile ) ? null : md5_file( $sFile );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param string $sFile - can either be absolute, or relative to ABSPATH
|
114 |
+
* @return string|null - the path to the file relative to Plugins Dir.
|
115 |
+
*/
|
116 |
+
public function getPluginPathFragmentFromPath( $sFile ) {
|
117 |
+
$sFragment = null;
|
118 |
+
|
119 |
+
if ( !path_is_absolute( $sFile ) ) { // assume it's relative to ABSPATH
|
120 |
+
$sFile = path_join( ABSPATH, $sFile );
|
121 |
+
}
|
122 |
+
$sFile = wp_normalize_path( $sFile );
|
123 |
+
$sPluginsDir = wp_normalize_path( WP_PLUGIN_DIR );
|
124 |
+
|
125 |
+
if ( strpos( $sFile, $sPluginsDir ) === 0 ) {
|
126 |
+
$sFragment = ltrim( str_replace( $sPluginsDir, '', $sFile ), '/' );
|
127 |
+
}
|
128 |
+
|
129 |
+
return $sFragment;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Gets the path of the plugin file relative to its own home plugin dir. (not wp-content/plugins/)
|
134 |
+
* @param string $sFile
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
private function getRelativeFilePathFromItsPluginDir( $sFile ) {
|
138 |
+
$sPluginsDirFragment = $this->getPluginPathFragmentFromPath( $sFile );
|
139 |
+
list( $sThisPluginDir, $sPluginPathFragment ) = explode( '/', $sPluginsDirFragment, 2 );
|
140 |
+
return $sPluginPathFragment;
|
141 |
+
}
|
142 |
+
}
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Repo
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
10 |
+
*/
|
11 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
12 |
+
|
13 |
+
use Base;
|
14 |
+
const URL_VCS_ROOT = 'https://plugins.svn.wordpress.org';
|
15 |
+
const URL_VCS_DOWNLOAD_VERSIONS = 'https://plugins.svn.wordpress.org/%s/tags/';
|
16 |
+
const URL_DOWNLOAD_SVN_FILE = 'https://plugins.svn.wordpress.org/%s/tags/%s/%s';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param string $sSlug
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
static public function GetUrlForPlugin( $sSlug ) {
|
23 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $sSlug );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string $sSlug
|
28 |
+
* @param string $sVersion
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
static public function GetUrlForPluginVersion( $sSlug, $sVersion ) {
|
32 |
+
return sprintf( '%s/tags/%s', static::GetUrlForPlugin( $sSlug ), $sVersion );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param string $sSlug
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
static public function GetUrlForPluginVersions( $sSlug ) {
|
40 |
+
return static::GetUrlForPluginVersion( $sSlug, '' );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $sFileFragment - relative to the working plugin directory
|
45 |
+
* @param string $sVersion
|
46 |
+
* @param bool $bUseSiteLocale - unused
|
47 |
+
* @return string
|
48 |
+
* @throws \Exception
|
49 |
+
*/
|
50 |
+
protected function getVcsUrlForFileAndVersion( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
51 |
+
if ( empty( $sFileFragment ) ) {
|
52 |
+
throw new \InvalidArgumentException( 'Plugin file fragment path provided is empty' );
|
53 |
+
}
|
54 |
+
if ( empty( $sVersion ) ) {
|
55 |
+
$sVersion = ( new Versions() )
|
56 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
57 |
+
->latest();
|
58 |
+
}
|
59 |
+
return sprintf( '%s/%s',
|
60 |
+
static::GetUrlForPluginVersion( $this->getWorkingSlug(), $sVersion ), ltrim( $sFileFragment, '/' ) );
|
61 |
+
}
|
62 |
+
}
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin\VOs;
|
4 |
+
|
5 |
+
use FernleafSystems\Utilities\Data\Adapter\StdClassAdapter;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class PluginInfoVO
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin\VOs
|
10 |
+
* @property string name
|
11 |
+
* @property string slug
|
12 |
+
* @property string version
|
13 |
+
* @property string author - a href link
|
14 |
+
* @property string author_profile - URL
|
15 |
+
* @property array contributors
|
16 |
+
* @property string requires
|
17 |
+
* @property string tested
|
18 |
+
* @property string requires_php
|
19 |
+
* @property int rating
|
20 |
+
* @property array ratings
|
21 |
+
* @property int num_ratings
|
22 |
+
* @property int support_threads
|
23 |
+
* @property int support_threads_resolved
|
24 |
+
* @property int active_installs
|
25 |
+
* @property string last_updated
|
26 |
+
* @property string added - YYYY-MM-DD
|
27 |
+
* @property string homepage - URL
|
28 |
+
* @property array sections
|
29 |
+
* @property string download_link
|
30 |
+
* @property array screenshots
|
31 |
+
* @property array tags
|
32 |
+
* @property array versions - key: versions; value: URL to ZIP
|
33 |
+
*/
|
34 |
+
class PluginInfoVO {
|
35 |
+
|
36 |
+
use StdClassAdapter;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @return float
|
40 |
+
*/
|
41 |
+
public function getNetPromoterScore() {
|
42 |
+
$aRs = $this->ratings;
|
43 |
+
return ( $aRs[ 5 ] - ( $aRs[ 1 ] + $aRs[ 2 ] + $aRs[ 3 ] ) )/array_sum( $aRs );
|
44 |
+
}
|
45 |
+
}
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services\Services;
|
6 |
+
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
7 |
+
|
8 |
+
class Versions {
|
9 |
+
|
10 |
+
use Base;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string[]
|
14 |
+
*/
|
15 |
+
public function allFallback() {
|
16 |
+
$aV = [];
|
17 |
+
$sSvnVersionsContent = Services::HttpRequest()
|
18 |
+
->getContent( Repo::GetUrlForPluginVersions( $this->getWorkingSlug() ) );
|
19 |
+
|
20 |
+
if ( !empty( $sSvnVersionsContent ) ) {
|
21 |
+
$oSvnDom = new \DOMDocument();
|
22 |
+
$oSvnDom->loadHTML( $sSvnVersionsContent );
|
23 |
+
|
24 |
+
foreach ( $oSvnDom->getElementsByTagName( 'a' ) as $oElem ) {
|
25 |
+
/** @var \DOMElement $oElem */
|
26 |
+
$sHref = $oElem->getAttribute( 'href' );
|
27 |
+
if ( $sHref != '../' && !filter_var( $sHref, FILTER_VALIDATE_URL ) ) {
|
28 |
+
$aV[] = trim( $sHref, '/' );
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
return $aV;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string[]
|
37 |
+
*/
|
38 |
+
public function all() {
|
39 |
+
try {
|
40 |
+
$oInfo = ( new Api() )
|
41 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
42 |
+
->getPluginInfo();
|
43 |
+
|
44 |
+
if ( !empty( $oInfo->versions ) ) {
|
45 |
+
$aVersions = array_filter(
|
46 |
+
array_keys( $oInfo->versions ),
|
47 |
+
function ( $sVersion ) {
|
48 |
+
return strpos( $sVersion, '.' );
|
49 |
+
}
|
50 |
+
);
|
51 |
+
}
|
52 |
+
else {
|
53 |
+
$aVersions = $this->allFallback();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
catch ( \Exception $oE ) {
|
57 |
+
$aVersions = [];
|
58 |
+
}
|
59 |
+
|
60 |
+
usort( $aVersions, 'version_compare' );
|
61 |
+
return $aVersions;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return string
|
66 |
+
* @throws \Exception
|
67 |
+
*/
|
68 |
+
public function latest() {
|
69 |
+
return ( new Api() )
|
70 |
+
->setWorkingSlug( $this->getWorkingSlug() )
|
71 |
+
->getPluginInfo()
|
72 |
+
->version;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param string $sVersion
|
77 |
+
* @param bool $bVerifyUrl
|
78 |
+
* @return bool
|
79 |
+
*/
|
80 |
+
public function exists( $sVersion, $bVerifyUrl = false ) {
|
81 |
+
$bExists = in_array( $sVersion, $this->all() );
|
82 |
+
if ( $bExists && $bVerifyUrl ) {
|
83 |
+
try {
|
84 |
+
( new HttpUtil() )->checkUrl( Repo::GetUrlForPluginVersion( $this->getWorkingSlug(), $sVersion ) );
|
85 |
+
}
|
86 |
+
catch ( \Exception $oE ) {
|
87 |
+
$bExists = false;
|
88 |
+
};
|
89 |
+
}
|
90 |
+
return $bExists;
|
91 |
+
}
|
92 |
+
}
|
@@ -4,6 +4,11 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
class Plugins {
|
8 |
|
9 |
const URL_TEMPLATE_DOWNLOAD_ZIP = 'https://downloads.wordpress.org/plugin/%s.%s.zip';
|
@@ -42,7 +47,7 @@ class Plugins {
|
|
42 |
* @return string[]
|
43 |
*/
|
44 |
public function getAllVersions() {
|
45 |
-
$aV =
|
46 |
$sSvnVersionsContent = Services::HttpRequest()->getContent(
|
47 |
sprintf( static::URL_TEMPLATE_DOWNLOAD_SVN_VERSIONS, $this->getWorkingSlug() )
|
48 |
);
|
@@ -70,12 +75,12 @@ class Plugins {
|
|
70 |
*/
|
71 |
public function latestVersion() {
|
72 |
$sFileLocation = null;
|
73 |
-
$api = plugins_api( 'plugin_information',
|
74 |
'slug' => $this->getWorkingSlug(),
|
75 |
-
'fields' =>
|
76 |
'sections' => false,
|
77 |
-
|
78 |
-
|
79 |
|
80 |
if ( is_wp_error( $api ) ) {
|
81 |
throw new \Exception( $api->get_error_message() );
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
7 |
+
/**
|
8 |
+
* @deprecated
|
9 |
+
* Class Plugins
|
10 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg
|
11 |
+
*/
|
12 |
class Plugins {
|
13 |
|
14 |
const URL_TEMPLATE_DOWNLOAD_ZIP = 'https://downloads.wordpress.org/plugin/%s.%s.zip';
|
47 |
* @return string[]
|
48 |
*/
|
49 |
public function getAllVersions() {
|
50 |
+
$aV = [];
|
51 |
$sSvnVersionsContent = Services::HttpRequest()->getContent(
|
52 |
sprintf( static::URL_TEMPLATE_DOWNLOAD_SVN_VERSIONS, $this->getWorkingSlug() )
|
53 |
);
|
75 |
*/
|
76 |
public function latestVersion() {
|
77 |
$sFileLocation = null;
|
78 |
+
$api = plugins_api( 'plugin_information', [
|
79 |
'slug' => $this->getWorkingSlug(),
|
80 |
+
'fields' => [
|
81 |
'sections' => false,
|
82 |
+
],
|
83 |
+
] );
|
84 |
|
85 |
if ( is_wp_error( $api ) ) {
|
86 |
throw new \Exception( $api->get_error_message() );
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Base
|
7 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp
|
8 |
+
*/
|
9 |
+
class Base {
|
10 |
+
|
11 |
+
}
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Files
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp
|
10 |
+
*/
|
11 |
+
class Files {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param string $sFilePath
|
15 |
+
* @return string|null
|
16 |
+
* @throws \InvalidArgumentException
|
17 |
+
*/
|
18 |
+
public function getOriginalFileFromVcs( $sFilePath ) {
|
19 |
+
$sTmpFile = null;
|
20 |
+
$oHashes = Services\Services::CoreFileHashes();
|
21 |
+
if ( !$oHashes->isCoreFile( $sFilePath ) ) {
|
22 |
+
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
23 |
+
}
|
24 |
+
return ( new Repo() )->downloadFromVcs( $oHashes->getFileFragment( $sFilePath ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param string $sFilePath
|
29 |
+
* @return bool
|
30 |
+
* @throws \InvalidArgumentException
|
31 |
+
*/
|
32 |
+
public function replaceFileFromVcs( $sFilePath ) {
|
33 |
+
$oHashes = Services\Services::CoreFileHashes();
|
34 |
+
if ( !$oHashes->isCoreFile( $sFilePath ) ) {
|
35 |
+
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
36 |
+
}
|
37 |
+
|
38 |
+
$sTmp = $this->getOriginalFileFromVcs( $sFilePath );
|
39 |
+
return !empty( $sTmp )
|
40 |
+
&& Services\Services::WpFs()->move( $sTmp, $oHashes->getAbsolutePathFromFragment( $sFilePath ) );
|
41 |
+
}
|
42 |
+
}
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Repo
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp
|
10 |
+
*/
|
11 |
+
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
12 |
+
|
13 |
+
const URL_VCS_ROOT = 'https://core.svn.wordpress.org';
|
14 |
+
const URL_VCS_ROOT_IL8N = 'https://i18n.svn.wordpress.org';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param string $sVersion
|
18 |
+
* @param bool $bUseLocale
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
static public function GetUrlForVersion( $sVersion, $bUseLocale = true ) {
|
22 |
+
return sprintf(
|
23 |
+
'%s/tags/%s',
|
24 |
+
$bUseLocale ? static::URL_VCS_ROOT_IL8N : static::URL_VCS_ROOT,
|
25 |
+
$bUseLocale ? $sVersion.'/dist' : $sVersion
|
26 |
+
);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
static public function GetUrlForVersions() {
|
33 |
+
return static::GetUrlForVersion( '' );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param string $sFileFragment
|
38 |
+
* @param string $sVersion
|
39 |
+
* @param bool $bUseSiteLocale
|
40 |
+
* @return string|null
|
41 |
+
*/
|
42 |
+
public function downloadFromVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
43 |
+
$sFile = parent::downloadFromVcs( $sFileFragment, $sVersion, $bUseSiteLocale );
|
44 |
+
if ( $bUseSiteLocale && empty( $sFile ) ) {
|
45 |
+
$sFile = parent::downloadFromVcs( $sFileFragment, $sVersion, false );
|
46 |
+
}
|
47 |
+
return $sFile;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param string $sFileFragment
|
52 |
+
* @param string $sVersion - leave empty to use the current version
|
53 |
+
* @param bool $bUseSiteLocale
|
54 |
+
* @return bool
|
55 |
+
*/
|
56 |
+
public function existsInVcs( $sFileFragment, $sVersion = null, $bUseSiteLocale = true ) {
|
57 |
+
$sFile = parent::existsInVcs( $sFileFragment, $sVersion, $bUseSiteLocale );
|
58 |
+
if ( $bUseSiteLocale && empty( $sFile ) ) {
|
59 |
+
$sFile = parent::existsInVcs( $sFileFragment, $sVersion, false );
|
60 |
+
}
|
61 |
+
return $sFile;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @param string $sFileFragment
|
66 |
+
* @param string $sVersion
|
67 |
+
* @param bool $bUseSiteLocale
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
protected function getVcsUrlForFileAndVersion( $sFileFragment, $sVersion, $bUseSiteLocale = true ) {
|
71 |
+
if ( empty( $sVersion ) ) {
|
72 |
+
$sVersion = Services\Services::WpGeneral()->getVersion();
|
73 |
+
}
|
74 |
+
return sprintf( '%s/%s', static::GetUrlForVersion( $sVersion, $bUseSiteLocale ), ltrim( $sFileFragment, '/' ) );
|
75 |
+
}
|
76 |
+
}
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Services;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Versions
|
9 |
+
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp
|
10 |
+
*/
|
11 |
+
class Versions extends Services\Utilities\WpOrg\Base\VersionsBase {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param string $sVersion
|
15 |
+
* @param bool $bVerifyUrl
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
public function exists( $sVersion, $bVerifyUrl = false ) {
|
19 |
+
$bExists = in_array( $sVersion, $this->all() );
|
20 |
+
if ( $bExists && $bVerifyUrl ) {
|
21 |
+
try {
|
22 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $sVersion ) );
|
23 |
+
}
|
24 |
+
catch ( \Exception $oE ) {
|
25 |
+
$bExists = false;
|
26 |
+
};
|
27 |
+
}
|
28 |
+
return $bExists;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return array
|
33 |
+
*/
|
34 |
+
protected function downloadVersions() {
|
35 |
+
$aV = [];
|
36 |
+
$sSvnVersionsContent = Services\Services::HttpRequest()->getContent( Repo::GetUrlForVersions() );
|
37 |
+
|
38 |
+
if ( !empty( $sSvnVersionsContent ) ) {
|
39 |
+
$oSvnDom = new \DOMDocument();
|
40 |
+
$oSvnDom->loadHTML( $sSvnVersionsContent );
|
41 |
+
|
42 |
+
foreach ( $oSvnDom->getElementsByTagName( 'a' ) as $oElem ) {
|
43 |
+
/** @var \DOMElement $oElem */
|
44 |
+
$sHref = $oElem->getAttribute( 'href' );
|
45 |
+
if ( $sHref != '../' && !filter_var( $sHref, FILTER_VALIDATE_URL ) ) {
|
46 |
+
$aV[] = trim( $sHref, '/' );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
return $aV;
|
52 |
+
}
|
53 |
+
}
|
@@ -2605,7 +2605,7 @@ class Carbon extends DateTime implements JsonSerializable
|
|
2605 |
*/
|
2606 |
public function isCurrentMonth($ofSameYear = null)
|
2607 |
{
|
2608 |
-
return $this->isSameMonth($ofSameYear);
|
2609 |
}
|
2610 |
|
2611 |
/**
|
2605 |
*/
|
2606 |
public function isCurrentMonth($ofSameYear = null)
|
2607 |
{
|
2608 |
+
return $this->isSameMonth(null, $ofSameYear);
|
2609 |
}
|
2610 |
|
2611 |
/**
|
@@ -13,7 +13,7 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
13 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
14 |
$oFO = $this->getMod();
|
15 |
|
16 |
-
add_filter( $oFO->prefix( 'is_plugin_admin' ),
|
17 |
|
18 |
if ( $oFO->isWlEnabled() ) {
|
19 |
$this->getSubProWhitelabel()->run();
|
@@ -40,35 +40,35 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
40 |
$oFO = $this->getMod();
|
41 |
|
42 |
if ( !$oFO->isUpgrading() && !$this->loadWp()->isRequestUserLogin() ) {
|
43 |
-
add_filter( 'pre_update_option',
|
44 |
}
|
45 |
|
46 |
if ( $oFO->isAdminAccessAdminUsersEnabled() ) {
|
47 |
-
add_filter( 'editable_roles',
|
48 |
-
add_filter( 'user_has_cap',
|
49 |
-
add_action( 'delete_user',
|
50 |
-
add_action( 'add_user_role',
|
51 |
-
add_action( 'remove_user_role',
|
52 |
-
add_action( 'set_user_role',
|
53 |
}
|
54 |
|
55 |
$aPluginRestrictions = $oFO->getAdminAccessArea_Plugins();
|
56 |
if ( !empty( $aPluginRestrictions ) ) {
|
57 |
-
add_filter( 'user_has_cap',
|
58 |
}
|
59 |
|
60 |
$aThemeRestrictions = $oFO->getAdminAccessArea_Themes();
|
61 |
if ( !empty( $aThemeRestrictions ) ) {
|
62 |
-
add_filter( 'user_has_cap',
|
63 |
}
|
64 |
|
65 |
$aPostRestrictions = $oFO->getAdminAccessArea_Posts();
|
66 |
if ( !empty( $aPostRestrictions ) ) {
|
67 |
-
add_filter( 'user_has_cap',
|
68 |
}
|
69 |
|
70 |
if ( !$this->getCon()->isThisPluginModuleRequest() ) {
|
71 |
-
add_action( 'admin_footer',
|
72 |
}
|
73 |
}
|
74 |
}
|
@@ -98,11 +98,11 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
98 |
$aData = parent::tracking_DataCollect( $aData );
|
99 |
$sSlug = $this->getMod()->getSlug();
|
100 |
|
101 |
-
$aKeysToBoolean =
|
102 |
'admin_access_restrict_plugins',
|
103 |
'admin_access_restrict_themes',
|
104 |
'admin_access_restrict_posts'
|
105 |
-
|
106 |
foreach ( $aKeysToBoolean as $sKeyToBoolean ) {
|
107 |
$aData[ $sSlug ][ 'options' ][ $sKeyToBoolean ]
|
108 |
= empty( $aData[ $sSlug ][ 'options' ][ $sKeyToBoolean ] ) ? 0 : 1;
|
@@ -119,9 +119,9 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
119 |
|
120 |
if ( $oWpUsers->getCurrentWpUserId() !== $nUserId && strtolower( $sRole ) === 'administrator' ) {
|
121 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
122 |
-
remove_action( 'remove_user_role',
|
123 |
$oModUser->remove_role( 'administrator' );
|
124 |
-
add_action( 'remove_user_role',
|
125 |
}
|
126 |
}
|
127 |
|
@@ -155,14 +155,14 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
155 |
|
156 |
if ( $bRevert ) {
|
157 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
158 |
-
remove_action( 'add_user_role',
|
159 |
-
remove_action( 'remove_user_role',
|
160 |
$oModUser->remove_role( $sRole );
|
161 |
foreach ( $aOldRoles as $sPreExistingRoles ) {
|
162 |
$oModUser->add_role( $sPreExistingRoles );
|
163 |
}
|
164 |
-
add_action( 'add_user_role',
|
165 |
-
add_action( 'remove_user_role',
|
166 |
}
|
167 |
}
|
168 |
}
|
@@ -176,9 +176,9 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
176 |
|
177 |
if ( $oWpUsers->getCurrentWpUserId() !== $nUserId && strtolower( $sRole ) === 'administrator' ) {
|
178 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
179 |
-
remove_action( 'add_user_role',
|
180 |
$oModUser->add_role( 'administrator' );
|
181 |
-
add_action( 'add_user_role',
|
182 |
}
|
183 |
}
|
184 |
|
@@ -218,7 +218,7 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
218 |
/** @var string $sUserCap */
|
219 |
$sUserCap = $aArgs[ 0 ];
|
220 |
|
221 |
-
$aReleventCaps =
|
222 |
|
223 |
// If we're registered with Admin Access we don't modify anything
|
224 |
if ( in_array( $sUserCap, $aReleventCaps ) ) {
|
@@ -283,22 +283,22 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
283 |
}
|
284 |
|
285 |
$sName = $this->getCon()->getHumanName();
|
286 |
-
$aRenderData =
|
287 |
'notice_attributes' => $aNoticeAttributes,
|
288 |
-
'strings' =>
|
289 |
'title' => sprintf( _wpsf__( '%s Security Restrictions Applied' ), $sName ),
|
290 |
'notice_message' => _wpsf__( 'Altering certain options has been restricted by your WordPress security administrator.' )
|
291 |
.' '._wpsf__( 'Repeated failed attempts to authenticate will probably lock you out of this site.' )
|
292 |
-
|
293 |
-
'hrefs' =>
|
294 |
'setting_page' => sprintf(
|
295 |
'<a href="%s" title="%s">%s</a>',
|
296 |
$oFO->getUrl_AdminPage(),
|
297 |
_wpsf__( 'Admin Access Login' ),
|
298 |
sprintf( _wpsf__( 'Go here to manage settings and authenticate with the %s plugin.' ), $sName )
|
299 |
)
|
300 |
-
|
301 |
-
|
302 |
add_thickbox();
|
303 |
$this->insertAdminNotice( $aRenderData );
|
304 |
}
|
@@ -322,23 +322,23 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
322 |
}
|
323 |
|
324 |
$sName = $oCon->getHumanName();
|
325 |
-
$aRenderData =
|
326 |
'notice_attributes' => $aNoticeAttributes,
|
327 |
-
'strings' =>
|
328 |
'title' => sprintf( _wpsf__( '%s Security Restrictions Applied' ), $sName ),
|
329 |
'notice_message' => _wpsf__( 'Editing existing administrators, promoting existing users to the administrator role, or deleting administrator users is currently restricted.' )
|
330 |
.' '._wpsf__( 'Please authenticate with the Security Admin system before attempting any administrator user modifications.' ),
|
331 |
'unlock_link' => $this->getUnlockLinkHtml( _wpsf__( 'Unlock Now' ) ),
|
332 |
-
|
333 |
-
'hrefs' =>
|
334 |
'setting_page' => sprintf(
|
335 |
'<a href="%s" title="%s">%s</a>',
|
336 |
$oFO->getUrl_AdminPage(),
|
337 |
_wpsf__( 'Security Admin Login' ),
|
338 |
sprintf( _wpsf__( 'Go here to manage settings and authenticate with the %s plugin.' ), $sName )
|
339 |
)
|
340 |
-
|
341 |
-
|
342 |
$this->insertAdminNotice( $aRenderData );
|
343 |
}
|
344 |
|
@@ -346,11 +346,11 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
346 |
* @return array
|
347 |
*/
|
348 |
protected function getUserPagesToRestrict() {
|
349 |
-
return
|
350 |
/* 'user-new.php', */
|
351 |
'user-edit.php',
|
352 |
'users.php',
|
353 |
-
|
354 |
}
|
355 |
|
356 |
/**
|
@@ -423,7 +423,7 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
423 |
return $aAllCaps;
|
424 |
}
|
425 |
|
426 |
-
$aEditCapabilities =
|
427 |
|
428 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
429 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Plugins();
|
@@ -452,13 +452,13 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
452 |
|
453 |
/** @var string $sRequestedCapability */
|
454 |
$sRequestedCapability = $aArgs[ 0 ];
|
455 |
-
$aEditCapabilities =
|
456 |
'switch_themes',
|
457 |
'edit_theme_options',
|
458 |
'install_themes',
|
459 |
'update_themes',
|
460 |
'delete_themes'
|
461 |
-
|
462 |
|
463 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
464 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Themes();
|
@@ -486,7 +486,7 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
486 |
|
487 |
/** @var string $sRequestedCapability */
|
488 |
$sRequestedCapability = $aArgs[ 0 ];
|
489 |
-
$aEditCapabilities =
|
490 |
'edit_post',
|
491 |
'publish_post',
|
492 |
'delete_post',
|
@@ -499,14 +499,14 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
499 |
'edit_pages',
|
500 |
'publish_pages',
|
501 |
'delete_pages'
|
502 |
-
|
503 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
504 |
-
$sRequestedCapabilityTrimmed = str_replace(
|
505 |
'_posts',
|
506 |
'_pages',
|
507 |
'_post',
|
508 |
'_page'
|
509 |
-
|
510 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Posts();
|
511 |
if ( in_array( $sRequestedCapabilityTrimmed, $aAreaRestrictions ) ) {
|
512 |
$aAllCaps[ $sRequestedCapability ] = false;
|
@@ -531,21 +531,21 @@ class ICWP_WPSF_Processor_AdminAccessRestriction extends ICWP_WPSF_Processor_Bas
|
|
531 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
532 |
$oFO = $this->getMod();
|
533 |
|
534 |
-
$aRenderData =
|
535 |
-
'flags' =>
|
536 |
'restrict_options' => $oFO->getAdminAccessArea_Options()
|
537 |
-
|
538 |
-
'strings' =>
|
539 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
540 |
'unlock_link' => $this->getUnlockLinkHtml(),
|
541 |
-
|
542 |
-
'js_snippets' =>
|
543 |
'options_to_restrict' => "'".implode( "','", $oFO->getOptionsToRestrict() )."'",
|
544 |
-
|
545 |
-
'ajax' =>
|
546 |
'sec_admin_login_box' => $oFO->getAjaxActionData( 'sec_admin_login_box', true )
|
547 |
-
|
548 |
-
|
549 |
add_thickbox();
|
550 |
echo $oFO->renderTemplate( 'snippets/admin_access_login_box.php', $aRenderData );
|
551 |
}
|
13 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
14 |
$oFO = $this->getMod();
|
15 |
|
16 |
+
add_filter( $oFO->prefix( 'is_plugin_admin' ), [ $this, 'adjustUserAdminPermissions' ] );
|
17 |
|
18 |
if ( $oFO->isWlEnabled() ) {
|
19 |
$this->getSubProWhitelabel()->run();
|
40 |
$oFO = $this->getMod();
|
41 |
|
42 |
if ( !$oFO->isUpgrading() && !$this->loadWp()->isRequestUserLogin() ) {
|
43 |
+
add_filter( 'pre_update_option', [ $this, 'blockOptionsSaves' ], 1, 3 );
|
44 |
}
|
45 |
|
46 |
if ( $oFO->isAdminAccessAdminUsersEnabled() ) {
|
47 |
+
add_filter( 'editable_roles', [ $this, 'restrictEditableRoles' ], 100, 1 );
|
48 |
+
add_filter( 'user_has_cap', [ $this, 'restrictAdminUserChanges' ], 100, 3 );
|
49 |
+
add_action( 'delete_user', [ $this, 'restrictAdminUserDelete' ], 100, 1 );
|
50 |
+
add_action( 'add_user_role', [ $this, 'restrictAddUserRole' ], 100, 2 );
|
51 |
+
add_action( 'remove_user_role', [ $this, 'restrictRemoveUserRole' ], 100, 2 );
|
52 |
+
add_action( 'set_user_role', [ $this, 'restrictSetUserRole' ], 100, 3 );
|
53 |
}
|
54 |
|
55 |
$aPluginRestrictions = $oFO->getAdminAccessArea_Plugins();
|
56 |
if ( !empty( $aPluginRestrictions ) ) {
|
57 |
+
add_filter( 'user_has_cap', [ $this, 'disablePluginManipulation' ], 0, 3 );
|
58 |
}
|
59 |
|
60 |
$aThemeRestrictions = $oFO->getAdminAccessArea_Themes();
|
61 |
if ( !empty( $aThemeRestrictions ) ) {
|
62 |
+
add_filter( 'user_has_cap', [ $this, 'disableThemeManipulation' ], 0, 3 );
|
63 |
}
|
64 |
|
65 |
$aPostRestrictions = $oFO->getAdminAccessArea_Posts();
|
66 |
if ( !empty( $aPostRestrictions ) ) {
|
67 |
+
add_filter( 'user_has_cap', [ $this, 'disablePostsManipulation' ], 0, 3 );
|
68 |
}
|
69 |
|
70 |
if ( !$this->getCon()->isThisPluginModuleRequest() ) {
|
71 |
+
add_action( 'admin_footer', [ $this, 'printAdminAccessAjaxForm' ] );
|
72 |
}
|
73 |
}
|
74 |
}
|
98 |
$aData = parent::tracking_DataCollect( $aData );
|
99 |
$sSlug = $this->getMod()->getSlug();
|
100 |
|
101 |
+
$aKeysToBoolean = [
|
102 |
'admin_access_restrict_plugins',
|
103 |
'admin_access_restrict_themes',
|
104 |
'admin_access_restrict_posts'
|
105 |
+
];
|
106 |
foreach ( $aKeysToBoolean as $sKeyToBoolean ) {
|
107 |
$aData[ $sSlug ][ 'options' ][ $sKeyToBoolean ]
|
108 |
= empty( $aData[ $sSlug ][ 'options' ][ $sKeyToBoolean ] ) ? 0 : 1;
|
119 |
|
120 |
if ( $oWpUsers->getCurrentWpUserId() !== $nUserId && strtolower( $sRole ) === 'administrator' ) {
|
121 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
122 |
+
remove_action( 'remove_user_role', [ $this, 'restrictRemoveUserRole' ], 100 );
|
123 |
$oModUser->remove_role( 'administrator' );
|
124 |
+
add_action( 'remove_user_role', [ $this, 'restrictRemoveUserRole' ], 100, 2 );
|
125 |
}
|
126 |
}
|
127 |
|
155 |
|
156 |
if ( $bRevert ) {
|
157 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
158 |
+
remove_action( 'add_user_role', [ $this, 'restrictAddUserRole' ], 100 );
|
159 |
+
remove_action( 'remove_user_role', [ $this, 'restrictRemoveUserRole' ], 100 );
|
160 |
$oModUser->remove_role( $sRole );
|
161 |
foreach ( $aOldRoles as $sPreExistingRoles ) {
|
162 |
$oModUser->add_role( $sPreExistingRoles );
|
163 |
}
|
164 |
+
add_action( 'add_user_role', [ $this, 'restrictAddUserRole' ], 100, 2 );
|
165 |
+
add_action( 'remove_user_role', [ $this, 'restrictRemoveUserRole' ], 100, 2 );
|
166 |
}
|
167 |
}
|
168 |
}
|
176 |
|
177 |
if ( $oWpUsers->getCurrentWpUserId() !== $nUserId && strtolower( $sRole ) === 'administrator' ) {
|
178 |
$oModUser = $oWpUsers->getUserById( $nUserId );
|
179 |
+
remove_action( 'add_user_role', [ $this, 'restrictAddUserRole' ], 100 );
|
180 |
$oModUser->add_role( 'administrator' );
|
181 |
+
add_action( 'add_user_role', [ $this, 'restrictAddUserRole' ], 100, 2 );
|
182 |
}
|
183 |
}
|
184 |
|
218 |
/** @var string $sUserCap */
|
219 |
$sUserCap = $aArgs[ 0 ];
|
220 |
|
221 |
+
$aReleventCaps = [ 'edit_users', 'create_users' ];
|
222 |
|
223 |
// If we're registered with Admin Access we don't modify anything
|
224 |
if ( in_array( $sUserCap, $aReleventCaps ) ) {
|
283 |
}
|
284 |
|
285 |
$sName = $this->getCon()->getHumanName();
|
286 |
+
$aRenderData = [
|
287 |
'notice_attributes' => $aNoticeAttributes,
|
288 |
+
'strings' => [
|
289 |
'title' => sprintf( _wpsf__( '%s Security Restrictions Applied' ), $sName ),
|
290 |
'notice_message' => _wpsf__( 'Altering certain options has been restricted by your WordPress security administrator.' )
|
291 |
.' '._wpsf__( 'Repeated failed attempts to authenticate will probably lock you out of this site.' )
|
292 |
+
],
|
293 |
+
'hrefs' => [
|
294 |
'setting_page' => sprintf(
|
295 |
'<a href="%s" title="%s">%s</a>',
|
296 |
$oFO->getUrl_AdminPage(),
|
297 |
_wpsf__( 'Admin Access Login' ),
|
298 |
sprintf( _wpsf__( 'Go here to manage settings and authenticate with the %s plugin.' ), $sName )
|
299 |
)
|
300 |
+
]
|
301 |
+
];
|
302 |
add_thickbox();
|
303 |
$this->insertAdminNotice( $aRenderData );
|
304 |
}
|
322 |
}
|
323 |
|
324 |
$sName = $oCon->getHumanName();
|
325 |
+
$aRenderData = [
|
326 |
'notice_attributes' => $aNoticeAttributes,
|
327 |
+
'strings' => [
|
328 |
'title' => sprintf( _wpsf__( '%s Security Restrictions Applied' ), $sName ),
|
329 |
'notice_message' => _wpsf__( 'Editing existing administrators, promoting existing users to the administrator role, or deleting administrator users is currently restricted.' )
|
330 |
.' '._wpsf__( 'Please authenticate with the Security Admin system before attempting any administrator user modifications.' ),
|
331 |
'unlock_link' => $this->getUnlockLinkHtml( _wpsf__( 'Unlock Now' ) ),
|
332 |
+
],
|
333 |
+
'hrefs' => [
|
334 |
'setting_page' => sprintf(
|
335 |
'<a href="%s" title="%s">%s</a>',
|
336 |
$oFO->getUrl_AdminPage(),
|
337 |
_wpsf__( 'Security Admin Login' ),
|
338 |
sprintf( _wpsf__( 'Go here to manage settings and authenticate with the %s plugin.' ), $sName )
|
339 |
)
|
340 |
+
]
|
341 |
+
];
|
342 |
$this->insertAdminNotice( $aRenderData );
|
343 |
}
|
344 |
|
346 |
* @return array
|
347 |
*/
|
348 |
protected function getUserPagesToRestrict() {
|
349 |
+
return [
|
350 |
/* 'user-new.php', */
|
351 |
'user-edit.php',
|
352 |
'users.php',
|
353 |
+
];
|
354 |
}
|
355 |
|
356 |
/**
|
423 |
return $aAllCaps;
|
424 |
}
|
425 |
|
426 |
+
$aEditCapabilities = [ 'activate_plugins', 'delete_plugins', 'install_plugins', 'update_plugins' ];
|
427 |
|
428 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
429 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Plugins();
|
452 |
|
453 |
/** @var string $sRequestedCapability */
|
454 |
$sRequestedCapability = $aArgs[ 0 ];
|
455 |
+
$aEditCapabilities = [
|
456 |
'switch_themes',
|
457 |
'edit_theme_options',
|
458 |
'install_themes',
|
459 |
'update_themes',
|
460 |
'delete_themes'
|
461 |
+
];
|
462 |
|
463 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
464 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Themes();
|
486 |
|
487 |
/** @var string $sRequestedCapability */
|
488 |
$sRequestedCapability = $aArgs[ 0 ];
|
489 |
+
$aEditCapabilities = [
|
490 |
'edit_post',
|
491 |
'publish_post',
|
492 |
'delete_post',
|
499 |
'edit_pages',
|
500 |
'publish_pages',
|
501 |
'delete_pages'
|
502 |
+
];
|
503 |
if ( in_array( $sRequestedCapability, $aEditCapabilities ) ) {
|
504 |
+
$sRequestedCapabilityTrimmed = str_replace( [
|
505 |
'_posts',
|
506 |
'_pages',
|
507 |
'_post',
|
508 |
'_page'
|
509 |
+
], '', $sRequestedCapability ); //Order of items in this array is important!
|
510 |
$aAreaRestrictions = $oFO->getAdminAccessArea_Posts();
|
511 |
if ( in_array( $sRequestedCapabilityTrimmed, $aAreaRestrictions ) ) {
|
512 |
$aAllCaps[ $sRequestedCapability ] = false;
|
531 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
532 |
$oFO = $this->getMod();
|
533 |
|
534 |
+
$aRenderData = [
|
535 |
+
'flags' => [
|
536 |
'restrict_options' => $oFO->getAdminAccessArea_Options()
|
537 |
+
],
|
538 |
+
'strings' => [
|
539 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
540 |
'unlock_link' => $this->getUnlockLinkHtml(),
|
541 |
+
],
|
542 |
+
'js_snippets' => [
|
543 |
'options_to_restrict' => "'".implode( "','", $oFO->getOptionsToRestrict() )."'",
|
544 |
+
],
|
545 |
+
'ajax' => [
|
546 |
'sec_admin_login_box' => $oFO->getAjaxActionData( 'sec_admin_login_box', true )
|
547 |
+
]
|
548 |
+
];
|
549 |
add_thickbox();
|
550 |
echo $oFO->renderTemplate( 'snippets/admin_access_login_box.php', $aRenderData );
|
551 |
}
|
@@ -8,9 +8,9 @@ class ICWP_WPSF_Processor_AdminAccess_Whitelabel extends ICWP_WPSF_Processor_Bas
|
|
8 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
9 |
$oFO = $this->getMod();
|
10 |
add_filter( $this->prefix( 'is_relabelled' ), '__return_true' );
|
11 |
-
add_filter( $oFO->prefix( 'plugin_labels' ),
|
12 |
-
add_filter( 'plugin_row_meta',
|
13 |
-
add_action( 'admin_print_footer_scripts-plugin-editor.php',
|
14 |
}
|
15 |
|
16 |
public function onWpInit() {
|
@@ -31,11 +31,11 @@ class ICWP_WPSF_Processor_AdminAccess_Whitelabel extends ICWP_WPSF_Processor_Bas
|
|
31 |
*/
|
32 |
protected function hideUpdates() {
|
33 |
$sCurrent = $this->loadWp()->getCurrentPage();
|
34 |
-
if ( in_array( $sCurrent,
|
35 |
-
add_filter( 'site_transient_update_plugins',
|
36 |
}
|
37 |
else {
|
38 |
-
add_filter( 'wp_get_update_data',
|
39 |
}
|
40 |
}
|
41 |
|
8 |
/** @var ICWP_WPSF_FeatureHandler_AdminAccessRestriction $oFO */
|
9 |
$oFO = $this->getMod();
|
10 |
add_filter( $this->prefix( 'is_relabelled' ), '__return_true' );
|
11 |
+
add_filter( $oFO->prefix( 'plugin_labels' ), [ $this, 'doRelabelPlugin' ] );
|
12 |
+
add_filter( 'plugin_row_meta', [ $this, 'fRemoveDetailsMetaLink' ], 200, 2 );
|
13 |
+
add_action( 'admin_print_footer_scripts-plugin-editor.php', [ $this, 'hideFromPluginEditor' ] );
|
14 |
}
|
15 |
|
16 |
public function onWpInit() {
|
31 |
*/
|
32 |
protected function hideUpdates() {
|
33 |
$sCurrent = $this->loadWp()->getCurrentPage();
|
34 |
+
if ( in_array( $sCurrent, [ 'plugins.php', 'update-core.php' ] ) ) {
|
35 |
+
add_filter( 'site_transient_update_plugins', [ $this, 'hidePluginUpdatesFromUI' ] );
|
36 |
}
|
37 |
else {
|
38 |
+
add_filter( 'wp_get_update_data', [ $this, 'adjustUpdateDataCount' ] );
|
39 |
}
|
40 |
}
|
41 |
|
@@ -16,7 +16,7 @@ class ICWP_WPSF_Processor_AuditTrail_Auditor extends ICWP_WPSF_BaseDbProcessor {
|
|
16 |
*/
|
17 |
public function init() {
|
18 |
parent::init();
|
19 |
-
add_action( $this->getMod()->prefix( 'add_new_audit_entry' ),
|
20 |
}
|
21 |
|
22 |
public function cleanupDatabase() {
|
16 |
*/
|
17 |
public function init() {
|
18 |
parent::init();
|
19 |
+
add_action( $this->getMod()->prefix( 'add_new_audit_entry' ), [ $this, 'addAuditTrialEntry' ] );
|
20 |
}
|
21 |
|
22 |
public function cleanupDatabase() {
|
@@ -7,7 +7,7 @@ class ICWP_WPSF_Processor_AuditTrail_Emails extends ICWP_WPSF_AuditTrail_Auditor
|
|
7 |
/**
|
8 |
*/
|
9 |
public function run() {
|
10 |
-
add_filter( 'wp_mail',
|
11 |
}
|
12 |
|
13 |
/**
|
@@ -25,10 +25,10 @@ class ICWP_WPSF_Processor_AuditTrail_Emails extends ICWP_WPSF_AuditTrail_Auditor
|
|
25 |
|
26 |
$aBacktrace = $this->findEmailSenderBacktrace();
|
27 |
|
28 |
-
$aMsg =
|
29 |
sprintf( _wpsf__( 'There was an attempt to send an email using the "%s" function.' ), 'wp_mail' ),
|
30 |
sprintf( _wpsf__( 'It was sent to "%s" with the subject "%s".' ), $sTo, $aEmail[ 'subject' ] ),
|
31 |
-
|
32 |
|
33 |
// Attempt to capture BCC/CC
|
34 |
if ( !empty( $aEmail[ 'headers' ] ) ) {
|
@@ -70,10 +70,10 @@ class ICWP_WPSF_Processor_AuditTrail_Emails extends ICWP_WPSF_AuditTrail_Auditor
|
|
70 |
* @return array
|
71 |
*/
|
72 |
private function extractCcFromHeaders( $aHeaders ) {
|
73 |
-
$aCCs =
|
74 |
'bcc' => [],
|
75 |
'cc' => []
|
76 |
-
|
77 |
|
78 |
$aHeaders = array_filter( array_map( 'trim', array_map( 'strtolower', $aHeaders ) ) );
|
79 |
foreach ( $aHeaders as $sHeader ) {
|
7 |
/**
|
8 |
*/
|
9 |
public function run() {
|
10 |
+
add_filter( 'wp_mail', [ $this, 'auditEmailSend' ], PHP_INT_MAX );
|
11 |
}
|
12 |
|
13 |
/**
|
25 |
|
26 |
$aBacktrace = $this->findEmailSenderBacktrace();
|
27 |
|
28 |
+
$aMsg = [
|
29 |
sprintf( _wpsf__( 'There was an attempt to send an email using the "%s" function.' ), 'wp_mail' ),
|
30 |
sprintf( _wpsf__( 'It was sent to "%s" with the subject "%s".' ), $sTo, $aEmail[ 'subject' ] ),
|
31 |
+
];
|
32 |
|
33 |
// Attempt to capture BCC/CC
|
34 |
if ( !empty( $aEmail[ 'headers' ] ) ) {
|
70 |
* @return array
|
71 |
*/
|
72 |
private function extractCcFromHeaders( $aHeaders ) {
|
73 |
+
$aCCs = [
|
74 |
'bcc' => [],
|
75 |
'cc' => []
|
76 |
+
];
|
77 |
|
78 |
$aHeaders = array_filter( array_map( 'trim', array_map( 'strtolower', $aHeaders ) ) );
|
79 |
foreach ( $aHeaders as $sHeader ) {
|
@@ -5,9 +5,9 @@ class ICWP_WPSF_Processor_AuditTrail_Plugins extends ICWP_WPSF_AuditTrail_Audito
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
-
add_action( 'deactivated_plugin',
|
9 |
-
add_action( 'activated_plugin',
|
10 |
-
add_action( 'check_admin_referer',
|
11 |
}
|
12 |
|
13 |
/**
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
+
add_action( 'deactivated_plugin', [ $this, 'auditDeactivatedPlugin' ] );
|
9 |
+
add_action( 'activated_plugin', [ $this, 'auditActivatedPlugin' ] );
|
10 |
+
add_action( 'check_admin_referer', [ $this, 'auditEditedPluginFile' ], 10, 2 );
|
11 |
}
|
12 |
|
13 |
/**
|
@@ -5,8 +5,8 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
-
add_action( 'deleted_post',
|
9 |
-
add_action( 'transition_post_status',
|
10 |
}
|
11 |
|
12 |
/**
|
@@ -29,8 +29,8 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
29 |
*/
|
30 |
public function auditPostStatus( $sNewStatus, $sOldStatus, $oPost ) {
|
31 |
|
32 |
-
if (
|
33 |
-
|| in_array( $sNewStatus,
|
34 |
return;
|
35 |
}
|
36 |
|
@@ -42,9 +42,9 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
42 |
$sEvent = 'post_recovered';
|
43 |
$sHumanEvent = _wpsf__( 'recovered from trash' );
|
44 |
}
|
45 |
-
else if ( in_array( $sNewStatus,
|
46 |
|
47 |
-
if ( in_array( $sOldStatus,
|
48 |
$sEvent = 'post_updated';
|
49 |
$sHumanEvent = _wpsf__( 'updated' );
|
50 |
}
|
@@ -53,7 +53,7 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
53 |
$sHumanEvent = _wpsf__( 'published' );
|
54 |
}
|
55 |
}
|
56 |
-
else if ( in_array( $sOldStatus,
|
57 |
$sEvent = 'post_unpublished';
|
58 |
$sHumanEvent = _wpsf__( 'unpublished' );
|
59 |
}
|
@@ -62,10 +62,10 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
62 |
$sHumanEvent = _wpsf__( 'updated' );
|
63 |
}
|
64 |
|
65 |
-
$aMsg =
|
66 |
sprintf( _wpsf__( 'Post entitled "%s" was %s.' ), $oPost->post_title, $sHumanEvent ),
|
67 |
sprintf( '%s: %s', _wpsf__( 'Post Type' ), $oPost->post_type ),
|
68 |
-
|
69 |
|
70 |
$this->add( 'posts', $sEvent, 1, implode( " ", $aMsg ) );
|
71 |
}
|
@@ -80,11 +80,11 @@ class ICWP_WPSF_Processor_AuditTrail_Posts extends ICWP_WPSF_AuditTrail_Auditor_
|
|
80 |
||
|
81 |
in_array(
|
82 |
$oPost->post_type,
|
83 |
-
|
84 |
'revision',
|
85 |
'nav_menu_item',
|
86 |
'attachment'
|
87 |
-
|
88 |
);
|
89 |
}
|
90 |
}
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
+
add_action( 'deleted_post', [ $this, 'auditDeletedPost' ] );
|
9 |
+
add_action( 'transition_post_status', [ $this, 'auditPostStatus' ], 30, 3 );
|
10 |
}
|
11 |
|
12 |
/**
|
29 |
*/
|
30 |
public function auditPostStatus( $sNewStatus, $sOldStatus, $oPost ) {
|
31 |
|
32 |
+
if ( !$oPost instanceof WP_Post || $this->isIgnoredPostType( $oPost )
|
33 |
+
|| in_array( $sNewStatus, [ 'auto-draft', 'inherit' ] ) ) {
|
34 |
return;
|
35 |
}
|
36 |
|
42 |
$sEvent = 'post_recovered';
|
43 |
$sHumanEvent = _wpsf__( 'recovered from trash' );
|
44 |
}
|
45 |
+
else if ( in_array( $sNewStatus, [ 'publish', 'private' ] ) ) {
|
46 |
|
47 |
+
if ( in_array( $sOldStatus, [ 'publish', 'private' ] ) ) {
|
48 |
$sEvent = 'post_updated';
|
49 |
$sHumanEvent = _wpsf__( 'updated' );
|
50 |
}
|
53 |
$sHumanEvent = _wpsf__( 'published' );
|
54 |
}
|
55 |
}
|
56 |
+
else if ( in_array( $sOldStatus, [ 'publish', 'private' ] ) && $sNewStatus == 'draft' ) {
|
57 |
$sEvent = 'post_unpublished';
|
58 |
$sHumanEvent = _wpsf__( 'unpublished' );
|
59 |
}
|
62 |
$sHumanEvent = _wpsf__( 'updated' );
|
63 |
}
|
64 |
|
65 |
+
$aMsg = [
|
66 |
sprintf( _wpsf__( 'Post entitled "%s" was %s.' ), $oPost->post_title, $sHumanEvent ),
|
67 |
sprintf( '%s: %s', _wpsf__( 'Post Type' ), $oPost->post_type ),
|
68 |
+
];
|
69 |
|
70 |
$this->add( 'posts', $sEvent, 1, implode( " ", $aMsg ) );
|
71 |
}
|
80 |
||
|
81 |
in_array(
|
82 |
$oPost->post_type,
|
83 |
+
[
|
84 |
'revision',
|
85 |
'nav_menu_item',
|
86 |
'attachment'
|
87 |
+
]
|
88 |
);
|
89 |
}
|
90 |
}
|
@@ -5,8 +5,8 @@ class ICWP_WPSF_Processor_AuditTrail_Themes extends ICWP_WPSF_AuditTrail_Auditor
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
-
add_action( 'switch_theme',
|
9 |
-
add_action( 'check_admin_referer',
|
10 |
// add_action( 'upgrader_process_complete', array( $this, 'auditInstalledTheme' ) );
|
11 |
}
|
12 |
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
+
add_action( 'switch_theme', [ $this, 'auditSwitchTheme' ] );
|
9 |
+
add_action( 'check_admin_referer', [ $this, 'auditEditedThemeFile' ], 10, 2 );
|
10 |
// add_action( 'upgrader_process_complete', array( $this, 'auditInstalledTheme' ) );
|
11 |
}
|
12 |
|
@@ -5,9 +5,9 @@ class ICWP_WPSF_Processor_AuditTrail_Users extends ICWP_WPSF_AuditTrail_Auditor_
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
-
add_action( 'wp_login',
|
9 |
-
add_action( 'user_register',
|
10 |
-
add_action( 'delete_user',
|
11 |
}
|
12 |
|
13 |
/**
|
@@ -46,7 +46,7 @@ class ICWP_WPSF_Processor_AuditTrail_Users extends ICWP_WPSF_AuditTrail_Auditor_
|
|
46 |
public function auditDeleteUser( $nUserId, $nReassigned ) {
|
47 |
$oWpUsers = $this->loadWpUsers();
|
48 |
|
49 |
-
$aAuditMessage =
|
50 |
|
51 |
$oDeletedUser = empty( $nUserId ) ? null : $oWpUsers->getUserById( $nUserId );
|
52 |
if ( empty( $oDeletedUser ) ) {
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
+
add_action( 'wp_login', [ $this, 'auditUserLoginSuccess' ] );
|
9 |
+
add_action( 'user_register', [ $this, 'auditNewUserRegistered' ] );
|
10 |
+
add_action( 'delete_user', [ $this, 'auditDeleteUser' ], 30, 2 );
|
11 |
}
|
12 |
|
13 |
/**
|
46 |
public function auditDeleteUser( $nUserId, $nReassigned ) {
|
47 |
$oWpUsers = $this->loadWpUsers();
|
48 |
|
49 |
+
$aAuditMessage = [ _wpsf__( 'WordPress user deleted.' ) ];
|
50 |
|
51 |
$oDeletedUser = empty( $nUserId ) ? null : $oWpUsers->getUserById( $nUserId );
|
52 |
if ( empty( $oDeletedUser ) ) {
|
@@ -5,8 +5,8 @@ class ICWP_WPSF_Processor_AuditTrail_Wordpress extends ICWP_WPSF_AuditTrail_Audi
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
-
add_action( '_core_updated_successfully',
|
9 |
-
add_action( 'update_option_permalink_structure',
|
10 |
}
|
11 |
|
12 |
/**
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
8 |
+
add_action( '_core_updated_successfully', [ $this, 'auditCoreUpdated' ] );
|
9 |
+
add_action( 'update_option_permalink_structure', [ $this, 'auditPermalinkStructure' ], 10, 2 );
|
10 |
}
|
11 |
|
12 |
/**
|
@@ -4,5 +4,6 @@ class ICWP_WPSF_Processor_AuditTrail_Wpsf extends ICWP_WPSF_AuditTrail_Auditor_B
|
|
4 |
|
5 |
/**
|
6 |
*/
|
7 |
-
public function run() {
|
|
|
8 |
}
|
4 |
|
5 |
/**
|
6 |
*/
|
7 |
+
public function run() {
|
8 |
+
}
|
9 |
}
|
@@ -37,13 +37,13 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
37 |
$oFO = $this->getMod();
|
38 |
|
39 |
$nFilterPriority = $this->getHookPriority();
|
40 |
-
add_filter( 'allow_minor_auto_core_updates',
|
41 |
-
add_filter( 'allow_major_auto_core_updates',
|
42 |
|
43 |
-
add_filter( 'auto_update_translation',
|
44 |
-
add_filter( 'auto_update_plugin',
|
45 |
-
add_filter( 'auto_update_theme',
|
46 |
-
add_filter( 'auto_update_core',
|
47 |
|
48 |
if ( $oFO->isOpt( 'enable_autoupdate_ignore_vcs', 'Y' ) ) {
|
49 |
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false', $nFilterPriority );
|
@@ -51,21 +51,21 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
51 |
|
52 |
if ( !$oFO->isDisableAllAutoUpdates() ) {
|
53 |
//more parameter options here for later
|
54 |
-
add_filter( 'auto_core_update_send_email',
|
55 |
-
add_filter( 'auto_core_update_email',
|
56 |
|
57 |
-
add_action( 'set_site_transient_update_core',
|
58 |
-
add_action( 'set_site_transient_update_plugins',
|
59 |
-
add_action( 'set_site_transient_update_themes',
|
60 |
|
61 |
if ( $oFO->isSendAutoupdatesNotificationEmail() ) {
|
62 |
$this->trackAssetsVersions();
|
63 |
-
add_action( 'automatic_updates_complete',
|
64 |
}
|
65 |
|
66 |
if ( $oFO->isAutoupdateIndividualPlugins() ) {
|
67 |
// Adds automatic update indicator column to all plugins in plugin listing.
|
68 |
-
add_filter( 'manage_plugins_columns',
|
69 |
}
|
70 |
}
|
71 |
}
|
@@ -111,10 +111,10 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
111 |
*/
|
112 |
protected function getTrackedAssetsVersions() {
|
113 |
if ( empty( $this->aAssetsVersions ) || !is_array( $this->aAssetsVersions ) ) {
|
114 |
-
$this->aAssetsVersions =
|
115 |
'plugins' => [],
|
116 |
'themes' => [],
|
117 |
-
|
118 |
}
|
119 |
return $this->aAssetsVersions;
|
120 |
}
|
@@ -447,7 +447,7 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
447 |
if ( $this->getCon()->isPluginAdmin() && !isset( $aColumns[ 'icwp_autoupdate' ] ) ) {
|
448 |
$aColumns[ 'icwp_autoupdate' ] = 'Auto Update';
|
449 |
add_action( 'manage_plugins_custom_column',
|
450 |
-
|
451 |
100, 2
|
452 |
);
|
453 |
}
|
@@ -481,13 +481,13 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
481 |
// Are there really updates?
|
482 |
$bReallyUpdates = false;
|
483 |
|
484 |
-
$aEmailContent =
|
485 |
sprintf(
|
486 |
_wpsf__( 'This is a quick notification from the %s that WordPress Automatic Updates just completed on your site with the following results.' ),
|
487 |
$this->getCon()->getHumanName()
|
488 |
),
|
489 |
''
|
490 |
-
|
491 |
|
492 |
$aTrkd = $this->getTrackedAssetsVersions();
|
493 |
|
@@ -520,7 +520,7 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
520 |
$bHasThemesUpdates = false;
|
521 |
$aTrkdThemes = $aTrkd[ 'themes' ];
|
522 |
|
523 |
-
$aTempContent =
|
524 |
foreach ( $aUpdateResults[ 'theme' ] as $oUpdate ) {
|
525 |
$oItem = $oUpdate->item;
|
526 |
$bValidUpdate = isset( $oUpdate->result ) && $oUpdate->result && !empty( $oUpdate->name )
|
@@ -543,7 +543,7 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
543 |
|
544 |
if ( !empty( $aUpdateResults[ 'core' ] ) && is_array( $aUpdateResults[ 'core' ] ) ) {
|
545 |
$bHasCoreUpdates = false;
|
546 |
-
$aTempContent =
|
547 |
foreach ( $aUpdateResults[ 'core' ] as $oUpdate ) {
|
548 |
if ( isset( $oUpdate->result ) && !is_wp_error( $oUpdate->result ) ) {
|
549 |
$aTempContent[] = ' - '.sprintf( 'WordPress was automatically updated to "%s"', $oUpdate->name );
|
@@ -595,7 +595,7 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
595 |
* Removes all filters that have been added from auto-update related WordPress filters
|
596 |
*/
|
597 |
protected function removeAllAutoupdateFilters() {
|
598 |
-
$aFilters =
|
599 |
'allow_minor_auto_core_updates',
|
600 |
'allow_major_auto_core_updates',
|
601 |
'auto_update_translation',
|
@@ -603,7 +603,7 @@ class ICWP_WPSF_Processor_Autoupdates extends ICWP_WPSF_Processor_BaseWpsf {
|
|
603 |
'auto_update_theme',
|
604 |
'automatic_updates_is_vcs_checkout',
|
605 |
'automatic_updater_disabled'
|
606 |
-
|
607 |
foreach ( $aFilters as $sFilter ) {
|
608 |
remove_all_filters( $sFilter );
|
609 |
}
|
37 |
$oFO = $this->getMod();
|
38 |
|
39 |
$nFilterPriority = $this->getHookPriority();
|
40 |
+
add_filter( 'allow_minor_auto_core_updates', [ $this, 'autoupdate_core_minor' ], $nFilterPriority );
|
41 |
+
add_filter( 'allow_major_auto_core_updates', [ $this, 'autoupdate_core_major' ], $nFilterPriority );
|
42 |
|
43 |
+
add_filter( 'auto_update_translation', [ $this, 'autoupdate_translations' ], $nFilterPriority, 1 );
|
44 |
+
add_filter( 'auto_update_plugin', [ $this, 'autoupdate_plugins' ], $nFilterPriority, 2 );
|
45 |
+
add_filter( 'auto_update_theme', [ $this, 'autoupdate_themes' ], $nFilterPriority, 2 );
|
46 |
+
add_filter( 'auto_update_core', [ $this, 'autoupdate_core' ], $nFilterPriority, 2 );
|
47 |
|
48 |
if ( $oFO->isOpt( 'enable_autoupdate_ignore_vcs', 'Y' ) ) {
|
49 |
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false', $nFilterPriority );
|
51 |
|
52 |
if ( !$oFO->isDisableAllAutoUpdates() ) {
|
53 |
//more parameter options here for later
|
54 |
+
add_filter( 'auto_core_update_send_email', [ $this, 'autoupdate_send_email' ], $nFilterPriority, 1 );
|
55 |
+
add_filter( 'auto_core_update_email', [ $this, 'autoupdate_email_override' ], $nFilterPriority, 1 );
|
56 |
|
57 |
+
add_action( 'set_site_transient_update_core', [ $this, 'trackUpdateTimesCore' ] );
|
58 |
+
add_action( 'set_site_transient_update_plugins', [ $this, 'trackUpdateTimesPlugins' ] );
|
59 |
+
add_action( 'set_site_transient_update_themes', [ $this, 'trackUpdateTimesThemes' ] );
|
60 |
|
61 |
if ( $oFO->isSendAutoupdatesNotificationEmail() ) {
|
62 |
$this->trackAssetsVersions();
|
63 |
+
add_action( 'automatic_updates_complete', [ $this, 'sendNotificationEmail' ] );
|
64 |
}
|
65 |
|
66 |
if ( $oFO->isAutoupdateIndividualPlugins() ) {
|
67 |
// Adds automatic update indicator column to all plugins in plugin listing.
|
68 |
+
add_filter( 'manage_plugins_columns', [ $this, 'fAddPluginsListAutoUpdateColumn' ] );
|
69 |
}
|
70 |
}
|
71 |
}
|
111 |
*/
|
112 |
protected function getTrackedAssetsVersions() {
|
113 |
if ( empty( $this->aAssetsVersions ) || !is_array( $this->aAssetsVersions ) ) {
|
114 |
+
$this->aAssetsVersions = [
|
115 |
'plugins' => [],
|
116 |
'themes' => [],
|
117 |
+
];
|
118 |
}
|
119 |
return $this->aAssetsVersions;
|
120 |
}
|
447 |
if ( $this->getCon()->isPluginAdmin() && !isset( $aColumns[ 'icwp_autoupdate' ] ) ) {
|
448 |
$aColumns[ 'icwp_autoupdate' ] = 'Auto Update';
|
449 |
add_action( 'manage_plugins_custom_column',
|
450 |
+
[ $this, 'aPrintPluginsListAutoUpdateColumnContent' ],
|
451 |
100, 2
|
452 |
);
|
453 |
}
|
481 |
// Are there really updates?
|
482 |
$bReallyUpdates = false;
|
483 |
|
484 |
+
$aEmailContent = [
|
485 |
sprintf(
|
486 |
_wpsf__( 'This is a quick notification from the %s that WordPress Automatic Updates just completed on your site with the following results.' ),
|
487 |
$this->getCon()->getHumanName()
|
488 |
),
|
489 |
''
|
490 |
+
];
|
491 |
|
492 |
$aTrkd = $this->getTrackedAssetsVersions();
|
493 |
|
520 |
$bHasThemesUpdates = false;
|
521 |
$aTrkdThemes = $aTrkd[ 'themes' ];
|
522 |
|
523 |
+
$aTempContent = [ _wpsf__( 'Themes Updated:' ) ];
|
524 |
foreach ( $aUpdateResults[ 'theme' ] as $oUpdate ) {
|
525 |
$oItem = $oUpdate->item;
|
526 |
$bValidUpdate = isset( $oUpdate->result ) && $oUpdate->result && !empty( $oUpdate->name )
|
543 |
|
544 |
if ( !empty( $aUpdateResults[ 'core' ] ) && is_array( $aUpdateResults[ 'core' ] ) ) {
|
545 |
$bHasCoreUpdates = false;
|
546 |
+
$aTempContent = [ _wpsf__( 'WordPress Core Updated:' ) ];
|
547 |
foreach ( $aUpdateResults[ 'core' ] as $oUpdate ) {
|
548 |
if ( isset( $oUpdate->result ) && !is_wp_error( $oUpdate->result ) ) {
|
549 |
$aTempContent[] = ' - '.sprintf( 'WordPress was automatically updated to "%s"', $oUpdate->name );
|
595 |
* Removes all filters that have been added from auto-update related WordPress filters
|
596 |
*/
|
597 |
protected function removeAllAutoupdateFilters() {
|
598 |
+
$aFilters = [
|
599 |
'allow_minor_auto_core_updates',
|
600 |
'allow_major_auto_core_updates',
|
601 |
'auto_update_translation',
|
603 |
'auto_update_theme',
|
604 |
'automatic_updates_is_vcs_checkout',
|
605 |
'automatic_updater_disabled'
|
606 |
+
];
|
607 |
foreach ( $aFilters as $sFilter ) {
|
608 |
remove_all_filters( $sFilter );
|
609 |
}
|
@@ -29,19 +29,30 @@ abstract class ICWP_WPSF_Processor_Base extends ICWP_WPSF_Foundation {
|
|
29 |
public function __construct( $oModCon ) {
|
30 |
$this->setMod( $oModCon );
|
31 |
|
32 |
-
add_action( 'init',
|
33 |
-
add_action( 'wp_loaded',
|
34 |
{ // Capture Logins
|
35 |
-
add_action( 'wp_login',
|
36 |
if ( !Services::WpUsers()->isProfilePage() ) { // This can be fired during profile update.
|
37 |
-
add_action( 'set_logged_in_cookie',
|
38 |
}
|
39 |
}
|
40 |
-
add_action( $oModCon->prefix( 'plugin_shutdown' ),
|
41 |
-
add_action( $oModCon->prefix( 'daily_cron' ),
|
42 |
-
add_action( $oModCon->prefix( 'hourly_cron' ),
|
43 |
-
add_action( $oModCon->prefix( 'deactivate_plugin' ),
|
44 |
-
add_action( $oModCon->prefix( 'generate_admin_notices' ),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
$this->init();
|
47 |
}
|
@@ -52,6 +63,9 @@ abstract class ICWP_WPSF_Processor_Base extends ICWP_WPSF_Foundation {
|
|
52 |
public function onWpLoaded() {
|
53 |
}
|
54 |
|
|
|
|
|
|
|
55 |
/**
|
56 |
* @param string $sUsername
|
57 |
* @param WP_User $oUser
|
@@ -132,7 +146,7 @@ abstract class ICWP_WPSF_Processor_Base extends ICWP_WPSF_Foundation {
|
|
132 |
if ( method_exists( $this, $sMethodName ) ) {
|
133 |
$aAttrs[ 'id' ] = $sNoticeId;
|
134 |
$aAttrs[ 'notice_id' ] = $sNoticeId;
|
135 |
-
call_user_func(
|
136 |
}
|
137 |
}
|
138 |
}
|
29 |
public function __construct( $oModCon ) {
|
30 |
$this->setMod( $oModCon );
|
31 |
|
32 |
+
add_action( 'init', [ $this, 'onWpInit' ], 9 );
|
33 |
+
add_action( 'wp_loaded', [ $this, 'onWpLoaded' ] );
|
34 |
{ // Capture Logins
|
35 |
+
add_action( 'wp_login', [ $this, 'onWpLogin' ], 10, 2 );
|
36 |
if ( !Services::WpUsers()->isProfilePage() ) { // This can be fired during profile update.
|
37 |
+
add_action( 'set_logged_in_cookie', [ $this, 'onWpSetLoggedInCookie' ], 5, 4 );
|
38 |
}
|
39 |
}
|
40 |
+
add_action( $oModCon->prefix( 'plugin_shutdown' ), [ $this, 'onModuleShutdown' ] );
|
41 |
+
add_action( $oModCon->prefix( 'daily_cron' ), [ $this, 'runDailyCron' ] );
|
42 |
+
add_action( $oModCon->prefix( 'hourly_cron' ), [ $this, 'runHourlyCron' ] );
|
43 |
+
add_action( $oModCon->prefix( 'deactivate_plugin' ), [ $this, 'deactivatePlugin' ] );
|
44 |
+
add_action( $oModCon->prefix( 'generate_admin_notices' ), [ $this, 'autoAddToAdminNotices' ] );
|
45 |
+
|
46 |
+
/**
|
47 |
+
* 2019-04-19:
|
48 |
+
* wp_service_worker: added to prevent infinite page reloads triggered by an error with the PWA plugin.
|
49 |
+
* It seems that using wp_localize_script() on a request with wp_service_worker=1 causes the worker
|
50 |
+
* reload the page. Why exactly this happens hasn't been investigated, so we just skip any FRONTend
|
51 |
+
* enqueues that might call wp_localize_script() for these requests.
|
52 |
+
*/
|
53 |
+
if ( Services::Request()->query( 'wp_service_worker', 0 ) != 1 ) {
|
54 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'onWpEnqueueJs' ] );
|
55 |
+
}
|
56 |
|
57 |
$this->init();
|
58 |
}
|
63 |
public function onWpLoaded() {
|
64 |
}
|
65 |
|
66 |
+
public function onWpEnqueueJs() {
|
67 |
+
}
|
68 |
+
|
69 |
/**
|
70 |
* @param string $sUsername
|
71 |
* @param WP_User $oUser
|
146 |
if ( method_exists( $this, $sMethodName ) ) {
|
147 |
$aAttrs[ 'id' ] = $sNoticeId;
|
148 |
$aAttrs[ 'notice_id' ] = $sNoticeId;
|
149 |
+
call_user_func( [ $this, $sMethodName ], $aAttrs );
|
150 |
}
|
151 |
}
|
152 |
}
|
@@ -25,17 +25,17 @@ class ICWP_WPSF_Processor_CommentsFilter_Base extends ICWP_WPSF_Processor_BaseWp
|
|
25 |
*/
|
26 |
public function run() {
|
27 |
$oFO = $this->getMod();
|
28 |
-
add_filter( 'preprocess_comment',
|
29 |
-
add_filter( $oFO->prefix( 'cf_status' ),
|
30 |
-
add_filter( $oFO->prefix( 'cf_status_expl' ),
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
* @param array $
|
35 |
* @return array
|
36 |
*/
|
37 |
-
public function doCommentChecking( $
|
38 |
-
return $
|
39 |
}
|
40 |
|
41 |
/**
|
25 |
*/
|
26 |
public function run() {
|
27 |
$oFO = $this->getMod();
|
28 |
+
add_filter( 'preprocess_comment', [ $this, 'doCommentChecking' ], 5 );
|
29 |
+
add_filter( $oFO->prefix( 'cf_status' ), [ $this, 'getCommentStatus' ], 1 );
|
30 |
+
add_filter( $oFO->prefix( 'cf_status_expl' ), [ $this, 'getCommentStatusExplanation' ], 1 );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @param array $aCommData
|
35 |
* @return array
|
36 |
*/
|
37 |
+
public function doCommentChecking( $aCommData ) {
|
38 |
+
return $aCommData;
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -57,17 +57,17 @@ class ICWP_WPSF_Processor_BasePlugin extends ICWP_WPSF_Processor_BaseWpsf {
|
|
57 |
*/
|
58 |
public function addNotice_rate_plugin( $aAttr ) {
|
59 |
|
60 |
-
$aRenderData =
|
61 |
'notice_attributes' => $aAttr,
|
62 |
-
'strings' =>
|
63 |
'title' => 'Will you help us out with a quick WordPress.org review?',
|
64 |
'dismiss' => _wpsf__( "I'd rather not show this support" ).' / '._wpsf__( "I've done this already" ).' :D',
|
65 |
'forums' => __( 'Support Forums' )
|
66 |
-
|
67 |
-
'hrefs' =>
|
68 |
'forums' => 'https://wordpress.org/support/plugin/wp-simple-firewall',
|
69 |
-
|
70 |
-
|
71 |
$this->insertAdminNotice( $aRenderData );
|
72 |
}
|
73 |
|
@@ -80,26 +80,26 @@ class ICWP_WPSF_Processor_BasePlugin extends ICWP_WPSF_Processor_BaseWpsf {
|
|
80 |
$oFO = $this->getMod();
|
81 |
|
82 |
$sName = $this->getCon()->getHumanName();
|
83 |
-
$aRenderData =
|
84 |
'notice_attributes' => $aNoticeAttributes,
|
85 |
-
'strings' =>
|
86 |
'dismiss' => _wpsf__( "I don't need the setup wizard just now" ),
|
87 |
'title' => sprintf( _wpsf__( 'Get started quickly with the %s Setup Wizard' ), $sName ),
|
88 |
'setup' => sprintf( _wpsf__( 'The welcome wizard will help you get setup quickly and become familiar with some of the core %s features' ), $sName ),
|
89 |
'no_setup' => sprintf( _wpsf__( "%s has a helpful setup wizard to walk you through the main features. Unfortunately your PHP version is reeeaally old as it needs PHP 5.4+" ), $sName ),
|
90 |
-
|
91 |
-
'hrefs' =>
|
92 |
'wizard' => $oFO->getUrl_Wizard( 'welcome' ),
|
93 |
-
|
94 |
'flags' => []
|
95 |
-
|
96 |
$this->insertAdminNotice( $aRenderData );
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
-
* @see autoAddToAdminNotices()
|
101 |
* @param array $aNoticeAttributes
|
102 |
* @throws \Exception
|
|
|
103 |
*/
|
104 |
protected function addNotice_plugin_update_available( $aNoticeAttributes ) {
|
105 |
$oPlugin = $this->getCon();
|
@@ -116,43 +116,43 @@ class ICWP_WPSF_Processor_BasePlugin extends ICWP_WPSF_Processor_BaseWpsf {
|
|
116 |
$sBaseFile = $oPlugin->getPluginBaseFile();
|
117 |
if ( $this->getIfShowAdminNotices() && $oWpPlugins->isUpdateAvailable( $sBaseFile )
|
118 |
&& !Services::WpPost()->isPage_Updates() ) { // Don't show on the update page
|
119 |
-
$aRenderData =
|
120 |
'notice_attributes' => $aNoticeAttributes,
|
121 |
'render_slug' => 'plugin-update-available',
|
122 |
-
'strings' =>
|
123 |
'title' => sprintf( _wpsf__( 'Update available for the %s plugin.' ), $this->getCon()
|
124 |
->getHumanName() ),
|
125 |
'click_update' => _wpsf__( 'Please click to update immediately' ),
|
126 |
'dismiss' => _wpsf__( 'Dismiss this notice' )
|
127 |
-
|
128 |
-
'hrefs' =>
|
129 |
'upgrade_link' => $oWpPlugins->getUrl_Upgrade( $sBaseFile )
|
130 |
-
|
131 |
-
|
132 |
$this->insertAdminNotice( $aRenderData );
|
133 |
}
|
134 |
}
|
135 |
|
136 |
/**
|
137 |
-
* @see autoAddToAdminNotices()
|
138 |
* @param array $aNoticeAttributes
|
|
|
139 |
*/
|
140 |
protected function addNotice_translate_plugin( $aNoticeAttributes ) {
|
141 |
if ( $this->getIfShowAdminNotices() ) {
|
142 |
-
$aRenderData =
|
143 |
'notice_attributes' => $aNoticeAttributes,
|
144 |
-
'strings' =>
|
145 |
'title' => 'Você não fala Inglês? No hablas Inglés? Heeft u geen Engels spreekt?',
|
146 |
'like_to_help' => sprintf( _wpsf__( "Can you help translate the %s plugin?" ), $this->getCon()
|
147 |
->getHumanName() ),
|
148 |
'head_over_to' => sprintf( _wpsf__( 'Head over to: %s' ), '' ),
|
149 |
'site_url' => 'translate.icontrolwp.com',
|
150 |
'dismiss' => _wpsf__( 'Dismiss this notice' )
|
151 |
-
|
152 |
-
'hrefs' =>
|
153 |
'translate' => 'http://translate.icontrolwp.com'
|
154 |
-
|
155 |
-
|
156 |
$this->insertAdminNotice( $aRenderData );
|
157 |
}
|
158 |
}
|
57 |
*/
|
58 |
public function addNotice_rate_plugin( $aAttr ) {
|
59 |
|
60 |
+
$aRenderData = [
|
61 |
'notice_attributes' => $aAttr,
|
62 |
+
'strings' => [
|
63 |
'title' => 'Will you help us out with a quick WordPress.org review?',
|
64 |
'dismiss' => _wpsf__( "I'd rather not show this support" ).' / '._wpsf__( "I've done this already" ).' :D',
|
65 |
'forums' => __( 'Support Forums' )
|
66 |
+
],
|
67 |
+
'hrefs' => [
|
68 |
'forums' => 'https://wordpress.org/support/plugin/wp-simple-firewall',
|
69 |
+
]
|
70 |
+
];
|
71 |
$this->insertAdminNotice( $aRenderData );
|
72 |
}
|
73 |
|
80 |
$oFO = $this->getMod();
|
81 |
|
82 |
$sName = $this->getCon()->getHumanName();
|
83 |
+
$aRenderData = [
|
84 |
'notice_attributes' => $aNoticeAttributes,
|
85 |
+
'strings' => [
|
86 |
'dismiss' => _wpsf__( "I don't need the setup wizard just now" ),
|
87 |
'title' => sprintf( _wpsf__( 'Get started quickly with the %s Setup Wizard' ), $sName ),
|
88 |
'setup' => sprintf( _wpsf__( 'The welcome wizard will help you get setup quickly and become familiar with some of the core %s features' ), $sName ),
|
89 |
'no_setup' => sprintf( _wpsf__( "%s has a helpful setup wizard to walk you through the main features. Unfortunately your PHP version is reeeaally old as it needs PHP 5.4+" ), $sName ),
|
90 |
+
],
|
91 |
+
'hrefs' => [
|
92 |
'wizard' => $oFO->getUrl_Wizard( 'welcome' ),
|
93 |
+
],
|
94 |
'flags' => []
|
95 |
+
];
|
96 |
$this->insertAdminNotice( $aRenderData );
|
97 |
}
|
98 |
|
99 |
/**
|
|
|
100 |
* @param array $aNoticeAttributes
|
101 |
* @throws \Exception
|
102 |
+
* @see autoAddToAdminNotices()
|
103 |
*/
|
104 |
protected function addNotice_plugin_update_available( $aNoticeAttributes ) {
|
105 |
$oPlugin = $this->getCon();
|
116 |
$sBaseFile = $oPlugin->getPluginBaseFile();
|
117 |
if ( $this->getIfShowAdminNotices() && $oWpPlugins->isUpdateAvailable( $sBaseFile )
|
118 |
&& !Services::WpPost()->isPage_Updates() ) { // Don't show on the update page
|
119 |
+
$aRenderData = [
|
120 |
'notice_attributes' => $aNoticeAttributes,
|
121 |
'render_slug' => 'plugin-update-available',
|
122 |
+
'strings' => [
|
123 |
'title' => sprintf( _wpsf__( 'Update available for the %s plugin.' ), $this->getCon()
|
124 |
->getHumanName() ),
|
125 |
'click_update' => _wpsf__( 'Please click to update immediately' ),
|
126 |
'dismiss' => _wpsf__( 'Dismiss this notice' )
|
127 |
+
],
|
128 |
+
'hrefs' => [
|
129 |
'upgrade_link' => $oWpPlugins->getUrl_Upgrade( $sBaseFile )
|
130 |
+
]
|
131 |
+
];
|
132 |
$this->insertAdminNotice( $aRenderData );
|
133 |
}
|
134 |
}
|
135 |
|
136 |
/**
|
|
|
137 |
* @param array $aNoticeAttributes
|
138 |
+
* @see autoAddToAdminNotices()
|
139 |
*/
|
140 |
protected function addNotice_translate_plugin( $aNoticeAttributes ) {
|
141 |
if ( $this->getIfShowAdminNotices() ) {
|
142 |
+
$aRenderData = [
|
143 |
'notice_attributes' => $aNoticeAttributes,
|
144 |
+
'strings' => [
|
145 |
'title' => 'Você não fala Inglês? No hablas Inglés? Heeft u geen Engels spreekt?',
|
146 |
'like_to_help' => sprintf( _wpsf__( "Can you help translate the %s plugin?" ), $this->getCon()
|
147 |
->getHumanName() ),
|
148 |
'head_over_to' => sprintf( _wpsf__( 'Head over to: %s' ), '' ),
|
149 |
'site_url' => 'translate.icontrolwp.com',
|
150 |
'dismiss' => _wpsf__( 'Dismiss this notice' )
|
151 |
+
],
|
152 |
+
'hrefs' => [
|
153 |
'translate' => 'http://translate.icontrolwp.com'
|
154 |
+
]
|
155 |
+
];
|
156 |
$this->insertAdminNotice( $aRenderData );
|
157 |
}
|
158 |
}
|
@@ -25,8 +25,8 @@ abstract class ICWP_WPSF_Processor_BaseWpsf extends ICWP_WPSF_Processor_Base {
|
|
25 |
public function init() {
|
26 |
parent::init();
|
27 |
$oFO = $this->getMod();
|
28 |
-
add_filter( $oFO->prefix( 'collect_stats' ),
|
29 |
-
add_filter( $oFO->prefix( 'collect_tracking_data' ),
|
30 |
}
|
31 |
|
32 |
/**
|
@@ -129,19 +129,19 @@ abstract class ICWP_WPSF_Processor_BaseWpsf extends ICWP_WPSF_Processor_Base {
|
|
129 |
|
130 |
public function registerGoogleRecaptchaJs() {
|
131 |
$sJsUri = add_query_arg(
|
132 |
-
|
133 |
'hl' => $this->getGoogleRecaptchaLocale(),
|
134 |
'onload' => 'onLoadIcwpRecaptchaCallback',
|
135 |
'render' => 'explicit',
|
136 |
-
|
137 |
'https://www.google.com/recaptcha/api.js'
|
138 |
);
|
139 |
wp_register_script( self::RECAPTCHA_JS_HANDLE, $sJsUri, [], false, true );
|
140 |
wp_enqueue_script( self::RECAPTCHA_JS_HANDLE );
|
141 |
|
142 |
// This also gives us the chance to remove recaptcha before it's printed, if it isn't needed
|
143 |
-
add_action( 'wp_footer',
|
144 |
-
add_action( 'login_footer',
|
145 |
|
146 |
$this->loadWpIncludes()
|
147 |
->addIncludeAttribute( self::RECAPTCHA_JS_HANDLE, 'async', 'async' )
|
@@ -207,7 +207,7 @@ abstract class ICWP_WPSF_Processor_BaseWpsf extends ICWP_WPSF_Processor_Base {
|
|
207 |
$aData = [];
|
208 |
}
|
209 |
$oFO = $this->getMod();
|
210 |
-
$aData[ $oFO->getSlug() ] =
|
211 |
return $aData;
|
212 |
}
|
213 |
|
@@ -250,12 +250,12 @@ abstract class ICWP_WPSF_Processor_BaseWpsf extends ICWP_WPSF_Processor_Base {
|
|
250 |
echo $this->loadRenderer( $this->getCon()->getPath_Templates() )
|
251 |
->setTemplateEnginePhp()
|
252 |
->setRenderVars(
|
253 |
-
|
254 |
'sitekey' => $oFO->getGoogleRecaptchaSiteKey(),
|
255 |
'size' => $this->isRecaptchaInvisible() ? 'invisible' : '',
|
256 |
'theme' => $this->getRecaptchaTheme(),
|
257 |
'invis' => $this->isRecaptchaInvisible(),
|
258 |
-
|
259 |
)
|
260 |
->setTemplate( 'snippets/google_recaptcha_js' )
|
261 |
->render();
|
@@ -284,8 +284,8 @@ abstract class ICWP_WPSF_Processor_BaseWpsf extends ICWP_WPSF_Processor_Base {
|
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
-
* @deprecated
|
288 |
* @return bool
|
|
|
289 |
*/
|
290 |
protected function getIfIpTransgressed() {
|
291 |
/** @var ICWP_WPSF_FeatureHandler_BaseWpsf $oFO */
|
25 |
public function init() {
|
26 |
parent::init();
|
27 |
$oFO = $this->getMod();
|
28 |
+
add_filter( $oFO->prefix( 'collect_stats' ), [ $this, 'stats_Collect' ] );
|
29 |
+
add_filter( $oFO->prefix( 'collect_tracking_data' ), [ $this, 'tracking_DataCollect' ] );
|
30 |
}
|
31 |
|
32 |
/**
|
129 |
|
130 |
public function registerGoogleRecaptchaJs() {
|
131 |
$sJsUri = add_query_arg(
|
132 |
+
[
|
133 |
'hl' => $this->getGoogleRecaptchaLocale(),
|
134 |
'onload' => 'onLoadIcwpRecaptchaCallback',
|
135 |
'render' => 'explicit',
|
136 |
+
],
|
137 |
'https://www.google.com/recaptcha/api.js'
|
138 |
);
|
139 |
wp_register_script( self::RECAPTCHA_JS_HANDLE, $sJsUri, [], false, true );
|
140 |
wp_enqueue_script( self::RECAPTCHA_JS_HANDLE );
|
141 |
|
142 |
// This also gives us the chance to remove recaptcha before it's printed, if it isn't needed
|
143 |
+
add_action( 'wp_footer', [ $this, 'maybeDequeueRecaptcha' ], -100 );
|
144 |
+
add_action( 'login_footer', [ $this, 'maybeDequeueRecaptcha' ], -100 );
|
145 |
|
146 |
$this->loadWpIncludes()
|
147 |
->addIncludeAttribute( self::RECAPTCHA_JS_HANDLE, 'async', 'async' )
|
207 |
$aData = [];
|
208 |
}
|
209 |
$oFO = $this->getMod();
|
210 |
+
$aData[ $oFO->getSlug() ] = [ 'options' => $oFO->collectOptionsForTracking() ];
|
211 |
return $aData;
|
212 |
}
|
213 |
|
250 |
echo $this->loadRenderer( $this->getCon()->getPath_Templates() )
|
251 |
->setTemplateEnginePhp()
|
252 |
->setRenderVars(
|
253 |
+
[
|
254 |
'sitekey' => $oFO->getGoogleRecaptchaSiteKey(),
|
255 |
'size' => $this->isRecaptchaInvisible() ? 'invisible' : '',
|
256 |
'theme' => $this->getRecaptchaTheme(),
|
257 |
'invis' => $this->isRecaptchaInvisible(),
|
258 |
+
]
|
259 |
)
|
260 |
->setTemplate( 'snippets/google_recaptcha_js' )
|
261 |
->render();
|
284 |
}
|
285 |
|
286 |
/**
|
|
|
287 |
* @return bool
|
288 |
+
* @deprecated
|
289 |
*/
|
290 |
protected function getIfIpTransgressed() {
|
291 |
/** @var ICWP_WPSF_FeatureHandler_BaseWpsf $oFO */
|
@@ -39,7 +39,7 @@ abstract class ICWP_WPSF_BaseDbProcessor extends ICWP_WPSF_Processor_BaseWpsf {
|
|
39 |
->setSqlCreate( $this->getCreateTableSql() )
|
40 |
->tableInit();
|
41 |
|
42 |
-
add_action( $this->getMod()->prefix( 'delete_plugin' ),
|
43 |
}
|
44 |
|
45 |
/**
|
39 |
->setSqlCreate( $this->getCreateTableSql() )
|
40 |
->tableInit();
|
41 |
|
42 |
+
add_action( $this->getMod()->prefix( 'delete_plugin' ), [ $this->getDbHandler(), 'deleteTable' ] );
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -11,10 +11,11 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
11 |
|
12 |
public function onWpInit() {
|
13 |
parent::onWpInit();
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
$oFO = $this->getMod();
|
18 |
if ( $oFO->isEnabledGaspCheck() ) {
|
19 |
$this->getSubProGasp()->run();
|
20 |
}
|
@@ -25,9 +26,9 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
25 |
$this->getSubProRecaptcha()->run();
|
26 |
}
|
27 |
|
28 |
-
add_filter( 'pre_comment_approved',
|
29 |
-
add_filter( 'pre_comment_content',
|
30 |
-
add_filter( 'comment_notification_recipients',
|
31 |
}
|
32 |
}
|
33 |
|
@@ -76,18 +77,18 @@ class ICWP_WPSF_Processor_CommentsFilter extends ICWP_WPSF_Processor_BaseWpsf {
|
|
76 |
$oWpPlugins = Services::WpPlugins();
|
77 |
$sPluginFile = $oWpPlugins->findPluginBy( 'Akismet', 'Name' );
|
78 |
if ( $oWpPlugins->isActive( $sPluginFile ) ) {
|
79 |
-
$aRenderData =
|
80 |
'notice_attributes' => $aNoticeAttributes,
|
81 |
-
'strings' =>
|
82 |
'title' => 'Akismet is Running',
|
83 |
'appears_running_akismet' => _wpsf__( 'It appears you have Akismet Anti-SPAM running alongside the our human Anti-SPAM filter.' ),
|
84 |
'not_recommended' => _wpsf__( 'This is not recommended and you should disable Akismet.' ),
|
85 |
'click_to_deactivate' => _wpsf__( 'Click to deactivate Akismet now.' ),
|
86 |
-
|
87 |
-
'hrefs' =>
|
88 |
'deactivate' => $oWpPlugins->getUrl_Deactivate( $sPluginFile )
|
89 |
-
|
90 |
-
|
91 |
$this->insertAdminNotice( $aRenderData );
|
92 |
}
|
93 |
}
|
11 |
|
12 |
public function onWpInit() {
|
13 |
parent::onWpInit();
|
14 |
+
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
15 |
+
$oFO = $this->getMod();
|
16 |
|
17 |
+
$oUser = Services::WpUsers()->getCurrentWpUser();
|
18 |
+
if ( !$oFO->isUserTrusted( $oUser ) ) {
|
|
|
19 |
if ( $oFO->isEnabledGaspCheck() ) {
|
20 |
$this->getSubProGasp()->run();
|
21 |
}
|
26 |
$this->getSubProRecaptcha()->run();
|
27 |
}
|
28 |
|
29 |
+
add_filter( 'pre_comment_approved', [ $this, 'doSetCommentStatus' ], 1 );
|
30 |
+
add_filter( 'pre_comment_content', [ $this, 'doInsertCommentStatusExplanation' ], 1, 1 );
|
31 |
+
add_filter( 'comment_notification_recipients', [ $this, 'clearCommentNotificationEmail' ], 100, 1 );
|
32 |
}
|
33 |
}
|
34 |
|
77 |
$oWpPlugins = Services::WpPlugins();
|
78 |
$sPluginFile = $oWpPlugins->findPluginBy( 'Akismet', 'Name' );
|
79 |
if ( $oWpPlugins->isActive( $sPluginFile ) ) {
|
80 |
+
$aRenderData = [
|
81 |
'notice_attributes' => $aNoticeAttributes,
|
82 |
+
'strings' => [
|
83 |
'title' => 'Akismet is Running',
|
84 |
'appears_running_akismet' => _wpsf__( 'It appears you have Akismet Anti-SPAM running alongside the our human Anti-SPAM filter.' ),
|
85 |
'not_recommended' => _wpsf__( 'This is not recommended and you should disable Akismet.' ),
|
86 |
'click_to_deactivate' => _wpsf__( 'Click to deactivate Akismet now.' ),
|
87 |
+
],
|
88 |
+
'hrefs' => [
|
89 |
'deactivate' => $oWpPlugins->getUrl_Deactivate( $sPluginFile )
|
90 |
+
]
|
91 |
+
];
|
92 |
$this->insertAdminNotice( $aRenderData );
|
93 |
}
|
94 |
}
|
@@ -41,7 +41,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
41 |
}
|
42 |
|
43 |
public function setupForm() {
|
44 |
-
if (
|
45 |
add_action( 'comment_form', array( $this, 'printGaspFormItems' ), 1 );
|
46 |
}
|
47 |
}
|
@@ -65,24 +65,25 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
-
* @param array $
|
69 |
* @return array
|
70 |
*/
|
71 |
-
public function doCommentChecking( $
|
72 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
73 |
$oFO = $this->getMod();
|
74 |
|
75 |
-
|
76 |
-
|
|
|
|
|
77 |
|
78 |
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
79 |
if ( $this->sCommentStatus == 'reject' ) {
|
80 |
-
|
81 |
-
$oWp->doRedirect( $oWp->getHomeUrl(), [], true, false );
|
82 |
}
|
83 |
}
|
84 |
|
85 |
-
return $
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -90,9 +91,6 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
90 |
* @param $nPostId
|
91 |
*/
|
92 |
protected function doGaspCommentCheck( $nPostId ) {
|
93 |
-
if ( !$this->getIfDoGaspCheck() ) {
|
94 |
-
return;
|
95 |
-
}
|
96 |
|
97 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
98 |
$oFO = $this->getMod();
|
@@ -147,27 +145,13 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
147 |
}
|
148 |
}
|
149 |
|
150 |
-
/**
|
151 |
-
* Tells us whether, for this particular comment post, if we should do GASP comments checking.
|
152 |
-
* @return boolean
|
153 |
-
*/
|
154 |
-
protected function getIfDoGaspCheck() {
|
155 |
-
$bCheck = true;
|
156 |
-
|
157 |
-
if ( function_exists( 'WPWall_Init' ) && !is_null( $this->loadRequest()->post( 'submit_wall_post' ) ) ) {
|
158 |
-
$bCheck = false; // Compatibility with shoutbox WP Wall Plugin http://wordpress.org/plugins/wp-wall/
|
159 |
-
}
|
160 |
-
|
161 |
-
return $bCheck;
|
162 |
-
}
|
163 |
-
|
164 |
/**
|
165 |
* @return Comments\EntryVO|null
|
166 |
*/
|
167 |
protected function initCommentFormToken() {
|
168 |
/** @var Comments\EntryVO $oToken */
|
169 |
$oToken = $this->getDbHandler()->getVo();
|
170 |
-
$oToken->post_id =
|
171 |
$oToken->unique_token = md5( $this->getCon()->getUniqueRequestId( false ) );
|
172 |
return $this->getDbHandler()
|
173 |
->getQueryInserter()
|
@@ -295,7 +279,7 @@ class ICWP_WPSF_Processor_CommentsFilter_AntiBotSpam extends ICWP_WPSF_BaseDbPro
|
|
295 |
*/
|
296 |
protected function getUniqueFormId() {
|
297 |
if ( !isset( $this->sFormId ) ) {
|
298 |
-
$oDp =
|
299 |
$sId = $oDp->generateRandomLetter().$oDp->generateRandomString( rand( 7, 23 ), 7 );
|
300 |
$this->sFormId = preg_replace(
|
301 |
'#[^a-zA-Z0-9]#', '',
|
41 |
}
|
42 |
|
43 |
public function setupForm() {
|
44 |
+
if ( !Services::Request()->isPost() ) {
|
45 |
add_action( 'comment_form', array( $this, 'printGaspFormItems' ), 1 );
|
46 |
}
|
47 |
}
|
65 |
}
|
66 |
|
67 |
/**
|
68 |
+
* @param array $aCommData
|
69 |
* @return array
|
70 |
*/
|
71 |
+
public function doCommentChecking( $aCommData ) {
|
72 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
73 |
$oFO = $this->getMod();
|
74 |
|
75 |
+
$nPostId = $aCommData[ 'comment_post_ID' ];
|
76 |
+
if ( $oFO->getIfDoCommentsCheck( $nPostId, $aCommData[ 'comment_author_email' ] ) ) {
|
77 |
+
|
78 |
+
$this->doGaspCommentCheck( $nPostId );
|
79 |
|
80 |
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
81 |
if ( $this->sCommentStatus == 'reject' ) {
|
82 |
+
Services::Response()->redirectToHome();
|
|
|
83 |
}
|
84 |
}
|
85 |
|
86 |
+
return $aCommData;
|
87 |
}
|
88 |
|
89 |
/**
|
91 |
* @param $nPostId
|
92 |
*/
|
93 |
protected function doGaspCommentCheck( $nPostId ) {
|
|
|
|
|
|
|
94 |
|
95 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
96 |
$oFO = $this->getMod();
|
145 |
}
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
/**
|
149 |
* @return Comments\EntryVO|null
|
150 |
*/
|
151 |
protected function initCommentFormToken() {
|
152 |
/** @var Comments\EntryVO $oToken */
|
153 |
$oToken = $this->getDbHandler()->getVo();
|
154 |
+
$oToken->post_id = Services::WpPost()->getCurrentPostId();
|
155 |
$oToken->unique_token = md5( $this->getCon()->getUniqueRequestId( false ) );
|
156 |
return $this->getDbHandler()
|
157 |
->getQueryInserter()
|
279 |
*/
|
280 |
protected function getUniqueFormId() {
|
281 |
if ( !isset( $this->sFormId ) ) {
|
282 |
+
$oDp = Services::Data();
|
283 |
$sId = $oDp->generateRandomLetter().$oDp->generateRandomString( rand( 7, 23 ), 7 );
|
284 |
$this->sFormId = preg_replace(
|
285 |
'#[^a-zA-Z0-9]#', '',
|
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Processor_CommentsFilter_Base {
|
4 |
|
5 |
/**
|
@@ -42,14 +44,14 @@ class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Proce
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* @param array $
|
46 |
* @return array
|
47 |
*/
|
48 |
-
public function doCommentChecking( $
|
49 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
50 |
$oFO = $this->getMod();
|
51 |
|
52 |
-
if ( $oFO->getIfDoCommentsCheck() ) {
|
53 |
|
54 |
try {
|
55 |
$this->checkRequestRecaptcha();
|
@@ -66,12 +68,11 @@ class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Proce
|
|
66 |
->setIpTransgressed();
|
67 |
|
68 |
if ( self::$sCommentStatus == 'reject' ) {
|
69 |
-
|
70 |
-
$oWp->doRedirect( $oWp->getHomeUrl(), [], true, false );
|
71 |
}
|
72 |
}
|
73 |
}
|
74 |
|
75 |
-
return $
|
76 |
}
|
77 |
}
|
1 |
<?php
|
2 |
|
3 |
+
use FernleafSystems\Wordpress\Services\Services;
|
4 |
+
|
5 |
class ICWP_WPSF_Processor_CommentsFilter_GoogleRecaptcha extends ICWP_WPSF_Processor_CommentsFilter_Base {
|
6 |
|
7 |
/**
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* @param array $aCommData
|
48 |
* @return array
|
49 |
*/
|
50 |
+
public function doCommentChecking( $aCommData ) {
|
51 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
52 |
$oFO = $this->getMod();
|
53 |
|
54 |
+
if ( $oFO->getIfDoCommentsCheck( $aCommData[ 'comment_post_ID' ], $aCommData[ 'comment_author_email' ] ) ) {
|
55 |
|
56 |
try {
|
57 |
$this->checkRequestRecaptcha();
|
68 |
->setIpTransgressed();
|
69 |
|
70 |
if ( self::$sCommentStatus == 'reject' ) {
|
71 |
+
Services::Response()->redirectToHome();
|
|
|
72 |
}
|
73 |
}
|
74 |
}
|
75 |
|
76 |
+
return $aCommData;
|
77 |
}
|
78 |
}
|
@@ -4,70 +4,32 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
4 |
|
5 |
class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_CommentsFilter_Base {
|
6 |
|
7 |
-
const Spam_Blacklist_Source = 'https://raw.githubusercontent.com/splorp/wordpress-comment-blacklist/master/blacklist.txt';
|
8 |
-
|
9 |
-
/**
|
10 |
-
*/
|
11 |
-
public function run() {
|
12 |
-
parent::run();
|
13 |
-
add_filter( $this->getMod()->prefix( 'if-do-comments-check' ), array( $this, 'getIfDoCommentsCheck' ) );
|
14 |
-
}
|
15 |
-
|
16 |
/**
|
17 |
-
* @param
|
18 |
-
* @return bool
|
19 |
-
*/
|
20 |
-
public function getIfDoCommentsCheck( $fIfDoCheck ) {
|
21 |
-
if ( !$fIfDoCheck ) {
|
22 |
-
return $fIfDoCheck;
|
23 |
-
}
|
24 |
-
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
25 |
-
$oFO = $this->getMod();
|
26 |
-
|
27 |
-
$oWpComments = $this->loadWpComments();
|
28 |
-
|
29 |
-
// 1st are comments enabled on this post?
|
30 |
-
$nPostId = $oFO->getCommentItem( 'comment_post_ID' );
|
31 |
-
$oPost = $nPostId ? $this->loadWp()->getPostById( $nPostId ) : null;
|
32 |
-
if ( $oPost ) {
|
33 |
-
$fIfDoCheck = $oWpComments->isCommentsOpen( $oPost );
|
34 |
-
}
|
35 |
-
|
36 |
-
if ( $fIfDoCheck && $oWpComments->getIfAllowCommentsByPreviouslyApproved()
|
37 |
-
&& $oWpComments->isAuthorApproved( $oFO->getCommentItem( 'comment_author_email' ) ) ) {
|
38 |
-
$fIfDoCheck = false;
|
39 |
-
}
|
40 |
-
|
41 |
-
return $fIfDoCheck;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @param array $aCommentData
|
46 |
* @return array
|
47 |
*/
|
48 |
-
public function doCommentChecking( $
|
49 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
50 |
$oFO = $this->getMod();
|
51 |
|
52 |
-
if ( $oFO->getIfDoCommentsCheck() ) {
|
53 |
|
54 |
$this->performBlacklistSpamCheck(
|
55 |
-
$
|
56 |
-
$
|
57 |
-
$
|
58 |
-
$
|
59 |
$this->ip(),
|
60 |
substr( Services::Request()->getUserAgent(), 0, 254 )
|
61 |
);
|
62 |
|
63 |
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
64 |
if ( self::$sCommentStatus == 'reject' ) {
|
65 |
-
|
66 |
-
$oWp->doRedirect( $oWp->getHomeUrl(), [], true, false );
|
67 |
}
|
68 |
}
|
69 |
|
70 |
-
return $
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -90,34 +52,25 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
90 |
if ( !empty( $sCurrentStatus ) ) {
|
91 |
return;
|
92 |
}
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
'author_email' => $sEmail,
|
105 |
-
'ip_address' => $sUserIp,
|
106 |
-
'user_agent' => $sUserAgent
|
107 |
);
|
108 |
-
$aDesiredItemsToCheck = $this->getOption( 'enable_comments_human_spam_filter_items' );
|
109 |
-
$aItemsToCheck = [];
|
110 |
-
foreach ( $aDesiredItemsToCheck as $sKey ) {
|
111 |
-
$aItemsToCheck[ $sKey ] = $aItemsMap[ $sKey ];
|
112 |
-
}
|
113 |
|
114 |
-
foreach ( $
|
115 |
-
foreach ( $
|
116 |
-
if ( stripos( $sItem, $
|
117 |
-
//mark as spam and exit;
|
118 |
$this->doStatIncrement( sprintf( 'spam.human.%s', $sKey ) );
|
119 |
$this->setCommentStatus( $this->getOption( 'comments_default_action_human_spam' ) );
|
120 |
-
$this->setCommentStatusExplanation( sprintf( _wpsf__( 'Human SPAM filter found "%s" in "%s"' ), $
|
121 |
$oFO->setOptInsightsAt( 'last_comment_block_at' )
|
122 |
->setIpTransgressed();
|
123 |
break 2;
|
@@ -127,68 +80,39 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
-
* @return
|
131 |
*/
|
132 |
-
|
133 |
-
$
|
|
|
134 |
$sBLFile = $this->getSpamBlacklistFile();
|
135 |
|
136 |
-
//
|
137 |
-
if ( !$oFs->exists( $sBLFile ) || ( $this->time() - $oFs->getModifiedTime( $sBLFile ) >
|
138 |
-
$this->
|
|
|
139 |
}
|
140 |
-
return $this->readSpamList();
|
141 |
-
}
|
142 |
|
143 |
-
/**
|
144 |
-
* @return string
|
145 |
-
*/
|
146 |
-
protected function readSpamList() {
|
147 |
-
$oFs = $this->loadFS();
|
148 |
-
$sBLFile = $this->getSpamBlacklistFile();
|
149 |
if ( $oFs->exists( $sBLFile ) ) {
|
150 |
$sList = $oFs->getFileContent( $sBLFile );
|
151 |
if ( !empty( $sList ) ) {
|
152 |
-
|
153 |
}
|
154 |
}
|
155 |
-
return
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
*/
|
160 |
-
protected function doSpamBlacklistUpdate() {
|
161 |
-
Services::WpFs()->deleteFile( $this->getSpamBlacklistFile() );
|
162 |
-
$this->doSpamBlacklistImport();
|
163 |
}
|
164 |
|
165 |
/**
|
166 |
*/
|
167 |
-
|
168 |
-
$oFs =
|
169 |
$sBLFile = $this->getSpamBlacklistFile();
|
170 |
if ( !$oFs->exists( $sBLFile ) ) {
|
171 |
-
|
172 |
-
$
|
173 |
-
|
174 |
-
|
175 |
-
$sList = '';
|
176 |
}
|
177 |
-
else {
|
178 |
-
// filter out empty lines
|
179 |
-
$aWords = explode( "\n", $sRawList );
|
180 |
-
foreach ( $aWords as $nIndex => $sWord ) {
|
181 |
-
$sWord = trim( $sWord );
|
182 |
-
if ( empty( $sWord ) ) {
|
183 |
-
unset( $aWords[ $nIndex ] );
|
184 |
-
}
|
185 |
-
else {
|
186 |
-
$aWords[ $nIndex ] = base64_encode( $sWord );
|
187 |
-
}
|
188 |
-
}
|
189 |
-
$sList = implode( "\n", $aWords );
|
190 |
-
}
|
191 |
-
|
192 |
// save the list to disk for the future.
|
193 |
$oFs->putFileContent( $sBLFile, $sList );
|
194 |
}
|
@@ -197,14 +121,7 @@ class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_C
|
|
197 |
/**
|
198 |
* @return string
|
199 |
*/
|
200 |
-
|
201 |
-
return
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @return string
|
206 |
-
*/
|
207 |
-
protected function getSpamBlacklistFile() {
|
208 |
-
return $this->getCon()->getPath_Assets( 'spamblacklist.txt' );
|
209 |
}
|
210 |
}
|
4 |
|
5 |
class ICWP_WPSF_Processor_CommentsFilter_HumanSpam extends ICWP_WPSF_Processor_CommentsFilter_Base {
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
/**
|
8 |
+
* @param array $aCommData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
* @return array
|
10 |
*/
|
11 |
+
public function doCommentChecking( $aCommData ) {
|
12 |
/** @var ICWP_WPSF_FeatureHandler_CommentsFilter $oFO */
|
13 |
$oFO = $this->getMod();
|
14 |
|
15 |
+
if ( $oFO->getIfDoCommentsCheck( $aCommData[ 'comment_post_ID' ], $aCommData[ 'comment_author_email' ] ) ) {
|
16 |
|
17 |
$this->performBlacklistSpamCheck(
|
18 |
+
$aCommData[ 'comment_author' ],
|
19 |
+
$aCommData[ 'comment_author_email' ],
|
20 |
+
$aCommData[ 'comment_author_url' ],
|
21 |
+
$aCommData[ 'comment_content' ],
|
22 |
$this->ip(),
|
23 |
substr( Services::Request()->getUserAgent(), 0, 254 )
|
24 |
);
|
25 |
|
26 |
// Now we check whether comment status is to completely reject and then we simply redirect to "home"
|
27 |
if ( self::$sCommentStatus == 'reject' ) {
|
28 |
+
Services::Response()->redirectToHome();
|
|
|
29 |
}
|
30 |
}
|
31 |
|
32 |
+
return $aCommData;
|
33 |
}
|
34 |
|
35 |
/**
|
52 |
if ( !empty( $sCurrentStatus ) ) {
|
53 |
return;
|
54 |
}
|
55 |
+
|
56 |
+
$aItemsToCheck = array_intersect_key(
|
57 |
+
[
|
58 |
+
'comment_content' => $sComment,
|
59 |
+
'url' => $sUrl,
|
60 |
+
'author_name' => $sAuthor,
|
61 |
+
'author_email' => $sEmail,
|
62 |
+
'ip_address' => $sUserIp,
|
63 |
+
'user_agent' => $sUserAgent
|
64 |
+
],
|
65 |
+
array_flip( $oFO->getHumanSpamFilterItems() )
|
|
|
|
|
|
|
66 |
);
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
foreach ( $this->getSpamBlacklist() as $sBlacklistWord ) {
|
69 |
+
foreach ( $aItemsToCheck as $sKey => $sItem ) {
|
70 |
+
if ( stripos( $sItem, $sBlacklistWord ) !== false ) { //mark as spam and exit;
|
|
|
71 |
$this->doStatIncrement( sprintf( 'spam.human.%s', $sKey ) );
|
72 |
$this->setCommentStatus( $this->getOption( 'comments_default_action_human_spam' ) );
|
73 |
+
$this->setCommentStatusExplanation( sprintf( _wpsf__( 'Human SPAM filter found "%s" in "%s"' ), $sBlacklistWord, $sKey ) );
|
74 |
$oFO->setOptInsightsAt( 'last_comment_block_at' )
|
75 |
->setIpTransgressed();
|
76 |
break 2;
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* @return string[]
|
84 |
*/
|
85 |
+
private function getSpamBlacklist() {
|
86 |
+
$aList = [];
|
87 |
+
$oFs = Services::WpFs();
|
88 |
$sBLFile = $this->getSpamBlacklistFile();
|
89 |
|
90 |
+
// Download if doesn't exist or expired.
|
91 |
+
if ( !$oFs->exists( $sBLFile ) || ( $this->time() - $oFs->getModifiedTime( $sBLFile ) > WEEK_IN_SECONDS ) ) {
|
92 |
+
Services::WpFs()->deleteFile( $this->getSpamBlacklistFile() );
|
93 |
+
$this->importBlacklist();
|
94 |
}
|
|
|
|
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
if ( $oFs->exists( $sBLFile ) ) {
|
97 |
$sList = $oFs->getFileContent( $sBLFile );
|
98 |
if ( !empty( $sList ) ) {
|
99 |
+
$aList = array_map( 'base64_decode', explode( "\n", $sList ) );
|
100 |
}
|
101 |
}
|
102 |
+
return $aList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
*/
|
107 |
+
private function importBlacklist() {
|
108 |
+
$oFs = Services::WpFs();
|
109 |
$sBLFile = $this->getSpamBlacklistFile();
|
110 |
if ( !$oFs->exists( $sBLFile ) ) {
|
111 |
+
$sRawList = Services::HttpRequest()->getContent( $this->getMod()->getDef( 'url_spam_blacklist_terms' ) );
|
112 |
+
$sList = '';
|
113 |
+
if ( !empty( $sRawList ) ) {
|
114 |
+
$sList = implode( "\n", array_map( 'base64_encode', array_filter( array_map( 'trim', explode( "\n", $sRawList ) ) ) ) );
|
|
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
// save the list to disk for the future.
|
117 |
$oFs->putFileContent( $sBLFile, $sList );
|
118 |
}
|
121 |
/**
|
122 |
* @return string
|
123 |
*/
|
124 |
+
private function getSpamBlacklistFile() {
|
125 |
+
return $this->getCon()->getPluginCachePath( 'spamblacklist.txt' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
}
|
@@ -11,11 +11,6 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
11 |
*/
|
12 |
private $aDieMessage;
|
13 |
|
14 |
-
/**
|
15 |
-
* @var bool
|
16 |
-
*/
|
17 |
-
private $bDoFirewallBlock;
|
18 |
-
|
19 |
/**
|
20 |
* @var array
|
21 |
*/
|
@@ -43,42 +38,33 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
43 |
/**
|
44 |
* @return bool
|
45 |
*/
|
46 |
-
|
47 |
-
|
48 |
-
$this->bDoFirewallBlock = !$this->isVisitorRequestPermitted();
|
49 |
-
}
|
50 |
-
return $this->bDoFirewallBlock;
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
* @return bool
|
55 |
*/
|
56 |
-
|
57 |
$bPerformScan = true;
|
58 |
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
59 |
$oFO = $this->getMod();
|
60 |
|
|
|
|
|
61 |
if ( count( $this->getRawRequestParams() ) == 0 ) {
|
62 |
$bPerformScan = false;
|
63 |
}
|
64 |
-
|
65 |
-
// if we couldn't process the REQUEST_URI parts, we can't firewall so we effectively whitelist without erroring.
|
66 |
-
$sPath = Services::Request()->getPath();
|
67 |
-
if ( $bPerformScan && empty( $sPath ) ) {
|
68 |
$sAuditMessage = sprintf( _wpsf__( 'Skipping firewall checking for this visit: %s.' ), _wpsf__( 'Parsing the URI failed' ) );
|
69 |
$this->addToAuditEntry( $sAuditMessage, 2, 'firewall_skip' );
|
70 |
$bPerformScan = false;
|
71 |
}
|
72 |
-
|
73 |
-
$aPageParamsToCheck = $this->getParamsToCheck();
|
74 |
-
if ( $bPerformScan && empty( $aPageParamsToCheck ) ) {
|
75 |
-
// $sAuditMessage = sprintf( _wpsf__('Skipping firewall checking for this visit: %s.'), _wpsf__('After whitelist options were applied, there were no page parameters to check') );
|
76 |
-
// $this->addToAuditEntry( $sAuditMessage, 1, 'firewall_skip' );
|
77 |
$bPerformScan = false;
|
78 |
}
|
79 |
-
|
80 |
// TODO: are we calling is_super_admin() too early?
|
81 |
-
if ( $
|
82 |
$bPerformScan = false;
|
83 |
}
|
84 |
|
@@ -88,7 +74,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
88 |
/**
|
89 |
* @return boolean - true if visitor is permitted, false if it should be blocked.
|
90 |
*/
|
91 |
-
|
92 |
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
93 |
$oFO = $this->getMod();
|
94 |
|
@@ -136,7 +122,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
136 |
$aMatchTerms = $this->getFirewallPatterns( 'exefile' );
|
137 |
if ( isset( $aMatchTerms[ 'regex' ] ) && is_array( $aMatchTerms[ 'regex' ] ) ) {
|
138 |
|
139 |
-
$aMatchTerms[ 'regex' ] = array_map(
|
140 |
foreach ( $aMatchTerms[ 'regex' ] as $sTerm ) {
|
141 |
foreach ( $aFileNames as $sParam => $mValue ) {
|
142 |
if ( is_scalar( $mValue ) && preg_match( $sTerm, (string)$mValue ) ) {
|
@@ -186,7 +172,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
186 |
}
|
187 |
|
188 |
if ( !$bFAIL && isset( $aMatchTerms[ 'regex' ] ) && is_array( $aMatchTerms[ 'regex' ] ) ) {
|
189 |
-
$aMatchTerms[ 'regex' ] = array_map(
|
190 |
foreach ( $aMatchTerms[ 'regex' ] as $sTerm ) {
|
191 |
foreach ( $aParamValues as $sParam => $mValue ) {
|
192 |
if ( is_scalar( $mValue ) && preg_match( $sTerm, (string)$mValue ) ) {
|
@@ -210,11 +196,11 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
210 |
|
211 |
$this->addToAuditEntry(
|
212 |
implode( "\n", $this->aAuditBlockMessage ), 3, 'firewall_block',
|
213 |
-
|
214 |
'param' => $sParam,
|
215 |
'val' => $mValue,
|
216 |
'blockkey' => $sBlockKey,
|
217 |
-
|
218 |
);
|
219 |
$this->doStatIncrement( 'firewall.blocked.'.$sBlockKey );
|
220 |
}
|
@@ -246,73 +232,66 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
246 |
|
247 |
/**
|
248 |
*/
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
253 |
-
$oFO = $this->getMod();
|
254 |
-
|
255 |
-
switch ( $oFO->getBlockResponse() ) {
|
256 |
-
case 'redirect_die':
|
257 |
-
$sMessage = _wpsf__( 'Visitor connection was killed with wp_die()' );
|
258 |
-
break;
|
259 |
-
case 'redirect_die_message':
|
260 |
-
$sMessage = _wpsf__( 'Visitor connection was killed with wp_die() and a message' );
|
261 |
-
break;
|
262 |
-
case 'redirect_home':
|
263 |
-
$sMessage = _wpsf__( 'Visitor was sent HOME' );
|
264 |
-
break;
|
265 |
-
case 'redirect_404':
|
266 |
-
$sMessage = _wpsf__( 'Visitor was sent 404' );
|
267 |
-
break;
|
268 |
-
default:
|
269 |
-
$sMessage = _wpsf__( 'Unknown' );
|
270 |
-
break;
|
271 |
-
}
|
272 |
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
-
|
276 |
-
if ( $this->sendBlockEmail( $sRecipient ) ) {
|
277 |
-
$this->addToAuditEntry( sprintf( _wpsf__( 'Successfully sent Firewall Block email alert to: %s' ), $sRecipient ) );
|
278 |
-
}
|
279 |
-
else {
|
280 |
-
$this->addToAuditEntry( sprintf( _wpsf__( 'Failed to send Firewall Block email alert to: %s' ), $sRecipient ) );
|
281 |
-
}
|
282 |
-
}
|
283 |
|
284 |
-
$oFO->
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
287 |
}
|
|
|
|
|
|
|
|
|
288 |
}
|
289 |
|
290 |
/**
|
291 |
*/
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
break;
|
311 |
-
default:
|
312 |
-
break;
|
313 |
-
}
|
314 |
-
exit();
|
315 |
}
|
|
|
316 |
}
|
317 |
|
318 |
/**
|
@@ -320,7 +299,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
320 |
*/
|
321 |
protected function getFirewallDieMessage() {
|
322 |
if ( !isset( $this->aDieMessage ) || !is_array( $this->aDieMessage ) ) {
|
323 |
-
$this->aDieMessage =
|
324 |
}
|
325 |
return $this->aDieMessage;
|
326 |
}
|
@@ -351,17 +330,19 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
351 |
/**
|
352 |
* @return array
|
353 |
*/
|
354 |
-
|
355 |
if ( isset( $this->aPageParams ) ) {
|
356 |
return $this->aPageParams;
|
357 |
}
|
|
|
|
|
358 |
|
359 |
$this->aPageParams = $this->getRawRequestParams();
|
360 |
-
$
|
361 |
|
362 |
// first we remove globally whitelisted request parameters
|
363 |
-
if ( !empty( $
|
364 |
-
foreach ( $
|
365 |
|
366 |
if ( preg_match( '#^/.+/$#', $sWhitelistParam ) ) {
|
367 |
foreach ( array_keys( $this->aPageParams ) as $sParamKey ) {
|
@@ -383,7 +364,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
383 |
|
384 |
// Now we run through the list of whitelist pages
|
385 |
$sRequestPage = Services::Request()->getPath();
|
386 |
-
foreach ( $
|
387 |
|
388 |
// if the page is white listed
|
389 |
if ( strpos( $sRequestPage, $sWhitelistPageName ) !== false ) {
|
@@ -414,19 +395,6 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
414 |
return Services::Request()->getRawRequestParams( $this->getMod()->isOpt( 'include_cookie_checks', 'Y' ) );
|
415 |
}
|
416 |
|
417 |
-
/**
|
418 |
-
* @return array
|
419 |
-
*/
|
420 |
-
protected function getWhitelistPages() {
|
421 |
-
if ( !isset( $this->aWhitelist ) ) {
|
422 |
-
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
423 |
-
$oFO = $this->getMod();
|
424 |
-
$this->aWhitelist = $this->loadDP()
|
425 |
-
->mergeArraysRecursive( $oFO->getDefaultWhitelist(), $oFO->getCustomWhitelist() );
|
426 |
-
}
|
427 |
-
return $this->aWhitelist;
|
428 |
-
}
|
429 |
-
|
430 |
/**
|
431 |
* @param string $sRecipient
|
432 |
* @return bool
|
@@ -456,6 +424,7 @@ class ICWP_WPSF_Processor_Firewall extends ICWP_WPSF_Processor_BaseWpsf {
|
|
456 |
return $this->getEmailProcessor()
|
457 |
->sendEmailWithWrap( $sRecipient, _wpsf__( 'Firewall Block Alert' ), $aMessage );
|
458 |
}
|
|
|
459 |
}
|
460 |
|
461 |
/**
|
11 |
*/
|
12 |
private $aDieMessage;
|
13 |
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* @var array
|
16 |
*/
|
38 |
/**
|
39 |
* @return bool
|
40 |
*/
|
41 |
+
private function getIfDoFirewallBlock() {
|
42 |
+
return !$this->isVisitorRequestPermitted();
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
* @return bool
|
47 |
*/
|
48 |
+
private function getIfPerformFirewallScan() {
|
49 |
$bPerformScan = true;
|
50 |
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
51 |
$oFO = $this->getMod();
|
52 |
|
53 |
+
$sPath = Services::Request()->getPath();
|
54 |
+
|
55 |
if ( count( $this->getRawRequestParams() ) == 0 ) {
|
56 |
$bPerformScan = false;
|
57 |
}
|
58 |
+
else if ( empty( $sPath ) ) {
|
|
|
|
|
|
|
59 |
$sAuditMessage = sprintf( _wpsf__( 'Skipping firewall checking for this visit: %s.' ), _wpsf__( 'Parsing the URI failed' ) );
|
60 |
$this->addToAuditEntry( $sAuditMessage, 2, 'firewall_skip' );
|
61 |
$bPerformScan = false;
|
62 |
}
|
63 |
+
else if ( count( $this->getParamsToCheck() ) == 0 ) {
|
|
|
|
|
|
|
|
|
64 |
$bPerformScan = false;
|
65 |
}
|
|
|
66 |
// TODO: are we calling is_super_admin() too early?
|
67 |
+
else if ( $oFO->isIgnoreAdmin() && is_super_admin() ) {
|
68 |
$bPerformScan = false;
|
69 |
}
|
70 |
|
74 |
/**
|
75 |
* @return boolean - true if visitor is permitted, false if it should be blocked.
|
76 |
*/
|
77 |
+
private function isVisitorRequestPermitted() {
|
78 |
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
79 |
$oFO = $this->getMod();
|
80 |
|
122 |
$aMatchTerms = $this->getFirewallPatterns( 'exefile' );
|
123 |
if ( isset( $aMatchTerms[ 'regex' ] ) && is_array( $aMatchTerms[ 'regex' ] ) ) {
|
124 |
|
125 |
+
$aMatchTerms[ 'regex' ] = array_map( [ $this, 'prepRegexTerms' ], $aMatchTerms[ 'regex' ] );
|
126 |
foreach ( $aMatchTerms[ 'regex' ] as $sTerm ) {
|
127 |
foreach ( $aFileNames as $sParam => $mValue ) {
|
128 |
if ( is_scalar( $mValue ) && preg_match( $sTerm, (string)$mValue ) ) {
|
172 |
}
|
173 |
|
174 |
if ( !$bFAIL && isset( $aMatchTerms[ 'regex' ] ) && is_array( $aMatchTerms[ 'regex' ] ) ) {
|
175 |
+
$aMatchTerms[ 'regex' ] = array_map( [ $this, 'prepRegexTerms' ], $aMatchTerms[ 'regex' ] );
|
176 |
foreach ( $aMatchTerms[ 'regex' ] as $sTerm ) {
|
177 |
foreach ( $aParamValues as $sParam => $mValue ) {
|
178 |
if ( is_scalar( $mValue ) && preg_match( $sTerm, (string)$mValue ) ) {
|
196 |
|
197 |
$this->addToAuditEntry(
|
198 |
implode( "\n", $this->aAuditBlockMessage ), 3, 'firewall_block',
|
199 |
+
[
|
200 |
'param' => $sParam,
|
201 |
'val' => $mValue,
|
202 |
'blockkey' => $sBlockKey,
|
203 |
+
]
|
204 |
);
|
205 |
$this->doStatIncrement( 'firewall.blocked.'.$sBlockKey );
|
206 |
}
|
232 |
|
233 |
/**
|
234 |
*/
|
235 |
+
private function doPreFirewallBlock() {
|
236 |
+
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
237 |
+
$oFO = $this->getMod();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
+
switch ( $oFO->getBlockResponse() ) {
|
240 |
+
case 'redirect_die':
|
241 |
+
$sMessage = _wpsf__( 'Visitor connection was killed with wp_die()' );
|
242 |
+
break;
|
243 |
+
case 'redirect_die_message':
|
244 |
+
$sMessage = _wpsf__( 'Visitor connection was killed with wp_die() and a message' );
|
245 |
+
break;
|
246 |
+
case 'redirect_home':
|
247 |
+
$sMessage = _wpsf__( 'Visitor was sent HOME' );
|
248 |
+
break;
|
249 |
+
case 'redirect_404':
|
250 |
+
$sMessage = _wpsf__( 'Visitor was sent 404' );
|
251 |
+
break;
|
252 |
+
default:
|
253 |
+
$sMessage = _wpsf__( 'Unknown' );
|
254 |
+
break;
|
255 |
+
}
|
256 |
|
257 |
+
if ( $oFO->isOpt( 'block_send_email', 'Y' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
$sRecipient = $oFO->getPluginDefaultRecipientAddress();
|
260 |
+
if ( $this->sendBlockEmail( $sRecipient ) ) {
|
261 |
+
$this->addToAuditEntry( sprintf( _wpsf__( 'Successfully sent Firewall Block email alert to: %s' ), $sRecipient ) );
|
262 |
+
}
|
263 |
+
else {
|
264 |
+
$this->addToAuditEntry( sprintf( _wpsf__( 'Failed to send Firewall Block email alert to: %s' ), $sRecipient ) );
|
265 |
+
}
|
266 |
}
|
267 |
+
|
268 |
+
$oFO->setOptInsightsAt( 'last_firewall_block_at' )
|
269 |
+
->setIpTransgressed();
|
270 |
+
$this->addToAuditEntry( sprintf( _wpsf__( 'Firewall Block Response: %s.' ), $sMessage ) );
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
*/
|
275 |
+
private function doFirewallBlock() {
|
276 |
+
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
277 |
+
$oFO = $this->getMod();
|
278 |
+
|
279 |
+
switch ( $oFO->getBlockResponse() ) {
|
280 |
+
case 'redirect_die':
|
281 |
+
break;
|
282 |
+
case 'redirect_die_message':
|
283 |
+
Services::WpGeneral()->wpDie( $this->getFirewallDieMessageForDisplay() );
|
284 |
+
break;
|
285 |
+
case 'redirect_home':
|
286 |
+
Services::Response()->redirectToHome();
|
287 |
+
break;
|
288 |
+
case 'redirect_404':
|
289 |
+
Services::Response()->redirect( '404' );
|
290 |
+
break;
|
291 |
+
default:
|
292 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
+
die();
|
295 |
}
|
296 |
|
297 |
/**
|
299 |
*/
|
300 |
protected function getFirewallDieMessage() {
|
301 |
if ( !isset( $this->aDieMessage ) || !is_array( $this->aDieMessage ) ) {
|
302 |
+
$this->aDieMessage = [ $this->getMod()->getTextOpt( 'text_firewalldie' ) ];
|
303 |
}
|
304 |
return $this->aDieMessage;
|
305 |
}
|
330 |
/**
|
331 |
* @return array
|
332 |
*/
|
333 |
+
private function getParamsToCheck() {
|
334 |
if ( isset( $this->aPageParams ) ) {
|
335 |
return $this->aPageParams;
|
336 |
}
|
337 |
+
/** @var ICWP_WPSF_FeatureHandler_Firewall $oFO */
|
338 |
+
$oFO = $this->getMod();
|
339 |
|
340 |
$this->aPageParams = $this->getRawRequestParams();
|
341 |
+
$aWhitelist = $this->loadDP()->mergeArraysRecursive( $oFO->getDefaultWhitelist(), $oFO->getCustomWhitelist() );
|
342 |
|
343 |
// first we remove globally whitelisted request parameters
|
344 |
+
if ( !empty( $aWhitelist[ '*' ] ) && is_array( $aWhitelist[ '*' ] ) ) {
|
345 |
+
foreach ( $aWhitelist[ '*' ] as $sWhitelistParam ) {
|
346 |
|
347 |
if ( preg_match( '#^/.+/$#', $sWhitelistParam ) ) {
|
348 |
foreach ( array_keys( $this->aPageParams ) as $sParamKey ) {
|
364 |
|
365 |
// Now we run through the list of whitelist pages
|
366 |
$sRequestPage = Services::Request()->getPath();
|
367 |
+
foreach ( $aWhitelist as $sWhitelistPageName => $aWhitelistPageParams ) {
|
368 |
|
369 |
// if the page is white listed
|
370 |
if ( strpos( $sRequestPage, $sWhitelistPageName ) !== false ) {
|
395 |
return Services::Request()->getRawRequestParams( $this->getMod()->isOpt( 'include_cookie_checks', 'Y' ) );
|
396 |
}
|
397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
/**
|
399 |
* @param string $sRecipient
|
400 |
* @return bool
|
424 |
return $this->getEmailProcessor()
|
425 |
->sendEmailWithWrap( $sRecipient, _wpsf__( 'Firewall Block Alert' ), $aMessage );
|
426 |
}
|
427 |
+
return true;
|
428 |
}
|
429 |
|
430 |
/**
|
@@ -17,7 +17,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
17 |
$this->revSliderPatch_AFU();
|
18 |
}
|
19 |
// not probably necessary any longer since it's patched in the Core
|
20 |
-
add_filter( 'pre_comment_content',
|
21 |
|
22 |
$this->getSubProScanner()->run();
|
23 |
if ( $oMod->isRtEnabledWpConfig() ) {
|
@@ -70,7 +70,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
70 |
$sAction = $oReq->query( 'action', '' );
|
71 |
$sFileExt = strtolower( Services::Data()->getExtension( $oReq->query( 'img', '' ) ) );
|
72 |
if ( $sAction == 'revslider_show_image' && !empty( $sFileExt ) ) {
|
73 |
-
if ( !in_array( $sFileExt,
|
74 |
die( 'RevSlider Local File Inclusion Attempt' );
|
75 |
}
|
76 |
}
|
@@ -99,8 +99,8 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
99 |
$oSelector = $oPro->getSubProScanner()->getDbHandler()->getQuerySelector();
|
100 |
|
101 |
$oCarbon = new \Carbon\Carbon();
|
102 |
-
$aData =
|
103 |
-
'ajax' =>
|
104 |
'start_scans' => $oMod->getAjaxActionData( 'start_scans', true ),
|
105 |
'render_table_scan' => $oMod->getAjaxActionData( 'render_table_scan', true ),
|
106 |
'bulk_action' => $oMod->getAjaxActionData( 'bulk_action', true ),
|
@@ -110,112 +110,134 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
110 |
'item_delete' => $oMod->getAjaxActionData( 'item_delete', true ),
|
111 |
'item_ignore' => $oMod->getAjaxActionData( 'item_ignore', true ),
|
112 |
'item_repair' => $oMod->getAjaxActionData( 'item_repair', true ),
|
113 |
-
|
114 |
-
'flags' =>
|
115 |
'is_premium' => $oMod->isPremium()
|
116 |
-
|
117 |
-
'strings' =>
|
118 |
'never' => _wpsf__( 'Never' ),
|
119 |
'go_pro' => 'Go Pro!',
|
120 |
'options' => _wpsf__( 'Scan Options' ),
|
121 |
'not_available' => _wpsf__( 'Sorry, this scan is not available.' ),
|
122 |
'not_enabled' => _wpsf__( 'This scan is not currently enabled.' ),
|
123 |
'please_enable' => _wpsf__( 'Please turn on this scan in the options.' ),
|
124 |
-
|
125 |
'vars' => [
|
126 |
],
|
127 |
-
'scans' =>
|
128 |
-
'apc' =>
|
129 |
-
'flags' =>
|
130 |
'is_enabled' => true,
|
131 |
'is_available' => true,
|
132 |
'has_items' => true,
|
133 |
'has_last_scan' => $oMod->getLastScanAt( 'apc' ) > 0
|
134 |
-
|
135 |
-
'hrefs' =>
|
136 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_scan_apc' )
|
137 |
-
|
138 |
-
'vars' =>
|
139 |
'last_scan_at' => sprintf(
|
140 |
_wpsf__( 'Last Scan: %s' ),
|
141 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'apc' ) )->diffForHumans()
|
142 |
),
|
143 |
-
|
144 |
'count' => $oSelector->countForScan( 'apc' ),
|
145 |
-
'strings' =>
|
146 |
'title' => _wpsf__( 'Abandoned Plugins Check' ),
|
147 |
'subtitle' => _wpsf__( "Discover abandoned plugins" )
|
148 |
-
|
149 |
-
|
150 |
-
'wcf' =>
|
151 |
-
'flags' =>
|
152 |
'is_enabled' => true,
|
153 |
'is_available' => true,
|
154 |
'has_items' => true,
|
155 |
'has_last_scan' => $oMod->getLastScanAt( 'wcf' ) > 0
|
156 |
-
|
157 |
-
'hrefs' =>
|
158 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' )
|
159 |
-
|
160 |
-
'vars' =>
|
161 |
'last_scan_at' => sprintf(
|
162 |
_wpsf__( 'Last Scan: %s' ),
|
163 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'wcf' ) )->diffForHumans()
|
164 |
),
|
165 |
-
|
166 |
'count' => $oSelector->countForScan( 'wcf' ),
|
167 |
-
'strings' =>
|
168 |
'title' => _wpsf__( 'WordPress Core File Integrity' ),
|
169 |
'subtitle' => _wpsf__( "Detects changes to core WordPress files" )
|
170 |
-
|
171 |
-
|
172 |
-
'ufc' =>
|
173 |
-
'flags' =>
|
174 |
'is_enabled' => true,
|
175 |
'is_available' => true,
|
176 |
'has_items' => true,
|
177 |
'has_last_scan' => $oMod->getLastScanAt( 'ufc' ) > 0
|
178 |
-
|
179 |
-
'hrefs' =>
|
180 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' )
|
181 |
-
|
182 |
-
'vars' =>
|
183 |
'last_scan_at' => sprintf(
|
184 |
_wpsf__( 'Last Scan: %s' ),
|
185 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'ufc' ) )->diffForHumans()
|
186 |
),
|
187 |
-
|
188 |
'count' => $oSelector->countForScan( 'ufc' ),
|
189 |
-
'strings' =>
|
190 |
'title' => _wpsf__( 'Unrecognised Core Files' ),
|
191 |
'subtitle' => _wpsf__( "Detects files that maybe shouldn't be there" )
|
192 |
-
|
193 |
-
|
194 |
-
'
|
195 |
-
'flags' =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
'is_enabled' => $oMod->isWpvulnEnabled(),
|
197 |
'is_available' => $oMod->isPremium(),
|
198 |
'has_items' => true,
|
199 |
'has_last_scan' => $oMod->getLastScanAt( 'wpv' ) > 0
|
200 |
-
|
201 |
-
'hrefs' =>
|
202 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_wpvuln_scan' )
|
203 |
-
|
204 |
-
'vars' =>
|
205 |
'last_scan_at' => sprintf(
|
206 |
_wpsf__( 'Last Scan: %s' ),
|
207 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'wpv' ) )->diffForHumans()
|
208 |
),
|
209 |
-
|
210 |
'count' => $oSelector->countForScan( 'wpv' ),
|
211 |
-
'strings' =>
|
212 |
'title' => _wpsf__( 'Plugin / Theme Vulnerabilities' ),
|
213 |
'subtitle' => _wpsf__( "Alerts on known security vulnerabilities" )
|
214 |
-
|
215 |
-
|
216 |
'ptg' => $this->getInsightVarsScan_Ptg(),
|
217 |
-
|
218 |
-
|
219 |
|
220 |
return $aData;
|
221 |
}
|
@@ -260,7 +282,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
260 |
$bInstalled = $oWpPlugins->isInstalled( $oIT->slug );
|
261 |
$bIsWpOrg = $bInstalled && $oWpPlugins->isWpOrg( $sSlug );
|
262 |
$bHasUpdate = $bIsWpOrg && $oWpPlugins->isUpdateAvailable( $sSlug );
|
263 |
-
$aProfile =
|
264 |
'id' => $oSelector->filterByHash( $oIT->hash )->first()->id,
|
265 |
'name' => _wpsf__( 'unknown' ),
|
266 |
'version' => _wpsf__( 'unknown' ),
|
@@ -272,7 +294,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
272 |
'has_update' => $bHasUpdate,
|
273 |
'count_files' => $oItemRS->countItems(),
|
274 |
'date_snapshot' => $aMeta[ 'ts' ],
|
275 |
-
|
276 |
|
277 |
if ( $bInstalled ) {
|
278 |
$oP = $oWpPlugins->getPluginAsVo( $oIT->slug );
|
@@ -309,7 +331,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
309 |
$bInstalled = $oWpThemes->isInstalled( $oIT->slug );
|
310 |
$bIsWpOrg = $bInstalled && $oWpThemes->isWpOrg( $sSlug );
|
311 |
$bHasUpdate = $bIsWpOrg && $oWpThemes->isUpdateAvailable( $sSlug );
|
312 |
-
$aProfile =
|
313 |
'id' => $oSelector->filterByHash( $oIT->hash )->first()->id,
|
314 |
'name' => _wpsf__( 'unknown' ),
|
315 |
'version' => _wpsf__( 'unknown' ),
|
@@ -321,7 +343,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
321 |
'has_update' => $bHasUpdate,
|
322 |
'count_files' => $oItemRS->countItems(),
|
323 |
'date_snapshot' => $aMeta[ 'ts' ],
|
324 |
-
|
325 |
if ( $bInstalled ) {
|
326 |
$oT = $oWpThemes->getTheme( $oIT->slug );
|
327 |
$aProfile[ 'name' ] = $oT->get( 'Name' );
|
@@ -333,28 +355,28 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
333 |
$aThemes[ $sSlug ] = $aProfile;
|
334 |
}
|
335 |
|
336 |
-
return
|
337 |
-
'flags' =>
|
338 |
'is_enabled' => $oMod->isPtgEnabled(),
|
339 |
'is_available' => $oMod->isPremium(),
|
340 |
'has_last_scan' => $oMod->getLastScanAt( 'ptg' ) > 0,
|
341 |
'has_items' => $oFullResults->hasItems(),
|
342 |
'has_plugins' => !empty( $aPlugins ),
|
343 |
'has_themes' => !empty( $aThemes ),
|
344 |
-
|
345 |
-
'hrefs' =>
|
346 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
347 |
'please_enable' => $oMod->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
348 |
-
|
349 |
-
'vars' =>
|
350 |
'last_scan_at' => sprintf(
|
351 |
_wpsf__( 'Last Scan: %s' ),
|
352 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'ptg' ) )->diffForHumans()
|
353 |
)
|
354 |
-
|
355 |
'count' => $oSelector->countForScan( 'ptg' ),
|
356 |
'assets' => array_merge( $aPlugins, $aThemes ),
|
357 |
-
'strings' =>
|
358 |
'title' => _wpsf__( 'Plugin / Theme Modifications' ),
|
359 |
'subtitle' => _wpsf__( "Detects unauthorized changes to plugins/themes" ),
|
360 |
'files_with_problems' => _wpsf__( 'Files with problems' ),
|
@@ -364,7 +386,7 @@ class ICWP_WPSF_Processor_HackProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
364 |
'deactivate' => __( 'Deactivate and Ignore' ),
|
365 |
'accept' => _wpsf__( 'Accept' ),
|
366 |
'update' => _wpsf__( 'Upgrade' ),
|
367 |
-
|
368 |
-
|
369 |
}
|
370 |
}
|
17 |
$this->revSliderPatch_AFU();
|
18 |
}
|
19 |
// not probably necessary any longer since it's patched in the Core
|
20 |
+
add_filter( 'pre_comment_content', [ $this, 'secXss64kb' ], 0, 1 );
|
21 |
|
22 |
$this->getSubProScanner()->run();
|
23 |
if ( $oMod->isRtEnabledWpConfig() ) {
|
70 |
$sAction = $oReq->query( 'action', '' );
|
71 |
$sFileExt = strtolower( Services::Data()->getExtension( $oReq->query( 'img', '' ) ) );
|
72 |
if ( $sAction == 'revslider_show_image' && !empty( $sFileExt ) ) {
|
73 |
+
if ( !in_array( $sFileExt, [ 'jpg', 'jpeg', 'png', 'tiff', 'tif', 'gif' ] ) ) {
|
74 |
die( 'RevSlider Local File Inclusion Attempt' );
|
75 |
}
|
76 |
}
|
99 |
$oSelector = $oPro->getSubProScanner()->getDbHandler()->getQuerySelector();
|
100 |
|
101 |
$oCarbon = new \Carbon\Carbon();
|
102 |
+
$aData = [
|
103 |
+
'ajax' => [
|
104 |
'start_scans' => $oMod->getAjaxActionData( 'start_scans', true ),
|
105 |
'render_table_scan' => $oMod->getAjaxActionData( 'render_table_scan', true ),
|
106 |
'bulk_action' => $oMod->getAjaxActionData( 'bulk_action', true ),
|
110 |
'item_delete' => $oMod->getAjaxActionData( 'item_delete', true ),
|
111 |
'item_ignore' => $oMod->getAjaxActionData( 'item_ignore', true ),
|
112 |
'item_repair' => $oMod->getAjaxActionData( 'item_repair', true ),
|
113 |
+
],
|
114 |
+
'flags' => [
|
115 |
'is_premium' => $oMod->isPremium()
|
116 |
+
],
|
117 |
+
'strings' => [
|
118 |
'never' => _wpsf__( 'Never' ),
|
119 |
'go_pro' => 'Go Pro!',
|
120 |
'options' => _wpsf__( 'Scan Options' ),
|
121 |
'not_available' => _wpsf__( 'Sorry, this scan is not available.' ),
|
122 |
'not_enabled' => _wpsf__( 'This scan is not currently enabled.' ),
|
123 |
'please_enable' => _wpsf__( 'Please turn on this scan in the options.' ),
|
124 |
+
],
|
125 |
'vars' => [
|
126 |
],
|
127 |
+
'scans' => [
|
128 |
+
'apc' => [
|
129 |
+
'flags' => [
|
130 |
'is_enabled' => true,
|
131 |
'is_available' => true,
|
132 |
'has_items' => true,
|
133 |
'has_last_scan' => $oMod->getLastScanAt( 'apc' ) > 0
|
134 |
+
],
|
135 |
+
'hrefs' => [
|
136 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_scan_apc' )
|
137 |
+
],
|
138 |
+
'vars' => [
|
139 |
'last_scan_at' => sprintf(
|
140 |
_wpsf__( 'Last Scan: %s' ),
|
141 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'apc' ) )->diffForHumans()
|
142 |
),
|
143 |
+
],
|
144 |
'count' => $oSelector->countForScan( 'apc' ),
|
145 |
+
'strings' => [
|
146 |
'title' => _wpsf__( 'Abandoned Plugins Check' ),
|
147 |
'subtitle' => _wpsf__( "Discover abandoned plugins" )
|
148 |
+
],
|
149 |
+
],
|
150 |
+
'wcf' => [
|
151 |
+
'flags' => [
|
152 |
'is_enabled' => true,
|
153 |
'is_available' => true,
|
154 |
'has_items' => true,
|
155 |
'has_last_scan' => $oMod->getLastScanAt( 'wcf' ) > 0
|
156 |
+
],
|
157 |
+
'hrefs' => [
|
158 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_core_file_integrity_scan' )
|
159 |
+
],
|
160 |
+
'vars' => [
|
161 |
'last_scan_at' => sprintf(
|
162 |
_wpsf__( 'Last Scan: %s' ),
|
163 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'wcf' ) )->diffForHumans()
|
164 |
),
|
165 |
+
],
|
166 |
'count' => $oSelector->countForScan( 'wcf' ),
|
167 |
+
'strings' => [
|
168 |
'title' => _wpsf__( 'WordPress Core File Integrity' ),
|
169 |
'subtitle' => _wpsf__( "Detects changes to core WordPress files" )
|
170 |
+
],
|
171 |
+
],
|
172 |
+
'ufc' => [
|
173 |
+
'flags' => [
|
174 |
'is_enabled' => true,
|
175 |
'is_available' => true,
|
176 |
'has_items' => true,
|
177 |
'has_last_scan' => $oMod->getLastScanAt( 'ufc' ) > 0
|
178 |
+
],
|
179 |
+
'hrefs' => [
|
180 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_unrecognised_file_scan' )
|
181 |
+
],
|
182 |
+
'vars' => [
|
183 |
'last_scan_at' => sprintf(
|
184 |
_wpsf__( 'Last Scan: %s' ),
|
185 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'ufc' ) )->diffForHumans()
|
186 |
),
|
187 |
+
],
|
188 |
'count' => $oSelector->countForScan( 'ufc' ),
|
189 |
+
'strings' => [
|
190 |
'title' => _wpsf__( 'Unrecognised Core Files' ),
|
191 |
'subtitle' => _wpsf__( "Detects files that maybe shouldn't be there" )
|
192 |
+
],
|
193 |
+
],
|
194 |
+
// 'mal' => [
|
195 |
+
// 'flags' => [
|
196 |
+
// 'is_enabled' => $oMod->isMalScanEnabled(),
|
197 |
+
// 'is_available' => $oMod->isPremium(),
|
198 |
+
// 'has_items' => true,
|
199 |
+
// 'has_last_scan' => $oMod->getLastScanAt( 'mal' ) > 0
|
200 |
+
// ],
|
201 |
+
// 'hrefs' => [
|
202 |
+
// 'options' => $oMod->getUrl_DirectLinkToSection( 'section_scan_malware' )
|
203 |
+
// ],
|
204 |
+
// 'vars' => [
|
205 |
+
// 'last_scan_at' => sprintf(
|
206 |
+
// _wpsf__( 'Last Scan: %s' ),
|
207 |
+
// $oCarbon->setTimestamp( $oMod->getLastScanAt( 'mal' ) )->diffForHumans()
|
208 |
+
// ),
|
209 |
+
// ],
|
210 |
+
// 'count' => $oSelector->countForScan( 'mal' ),
|
211 |
+
// 'strings' => [
|
212 |
+
// 'title' => _wpsf__( 'Malware Scanner' ),
|
213 |
+
// 'subtitle' => _wpsf__( "Detects malware in files" )
|
214 |
+
// ],
|
215 |
+
// ],
|
216 |
+
'wpv' => [
|
217 |
+
'flags' => [
|
218 |
'is_enabled' => $oMod->isWpvulnEnabled(),
|
219 |
'is_available' => $oMod->isPremium(),
|
220 |
'has_items' => true,
|
221 |
'has_last_scan' => $oMod->getLastScanAt( 'wpv' ) > 0
|
222 |
+
],
|
223 |
+
'hrefs' => [
|
224 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_wpvuln_scan' )
|
225 |
+
],
|
226 |
+
'vars' => [
|
227 |
'last_scan_at' => sprintf(
|
228 |
_wpsf__( 'Last Scan: %s' ),
|
229 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'wpv' ) )->diffForHumans()
|
230 |
),
|
231 |
+
],
|
232 |
'count' => $oSelector->countForScan( 'wpv' ),
|
233 |
+
'strings' => [
|
234 |
'title' => _wpsf__( 'Plugin / Theme Vulnerabilities' ),
|
235 |
'subtitle' => _wpsf__( "Alerts on known security vulnerabilities" )
|
236 |
+
],
|
237 |
+
],
|
238 |
'ptg' => $this->getInsightVarsScan_Ptg(),
|
239 |
+
],
|
240 |
+
];
|
241 |
|
242 |
return $aData;
|
243 |
}
|
282 |
$bInstalled = $oWpPlugins->isInstalled( $oIT->slug );
|
283 |
$bIsWpOrg = $bInstalled && $oWpPlugins->isWpOrg( $sSlug );
|
284 |
$bHasUpdate = $bIsWpOrg && $oWpPlugins->isUpdateAvailable( $sSlug );
|
285 |
+
$aProfile = [
|
286 |
'id' => $oSelector->filterByHash( $oIT->hash )->first()->id,
|
287 |
'name' => _wpsf__( 'unknown' ),
|
288 |
'version' => _wpsf__( 'unknown' ),
|
294 |
'has_update' => $bHasUpdate,
|
295 |
'count_files' => $oItemRS->countItems(),
|
296 |
'date_snapshot' => $aMeta[ 'ts' ],
|
297 |
+
];
|
298 |
|
299 |
if ( $bInstalled ) {
|
300 |
$oP = $oWpPlugins->getPluginAsVo( $oIT->slug );
|
331 |
$bInstalled = $oWpThemes->isInstalled( $oIT->slug );
|
332 |
$bIsWpOrg = $bInstalled && $oWpThemes->isWpOrg( $sSlug );
|
333 |
$bHasUpdate = $bIsWpOrg && $oWpThemes->isUpdateAvailable( $sSlug );
|
334 |
+
$aProfile = [
|
335 |
'id' => $oSelector->filterByHash( $oIT->hash )->first()->id,
|
336 |
'name' => _wpsf__( 'unknown' ),
|
337 |
'version' => _wpsf__( 'unknown' ),
|
343 |
'has_update' => $bHasUpdate,
|
344 |
'count_files' => $oItemRS->countItems(),
|
345 |
'date_snapshot' => $aMeta[ 'ts' ],
|
346 |
+
];
|
347 |
if ( $bInstalled ) {
|
348 |
$oT = $oWpThemes->getTheme( $oIT->slug );
|
349 |
$aProfile[ 'name' ] = $oT->get( 'Name' );
|
355 |
$aThemes[ $sSlug ] = $aProfile;
|
356 |
}
|
357 |
|
358 |
+
return [
|
359 |
+
'flags' => [
|
360 |
'is_enabled' => $oMod->isPtgEnabled(),
|
361 |
'is_available' => $oMod->isPremium(),
|
362 |
'has_last_scan' => $oMod->getLastScanAt( 'ptg' ) > 0,
|
363 |
'has_items' => $oFullResults->hasItems(),
|
364 |
'has_plugins' => !empty( $aPlugins ),
|
365 |
'has_themes' => !empty( $aThemes ),
|
366 |
+
],
|
367 |
+
'hrefs' => [
|
368 |
'options' => $oMod->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
369 |
'please_enable' => $oMod->getUrl_DirectLinkToSection( 'section_pluginthemes_guard' ),
|
370 |
+
],
|
371 |
+
'vars' => [
|
372 |
'last_scan_at' => sprintf(
|
373 |
_wpsf__( 'Last Scan: %s' ),
|
374 |
$oCarbon->setTimestamp( $oMod->getLastScanAt( 'ptg' ) )->diffForHumans()
|
375 |
)
|
376 |
+
],
|
377 |
'count' => $oSelector->countForScan( 'ptg' ),
|
378 |
'assets' => array_merge( $aPlugins, $aThemes ),
|
379 |
+
'strings' => [
|
380 |
'title' => _wpsf__( 'Plugin / Theme Modifications' ),
|
381 |
'subtitle' => _wpsf__( "Detects unauthorized changes to plugins/themes" ),
|
382 |
'files_with_problems' => _wpsf__( 'Files with problems' ),
|
386 |
'deactivate' => __( 'Deactivate and Ignore' ),
|
387 |
'accept' => _wpsf__( 'Accept' ),
|
388 |
'update' => _wpsf__( 'Upgrade' ),
|
389 |
+
]
|
390 |
+
];
|
391 |
}
|
392 |
}
|
@@ -2,8 +2,6 @@
|
|
2 |
|
3 |
class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_BaseWpsf {
|
4 |
|
5 |
-
use \FernleafSystems\Wordpress\Plugin\Shield\Crons\StandardCron;
|
6 |
-
|
7 |
/**
|
8 |
*/
|
9 |
public function run() {
|
@@ -13,9 +11,9 @@ class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_Base
|
|
13 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
14 |
$oFO = $this->getMod();
|
15 |
if ( $oFO->isIcUsersEnabled() ) {
|
16 |
-
add_action( 'user_register',
|
17 |
-
add_action( 'profile_update',
|
18 |
-
add_action( 'after_password_reset',
|
19 |
}
|
20 |
}
|
21 |
|
@@ -30,7 +28,7 @@ class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_Base
|
|
30 |
* @return array
|
31 |
*/
|
32 |
public function getStandardUserFields() {
|
33 |
-
return
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -85,7 +83,7 @@ class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_Base
|
|
85 |
$oDb = $this->loadDbProcessor();
|
86 |
return $oDb->deleteRowsFromTableWhere(
|
87 |
$oDb->getTable_Users(),
|
88 |
-
|
89 |
) > 0;
|
90 |
}
|
91 |
|
@@ -101,7 +99,7 @@ class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_Base
|
|
101 |
return $oDb->updateRowsFromTableWhere(
|
102 |
$oDb->getTable_Users(),
|
103 |
$aUser,
|
104 |
-
|
105 |
) > 0;
|
106 |
}
|
107 |
|
@@ -147,13 +145,4 @@ class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_Base
|
|
147 |
$oFO = $this->getMod();
|
148 |
return $oFO->getScanFrequency();
|
149 |
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* @return int
|
153 |
-
*/
|
154 |
-
protected function getCronName() {
|
155 |
-
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
156 |
-
$oFO = $this->getMod();
|
157 |
-
return $oFO->getIcCronName();
|
158 |
-
}
|
159 |
}
|
2 |
|
3 |
class ICWP_WPSF_Processor_HackProtect_Integrity extends ICWP_WPSF_Processor_BaseWpsf {
|
4 |
|
|
|
|
|
5 |
/**
|
6 |
*/
|
7 |
public function run() {
|
11 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
12 |
$oFO = $this->getMod();
|
13 |
if ( $oFO->isIcUsersEnabled() ) {
|
14 |
+
add_action( 'user_register', [ $this, 'snapshotUsers' ] );
|
15 |
+
add_action( 'profile_update', [ $this, 'snapshotUsers' ] );
|
16 |
+
add_action( 'after_password_reset', [ $this, 'snapshotUsers' ] );
|
17 |
}
|
18 |
}
|
19 |
|
28 |
* @return array
|
29 |
*/
|
30 |
public function getStandardUserFields() {
|
31 |
+
return [ 'user_login', 'user_email', 'user_pass' ];
|
32 |
}
|
33 |
|
34 |
/**
|
83 |
$oDb = $this->loadDbProcessor();
|
84 |
return $oDb->deleteRowsFromTableWhere(
|
85 |
$oDb->getTable_Users(),
|
86 |
+
[ 'ID' => $nId ]
|
87 |
) > 0;
|
88 |
}
|
89 |
|
99 |
return $oDb->updateRowsFromTableWhere(
|
100 |
$oDb->getTable_Users(),
|
101 |
$aUser,
|
102 |
+
[ 'ID' => $nId ]
|
103 |
) > 0;
|
104 |
}
|
105 |
|
145 |
$oFO = $this->getMod();
|
146 |
return $oFO->getScanFrequency();
|
147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
}
|
@@ -98,12 +98,12 @@ class ICWP_WPSF_Processor_HackProtect_Apc extends ICWP_WPSF_Processor_ScanBase {
|
|
98 |
$oWp = Services::WpGeneral();
|
99 |
$oCon = $this->getCon();
|
100 |
|
101 |
-
$aContent =
|
102 |
sprintf( _wpsf__( '%s has detected abandoned plugins installed on your site.' ), $oCon->getHumanName() ),
|
103 |
_wpsf__( "Running code that hasn't seen any updates for over 2 years is far from ideal." ),
|
104 |
_wpsf__( 'Details for the items(s) are below:' ),
|
105 |
'',
|
106 |
-
|
107 |
|
108 |
/** @var Shield\Scans\Apc\ResultItem $oItem */
|
109 |
foreach ( $oRes->getItems() as $oItem ) {
|
@@ -116,11 +116,11 @@ class ICWP_WPSF_Processor_HackProtect_Apc extends ICWP_WPSF_Processor_ScanBase {
|
|
116 |
$sName = sprintf( '%s - %s', _wpsf__( 'Theme' ), $oWpThemes->getTheme( $oItem->slug ) );
|
117 |
}
|
118 |
|
119 |
-
$aContent[] = implode( "<br />",
|
120 |
sprintf( '%s: %s', _wpsf__( 'Item' ), $sName ),
|
121 |
'- '.sprintf( _wpsf__( 'Last Updated: %s' ), $oWp->getTimeStringForDisplay( $oItem->last_updated_at, false ) ),
|
122 |
'',
|
123 |
-
|
124 |
}
|
125 |
|
126 |
$aContent[] = $this->getScannerButtonForEmail();
|
98 |
$oWp = Services::WpGeneral();
|
99 |
$oCon = $this->getCon();
|
100 |
|
101 |
+
$aContent = [
|
102 |
sprintf( _wpsf__( '%s has detected abandoned plugins installed on your site.' ), $oCon->getHumanName() ),
|
103 |
_wpsf__( "Running code that hasn't seen any updates for over 2 years is far from ideal." ),
|
104 |
_wpsf__( 'Details for the items(s) are below:' ),
|
105 |
'',
|
106 |
+
];
|
107 |
|
108 |
/** @var Shield\Scans\Apc\ResultItem $oItem */
|
109 |
foreach ( $oRes->getItems() as $oItem ) {
|
116 |
$sName = sprintf( '%s - %s', _wpsf__( 'Theme' ), $oWpThemes->getTheme( $oItem->slug ) );
|
117 |
}
|
118 |
|
119 |
+
$aContent[] = implode( "<br />", [
|
120 |
sprintf( '%s: %s', _wpsf__( 'Item' ), $sName ),
|
121 |
'- '.sprintf( _wpsf__( 'Last Updated: %s' ), $oWp->getTimeStringForDisplay( $oItem->last_updated_at, false ) ),
|
122 |
'',
|
123 |
+
] );
|
124 |
}
|
125 |
|
126 |
$aContent[] = $this->getScannerButtonForEmail();
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use FernleafSystems\Wordpress\Plugin\Shield;
|
4 |
+
use FernleafSystems\Wordpress\Services\Services;
|
5 |
+
|
6 |
+
class ICWP_WPSF_Processor_HackProtect_Mal extends ICWP_WPSF_Processor_ScanBase {
|
7 |
+
|
8 |
+
const SCAN_SLUG = 'mal';
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @return bool
|
12 |
+
*/
|
13 |
+
public function isEnabled() {
|
14 |
+
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
15 |
+
$oFO = $this->getMod();
|
16 |
+
return $oFO->isMalScanEnabled();
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @param Shield\Scans\Mal\ResultsSet $oResults
|
21 |
+
* @return Shield\Databases\Scanner\EntryVO[]
|
22 |
+
*/
|
23 |
+
protected function convertResultsToVos( $oResults ) {
|
24 |
+
return ( new Shield\Scans\Mal\ConvertResultsToVos() )->convert( $oResults );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param Shield\Databases\Scanner\EntryVO[] $aVos
|
29 |
+
* @return Shield\Scans\Mal\ResultsSet
|
30 |
+
*/
|
31 |
+
protected function convertVosToResults( $aVos ) {
|
32 |
+
return ( new Shield\Scans\Mal\ConvertVosToResults() )->convert( $aVos );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param Shield\Databases\Scanner\EntryVO $oVo
|
37 |
+
* @return Shield\Scans\Mal\ResultItem
|
38 |
+
*/
|
39 |
+
protected function convertVoToResultItem( $oVo ) {
|
40 |
+
return ( new Shield\Scans\Mal\ConvertVosToResults() )->convertItem( $oVo );
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return Shield\Scans\Mal\Repair|mixed
|
45 |
+
*/
|
46 |
+
protected function getRepairer() {
|
47 |
+
return new Shield\Scans\Mal\Repair();
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return Shield\Scans\Mal\Scanner
|
52 |
+
*/
|
53 |
+
protected function getScanner() {
|
54 |
+
return ( new Shield\Scans\Mal\Scanner() )->setMalSigs( $this->getMalSignatures() );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @return string[]
|
59 |
+
* @throws \Exception
|
60 |
+
*/
|
61 |
+
private function getMalSignatures() {
|
62 |
+
$oWpFs = Services::WpFs();
|
63 |
+
$sFile = $this->getCon()->getPluginCachePath( 'malsigs.txt' );
|
64 |
+
if ( $oWpFs->exists( $sFile ) ) {
|
65 |
+
$aSigs = explode( "\n", \LZCompressor\LZString::decompress( base64_decode( $oWpFs->getFileContent( $sFile ) ) ) );
|
66 |
+
}
|
67 |
+
else {
|
68 |
+
$aSigs = array_filter(
|
69 |
+
array_map( 'trim', explode( "\n", Services::HttpRequest()->getContent( $this->getMod()
|
70 |
+
->getDef( 'url_mal_sigs' ) ) ) ),
|
71 |
+
function ( $sLine ) {
|
72 |
+
return ( ( strpos( $sLine, '#' ) !== 0 ) && strlen( $sLine ) > 0 );
|
73 |
+
}
|
74 |
+
);
|
75 |
+
|
76 |
+
$oWpFs->putFileContent( $sFile, base64_encode( \LZCompressor\LZString::compress( implode( "\n", $aSigs ) ) ) );
|
77 |
+
}
|
78 |
+
return $aSigs;
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @param Shield\Scans\Mal\ResultItem $oItem
|
83 |
+
* @return bool
|
84 |
+
* @throws \Exception
|
85 |
+
*/
|
86 |
+
protected function itemRepair( $oItem ) {
|
87 |
+
$this->getRepairer()->repairItem( $oItem );
|
88 |
+
$this->doStatIncrement( 'file.malware.replaced' );
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param Shield\Scans\Mal\ResultsSet $oRes
|
94 |
+
*/
|
95 |
+
protected function runCronAutoRepair( $oRes ) {
|
96 |
+
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
97 |
+
$oFO = $this->getMod();
|
98 |
+
if ( $oFO->isMalScanAutoRepair() ) {
|
99 |
+
$this->getRepairer()->repairResultsSet( $oRes );
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @param Shield\Scans\Mal\ResultsSet $oRes
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
protected function runCronUserNotify( $oRes ) {
|
108 |
+
$this->emailResults( $oRes );
|
109 |
+
return true;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param Shield\Scans\Mal\ResultsSet $oResults
|
114 |
+
*/
|
115 |
+
protected function emailResults( $oResults ) {
|
116 |
+
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
117 |
+
$oFO = $this->getMod();
|
118 |
+
|
119 |
+
$sTo = $oFO->getPluginDefaultRecipientAddress();
|
120 |
+
$this->getEmailProcessor()
|
121 |
+
->sendEmailWithWrap(
|
122 |
+
$sTo,
|
123 |
+
sprintf( '[%s] %s', _wpsf__( 'Warning' ), _wpsf__( 'Modified Core WordPress Files Discovered' ) ),
|
124 |
+
$this->buildEmailBodyFromFiles( $oResults )
|
125 |
+
);
|
126 |
+
|
127 |
+
$this->addToAuditEntry(
|
128 |
+
sprintf( _wpsf__( 'Sent Checksum Scan Notification email alert to: %s' ), $sTo )
|
129 |
+
);
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param Shield\Scans\Mal\ResultsSet $oResults
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
private function buildEmailBodyFromFiles( $oResults ) {
|
137 |
+
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
138 |
+
$oFO = $this->getMod();
|
139 |
+
$sName = $this->getCon()->getHumanName();
|
140 |
+
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
141 |
+
|
142 |
+
$aContent = [
|
143 |
+
sprintf( _wpsf__( "The %s Core File Scanner found files with potential problems." ), $sName ),
|
144 |
+
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
145 |
+
];
|
146 |
+
|
147 |
+
if ( $oFO->isMalScanAutoRepair() || $oFO->isIncludeFileLists() ) {
|
148 |
+
$aContent = array_merge( $aContent, $this->buildListOfFilesForEmail( $oResults ) );
|
149 |
+
$aContent[] = '';
|
150 |
+
|
151 |
+
if ( $oFO->isMalScanAutoRepair() ) {
|
152 |
+
$aContent[] = '<strong>'.sprintf( _wpsf__( "%s has already attempted to repair the files." ), $sName ).'</strong>'
|
153 |
+
.' '._wpsf__( 'But, you should always check these files to ensure everything is as you expect.' );
|
154 |
+
}
|
155 |
+
else {
|
156 |
+
$aContent[] = _wpsf__( 'You should review these files and replace them with official versions if required.' );
|
157 |
+
$aContent[] = _wpsf__( 'Alternatively you can have the plugin attempt to repair/replace these files automatically.' )
|
158 |
+
.' [<a href="https://icwp.io/moreinfochecksum">'._wpsf__( 'More Info' ).']</a>';
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
$aContent[] = '';
|
163 |
+
$aContent[] = _wpsf__( 'We recommend you run the scanner to review your site' ).':';
|
164 |
+
$aContent[] = $this->getScannerButtonForEmail();
|
165 |
+
|
166 |
+
if ( !$this->getCon()->isRelabelled() ) {
|
167 |
+
$aContent[] = '';
|
168 |
+
$aContent[] = '[ <a href="https://icwp.io/moreinfochecksum">'._wpsf__( 'More Info On This Scanner' ).' ]</a>';
|
169 |
+
}
|
170 |
+
|
171 |
+
return $aContent;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @param Shield\Scans\Mal\ResultsSet $oResult
|
176 |
+
* @return array
|
177 |
+
*/
|
178 |
+
private function buildListOfFilesForEmail( $oResult ) {
|
179 |
+
$aContent = [ '' ];
|
180 |
+
$aContent[] = _wpsf__( 'The following files contain suspected malware:' );
|
181 |
+
foreach ( $oResult->getAllItems() as $oItem ) {
|
182 |
+
/** @var Shield\Scans\Mal\ResultItem $oItem */
|
183 |
+
$aContent[] = ' - '.$oItem->path_fragment;
|
184 |
+
}
|
185 |
+
return $aContent;
|
186 |
+
}
|
187 |
+
}
|
@@ -38,15 +38,15 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
38 |
}
|
39 |
|
40 |
if ( $oFO->isPtgReadyToScan() ) {
|
41 |
-
add_action( 'upgrader_process_complete',
|
42 |
-
add_action( 'activated_plugin',
|
43 |
-
add_action( 'deactivated_plugin',
|
44 |
-
add_action( 'switch_theme',
|
45 |
}
|
46 |
|
47 |
if ( $oFO->isPtgReinstallLinks() ) {
|
48 |
-
add_filter( 'plugin_action_links',
|
49 |
-
add_action( 'admin_footer',
|
50 |
}
|
51 |
}
|
52 |
|
@@ -172,12 +172,12 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
172 |
}
|
173 |
|
174 |
public function printPluginReinstallDialogs() {
|
175 |
-
$aRenderData =
|
176 |
-
'strings' =>
|
177 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
178 |
-
|
179 |
'js_snippets' => []
|
180 |
-
|
181 |
echo $this->getMod()
|
182 |
->renderTemplate( 'snippets/hg-plugins-reinstall-dialogs.php', $aRenderData );
|
183 |
}
|
@@ -231,11 +231,11 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
231 |
}
|
232 |
else if ( !empty( $aInfo[ 'plugin' ] ) ) {
|
233 |
$sContext = self::CONTEXT_PLUGINS;
|
234 |
-
$aSlugs =
|
235 |
}
|
236 |
else if ( !empty( $aInfo[ 'theme' ] ) ) {
|
237 |
$sContext = self::CONTEXT_THEMES;
|
238 |
-
$aSlugs =
|
239 |
}
|
240 |
else if ( isset( $aInfo[ 'action' ] ) && $aInfo[ 'action' ] == 'install' && isset( $aInfo[ 'type' ] )
|
241 |
&& !empty( $oUpgrader->result[ 'destination_name' ] ) ) {
|
@@ -245,14 +245,14 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
245 |
$sDir = $oWpPlugins->getFileFromDirName( $oUpgrader->result[ 'destination_name' ] );
|
246 |
if ( $sDir && $oWpPlugins->isActive( $sDir ) ) {
|
247 |
$sContext = self::CONTEXT_PLUGINS;
|
248 |
-
$aSlugs =
|
249 |
}
|
250 |
}
|
251 |
else if ( $aInfo[ 'type' ] == 'theme' ) {
|
252 |
$sDir = $oUpgrader->result[ 'destination_name' ];
|
253 |
if ( Services\Services::WpThemes()->isActive( $sDir ) ) {
|
254 |
$sContext = self::CONTEXT_THEMES;
|
255 |
-
$aSlugs =
|
256 |
}
|
257 |
}
|
258 |
}
|
@@ -417,15 +417,15 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
417 |
private function buildSnapshotPlugin( $sBaseFile ) {
|
418 |
$aPlugin = Services\Services::WpPlugins()->getPlugin( $sBaseFile );
|
419 |
|
420 |
-
return
|
421 |
-
'meta' =>
|
422 |
'name' => $aPlugin[ 'Name' ],
|
423 |
'version' => $aPlugin[ 'Version' ],
|
424 |
'ts' => Services\Services::Request()->ts(),
|
425 |
'snap_version' => $this->getCon()->getVersion(),
|
426 |
-
|
427 |
'hashes' => $this->getContextScanner( self::CONTEXT_PLUGINS )->hashAssetFiles( $sBaseFile )
|
428 |
-
|
429 |
}
|
430 |
|
431 |
/**
|
@@ -435,15 +435,15 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
435 |
private function buildSnapshotTheme( $sSlug ) {
|
436 |
$oTheme = Services\Services::WpThemes()->getTheme( $sSlug );
|
437 |
|
438 |
-
return
|
439 |
-
'meta' =>
|
440 |
'name' => $oTheme->get( 'Name' ),
|
441 |
'version' => $oTheme->get( 'Version' ),
|
442 |
'ts' => Services\Services::Request()->ts(),
|
443 |
'snap_version' => $this->getCon()->getVersion(),
|
444 |
-
|
445 |
'hashes' => $this->getContextScanner( self::CONTEXT_THEMES )->hashAssetFiles( $sSlug )
|
446 |
-
|
447 |
}
|
448 |
|
449 |
/**
|
@@ -475,9 +475,9 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
475 |
->deleteSnapshots();
|
476 |
|
477 |
$oActiveTheme = $oWpThemes->getCurrent();
|
478 |
-
$aThemes =
|
479 |
$oActiveTheme->get_stylesheet() => $oActiveTheme
|
480 |
-
|
481 |
|
482 |
if ( $oWpThemes->isActiveThemeAChild() ) { // is child theme
|
483 |
$oParent = $oWpThemes->getCurrentParent();
|
@@ -589,7 +589,7 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
589 |
$sName = $this->getCon()->getHumanName();
|
590 |
$sHomeUrl = Services\Services::WpGeneral()->getHomeUrl();
|
591 |
|
592 |
-
$aContent =
|
593 |
sprintf( _wpsf__( '%s has detected at least 1 Plugins/Themes have been modified on your site.' ), $sName ),
|
594 |
'',
|
595 |
sprintf( '<strong>%s</strong>', _wpsf__( 'You will receive only 1 email notification about these changes in a 1 week period.' ) ),
|
@@ -597,7 +597,7 @@ class ICWP_WPSF_Processor_HackProtect_Ptg extends ICWP_WPSF_Processor_HackProtec
|
|
597 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
598 |
'',
|
599 |
_wpsf__( 'Details of the problem items are below:' ),
|
600 |
-
|
601 |
|
602 |
if ( !empty( $aAllPlugins ) ) {
|
603 |
$aContent[] = '';
|
38 |
}
|
39 |
|
40 |
if ( $oFO->isPtgReadyToScan() ) {
|
41 |
+
add_action( 'upgrader_process_complete', [ $this, 'updateSnapshotAfterUpgrade' ], 10, 2 );
|
42 |
+
add_action( 'activated_plugin', [ $this, 'onActivatePlugin' ], 10 );
|
43 |
+
add_action( 'deactivated_plugin', [ $this, 'onDeactivatePlugin' ], 10 );
|
44 |
+
add_action( 'switch_theme', [ $this, 'onActivateTheme' ], 10, 0 );
|
45 |
}
|
46 |
|
47 |
if ( $oFO->isPtgReinstallLinks() ) {
|
48 |
+
add_filter( 'plugin_action_links', [ $this, 'addActionLinkRefresh' ], 50, 2 );
|
49 |
+
add_action( 'admin_footer', [ $this, 'printPluginReinstallDialogs' ] );
|
50 |
}
|
51 |
}
|
52 |
|
172 |
}
|
173 |
|
174 |
public function printPluginReinstallDialogs() {
|
175 |
+
$aRenderData = [
|
176 |
+
'strings' => [
|
177 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
178 |
+
],
|
179 |
'js_snippets' => []
|
180 |
+
];
|
181 |
echo $this->getMod()
|
182 |
->renderTemplate( 'snippets/hg-plugins-reinstall-dialogs.php', $aRenderData );
|
183 |
}
|
231 |
}
|
232 |
else if ( !empty( $aInfo[ 'plugin' ] ) ) {
|
233 |
$sContext = self::CONTEXT_PLUGINS;
|
234 |
+
$aSlugs = [ $aInfo[ 'plugin' ] ];
|
235 |
}
|
236 |
else if ( !empty( $aInfo[ 'theme' ] ) ) {
|
237 |
$sContext = self::CONTEXT_THEMES;
|
238 |
+
$aSlugs = [ $aInfo[ 'theme' ] ];
|
239 |
}
|
240 |
else if ( isset( $aInfo[ 'action' ] ) && $aInfo[ 'action' ] == 'install' && isset( $aInfo[ 'type' ] )
|
241 |
&& !empty( $oUpgrader->result[ 'destination_name' ] ) ) {
|
245 |
$sDir = $oWpPlugins->getFileFromDirName( $oUpgrader->result[ 'destination_name' ] );
|
246 |
if ( $sDir && $oWpPlugins->isActive( $sDir ) ) {
|
247 |
$sContext = self::CONTEXT_PLUGINS;
|
248 |
+
$aSlugs = [ $sDir ];
|
249 |
}
|
250 |
}
|
251 |
else if ( $aInfo[ 'type' ] == 'theme' ) {
|
252 |
$sDir = $oUpgrader->result[ 'destination_name' ];
|
253 |
if ( Services\Services::WpThemes()->isActive( $sDir ) ) {
|
254 |
$sContext = self::CONTEXT_THEMES;
|
255 |
+
$aSlugs = [ $sDir ];
|
256 |
}
|
257 |
}
|
258 |
}
|
417 |
private function buildSnapshotPlugin( $sBaseFile ) {
|
418 |
$aPlugin = Services\Services::WpPlugins()->getPlugin( $sBaseFile );
|
419 |
|
420 |
+
return [
|
421 |
+
'meta' => [
|
422 |
'name' => $aPlugin[ 'Name' ],
|
423 |
'version' => $aPlugin[ 'Version' ],
|
424 |
'ts' => Services\Services::Request()->ts(),
|
425 |
'snap_version' => $this->getCon()->getVersion(),
|
426 |
+
],
|
427 |
'hashes' => $this->getContextScanner( self::CONTEXT_PLUGINS )->hashAssetFiles( $sBaseFile )
|
428 |
+
];
|
429 |
}
|
430 |
|
431 |
/**
|
435 |
private function buildSnapshotTheme( $sSlug ) {
|
436 |
$oTheme = Services\Services::WpThemes()->getTheme( $sSlug );
|
437 |
|
438 |
+
return [
|
439 |
+
'meta' => [
|
440 |
'name' => $oTheme->get( 'Name' ),
|
441 |
'version' => $oTheme->get( 'Version' ),
|
442 |
'ts' => Services\Services::Request()->ts(),
|
443 |
'snap_version' => $this->getCon()->getVersion(),
|
444 |
+
],
|
445 |
'hashes' => $this->getContextScanner( self::CONTEXT_THEMES )->hashAssetFiles( $sSlug )
|
446 |
+
];
|
447 |
}
|
448 |
|
449 |
/**
|
475 |
->deleteSnapshots();
|
476 |
|
477 |
$oActiveTheme = $oWpThemes->getCurrent();
|
478 |
+
$aThemes = [
|
479 |
$oActiveTheme->get_stylesheet() => $oActiveTheme
|
480 |
+
];
|
481 |
|
482 |
if ( $oWpThemes->isActiveThemeAChild() ) { // is child theme
|
483 |
$oParent = $oWpThemes->getCurrentParent();
|
589 |
$sName = $this->getCon()->getHumanName();
|
590 |
$sHomeUrl = Services\Services::WpGeneral()->getHomeUrl();
|
591 |
|
592 |
+
$aContent = [
|
593 |
sprintf( _wpsf__( '%s has detected at least 1 Plugins/Themes have been modified on your site.' ), $sName ),
|
594 |
'',
|
595 |
sprintf( '<strong>%s</strong>', _wpsf__( 'You will receive only 1 email notification about these changes in a 1 week period.' ) ),
|
597 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
598 |
'',
|
599 |
_wpsf__( 'Details of the problem items are below:' ),
|
600 |
+
];
|
601 |
|
602 |
if ( !empty( $aAllPlugins ) ) {
|
603 |
$aContent[] = '';
|
@@ -150,11 +150,11 @@ class ICWP_WPSF_Processor_HackProtect_Ufc extends ICWP_WPSF_Processor_ScanBase {
|
|
150 |
$sName = $oCon->getHumanName();
|
151 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
152 |
|
153 |
-
$aContent =
|
154 |
sprintf( _wpsf__( 'The %s Unrecognised File Scanner found files which you need to review.' ), $sName ),
|
155 |
'',
|
156 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
157 |
-
|
158 |
|
159 |
if ( $oFO->isUfcDeleteFiles() || $oFO->isIncludeFileLists() ) {
|
160 |
$aContent[] = _wpsf__( 'Files discovered' ).':';
|
150 |
$sName = $oCon->getHumanName();
|
151 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
152 |
|
153 |
+
$aContent = [
|
154 |
sprintf( _wpsf__( 'The %s Unrecognised File Scanner found files which you need to review.' ), $sName ),
|
155 |
'',
|
156 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
157 |
+
];
|
158 |
|
159 |
if ( $oFO->isUfcDeleteFiles() || $oFO->isIncludeFileLists() ) {
|
160 |
$aContent[] = _wpsf__( 'Files discovered' ).':';
|
@@ -146,10 +146,10 @@ class ICWP_WPSF_Processor_HackProtect_Wcf extends ICWP_WPSF_Processor_ScanBase {
|
|
146 |
$sName = $this->getCon()->getHumanName();
|
147 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
148 |
|
149 |
-
$aContent =
|
150 |
sprintf( _wpsf__( "The %s Core File Scanner found files with potential problems." ), $sName ),
|
151 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
152 |
-
|
153 |
|
154 |
if ( $oFO->isWcfScanAutoRepair() || $oFO->isIncludeFileLists() ) {
|
155 |
$aContent = array_merge( $aContent, $this->buildListOfFilesForEmail( $oResults ) );
|
146 |
$sName = $this->getCon()->getHumanName();
|
147 |
$sHomeUrl = $this->loadWp()->getHomeUrl();
|
148 |
|
149 |
+
$aContent = [
|
150 |
sprintf( _wpsf__( "The %s Core File Scanner found files with potential problems." ), $sName ),
|
151 |
sprintf( '%s: %s', _wpsf__( 'Site URL' ), sprintf( '<a href="%s" target="_blank">%s</a>', $sHomeUrl, $sHomeUrl ) ),
|
152 |
+
];
|
153 |
|
154 |
if ( $oFO->isWcfScanAutoRepair() || $oFO->isIncludeFileLists() ) {
|
155 |
$aContent = array_merge( $aContent, $this->buildListOfFilesForEmail( $oResults ) );
|
@@ -18,14 +18,14 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
18 |
parent::run();
|
19 |
|
20 |
// For display on the Plugins page
|
21 |
-
add_action( 'load-plugins.php',
|
22 |
-
add_action( 'upgrader_process_complete',
|
23 |
-
add_action( 'deleted_plugin',
|
24 |
|
25 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
26 |
$oFO = $this->getMod();
|
27 |
if ( $oFO->isWpvulnAutoupdatesEnabled() ) {
|
28 |
-
add_filter( 'auto_update_plugin',
|
29 |
}
|
30 |
}
|
31 |
|
@@ -139,13 +139,12 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
139 |
if ( $oFO->isWpvulnPluginsHighlightEnabled() && $this->countVulnerablePlugins() > 0 ) {
|
140 |
// These 3 add the 'Vulnerable' plugin status view.
|
141 |
// BUG: when vulnerable is active, only 1 plugin is available to "All" status. don't know fix.
|
142 |
-
add_action( 'pre_current_active_plugins',
|
143 |
-
add_filter( 'all_plugins',
|
144 |
-
add_filter( 'views_plugins',
|
145 |
-
|
146 |
-
add_filter( 'manage_plugins_columns', array( $this, 'fCountColumns' ), 1000 );
|
147 |
foreach ( Services::WpPlugins()->getInstalledPluginFiles() as $sPluginFile ) {
|
148 |
-
add_action( "after_plugin_row_$sPluginFile",
|
149 |
}
|
150 |
}
|
151 |
}
|
@@ -155,7 +154,7 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
155 |
global $status;
|
156 |
$status = 'vulnerable';
|
157 |
}
|
158 |
-
add_filter( 'views_plugins',
|
159 |
}
|
160 |
|
161 |
/**
|
@@ -200,18 +199,18 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
200 |
$aVuln = $this->getPluginVulnerabilities( $sPluginFile );
|
201 |
if ( count( $aVuln ) ) {
|
202 |
$sOurName = $this->getCon()->getHumanName();
|
203 |
-
$aRenderData =
|
204 |
-
'strings' =>
|
205 |
'known_vuln' => sprintf( _wpsf__( '%s has discovered that the currently installed version of the %s plugin has known security vulnerabilities.' ),
|
206 |
$sOurName, '<strong>'.$aPluginData[ 'Name' ].'</strong>' ),
|
207 |
'name' => _wpsf__( 'Vulnerability Name' ),
|
208 |
'type' => _wpsf__( 'Vulnerability Type' ),
|
209 |
'fixed_versions' => _wpsf__( 'Fixed Versions' ),
|
210 |
'more_info' => _wpsf__( 'More Info' ),
|
211 |
-
|
212 |
'vulns' => $aVuln,
|
213 |
'nColspan' => $this->nColumnsCount
|
214 |
-
|
215 |
echo $this->getMod()
|
216 |
->renderTemplate( 'snippets/plugin-vulnerability.php', $aRenderData );
|
217 |
}
|
@@ -236,12 +235,12 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
236 |
$oWpThemes = $this->loadWpThemes();
|
237 |
$oCon = $this->getCon();
|
238 |
|
239 |
-
$aContent =
|
240 |
sprintf( _wpsf__( '%s has detected items with known security vulnerabilities.' ), $oCon->getHumanName() ),
|
241 |
_wpsf__( 'You should update or remove these items at your earliest convenience.' ),
|
242 |
_wpsf__( 'Details for the items(s) are below:' ),
|
243 |
'',
|
244 |
-
|
245 |
|
246 |
/** @var Shield\Scans\Wpv\ResultItem $oItem */
|
247 |
foreach ( $oRes->getItems() as $oItem ) {
|
@@ -255,14 +254,14 @@ class ICWP_WPSF_Processor_HackProtect_Wpv extends ICWP_WPSF_Processor_HackProtec
|
|
255 |
}
|
256 |
|
257 |
$oVuln = $oItem->getWpVulnVo();
|
258 |
-
$aContent[] = implode( "<br />",
|
259 |
sprintf( '%s: %s', _wpsf__( 'Item' ), $sName ),
|
260 |
'- '.sprintf( _wpsf__( 'Vulnerability Title: %s' ), $oVuln->title ),
|
261 |
'- '.sprintf( _wpsf__( 'Vulnerability Type: %s' ), $oVuln->vuln_type ),
|
262 |
'- '.sprintf( _wpsf__( 'Fixed Version: %s' ), $oVuln->fixed_in ),
|
263 |
'- '.sprintf( _wpsf__( 'Further Information: %s' ), $oVuln->getUrl() ),
|
264 |
'',
|
265 |
-
|
266 |
}
|
267 |
|
268 |
$aContent[] = $this->getScannerButtonForEmail();
|
18 |
parent::run();
|
19 |
|
20 |
// For display on the Plugins page
|
21 |
+
add_action( 'load-plugins.php', [ $this, 'addPluginVulnerabilityRows' ], 10, 2 );
|
22 |
+
add_action( 'upgrader_process_complete', [ $this, 'doScan' ], 10, 2 );
|
23 |
+
add_action( 'deleted_plugin', [ $this, 'doScan' ], 10, 2 );
|
24 |
|
25 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oFO */
|
26 |
$oFO = $this->getMod();
|
27 |
if ( $oFO->isWpvulnAutoupdatesEnabled() ) {
|
28 |
+
add_filter( 'auto_update_plugin', [ $this, 'autoupdateVulnerablePlugins' ], PHP_INT_MAX, 2 );
|
29 |
}
|
30 |
}
|
31 |
|
139 |
if ( $oFO->isWpvulnPluginsHighlightEnabled() && $this->countVulnerablePlugins() > 0 ) {
|
140 |
// These 3 add the 'Vulnerable' plugin status view.
|
141 |
// BUG: when vulnerable is active, only 1 plugin is available to "All" status. don't know fix.
|
142 |
+
add_action( 'pre_current_active_plugins', [ $this, 'addVulnerablePluginStatusView' ], 1000 );
|
143 |
+
add_filter( 'all_plugins', [ $this, 'filterPluginsToView' ], 1000 );
|
144 |
+
add_filter( 'views_plugins', [ $this, 'addPluginsStatusViewLink' ], 1000 );
|
145 |
+
add_filter( 'manage_plugins_columns', [ $this, 'fCountColumns' ], 1000 );
|
|
|
146 |
foreach ( Services::WpPlugins()->getInstalledPluginFiles() as $sPluginFile ) {
|
147 |
+
add_action( "after_plugin_row_$sPluginFile", [ $this, 'attachVulnerabilityWarning' ], 100, 2 );
|
148 |
}
|
149 |
}
|
150 |
}
|
154 |
global $status;
|
155 |
$status = 'vulnerable';
|
156 |
}
|
157 |
+
add_filter( 'views_plugins', [ $this, 'addPluginsStatusViewLink' ], 1000 );
|
158 |
}
|
159 |
|
160 |
/**
|
199 |
$aVuln = $this->getPluginVulnerabilities( $sPluginFile );
|
200 |
if ( count( $aVuln ) ) {
|
201 |
$sOurName = $this->getCon()->getHumanName();
|
202 |
+
$aRenderData = [
|
203 |
+
'strings' => [
|
204 |
'known_vuln' => sprintf( _wpsf__( '%s has discovered that the currently installed version of the %s plugin has known security vulnerabilities.' ),
|
205 |
$sOurName, '<strong>'.$aPluginData[ 'Name' ].'</strong>' ),
|
206 |
'name' => _wpsf__( 'Vulnerability Name' ),
|
207 |
'type' => _wpsf__( 'Vulnerability Type' ),
|
208 |
'fixed_versions' => _wpsf__( 'Fixed Versions' ),
|
209 |
'more_info' => _wpsf__( 'More Info' ),
|
210 |
+
],
|
211 |
'vulns' => $aVuln,
|
212 |
'nColspan' => $this->nColumnsCount
|
213 |
+
];
|
214 |
echo $this->getMod()
|
215 |
->renderTemplate( 'snippets/plugin-vulnerability.php', $aRenderData );
|
216 |
}
|
235 |
$oWpThemes = $this->loadWpThemes();
|
236 |
$oCon = $this->getCon();
|
237 |
|
238 |
+
$aContent = [
|
239 |
sprintf( _wpsf__( '%s has detected items with known security vulnerabilities.' ), $oCon->getHumanName() ),
|
240 |
_wpsf__( 'You should update or remove these items at your earliest convenience.' ),
|
241 |
_wpsf__( 'Details for the items(s) are below:' ),
|
242 |
'',
|
243 |
+
];
|
244 |
|
245 |
/** @var Shield\Scans\Wpv\ResultItem $oItem */
|
246 |
foreach ( $oRes->getItems() as $oItem ) {
|
254 |
}
|
255 |
|
256 |
$oVuln = $oItem->getWpVulnVo();
|
257 |
+
$aContent[] = implode( "<br />", [
|
258 |
sprintf( '%s: %s', _wpsf__( 'Item' ), $sName ),
|
259 |
'- '.sprintf( _wpsf__( 'Vulnerability Title: %s' ), $oVuln->title ),
|
260 |
'- '.sprintf( _wpsf__( 'Vulnerability Type: %s' ), $oVuln->vuln_type ),
|
261 |
'- '.sprintf( _wpsf__( 'Fixed Version: %s' ), $oVuln->fixed_in ),
|
262 |
'- '.sprintf( _wpsf__( 'Further Information: %s' ), $oVuln->getUrl() ),
|
263 |
'',
|
264 |
+
] );
|
265 |
}
|
266 |
|
267 |
$aContent[] = $this->getScannerButtonForEmail();
|
@@ -25,6 +25,9 @@ class ICWP_WPSF_Processor_HackProtect_Scanner extends ICWP_WPSF_BaseDbProcessor
|
|
25 |
if ( $oFO->isUfcEnabled() ) {
|
26 |
$this->getSubProcessorUfc()->run();
|
27 |
}
|
|
|
|
|
|
|
28 |
if ( $oFO->isPtgEnabled() ) {
|
29 |
$this->getSubProcessorPtg()->run();
|
30 |
}
|
@@ -40,42 +43,49 @@ class ICWP_WPSF_Processor_HackProtect_Scanner extends ICWP_WPSF_BaseDbProcessor
|
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
-
* @return ICWP_WPSF_Processor_HackProtect_Apc
|
44 |
*/
|
45 |
public function getSubProcessorApc() {
|
46 |
return $this->getSubPro( 'apc' );
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* @return ICWP_WPSF_Processor_HackProtect_Ufc
|
51 |
*/
|
52 |
protected function getSubProcessorIntegrity() {
|
53 |
return $this->getSubPro( 'int' );
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
* @return ICWP_WPSF_Processor_HackProtect_Ptg
|
58 |
*/
|
59 |
public function getSubProcessorPtg() {
|
60 |
return $this->getSubPro( 'ptg' );
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
-
* @return ICWP_WPSF_Processor_HackProtect_Ufc
|
65 |
*/
|
66 |
public function getSubProcessorUfc() {
|
67 |
return $this->getSubPro( 'ufc' );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* @return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
*/
|
73 |
public function getSubProcessorWcf() {
|
74 |
return $this->getSubPro( 'wcf' );
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
* @return ICWP_WPSF_Processor_HackProtect_Wpv
|
79 |
*/
|
80 |
public function getSubProcessorWpv() {
|
81 |
return $this->getSubPro( 'wpv' );
|
@@ -88,16 +98,17 @@ class ICWP_WPSF_Processor_HackProtect_Scanner extends ICWP_WPSF_BaseDbProcessor
|
|
88 |
return [
|
89 |
'apc' => 'ICWP_WPSF_Processor_HackProtect_Apc',
|
90 |
'int' => 'ICWP_WPSF_Processor_HackProtect_Integrity',
|
|
|
91 |
'ptg' => 'ICWP_WPSF_Processor_HackProtect_Ptg',
|
92 |
'ufc' => 'ICWP_WPSF_Processor_HackProtect_Ufc',
|
93 |
-
'wpv' => 'ICWP_WPSF_Processor_HackProtect_Wpv',
|
94 |
'wcf' => 'ICWP_WPSF_Processor_HackProtect_Wcf',
|
|
|
95 |
];
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
* @param string $sKey
|
100 |
-
* @return ICWP_WPSF_Processor_ScanBase|null
|
101 |
*/
|
102 |
protected function getSubPro( $sKey ) {
|
103 |
/** @var ICWP_WPSF_Processor_ScanBase $oPro */
|
25 |
if ( $oFO->isUfcEnabled() ) {
|
26 |
$this->getSubProcessorUfc()->run();
|
27 |
}
|
28 |
+
if ( $oFO->isMalScanEnabled() ) {
|
29 |
+
// $this->getSubProcessorMal()->run();
|
30 |
+
}
|
31 |
if ( $oFO->isPtgEnabled() ) {
|
32 |
$this->getSubProcessorPtg()->run();
|
33 |
}
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* @return ICWP_WPSF_Processor_HackProtect_Apc
|
47 |
*/
|
48 |
public function getSubProcessorApc() {
|
49 |
return $this->getSubPro( 'apc' );
|
50 |
}
|
51 |
|
52 |
/**
|
53 |
+
* @return ICWP_WPSF_Processor_HackProtect_Ufc
|
54 |
*/
|
55 |
protected function getSubProcessorIntegrity() {
|
56 |
return $this->getSubPro( 'int' );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* @return ICWP_WPSF_Processor_HackProtect_Ptg
|
61 |
*/
|
62 |
public function getSubProcessorPtg() {
|
63 |
return $this->getSubPro( 'ptg' );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* @return ICWP_WPSF_Processor_HackProtect_Ufc
|
68 |
*/
|
69 |
public function getSubProcessorUfc() {
|
70 |
return $this->getSubPro( 'ufc' );
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
+
* @return ICWP_WPSF_Processor_HackProtect_Mal
|
75 |
+
*/
|
76 |
+
public function getSubProcessorMal() {
|
77 |
+
return $this->getSubPro( 'mal' );
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return ICWP_WPSF_Processor_HackProtect_Wcf
|
82 |
*/
|
83 |
public function getSubProcessorWcf() {
|
84 |
return $this->getSubPro( 'wcf' );
|
85 |
}
|
86 |
|
87 |
/**
|
88 |
+
* @return ICWP_WPSF_Processor_HackProtect_Wpv
|
89 |
*/
|
90 |
public function getSubProcessorWpv() {
|
91 |
return $this->getSubPro( 'wpv' );
|
98 |
return [
|
99 |
'apc' => 'ICWP_WPSF_Processor_HackProtect_Apc',
|
100 |
'int' => 'ICWP_WPSF_Processor_HackProtect_Integrity',
|
101 |
+
'mal' => 'ICWP_WPSF_Processor_HackProtect_Mal',
|
102 |
'ptg' => 'ICWP_WPSF_Processor_HackProtect_Ptg',
|
103 |
'ufc' => 'ICWP_WPSF_Processor_HackProtect_Ufc',
|
|
|
104 |
'wcf' => 'ICWP_WPSF_Processor_HackProtect_Wcf',
|
105 |
+
'wpv' => 'ICWP_WPSF_Processor_HackProtect_Wpv',
|
106 |
];
|
107 |
}
|
108 |
|
109 |
/**
|
110 |
* @param string $sKey
|
111 |
+
* @return ICWP_WPSF_Processor_ScanBase|mixed|null
|
112 |
*/
|
113 |
protected function getSubPro( $sKey ) {
|
114 |
/** @var ICWP_WPSF_Processor_ScanBase $oPro */
|
@@ -5,20 +5,22 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
5 |
/**
|
6 |
* @var bool
|
7 |
*/
|
8 |
-
|
|
|
9 |
/**
|
10 |
* @var array
|
11 |
*/
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
*/
|
16 |
public function run() {
|
17 |
if ( $this->getPushHeadersEarly() ) {
|
18 |
-
$this->
|
19 |
}
|
20 |
else {
|
21 |
-
add_filter( 'wp_headers',
|
|
|
22 |
}
|
23 |
}
|
24 |
|
@@ -31,11 +33,10 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
31 |
|
32 |
/**
|
33 |
*/
|
34 |
-
|
35 |
if ( !$this->isHeadersPushed() ) {
|
36 |
-
|
37 |
-
|
38 |
-
header( sprintf( '%s: %s', $sHeader, $sValue ) );
|
39 |
}
|
40 |
$this->setHeadersPushed( true );
|
41 |
}
|
@@ -56,7 +57,7 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
56 |
/**
|
57 |
* @return array|null
|
58 |
*/
|
59 |
-
|
60 |
switch ( $this->getOption( 'x_frame' ) ) {
|
61 |
case 'on_sameorigin':
|
62 |
$sXFrameOption = 'SAMEORIGIN';
|
@@ -68,36 +69,36 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
68 |
$sXFrameOption = '';
|
69 |
break;
|
70 |
}
|
71 |
-
return !empty( $sXFrameOption ) ?
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
* @return array
|
76 |
*/
|
77 |
-
|
78 |
-
return
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
* @return array
|
83 |
*/
|
84 |
-
|
85 |
-
return
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
* @return array|null
|
90 |
*/
|
91 |
-
|
92 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
93 |
$oFO = $this->getMod();
|
94 |
-
return
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
* @return array|null
|
99 |
*/
|
100 |
-
|
101 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
102 |
$oFO = $this->getMod();
|
103 |
if ( !$oFO->isContentSecurityPolicyEnabled() ) {
|
@@ -128,13 +129,13 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
128 |
if ( !empty( $aDomains ) && is_array( $aDomains ) ) {
|
129 |
$aDefaultSrcDirectives[] = implode( " ", $aDomains );
|
130 |
}
|
131 |
-
return
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
* @return array
|
136 |
*/
|
137 |
-
|
138 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
139 |
$oFO = $this->getMod();
|
140 |
|
@@ -163,7 +164,7 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
163 |
if ( !isset( $this->aHeaders ) || !is_array( $this->aHeaders ) ) {
|
164 |
$this->aHeaders = [];
|
165 |
}
|
166 |
-
return $this->aHeaders;
|
167 |
}
|
168 |
|
169 |
/**
|
@@ -178,7 +179,7 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
178 |
/**
|
179 |
* @return bool
|
180 |
*/
|
181 |
-
|
182 |
return (bool)$this->bHeadersPushed;
|
183 |
}
|
184 |
|
@@ -186,7 +187,7 @@ class ICWP_WPSF_Processor_Headers extends ICWP_WPSF_Processor_BaseWpsf {
|
|
186 |
* @param bool $bHeadersPushed
|
187 |
* @return $this
|
188 |
*/
|
189 |
-
|
190 |
$this->bHeadersPushed = $bHeadersPushed;
|
191 |
return $this;
|
192 |
}
|
5 |
/**
|
6 |
* @var bool
|
7 |
*/
|
8 |
+
private $bHeadersPushed;
|
9 |
+
|
10 |
/**
|
11 |
* @var array
|
12 |
*/
|
13 |
+
private $aHeaders;
|
14 |
|
15 |
/**
|
16 |
*/
|
17 |
public function run() {
|
18 |
if ( $this->getPushHeadersEarly() ) {
|
19 |
+
$this->sendHeaders();
|
20 |
}
|
21 |
else {
|
22 |
+
add_filter( 'wp_headers', [ $this, 'addToHeaders' ] );
|
23 |
+
add_action( 'send_headers', [ $this, 'sendHeaders' ], 100, 0 );
|
24 |
}
|
25 |
}
|
26 |
|
33 |
|
34 |
/**
|
35 |
*/
|
36 |
+
public function sendHeaders() {
|
37 |
if ( !$this->isHeadersPushed() ) {
|
38 |
+
foreach ( $this->gatherSecurityHeaders() as $sName => $sValue ) {
|
39 |
+
@header( sprintf( '%s: %s', $sName, $sValue ) );
|
|
|
40 |
}
|
41 |
$this->setHeadersPushed( true );
|
42 |
}
|
57 |
/**
|
58 |
* @return array|null
|
59 |
*/
|
60 |
+
private function getXFrameHeader() {
|
61 |
switch ( $this->getOption( 'x_frame' ) ) {
|
62 |
case 'on_sameorigin':
|
63 |
$sXFrameOption = 'SAMEORIGIN';
|
69 |
$sXFrameOption = '';
|
70 |
break;
|
71 |
}
|
72 |
+
return !empty( $sXFrameOption ) ? [ 'x-frame-options' => $sXFrameOption ] : null;
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
* @return array
|
77 |
*/
|
78 |
+
private function getXssProtectionHeader() {
|
79 |
+
return [ 'X-XSS-Protection' => '1; mode=block' ];
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
* @return array
|
84 |
*/
|
85 |
+
private function getContentTypeOptionHeader() {
|
86 |
+
return [ 'X-Content-Type-Options' => 'nosniff' ];
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
* @return array|null
|
91 |
*/
|
92 |
+
private function getReferrerPolicyHeader() {
|
93 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
94 |
$oFO = $this->getMod();
|
95 |
+
return [ 'Referrer-Policy' => $oFO->getReferrerPolicyValue() ];
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
* @return array|null
|
100 |
*/
|
101 |
+
private function setContentSecurityPolicyHeader() {
|
102 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
103 |
$oFO = $this->getMod();
|
104 |
if ( !$oFO->isContentSecurityPolicyEnabled() ) {
|
129 |
if ( !empty( $aDomains ) && is_array( $aDomains ) ) {
|
130 |
$aDefaultSrcDirectives[] = implode( " ", $aDomains );
|
131 |
}
|
132 |
+
return [ 'Content-Security-Policy' => sprintf( $sTemplate, implode( " ", $aDefaultSrcDirectives ) ) ];
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
* @return array
|
137 |
*/
|
138 |
+
private function gatherSecurityHeaders() {
|
139 |
/** @var ICWP_WPSF_FeatureHandler_Headers $oFO */
|
140 |
$oFO = $this->getMod();
|
141 |
|
164 |
if ( !isset( $this->aHeaders ) || !is_array( $this->aHeaders ) ) {
|
165 |
$this->aHeaders = [];
|
166 |
}
|
167 |
+
return array_unique( $this->aHeaders );
|
168 |
}
|
169 |
|
170 |
/**
|
179 |
/**
|
180 |
* @return bool
|
181 |
*/
|
182 |
+
private function isHeadersPushed() {
|
183 |
return (bool)$this->bHeadersPushed;
|
184 |
}
|
185 |
|
187 |
* @param bool $bHeadersPushed
|
188 |
* @return $this
|
189 |
*/
|
190 |
+
private function setHeadersPushed( $bHeadersPushed ) {
|
191 |
$this->bHeadersPushed = $bHeadersPushed;
|
192 |
return $this;
|
193 |
}
|
@@ -35,8 +35,8 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
35 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
36 |
$oFO = $this->getMod();
|
37 |
if ( $oFO->isAutoBlackListEnabled() ) {
|
38 |
-
add_filter( $oFO->prefix( 'firewall_die_message' ),
|
39 |
-
add_action( $oFO->prefix( 'pre_plugin_shutdown' ),
|
40 |
}
|
41 |
}
|
42 |
|
@@ -92,15 +92,15 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
92 |
$oCon = $this->getCon();
|
93 |
|
94 |
if ( $oCon->getIsPage_PluginAdmin() && $this->isCurrentIpWhitelisted() ) {
|
95 |
-
$aRenderData =
|
96 |
'notice_attributes' => $aNoticeAttributes,
|
97 |
-
'strings' =>
|
98 |
'title' => sprintf( _wpsf__( '%s is ignoring you' ), $oCon->getHumanName() ),
|
99 |
'your_ip' => sprintf( _wpsf__( 'Your IP address is: %s' ), $this->ip() ),
|
100 |
'notice_message' => _wpsf__( 'Your IP address is whitelisted and NO features you activate apply to you.' ),
|
101 |
'including_message' => _wpsf__( 'Including the hiding the WP Login page.' )
|
102 |
-
|
103 |
-
|
104 |
$this->insertAdminNotice( $aRenderData );
|
105 |
}
|
106 |
}
|
@@ -245,49 +245,49 @@ class ICWP_WPSF_Processor_Ips extends ICWP_WPSF_BaseDbProcessor {
|
|
245 |
$sIp = $this->ip();
|
246 |
$nTimeRemaining = max( floor( $oFO->getAutoExpireTime()/60 ), 0 );
|
247 |
$aData = [
|
248 |
-
'strings' =>
|
249 |
'title' => sprintf( _wpsf__( "You've been blocked by the %s plugin" ),
|
250 |
sprintf( '<a href="%s" target="_blank">%s</a>',
|
251 |
$oCon->getPluginSpec()[ 'meta' ][ 'url_repo_home' ],
|
252 |
$oCon->getHumanName()
|
253 |
)
|
254 |
),
|
255 |
-
'lines' =>
|
256 |
sprintf( _wpsf__( 'Time remaining on black list: %s' ),
|
257 |
sprintf( _n( '%s minute', '%s minutes', $nTimeRemaining, 'wp-simple-firewall' ), $nTimeRemaining )
|
258 |
),
|
259 |
sprintf( _wpsf__( 'You tripped the security plugin defenses a total of %s times making you a suspect.' ), $oFO->getOptTransgressionLimit() ),
|
260 |
sprintf( _wpsf__( 'If you believe this to be in error, please contact the site owner and quote your IP address below.' ) ),
|
261 |
-
|
262 |
'your_ip' => 'Your IP address',
|
263 |
'unblock' => [
|
264 |
'title' => _wpsf__( 'Auto-Unblock Your IP' ),
|
265 |
'you_can' => _wpsf__( 'You can automatically unblock your IP address by clicking the button below.' ),
|
266 |
'button' => _wpsf__( 'Unblock My IP Address' ),
|
267 |
],
|
268 |
-
|
269 |
-
'vars' =>
|
270 |
'nonce' => $oFO->getNonceActionData( 'uau' ),
|
271 |
'ip' => $sIp,
|
272 |
'gasp_element' => $oFO->renderTemplate(
|
273 |
'snippets/gasp_js.php',
|
274 |
-
|
275 |
'sCbName' => $oLoginFO->getGaspKey(),
|
276 |
'sLabel' => $oLoginFO->getTextImAHuman(),
|
277 |
'sAlert' => $oLoginFO->getTextPleaseCheckBox(),
|
278 |
'sMustJs' => _wpsf__( 'You MUST enable Javascript to be able to login' ),
|
279 |
'sUniqId' => $sUniqId,
|
280 |
'sUniqElem' => 'icwp_wpsf_login_p'.$sUniqId,
|
281 |
-
'strings' =>
|
282 |
'loading' => _wpsf__( 'Loading' )
|
283 |
-
|
284 |
-
|
285 |
),
|
286 |
-
|
287 |
-
'flags' =>
|
288 |
'is_autorecover' => $oFO->isEnabledAutoUserRecover(),
|
289 |
'is_uau_permitted' => $oFO->getCanIpRequestAutoUnblock( $sIp ),
|
290 |
-
|
291 |
];
|
292 |
$this->loadWp()
|
293 |
->wpDie(
|
35 |
/** @var ICWP_WPSF_FeatureHandler_Ips $oFO */
|
36 |
$oFO = $this->getMod();
|
37 |
if ( $oFO->isAutoBlackListEnabled() ) {
|
38 |
+
add_filter( $oFO->prefix( 'firewall_die_message' ), [ $this, 'fAugmentFirewallDieMessage' ] );
|
39 |
+
add_action( $oFO->prefix( 'pre_plugin_shutdown' ), [ $this, 'doBlackMarkCurrentVisitor' ] );
|
40 |
}
|
41 |
}
|
42 |
|
92 |
$oCon = $this->getCon();
|
93 |
|
94 |
if ( $oCon->getIsPage_PluginAdmin() && $this->isCurrentIpWhitelisted() ) {
|
95 |
+
$aRenderData = [
|
96 |
'notice_attributes' => $aNoticeAttributes,
|
97 |
+
'strings' => [
|
98 |
'title' => sprintf( _wpsf__( '%s is ignoring you' ), $oCon->getHumanName() ),
|
99 |
'your_ip' => sprintf( _wpsf__( 'Your IP address is: %s' ), $this->ip() ),
|
100 |
'notice_message' => _wpsf__( 'Your IP address is whitelisted and NO features you activate apply to you.' ),
|
101 |
'including_message' => _wpsf__( 'Including the hiding the WP Login page.' )
|
102 |
+
]
|
103 |
+
];
|
104 |
$this->insertAdminNotice( $aRenderData );
|
105 |
}
|
106 |
}
|
245 |
$sIp = $this->ip();
|
246 |
$nTimeRemaining = max( floor( $oFO->getAutoExpireTime()/60 ), 0 );
|
247 |
$aData = [
|
248 |
+
'strings' => [
|
249 |
'title' => sprintf( _wpsf__( "You've been blocked by the %s plugin" ),
|
250 |
sprintf( '<a href="%s" target="_blank">%s</a>',
|
251 |
$oCon->getPluginSpec()[ 'meta' ][ 'url_repo_home' ],
|
252 |
$oCon->getHumanName()
|
253 |
)
|
254 |
),
|
255 |
+
'lines' => [
|
256 |
sprintf( _wpsf__( 'Time remaining on black list: %s' ),
|
257 |
sprintf( _n( '%s minute', '%s minutes', $nTimeRemaining, 'wp-simple-firewall' ), $nTimeRemaining )
|
258 |
),
|
259 |
sprintf( _wpsf__( 'You tripped the security plugin defenses a total of %s times making you a suspect.' ), $oFO->getOptTransgressionLimit() ),
|
260 |
sprintf( _wpsf__( 'If you believe this to be in error, please contact the site owner and quote your IP address below.' ) ),
|
261 |
+
],
|
262 |
'your_ip' => 'Your IP address',
|
263 |
'unblock' => [
|
264 |
'title' => _wpsf__( 'Auto-Unblock Your IP' ),
|
265 |
'you_can' => _wpsf__( 'You can automatically unblock your IP address by clicking the button below.' ),
|
266 |
'button' => _wpsf__( 'Unblock My IP Address' ),
|
267 |
],
|
268 |
+
],
|
269 |
+
'vars' => [
|
270 |
'nonce' => $oFO->getNonceActionData( 'uau' ),
|
271 |
'ip' => $sIp,
|
272 |
'gasp_element' => $oFO->renderTemplate(
|
273 |
'snippets/gasp_js.php',
|
274 |
+
[
|
275 |
'sCbName' => $oLoginFO->getGaspKey(),
|
276 |
'sLabel' => $oLoginFO->getTextImAHuman(),
|
277 |
'sAlert' => $oLoginFO->getTextPleaseCheckBox(),
|
278 |
'sMustJs' => _wpsf__( 'You MUST enable Javascript to be able to login' ),
|
279 |
'sUniqId' => $sUniqId,
|
280 |
'sUniqElem' => 'icwp_wpsf_login_p'.$sUniqId,
|
281 |
+
'strings' => [
|
282 |
'loading' => _wpsf__( 'Loading' )
|
283 |
+
]
|
284 |
+
]
|
285 |
),
|
286 |
+
],
|
287 |
+
'flags' => [
|
288 |
'is_autorecover' => $oFO->isEnabledAutoUserRecover(),
|
289 |
'is_uau_permitted' => $oFO->getCanIpRequestAutoUnblock( $sIp ),
|
290 |
+
],
|
291 |
];
|
292 |
$this->loadWp()
|
293 |
->wpDie(
|
@@ -16,8 +16,6 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
16 |
if ( !empty( $sWpVersionMask ) ) {
|
17 |
global $wp_version;
|
18 |
$wp_version = $sWpVersionMask;
|
19 |
-
// add_filter( 'bloginfo', array( $this, 'maskWordpressVersion' ), 1, 2 );
|
20 |
-
// add_filter( 'bloginfo_url', array( $this, 'maskWordpressVersion' ), 1, 2 );
|
21 |
}
|
22 |
|
23 |
if ( $oFO->isOpt( 'force_ssl_admin', 'Y' ) && function_exists( 'force_ssl_admin' ) ) {
|
@@ -32,8 +30,8 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
32 |
}
|
33 |
|
34 |
if ( $oFO->isXmlrpcDisabled() ) {
|
35 |
-
add_filter( 'xmlrpc_enabled',
|
36 |
-
add_filter( 'xmlrpc_methods',
|
37 |
}
|
38 |
}
|
39 |
|
@@ -62,14 +60,15 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
62 |
|
63 |
public function onWpInit() {
|
64 |
parent::onWpInit();
|
|
|
65 |
if ( !Services::WpUsers()->isUserLoggedIn() ) {
|
66 |
$this->interceptCanonicalRedirects();
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
}
|
74 |
}
|
75 |
|
@@ -84,20 +83,6 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
84 |
return ( current_filter() == 'xmlrpc_enabled' ) ? false : [];
|
85 |
}
|
86 |
|
87 |
-
/**
|
88 |
-
* TODO: instead of filtering auth errors, perhaps create a valid json response
|
89 |
-
*/
|
90 |
-
private function interceptAnonRestApi() {
|
91 |
-
/** @var ICWP_WPSF_FeatureHandler_Lockdown $oFO */
|
92 |
-
$oFO = $this->getMod();
|
93 |
-
$oWpRest = Services::Rest();
|
94 |
-
if ( $oWpRest->isRest() && $oFO->isRestApiAnonymousAccessDisabled()
|
95 |
-
&& !$oFO->isPermittedAnonRestApiNamespace( $oWpRest->getNamespace() ) ) {
|
96 |
-
// 99 so that we jump in just before the always-on WordPress cookie auth.
|
97 |
-
add_filter( 'rest_authentication_errors', array( $this, 'disableAnonymousRestApi' ), 99 );
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
/**
|
102 |
* @uses wp_die()
|
103 |
*/
|
@@ -125,14 +110,18 @@ class ICWP_WPSF_Processor_Lockdown extends ICWP_WPSF_Processor_BaseWpsf {
|
|
125 |
* @return WP_Error
|
126 |
*/
|
127 |
public function disableAnonymousRestApi( $mStatus ) {
|
|
|
|
|
|
|
128 |
|
129 |
-
if ( $mStatus !== true && !is_wp_error( $mStatus )
|
|
|
130 |
|
131 |
$mStatus = new \WP_Error(
|
132 |
'shield_block_anon_restapi',
|
133 |
sprintf( _wpsf__( 'Anonymous access to the WordPress Rest API has been restricted by %s.' ), $this->getCon()
|
134 |
->getHumanName() ),
|
135 |
-
|
136 |
$this->addToAuditEntry(
|
137 |
sprintf( 'Blocked Anonymous API Access through "%s" namespace', Services::Rest()->getNamespace() ),
|
138 |
1,
|
16 |
if ( !empty( $sWpVersionMask ) ) {
|
17 |
global $wp_version;
|
18 |
$wp_version = $sWpVersionMask;
|
|
|
|
|
19 |
}
|
20 |
|
21 |
if ( $oFO->isOpt( 'force_ssl_admin', 'Y' ) && function_exists( 'force_ssl_admin' ) ) {
|
30 |
}
|
31 |
|
32 |
if ( $oFO->isXmlrpcDisabled() ) {
|
33 |
+
add_filter( 'xmlrpc_enabled', [ $this, 'disableXmlrpc' ], 1000, 0 );
|
34 |
+
add_filter( 'xmlrpc_methods', [ $this, 'disableXmlrpc' ], 1000, 0 );
|
35 |
}
|
36 |
}
|
37 |
|
60 |
|
61 |
public function onWpInit() {
|
62 |
parent::onWpInit();
|
63 |
+
|
64 |
if ( !Services::WpUsers()->isUserLoggedIn() ) {
|
65 |
$this->interceptCanonicalRedirects();
|
66 |
|
67 |
+
/** @var ICWP_WPSF_FeatureHandler_Lockdown $oFO */
|
68 |
+
$oFO = $this->getMod();
|
69 |
+
if ( $oFO->isRestApiAnonymousAccessDisabled() ) {
|
70 |
+
add_filter( 'rest_authentication_errors', [ $this, 'disableAnonymousRestApi' ], 99 );
|
71 |
+
}
|
72 |
}
|
73 |
}
|
74 |
|
83 |
return ( current_filter() == 'xmlrpc_enabled' ) ? false : [];
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
/**
|
87 |
* @uses wp_die()
|
88 |
*/
|
110 |
* @return WP_Error
|
111 |
*/
|
112 |
public function disableAnonymousRestApi( $mStatus ) {
|
113 |
+
/** @var ICWP_WPSF_FeatureHandler_Lockdown $oFO */
|
114 |
+
$oFO = $this->getMod();
|
115 |
+
$oWpRest = Services::Rest();
|
116 |
|
117 |
+
if ( $mStatus !== true && !is_wp_error( $mStatus )
|
118 |
+
&& !$oFO->isPermittedAnonRestApiNamespace( $oWpRest->getNamespace() ) ) {
|
119 |
|
120 |
$mStatus = new \WP_Error(
|
121 |
'shield_block_anon_restapi',
|
122 |
sprintf( _wpsf__( 'Anonymous access to the WordPress Rest API has been restricted by %s.' ), $this->getCon()
|
123 |
->getHumanName() ),
|
124 |
+
[ 'status' => rest_authorization_required_code() ] );
|
125 |
$this->addToAuditEntry(
|
126 |
sprintf( 'Blocked Anonymous API Access through "%s" namespace', Services::Rest()->getNamespace() ),
|
127 |
1,
|
@@ -35,6 +35,48 @@ class ICWP_WPSF_Processor_LoginProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
35 |
$this->getSubProIntent()->run();
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* Override the original collection to then add plugin statistics to the mix
|
40 |
* @param $aData
|
@@ -56,9 +98,9 @@ class ICWP_WPSF_Processor_LoginProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
56 |
$oFO = $this->getMod();
|
57 |
|
58 |
if ( $oFO->isEmailAuthenticationOptionOn() && !$oFO->isEmailAuthenticationActive() && !$oFO->getIfCanSendEmailVerified() ) {
|
59 |
-
$aRenderData =
|
60 |
'notice_attributes' => $aNoticeAttributes,
|
61 |
-
'strings' =>
|
62 |
'title' => $this->getCon()->getHumanName()
|
63 |
.': '._wpsf__( 'Please verify email has been received' ),
|
64 |
'need_you_confirm' => _wpsf__( "Before we can activate email 2-factor authentication, we need you to confirm your website can send emails." ),
|
@@ -69,12 +111,12 @@ class ICWP_WPSF_Processor_LoginProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
69 |
),
|
70 |
'how_resend_email' => _wpsf__( "Resend verification email" ),
|
71 |
'how_turn_off' => _wpsf__( "Disable 2FA by email" ),
|
72 |
-
|
73 |
'ajax' => [
|
74 |
'resend_verification_email' => $oFO->getAjaxActionData( 'resend_verification_email', true ),
|
75 |
'disable_2fa_email' => $oFO->getAjaxActionData( 'disable_2fa_email', true ),
|
76 |
]
|
77 |
-
|
78 |
$this->insertAdminNotice( $aRenderData );
|
79 |
}
|
80 |
}
|
@@ -84,11 +126,11 @@ class ICWP_WPSF_Processor_LoginProtect extends ICWP_WPSF_Processor_BaseWpsf {
|
|
84 |
*/
|
85 |
protected function getSubProMap() {
|
86 |
return [
|
87 |
-
'cooldown'
|
88 |
-
'gasp'
|
89 |
-
'intent'
|
90 |
-
'recaptcha'
|
91 |
-
'rename'
|
92 |
];
|
93 |
}
|
94 |
|
35 |
$this->getSubProIntent()->run();
|
36 |
}
|
37 |
|
38 |
+
public function onWpEnqueueJs() {
|
39 |
+
/** @var ICWP_WPSF_FeatureHandler_LoginProtect $oFO */
|
40 |
+
$oFO = $this->getMod();
|
41 |
+
|
42 |
+
if ( $oFO->isEnabledBotJs() ) {
|
43 |
+
$oConn = $this->getCon();
|
44 |
+
|
45 |
+
$sAsset = 'shield-antibot';
|
46 |
+
$sUnique = $this->prefix( $sAsset );
|
47 |
+
wp_register_script(
|
48 |
+
$sUnique,
|
49 |
+
$oConn->getPluginUrl_Js( $sAsset.'.js' ),
|
50 |
+
[ 'jquery' ],
|
51 |
+
$oConn->getVersion(),
|
52 |
+
true
|
53 |
+
);
|
54 |
+
wp_enqueue_script( $sUnique );
|
55 |
+
|
56 |
+
wp_localize_script(
|
57 |
+
$sUnique,
|
58 |
+
'icwp_wpsf_vars_lpantibot',
|
59 |
+
[
|
60 |
+
'form_selectors' => implode( ',', $oFO->getAntiBotFormSelectors() ),
|
61 |
+
'uniq' => preg_replace( '#[^a-zA-Z0-9]#', '', apply_filters( 'icwp_shield_lp_gasp_uniqid', uniqid() ) ),
|
62 |
+
'cbname' => $oFO->getGaspKey(),
|
63 |
+
'strings' => [
|
64 |
+
'label' => $oFO->getTextImAHuman(),
|
65 |
+
'alert' => $oFO->getTextPleaseCheckBox(),
|
66 |
+
],
|
67 |
+
'flags' => [
|
68 |
+
'gasp' => $oFO->isEnabledGaspCheck(),
|
69 |
+
'recap' => $oFO->isGoogleRecaptchaEnabled(),
|
70 |
+
]
|
71 |
+
]
|
72 |
+
);
|
73 |
+
|
74 |
+
if ( $oFO->isGoogleRecaptchaEnabled() ) {
|
75 |
+
$this->setRecaptchaToEnqueue();
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
/**
|
81 |
* Override the original collection to then add plugin statistics to the mix
|
82 |
* @param $aData
|
98 |
$oFO = $this->getMod();
|
99 |
|
100 |
if ( $oFO->isEmailAuthenticationOptionOn() && !$oFO->isEmailAuthenticationActive() && !$oFO->getIfCanSendEmailVerified() ) {
|
101 |
+
$aRenderData = [
|
102 |
'notice_attributes' => $aNoticeAttributes,
|
103 |
+
'strings' => [
|
104 |
'title' => $this->getCon()->getHumanName()
|
105 |
.': '._wpsf__( 'Please verify email has been received' ),
|
106 |
'need_you_confirm' => _wpsf__( "Before we can activate email 2-factor authentication, we need you to confirm your website can send emails." ),
|
111 |
),
|
112 |
'how_resend_email' => _wpsf__( "Resend verification email" ),
|
113 |
'how_turn_off' => _wpsf__( "Disable 2FA by email" ),
|
114 |
+
],
|
115 |
'ajax' => [
|
116 |
'resend_verification_email' => $oFO->getAjaxActionData( 'resend_verification_email', true ),
|
117 |
'disable_2fa_email' => $oFO->getAjaxActionData( 'disable_2fa_email', true ),
|
118 |
]
|
119 |
+
];
|
120 |
$this->insertAdminNotice( $aRenderData );
|
121 |
}
|
122 |
}
|
126 |
*/
|
127 |
protected function getSubProMap() {
|
128 |
return [
|
129 |
+
'cooldown' => 'ICWP_WPSF_Processor_LoginProtect_Cooldown',
|
130 |
+
'gasp' => 'ICWP_WPSF_Processor_LoginProtect_Gasp',
|
131 |
+
'intent' => 'ICWP_WPSF_Processor_LoginProtect_Intent',
|
132 |
+
'recaptcha' => 'ICWP_WPSF_Processor_LoginProtect_GoogleRecaptcha',
|
133 |
+
'rename' => 'ICWP_WPSF_Processor_LoginProtect_WpLogin',
|
134 |
];
|
135 |
}
|
136 |
|
@@ -35,7 +35,7 @@ abstract class ICWP_WPSF_Processor_LoginProtect_Base extends ICWP_WPSF_Processor
|
|
35 |
*/
|
36 |
public function run() {
|
37 |
$this->setFactorTested( false );
|
38 |
-
add_action( 'init',
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -52,34 +52,37 @@ abstract class ICWP_WPSF_Processor_LoginProtect_Base extends ICWP_WPSF_Processor
|
|
52 |
|
53 |
if ( $oFO->isProtectLogin() ) {
|
54 |
// We give it a priority of 10 so that we can jump in before WordPress does its own validation.
|
55 |
-
add_filter( 'authenticate',
|
56 |
|
57 |
-
add_action( 'login_form',
|
58 |
-
add_filter( 'login_form_middle',
|
59 |
|
60 |
if ( $b3rdParty ) {
|
61 |
-
add_action( 'edd_login_fields_after',
|
62 |
|
63 |
-
add_action( 'woocommerce_login_form',
|
64 |
-
add_filter( 'woocommerce_process_login_errors',
|
65 |
|
66 |
// MemberPress
|
67 |
-
add_action( 'mepr-login-form-before-submit',
|
68 |
-
add_filter( 'mepr-validate-login',
|
69 |
// Ultimate Member
|
70 |
-
add_action( 'um_after_login_fields',
|
71 |
-
add_action( 'um_submit_form_login',
|
72 |
|
73 |
// LearnPress
|
74 |
-
add_action( 'learn-press/after-form-login-fields',
|
75 |
-
add_action( 'learn-press/before-checkout-form-login-button', [
|
76 |
-
|
|
|
|
|
|
|
77 |
}
|
78 |
}
|
79 |
|
80 |
if ( $oFO->isProtectLostPassword() ) {
|
81 |
-
add_action( 'lostpassword_form',
|
82 |
-
add_action( 'lostpassword_post',
|
83 |
|
84 |
//No need to really cover this form
|
85 |
// add_action( 'resetpass_form', array( $this, 'printFormItems' ) );
|
@@ -87,51 +90,60 @@ abstract class ICWP_WPSF_Processor_LoginProtect_Base extends ICWP_WPSF_Processor
|
|
87 |
// add_action( 'woocommerce_resetpassword_form', array( $this, 'printFormItems' ), 10 );
|
88 |
|
89 |
if ( $b3rdParty ) {
|
90 |
-
add_action( 'woocommerce_lostpassword_form',
|
91 |
|
92 |
// MemberPress
|
93 |
-
add_action( 'mepr-forgot-password-form',
|
94 |
-
add_filter( 'mepr-validate-forgot-password',
|
95 |
// Ultimate Member
|
96 |
-
add_action( 'um_after_password_reset_fields',
|
97 |
-
add_action( 'um_submit_form_password_reset',
|
98 |
}
|
99 |
}
|
100 |
|
101 |
if ( $oFO->isProtectRegister() ) {
|
102 |
-
add_action( 'register_form',
|
103 |
// add_action( 'register_post', array( $this, 'checkReqRegistration_Wp' ), 10, 1 );
|
104 |
-
add_filter( 'registration_errors',
|
105 |
|
106 |
if ( $b3rdParty ) {
|
107 |
// A Catch-all:
|
108 |
// 20180909 - not a bit wise as it breaks anything that doesn't properly display front-end output
|
109 |
// add_filter( 'wp_pre_insert_user_data', array( $this, 'checkPreUserInsert_Wp' ), 10, 1 );
|
110 |
|
111 |
-
add_action( 'bp_before_registration_submit_buttons',
|
112 |
-
add_action( 'bp_signup_validate',
|
113 |
|
114 |
-
add_action( 'edd_register_form_fields_before_submit',
|
115 |
-
add_action( 'edd_process_register_form',
|
116 |
|
117 |
-
add_action( 'woocommerce_register_form',
|
118 |
-
add_action( 'woocommerce_after_checkout_registration_form', [
|
|
|
|
|
|
|
119 |
add_filter( 'woocommerce_process_registration_errors', [ $this, 'checkReqRegistration_Woo' ], 10, 2 );
|
120 |
|
121 |
// MemberPress - Checkout == Registration
|
122 |
-
add_action( 'mepr-checkout-before-submit',
|
123 |
-
add_filter( 'mepr-validate-signup',
|
124 |
// Ultimate Member
|
125 |
-
add_action( 'um_after_register_fields',
|
126 |
-
add_action( 'um_submit_form_register',
|
127 |
// LearnPress
|
128 |
add_action( 'learn-press/after-form-register-fields', [ $this, 'printFormItems_LearnPress' ], 100 );
|
129 |
-
add_filter( 'learn-press/register-validate-field', [
|
|
|
|
|
|
|
130 |
}
|
131 |
}
|
132 |
|
133 |
if ( $b3rdParty && $oFO->isProtect( 'checkout_woo' ) ) {
|
134 |
-
add_action( 'woocommerce_after_checkout_registration_form', [
|
|
|
|
|
|
|
135 |
add_action( 'woocommerce_after_checkout_validation', [ $this, 'checkReqCheckout_Woo' ], 10, 2 );
|
136 |
}
|
137 |
}
|
@@ -433,7 +445,7 @@ abstract class ICWP_WPSF_Processor_LoginProtect_Base extends ICWP_WPSF_Processor
|
|
433 |
|
434 |
/**
|
435 |
* @param WP_Error $oWpError
|
436 |
-
* @param
|
437 |
* @return WP_Error
|
438 |
*/
|
439 |
public function checkReqRegistrationErrors_Wp( $oWpError, $sUsername ) {
|
35 |
*/
|
36 |
public function run() {
|
37 |
$this->setFactorTested( false );
|
38 |
+
add_action( 'init', [ $this, 'addHooks' ], -100 );
|
39 |
}
|
40 |
|
41 |
/**
|
52 |
|
53 |
if ( $oFO->isProtectLogin() ) {
|
54 |
// We give it a priority of 10 so that we can jump in before WordPress does its own validation.
|
55 |
+
add_filter( 'authenticate', [ $this, 'checkReqLogin_Wp' ], 10, 3 );
|
56 |
|
57 |
+
add_action( 'login_form', [ $this, 'printLoginFormItems' ], 100 );
|
58 |
+
add_filter( 'login_form_middle', [ $this, 'provideLoginFormItems' ], 100 );
|
59 |
|
60 |
if ( $b3rdParty ) {
|
61 |
+
add_action( 'edd_login_fields_after', [ $this, 'printLoginFormItems' ], 10 );
|
62 |
|
63 |
+
add_action( 'woocommerce_login_form', [ $this, 'printLoginFormItems_Woo' ], 100 );
|
64 |
+
add_filter( 'woocommerce_process_login_errors', [ $this, 'checkReqLogin_Woo' ], 10, 2 );
|
65 |
|
66 |
// MemberPress
|
67 |
+
add_action( 'mepr-login-form-before-submit', [ $this, 'printLoginFormItems_MePr' ], 100 );
|
68 |
+
add_filter( 'mepr-validate-login', [ $this, 'checkReqLogin_MePr' ], 100 );
|
69 |
// Ultimate Member
|
70 |
+
add_action( 'um_after_login_fields', [ $this, 'printFormItems_UltMem' ], 100 );
|
71 |
+
add_action( 'um_submit_form_login', [ $this, 'checkReqLogin_UltMem' ], 100 );
|
72 |
|
73 |
// LearnPress
|
74 |
+
add_action( 'learn-press/after-form-login-fields', [ $this, 'printFormItems_LearnPress' ], 100 );
|
75 |
+
add_action( 'learn-press/before-checkout-form-login-button', [
|
76 |
+
$this,
|
77 |
+
'printFormItems_LearnPress'
|
78 |
+
], 100 );
|
79 |
+
add_filter( 'learn-press/login-validate-field', [ $this, 'checkReqLogin_LearnPress' ], 100 );
|
80 |
}
|
81 |
}
|
82 |
|
83 |
if ( $oFO->isProtectLostPassword() ) {
|
84 |
+
add_action( 'lostpassword_form', [ $this, 'printFormItems' ] );
|
85 |
+
add_action( 'lostpassword_post', [ $this, 'checkReqLostPassword_Wp' ], 10, 1 );
|
86 |
|
87 |
//No need to really cover this form
|
88 |
// add_action( 'resetpass_form', array( $this, 'printFormItems' ) );
|
90 |
// add_action( 'woocommerce_resetpassword_form', array( $this, 'printFormItems' ), 10 );
|
91 |
|
92 |
if ( $b3rdParty ) {
|
93 |
+
add_action( 'woocommerce_lostpassword_form', [ $this, 'printFormItems' ], 10 );
|
94 |
|
95 |
// MemberPress
|
96 |
+
add_action( 'mepr-forgot-password-form', [ $this, 'printLoginFormItems_MePr' ], 100 );
|
97 |
+
add_filter( 'mepr-validate-forgot-password', [ $this, 'checkReqLostPassword_MePr' ], 100 );
|
98 |
// Ultimate Member
|
99 |
+
add_action( 'um_after_password_reset_fields', [ $this, 'printFormItems_UltMem' ], 100 );
|
100 |
+
add_action( 'um_submit_form_password_reset', [ $this, 'checkReqLostPassword_UltMem' ], 5, 0 );
|
101 |
}
|
102 |
}
|
103 |
|
104 |
if ( $oFO->isProtectRegister() ) {
|
105 |
+
add_action( 'register_form', [ $this, 'printFormItems' ] );
|
106 |
// add_action( 'register_post', array( $this, 'checkReqRegistration_Wp' ), 10, 1 );
|
107 |
+
add_filter( 'registration_errors', [ $this, 'checkReqRegistrationErrors_Wp' ], 10, 2 );
|
108 |
|
109 |
if ( $b3rdParty ) {
|
110 |
// A Catch-all:
|
111 |
// 20180909 - not a bit wise as it breaks anything that doesn't properly display front-end output
|
112 |
// add_filter( 'wp_pre_insert_user_data', array( $this, 'checkPreUserInsert_Wp' ), 10, 1 );
|
113 |
|
114 |
+
add_action( 'bp_before_registration_submit_buttons', [ $this, 'printLoginFormItems_Bp' ], 10 );
|
115 |
+
add_action( 'bp_signup_validate', [ $this, 'checkReqRegistration_Bp' ], 10 );
|
116 |
|
117 |
+
add_action( 'edd_register_form_fields_before_submit', [ $this, 'printFormItems' ], 10 );
|
118 |
+
add_action( 'edd_process_register_form', [ $this, 'checkReqRegistration_Edd' ], 10 );
|
119 |
|
120 |
+
add_action( 'woocommerce_register_form', [ $this, 'printRegisterFormItems_Woo' ], 10 );
|
121 |
+
add_action( 'woocommerce_after_checkout_registration_form', [
|
122 |
+
$this,
|
123 |
+
'printRegistrationFormItems_Woo'
|
124 |
+
], 10 );
|
125 |
add_filter( 'woocommerce_process_registration_errors', [ $this, 'checkReqRegistration_Woo' ], 10, 2 );
|
126 |
|
127 |
// MemberPress - Checkout == Registration
|
128 |
+
add_action( 'mepr-checkout-before-submit', [ $this, 'printRegisterFormItems_MePr' ], 10 );
|
129 |
+
add_filter( 'mepr-validate-signup', [ $this, 'checkReqRegistration_MePr' ], 10, 2 );
|
130 |
// Ultimate Member
|
131 |
+
add_action( 'um_after_register_fields', [ $this, 'printFormItems_UltMem' ], 100 );
|
132 |
+
add_action( 'um_submit_form_register', [ $this, 'checkReqRegistration_UltMem' ], 5, 0 );
|
133 |
// LearnPress
|
134 |
add_action( 'learn-press/after-form-register-fields', [ $this, 'printFormItems_LearnPress' ], 100 );
|
135 |
+
add_filter( 'learn-press/register-validate-field', [
|
136 |
+
$this,
|
137 |
+
'checkReqRegistration_LearnPress'
|
138 |
+
], 100, 1 );
|
139 |
}
|
140 |
}
|
141 |
|
142 |
if ( $b3rdParty && $oFO->isProtect( 'checkout_woo' ) ) {
|
143 |
+
add_action( 'woocommerce_after_checkout_registration_form', [
|
144 |
+
$this,
|
145 |
+
'printRegistrationFormItems_Woo'
|
146 |
+
], 10 );
|
147 |
add_action( 'woocommerce_after_checkout_validation', [ $this, 'checkReqCheckout_Woo' ], 10, 2 );
|
148 |
}
|
149 |
}
|
445 |
|
446 |
/**
|
447 |
* @param WP_Error $oWpError
|
448 |
+
* @param string $sUsername
|
449 |
* @return WP_Error
|
450 |
*/
|
451 |
public function checkReqRegistrationErrors_Wp( $oWpError, $sUsername ) {
|
@@ -20,17 +20,17 @@ class ICWP_WPSF_Processor_LoginProtect_Gasp extends ICWP_WPSF_Processor_LoginPro
|
|
20 |
$sUniqId = preg_replace( '#[^a-zA-Z0-9]#', '', apply_filters( 'icwp_shield_lp_gasp_uniqid', uniqid() ) );
|
21 |
return $this->getMod()->renderTemplate(
|
22 |
'snippets/gasp_js.php',
|
23 |
-
|
24 |
'sCbName' => $oFO->getGaspKey(),
|
25 |
'sLabel' => $oFO->getTextImAHuman(),
|
26 |
'sAlert' => $oFO->getTextPleaseCheckBox(),
|
27 |
'sMustJs' => _wpsf__( 'You MUST enable Javascript to be able to login' ),
|
28 |
'sUniqId' => $sUniqId,
|
29 |
'sUniqElem' => 'icwp_wpsf_login_p'.$sUniqId,
|
30 |
-
'strings' =>
|
31 |
'loading' => _wpsf__( 'Loading' )
|
32 |
-
|
33 |
-
|
34 |
);
|
35 |
}
|
36 |
|
20 |
$sUniqId = preg_replace( '#[^a-zA-Z0-9]#', '', apply_filters( 'icwp_shield_lp_gasp_uniqid', uniqid() ) );
|
21 |
return $this->getMod()->renderTemplate(
|
22 |
'snippets/gasp_js.php',
|
23 |
+
[
|
24 |
'sCbName' => $oFO->getGaspKey(),
|
25 |
'sLabel' => $oFO->getTextImAHuman(),
|
26 |
'sAlert' => $oFO->getTextPleaseCheckBox(),
|
27 |
'sMustJs' => _wpsf__( 'You MUST enable Javascript to be able to login' ),
|
28 |
'sUniqId' => $sUniqId,
|
29 |
'sUniqElem' => 'icwp_wpsf_login_p'.$sUniqId,
|
30 |
+
'strings' => [
|
31 |
'loading' => _wpsf__( 'Loading' )
|
32 |
+
]
|
33 |
+
]
|
34 |
);
|
35 |
}
|
36 |
|
@@ -7,8 +7,8 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleRecaptcha extends ICWP_WPSF_Process
|
|
7 |
*/
|
8 |
public function run() {
|
9 |
parent::run();
|
10 |
-
add_action( 'wp_enqueue_scripts',
|
11 |
-
add_action( 'login_enqueue_scripts',
|
12 |
}
|
13 |
|
14 |
/**
|
7 |
*/
|
8 |
public function run() {
|
9 |
parent::run();
|
10 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'registerGoogleRecaptchaJs' ], 99 );
|
11 |
+
add_action( 'login_enqueue_scripts', [ $this, 'registerGoogleRecaptchaJs' ], 99 );
|
12 |
}
|
13 |
|
14 |
/**
|
@@ -19,13 +19,13 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
19 |
public function run() {
|
20 |
/** @var ICWP_WPSF_FeatureHandler_LoginProtect $oFO */
|
21 |
$oFO = $this->getMod();
|
22 |
-
add_action( 'wp_logout',
|
23 |
|
24 |
// 100 priority is important as this takes priority
|
25 |
// add_filter( $oFO->prefix( 'user_subject_to_login_intent' ), array( $this, 'applyUserCanMfaSkip' ), 100, 2 );
|
26 |
|
27 |
if ( $oFO->getIfSupport3rdParty() ) {
|
28 |
-
add_action( 'wc_social_login_before_user_login',
|
29 |
}
|
30 |
}
|
31 |
|
@@ -297,8 +297,8 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
297 |
$aLabels = $oCon->getLabels();
|
298 |
$sBannerUrl = empty( $aLabels[ 'url_login2fa_logourl' ] ) ? $oCon->getPluginUrl_Image( 'pluginlogo_banner-772x250.png' ) : $aLabels[ 'url_login2fa_logourl' ];
|
299 |
$nMfaSkip = $oFO->getMfaSkip();
|
300 |
-
$aDisplayData =
|
301 |
-
'strings' =>
|
302 |
'cancel' => _wpsf__( 'Cancel Login' ),
|
303 |
'time_remaining' => _wpsf__( 'Time Remaining' ),
|
304 |
'calculating' => _wpsf__( 'Calculating' ).' ...',
|
@@ -313,15 +313,15 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
313 |
_wpsf__( "Don't ask again on this browser for %s." ),
|
314 |
sprintf( _n( '%s day', '%s days', $nMfaSkip, 'wp-simple-firewall' ), $nMfaSkip )
|
315 |
)
|
316 |
-
|
317 |
-
'data' =>
|
318 |
'login_fields' => $aLoginIntentFields,
|
319 |
'time_remaining' => $this->getLoginIntentExpiresAt() - $this->time(),
|
320 |
'message_type' => $sMessageType,
|
321 |
'login_intent_flag' => $oFO->getLoginIntentRequestFlag(),
|
322 |
'page_locale' => Services::WpGeneral()->getLocale( '-' )
|
323 |
-
|
324 |
-
'hrefs' =>
|
325 |
'form_action' => $oReq->getUri(),
|
326 |
'css_bootstrap' => $oCon->getPluginUrl_Css( 'bootstrap4.min.css' ),
|
327 |
'js_bootstrap' => $oCon->getPluginUrl_Js( 'bootstrap4.min.js' ),
|
@@ -329,16 +329,16 @@ class ICWP_WPSF_Processor_LoginProtect_Intent extends ICWP_WPSF_Processor_BaseWp
|
|
329 |
'redirect_to' => $sRedirectTo,
|
330 |
'what_is_this' => 'https://icontrolwp.freshdesk.com/support/solutions/articles/3000064840',
|
331 |
'cancel_href' => $sCancelHref
|
332 |
-
|
333 |
-
'imgs' =>
|
334 |
'banner' => $sBannerUrl,
|
335 |
'favicon' => $oCon->getPluginUrl_Image( 'pluginlogo_24x24.png' ),
|
336 |
-
|
337 |
-
'flags' =>
|
338 |
'can_skip_mfa' => $oFO->getMfaSkipEnabled(),
|
339 |
'show_branded_links' => !$oFO->isWlEnabled(), // white label mitigation
|
340 |
-
|
341 |
-
|
342 |
|
343 |
$this->loadRenderer( $this->getCon()->getPath_Templates() )
|
344 |
->setTemplate( 'page/login_intent' )
|
19 |
public function run() {
|
20 |
/** @var ICWP_WPSF_FeatureHandler_LoginProtect $oFO */
|
21 |
$oFO = $this->getMod();
|
22 |
+
add_action( 'wp_logout', [ $this, 'onWpLogout' ] );
|
23 |
|
24 |
// 100 priority is important as this takes priority
|
25 |
// add_filter( $oFO->prefix( 'user_subject_to_login_intent' ), array( $this, 'applyUserCanMfaSkip' ), 100, 2 );
|
26 |
|
27 |
if ( $oFO->getIfSupport3rdParty() ) {
|
28 |
+
add_action( 'wc_social_login_before_user_login', [ $this, 'onWcSocialLogin' ] );
|
29 |
}
|
30 |
}
|
31 |
|
297 |
$aLabels = $oCon->getLabels();
|
298 |
$sBannerUrl = empty( $aLabels[ 'url_login2fa_logourl' ] ) ? $oCon->getPluginUrl_Image( 'pluginlogo_banner-772x250.png' ) : $aLabels[ 'url_login2fa_logourl' ];
|
299 |
$nMfaSkip = $oFO->getMfaSkip();
|
300 |
+
$aDisplayData = [
|
301 |
+
'strings' => [
|
302 |
'cancel' => _wpsf__( 'Cancel Login' ),
|
303 |
'time_remaining' => _wpsf__( 'Time Remaining' ),
|
304 |
'calculating' => _wpsf__( 'Calculating' ).' ...',
|
313 |
_wpsf__( "Don't ask again on this browser for %s." ),
|
314 |
sprintf( _n( '%s day', '%s days', $nMfaSkip, 'wp-simple-firewall' ), $nMfaSkip )
|
315 |
)
|
316 |
+
],
|
317 |
+
'data' => [
|
318 |
'login_fields' => $aLoginIntentFields,
|
319 |
'time_remaining' => $this->getLoginIntentExpiresAt() - $this->time(),
|
320 |
'message_type' => $sMessageType,
|
321 |
'login_intent_flag' => $oFO->getLoginIntentRequestFlag(),
|
322 |
'page_locale' => Services::WpGeneral()->getLocale( '-' )
|
323 |
+
],
|
324 |
+
'hrefs' => [
|
325 |
'form_action' => $oReq->getUri(),
|
326 |
'css_bootstrap' => $oCon->getPluginUrl_Css( 'bootstrap4.min.css' ),
|
327 |
'js_bootstrap' => $oCon->getPluginUrl_Js( 'bootstrap4.min.js' ),
|
329 |
'redirect_to' => $sRedirectTo,
|
330 |
'what_is_this' => 'https://icontrolwp.freshdesk.com/support/solutions/articles/3000064840',
|
331 |
'cancel_href' => $sCancelHref
|
332 |
+
],
|
333 |
+
'imgs' => [
|
334 |
'banner' => $sBannerUrl,
|
335 |
'favicon' => $oCon->getPluginUrl_Image( 'pluginlogo_24x24.png' ),
|
336 |
+
],
|
337 |
+
'flags' => [
|
338 |
'can_skip_mfa' => $oFO->getMfaSkipEnabled(),
|
339 |
'show_branded_links' => !$oFO->isWlEnabled(), // white label mitigation
|
340 |
+
]
|
341 |
+
];
|
342 |
|
343 |
$this->loadRenderer( $this->getCon()->getPath_Templates() )
|
344 |
->setTemplate( 'page/login_intent' )
|
@@ -13,14 +13,14 @@ class ICWP_WPSF_Processor_LoginProtect_BackupCodes extends ICWP_WPSF_Processor_L
|
|
13 |
$oCon = $this->getCon();
|
14 |
|
15 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
16 |
-
$aData =
|
17 |
'has_mfa' => $this->isUserSubjectToLoginIntent( $oUser ),
|
18 |
'has_validated_profile' => $bValidatedProfile,
|
19 |
'user_google_authenticator_secret' => $this->getSecret( $oUser ),
|
20 |
'is_my_user_profile' => ( $oUser->ID == Services::WpUsers()->getCurrentWpUserId() ),
|
21 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
22 |
'user_to_edit_is_admin' => Services::WpUsers()->isUserAdmin( $oUser ),
|
23 |
-
'strings' =>
|
24 |
'button_gen_code' => _wpsf__( 'Generate ONE-Time Backup 2FA Login Code' ),
|
25 |
'button_del_code' => _wpsf__( 'Delete Login Backup Code' ),
|
26 |
'not_available' => _wpsf__( 'Backup login codes are not available if you do not have any other two-factor authentication modes active.' ),
|
@@ -42,11 +42,11 @@ class ICWP_WPSF_Processor_LoginProtect_BackupCodes extends ICWP_WPSF_Processor_L
|
|
42 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Backup Codes' ) ),
|
43 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
44 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
45 |
-
|
46 |
-
'data' =>
|
47 |
'otp_field_name' => $this->getLoginFormParameter()
|
48 |
-
|
49 |
-
|
50 |
|
51 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_backupcode.php', $aData );
|
52 |
}
|
@@ -64,14 +64,14 @@ class ICWP_WPSF_Processor_LoginProtect_BackupCodes extends ICWP_WPSF_Processor_L
|
|
64 |
*/
|
65 |
public function addLoginIntentField( $aFields ) {
|
66 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
67 |
-
$aFields[] =
|
68 |
'name' => $this->getLoginFormParameter(),
|
69 |
'type' => 'text',
|
70 |
'value' => '',
|
71 |
'placeholder' => _wpsf__( 'Please use your Backup Code to login.' ),
|
72 |
'text' => _wpsf__( 'Login Backup Code' ),
|
73 |
'help_link' => '',
|
74 |
-
|
75 |
}
|
76 |
return $aFields;
|
77 |
}
|
@@ -161,7 +161,7 @@ class ICWP_WPSF_Processor_LoginProtect_BackupCodes extends ICWP_WPSF_Processor_L
|
|
161 |
* @param WP_User $oUser
|
162 |
*/
|
163 |
private function sendBackupCodeUsedEmail( $oUser ) {
|
164 |
-
$aEmailContent =
|
165 |
_wpsf__( 'This is a quick notice to inform you that your Backup Login code was just used.' ),
|
166 |
_wpsf__( "Your WordPress account had only 1 backup login code." )
|
167 |
.' '._wpsf__( "You must go to your profile and regenerate a new code if you want to use this method again." ),
|
@@ -172,7 +172,7 @@ class ICWP_WPSF_Processor_LoginProtect_BackupCodes extends ICWP_WPSF_Processor_L
|
|
172 |
sprintf( '%s: %s', _wpsf__( 'IP Address' ), $this->ip() ),
|
173 |
'',
|
174 |
_wpsf__( 'Thank You.' ),
|
175 |
-
|
176 |
|
177 |
$sTitle = sprintf( _wpsf__( "Notice: %s" ), _wpsf__( "Backup Login Code Just Used" ) );
|
178 |
$this->getEmailProcessor()
|
13 |
$oCon = $this->getCon();
|
14 |
|
15 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
16 |
+
$aData = [
|
17 |
'has_mfa' => $this->isUserSubjectToLoginIntent( $oUser ),
|
18 |
'has_validated_profile' => $bValidatedProfile,
|
19 |
'user_google_authenticator_secret' => $this->getSecret( $oUser ),
|
20 |
'is_my_user_profile' => ( $oUser->ID == Services::WpUsers()->getCurrentWpUserId() ),
|
21 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
22 |
'user_to_edit_is_admin' => Services::WpUsers()->isUserAdmin( $oUser ),
|
23 |
+
'strings' => [
|
24 |
'button_gen_code' => _wpsf__( 'Generate ONE-Time Backup 2FA Login Code' ),
|
25 |
'button_del_code' => _wpsf__( 'Delete Login Backup Code' ),
|
26 |
'not_available' => _wpsf__( 'Backup login codes are not available if you do not have any other two-factor authentication modes active.' ),
|
42 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Backup Codes' ) ),
|
43 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
44 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
45 |
+
],
|
46 |
+
'data' => [
|
47 |
'otp_field_name' => $this->getLoginFormParameter()
|
48 |
+
]
|
49 |
+
];
|
50 |
|
51 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_backupcode.php', $aData );
|
52 |
}
|
64 |
*/
|
65 |
public function addLoginIntentField( $aFields ) {
|
66 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
67 |
+
$aFields[] = [
|
68 |
'name' => $this->getLoginFormParameter(),
|
69 |
'type' => 'text',
|
70 |
'value' => '',
|
71 |
'placeholder' => _wpsf__( 'Please use your Backup Code to login.' ),
|
72 |
'text' => _wpsf__( 'Login Backup Code' ),
|
73 |
'help_link' => '',
|
74 |
+
];
|
75 |
}
|
76 |
return $aFields;
|
77 |
}
|
161 |
* @param WP_User $oUser
|
162 |
*/
|
163 |
private function sendBackupCodeUsedEmail( $oUser ) {
|
164 |
+
$aEmailContent = [
|
165 |
_wpsf__( 'This is a quick notice to inform you that your Backup Login code was just used.' ),
|
166 |
_wpsf__( "Your WordPress account had only 1 backup login code." )
|
167 |
.' '._wpsf__( "You must go to your profile and regenerate a new code if you want to use this method again." ),
|
172 |
sprintf( '%s: %s', _wpsf__( 'IP Address' ), $this->ip() ),
|
173 |
'',
|
174 |
_wpsf__( 'Thank You.' ),
|
175 |
+
];
|
176 |
|
177 |
$sTitle = sprintf( _wpsf__( "Notice: %s" ), _wpsf__( "Backup Login Code Just Used" ) );
|
178 |
$this->getEmailProcessor()
|
@@ -18,8 +18,8 @@ abstract class ICWP_WPSF_Processor_LoginProtect_IntentProviderBase extends ICWP_
|
|
18 |
$this->getLoginTrack()->addFactorToTrack( $this->getStub() );
|
19 |
|
20 |
if ( $oFO->getIfUseLoginIntentPage() ) {
|
21 |
-
add_filter( $oFO->prefix( 'login-intent-form-fields' ),
|
22 |
-
add_action( $oFO->prefix( 'login-intent-validation' ),
|
23 |
}
|
24 |
|
25 |
if ( $this->loadWp()->isRequestUserLogin() || $oFO->getIfSupport3rdParty() ) {
|
@@ -27,14 +27,14 @@ abstract class ICWP_WPSF_Processor_LoginProtect_IntentProviderBase extends ICWP_
|
|
27 |
}
|
28 |
|
29 |
// Necessary so we don't show user intent to people without it
|
30 |
-
add_filter( $oFO->prefix( 'user_subject_to_login_intent' ),
|
31 |
|
32 |
-
add_action( 'show_user_profile',
|
33 |
-
add_action( 'personal_options_update',
|
34 |
|
35 |
if ( $this->getCon()->isPluginAdmin() ) {
|
36 |
-
add_action( 'edit_user_profile',
|
37 |
-
add_action( 'edit_user_profile_update',
|
38 |
}
|
39 |
}
|
40 |
|
@@ -88,9 +88,9 @@ abstract class ICWP_WPSF_Processor_LoginProtect_IntentProviderBase extends ICWP_
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
* @since 6.9.0 removed fallback to old user meta
|
92 |
* @param WP_User $oUser
|
93 |
* @return bool
|
|
|
94 |
*/
|
95 |
protected function hasValidatedProfile( $oUser ) {
|
96 |
$sKey = $this->getStub().'_validated';
|
18 |
$this->getLoginTrack()->addFactorToTrack( $this->getStub() );
|
19 |
|
20 |
if ( $oFO->getIfUseLoginIntentPage() ) {
|
21 |
+
add_filter( $oFO->prefix( 'login-intent-form-fields' ), [ $this, 'addLoginIntentField' ] );
|
22 |
+
add_action( $oFO->prefix( 'login-intent-validation' ), [ $this, 'validateLoginIntent' ] );
|
23 |
}
|
24 |
|
25 |
if ( $this->loadWp()->isRequestUserLogin() || $oFO->getIfSupport3rdParty() ) {
|
27 |
}
|
28 |
|
29 |
// Necessary so we don't show user intent to people without it
|
30 |
+
add_filter( $oFO->prefix( 'user_subject_to_login_intent' ), [ $this, 'filterUserSubjectToIntent' ], 10, 2 );
|
31 |
|
32 |
+
add_action( 'show_user_profile', [ $this, 'addOptionsToUserProfile' ] );
|
33 |
+
add_action( 'personal_options_update', [ $this, 'handleUserProfileSubmit' ] );
|
34 |
|
35 |
if ( $this->getCon()->isPluginAdmin() ) {
|
36 |
+
add_action( 'edit_user_profile', [ $this, 'addOptionsToUserEditProfile' ] );
|
37 |
+
add_action( 'edit_user_profile_update', [ $this, 'handleEditOtherUserProfileSubmit' ] );
|
38 |
}
|
39 |
}
|
40 |
|
88 |
}
|
89 |
|
90 |
/**
|
|
|
91 |
* @param WP_User $oUser
|
92 |
* @return bool
|
93 |
+
* @since 6.9.0 removed fallback to old user meta
|
94 |
*/
|
95 |
protected function hasValidatedProfile( $oUser ) {
|
96 |
$sKey = $this->getStub().'_validated';
|
@@ -74,14 +74,14 @@ class ICWP_WPSF_Processor_LoginProtect_TwoFactorAuth extends ICWP_WPSF_Processor
|
|
74 |
*/
|
75 |
public function addLoginIntentField( $aFields ) {
|
76 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
77 |
-
$aFields[] =
|
78 |
'name' => $this->getLoginFormParameter(),
|
79 |
'type' => 'text',
|
80 |
'value' => $this->fetchCodeFromRequest(),
|
81 |
'placeholder' => _wpsf__( 'This code was just sent to your registered Email address.' ),
|
82 |
'text' => _wpsf__( 'Email OTP' ),
|
83 |
'help_link' => 'https://icwp.io/3t'
|
84 |
-
|
85 |
}
|
86 |
return $aFields;
|
87 |
}
|
@@ -154,7 +154,7 @@ class ICWP_WPSF_Processor_LoginProtect_TwoFactorAuth extends ICWP_WPSF_Processor
|
|
154 |
protected function sendEmailTwoFactorVerify( WP_User $oUser ) {
|
155 |
$sIpAddress = $this->ip();
|
156 |
|
157 |
-
$aMessage =
|
158 |
_wpsf__( 'Someone attempted to login into this WordPress site using your account.' ),
|
159 |
_wpsf__( 'Login requires verification with the following code.' ),
|
160 |
'',
|
@@ -165,7 +165,7 @@ class ICWP_WPSF_Processor_LoginProtect_TwoFactorAuth extends ICWP_WPSF_Processor
|
|
165 |
sprintf( '%s: %s', _wpsf__( 'Username' ), $oUser->user_login ),
|
166 |
sprintf( '%s: %s', _wpsf__( 'IP Address' ), $sIpAddress ),
|
167 |
'',
|
168 |
-
|
169 |
|
170 |
if ( !$this->getCon()->isRelabelled() ) {
|
171 |
$aMessage[] = sprintf( '- <a href="%s" target="_blank">%s</a>', 'https://icwp.io/96', _wpsf__( 'Why no login link?' ) );
|
@@ -195,26 +195,26 @@ class ICWP_WPSF_Processor_LoginProtect_TwoFactorAuth extends ICWP_WPSF_Processor
|
|
195 |
public function addOptionsToUserProfile( $oUser ) {
|
196 |
$oWp = Services::WpUsers();
|
197 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
198 |
-
$aData =
|
199 |
'user_has_email_authentication_active' => $bValidatedProfile,
|
200 |
'user_has_email_authentication_enforced' => $this->isSubjectToEmailAuthentication( $oUser ),
|
201 |
'is_my_user_profile' => ( $oUser->ID == $oWp->getCurrentWpUserId() ),
|
202 |
'i_am_valid_admin' => $this->getCon()->isPluginAdmin(),
|
203 |
'user_to_edit_is_admin' => $oWp->isUserAdmin( $oUser ),
|
204 |
-
'strings' =>
|
205 |
'label_email_authentication' => _wpsf__( 'Email Authentication' ),
|
206 |
'title' => _wpsf__( 'Email Authentication' ),
|
207 |
'description_email_authentication_checkbox' => _wpsf__( 'Check the box to enable email-based login authentication.' ),
|
208 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $this->getCon()
|
209 |
->getHumanName() )
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
$aData[ 'bools' ] =
|
214 |
'checked' => $bValidatedProfile || $aData[ 'user_has_email_authentication_enforced' ],
|
215 |
'disabled' => true || $aData[ 'user_has_email_authentication_enforced' ]
|
216 |
//TODO: Make email authentication a per-user setting
|
217 |
-
|
218 |
|
219 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_emailauthentication.php', $aData );
|
220 |
}
|
74 |
*/
|
75 |
public function addLoginIntentField( $aFields ) {
|
76 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
77 |
+
$aFields[] = [
|
78 |
'name' => $this->getLoginFormParameter(),
|
79 |
'type' => 'text',
|
80 |
'value' => $this->fetchCodeFromRequest(),
|
81 |
'placeholder' => _wpsf__( 'This code was just sent to your registered Email address.' ),
|
82 |
'text' => _wpsf__( 'Email OTP' ),
|
83 |
'help_link' => 'https://icwp.io/3t'
|
84 |
+
];
|
85 |
}
|
86 |
return $aFields;
|
87 |
}
|
154 |
protected function sendEmailTwoFactorVerify( WP_User $oUser ) {
|
155 |
$sIpAddress = $this->ip();
|
156 |
|
157 |
+
$aMessage = [
|
158 |
_wpsf__( 'Someone attempted to login into this WordPress site using your account.' ),
|
159 |
_wpsf__( 'Login requires verification with the following code.' ),
|
160 |
'',
|
165 |
sprintf( '%s: %s', _wpsf__( 'Username' ), $oUser->user_login ),
|
166 |
sprintf( '%s: %s', _wpsf__( 'IP Address' ), $sIpAddress ),
|
167 |
'',
|
168 |
+
];
|
169 |
|
170 |
if ( !$this->getCon()->isRelabelled() ) {
|
171 |
$aMessage[] = sprintf( '- <a href="%s" target="_blank">%s</a>', 'https://icwp.io/96', _wpsf__( 'Why no login link?' ) );
|
195 |
public function addOptionsToUserProfile( $oUser ) {
|
196 |
$oWp = Services::WpUsers();
|
197 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
198 |
+
$aData = [
|
199 |
'user_has_email_authentication_active' => $bValidatedProfile,
|
200 |
'user_has_email_authentication_enforced' => $this->isSubjectToEmailAuthentication( $oUser ),
|
201 |
'is_my_user_profile' => ( $oUser->ID == $oWp->getCurrentWpUserId() ),
|
202 |
'i_am_valid_admin' => $this->getCon()->isPluginAdmin(),
|
203 |
'user_to_edit_is_admin' => $oWp->isUserAdmin( $oUser ),
|
204 |
+
'strings' => [
|
205 |
'label_email_authentication' => _wpsf__( 'Email Authentication' ),
|
206 |
'title' => _wpsf__( 'Email Authentication' ),
|
207 |
'description_email_authentication_checkbox' => _wpsf__( 'Check the box to enable email-based login authentication.' ),
|
208 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $this->getCon()
|
209 |
->getHumanName() )
|
210 |
+
]
|
211 |
+
];
|
212 |
|
213 |
+
$aData[ 'bools' ] = [
|
214 |
'checked' => $bValidatedProfile || $aData[ 'user_has_email_authentication_enforced' ],
|
215 |
'disabled' => true || $aData[ 'user_has_email_authentication_enforced' ]
|
216 |
//TODO: Make email authentication a per-user setting
|
217 |
+
];
|
218 |
|
219 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_emailauthentication.php', $aData );
|
220 |
}
|
@@ -9,7 +9,7 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
9 |
public function run() {
|
10 |
parent::run();
|
11 |
if ( Services::Request()->query( 'shield_action' ) == 'garemovalconfirm' ) {
|
12 |
-
add_action( 'wp_loaded',
|
13 |
}
|
14 |
}
|
15 |
|
@@ -23,13 +23,13 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
23 |
|
24 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
25 |
|
26 |
-
$aData =
|
27 |
'has_validated_profile' => $bValidatedProfile,
|
28 |
'user_google_authenticator_secret' => $this->getSecret( $oUser ),
|
29 |
'is_my_user_profile' => ( $oUser->ID == Services::WpUsers()->getCurrentWpUserId() ),
|
30 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
31 |
'user_to_edit_is_admin' => Services::WpUsers()->isUserAdmin( $oUser ),
|
32 |
-
'strings' =>
|
33 |
'description_otp_code' => _wpsf__( 'Provide the current code generated by your Google Authenticator app.' ),
|
34 |
'description_otp_code_ext' => _wpsf__( 'To reset this QR Code enter fake data here.' ),
|
35 |
'description_chart_url' => _wpsf__( 'Use your Google Authenticator app to scan this QR code and enter the one time password below.' ),
|
@@ -44,11 +44,11 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
44 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Google Authenticator' ) ),
|
45 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
46 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
47 |
-
|
48 |
-
'data' =>
|
49 |
'otp_field_name' => $this->getLoginFormParameter()
|
50 |
-
|
51 |
-
|
52 |
|
53 |
if ( !$bValidatedProfile ) {
|
54 |
$aData[ 'chart_url' ] = $this->getGaRegisterChartUrl( $oUser );
|
@@ -194,17 +194,17 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
194 |
*/
|
195 |
public function addLoginIntentField( $aFields ) {
|
196 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
197 |
-
$aFields[] =
|
198 |
'name' => $this->getLoginFormParameter(),
|
199 |
'type' => 'text',
|
200 |
'value' => '',
|
201 |
'placeholder' => _wpsf__( 'Please use your Google Authenticator App to retrieve your code.' ),
|
202 |
'text' => _wpsf__( 'Google Authenticator Code' ),
|
203 |
'help_link' => 'https://icwp.io/wpsf42',
|
204 |
-
'extras' =>
|
205 |
'onkeyup' => "this.value=this.value.replace(/[^\d]/g,'')"
|
206 |
-
|
207 |
-
|
208 |
}
|
209 |
return $aFields;
|
210 |
}
|
@@ -301,10 +301,10 @@ class ICWP_WPSF_Processor_LoginProtect_GoogleAuthenticator extends ICWP_WPSF_Pro
|
|
301 |
* @return string
|
302 |
*/
|
303 |
protected function generateGaRemovalConfirmationLink() {
|
304 |
-
$aQueryArgs =
|
305 |
'shield_action' => 'garemovalconfirm',
|
306 |
'sessionid' => $this->getCon()->getSessionId()
|
307 |
-
|
308 |
return add_query_arg( $aQueryArgs, Services::WpGeneral()->getAdminUrl() );
|
309 |
}
|
310 |
|
9 |
public function run() {
|
10 |
parent::run();
|
11 |
if ( Services::Request()->query( 'shield_action' ) == 'garemovalconfirm' ) {
|
12 |
+
add_action( 'wp_loaded', [ $this, 'validateUserGaRemovalLink' ], 10 );
|
13 |
}
|
14 |
}
|
15 |
|
23 |
|
24 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
25 |
|
26 |
+
$aData = [
|
27 |
'has_validated_profile' => $bValidatedProfile,
|
28 |
'user_google_authenticator_secret' => $this->getSecret( $oUser ),
|
29 |
'is_my_user_profile' => ( $oUser->ID == Services::WpUsers()->getCurrentWpUserId() ),
|
30 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
31 |
'user_to_edit_is_admin' => Services::WpUsers()->isUserAdmin( $oUser ),
|
32 |
+
'strings' => [
|
33 |
'description_otp_code' => _wpsf__( 'Provide the current code generated by your Google Authenticator app.' ),
|
34 |
'description_otp_code_ext' => _wpsf__( 'To reset this QR Code enter fake data here.' ),
|
35 |
'description_chart_url' => _wpsf__( 'Use your Google Authenticator app to scan this QR code and enter the one time password below.' ),
|
44 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Google Authenticator' ) ),
|
45 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
46 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
47 |
+
],
|
48 |
+
'data' => [
|
49 |
'otp_field_name' => $this->getLoginFormParameter()
|
50 |
+
]
|
51 |
+
];
|
52 |
|
53 |
if ( !$bValidatedProfile ) {
|
54 |
$aData[ 'chart_url' ] = $this->getGaRegisterChartUrl( $oUser );
|
194 |
*/
|
195 |
public function addLoginIntentField( $aFields ) {
|
196 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
197 |
+
$aFields[] = [
|
198 |
'name' => $this->getLoginFormParameter(),
|
199 |
'type' => 'text',
|
200 |
'value' => '',
|
201 |
'placeholder' => _wpsf__( 'Please use your Google Authenticator App to retrieve your code.' ),
|
202 |
'text' => _wpsf__( 'Google Authenticator Code' ),
|
203 |
'help_link' => 'https://icwp.io/wpsf42',
|
204 |
+
'extras' => [
|
205 |
'onkeyup' => "this.value=this.value.replace(/[^\d]/g,'')"
|
206 |
+
]
|
207 |
+
];
|
208 |
}
|
209 |
return $aFields;
|
210 |
}
|
301 |
* @return string
|
302 |
*/
|
303 |
protected function generateGaRemovalConfirmationLink() {
|
304 |
+
$aQueryArgs = [
|
305 |
'shield_action' => 'garemovalconfirm',
|
306 |
'sessionid' => $this->getCon()->getSessionId()
|
307 |
+
];
|
308 |
return add_query_arg( $aQueryArgs, Services::WpGeneral()->getAdminUrl() );
|
309 |
}
|
310 |
|
@@ -20,12 +20,12 @@ class ICWP_WPSF_Processor_LoginProtect_Yubikey extends ICWP_WPSF_Processor_Login
|
|
20 |
$oWpUsers = Services::WpUsers();
|
21 |
|
22 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
23 |
-
$aData =
|
24 |
'has_validated_profile' => $bValidatedProfile,
|
25 |
'is_my_user_profile' => ( $oUser->ID == $oWpUsers->getCurrentWpUserId() ),
|
26 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
27 |
'user_to_edit_is_admin' => $oWpUsers->isUserAdmin( $oUser ),
|
28 |
-
'strings' =>
|
29 |
'description_otp_code' => _wpsf__( 'This is your unique Yubikey Device ID.' ),
|
30 |
'description_otp_code_ext' => '['._wpsf__( 'Pro Only' ).'] '
|
31 |
._wpsf__( 'Multiple Yubikey Device IDs are separated by a comma.' ),
|
@@ -43,12 +43,12 @@ class ICWP_WPSF_Processor_LoginProtect_Yubikey extends ICWP_WPSF_Processor_Login
|
|
43 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Yubikey' ) ),
|
44 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
45 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
46 |
-
|
47 |
-
'data' =>
|
48 |
'otp_field_name' => $this->getLoginFormParameter(),
|
49 |
'secret' => str_replace( ',', ', ', $this->getSecret( $oUser ) ),
|
50 |
-
|
51 |
-
|
52 |
|
53 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_yubikey.php', $aData );
|
54 |
}
|
@@ -255,14 +255,14 @@ class ICWP_WPSF_Processor_LoginProtect_Yubikey extends ICWP_WPSF_Processor_Login
|
|
255 |
*/
|
256 |
public function addLoginIntentField( $aFields ) {
|
257 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
258 |
-
$aFields[] =
|
259 |
'name' => $this->getLoginFormParameter(),
|
260 |
'type' => 'text',
|
261 |
'placeholder' => _wpsf__( 'Use your Yubikey to generate a new code.' ),
|
262 |
'value' => '',
|
263 |
'text' => _wpsf__( 'Yubikey OTP' ),
|
264 |
'help_link' => 'https://icwp.io/4i'
|
265 |
-
|
266 |
}
|
267 |
return $aFields;
|
268 |
}
|
20 |
$oWpUsers = Services::WpUsers();
|
21 |
|
22 |
$bValidatedProfile = $this->hasValidatedProfile( $oUser );
|
23 |
+
$aData = [
|
24 |
'has_validated_profile' => $bValidatedProfile,
|
25 |
'is_my_user_profile' => ( $oUser->ID == $oWpUsers->getCurrentWpUserId() ),
|
26 |
'i_am_valid_admin' => $oCon->isPluginAdmin(),
|
27 |
'user_to_edit_is_admin' => $oWpUsers->isUserAdmin( $oUser ),
|
28 |
+
'strings' => [
|
29 |
'description_otp_code' => _wpsf__( 'This is your unique Yubikey Device ID.' ),
|
30 |
'description_otp_code_ext' => '['._wpsf__( 'Pro Only' ).'] '
|
31 |
._wpsf__( 'Multiple Yubikey Device IDs are separated by a comma.' ),
|
43 |
'cant_remove_admins' => sprintf( _wpsf__( "Sorry, %s may only be removed from another user's account by a Security Administrator." ), _wpsf__( 'Yubikey' ) ),
|
44 |
'provided_by' => sprintf( _wpsf__( 'Provided by %s' ), $oCon->getHumanName() ),
|
45 |
'remove_more_info' => sprintf( _wpsf__( 'Understand how to remove Google Authenticator' ) )
|
46 |
+
],
|
47 |
+
'data' => [
|
48 |
'otp_field_name' => $this->getLoginFormParameter(),
|
49 |
'secret' => str_replace( ',', ', ', $this->getSecret( $oUser ) ),
|
50 |
+
]
|
51 |
+
];
|
52 |
|
53 |
echo $this->getMod()->renderTemplate( 'snippets/user_profile_yubikey.php', $aData );
|
54 |
}
|
255 |
*/
|
256 |
public function addLoginIntentField( $aFields ) {
|
257 |
if ( $this->getCurrentUserHasValidatedProfile() ) {
|
258 |
+
$aFields[] = [
|
259 |
'name' => $this->getLoginFormParameter(),
|
260 |
'type' => 'text',
|
261 |
'placeholder' => _wpsf__( 'Use your Yubikey to generate a new code.' ),
|
262 |
'value' => '',
|
263 |
'text' => _wpsf__( 'Yubikey OTP' ),
|
264 |
'help_link' => 'https://icwp.io/4i'
|
265 |
+
];
|
266 |
}
|
267 |
return $aFields;
|
268 |
}
|
@@ -15,22 +15,22 @@ class ICWP_WPSF_Processor_LoginProtect_WpLogin extends ICWP_WPSF_Processor_BaseW
|
|
15 |
}
|
16 |
|
17 |
// Loads the wp-login.php if the correct URL is loaded
|
18 |
-
add_action( 'init',
|
19 |
|
20 |
// Loads the wp-login.php is the correct URL is loaded
|
21 |
-
add_filter( 'wp_loaded',
|
22 |
|
23 |
// Shouldn't be necessary, but in-case something else includes the wp-login.php, we block that too.
|
24 |
-
add_action( 'login_init',
|
25 |
|
26 |
// ensure that wp-login.php is never used in site urls or redirects
|
27 |
-
add_filter( 'site_url',
|
28 |
-
add_filter( 'network_site_url',
|
29 |
-
add_filter( 'wp_redirect',
|
30 |
-
add_filter( 'wp_redirect',
|
31 |
-
add_filter( 'register_url',
|
32 |
|
33 |
-
add_filter( 'et_anticipate_exceptions',
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -104,7 +104,7 @@ class ICWP_WPSF_Processor_LoginProtect_WpLogin extends ICWP_WPSF_Processor_BaseW
|
|
104 |
// Next block option is where it's a direct attempt to access the old login URL
|
105 |
if ( !$bDoBlock ) {
|
106 |
$sPath = trim( Services::Request()->getPath(), '/' );
|
107 |
-
$aPossiblePaths =
|
108 |
trim( home_url( 'wp-login.php', 'relative' ), '/' ),
|
109 |
trim( home_url( 'wp-signup.php', 'relative' ), '/' ),
|
110 |
trim( site_url( 'wp-signup.php', 'relative' ), '/' ),
|
@@ -112,7 +112,7 @@ class ICWP_WPSF_Processor_LoginProtect_WpLogin extends ICWP_WPSF_Processor_BaseW
|
|
112 |
trim( rtrim( site_url( '', 'relative' ), '/' ).'/wp-login.php', '/' ),
|
113 |
trim( home_url( 'login', 'relative' ), '/' ),
|
114 |
trim( site_url( 'login', 'relative' ), '/' )
|
115 |
-
|
116 |
$bDoBlock = !empty( $sPath )
|
117 |
&& ( in_array( $sPath, $aPossiblePaths ) || preg_match( '/wp-login\.php/i', $sPath ) );
|
118 |
}
|
15 |
}
|
16 |
|
17 |
// Loads the wp-login.php if the correct URL is loaded
|
18 |
+
add_action( 'init', [ $this, 'doBlockPossibleWpLoginLoad' ] );
|
19 |
|
20 |
// Loads the wp-login.php is the correct URL is loaded
|
21 |
+
add_filter( 'wp_loaded', [ $this, 'aLoadWpLogin' ] );
|
22 |
|
23 |
// Shouldn't be necessary, but in-case something else includes the wp-login.php, we block that too.
|
24 |
+
add_action( 'login_init', [ $this, 'aLoginFormAction' ], 0 );
|
25 |
|
26 |
// ensure that wp-login.php is never used in site urls or redirects
|
27 |
+
add_filter( 'site_url', [ $this, 'fCheckForLoginPhp' ], 20, 2 );
|
28 |
+
add_filter( 'network_site_url', [ $this, 'fCheckForLoginPhp' ], 20, 2 );
|
29 |
+
add_filter( 'wp_redirect', [ $this, 'fCheckForLoginPhp' ], 20, 2 );
|
30 |
+
add_filter( 'wp_redirect', [ $this, 'fProtectUnauthorizedLoginRedirect' ], 50, 2 );
|
31 |
+
add_filter( 'register_url', [ $this, 'blockRegisterUrlRedirect' ], 20, 1 );
|
32 |
|
33 |
+
add_filter( 'et_anticipate_exceptions', [ $this, 'fAddToEtMaintenanceExceptions' ] );
|
34 |
}
|
35 |
|
36 |
/**
|
104 |
// Next block option is where it's a direct attempt to access the old login URL
|
105 |
if ( !$bDoBlock ) {
|
106 |
$sPath = trim( Services::Request()->getPath(), '/' );
|
107 |
+
$aPossiblePaths = [
|
108 |
trim( home_url( 'wp-login.php', 'relative' ), '/' ),
|
109 |
trim( home_url( 'wp-signup.php', 'relative' ), '/' ),
|
110 |
trim( site_url( 'wp-signup.php', 'relative' ), '/' ),
|
112 |
trim( rtrim( site_url( '', 'relative' ), '/' ).'/wp-login.php', '/' ),
|
113 |
trim( home_url( 'login', 'relative' ), '/' ),
|
114 |
trim( site_url( 'login', 'relative' ), '/' )
|
115 |
+
];
|
116 |
$bDoBlock = !empty( $sPath )
|
117 |
&& ( in_array( $sPath, $aPossiblePaths ) || preg_match( '/wp-login\.php/i', $sPath ) );
|
118 |
}
|
@@ -27,9 +27,11 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
27 |
$this->getSubProImportExport()->run();
|
28 |
}
|
29 |
|
|
|
|
|
30 |
switch ( Services::Request()->query( 'shield_action', '' ) ) {
|
31 |
case 'dump_tracking_data':
|
32 |
-
add_action( 'wp_loaded',
|
33 |
break;
|
34 |
|
35 |
case 'importexport_export':
|
@@ -44,7 +46,7 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
44 |
break;
|
45 |
}
|
46 |
|
47 |
-
add_action( 'admin_footer',
|
48 |
}
|
49 |
|
50 |
public function onWpLoaded() {
|
@@ -54,42 +56,49 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
* @return ICWP_WPSF_Processor_Plugin_Badge
|
58 |
*/
|
59 |
protected function getSubProBadge() {
|
60 |
return $this->getSubPro( 'badge' );
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
-
* @return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
*/
|
66 |
protected function getSubProCronDaily() {
|
67 |
return $this->getSubPro( 'crondaily' );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* @return ICWP_WPSF_Processor_Plugin_CronHourly
|
72 |
*/
|
73 |
protected function getSubProCronHourly() {
|
74 |
return $this->getSubPro( 'cronhourly' );
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
* @return ICWP_WPSF_Processor_Plugin_Tracking
|
79 |
*/
|
80 |
protected function getSubProTracking() {
|
81 |
return $this->getSubPro( 'tracking' );
|
82 |
}
|
83 |
|
84 |
/**
|
85 |
-
* @return ICWP_WPSF_Processor_Plugin_ImportExport
|
86 |
*/
|
87 |
public function getSubProImportExport() {
|
88 |
return $this->getSubPro( 'importexport' );
|
89 |
}
|
90 |
|
91 |
/**
|
92 |
-
* @return ICWP_WPSF_Processor_Plugin_Notes
|
93 |
*/
|
94 |
public function getSubProcessorNotes() {
|
95 |
return $this->getSubPro( 'notes' );
|
@@ -101,6 +110,7 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
101 |
protected function getSubProMap() {
|
102 |
return [
|
103 |
'badge' => 'ICWP_WPSF_Processor_Plugin_Badge',
|
|
|
104 |
'importexport' => 'ICWP_WPSF_Processor_Plugin_ImportExport',
|
105 |
'notes' => 'ICWP_WPSF_Processor_Plugin_Notes',
|
106 |
'tracking' => 'ICWP_WPSF_Processor_Plugin_Tracking',
|
@@ -119,12 +129,12 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
119 |
*/
|
120 |
private function printToastTemplate() {
|
121 |
if ( $this->getCon()->isModulePage() ) {
|
122 |
-
$aRenderData =
|
123 |
-
'strings' =>
|
124 |
'title' => $this->getCon()->getHumanName(),
|
125 |
-
|
126 |
'js_snippets' => []
|
127 |
-
|
128 |
echo $this->getMod()
|
129 |
->renderTemplate( 'snippets/toaster.twig', $aRenderData, true );
|
130 |
}
|
@@ -133,7 +143,7 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
133 |
private function printPluginDeactivateSurvey() {
|
134 |
if ( Services::WpPost()->isCurrentPage( 'plugins.php' ) ) {
|
135 |
|
136 |
-
$aOpts =
|
137 |
'reason_confusing' => "It's too confusing",
|
138 |
'reason_expected' => "It's not what I expected",
|
139 |
'reason_accident' => "I downloaded it accidentally",
|
@@ -141,17 +151,17 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
141 |
'reason_trust' => "I don't trust the developer :(",
|
142 |
'reason_not_work' => "It doesn't work",
|
143 |
'reason_errors' => "I'm getting errors",
|
144 |
-
|
145 |
|
146 |
-
$aRenderData =
|
147 |
-
'strings' =>
|
148 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
149 |
-
|
150 |
-
'inputs' =>
|
151 |
'checkboxes' => $this->loadDP()->shuffleArray( $aOpts )
|
152 |
-
|
153 |
'js_snippets' => []
|
154 |
-
|
155 |
echo $this->getMod()
|
156 |
->renderTemplate( 'snippets/plugin-deactivate-survey.php', $aRenderData );
|
157 |
}
|
@@ -186,8 +196,8 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
-
* @see autoAddToAdminNotices()
|
190 |
* @param array $aNoticeAttributes
|
|
|
191 |
*/
|
192 |
protected function addNotice_override_forceoff( $aNoticeAttributes ) {
|
193 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
@@ -195,9 +205,9 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
195 |
|
196 |
$oCon = $this->getCon();
|
197 |
if ( $oCon->getIfForceOffActive() ) {
|
198 |
-
$aRenderData =
|
199 |
'notice_attributes' => $aNoticeAttributes,
|
200 |
-
'strings' =>
|
201 |
'title' => sprintf( '%s: %s', _wpsf__( 'Warning' ), sprintf( _wpsf__( '%s is not protecting your site' ), $oCon->getHumanName() ) ),
|
202 |
'message' => sprintf(
|
203 |
_wpsf__( 'Please delete the "%s" file to reactivate %s protection' ),
|
@@ -205,18 +215,18 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
205 |
$oCon->getHumanName()
|
206 |
),
|
207 |
'delete' => _wpsf__( 'Click here to automatically delete the file' )
|
208 |
-
|
209 |
-
'ajax' =>
|
210 |
'delete_forceoff' => $oFO->getAjaxActionData( 'delete_forceoff', true )
|
211 |
-
|
212 |
-
|
213 |
$this->insertAdminNotice( $aRenderData );
|
214 |
}
|
215 |
}
|
216 |
|
217 |
/**
|
218 |
-
* @see autoAddToAdminNotices()
|
219 |
* @param array $aNoticeAttributes
|
|
|
220 |
*/
|
221 |
protected function addNotice_plugin_mailing_list_signup( $aNoticeAttributes ) {
|
222 |
$oModCon = $this->getMod();
|
@@ -224,9 +234,9 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
224 |
$nDays = $this->getInstallationDays();
|
225 |
if ( $this->getIfShowAdminNotices() && $nDays >= 5 ) {
|
226 |
$oUser = Services::WpUsers()->getCurrentWpUser();
|
227 |
-
$aRenderData =
|
228 |
'notice_attributes' => $aNoticeAttributes,
|
229 |
-
'strings' =>
|
230 |
'title' => 'Come and Join Us!',
|
231 |
'yes' => "Yes please! I'd love to join in and learn more",
|
232 |
'no' => "No thanks, I'm not interested in such groups",
|
@@ -239,16 +249,16 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
239 |
'I certify that I have read and agree to the <a href="%s" target="_blank">Privacy Policy</a>',
|
240 |
$this->getMod()->getDef( 'href_privacy_policy' )
|
241 |
),
|
242 |
-
|
243 |
-
'hrefs' =>
|
244 |
'privacy_policy' => $oModCon->getDef( 'href_privacy_policy' )
|
245 |
-
|
246 |
'install_days' => $nDays,
|
247 |
'vars' => [
|
248 |
'name' => $oUser->first_name,
|
249 |
'user_email' => $oUser->user_email
|
250 |
]
|
251 |
-
|
252 |
$this->insertAdminNotice( $aRenderData );
|
253 |
}
|
254 |
}
|
@@ -258,7 +268,7 @@ class ICWP_WPSF_Processor_Plugin extends ICWP_WPSF_Processor_BasePlugin {
|
|
258 |
*/
|
259 |
protected function removePluginConflicts() {
|
260 |
if ( class_exists( 'AIO_WP_Security' ) && isset( $GLOBALS[ 'aio_wp_security' ] ) ) {
|
261 |
-
remove_action( 'init',
|
262 |
}
|
263 |
}
|
264 |
}
|
27 |
$this->getSubProImportExport()->run();
|
28 |
}
|
29 |
|
30 |
+
$this->getSubProGeoip()->run();
|
31 |
+
|
32 |
switch ( Services::Request()->query( 'shield_action', '' ) ) {
|
33 |
case 'dump_tracking_data':
|
34 |
+
add_action( 'wp_loaded', [ $this, 'dumpTrackingData' ] );
|
35 |
break;
|
36 |
|
37 |
case 'importexport_export':
|
46 |
break;
|
47 |
}
|
48 |
|
49 |
+
add_action( 'admin_footer', [ $this, 'printAdminFooterItems' ], 100, 0 );
|
50 |
}
|
51 |
|
52 |
public function onWpLoaded() {
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* @return ICWP_WPSF_Processor_Plugin_Badge
|
60 |
*/
|
61 |
protected function getSubProBadge() {
|
62 |
return $this->getSubPro( 'badge' );
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
+
* @return ICWP_WPSF_Processor_Plugin_Geoip
|
67 |
+
*/
|
68 |
+
public function getSubProGeoip() {
|
69 |
+
return $this->getSubPro( 'geoip' );
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return ICWP_WPSF_Processor_Plugin_CronDaily
|
74 |
*/
|
75 |
protected function getSubProCronDaily() {
|
76 |
return $this->getSubPro( 'crondaily' );
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
+
* @return ICWP_WPSF_Processor_Plugin_CronHourly
|
81 |
*/
|
82 |
protected function getSubProCronHourly() {
|
83 |
return $this->getSubPro( 'cronhourly' );
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
+
* @return ICWP_WPSF_Processor_Plugin_Tracking
|
88 |
*/
|
89 |
protected function getSubProTracking() {
|
90 |
return $this->getSubPro( 'tracking' );
|
91 |
}
|
92 |
|
93 |
/**
|
94 |
+
* @return ICWP_WPSF_Processor_Plugin_ImportExport
|
95 |
*/
|
96 |
public function getSubProImportExport() {
|
97 |
return $this->getSubPro( 'importexport' );
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* @return ICWP_WPSF_Processor_Plugin_Notes
|
102 |
*/
|
103 |
public function getSubProcessorNotes() {
|
104 |
return $this->getSubPro( 'notes' );
|
110 |
protected function getSubProMap() {
|
111 |
return [
|
112 |
'badge' => 'ICWP_WPSF_Processor_Plugin_Badge',
|
113 |
+
'geoip' => 'ICWP_WPSF_Processor_Plugin_Geoip',
|
114 |
'importexport' => 'ICWP_WPSF_Processor_Plugin_ImportExport',
|
115 |
'notes' => 'ICWP_WPSF_Processor_Plugin_Notes',
|
116 |
'tracking' => 'ICWP_WPSF_Processor_Plugin_Tracking',
|
129 |
*/
|
130 |
private function printToastTemplate() {
|
131 |
if ( $this->getCon()->isModulePage() ) {
|
132 |
+
$aRenderData = [
|
133 |
+
'strings' => [
|
134 |
'title' => $this->getCon()->getHumanName(),
|
135 |
+
],
|
136 |
'js_snippets' => []
|
137 |
+
];
|
138 |
echo $this->getMod()
|
139 |
->renderTemplate( 'snippets/toaster.twig', $aRenderData, true );
|
140 |
}
|
143 |
private function printPluginDeactivateSurvey() {
|
144 |
if ( Services::WpPost()->isCurrentPage( 'plugins.php' ) ) {
|
145 |
|
146 |
+
$aOpts = [
|
147 |
'reason_confusing' => "It's too confusing",
|
148 |
'reason_expected' => "It's not what I expected",
|
149 |
'reason_accident' => "I downloaded it accidentally",
|
151 |
'reason_trust' => "I don't trust the developer :(",
|
152 |
'reason_not_work' => "It doesn't work",
|
153 |
'reason_errors' => "I'm getting errors",
|
154 |
+
];
|
155 |
|
156 |
+
$aRenderData = [
|
157 |
+
'strings' => [
|
158 |
'editing_restricted' => _wpsf__( 'Editing this option is currently restricted.' ),
|
159 |
+
],
|
160 |
+
'inputs' => [
|
161 |
'checkboxes' => $this->loadDP()->shuffleArray( $aOpts )
|
162 |
+
],
|
163 |
'js_snippets' => []
|
164 |
+
];
|
165 |
echo $this->getMod()
|
166 |
->renderTemplate( 'snippets/plugin-deactivate-survey.php', $aRenderData );
|
167 |
}
|
196 |
}
|
197 |
|
198 |
/**
|
|
|
199 |
* @param array $aNoticeAttributes
|
200 |
+
* @see autoAddToAdminNotices()
|
201 |
*/
|
202 |
protected function addNotice_override_forceoff( $aNoticeAttributes ) {
|
203 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
205 |
|
206 |
$oCon = $this->getCon();
|
207 |
if ( $oCon->getIfForceOffActive() ) {
|
208 |
+
$aRenderData = [
|
209 |
'notice_attributes' => $aNoticeAttributes,
|
210 |
+
'strings' => [
|
211 |
'title' => sprintf( '%s: %s', _wpsf__( 'Warning' ), sprintf( _wpsf__( '%s is not protecting your site' ), $oCon->getHumanName() ) ),
|
212 |
'message' => sprintf(
|
213 |
_wpsf__( 'Please delete the "%s" file to reactivate %s protection' ),
|
215 |
$oCon->getHumanName()
|
216 |
),
|
217 |
'delete' => _wpsf__( 'Click here to automatically delete the file' )
|
218 |
+
],
|
219 |
+
'ajax' => [
|
220 |
'delete_forceoff' => $oFO->getAjaxActionData( 'delete_forceoff', true )
|
221 |
+
]
|
222 |
+
];
|
223 |
$this->insertAdminNotice( $aRenderData );
|
224 |
}
|
225 |
}
|
226 |
|
227 |
/**
|
|
|
228 |
* @param array $aNoticeAttributes
|
229 |
+
* @see autoAddToAdminNotices()
|
230 |
*/
|
231 |
protected function addNotice_plugin_mailing_list_signup( $aNoticeAttributes ) {
|
232 |
$oModCon = $this->getMod();
|
234 |
$nDays = $this->getInstallationDays();
|
235 |
if ( $this->getIfShowAdminNotices() && $nDays >= 5 ) {
|
236 |
$oUser = Services::WpUsers()->getCurrentWpUser();
|
237 |
+
$aRenderData = [
|
238 |
'notice_attributes' => $aNoticeAttributes,
|
239 |
+
'strings' => [
|
240 |
'title' => 'Come and Join Us!',
|
241 |
'yes' => "Yes please! I'd love to join in and learn more",
|
242 |
'no' => "No thanks, I'm not interested in such groups",
|
249 |
'I certify that I have read and agree to the <a href="%s" target="_blank">Privacy Policy</a>',
|
250 |
$this->getMod()->getDef( 'href_privacy_policy' )
|
251 |
),
|
252 |
+
],
|
253 |
+
'hrefs' => [
|
254 |
'privacy_policy' => $oModCon->getDef( 'href_privacy_policy' )
|
255 |
+
],
|
256 |
'install_days' => $nDays,
|
257 |
'vars' => [
|
258 |
'name' => $oUser->first_name,
|
259 |
'user_email' => $oUser->user_email
|
260 |
]
|
261 |
+
];
|
262 |
$this->insertAdminNotice( $aRenderData );
|
263 |
}
|
264 |
}
|
268 |
*/
|
269 |
protected function removePluginConflicts() {
|
270 |
if ( class_exists( 'AIO_WP_Security' ) && isset( $GLOBALS[ 'aio_wp_security' ] ) ) {
|
271 |
+
remove_action( 'init', [ $GLOBALS[ 'aio_wp_security' ], 'wp_security_plugin_init' ], 0 );
|
272 |
}
|
273 |
}
|
274 |
}
|
@@ -10,13 +10,13 @@ class ICWP_WPSF_Processor_Plugin_Badge extends ICWP_WPSF_Processor_BaseWpsf {
|
|
10 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
11 |
$oFO = $this->getMod();
|
12 |
if ( $oFO->isDisplayPluginBadge() ) {
|
13 |
-
add_action( 'wp_enqueue_scripts',
|
14 |
-
add_action( 'login_enqueue_scripts',
|
15 |
-
add_action( 'wp_footer',
|
16 |
-
add_action( 'login_footer',
|
17 |
}
|
18 |
-
add_action( 'widgets_init',
|
19 |
-
add_filter( $oFO->prefix( 'dashboard_widget_content' ),
|
20 |
}
|
21 |
|
22 |
public function includeJquery() {
|
@@ -37,11 +37,11 @@ class ICWP_WPSF_Processor_Plugin_Badge extends ICWP_WPSF_Processor_BaseWpsf {
|
|
37 |
sprintf( '<a href="%s">%s</a>', $aLabels[ 'AuthorURI' ], $aLabels[ 'Author' ] )
|
38 |
);
|
39 |
|
40 |
-
$aDisplayData =
|
41 |
'sInstallationDays' => sprintf( _wpsf__( 'Days Installed: %s' ), $this->getInstallationDays() ),
|
42 |
'sFooter' => $sFooter,
|
43 |
'sIpAddress' => sprintf( _wpsf__( 'Your IP address is: %s' ), $this->ip() )
|
44 |
-
|
45 |
|
46 |
if ( !is_array( $aContent ) ) {
|
47 |
$aContent = [];
|
10 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
11 |
$oFO = $this->getMod();
|
12 |
if ( $oFO->isDisplayPluginBadge() ) {
|
13 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'includeJquery' ] );
|
14 |
+
add_action( 'login_enqueue_scripts', [ $this, 'includeJquery' ] );
|
15 |
+
add_action( 'wp_footer', [ $this, 'printPluginBadge' ], 100 );
|
16 |
+
add_action( 'login_footer', [ $this, 'printPluginBadge' ], 100 );
|
17 |
}
|
18 |
+
add_action( 'widgets_init', [ $this, 'addPluginBadgeWidget' ] );
|
19 |
+
add_filter( $oFO->prefix( 'dashboard_widget_content' ), [ $this, 'gatherPluginWidgetContent' ], 100 );
|
20 |
}
|
21 |
|
22 |
public function includeJquery() {
|
37 |
sprintf( '<a href="%s">%s</a>', $aLabels[ 'AuthorURI' ], $aLabels[ 'Author' ] )
|
38 |
);
|
39 |
|
40 |
+
$aDisplayData = [
|
41 |
'sInstallationDays' => sprintf( _wpsf__( 'Days Installed: %s' ), $this->getInstallationDays() ),
|
42 |
'sFooter' => $sFooter,
|
43 |
'sIpAddress' => sprintf( _wpsf__( 'Your IP address is: %s' ), $this->ip() )
|
44 |
+
];
|
45 |
|
46 |
if ( !is_array( $aContent ) ) {
|
47 |
$aContent = [];
|
@@ -23,13 +23,13 @@ class ICWP_WPSF_Processor_Plugin_BadgeWidget extends ICWP_WPSF_WpWidget {
|
|
23 |
parent::__construct(
|
24 |
$oMod->prefixOptionKey( 'plugin_badge' ),
|
25 |
sprintf( _wpsf__( '%s Plugin Badge' ), $this->getCon()->getHumanName() ),
|
26 |
-
|
27 |
'description' => sprintf( _wpsf__( 'You can now help spread the word about the %s plugin anywhere on your site' ), $this->getCon()
|
28 |
->getHumanName() ),
|
29 |
-
|
30 |
);
|
31 |
|
32 |
-
add_shortcode( 'SHIELD_BADGE',
|
33 |
}
|
34 |
|
35 |
/**
|
@@ -60,14 +60,14 @@ class ICWP_WPSF_Processor_Plugin_BadgeWidget extends ICWP_WPSF_WpWidget {
|
|
60 |
*/
|
61 |
public function renderBadge() {
|
62 |
$oCon = $this->getCon();
|
63 |
-
$aData =
|
64 |
-
'strings' =>
|
65 |
'plugin_name' => $oCon->getHumanName(),
|
66 |
-
|
67 |
-
'hrefs' =>
|
68 |
'img_src' => $oCon->getPluginUrl_Image( 'pluginlogo_32x32.png' )
|
69 |
-
|
70 |
-
|
71 |
|
72 |
return $this->getMod()
|
73 |
->loadRenderer( $oCon->getPath_Templates().'php' )
|
23 |
parent::__construct(
|
24 |
$oMod->prefixOptionKey( 'plugin_badge' ),
|
25 |
sprintf( _wpsf__( '%s Plugin Badge' ), $this->getCon()->getHumanName() ),
|
26 |
+
[
|
27 |
'description' => sprintf( _wpsf__( 'You can now help spread the word about the %s plugin anywhere on your site' ), $this->getCon()
|
28 |
->getHumanName() ),
|
29 |
+
]
|
30 |
);
|
31 |
|
32 |
+
add_shortcode( 'SHIELD_BADGE', [ $this, 'renderBadge' ] );
|
33 |
}
|
34 |
|
35 |
/**
|
60 |
*/
|
61 |
public function renderBadge() {
|
62 |
$oCon = $this->getCon();
|
63 |
+
$aData = [
|
64 |
+
'strings' => [
|
65 |
'plugin_name' => $oCon->getHumanName(),
|
66 |
+
],
|
67 |
+
'hrefs' => [
|
68 |
'img_src' => $oCon->getPluginUrl_Image( 'pluginlogo_32x32.png' )
|
69 |
+
]
|
70 |
+
];
|
71 |
|
72 |
return $this->getMod()
|
73 |
->loadRenderer( $oCon->getPath_Templates().'php' )
|
@@ -8,6 +8,7 @@ class ICWP_WPSF_Processor_Plugin_CronHourly extends ICWP_WPSF_Processor_BaseWpsf
|
|
8 |
parent::run();
|
9 |
$this->setupCron();
|
10 |
}
|
|
|
11 |
/**
|
12 |
* @return string
|
13 |
*/
|
8 |
parent::run();
|
9 |
$this->setupCron();
|
10 |
}
|
11 |
+
|
12 |
/**
|
13 |
* @return string
|
14 |
*/
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Databases\GeoIp;
|
4 |
+
|
5 |
+
class ICWP_WPSF_Processor_Plugin_Geoip extends ICWP_WPSF_BaseDbProcessor {
|
6 |
+
|
7 |
+
const DAYS_TO_KEEP = 30;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param ICWP_WPSF_FeatureHandler_Plugin $oModCon
|
11 |
+
*/
|
12 |
+
public function __construct( ICWP_WPSF_FeatureHandler_Plugin $oModCon ) {
|
13 |
+
parent::__construct( $oModCon, $oModCon->getDef( 'geoip_table_name' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
public function run() {
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function getCreateTableSql() {
|
23 |
+
return "CREATE TABLE %s (
|
24 |
+
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
25 |
+
ip varbinary(16) DEFAULT NULL COMMENT 'IP Address',
|
26 |
+
meta TEXT,
|
27 |
+
created_at int(15) UNSIGNED NOT NULL DEFAULT 0,
|
28 |
+
deleted_at int(15) UNSIGNED NOT NULL DEFAULT 0,
|
29 |
+
PRIMARY KEY (id)
|
30 |
+
) %s;";
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
protected function getTableColumnsByDefinition() {
|
37 |
+
$aDef = $this->getMod()->getDef( 'geoip_table_columns' );
|
38 |
+
return is_array( $aDef ) ? $aDef : [];
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return GeoIp\Handler
|
43 |
+
*/
|
44 |
+
protected function createDbHandler() {
|
45 |
+
return new GeoIp\Handler();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return int
|
50 |
+
*/
|
51 |
+
protected function getAutoExpirePeriod() {
|
52 |
+
return DAY_IN_SECONDS*self::DAYS_TO_KEEP;
|
53 |
+
}
|
54 |
+
}
|
@@ -9,11 +9,11 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
9 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
10 |
$oFO = $this->getMod();
|
11 |
|
12 |
-
add_action( $this->prefix( 'importexport_notify' ),
|
13 |
|
14 |
if ( $oFO->hasImportExportMasterImportUrl() ) {
|
15 |
// For auto update whitelist notifications:
|
16 |
-
add_action( $oFO->prefix( 'importexport_updatenotified' ),
|
17 |
}
|
18 |
}
|
19 |
|
@@ -24,19 +24,19 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
24 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oMod */
|
25 |
$oMod = $this->getMod();
|
26 |
$aData = [
|
27 |
-
'vars' =>
|
28 |
'form_nonce' => $oMod->getNonceActionData( 'import_file_upload' ),
|
29 |
'form_action' => $oMod->getUrl_AdminPage()
|
30 |
-
|
31 |
-
'ajax' =>
|
32 |
'import_from_site' => $oMod->getAjaxActionData( 'import_from_site', true ),
|
33 |
-
|
34 |
-
'flags' =>
|
35 |
'can_importexport' => $this->getCon()->isPremiumActive(),
|
36 |
-
|
37 |
-
'hrefs' =>
|
38 |
'export_file_download' => $this->createExportFileDownloadLink()
|
39 |
-
|
40 |
];
|
41 |
|
42 |
return $aData;
|
@@ -61,10 +61,10 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
61 |
foreach ( $oFO->getImportExportWhitelist() as $sUrl ) {
|
62 |
$this->loadFS()->getUrl(
|
63 |
$sUrl,
|
64 |
-
|
65 |
'blocking' => false,
|
66 |
-
'body' =>
|
67 |
-
|
68 |
);
|
69 |
}
|
70 |
|
@@ -265,7 +265,7 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
265 |
$oFO = $this->getMod();
|
266 |
if ( $oFO->isPremium() && $oFO->isImportExportPermitted() &&
|
267 |
( Services::Request()->ts() < $oFO->getImportExportHandshakeExpiresAt() ) ) {
|
268 |
-
echo json_encode(
|
269 |
die();
|
270 |
}
|
271 |
else {
|
@@ -373,12 +373,12 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
373 |
}
|
374 |
}
|
375 |
|
376 |
-
$aResponse =
|
377 |
'success' => $bSuccess,
|
378 |
'code' => $nCode,
|
379 |
'message' => $sMessage,
|
380 |
'data' => $aData,
|
381 |
-
|
382 |
echo json_encode( $aResponse );
|
383 |
die();
|
384 |
}
|
@@ -401,7 +401,7 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
401 |
$bVerified = false;
|
402 |
|
403 |
if ( !empty( $sUrl ) ) {
|
404 |
-
$sReqUrl = add_query_arg(
|
405 |
$aResp = @json_decode( Services::HttpRequest()->getContent( $sReqUrl ), true );
|
406 |
$bVerified = is_array( $aResp ) && isset( $aResp[ 'success' ] ) && ( $aResp[ 'success' ] === true );
|
407 |
}
|
@@ -449,7 +449,7 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
449 |
}
|
450 |
else {
|
451 |
$bReady = true;
|
452 |
-
$aEssential =
|
453 |
foreach ( $aEssential as $sKey ) {
|
454 |
$bReady = $bReady && !empty( $aParts[ $sKey ] );
|
455 |
}
|
@@ -462,11 +462,11 @@ class ICWP_WPSF_Processor_Plugin_ImportExport extends ICWP_WPSF_Processor_BaseWp
|
|
462 |
else {
|
463 |
$oFO->startImportExportHandshake();
|
464 |
|
465 |
-
$aData =
|
466 |
'shield_action' => 'importexport_export',
|
467 |
'secret' => $sSecretKey,
|
468 |
'url' => Services::WpGeneral()->getHomeUrl()
|
469 |
-
|
470 |
// Don't send the network setup request if it's the cron.
|
471 |
if ( !is_null( $bEnableNetwork ) && !Services::WpGeneral()->isCron() ) {
|
472 |
$aData[ 'network' ] = $bEnableNetwork ? 'Y' : 'N';
|
9 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
10 |
$oFO = $this->getMod();
|
11 |
|
12 |
+
add_action( $this->prefix( 'importexport_notify' ), [ $this, 'runWhitelistNotify' ] );
|
13 |
|
14 |
if ( $oFO->hasImportExportMasterImportUrl() ) {
|
15 |
// For auto update whitelist notifications:
|
16 |
+
add_action( $oFO->prefix( 'importexport_updatenotified' ), [ $this, 'runImport' ] );
|
17 |
}
|
18 |
}
|
19 |
|
24 |
/** @var ICWP_WPSF_FeatureHandler_HackProtect $oMod */
|
25 |
$oMod = $this->getMod();
|
26 |
$aData = [
|
27 |
+
'vars' => [
|
28 |
'form_nonce' => $oMod->getNonceActionData( 'import_file_upload' ),
|
29 |
'form_action' => $oMod->getUrl_AdminPage()
|
30 |
+
],
|
31 |
+
'ajax' => [
|
32 |
'import_from_site' => $oMod->getAjaxActionData( 'import_from_site', true ),
|
33 |
+
],
|
34 |
+
'flags' => [
|
35 |
'can_importexport' => $this->getCon()->isPremiumActive(),
|
36 |
+
],
|
37 |
+
'hrefs' => [
|
38 |
'export_file_download' => $this->createExportFileDownloadLink()
|
39 |
+
]
|
40 |
];
|
41 |
|
42 |
return $aData;
|
61 |
foreach ( $oFO->getImportExportWhitelist() as $sUrl ) {
|
62 |
$this->loadFS()->getUrl(
|
63 |
$sUrl,
|
64 |
+
[
|
65 |
'blocking' => false,
|
66 |
+
'body' => [ 'shield_action' => 'importexport_updatenotified' ]
|
67 |
+
]
|
68 |
);
|
69 |
}
|
70 |
|
265 |
$oFO = $this->getMod();
|
266 |
if ( $oFO->isPremium() && $oFO->isImportExportPermitted() &&
|
267 |
( Services::Request()->ts() < $oFO->getImportExportHandshakeExpiresAt() ) ) {
|
268 |
+
echo json_encode( [ 'success' => true ] );
|
269 |
die();
|
270 |
}
|
271 |
else {
|
373 |
}
|
374 |
}
|
375 |
|
376 |
+
$aResponse = [
|
377 |
'success' => $bSuccess,
|
378 |
'code' => $nCode,
|
379 |
'message' => $sMessage,
|
380 |
'data' => $aData,
|
381 |
+
];
|
382 |
echo json_encode( $aResponse );
|
383 |
die();
|
384 |
}
|
401 |
$bVerified = false;
|
402 |
|
403 |
if ( !empty( $sUrl ) ) {
|
404 |
+
$sReqUrl = add_query_arg( [ 'shield_action' => 'importexport_handshake' ], $sUrl );
|
405 |
$aResp = @json_decode( Services::HttpRequest()->getContent( $sReqUrl ), true );
|
406 |
$bVerified = is_array( $aResp ) && isset( $aResp[ 'success' ] ) && ( $aResp[ 'success' ] === true );
|
407 |
}
|
449 |
}
|
450 |
else {
|
451 |
$bReady = true;
|
452 |
+
$aEssential = [ 'scheme', 'host' ];
|
453 |
foreach ( $aEssential as $sKey ) {
|
454 |
$bReady = $bReady && !empty( $aParts[ $sKey ] );
|
455 |
}
|
462 |
else {
|
463 |
$oFO->startImportExportHandshake();
|
464 |
|
465 |
+
$aData = [
|
466 |
'shield_action' => 'importexport_export',
|
467 |
'secret' => $sSecretKey,
|
468 |
'url' => Services::WpGeneral()->getHomeUrl()
|
469 |
+
];
|
470 |
// Don't send the network setup request if it's the cron.
|
471 |
if ( !is_null( $bEnableNetwork ) && !Services::WpGeneral()->isCron() ) {
|
472 |
$aData[ 'network' ] = $bEnableNetwork ? 'Y' : 'N';
|
@@ -31,7 +31,7 @@ class ICWP_WPSF_Processor_Plugin_Notes extends ICWP_WPSF_BaseDbProcessor {
|
|
31 |
*/
|
32 |
protected function getTableColumnsByDefinition() {
|
33 |
$aDef = $this->getMod()->getDef( 'db_notes_table_columns' );
|
34 |
-
return
|
35 |
}
|
36 |
|
37 |
/**
|
31 |
*/
|
32 |
protected function getTableColumnsByDefinition() {
|
33 |
$aDef = $this->getMod()->getDef( 'db_notes_table_columns' );
|
34 |
+
return is_array( $aDef ) ? $aDef : [];
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -6,17 +6,17 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
6 |
class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin {
|
7 |
|
8 |
/**
|
9 |
-
* @see autoAddToAdminNotices()
|
10 |
* @param array $aNoticeAttributes
|
|
|
11 |
*/
|
12 |
protected function addNotice_allow_tracking( $aNoticeAttributes ) {
|
13 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
14 |
$oFO = $this->getMod();
|
15 |
if ( $this->getIfShowAdminNotices() && !$oFO->isTrackingPermissionSet() ) {
|
16 |
$oCon = $this->getCon();
|
17 |
-
$aRenderData =
|
18 |
'notice_attributes' => $aNoticeAttributes,
|
19 |
-
'strings' =>
|
20 |
'title' => sprintf( _wpsf__( "Make %s even better by sharing usage info?" ), $oCon->getHumanName() ),
|
21 |
'want_to_track' => sprintf( _wpsf__( "We're hoping to understand how %s is configured and used." ), $oCon->getHumanName() ),
|
22 |
'what_we_collect' => _wpsf__( "We'd like to understand how effective it is on a global scale." ),
|
@@ -26,17 +26,17 @@ class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin
|
|
26 |
'learn_more' => _wpsf__( 'Learn More.' ),
|
27 |
'site_url' => 'translate.icontrolwp.com',
|
28 |
'yes' => _wpsf__( 'Absolutely' )
|
29 |
-
|
30 |
-
'ajax' =>
|
31 |
'set_plugin_tracking_perm' => $oFO->getAjaxActionData( 'set_plugin_tracking_perm', true ),
|
32 |
-
|
33 |
-
'hrefs' =>
|
34 |
'learn_more' => 'http://translate.icontrolwp.com',
|
35 |
'link_to_see' => $oFO->getLinkToTrackingDataDump(),
|
36 |
'link_to_moreinfo' => 'https://icwp.io/shieldtrackinginfo',
|
37 |
|
38 |
-
|
39 |
-
|
40 |
$this->insertAdminNotice( $aRenderData );
|
41 |
}
|
42 |
}
|
@@ -88,9 +88,9 @@ class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin
|
|
88 |
protected function getBaseTrackingData() {
|
89 |
$oWP = Services::WpGeneral();
|
90 |
$oWpPlugins = Services::WpPlugins();
|
91 |
-
return
|
92 |
-
'env' =>
|
93 |
-
'options' =>
|
94 |
'php' => Services::Data()->getPhpVersionCleaned(),
|
95 |
'wordpress' => $oWP->getVersion(),
|
96 |
'slug' => $this->getCon()->getPluginSlug(),
|
@@ -102,9 +102,9 @@ class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin
|
|
102 |
'plugins_total' => count( $oWpPlugins->getPlugins() ),
|
103 |
'plugins_active' => count( $oWpPlugins->getActivePlugins() ),
|
104 |
'plugins_updates' => count( $oWpPlugins->getUpdates() )
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
}
|
109 |
|
110 |
/**
|
6 |
class ICWP_WPSF_Processor_Plugin_Tracking extends ICWP_WPSF_Processor_BasePlugin {
|
7 |
|
8 |
/**
|
|
|
9 |
* @param array $aNoticeAttributes
|
10 |
+
* @see autoAddToAdminNotices()
|
11 |
*/
|
12 |
protected function addNotice_allow_tracking( $aNoticeAttributes ) {
|
13 |
/** @var ICWP_WPSF_FeatureHandler_Plugin $oFO */
|
14 |
$oFO = $this->getMod();
|
15 |
if ( $this->getIfShowAdminNotices() && !$oFO->isTrackingPermissionSet() ) {
|
16 |
$oCon = $this->getCon();
|
17 |
+
$aRenderData = [
|
18 |
'notice_attributes' => $aNoticeAttributes,
|
19 |
+
'strings' => [
|
20 |
'title' => sprintf( _wpsf__( "Make %s even better by sharing usage info?" ), $oCon->getHumanName() ),
|
21 |
'want_to_track' => sprintf( _wpsf__( "We're hoping to understand how %s is configured and used." ), $oCon->getHumanName() ),
|
22 |
'what_we_collect' => _wpsf__( "We'd like to understand how effective it is on a global scale." ),
|
26 |
'learn_more' => _wpsf__( 'Learn More.' ),
|
27 |
'site_url' => 'translate.icontrolwp.com',
|
28 |
'yes' => _wpsf__( 'Absolutely' )
|
29 |
+
],
|
30 |
+
'ajax' => [
|
31 |
'set_plugin_tracking_perm' => $oFO->getAjaxActionData( 'set_plugin_tracking_perm', true ),
|
32 |
+
],
|
33 |
+
'hrefs' => [
|
34 |
'learn_more' => 'http://translate.icontrolwp.com',
|
35 |
'link_to_see' => $oFO->getLinkToTrackingDataDump(),
|
36 |
'link_to_moreinfo' => 'https://icwp.io/shieldtrackinginfo',
|
37 |
|
38 |
+
]
|
39 |
+
];
|
40 |
$this->insertAdminNotice( $aRenderData );
|
41 |
}
|
42 |
}
|
88 |
protected function getBaseTrackingData() {
|
89 |
$oWP = Services::WpGeneral();
|
90 |
$oWpPlugins = Services::WpPlugins();
|
91 |
+
return [
|
92 |
+
'env' => [
|
93 |
+
'options' => [
|
94 |
'php' => Services::Data()->getPhpVersionCleaned(),
|
95 |
'wordpress' => $oWP->getVersion(),
|
96 |
'slug' => $this->getCon()->getPluginSlug(),
|
102 |
'plugins_total' => count( $oWpPlugins->getPlugins() ),
|
103 |
'plugins_active' => count( $oWpPlugins->getActivePlugins() ),
|
104 |
'plugins_updates' => count( $oWpPlugins->getUpdates() )
|
105 |
+
]
|
106 |
+
]
|
107 |
+
];
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -29,7 +29,7 @@ class ICWP_WPSF_Processor_Sessions extends ICWP_WPSF_BaseDbProcessor {
|
|
29 |
$this->terminateCurrentSession();
|
30 |
}, 0 );
|
31 |
}
|
32 |
-
add_filter( 'login_message',
|
33 |
}
|
34 |
}
|
35 |
|
29 |
$this->terminateCurrentSession();
|
30 |
}, 0 );
|
31 |
}
|
32 |
+
add_filter( 'login_message', [ $this, 'printLinkToAdmin' ] );
|
33 |
}
|
34 |
}
|
35 |
|
@@ -6,10 +6,7 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
6 |
/** @var ICWP_WPSF_FeatureHandler_Statistics $oFO */
|
7 |
$oFO = $this->getMod();
|
8 |
if ( $this->isReadyToRun() ) {
|
9 |
-
add_filter( $oFO->prefix( 'dashboard_widget_content' ),
|
10 |
-
$this,
|
11 |
-
'gatherStatsSummaryWidgetContent'
|
12 |
-
), 10 );
|
13 |
}
|
14 |
$this->getTallyProcessor()
|
15 |
->run();
|
@@ -45,7 +42,7 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
45 |
$aAllTallys = $this->getAllTallys();
|
46 |
$aAllStats = [];
|
47 |
|
48 |
-
$aSpamCommentKeys =
|
49 |
'spam.gasp.checkbox',
|
50 |
'spam.gasp.token',
|
51 |
'spam.gasp.honeypot',
|
@@ -57,20 +54,20 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
57 |
'spam.human.author_email',
|
58 |
'spam.human.ip_address',
|
59 |
'spam.human.user_agent'
|
60 |
-
|
61 |
-
$aLoginFailKeys =
|
62 |
'login.cooldown.fail',
|
63 |
'login.recaptcha.fail',
|
64 |
'login.gasp.checkbox.fail',
|
65 |
'login.gasp.honeypot.fail',
|
66 |
'login.googleauthenticator.fail',
|
67 |
'login.rename.fail',
|
68 |
-
|
69 |
-
$aLoginVerifiedKeys =
|
70 |
'login.googleauthenticator.verified',
|
71 |
'login.recaptcha.verified',
|
72 |
'login.twofactor.verified'
|
73 |
-
|
74 |
|
75 |
$aAllStats[ 'ip.transgression.incremented' ] = 0;
|
76 |
$aAllStats[ 'ip.connection.killed' ] = 0;
|
@@ -110,19 +107,19 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
110 |
}
|
111 |
|
112 |
return array_merge(
|
113 |
-
|
114 |
'ip.transgression.incremented' => 0,
|
115 |
'ip.connection.killed' => 0,
|
116 |
'firewall.blocked.all' => 0,
|
117 |
'comments.blocked.all' => 0,
|
118 |
'login.blocked.all' => 0,
|
119 |
'login.verified.all' => 0,
|
120 |
-
|
121 |
$aAllStats
|
122 |
);
|
123 |
}
|
124 |
|
125 |
-
public function
|
126 |
/** @var ICWP_WPSF_FeatureHandler_Statistics $oFO */
|
127 |
$oFO = $this->getMod();
|
128 |
|
@@ -136,7 +133,7 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
136 |
$nTotalUserSessionsStarted = 0;
|
137 |
// $nTotalFilesReplaced = 0;
|
138 |
|
139 |
-
$aSpamCommentKeys =
|
140 |
'spam.gasp.checkbox',
|
141 |
'spam.gasp.token',
|
142 |
'spam.gasp.honeypot',
|
@@ -148,20 +145,20 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
148 |
'spam.human.author_email',
|
149 |
'spam.human.ip_address',
|
150 |
'spam.human.user_agent'
|
151 |
-
|
152 |
-
$aLoginFailKeys =
|
153 |
'login.cooldown.fail',
|
154 |
'login.recaptcha.fail',
|
155 |
'login.gasp.checkbox.fail',
|
156 |
'login.gasp.honeypot.fail',
|
157 |
'login.googleauthenticator.fail',
|
158 |
'login.rename.fail',
|
159 |
-
|
160 |
-
$aLoginVerifiedKeys =
|
161 |
'login.googleauthenticator.verified',
|
162 |
'login.recaptcha.verified',
|
163 |
'login.twofactor.verified'
|
164 |
-
|
165 |
foreach ( $aAllStats as $oStat ) {
|
166 |
$sStatKey = $oStat->stat_key;
|
167 |
$nTally = $oStat->tally;
|
@@ -192,21 +189,21 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
192 |
}
|
193 |
}
|
194 |
|
195 |
-
$aKeyStats =
|
196 |
-
'comments' =>
|
197 |
-
'firewall' =>
|
198 |
-
'login_fail' =>
|
199 |
-
'login_verified' =>
|
200 |
-
'session_start' =>
|
201 |
-
'ip_killed' =>
|
202 |
-
'ip_transgressions' =>
|
203 |
-
|
204 |
|
205 |
-
$aDisplayData =
|
206 |
'sHeading' => sprintf( _wpsf__( '%s Statistics' ), $this->getCon()->getHumanName() ),
|
207 |
'aAllStats' => $aAllStats,
|
208 |
'aKeyStats' => $aKeyStats,
|
209 |
-
|
210 |
|
211 |
if ( !is_array( $aContent ) ) {
|
212 |
$aContent = [];
|
@@ -223,7 +220,7 @@ class ICWP_WPSF_Processor_Statistics extends ICWP_WPSF_Processor_BaseWpsf {
|
|
223 |
$aRes = $this->getTallyProcessor()
|
224 |
->getDbHandler()
|
225 |
->getQuerySelector()
|
226 |
-
->setColumnsToSelect(
|
227 |
->query();
|
228 |
return $aRes;
|
229 |
}
|
6 |
/** @var ICWP_WPSF_FeatureHandler_Statistics $oFO */
|
7 |
$oFO = $this->getMod();
|
8 |
if ( $this->isReadyToRun() ) {
|
9 |
+
add_filter( $oFO->prefix( 'dashboard_widget_content' ), [ $this, 'gatherStatsWidgetContent' ], 10 );
|
|
|
|
|
|
|
10 |
}
|
11 |
$this->getTallyProcessor()
|
12 |
->run();
|
42 |
$aAllTallys = $this->getAllTallys();
|
43 |
$aAllStats = [];
|
44 |
|
45 |
+
$aSpamCommentKeys = [
|
46 |
'spam.gasp.checkbox',
|
47 |
'spam.gasp.token',
|
48 |
'spam.gasp.honeypot',
|
54 |
'spam.human.author_email',
|
55 |
'spam.human.ip_address',
|
56 |
'spam.human.user_agent'
|
57 |
+
];
|
58 |
+
$aLoginFailKeys = [
|
59 |
'login.cooldown.fail',
|
60 |
'login.recaptcha.fail',
|
61 |
'login.gasp.checkbox.fail',
|
62 |
'login.gasp.honeypot.fail',
|
63 |
'login.googleauthenticator.fail',
|
64 |
'login.rename.fail',
|
65 |
+
];
|
66 |
+
$aLoginVerifiedKeys = [
|
67 |
'login.googleauthenticator.verified',
|
68 |
'login.recaptcha.verified',
|
69 |
'login.twofactor.verified'
|
70 |
+
];
|
71 |
|
72 |
$aAllStats[ 'ip.transgression.incremented' ] = 0;
|
73 |
$aAllStats[ 'ip.connection.killed' ] = 0;
|
107 |
}
|
108 |
|
109 |
return array_merge(
|
110 |
+
[
|
111 |
'ip.transgression.incremented' => 0,
|
112 |
'ip.connection.killed' => 0,
|
113 |
'firewall.blocked.all' => 0,
|
114 |
'comments.blocked.all' => 0,
|
115 |
'login.blocked.all' => 0,
|
116 |
'login.verified.all' => 0,
|
117 |
+
],
|
118 |
$aAllStats
|
119 |
);
|
120 |
}
|
121 |
|
122 |
+
public function gatherStatsWidgetContent( $aContent ) {
|
123 |
/** @var ICWP_WPSF_FeatureHandler_Statistics $oFO */
|
124 |
$oFO = $this->getMod();
|
125 |
|
133 |
$nTotalUserSessionsStarted = 0;
|
134 |
// $nTotalFilesReplaced = 0;
|
135 |
|
136 |
+
$aSpamCommentKeys = [
|
137 |
'spam.gasp.checkbox',
|
138 |
'spam.gasp.token',
|
139 |
'spam.gasp.honeypot',
|
145 |
'spam.human.author_email',
|
146 |
'spam.human.ip_address',
|
147 |
'spam.human.user_agent'
|
148 |
+
];
|
149 |
+
$aLoginFailKeys = [
|
150 |
'login.cooldown.fail',
|
151 |
'login.recaptcha.fail',
|
152 |
'login.gasp.checkbox.fail',
|
153 |
'login.gasp.honeypot.fail',
|
154 |
'login.googleauthenticator.fail',
|
155 |
'login.rename.fail',
|
156 |
+
];
|
157 |
+
$aLoginVerifiedKeys = [
|
158 |
'login.googleauthenticator.verified',
|
159 |
'login.recaptcha.verified',
|
160 |
'login.twofactor.verified'
|
161 |
+
];
|
162 |
foreach ( $aAllStats as $oStat ) {
|
163 |
$sStatKey = $oStat->stat_key;
|
164 |
$nTally = $oStat->tally;
|
189 |
}
|
190 |
}
|
191 |
|
192 |
+
$aKeyStats = [
|
193 |
+
'comments' => [ _wpsf__( 'Comment Blocks' ), $nTotalCommentSpamBlocked ],
|
194 |
+
'firewall' => [ _wpsf__( 'Firewall Blocks' ), $nTotalFirewallBlocked ],
|
195 |
+
'login_fail' => [ _wpsf__( 'Login Blocks' ), $nTotalLoginBlocked ],
|
196 |
+
'login_verified' => [ _wpsf__( 'Login Verified' ), $nTotalLoginVerified ],
|
197 |
+
'session_start' => [ _wpsf__( 'User Sessions' ), $nTotalUserSessionsStarted ],
|
198 |
+
'ip_killed' => [ _wpsf__( 'IP Auto Black-Listed' ), $nTotalConnectionKilled ],
|
199 |
+
'ip_transgressions' => [ _wpsf__( 'Total Transgressions' ), $nTotalTransgressions ],
|
200 |
+
];
|
201 |
|
202 |
+
$aDisplayData = [
|
203 |
'sHeading' => sprintf( _wpsf__( '%s Statistics' ), $this->getCon()->getHumanName() ),
|
204 |
'aAllStats' => $aAllStats,
|
205 |
'aKeyStats' => $aKeyStats,
|
206 |
+
];
|
207 |
|
208 |
if ( !is_array( $aContent ) ) {
|
209 |
$aContent = [];
|
220 |
$aRes = $this->getTallyProcessor()
|
221 |
->getDbHandler()
|
222 |
->getQuerySelector()
|
223 |
+
->setColumnsToSelect( [ 'stat_key', 'tally' ] )
|
224 |
->query();
|
225 |
return $aRes;
|
226 |
}
|
@@ -28,9 +28,9 @@ class ICWP_WPSF_Processor_Statistics_Reporting extends ICWP_WPSF_BaseDbProcessor
|
|
28 |
->setRecurrence( 'daily' )
|
29 |
->createCronJob(
|
30 |
$this->getCronName(),
|
31 |
-
|
32 |
);
|
33 |
-
add_action( $this->getMod()->prefix( 'deactivate_plugin' ),
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -55,12 +55,12 @@ class ICWP_WPSF_Processor_Statistics_Reporting extends ICWP_WPSF_BaseDbProcessor
|
|
55 |
|
56 |
// Now add new entry
|
57 |
$mResult = $this->insertData(
|
58 |
-
|
59 |
'stat_key' => $sStatKey,
|
60 |
'tally' => 1,
|
61 |
'created_at' => $this->time(),
|
62 |
'deleted_at' => 0,
|
63 |
-
|
64 |
);
|
65 |
return (bool)$mResult;
|
66 |
}
|
28 |
->setRecurrence( 'daily' )
|
29 |
->createCronJob(
|
30 |
$this->getCronName(),
|
31 |
+
[ $this, 'cron_dailyReportingConsolidation' ]
|
32 |
);
|
33 |
+
add_action( $this->getMod()->prefix( 'deactivate_plugin' ), [ $this, 'deleteCron' ] );
|
34 |
}
|
35 |
|
36 |
/**
|
55 |
|
56 |
// Now add new entry
|
57 |
$mResult = $this->insertData(
|
58 |
+
[
|
59 |
'stat_key' => $sStatKey,
|
60 |
'tally' => 1,
|
61 |
'created_at' => $this->time(),
|
62 |
'deleted_at' => 0,
|
63 |
+
]
|
64 |
);
|
65 |
return (bool)$mResult;
|
66 |
}
|
@@ -11,8 +11,8 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
11 |
$oFO = $this->getMod();
|
12 |
|
13 |
// Adds last login indicator column
|
14 |
-
add_filter( 'manage_users_columns',
|
15 |
-
add_filter( 'wpmu_users_columns',
|
16 |
|
17 |
/** Everything from this point on must consider XMLRPC compatibility **/
|
18 |
|
@@ -30,7 +30,14 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
30 |
$this->getProcessorPasswords()->run();
|
31 |
}
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -45,11 +52,11 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
-
* @param string
|
49 |
-
* @param WP_User $oUser
|
50 |
*/
|
51 |
public function onWpLogin( $sUsername, $oUser = null ) {
|
52 |
-
if ( !$oUser instanceof WP_User ) {
|
53 |
$oUser = Services::WpUsers()->getUserByUsername( $sUsername );
|
54 |
}
|
55 |
$this->setPasswordStartedAt( $oUser )// used by Password Policies
|
@@ -57,11 +64,8 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
57 |
->sendLoginNotifications( $oUser );
|
58 |
}
|
59 |
|
60 |
-
public function runDailyCron() {
|
61 |
-
}
|
62 |
-
|
63 |
/**
|
64 |
-
* @param WP_User $oUser - not checking that user is valid
|
65 |
* @return $this
|
66 |
*/
|
67 |
private function sendLoginNotifications( $oUser ) {
|
@@ -86,7 +90,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
-
* @param WP_User $oUser
|
90 |
* @return $this
|
91 |
*/
|
92 |
private function setPasswordStartedAt( $oUser ) {
|
@@ -97,7 +101,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
-
* @param WP_User $oUser
|
101 |
* @return $this
|
102 |
*/
|
103 |
protected function setUserLastLoginTime( $oUser ) {
|
@@ -150,14 +154,14 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
150 |
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oFO */
|
151 |
$oFO = $this->getMod();
|
152 |
|
153 |
-
$aUserCapToRolesMap =
|
154 |
'network_admin' => 'manage_network',
|
155 |
'administrator' => 'manage_options',
|
156 |
'editor' => 'edit_pages',
|
157 |
'author' => 'publish_posts',
|
158 |
'contributor' => 'delete_posts',
|
159 |
'subscriber' => 'read',
|
160 |
-
|
161 |
|
162 |
$sRoleToCheck = strtolower( apply_filters( $this->getMod()
|
163 |
->prefix( 'login-notification-email-role' ), 'administrator' ) );
|
@@ -181,7 +185,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
181 |
|
182 |
$sHomeUrl = Services::WpGeneral()->getHomeUrl();
|
183 |
|
184 |
-
$aMessage =
|
185 |
sprintf( _wpsf__( 'As requested, %s is notifying you of a successful %s login to a WordPress site that you manage.' ),
|
186 |
$this->getCon()->getHumanName(),
|
187 |
$sHumanName
|
@@ -196,7 +200,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
196 |
'- '.sprintf( '%s: %s', _wpsf__( 'IP Address' ), $this->ip() ),
|
197 |
'',
|
198 |
_wpsf__( 'Thanks.' )
|
199 |
-
|
200 |
|
201 |
return $this
|
202 |
->getMod()
|
@@ -214,7 +218,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
214 |
*/
|
215 |
private function sendUserLoginEmailNotification( $oUser ) {
|
216 |
$oWp = Services::WpGeneral();
|
217 |
-
$aMessage =
|
218 |
sprintf( _wpsf__( '%s is notifying you of a successful login to your WordPress account.' ), $this->getCon()
|
219 |
->getHumanName() ),
|
220 |
'',
|
@@ -227,7 +231,7 @@ class ICWP_WPSF_Processor_UserManagement extends ICWP_WPSF_Processor_BaseWpsf {
|
|
227 |
_wpsf__( 'If this is unexpected or suspicious, please contact your site administrator immediately.' ),
|
228 |
'',
|
229 |
_wpsf__( 'Thanks.' )
|
230 |
-
|
231 |
|
232 |
return $this
|
233 |
->getMod()
|
11 |
$oFO = $this->getMod();
|
12 |
|
13 |
// Adds last login indicator column
|
14 |
+
add_filter( 'manage_users_columns', [ $this, 'addUserStatusLastLogin' ] );
|
15 |
+
add_filter( 'wpmu_users_columns', [ $this, 'addUserStatusLastLogin' ] );
|
16 |
|
17 |
/** Everything from this point on must consider XMLRPC compatibility **/
|
18 |
|
30 |
$this->getProcessorPasswords()->run();
|
31 |
}
|
32 |
|
33 |
+
if ( $oFO->isSuspendEnabled() ) {
|
34 |
+
$this->getProcessorSuspend()->run();
|
35 |
+
}
|
36 |
+
|
37 |
+
// All newly created users have their first seen and password start date set
|
38 |
+
add_action( 'user_register', function ( $nUserId ) {
|
39 |
+
$this->getCon()->getUserMeta( Services::WpUsers()->getUserById( $nUserId ) );
|
40 |
+
} );
|
41 |
}
|
42 |
|
43 |
/**
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* @param string $sUsername
|
56 |
+
* @param \WP_User $oUser
|
57 |
*/
|
58 |
public function onWpLogin( $sUsername, $oUser = null ) {
|
59 |
+
if ( !$oUser instanceof \WP_User ) {
|
60 |
$oUser = Services::WpUsers()->getUserByUsername( $sUsername );
|
61 |
}
|
62 |
$this->setPasswordStartedAt( $oUser )// used by Password Policies
|
64 |
->sendLoginNotifications( $oUser );
|
65 |
}
|
66 |
|
|
|
|
|
|
|
67 |
/**
|
68 |
+
* @param \WP_User $oUser - not checking that user is valid
|
69 |
* @return $this
|
70 |
*/
|
71 |
private function sendLoginNotifications( $oUser ) {
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
+
* @param \WP_User $oUser
|
94 |
* @return $this
|
95 |
*/
|
96 |
private function setPasswordStartedAt( $oUser ) {
|
101 |
}
|
102 |
|
103 |
/**
|
104 |
+
* @param \WP_User $oUser
|
105 |
* @return $this
|
106 |
*/
|
107 |
protected function setUserLastLoginTime( $oUser ) {
|
154 |
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oFO */
|
155 |
$oFO = $this->getMod();
|
156 |
|
157 |
+
$aUserCapToRolesMap = [
|
158 |
'network_admin' => 'manage_network',
|
159 |
'administrator' => 'manage_options',
|
160 |
'editor' => 'edit_pages',
|
161 |
'author' => 'publish_posts',
|
162 |
'contributor' => 'delete_posts',
|
163 |
'subscriber' => 'read',
|
164 |
+
];
|
165 |
|
166 |
$sRoleToCheck = strtolower( apply_filters( $this->getMod()
|
167 |
->prefix( 'login-notification-email-role' ), 'administrator' ) );
|
185 |
|
186 |
$sHomeUrl = Services::WpGeneral()->getHomeUrl();
|
187 |
|
188 |
+
$aMessage = [
|
189 |
sprintf( _wpsf__( 'As requested, %s is notifying you of a successful %s login to a WordPress site that you manage.' ),
|
190 |
$this->getCon()->getHumanName(),
|
191 |
$sHumanName
|
200 |
'- '.sprintf( '%s: %s', _wpsf__( 'IP Address' ), $this->ip() ),
|
201 |
'',
|
202 |
_wpsf__( 'Thanks.' )
|
203 |
+
];
|
204 |
|
205 |
return $this
|
206 |
->getMod()
|
218 |
*/
|
219 |
private function sendUserLoginEmailNotification( $oUser ) {
|
220 |
$oWp = Services::WpGeneral();
|
221 |
+
$aMessage = [
|
222 |
sprintf( _wpsf__( '%s is notifying you of a successful login to your WordPress account.' ), $this->getCon()
|
223 |
->getHumanName() ),
|
224 |
'',
|
231 |
_wpsf__( 'If this is unexpected or suspicious, please contact your site administrator immediately.' ),
|
232 |
'',
|
233 |
_wpsf__( 'Thanks.' )
|
234 |
+
];
|
235 |
|
236 |
return $this
|
237 |
->getMod()
|
@@ -9,11 +9,11 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
9 |
class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
11 |
public function run() {
|
12 |
-
add_action( 'password_reset',
|
13 |
-
add_filter( 'registration_errors',
|
14 |
-
add_action( 'user_profile_update_errors',
|
15 |
-
add_action( 'validate_password_reset',
|
16 |
-
add_filter( 'login_message',
|
17 |
}
|
18 |
|
19 |
/**
|
@@ -31,7 +31,7 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
31 |
* @param int $nUserId
|
32 |
*/
|
33 |
public function onWpSetLoggedInCookie( $sCookie, $nExpire, $nExpiration, $nUserId ) {
|
34 |
-
$this->captureLogin(
|
35 |
}
|
36 |
|
37 |
/**
|
@@ -55,7 +55,7 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
55 |
}
|
56 |
|
57 |
public function onWpLoaded() {
|
58 |
-
if ( is_admin() && !$this->loadRequest()->isMethodPost() &&
|
59 |
$this->processExpiredPassword();
|
60 |
$this->processFailedCheckPassword();
|
61 |
}
|
@@ -123,8 +123,8 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
123 |
* IMPORTANT: User must be logged-in for this to work correctly
|
124 |
* We have a 2 minute delay between redirects because some custom user forms redirect to custom
|
125 |
* password reset pages. This prevents users following this flow.
|
126 |
-
* @uses wp_redirect()
|
127 |
* @param string $sMessage
|
|
|
128 |
*/
|
129 |
private function redirectToResetPassword( $sMessage ) {
|
130 |
|
@@ -135,10 +135,10 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
135 |
$oMeta->pass_reset_last_redirect_at = $this->time();
|
136 |
|
137 |
$oWp = $this->loadWp();
|
138 |
-
$oWpUsers =
|
139 |
-
$sAction =
|
140 |
$oUser = $oWpUsers->getCurrentWpUser();
|
141 |
-
if ( $oUser && ( !$oWp->isRequestLoginUrl() || !in_array( $sAction,
|
142 |
|
143 |
$sMessage .= ' '._wpsf__( 'For your security, please use the password section below to update your password.' );
|
144 |
$this->getMod()
|
@@ -160,7 +160,7 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
160 |
if ( !empty( $sPassword ) ) {
|
161 |
try {
|
162 |
$this->applyPasswordChecks( $sPassword );
|
163 |
-
if (
|
164 |
$this->getCon()->getCurrentUserMeta()->pass_check_failed_at = 0;
|
165 |
}
|
166 |
}
|
@@ -209,8 +209,7 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
209 |
$oFO = $this->getMod();
|
210 |
$nMin = $oFO->getPassMinStrength();
|
211 |
|
212 |
-
$
|
213 |
-
$aResults = $oStengther->passwordStrength( $sPassword );
|
214 |
$nScore = $aResults[ 'score' ];
|
215 |
|
216 |
if ( $nMin > 0 && $nScore < $nMin ) {
|
@@ -261,11 +260,11 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
261 |
|
262 |
$aResponse = $this->loadFS()->requestUrl(
|
263 |
sprintf( '%s/%s', $oFO->getDef( 'pwned_api_url_password_single' ), hash( 'sha1', $sPass ) ),
|
264 |
-
|
265 |
-
'headers' =>
|
266 |
'user-agent' => sprintf( '%s WP Plugin-v%s', $oCon->getHumanName(), $oCon->getVersion() )
|
267 |
-
|
268 |
-
|
269 |
true
|
270 |
);
|
271 |
|
@@ -326,11 +325,11 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
326 |
|
327 |
$aResponse = $this->loadFS()->requestUrl(
|
328 |
sprintf( '%s/%s', $oFO->getDef( 'pwned_api_url_password_range' ), $sSubHash ),
|
329 |
-
|
330 |
-
'headers' =>
|
331 |
'user-agent' => sprintf( '%s WP Plugin-v%s', $oCon->getHumanName(), $oCon->getVersion() )
|
332 |
-
|
333 |
-
|
334 |
true
|
335 |
);
|
336 |
|
@@ -385,7 +384,7 @@ class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_B
|
|
385 |
$sPass = null;
|
386 |
|
387 |
// Edd: edd_user_pass; Woo: password;
|
388 |
-
foreach (
|
389 |
$sP = $this->loadRequest()->post( $sKey );
|
390 |
if ( !empty( $sP ) ) {
|
391 |
$sPass = $sP;
|
9 |
class ICWP_WPSF_Processor_UserManagement_Passwords extends ICWP_WPSF_Processor_BaseWpsf {
|
10 |
|
11 |
public function run() {
|
12 |
+
add_action( 'password_reset', [ $this, 'onPasswordReset' ], 100, 1 );
|
13 |
+
add_filter( 'registration_errors', [ $this, 'checkPassword' ], 100, 3 );
|
14 |
+
add_action( 'user_profile_update_errors', [ $this, 'checkPassword' ], 100, 3 );
|
15 |
+
add_action( 'validate_password_reset', [ $this, 'checkPassword' ], 100, 3 );
|
16 |
+
add_filter( 'login_message', [ $this, 'addPasswordResetMessage' ] );
|
17 |
}
|
18 |
|
19 |
/**
|
31 |
* @param int $nUserId
|
32 |
*/
|
33 |
public function onWpSetLoggedInCookie( $sCookie, $nExpire, $nExpiration, $nUserId ) {
|
34 |
+
$this->captureLogin( Services::WpUsers()->getUserById( $nUserId ) );
|
35 |
}
|
36 |
|
37 |
/**
|
55 |
}
|
56 |
|
57 |
public function onWpLoaded() {
|
58 |
+
if ( is_admin() && !$this->loadRequest()->isMethodPost() && Services::WpUsers()->isUserLoggedIn() ) {
|
59 |
$this->processExpiredPassword();
|
60 |
$this->processFailedCheckPassword();
|
61 |
}
|
123 |
* IMPORTANT: User must be logged-in for this to work correctly
|
124 |
* We have a 2 minute delay between redirects because some custom user forms redirect to custom
|
125 |
* password reset pages. This prevents users following this flow.
|
|
|
126 |
* @param string $sMessage
|
127 |
+
* @uses wp_redirect()
|
128 |
*/
|
129 |
private function redirectToResetPassword( $sMessage ) {
|
130 |
|
135 |
$oMeta->pass_reset_last_redirect_at = $this->time();
|
136 |
|
137 |
$oWp = $this->loadWp();
|
138 |
+
$oWpUsers = Services::WpUsers();
|
139 |
+
$sAction = Services::Request()->query( 'action' );
|
140 |
$oUser = $oWpUsers->getCurrentWpUser();
|
141 |
+
if ( $oUser && ( !$oWp->isRequestLoginUrl() || !in_array( $sAction, [ 'rp', 'resetpass' ] ) ) ) {
|
142 |
|
143 |
$sMessage .= ' '._wpsf__( 'For your security, please use the password section below to update your password.' );
|
144 |
$this->getMod()
|
160 |
if ( !empty( $sPassword ) ) {
|
161 |
try {
|
162 |
$this->applyPasswordChecks( $sPassword );
|
163 |
+
if ( Services::WpUsers()->isUserLoggedIn() ) {
|
164 |
$this->getCon()->getCurrentUserMeta()->pass_check_failed_at = 0;
|
165 |
}
|
166 |
}
|
209 |
$oFO = $this->getMod();
|
210 |
$nMin = $oFO->getPassMinStrength();
|
211 |
|
212 |
+
$aResults = ( new \ZxcvbnPhp\Zxcvbn() )->passwordStrength( $sPassword );
|
|
|
213 |
$nScore = $aResults[ 'score' ];
|
214 |
|
215 |
if ( $nMin > 0 && $nScore < $nMin ) {
|
260 |
|
261 |
$aResponse = $this->loadFS()->requestUrl(
|
262 |
sprintf( '%s/%s', $oFO->getDef( 'pwned_api_url_password_single' ), hash( 'sha1', $sPass ) ),
|
263 |
+
[
|
264 |
+
'headers' => [
|
265 |
'user-agent' => sprintf( '%s WP Plugin-v%s', $oCon->getHumanName(), $oCon->getVersion() )
|
266 |
+
]
|
267 |
+
],
|
268 |
true
|
269 |
);
|
270 |
|
325 |
|
326 |
$aResponse = $this->loadFS()->requestUrl(
|
327 |
sprintf( '%s/%s', $oFO->getDef( 'pwned_api_url_password_range' ), $sSubHash ),
|
328 |
+
[
|
329 |
+
'headers' => [
|
330 |
'user-agent' => sprintf( '%s WP Plugin-v%s', $oCon->getHumanName(), $oCon->getVersion() )
|
331 |
+
]
|
332 |
+
],
|
333 |
true
|
334 |
);
|
335 |
|
384 |
$sPass = null;
|
385 |
|
386 |
// Edd: edd_user_pass; Woo: password;
|
387 |
+
foreach ( [ 'pwd', 'pass1' ] as $sKey ) {
|
388 |
$sP = $this->loadRequest()->post( $sKey );
|
389 |
if ( !empty( $sP ) ) {
|
390 |
$sPass = $sP;
|
@@ -7,8 +7,8 @@ class ICWP_WPSF_Processor_UserManagement_Sessions extends ICWP_WPSF_Processor_Ba
|
|
7 |
public function run() {
|
8 |
if ( $this->isReadyToRun() ) {
|
9 |
parent::run();
|
10 |
-
add_filter( 'wp_login_errors',
|
11 |
-
add_filter( 'auth_cookie_expiration',
|
12 |
}
|
13 |
}
|
14 |
|
@@ -107,7 +107,7 @@ class ICWP_WPSF_Processor_UserManagement_Sessions extends ICWP_WPSF_Processor_Ba
|
|
107 |
$this->addToAuditEntry(
|
108 |
$sMessage.' '._wpsf__( 'Logging out.' ), 2, 'um_session_no_valid_found'
|
109 |
);
|
110 |
-
$oWpUsers->forceUserRelogin(
|
111 |
break;
|
112 |
|
113 |
case 7:
|
@@ -126,7 +126,7 @@ class ICWP_WPSF_Processor_UserManagement_Sessions extends ICWP_WPSF_Processor_Ba
|
|
126 |
2,
|
127 |
'um_session_not_found_redirect'
|
128 |
);
|
129 |
-
$oWpUsers->forceUserRelogin(
|
130 |
break;
|
131 |
}
|
132 |
}
|
7 |
public function run() {
|
8 |
if ( $this->isReadyToRun() ) {
|
9 |
parent::run();
|
10 |
+
add_filter( 'wp_login_errors', [ $this, 'addLoginMessage' ] );
|
11 |
+
add_filter( 'auth_cookie_expiration', [ $this, 'setMaxAuthCookieExpiration' ], 100, 1 );
|
12 |
}
|
13 |
}
|
14 |
|
107 |
$this->addToAuditEntry(
|
108 |
$sMessage.' '._wpsf__( 'Logging out.' ), 2, 'um_session_no_valid_found'
|
109 |
);
|
110 |
+
$oWpUsers->forceUserRelogin( [ 'wpsf-forcelogout' => $nCode ] );
|
111 |
break;
|
112 |
|
113 |
case 7:
|
126 |
2,
|
127 |
'um_session_not_found_redirect'
|
128 |
);
|
129 |
+
$oWpUsers->forceUserRelogin( [ 'wpsf-forcelogout' => $nCode ] );
|
130 |
break;
|
131 |
}
|
132 |
}
|
@@ -12,25 +12,58 @@ class ICWP_WPSF_Processor_UserManagement_Suspend extends ICWP_WPSF_Processor_Bas
|
|
12 |
if ( $oFO->isSuspendManualEnabled() ) {
|
13 |
$this->setupUserFilters();
|
14 |
( new Suspend\Suspended() )
|
15 |
-
->
|
16 |
->run();
|
17 |
}
|
18 |
|
19 |
if ( $oFO->isSuspendAutoIdleEnabled() ) {
|
20 |
( new Suspend\Idle() )
|
21 |
-
->
|
22 |
-
->setCon( $this->getCon() )
|
23 |
->run();
|
24 |
}
|
25 |
|
26 |
if ( $oFO->isSuspendAutoPasswordEnabled() ) {
|
27 |
( new Suspend\PasswordExpiry() )
|
28 |
->setMaxPasswordAge( $oFO->getPassExpireTimeout() )
|
29 |
-
->
|
30 |
->run();
|
31 |
}
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* Sets-up all the UI filters necessary to provide manual user suspension and filter the User Tables
|
36 |
*/
|
@@ -39,8 +72,8 @@ class ICWP_WPSF_Processor_UserManagement_Suspend extends ICWP_WPSF_Processor_Bas
|
|
39 |
$oFO = $this->getMod();
|
40 |
|
41 |
// User profile UI
|
42 |
-
add_filter( 'edit_user_profile', [ $this, 'addUserBlockOption' ] );
|
43 |
-
|
44 |
|
45 |
// Display suspended on the user list table
|
46 |
add_filter( 'manage_users_columns', [ $this, 'addUserListSuspendedFlag' ] );
|
@@ -50,10 +83,9 @@ class ICWP_WPSF_Processor_UserManagement_Suspend extends ICWP_WPSF_Processor_Bas
|
|
50 |
if ( !empty( $aUserIds ) ) {
|
51 |
// Provide the link above the table.
|
52 |
add_filter( 'views_users', function ( $aViews ) use ( $aUserIds ) {
|
53 |
-
$nTotal = count( $aUserIds );
|
54 |
$aViews[ 'shield_suspended_users' ] = sprintf( '<a href="%s">%s</a>',
|
55 |
add_query_arg( [ 'suspended' => 1 ], Services::WpGeneral()->getUrl_CurrentAdminPage() ),
|
56 |
-
sprintf( '%s (%s)', _wpsf__( 'Suspended' ), $
|
57 |
return $aViews;
|
58 |
} );
|
59 |
|
@@ -68,7 +100,6 @@ class ICWP_WPSF_Processor_UserManagement_Suspend extends ICWP_WPSF_Processor_Bas
|
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* Adds the column to the users listing table to indicate whether WordPress will automatically update the plugins
|
72 |
* @param array $aColumns
|
73 |
* @return array
|
74 |
*/
|
@@ -109,39 +140,51 @@ class ICWP_WPSF_Processor_UserManagement_Suspend extends ICWP_WPSF_Processor_Bas
|
|
109 |
*/
|
110 |
public function addUserBlockOption( $oUser ) {
|
111 |
$oCon = $this->getCon();
|
|
|
112 |
$oMeta = $oCon->getUserMeta( $oUser );
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
),
|
122 |
-
'
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
* @param int $nUserId
|
133 |
*/
|
134 |
-
public function
|
135 |
$oCon = $this->getCon();
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
}
|
147 |
}
|
12 |
if ( $oFO->isSuspendManualEnabled() ) {
|
13 |
$this->setupUserFilters();
|
14 |
( new Suspend\Suspended() )
|
15 |
+
->setMod( $this->getMod() )
|
16 |
->run();
|
17 |
}
|
18 |
|
19 |
if ( $oFO->isSuspendAutoIdleEnabled() ) {
|
20 |
( new Suspend\Idle() )
|
21 |
+
->setMod( $this->getMod() )
|
|
|
22 |
->run();
|
23 |
}
|
24 |
|
25 |
if ( $oFO->isSuspendAutoPasswordEnabled() ) {
|
26 |
( new Suspend\PasswordExpiry() )
|
27 |
->setMaxPasswordAge( $oFO->getPassExpireTimeout() )
|
28 |
+
->setMod( $this->getMod() )
|
29 |
->run();
|
30 |
}
|
31 |
}
|
32 |
|
33 |
+
public function runHourlyCron() {
|
34 |
+
$this->updateUserMetaVersion();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Run from CRON
|
39 |
+
* Updates all user meta versions. Limits to 25 users at a time via the cron
|
40 |
+
*/
|
41 |
+
private function updateUserMetaVersion() {
|
42 |
+
$oCon = $this->getCon();
|
43 |
+
$nVersion = $this->getCon()->getVersionNumeric();
|
44 |
+
$sMetaKey = $this->prefix( 'meta-version' );
|
45 |
+
|
46 |
+
$nCount = 0;
|
47 |
+
|
48 |
+
$oUserIt = new \FernleafSystems\Wordpress\Services\Utilities\Iterators\WpUserIterator();
|
49 |
+
$oUserIt->filterByMeta( $sMetaKey, $nVersion, 'NOT EXISTS' );
|
50 |
+
foreach ( $oUserIt as $oUser ) {
|
51 |
+
$oCon->getUserMeta( $oUser );
|
52 |
+
if ( $nCount++ > 25 ) {
|
53 |
+
break;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
$oUserIt = new \FernleafSystems\Wordpress\Services\Utilities\Iterators\WpUserIterator();
|
58 |
+
$oUserIt->filterByMeta( $sMetaKey, $nVersion, '<' );
|
59 |
+
foreach ( $oUserIt as $oUser ) {
|
60 |
+
$oCon->getUserMeta( $oUser );
|
61 |
+
if ( $nCount++ > 25 ) {
|
62 |
+
break;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
/**
|
68 |
* Sets-up all the UI filters necessary to provide manual user suspension and filter the User Tables
|
69 |
*/
|
72 |
$oFO = $this->getMod();
|
73 |
|
74 |
// User profile UI
|
75 |
+
add_filter( 'edit_user_profile', [ $this, 'addUserBlockOption' ], 1, 1 );
|
76 |
+
add_action( 'edit_user_profile_update', [ $this, 'handleUserSuspendOptionSubmit' ] );
|
77 |
|
78 |
// Display suspended on the user list table
|
79 |
add_filter( 'manage_users_columns', [ $this, 'addUserListSuspendedFlag' ] );
|
83 |
if ( !empty( $aUserIds ) ) {
|
84 |
// Provide the link above the table.
|
85 |
add_filter( 'views_users', function ( $aViews ) use ( $aUserIds ) {
|
|
|
86 |
$aViews[ 'shield_suspended_users' ] = sprintf( '<a href="%s">%s</a>',
|
87 |
add_query_arg( [ 'suspended' => 1 ], Services::WpGeneral()->getUrl_CurrentAdminPage() ),
|
88 |
+
sprintf( '%s (%s)', _wpsf__( 'Suspended' ), count( $aUserIds ) ) );
|
89 |
return $aViews;
|
90 |
} );
|
91 |
|
100 |
}
|
101 |
|
102 |
/**
|
|
|
103 |
* @param array $aColumns
|
104 |
* @return array
|
105 |
*/
|
140 |
*/
|
141 |
public function addUserBlockOption( $oUser ) {
|
142 |
$oCon = $this->getCon();
|
143 |
+
$oWpUsers = Services::WpUsers();
|
144 |
$oMeta = $oCon->getUserMeta( $oUser );
|
145 |
|
146 |
+
$oWpUsers->isUserAdmin( $oUser );
|
147 |
+
|
148 |
+
$aData = [
|
149 |
+
'strings' => [
|
150 |
+
'title' => _wpsf__( 'Suspend Account' ),
|
151 |
+
'label' => _wpsf__( 'Check to un/suspend user account' ),
|
152 |
+
'description' => _wpsf__( 'The user can never login while their account is suspended.' ),
|
153 |
+
'cant_manage' => _wpsf__( 'Sorry, suspension for this account may only be managed by a security administrator.' ),
|
154 |
+
'since' => sprintf( '%s: %s', _wpsf__( 'Suspended' ), Services::WpGeneral()
|
155 |
+
->getTimeStringForDisplay( $oMeta->hard_suspended_at ) ),
|
156 |
+
],
|
157 |
+
'flags' => [
|
158 |
+
'can_manage_suspension' => !$oWpUsers->isUserAdmin( $oUser ) || $oCon->isPluginAdmin(),
|
159 |
+
'is_suspended' => $oMeta->hard_suspended_at > 0
|
160 |
+
],
|
161 |
+
'vars' => [
|
162 |
+
'form_field' => 'shield_suspend_user',
|
163 |
+
]
|
164 |
+
];
|
165 |
+
echo $this->getMod()->renderTemplate( '/snippets/user/profile/suspend.twig', $aData, true );
|
166 |
}
|
167 |
|
168 |
/**
|
169 |
* @param int $nUserId
|
170 |
*/
|
171 |
+
public function handleUserSuspendOptionSubmit( $nUserId ) {
|
172 |
$oCon = $this->getCon();
|
173 |
+
$oWpUsers = Services::WpUsers();
|
174 |
+
|
175 |
+
$oEditedUser = $oWpUsers->getUserById( $nUserId );
|
176 |
+
|
177 |
+
if ( !$oWpUsers->isUserAdmin( $oEditedUser ) || $oCon->isPluginAdmin() ) {
|
178 |
+
$bIsSuspend = Services::Request()->post( 'shield_suspend_user' ) === 'Y';
|
179 |
+
/** @var ICWP_WPSF_FeatureHandler_UserManagement $oFO */
|
180 |
+
$oFO = $this->getMod();
|
181 |
+
$oFO->addRemoveHardSuspendUserId( $nUserId, $bIsSuspend );
|
182 |
+
|
183 |
+
if ( $bIsSuspend ) { // Delete any existing user sessions
|
184 |
+
$oProcessor = $oFO->getSessionsProcessor();
|
185 |
+
/** @var \FernleafSystems\Wordpress\Plugin\Shield\Databases\Session\Delete $oDel */
|
186 |
+
$oDel = $oProcessor->getDbHandler()->getQueryDeleter();
|
187 |
+
$oDel->forUsername( $oEditedUser->user_login );
|
188 |
}
|
189 |
}
|
190 |
}
|
@@ -1,3 +1,3 @@
|
|
1 |
<?php
|
2 |
$sBaseDirName = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
|
3 |
-
include_once( $sBaseDirName.'widgets/icwp_widgets.php' );
|
1 |
<?php
|
2 |
$sBaseDirName = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
|
3 |
+
include_once( $sBaseDirName.'widgets/icwp_widgets.php' );
|
@@ -1,17 +1,29 @@
|
|
1 |
<table class="form-table">
|
2 |
<tbody>
|
3 |
<tr id="password" class="user-pass1-wrap">
|
4 |
-
<th><label for="
|
5 |
-
|
6 |
-
<
|
7 |
-
<
|
8 |
-
|
9 |
-
<
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
</tr>
|
16 |
</tbody>
|
17 |
</table>
|
1 |
<table class="form-table">
|
2 |
<tbody>
|
3 |
<tr id="password" class="user-pass1-wrap">
|
4 |
+
<th><label for="_shield_suspend_user">{{ strings.title }}</label></th>
|
5 |
+
{% if flags.can_manage_suspension %}
|
6 |
+
<td>
|
7 |
+
<fieldset>
|
8 |
+
<legend class="screen-reader-text"><span>{{ strings.title }}</span></legend>
|
9 |
+
<label for="_shield_suspend_user">
|
10 |
+
<input name="{{ vars.form_field }}" type="checkbox" id="_shield_suspend_user" value="Y"
|
11 |
+
{% if flags.is_suspended %}checked="checked"{% endif %}>
|
12 |
+
{{ strings.label }}
|
13 |
+
</label>
|
14 |
+
|
15 |
+
<p class="description">{{ strings.description }}
|
16 |
+
{% if flags.is_suspended %}
|
17 |
+
<br/><span>({{ strings.since }})</span>
|
18 |
+
{% endif %}
|
19 |
+
</p>
|
20 |
+
</fieldset>
|
21 |
+
</td>
|
22 |
+
{% else %}
|
23 |
+
<td>
|
24 |
+
<p>{{ strings.cant_manage }}</p>
|
25 |
+
</td>
|
26 |
+
{% endif %}
|
27 |
</tr>
|
28 |
</tbody>
|
29 |
</table>
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="row insights_widget" id="SectionScanResultsMal">
|
2 |
+
<div class="col-12">
|
3 |
+
<div class="card card-scan_results">
|
4 |
+
|
5 |
+
<div class="card-header">
|
6 |
+
<h5 class="card-title">Malware Scanner</h5>
|
7 |
+
<h6 class="card-subtitle text-muted">Discover files that have Malware</h6>
|
8 |
+
</div>
|
9 |
+
|
10 |
+
<div class="card-body">
|
11 |
+
|
12 |
+
{% if scan.flags.is_available %}
|
13 |
+
|
14 |
+
{% if scan.flags.is_enabled %}
|
15 |
+
|
16 |
+
{% if not scan.flags.has_items %}
|
17 |
+
<div class="alert alert-info m-0">No items discovered</div>
|
18 |
+
{% else %}
|
19 |
+
<div id="TableScanMal" class="container-scantable"></div>
|
20 |
+
{% endif %}
|
21 |
+
|
22 |
+
{% else %}
|
23 |
+
{% include '/wpadmin_pages/insights_new/scans/results/'~scankey~'_disabled.twig' %}
|
24 |
+
{% endif %}
|
25 |
+
|
26 |
+
{% else %}
|
27 |
+
{% include '/wpadmin_pages/insights_new/scans/results/common_unavailable.twig' %}
|
28 |
+
{% endif %}
|
29 |
+
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<div class="card-footer">
|
33 |
+
<div class="row">
|
34 |
+
<div class="col-sm-6">
|
35 |
+
{% if scan.flags.has_last_scan %}
|
36 |
+
{{ scan.vars.last_scan_at }}
|
37 |
+
{% else %}
|
38 |
+
{{ strings.never }}
|
39 |
+
{% endif %}
|
40 |
+
</div>
|
41 |
+
<div class="col-sm-6 text-right">
|
42 |
+
<a href="{{ scan.hrefs.options }}"
|
43 |
+
class="btn btn-sm btn-outline-dark">{{ strings.options }} →</a>
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
</div>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
<script>
|
52 |
+
var $oTableScanMal = jQuery( '#TableScanMal' ).icwpWpsfAjaxTable(
|
53 |
+
{
|
54 |
+
'ajax_render':{{ ajax.render_table_scan|raw }},
|
55 |
+
'req_params': {
|
56 |
+
'fScan': 'mal'
|
57 |
+
}
|
58 |
+
}
|
59 |
+
);
|
60 |
+
jQuery( '#SectionScanResultsMal' ).icwpWpsfTableActions(
|
61 |
+
{
|
62 |
+
'table': $oTableScanMal,
|
63 |
+
'ajax_bulk_action':{{ ajax.bulk_action|raw }},
|
64 |
+
'ajax_item_ignore':{{ ajax.item_ignore|raw }},
|
65 |
+
'req_params': {
|
66 |
+
'fScan': 'mal'
|
67 |
+
}
|
68 |
+
}
|
69 |
+
);
|
70 |
+
</script>
|
@@ -88,13 +88,31 @@
|
|
88 |
</div>
|
89 |
</div>
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
<div class="col-xl-3 col-lg-4 col-md-6">
|
92 |
<div class="scan-select pl-2 text-nowrap">
|
93 |
<label for="_apc" class="col-form-label">
|
94 |
<input type="checkbox" class="form-control text-right"
|
95 |
-
|
96 |
-
disabled="disabled"
|
97 |
-
{% endif %}
|
98 |
name="apc" id="_apc" value="Y" checked="checked" aria-selected="true" />
|
99 |
Abandoned Plugins
|
100 |
<br />
|
88 |
</div>
|
89 |
</div>
|
90 |
|
91 |
+
{# <div class="col-xl-3 col-lg-4 col-md-6">#}
|
92 |
+
{# <div class="scan-select pl-2 text-nowrap">#}
|
93 |
+
{# <label for="_mal" class="col-form-label">#}
|
94 |
+
{# <input type="checkbox" class="form-control text-right"#}
|
95 |
+
{# {% if not scans.mal.flags.is_enabled %}disabled="disabled"{% endif %}#}
|
96 |
+
{# name="mal" id="_mal" value="Y" checked="checked" aria-selected="true" />#}
|
97 |
+
{# Malware Scanner#}
|
98 |
+
{# <br />#}
|
99 |
+
{# <small class="form-text text-muted">#}
|
100 |
+
{# {% if not scans.mal.flags.is_enabled %}#}
|
101 |
+
{# <small class="form-text text-muted">#}
|
102 |
+
{# Use the Scan Options link below to enable this scan.#}
|
103 |
+
{# </small>#}
|
104 |
+
{# {% endif %}#}
|
105 |
+
{# {{ scans.mal.strings.subtitle }}#}
|
106 |
+
{# </small>#}
|
107 |
+
{# </label>#}
|
108 |
+
{# </div>#}
|
109 |
+
{# </div>#}
|
110 |
+
|
111 |
<div class="col-xl-3 col-lg-4 col-md-6">
|
112 |
<div class="scan-select pl-2 text-nowrap">
|
113 |
<label for="_apc" class="col-form-label">
|
114 |
<input type="checkbox" class="form-control text-right"
|
115 |
+
{% if not scans.apc.flags.is_enabled %}disabled="disabled"{% endif %}
|
|
|
|
|
116 |
name="apc" id="_apc" value="Y" checked="checked" aria-selected="true" />
|
117 |
Abandoned Plugins
|
118 |
<br />
|
@@ -1,30 +1,3 @@
|
|
1 |
-
{#<div class="row">#}
|
2 |
-
{#{% set scankey = 'wcf' %}#}
|
3 |
-
{#{% set scan = attribute(scans, scankey) %}#}
|
4 |
-
{#<div class="col-lg-12 col-xl-6">#}
|
5 |
-
{#{% include '/wpadmin_pages/insights_new/scans/results/wcf.twig' %}#}
|
6 |
-
{#</div>#}
|
7 |
-
{#{% set scankey = 'ufc' %}#}
|
8 |
-
{#{% set scan = attribute(scans, scankey) %}#}
|
9 |
-
{#<div class="col-lg-12 col-xl-6">#}
|
10 |
-
{#{% include '/wpadmin_pages/insights_new/scans/results/ufc.twig' %}#}
|
11 |
-
{#</div>#}
|
12 |
-
{#{% set scankey = 'apc' %}#}
|
13 |
-
{#{% set scan = attribute(scans, scankey) %}#}
|
14 |
-
{#<div class="col-lg-12 col-xl-6">#}
|
15 |
-
{#{% include '/wpadmin_pages/insights_new/scans/results/apc.twig' %}#}
|
16 |
-
{#</div>#}
|
17 |
-
{#{% set scankey = 'ptg' %}#}
|
18 |
-
{#{% set scan = attribute(scans, scankey) %}#}
|
19 |
-
{#<div class="col-12">#}
|
20 |
-
{#{% include '/wpadmin_pages/insights_new/scans/results/ptg.twig' %}#}
|
21 |
-
{#</div>#}
|
22 |
-
{#{% set scankey = 'wpv' %}#}
|
23 |
-
{#{% set scan = attribute(scans, scankey) %}#}
|
24 |
-
{#<div class="col-12">#}
|
25 |
-
{#{% include '/wpadmin_pages/insights_new/scans/results/wpv.twig' %}#}
|
26 |
-
{#</div>#}
|
27 |
-
{#</div>#}
|
28 |
<div class="row" id="ScanResultsPills">
|
29 |
<div class="col-sm-3 col-md-3 col-xl-2">
|
30 |
<nav class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="row" id="ScanResultsPills">
|
2 |
<div class="col-sm-3 col-md-3 col-xl-2">
|
3 |
<nav class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
|
@@ -5,7 +5,4 @@
|
|
5 |
<div class="col-12">
|
6 |
{% include '/wpadmin_pages/insights_new/scans/scan_results.twig' %}
|
7 |
</div>
|
8 |
-
</div>
|
9 |
-
|
10 |
-
<script>
|
11 |
-
</script>
|
5 |
<div class="col-12">
|
6 |
{% include '/wpadmin_pages/insights_new/scans/scan_results.twig' %}
|
7 |
</div>
|
8 |
+
</div>
|
|
|
|
|
|