Version Description
Download this release
Release Info
Developer | paultgoodchild |
Plugin | Shield Security for WordPress |
Version | 12.0.11 |
Comparing to | |
See all releases |
Code changes from version 12.0.9 to 12.0.11
- cl.json +12 -0
- icwp-wpsf.php +1 -1
- plugin-spec.php +6 -6
- plugin.json +6 -6
- readme.txt +1 -1
- resources/images/bootstrap/graph-up.svg +2 -2
- resources/images/bootstrap/people.svg +2 -2
- resources/images/bootstrap/tools.svg +2 -2
- resources/js/shield/notbot.js +33 -21
- src/lib/src/Modules/Data/DB/ReqLogs/LoadLogs.php +2 -1
- src/lib/src/Modules/HackGuard/Lib/FileLocker/File.php +0 -2
- src/lib/src/Modules/HackGuard/Lib/FileLocker/FileLockerController.php +26 -45
- src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php +4 -4
- src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildFileFromFileKey.php +57 -0
- src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php +1 -12
- src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/HasFileLocksToCreate.php +29 -0
- src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php +0 -4
- src/lib/src/Modules/HackGuard/Scan/Utilities/WpvAddPluginRows.php +12 -3
- src/lib/src/Modules/IPs/Lib/Bots/BotSignalsController.php +2 -1
- src/lib/src/Modules/IPs/Lib/Bots/NotBot/NotBotHandler.php +3 -10
- src/lib/vendor/composer/autoload_classmap.php +3 -0
- src/lib/vendor/composer/autoload_static.php +3 -0
- src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php +7 -7
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php +31 -33
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php +77 -52
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/HttpUtil.php +23 -23
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/PluginThemeFilesBase.php +16 -16
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/PluginThemeVersionsBase.php +11 -11
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php +47 -29
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/VersionsBase.php +0 -4
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Download.php +19 -19
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Files.php +4 -8
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php +21 -25
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Versions.php +18 -21
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Api.php +0 -2
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Base.php +10 -14
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Download.php +10 -14
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Files.php +23 -27
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php +23 -27
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Versions.php +6 -6
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Api.php +3 -5
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Base.php +15 -19
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Download.php +10 -14
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Files.php +22 -27
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Repo.php +20 -24
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Versions.php +9 -9
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Base.php +0 -4
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Download.php +18 -18
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Files.php +8 -12
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php +28 -32
- src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Versions.php +19 -26
- templates/twig/snippets/plugin_vulnerability.twig +5 -1
cl.json
CHANGED
@@ -146,6 +146,18 @@
|
|
146 |
"title": "Yubikey 2FA verification was failing with a nonce less than 16 characters. Who knew?",
|
147 |
"description": [],
|
148 |
"patch": "12.0.9"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
]
|
151 |
},
|
146 |
"title": "Yubikey 2FA verification was failing with a nonce less than 16 characters. Who knew?",
|
147 |
"description": [],
|
148 |
"patch": "12.0.9"
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"type": "fixed",
|
152 |
+
"title": "A few minor fixes, along with slight optimisation of NotBot JS.",
|
153 |
+
"description": [],
|
154 |
+
"patch": "12.0.11"
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"type": "fixed",
|
158 |
+
"title": "Issue with managing Shield Central profiles.",
|
159 |
+
"description": [],
|
160 |
+
"patch": "12.0.11"
|
161 |
}
|
162 |
]
|
163 |
},
|
icwp-wpsf.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
-
* Version: 12.0.
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
3 |
* Plugin Name: Shield Security
|
4 |
* Plugin URI: https://shsec.io/2f
|
5 |
* Description: Powerful, Easy-To-Use #1 Rated WordPress Security System
|
6 |
+
* Version: 12.0.11
|
7 |
* Text Domain: wp-simple-firewall
|
8 |
* Domain Path: /languages
|
9 |
* Author: Shield Security
|
plugin-spec.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "12.0.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
@@ -105,7 +105,7 @@
|
|
105 |
]
|
106 |
},
|
107 |
"datatables-bootstrap": {
|
108 |
-
"url": "https://cdn.datatables.net/1.11.
|
109 |
"deps": [
|
110 |
"bootstrap"
|
111 |
]
|
@@ -214,14 +214,14 @@
|
|
214 |
]
|
215 |
},
|
216 |
"datatables": {
|
217 |
-
"url": "https://cdn.datatables.net/1.11.
|
218 |
"deps": [
|
219 |
"bootstrap",
|
220 |
"wp-jquery"
|
221 |
]
|
222 |
},
|
223 |
"datatables-bootstrap": {
|
224 |
-
"url": "https://cdn.datatables.net/1.11.
|
225 |
"deps": [
|
226 |
"datatables"
|
227 |
]
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "12.0.11",
|
4 |
+
"release_timestamp": 1633596600,
|
5 |
+
"build": "202110.0701",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
105 |
]
|
106 |
},
|
107 |
"datatables-bootstrap": {
|
108 |
+
"url": "https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css",
|
109 |
"deps": [
|
110 |
"bootstrap"
|
111 |
]
|
214 |
]
|
215 |
},
|
216 |
"datatables": {
|
217 |
+
"url": "https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js",
|
218 |
"deps": [
|
219 |
"bootstrap",
|
220 |
"wp-jquery"
|
221 |
]
|
222 |
},
|
223 |
"datatables-bootstrap": {
|
224 |
+
"url": "https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap4.min.js",
|
225 |
"deps": [
|
226 |
"datatables"
|
227 |
]
|
plugin.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
{
|
2 |
"properties": {
|
3 |
-
"version": "12.0.
|
4 |
-
"release_timestamp":
|
5 |
-
"build": "
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
@@ -105,7 +105,7 @@
|
|
105 |
]
|
106 |
},
|
107 |
"datatables-bootstrap": {
|
108 |
-
"url": "https://cdn.datatables.net/1.11.
|
109 |
"deps": [
|
110 |
"bootstrap"
|
111 |
]
|
@@ -214,14 +214,14 @@
|
|
214 |
]
|
215 |
},
|
216 |
"datatables": {
|
217 |
-
"url": "https://cdn.datatables.net/1.11.
|
218 |
"deps": [
|
219 |
"bootstrap",
|
220 |
"wp-jquery"
|
221 |
]
|
222 |
},
|
223 |
"datatables-bootstrap": {
|
224 |
-
"url": "https://cdn.datatables.net/1.11.
|
225 |
"deps": [
|
226 |
"datatables"
|
227 |
]
|
1 |
{
|
2 |
"properties": {
|
3 |
+
"version": "12.0.11",
|
4 |
+
"release_timestamp": 1633596600,
|
5 |
+
"build": "202110.0701",
|
6 |
"slug_parent": "icwp",
|
7 |
"slug_plugin": "wpsf",
|
8 |
"human_name": "Shield Security",
|
105 |
]
|
106 |
},
|
107 |
"datatables-bootstrap": {
|
108 |
+
"url": "https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap4.min.css",
|
109 |
"deps": [
|
110 |
"bootstrap"
|
111 |
]
|
214 |
]
|
215 |
},
|
216 |
"datatables": {
|
217 |
+
"url": "https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js",
|
218 |
"deps": [
|
219 |
"bootstrap",
|
220 |
"wp-jquery"
|
221 |
]
|
222 |
},
|
223 |
"datatables-bootstrap": {
|
224 |
+
"url": "https://cdn.datatables.net/1.11.3/js/dataTables.bootstrap4.min.js",
|
225 |
"deps": [
|
226 |
"datatables"
|
227 |
]
|
readme.txt
CHANGED
@@ -8,7 +8,7 @@ Requires at least: 3.7
|
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
-
Stable tag: 12.0.
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
8 |
Requires PHP: 7.0
|
9 |
Recommended PHP: 7.4
|
10 |
Tested up to: 5.8
|
11 |
+
Stable tag: 12.0.11
|
12 |
|
13 |
No-Nonsense Security Hardening that protects WordPress against hackers, malicious bots, and spammers (no captchas!). Now with exclusive ShieldNET Technology.
|
14 |
|
resources/images/bootstrap/graph-up.svg
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-graph-up" viewBox="0 0 16 16">
|
2 |
-
<path fill-rule="evenodd" d="M0 0h1v15h15v1H0V0zm10 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V4.9l-3.613 4.417a.5.5 0 0 1-.74.037L7.06 6.767l-3.656 5.027a.5.5 0 0 1-.808-.588l4-5.5a.5.5 0 0 1 .758-.06l2.609 2.61L13.445 4H10.5a.5.5 0 0 1-.5-.5z"/>
|
3 |
</svg>
|
1 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-graph-up" viewBox="0 0 16 16">
|
2 |
+
<path fill-rule="evenodd" d="M0 0h1v15h15v1H0V0zm10 3.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V4.9l-3.613 4.417a.5.5 0 0 1-.74.037L7.06 6.767l-3.656 5.027a.5.5 0 0 1-.808-.588l4-5.5a.5.5 0 0 1 .758-.06l2.609 2.61L13.445 4H10.5a.5.5 0 0 1-.5-.5z"/>
|
3 |
</svg>
|
resources/images/bootstrap/people.svg
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16">
|
2 |
-
<path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816zM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275zM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/>
|
3 |
</svg>
|
1 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16">
|
2 |
+
<path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816zM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275zM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/>
|
3 |
</svg>
|
resources/images/bootstrap/tools.svg
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-tools" viewBox="0 0 16 16">
|
2 |
-
<path d="M1 0 0 1l2.2 3.081a1 1 0 0 0 .815.419h.07a1 1 0 0 1 .708.293l2.675 2.675-2.617 2.654A3.003 3.003 0 0 0 0 13a3 3 0 1 0 5.878-.851l2.654-2.617.968.968-.305.914a1 1 0 0 0 .242 1.023l3.356 3.356a1 1 0 0 0 1.414 0l1.586-1.586a1 1 0 0 0 0-1.414l-3.356-3.356a1 1 0 0 0-1.023-.242L10.5 9.5l-.96-.96 2.68-2.643A3.005 3.005 0 0 0 16 3c0-.269-.035-.53-.102-.777l-2.14 2.141L12 4l-.364-1.757L13.777.102a3 3 0 0 0-3.675 3.68L7.462 6.46 4.793 3.793a1 1 0 0 1-.293-.707v-.071a1 1 0 0 0-.419-.814L1 0zm9.646 10.646a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708zM3 11l.471.242.529.026.287.445.445.287.026.529L5 13l-.242.471-.026.529-.445.287-.287.445-.529.026L3 15l-.471-.242L2 14.732l-.287-.445L1.268 14l-.026-.529L1 13l.242-.471.026-.529.445-.287.287-.445.529-.026L3 11z"/>
|
3 |
</svg>
|
1 |
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-tools" viewBox="0 0 16 16">
|
2 |
+
<path d="M1 0 0 1l2.2 3.081a1 1 0 0 0 .815.419h.07a1 1 0 0 1 .708.293l2.675 2.675-2.617 2.654A3.003 3.003 0 0 0 0 13a3 3 0 1 0 5.878-.851l2.654-2.617.968.968-.305.914a1 1 0 0 0 .242 1.023l3.356 3.356a1 1 0 0 0 1.414 0l1.586-1.586a1 1 0 0 0 0-1.414l-3.356-3.356a1 1 0 0 0-1.023-.242L10.5 9.5l-.96-.96 2.68-2.643A3.005 3.005 0 0 0 16 3c0-.269-.035-.53-.102-.777l-2.14 2.141L12 4l-.364-1.757L13.777.102a3 3 0 0 0-3.675 3.68L7.462 6.46 4.793 3.793a1 1 0 0 1-.293-.707v-.071a1 1 0 0 0-.419-.814L1 0zm9.646 10.646a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708zM3 11l.471.242.529.026.287.445.445.287.026.529L5 13l-.242.471-.026.529-.445.287-.287.445-.529.026L3 15l-.471-.242L2 14.732l-.287-.445L1.268 14l-.026-.529L1 13l.242-.471.026-.529.445-.287.287-.445.529-.026L3 11z"/>
|
3 |
</svg>
|
resources/js/shield/notbot.js
CHANGED
@@ -2,7 +2,8 @@ if ( typeof Shield_Antibot === typeof undefined && typeof shield_vars_notbotjs !
|
|
2 |
|
3 |
var Shield_Antibot = new function () {
|
4 |
|
5 |
-
|
|
|
6 |
|
7 |
var domReady = function ( fn ) {
|
8 |
if ( document.readyState !== 'loading' ) {
|
@@ -22,47 +23,58 @@ if ( typeof Shield_Antibot === typeof undefined && typeof shield_vars_notbotjs !
|
|
22 |
this.initialise = function () {
|
23 |
/**
|
24 |
* @since 11.2 we no longer wait until DOM is ready.
|
|
|
25 |
* This is mainly AJAX so it's asynchronous and wont hold up any other part of the page load.
|
26 |
* Early execution also helps mitigate the case where login requests are
|
27 |
* sent quickly, before browser has fired NotBot request.
|
28 |
*/
|
29 |
if ( shield_vars_notbotjs.flags.run ) {
|
30 |
-
|
31 |
}
|
32 |
/**
|
33 |
* @since 11.2 this script is only loaded if a not bot signal doesn't exist for this IP.
|
34 |
-
* This removes the need for cookies - as used by fire()
|
35 |
*/
|
36 |
domReady( function () {
|
37 |
// fire();
|
38 |
} );
|
39 |
};
|
40 |
|
|
|
|
|
|
|
|
|
41 |
var fire = function () {
|
42 |
-
|
43 |
-
|
44 |
-
if ( current === undefined ) {
|
45 |
-
sendRequest = true;
|
46 |
-
}
|
47 |
-
else {
|
48 |
-
var remaining = current.split( "z" )[ 0 ] - Math.floor( Date.now() / 1000 );
|
49 |
-
if ( remaining < 60 ) {
|
50 |
-
sendRequest = true;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
if ( sendRequest && request_count < 11 ) {
|
55 |
sendReq();
|
56 |
}
|
57 |
-
|
|
|
|
|
58 |
};
|
59 |
|
60 |
var sendReq = function ( name ) {
|
61 |
-
var xhttp = new XMLHttpRequest();
|
62 |
-
xhttp.open( "POST", shield_vars_notbotjs.hrefs.ajax, true );
|
63 |
-
xhttp.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded;' );
|
64 |
-
xhttp.send( shield_vars_notbotjs.ajax.not_bot );
|
65 |
request_count++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
};
|
67 |
|
68 |
var getCookie = function ( name ) {
|
2 |
|
3 |
var Shield_Antibot = new function () {
|
4 |
|
5 |
+
let request_count = 0;
|
6 |
+
let can_continue = true;
|
7 |
|
8 |
var domReady = function ( fn ) {
|
9 |
if ( document.readyState !== 'loading' ) {
|
23 |
this.initialise = function () {
|
24 |
/**
|
25 |
* @since 11.2 we no longer wait until DOM is ready.
|
26 |
+
* @since 12.0.10 we return to using cookies to optimise whether the AJAX request is sent.
|
27 |
* This is mainly AJAX so it's asynchronous and wont hold up any other part of the page load.
|
28 |
* Early execution also helps mitigate the case where login requests are
|
29 |
* sent quickly, before browser has fired NotBot request.
|
30 |
*/
|
31 |
if ( shield_vars_notbotjs.flags.run ) {
|
32 |
+
fire();
|
33 |
}
|
34 |
/**
|
35 |
* @since 11.2 this script is only loaded if a not bot signal doesn't exist for this IP.
|
|
|
36 |
*/
|
37 |
domReady( function () {
|
38 |
// fire();
|
39 |
} );
|
40 |
};
|
41 |
|
42 |
+
/**
|
43 |
+
* @since 12.0.10 - rather than auto send request every page load, check for cookie repeatedly and send if
|
44 |
+
* absent.
|
45 |
+
*/
|
46 |
var fire = function () {
|
47 |
+
let current = getCookie( 'icwp-wpsf-notbot' );
|
48 |
+
if ( current === undefined || typeof (current) === 'undefined' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
sendReq();
|
50 |
}
|
51 |
+
if ( can_continue && request_count < 10 ) {
|
52 |
+
window.setTimeout( fire, 10000 );
|
53 |
+
}
|
54 |
};
|
55 |
|
56 |
var sendReq = function ( name ) {
|
|
|
|
|
|
|
|
|
57 |
request_count++;
|
58 |
+
|
59 |
+
let xhr = new XMLHttpRequest();
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Ensures that if there's an error with the AJAX, we don't continue
|
63 |
+
* to keep trying the requests.
|
64 |
+
*/
|
65 |
+
xhr.onreadystatechange = function () {
|
66 |
+
if ( xhr.readyState === 4 ) {
|
67 |
+
let resp = JSON.parse( xhr.response );
|
68 |
+
can_continue = resp && resp.success;
|
69 |
+
if ( !can_continue ) {
|
70 |
+
console.log( xhr.response );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
xhr.open( "POST", shield_vars_notbotjs.hrefs.ajax, true );
|
76 |
+
xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded;' );
|
77 |
+
xhr.send( shield_vars_notbotjs.ajax.not_bot );
|
78 |
};
|
79 |
|
80 |
var getCookie = function ( name ) {
|
src/lib/src/Modules/Data/DB/ReqLogs/LoadLogs.php
CHANGED
@@ -38,7 +38,8 @@ class LoadLogs {
|
|
38 |
%s
|
39 |
INNER JOIN `%s` as `ips`
|
40 |
ON req.ip_ref = ips.id
|
41 |
-
ORDER BY `req`.created_at DESC
|
|
|
42 |
$mod->getDbH_ReqLogs()->getTableSchema()->table,
|
43 |
empty( $ip ) ? '' : sprintf( "WHERE `ips`.ip=INET6_ATON('%s')", $ip ),
|
44 |
$this->getCon()->getModule_Data()->getDbH_IPs()->getTableSchema()->table
|
38 |
%s
|
39 |
INNER JOIN `%s` as `ips`
|
40 |
ON req.ip_ref = ips.id
|
41 |
+
ORDER BY `req`.created_at DESC
|
42 |
+
LIMIT 1000;',
|
43 |
$mod->getDbH_ReqLogs()->getTableSchema()->table,
|
44 |
empty( $ip ) ? '' : sprintf( "WHERE `ips`.ip=INET6_ATON('%s')", $ip ),
|
45 |
$this->getCon()->getModule_Data()->getDbH_IPs()->getTableSchema()->table
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/File.php
CHANGED
@@ -6,8 +6,6 @@ use FernleafSystems\Utilities\Data\Adapter\DynPropertiesClass;
|
|
6 |
use FernleafSystems\Wordpress\Services\Services;
|
7 |
|
8 |
/**
|
9 |
-
* Class BaseFile
|
10 |
-
* @package FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker
|
11 |
* @property string $dir
|
12 |
* @property string $file
|
13 |
* @property int $max_levels
|
6 |
use FernleafSystems\Wordpress\Services\Services;
|
7 |
|
8 |
/**
|
|
|
|
|
9 |
* @property string $dir
|
10 |
* @property string $file
|
11 |
* @property int $max_levels
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/FileLockerController.php
CHANGED
@@ -142,7 +142,26 @@ class FileLockerController {
|
|
142 |
|
143 |
// 2. Create any outstanding locks.
|
144 |
if ( is_main_network() ) {
|
145 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
}
|
148 |
|
@@ -151,7 +170,7 @@ class FileLockerController {
|
|
151 |
* This ensures our API isn't bombarded by sites that, for some reason, fail to store the lock in the DB.
|
152 |
*/
|
153 |
private function runLocksCreation() {
|
154 |
-
/** @var
|
155 |
$opts = $this->getOptions();
|
156 |
$filesToLock = $opts->getFilesToLock();
|
157 |
|
@@ -163,7 +182,9 @@ class FileLockerController {
|
|
163 |
try {
|
164 |
$lockCreated = ( new Ops\CreateFileLocks() )
|
165 |
->setMod( $this->getMod() )
|
166 |
-
->setWorkingFile(
|
|
|
|
|
167 |
->create();
|
168 |
}
|
169 |
catch ( \Exception $e ) {
|
@@ -183,50 +204,10 @@ class FileLockerController {
|
|
183 |
* @param string $fileKey
|
184 |
* @return File
|
185 |
* @throws \Exception
|
|
|
186 |
*/
|
187 |
private function getFile( string $fileKey ) :File {
|
188 |
-
|
189 |
-
$maxPaths = 1;
|
190 |
-
switch ( $fileKey ) {
|
191 |
-
case 'wpconfig':
|
192 |
-
$fileKey = 'wp-config.php';
|
193 |
-
$maxPaths = 1;
|
194 |
-
$levels = $isSplitWpUrl ? 3 : 2;
|
195 |
-
$openBaseDir = ini_get( 'open_basedir' );
|
196 |
-
if ( !empty( $openBaseDir ) ) {
|
197 |
-
$levels--;
|
198 |
-
}
|
199 |
-
break;
|
200 |
-
|
201 |
-
case 'root_htaccess':
|
202 |
-
$fileKey = '.htaccess';
|
203 |
-
$levels = $isSplitWpUrl ? 2 : 1;
|
204 |
-
break;
|
205 |
-
|
206 |
-
case 'root_webconfig':
|
207 |
-
$fileKey = 'Web.Config';
|
208 |
-
$levels = $isSplitWpUrl ? 2 : 1;
|
209 |
-
break;
|
210 |
-
|
211 |
-
case 'root_index':
|
212 |
-
$fileKey = 'index.php';
|
213 |
-
$levels = $isSplitWpUrl ? 2 : 1;
|
214 |
-
break;
|
215 |
-
default:
|
216 |
-
if ( Services::WpFs()->isAbsPath( $fileKey ) && Services::WpFs()->isFile( $fileKey ) ) {
|
217 |
-
$levels = 1;
|
218 |
-
$maxPaths = 1;
|
219 |
-
}
|
220 |
-
else {
|
221 |
-
throw new \Exception( 'Not a supported file lock type' );
|
222 |
-
}
|
223 |
-
break;
|
224 |
-
}
|
225 |
-
|
226 |
-
$file = new File( $fileKey );
|
227 |
-
$file->max_levels = $levels;
|
228 |
-
$file->max_paths = $maxPaths;
|
229 |
-
return $file;
|
230 |
}
|
231 |
|
232 |
protected function getState() :array {
|
142 |
|
143 |
// 2. Create any outstanding locks.
|
144 |
if ( is_main_network() ) {
|
145 |
+
$this->maybeRunLocksCreation();
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
private function maybeRunLocksCreation() {
|
150 |
+
if ( ( new Lib\FileLocker\Ops\HasFileLocksToCreate() )->setMod( $this->getMod() )->run() ) {
|
151 |
+
$con = $this->getCon();
|
152 |
+
|
153 |
+
if ( !Services::WpGeneral()->isCron() ) {
|
154 |
+
if ( !wp_next_scheduled( $con->prefix( 'create_file_locks' ) ) ) {
|
155 |
+
wp_schedule_single_event(
|
156 |
+
Services::Request()->ts() + 60,
|
157 |
+
$con->prefix( 'create_file_locks' )
|
158 |
+
);
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
add_action( $this->getCon()->prefix( 'create_file_locks' ), function () {
|
163 |
+
$this->runLocksCreation();
|
164 |
+
} );
|
165 |
}
|
166 |
}
|
167 |
|
170 |
* This ensures our API isn't bombarded by sites that, for some reason, fail to store the lock in the DB.
|
171 |
*/
|
172 |
private function runLocksCreation() {
|
173 |
+
/** @var HackGuard\Options $opts */
|
174 |
$opts = $this->getOptions();
|
175 |
$filesToLock = $opts->getFilesToLock();
|
176 |
|
182 |
try {
|
183 |
$lockCreated = ( new Ops\CreateFileLocks() )
|
184 |
->setMod( $this->getMod() )
|
185 |
+
->setWorkingFile(
|
186 |
+
( new Lib\FileLocker\Ops\BuildFileFromFileKey() )->build( $fileKey )
|
187 |
+
)
|
188 |
->create();
|
189 |
}
|
190 |
catch ( \Exception $e ) {
|
204 |
* @param string $fileKey
|
205 |
* @return File
|
206 |
* @throws \Exception
|
207 |
+
* @deprecated 12.0.10
|
208 |
*/
|
209 |
private function getFile( string $fileKey ) :File {
|
210 |
+
return ( new Lib\FileLocker\Ops\BuildFileFromFileKey() )->build( $fileKey );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
}
|
212 |
|
213 |
protected function getState() :array {
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php
CHANGED
@@ -26,10 +26,10 @@ class BaseOps {
|
|
26 |
*/
|
27 |
protected function findLockRecordForFile() {
|
28 |
$theLock = null;
|
29 |
-
foreach ( $this->file->getPossiblePaths() as $
|
30 |
-
foreach ( $this->getFileLocks() as $
|
31 |
-
if ( $
|
32 |
-
$theLock = $
|
33 |
break;
|
34 |
}
|
35 |
}
|
26 |
*/
|
27 |
protected function findLockRecordForFile() {
|
28 |
$theLock = null;
|
29 |
+
foreach ( $this->file->getPossiblePaths() as $path ) {
|
30 |
+
foreach ( $this->getFileLocks() as $maybeLock ) {
|
31 |
+
if ( $maybeLock->file === $path ) {
|
32 |
+
$theLock = $maybeLock;
|
33 |
break;
|
34 |
}
|
35 |
}
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildFileFromFileKey.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker\Ops;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker\File;
|
6 |
+
use FernleafSystems\Wordpress\Services\Services;
|
7 |
+
|
8 |
+
class BuildFileFromFileKey {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @throws \Exception
|
12 |
+
*/
|
13 |
+
public function build( string $fileKey ) :File {
|
14 |
+
$isSplitWpUrl = false; // TODO: is split URL?
|
15 |
+
$maxPaths = 1;
|
16 |
+
switch ( $fileKey ) {
|
17 |
+
case 'wpconfig':
|
18 |
+
$fileKey = 'wp-config.php';
|
19 |
+
$maxPaths = 1;
|
20 |
+
$levels = $isSplitWpUrl ? 3 : 2;
|
21 |
+
$openBaseDir = ini_get( 'open_basedir' );
|
22 |
+
if ( !empty( $openBaseDir ) ) {
|
23 |
+
$levels--;
|
24 |
+
}
|
25 |
+
break;
|
26 |
+
|
27 |
+
case 'root_htaccess':
|
28 |
+
$fileKey = '.htaccess';
|
29 |
+
$levels = $isSplitWpUrl ? 2 : 1;
|
30 |
+
break;
|
31 |
+
|
32 |
+
case 'root_webconfig':
|
33 |
+
$fileKey = 'Web.Config';
|
34 |
+
$levels = $isSplitWpUrl ? 2 : 1;
|
35 |
+
break;
|
36 |
+
|
37 |
+
case 'root_index':
|
38 |
+
$fileKey = 'index.php';
|
39 |
+
$levels = $isSplitWpUrl ? 2 : 1;
|
40 |
+
break;
|
41 |
+
default:
|
42 |
+
if ( Services::WpFs()->isAbsPath( $fileKey ) && Services::WpFs()->isFile( $fileKey ) ) {
|
43 |
+
$levels = 1;
|
44 |
+
$maxPaths = 1;
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
throw new \Exception( 'Not a supported file lock type' );
|
48 |
+
}
|
49 |
+
break;
|
50 |
+
}
|
51 |
+
|
52 |
+
$file = new File( $fileKey );
|
53 |
+
$file->max_levels = $levels;
|
54 |
+
$file->max_paths = $maxPaths;
|
55 |
+
return $file;
|
56 |
+
}
|
57 |
+
}
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php
CHANGED
@@ -6,10 +6,6 @@ use FernleafSystems\Wordpress\Plugin\Shield\Databases\FileLocker;
|
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\ModCon;
|
7 |
use FernleafSystems\Wordpress\Services\Services;
|
8 |
|
9 |
-
/**
|
10 |
-
* Class CreateFileLocks
|
11 |
-
* @package FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker\Ops
|
12 |
-
*/
|
13 |
class CreateFileLocks extends BaseOps {
|
14 |
|
15 |
/**
|
@@ -18,14 +14,7 @@ class CreateFileLocks extends BaseOps {
|
|
18 |
public function create() :bool {
|
19 |
$pathsProcessed = false;
|
20 |
foreach ( $this->file->getExistingPossiblePaths() as $path ) {
|
21 |
-
$
|
22 |
-
foreach ( $this->getFileLocks() as $maybeLock ) {
|
23 |
-
if ( $maybeLock->file === $path ) {
|
24 |
-
$theLock = $maybeLock;
|
25 |
-
break;
|
26 |
-
}
|
27 |
-
}
|
28 |
-
if ( !$theLock instanceof FileLocker\EntryVO ) {
|
29 |
$this->processPath( $path );
|
30 |
$pathsProcessed = true;
|
31 |
}
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\ModCon;
|
7 |
use FernleafSystems\Wordpress\Services\Services;
|
8 |
|
|
|
|
|
|
|
|
|
9 |
class CreateFileLocks extends BaseOps {
|
10 |
|
11 |
/**
|
14 |
public function create() :bool {
|
15 |
$pathsProcessed = false;
|
16 |
foreach ( $this->file->getExistingPossiblePaths() as $path ) {
|
17 |
+
if ( empty( $this->findLockRecordForFile() ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
$this->processPath( $path );
|
19 |
$pathsProcessed = true;
|
20 |
}
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/HasFileLocksToCreate.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker\Ops;
|
4 |
+
|
5 |
+
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Options;
|
6 |
+
|
7 |
+
class HasFileLocksToCreate extends BaseOps {
|
8 |
+
|
9 |
+
public function run() :bool {
|
10 |
+
/** @var Options $opts */
|
11 |
+
$opts = $this->getOptions();
|
12 |
+
|
13 |
+
$hasLockToCreate = false;
|
14 |
+
foreach ( $opts->getFilesToLock() as $fileKey ) {
|
15 |
+
try {
|
16 |
+
$file = ( new BuildFileFromFileKey() )->build( $fileKey );
|
17 |
+
$lock = $this->setWorkingFile( $file )->findLockRecordForFile();
|
18 |
+
if ( empty( $lock ) ) {
|
19 |
+
$hasLockToCreate = true;
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
catch ( \Exception $e ) {
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
return $hasLockToCreate;
|
28 |
+
}
|
29 |
+
}
|
src/lib/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php
CHANGED
@@ -6,10 +6,6 @@ use FernleafSystems\Wordpress\Plugin\Shield\Databases\FileLocker;
|
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\ModCon;
|
7 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
|
8 |
|
9 |
-
/**
|
10 |
-
* Class LoadFileLocks
|
11 |
-
* @package FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Lib\FileLocker\Ops
|
12 |
-
*/
|
13 |
class LoadFileLocks {
|
14 |
|
15 |
use ModConsumer;
|
6 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\ModCon;
|
7 |
use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
|
8 |
|
|
|
|
|
|
|
|
|
9 |
class LoadFileLocks {
|
10 |
|
11 |
use ModConsumer;
|
src/lib/src/Modules/HackGuard/Scan/Utilities/WpvAddPluginRows.php
CHANGED
@@ -124,10 +124,19 @@ class WpvAddPluginRows {
|
|
124 |
],
|
125 |
'vars' => [
|
126 |
'vulns' => array_map(
|
127 |
-
function ( $vuln ) {
|
128 |
$data = $vuln->getRawData();
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
return $data;
|
133 |
},
|
124 |
],
|
125 |
'vars' => [
|
126 |
'vulns' => array_map(
|
127 |
+
function ( $vuln ) use ( $pluginFile ) {
|
128 |
$data = $vuln->getRawData();
|
129 |
+
|
130 |
+
$plugin = Services::WpPlugins()->getPluginAsVo( $pluginFile );
|
131 |
+
if ( !empty( $plugin ) ) {
|
132 |
+
$data[ 'url' ] = add_query_arg(
|
133 |
+
[
|
134 |
+
'type' => $plugin->asset_type,
|
135 |
+
'slug' => $plugin->slug,
|
136 |
+
'version' => $plugin->Version,
|
137 |
+
],
|
138 |
+
'https://shsec.io/shieldvulnerabilitylookup'
|
139 |
+
);
|
140 |
}
|
141 |
return $data;
|
142 |
},
|
src/lib/src/Modules/IPs/Lib/Bots/BotSignalsController.php
CHANGED
@@ -55,7 +55,8 @@ class BotSignalsController extends ExecOnceModConsumer {
|
|
55 |
|
56 |
public function getHandlerNotBot() :NotBot\NotBotHandler {
|
57 |
if ( !isset( $this->handlerNotBot ) ) {
|
58 |
-
$this->handlerNotBot = ( new NotBot\NotBotHandler(
|
|
|
59 |
}
|
60 |
return $this->handlerNotBot;
|
61 |
}
|
55 |
|
56 |
public function getHandlerNotBot() :NotBot\NotBotHandler {
|
57 |
if ( !isset( $this->handlerNotBot ) ) {
|
58 |
+
$this->handlerNotBot = ( new NotBot\NotBotHandler( true ) )
|
59 |
+
->setMod( $this->getMod() );
|
60 |
}
|
61 |
return $this->handlerNotBot;
|
62 |
}
|
src/lib/src/Modules/IPs/Lib/Bots/NotBot/NotBotHandler.php
CHANGED
@@ -8,7 +8,7 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
8 |
|
9 |
class NotBotHandler extends ExecOnceModConsumer {
|
10 |
|
11 |
-
const LIFETIME =
|
12 |
const SLUG = 'notbot';
|
13 |
|
14 |
private $useCookies;
|
@@ -27,7 +27,6 @@ class NotBotHandler extends ExecOnceModConsumer {
|
|
27 |
->execute();
|
28 |
$this->registerFrontPageLoad();
|
29 |
$this->registerLoginPageLoad();
|
30 |
-
$this->maybeDeleteCookie();
|
31 |
}
|
32 |
|
33 |
private function registerFrontPageLoad() {
|
@@ -56,16 +55,10 @@ class NotBotHandler extends ExecOnceModConsumer {
|
|
56 |
} );
|
57 |
}
|
58 |
|
59 |
-
private function maybeDeleteCookie() {
|
60 |
-
$cookie = $this->getCookieParts();
|
61 |
-
if ( !empty( $cookie ) && $cookie[ 'ts' ] - Services::Request()->ts() < 300 ) {
|
62 |
-
$this->clearCookie();
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
public function registerAsNotBot() :bool {
|
67 |
if ( $this->useCookies ) {
|
68 |
-
$ts = Services::Request()->ts() +
|
|
|
69 |
Services::Response()->cookieSet(
|
70 |
$this->getMod()->prefix( self::SLUG ),
|
71 |
sprintf( '%sz%s', $ts, $this->getHashForVisitorTS( $ts ) ),
|
8 |
|
9 |
class NotBotHandler extends ExecOnceModConsumer {
|
10 |
|
11 |
+
const LIFETIME = 60;
|
12 |
const SLUG = 'notbot';
|
13 |
|
14 |
private $useCookies;
|
27 |
->execute();
|
28 |
$this->registerFrontPageLoad();
|
29 |
$this->registerLoginPageLoad();
|
|
|
30 |
}
|
31 |
|
32 |
private function registerFrontPageLoad() {
|
55 |
} );
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
public function registerAsNotBot() :bool {
|
59 |
if ( $this->useCookies ) {
|
60 |
+
$ts = Services::Request()->ts() +
|
61 |
+
apply_filters( 'shield/notbot_cookie_life', self::LIFETIME );
|
62 |
Services::Response()->cookieSet(
|
63 |
$this->getMod()->prefix( self::SLUG ),
|
64 |
sprintf( '%sz%s', $ts, $this->getHashForVisitorTS( $ts ) ),
|
src/lib/vendor/composer/autoload_classmap.php
CHANGED
@@ -379,9 +379,11 @@ return array(
|
|
379 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\AssessLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/AssessLocks.php',
|
380 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BaseOps' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php',
|
381 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildEncryptedFilePayload' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildEncryptedFilePayload.php',
|
|
|
382 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\CreateFileLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php',
|
383 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\DeleteFileLock' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/DeleteFileLock.php',
|
384 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\Diff' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/Diff.php',
|
|
|
385 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\LoadFileLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php',
|
386 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\PerformAction' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/PerformAction.php',
|
387 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\ReadOriginalFileContent' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/ReadOriginalFileContent.php',
|
@@ -1000,6 +1002,7 @@ return array(
|
|
1000 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\LoadFromCache' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/LoadFromCache.php',
|
1001 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\StoreToCache' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/StoreToCache.php',
|
1002 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Compare\\CompareHash' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php',
|
|
|
1003 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLineFromFile' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLineFromFile.php',
|
1004 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLinesFromFile' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLinesFromFile.php',
|
1005 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\GetFileAsArray' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/GetFileAsArray.php',
|
379 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\AssessLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/AssessLocks.php',
|
380 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BaseOps' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php',
|
381 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildEncryptedFilePayload' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildEncryptedFilePayload.php',
|
382 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildFileFromFileKey' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildFileFromFileKey.php',
|
383 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\CreateFileLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php',
|
384 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\DeleteFileLock' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/DeleteFileLock.php',
|
385 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\Diff' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/Diff.php',
|
386 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\HasFileLocksToCreate' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/HasFileLocksToCreate.php',
|
387 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\LoadFileLocks' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php',
|
388 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\PerformAction' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/PerformAction.php',
|
389 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\ReadOriginalFileContent' => $baseDir . '/src/Modules/HackGuard/Lib/FileLocker/Ops/ReadOriginalFileContent.php',
|
1002 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\LoadFromCache' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/LoadFromCache.php',
|
1003 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\StoreToCache' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/StoreToCache.php',
|
1004 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Compare\\CompareHash' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php',
|
1005 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ConvertLineEndings' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/ConvertLineEndings.php',
|
1006 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLineFromFile' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLineFromFile.php',
|
1007 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLinesFromFile' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLinesFromFile.php',
|
1008 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\GetFileAsArray' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/File/GetFileAsArray.php',
|
src/lib/vendor/composer/autoload_static.php
CHANGED
@@ -565,9 +565,11 @@ class ComposerStaticInit4fc2c6daaffaf40b64b79b6d26830171
|
|
565 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\AssessLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/AssessLocks.php',
|
566 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BaseOps' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php',
|
567 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildEncryptedFilePayload' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildEncryptedFilePayload.php',
|
|
|
568 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\CreateFileLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php',
|
569 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\DeleteFileLock' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/DeleteFileLock.php',
|
570 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\Diff' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/Diff.php',
|
|
|
571 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\LoadFileLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php',
|
572 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\PerformAction' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/PerformAction.php',
|
573 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\ReadOriginalFileContent' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/ReadOriginalFileContent.php',
|
@@ -1186,6 +1188,7 @@ class ComposerStaticInit4fc2c6daaffaf40b64b79b6d26830171
|
|
1186 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\LoadFromCache' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/LoadFromCache.php',
|
1187 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\StoreToCache' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/StoreToCache.php',
|
1188 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Compare\\CompareHash' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php',
|
|
|
1189 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLineFromFile' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLineFromFile.php',
|
1190 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLinesFromFile' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLinesFromFile.php',
|
1191 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\GetFileAsArray' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/GetFileAsArray.php',
|
565 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\AssessLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/AssessLocks.php',
|
566 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BaseOps' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BaseOps.php',
|
567 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildEncryptedFilePayload' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildEncryptedFilePayload.php',
|
568 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\BuildFileFromFileKey' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/BuildFileFromFileKey.php',
|
569 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\CreateFileLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/CreateFileLocks.php',
|
570 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\DeleteFileLock' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/DeleteFileLock.php',
|
571 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\Diff' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/Diff.php',
|
572 |
+
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\HasFileLocksToCreate' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/HasFileLocksToCreate.php',
|
573 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\LoadFileLocks' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/LoadFileLocks.php',
|
574 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\PerformAction' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/PerformAction.php',
|
575 |
'FernleafSystems\\Wordpress\\Plugin\\Shield\\Modules\\HackGuard\\Lib\\FileLocker\\Ops\\ReadOriginalFileContent' => __DIR__ . '/../..' . '/src/Modules/HackGuard/Lib/FileLocker/Ops/ReadOriginalFileContent.php',
|
1188 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\LoadFromCache' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/LoadFromCache.php',
|
1189 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Cache\\StoreToCache' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Cache/StoreToCache.php',
|
1190 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\Compare\\CompareHash' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php',
|
1191 |
+
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ConvertLineEndings' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/ConvertLineEndings.php',
|
1192 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLineFromFile' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLineFromFile.php',
|
1193 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\ExtractLinesFromFile' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/ExtractLinesFromFile.php',
|
1194 |
'FernleafSystems\\Wordpress\\Services\\Utilities\\File\\GetFileAsArray' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/File/GetFileAsArray.php',
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php
CHANGED
@@ -300,21 +300,21 @@ class Fs {
|
|
300 |
* @return string|null
|
301 |
*/
|
302 |
public function getFileContent( $sFilePath, $bIsCompressed = false ) {
|
303 |
-
$
|
304 |
$FS = $this->getWpfs();
|
305 |
if ( $FS ) {
|
306 |
-
$
|
307 |
}
|
308 |
|
309 |
-
if ( empty( $
|
310 |
-
$
|
311 |
}
|
312 |
|
313 |
-
if ( !empty( $
|
314 |
-
$
|
315 |
}
|
316 |
|
317 |
-
return $
|
318 |
}
|
319 |
|
320 |
/**
|
300 |
* @return string|null
|
301 |
*/
|
302 |
public function getFileContent( $sFilePath, $bIsCompressed = false ) {
|
303 |
+
$contents = null;
|
304 |
$FS = $this->getWpfs();
|
305 |
if ( $FS ) {
|
306 |
+
$contents = $FS->get_contents( $sFilePath );
|
307 |
}
|
308 |
|
309 |
+
if ( empty( $contents ) && function_exists( 'file_get_contents' ) ) {
|
310 |
+
$contents = file_get_contents( $sFilePath );
|
311 |
}
|
312 |
|
313 |
+
if ( !empty( $contents ) && $bIsCompressed && function_exists( 'gzinflate' ) ) {
|
314 |
+
$contents = gzinflate( $contents );
|
315 |
}
|
316 |
|
317 |
+
return $contents;
|
318 |
}
|
319 |
|
320 |
/**
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/DataManipulation.php
CHANGED
@@ -2,75 +2,73 @@
|
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Services\Utilities;
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
* @package FernleafSystems\Wordpress\Services\Utilities
|
8 |
-
*/
|
9 |
class DataManipulation {
|
10 |
|
11 |
/**
|
12 |
-
* @param string $
|
13 |
* @return string
|
14 |
*/
|
15 |
-
public function convertLineEndingsDosToLinux( $
|
16 |
-
return
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
* @param string $
|
21 |
* @return string
|
22 |
*/
|
23 |
-
public function convertLineEndingsLinuxToDos( $
|
24 |
-
return
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* @param array $
|
29 |
* @return string
|
30 |
*/
|
31 |
-
public function convertArrayToJavascriptDataString( $
|
32 |
-
$
|
33 |
-
foreach ( $
|
34 |
-
$
|
35 |
}
|
36 |
-
return trim( $
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
* @param array $
|
41 |
* @return \stdClass
|
42 |
*/
|
43 |
-
public function convertArrayToStdClass( $
|
44 |
-
$
|
45 |
-
if ( !empty( $
|
46 |
-
foreach ( $
|
47 |
-
$
|
48 |
}
|
49 |
}
|
50 |
-
return $
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* @param \stdClass $
|
55 |
* @return array
|
56 |
*/
|
57 |
-
public function convertStdClassToArray( $
|
58 |
-
return json_decode( json_encode( $
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* @param array $
|
63 |
-
* @param callable $
|
64 |
* @return array
|
65 |
*/
|
66 |
-
public function arrayMapRecursive( $
|
67 |
$aMapped = [];
|
68 |
-
foreach ( $
|
69 |
-
if ( is_array( $
|
70 |
-
$aMapped[ $
|
71 |
}
|
72 |
else {
|
73 |
-
$aMapped[ $
|
74 |
}
|
75 |
}
|
76 |
return $aMapped;
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Services\Utilities;
|
4 |
|
5 |
+
use FernleafSystems\Wordpress\Services\Utilities\File\ConvertLineEndings;
|
6 |
+
|
|
|
|
|
7 |
class DataManipulation {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $path
|
11 |
* @return string
|
12 |
*/
|
13 |
+
public function convertLineEndingsDosToLinux( $path ) :string {
|
14 |
+
return ( new ConvertLineEndings() )->fileDosToLinux( $path );
|
15 |
}
|
16 |
|
17 |
/**
|
18 |
+
* @param string $path
|
19 |
* @return string
|
20 |
*/
|
21 |
+
public function convertLineEndingsLinuxToDos( $path ) :string {
|
22 |
+
return ( new ConvertLineEndings() )->fileLinuxToDos( $path );
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
+
* @param array $toConvert
|
27 |
* @return string
|
28 |
*/
|
29 |
+
public function convertArrayToJavascriptDataString( $toConvert ) {
|
30 |
+
$asJS = '';
|
31 |
+
foreach ( $toConvert as $key => $value ) {
|
32 |
+
$asJS .= sprintf( "'%s':'%s',", $key, $value );
|
33 |
}
|
34 |
+
return trim( $asJS, ',' );
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* @param array $array
|
39 |
* @return \stdClass
|
40 |
*/
|
41 |
+
public function convertArrayToStdClass( $array ) :\stdClass {
|
42 |
+
$object = new \stdClass();
|
43 |
+
if ( !empty( $array ) && is_array( $array ) ) {
|
44 |
+
foreach ( $array as $key => $mValue ) {
|
45 |
+
$object->{$key} = $mValue;
|
46 |
}
|
47 |
}
|
48 |
+
return $object;
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* @param \stdClass $stdClass
|
53 |
* @return array
|
54 |
*/
|
55 |
+
public function convertStdClassToArray( $stdClass ) {
|
56 |
+
return json_decode( json_encode( $stdClass ), true );
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* @param array $array
|
61 |
+
* @param callable $callable
|
62 |
* @return array
|
63 |
*/
|
64 |
+
public function arrayMapRecursive( $array, $callable ) {
|
65 |
$aMapped = [];
|
66 |
+
foreach ( $array as $key => $value ) {
|
67 |
+
if ( is_array( $value ) ) {
|
68 |
+
$aMapped[ $key ] = $this->arrayMapRecursive( $value, $callable );
|
69 |
}
|
70 |
else {
|
71 |
+
$aMapped[ $key ] = call_user_func( $callable, $value );
|
72 |
}
|
73 |
}
|
74 |
return $aMapped;
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/File/Compare/CompareHash.php
CHANGED
@@ -7,90 +7,115 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
7 |
class CompareHash {
|
8 |
|
9 |
/**
|
10 |
-
* @param string $
|
11 |
-
* @param string $
|
12 |
* @return bool
|
13 |
* @throws \InvalidArgumentException
|
14 |
*/
|
15 |
-
public function isEqualFileMd5( $
|
16 |
-
if ( !Services::WpFs()->isFile( $
|
17 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
18 |
}
|
19 |
-
if ( !is_string( $
|
20 |
throw new \InvalidArgumentException( 'Provided user hash was not a string' );
|
21 |
}
|
22 |
-
|
23 |
-
$oDataManip = Services::DataManipulation();
|
24 |
-
return hash_equals( md5_file( $sPath ), $sHashToCompare )
|
25 |
-
|| hash_equals( md5( $oDataManip->convertLineEndingsDosToLinux( $sPath ) ), $sHashToCompare )
|
26 |
-
|| hash_equals( md5( $oDataManip->convertLineEndingsLinuxToDos( $sPath ) ), $sHashToCompare );
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
-
* @param string $
|
31 |
-
* @param string $
|
32 |
* @return bool
|
33 |
* @throws \InvalidArgumentException
|
34 |
*/
|
35 |
-
public function isEqualFileSha1( $
|
36 |
-
if ( !Services::WpFs()->isFile( $
|
37 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
38 |
}
|
39 |
-
if ( !is_string( $
|
40 |
throw new \InvalidArgumentException( 'Provided user hash was not a string' );
|
41 |
}
|
42 |
-
|
43 |
-
$oDataManip = Services::DataManipulation();
|
44 |
-
return hash_equals( sha1_file( $sPath ), $sHashToCompare )
|
45 |
-
|| hash_equals( sha1( $oDataManip->convertLineEndingsDosToLinux( $sPath ) ), $sHashToCompare )
|
46 |
-
|| hash_equals( sha1( $oDataManip->convertLineEndingsLinuxToDos( $sPath ) ), $sHashToCompare );
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* @param string $sPath1
|
51 |
-
* @param string $sPath2
|
52 |
-
* @return bool
|
53 |
* @throws \InvalidArgumentException
|
54 |
*/
|
55 |
-
public function
|
56 |
-
|
57 |
-
if ( !Services::WpFs()->isFile( $sPath2 ) ) {
|
58 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
59 |
}
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
$
|
64 |
-
$
|
65 |
-
|
66 |
-
)
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
73 |
/**
|
74 |
-
* @param string $sPath1
|
75 |
-
* @param string $sPath2
|
76 |
-
* @return bool
|
77 |
* @throws \InvalidArgumentException
|
78 |
*/
|
79 |
-
public function
|
80 |
-
|
81 |
-
if ( !Services::WpFs()->isFile( $sPath2 ) ) {
|
82 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
83 |
}
|
84 |
|
85 |
-
$
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
}
|
7 |
class CompareHash {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $path
|
11 |
+
* @param string $hashToCompare
|
12 |
* @return bool
|
13 |
* @throws \InvalidArgumentException
|
14 |
*/
|
15 |
+
public function isEqualFileMd5( $path, $hashToCompare ) :bool {
|
16 |
+
if ( !Services::WpFs()->isFile( $path ) ) {
|
17 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
18 |
}
|
19 |
+
if ( !is_string( $hashToCompare ) ) {
|
20 |
throw new \InvalidArgumentException( 'Provided user hash was not a string' );
|
21 |
}
|
22 |
+
return $this->isEqualFile( $path, $hashToCompare, 'md5' );
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
+
* @param string $path
|
27 |
+
* @param string $hashToCompare
|
28 |
* @return bool
|
29 |
* @throws \InvalidArgumentException
|
30 |
*/
|
31 |
+
public function isEqualFileSha1( $path, $hashToCompare ) :bool {
|
32 |
+
if ( !Services::WpFs()->isFile( $path ) ) {
|
33 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
34 |
}
|
35 |
+
if ( !is_string( $hashToCompare ) ) {
|
36 |
throw new \InvalidArgumentException( 'Provided user hash was not a string' );
|
37 |
}
|
38 |
+
return $this->isEqualFile( $path, $hashToCompare, 'sha1' );
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
|
|
|
|
|
|
42 |
* @throws \InvalidArgumentException
|
43 |
*/
|
44 |
+
public function isEqualFile( string $path, string $hashToCompare, string $algo = null ) :bool {
|
45 |
+
if ( !Services::WpFs()->isFile( $path ) ) {
|
|
|
46 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
47 |
}
|
48 |
|
49 |
+
if ( empty( $algo ) ) {
|
50 |
+
$length = strlen( $hashToCompare );
|
51 |
+
if ( $length === 40 ) {
|
52 |
+
$algo = 'sha1';
|
53 |
+
}
|
54 |
+
elseif ( $length === 64 ) {
|
55 |
+
$algo = 'sha256';
|
56 |
+
}
|
57 |
+
elseif ( $length === 32 ) {
|
58 |
+
$algo = 'md5';
|
59 |
+
}
|
60 |
+
else {
|
61 |
+
throw new \Exception( "Algo not provided and couldn't be detected." );
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
$data = Services::DataManipulation();
|
66 |
+
return hash_equals( hash_file( $algo, $path ), $hashToCompare )
|
67 |
+
|| hash_equals( hash( $algo, $data->convertLineEndingsDosToLinux( $path ) ), $hashToCompare )
|
68 |
+
|| hash_equals( hash( $algo, $data->convertLineEndingsLinuxToDos( $path ) ), $hashToCompare );
|
69 |
}
|
70 |
|
71 |
/**
|
|
|
|
|
|
|
72 |
* @throws \InvalidArgumentException
|
73 |
*/
|
74 |
+
public function isEqualFiles( string $path1, string $path2, string $algo = 'sha1' ) :bool {
|
75 |
+
if ( !Services::WpFs()->isFile( $path2 ) ) {
|
|
|
76 |
throw new \InvalidArgumentException( 'File does not exist on disk to compare' );
|
77 |
}
|
78 |
|
79 |
+
$possibleHashes = [
|
80 |
+
function () use ( $path2 ) {
|
81 |
+
return Services::WpFs()->getFileContent( $path2 );
|
82 |
+
},
|
83 |
+
function () use ( $path2 ) {
|
84 |
+
return Services::DataManipulation()->convertLineEndingsDosToLinux( $path2 );
|
85 |
+
},
|
86 |
+
function () use ( $path2 ) {
|
87 |
+
return Services::DataManipulation()->convertLineEndingsDosToLinux( $path2 );
|
88 |
+
},
|
89 |
+
];
|
90 |
+
|
91 |
+
$equals = false;
|
92 |
+
foreach ( $possibleHashes as $possibleHashFunc ) {
|
93 |
+
if ( $this->isEqualFile( $path1, hash( $algo, $possibleHashFunc() ), $algo ) ) {
|
94 |
+
$equals = true;
|
95 |
+
break;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return $equals;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @param string $path1
|
104 |
+
* @param string $path2
|
105 |
+
* @return bool
|
106 |
+
* @throws \InvalidArgumentException
|
107 |
+
*/
|
108 |
+
public function isEqualFilesMd5( $path1, $path2 ) :bool {
|
109 |
+
return $this->isEqualFiles( $path1, $path2, 'md5' );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param string $path1
|
114 |
+
* @param string $path2
|
115 |
+
* @return bool
|
116 |
+
* @throws \InvalidArgumentException
|
117 |
+
*/
|
118 |
+
public function isEqualFilesSha1( $path1, $path2 ) :bool {
|
119 |
+
return $this->isEqualFiles( $path1, $path2, 'sha1' );
|
120 |
}
|
121 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/HttpUtil.php
CHANGED
@@ -13,35 +13,35 @@ class HttpUtil {
|
|
13 |
/**
|
14 |
* @var string[]
|
15 |
*/
|
16 |
-
private $
|
17 |
|
18 |
public function __construct() {
|
19 |
-
$this->
|
20 |
add_action( 'shutdown', [ $this, 'deleteDownloads' ] );
|
21 |
}
|
22 |
|
23 |
public function deleteDownloads() {
|
24 |
-
$
|
25 |
-
foreach ( $this->
|
26 |
-
if ( $
|
27 |
-
$
|
28 |
}
|
29 |
}
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
* @param string $
|
34 |
-
* @param array $
|
35 |
* @return $this
|
36 |
* @throws \Exception
|
37 |
*/
|
38 |
-
public function checkUrl( $
|
39 |
-
$
|
40 |
-
if ( !$
|
41 |
-
throw new \Exception( $
|
42 |
}
|
43 |
|
44 |
-
if ( !in_array( $
|
45 |
throw new \Exception( 'Head Request Failed. Likely the version does not exist.' );
|
46 |
}
|
47 |
|
@@ -49,20 +49,20 @@ class HttpUtil {
|
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* @param string $
|
53 |
* @return string
|
54 |
* @throws \Exception
|
55 |
*/
|
56 |
-
public function downloadUrl( $
|
57 |
-
/** @var string|\WP_Error $
|
58 |
-
$
|
59 |
-
if ( is_wp_error( $
|
60 |
-
throw new \Exception( $
|
61 |
}
|
62 |
-
if ( !realpath( $
|
63 |
-
throw new \Exception( 'Downloaded could not be found' );
|
64 |
}
|
65 |
-
$this->
|
66 |
-
return $
|
67 |
}
|
68 |
}
|
13 |
/**
|
14 |
* @var string[]
|
15 |
*/
|
16 |
+
private $downloads;
|
17 |
|
18 |
public function __construct() {
|
19 |
+
$this->downloads = [];
|
20 |
add_action( 'shutdown', [ $this, 'deleteDownloads' ] );
|
21 |
}
|
22 |
|
23 |
public function deleteDownloads() {
|
24 |
+
$FS = Services::WpFs();
|
25 |
+
foreach ( $this->downloads as $file ) {
|
26 |
+
if ( $FS->exists( $file ) ) {
|
27 |
+
$FS->deleteFile( $file );
|
28 |
}
|
29 |
}
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* @param string $url
|
34 |
+
* @param array $validResponseCodes
|
35 |
* @return $this
|
36 |
* @throws \Exception
|
37 |
*/
|
38 |
+
public function checkUrl( $url, $validResponseCodes = [ 200, 304 ] ) {
|
39 |
+
$request = new HttpRequest();
|
40 |
+
if ( !$request->get( $url ) ) {
|
41 |
+
throw new \Exception( $request->lastError->get_error_message() );
|
42 |
}
|
43 |
|
44 |
+
if ( !in_array( $request->lastResponse->getCode(), $validResponseCodes ) ) {
|
45 |
throw new \Exception( 'Head Request Failed. Likely the version does not exist.' );
|
46 |
}
|
47 |
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* @param string $url
|
53 |
* @return string
|
54 |
* @throws \Exception
|
55 |
*/
|
56 |
+
public function downloadUrl( $url ) {
|
57 |
+
/** @var string|\WP_Error $file */
|
58 |
+
$file = download_url( $url );
|
59 |
+
if ( is_wp_error( $file ) ) {
|
60 |
+
throw new \Exception( $file->get_error_message() );
|
61 |
}
|
62 |
+
if ( !realpath( $file ) ) {
|
63 |
+
throw new \Exception( 'Downloaded file could not be found' );
|
64 |
}
|
65 |
+
$this->downloads[] = $file;
|
66 |
+
return $file;
|
67 |
}
|
68 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/PluginThemeFilesBase.php
CHANGED
@@ -11,46 +11,46 @@ use FernleafSystems\Wordpress\Services;
|
|
11 |
abstract class PluginThemeFilesBase {
|
12 |
|
13 |
/**
|
14 |
-
* @param string $
|
15 |
* @return bool
|
16 |
*/
|
17 |
-
public function replaceFileFromVcs( $
|
18 |
-
$
|
19 |
-
return !empty( $
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
24 |
-
* @param string $
|
25 |
* @return bool
|
26 |
* @throws \InvalidArgumentException
|
27 |
*/
|
28 |
-
public function verifyFileContents( $
|
29 |
-
$
|
30 |
-
return !empty( $
|
31 |
&& ( new Services\Utilities\File\Compare\CompareHash() )
|
32 |
-
->
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
-
* @param string $
|
37 |
* @return string
|
38 |
*/
|
39 |
-
public function getOriginalFileMd5FromVcs( $
|
40 |
-
$
|
41 |
-
return empty( $
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* @param string $
|
46 |
* @return string|null
|
47 |
*/
|
48 |
-
abstract public function getOriginalFileFromVcs( $
|
49 |
|
50 |
/**
|
51 |
* Gets the path of the plugin file relative to its own home plugin dir. (not wp-content/plugins/)
|
52 |
* @param string $file
|
53 |
* @return string
|
54 |
*/
|
55 |
-
abstract
|
56 |
}
|
11 |
abstract class PluginThemeFilesBase {
|
12 |
|
13 |
/**
|
14 |
+
* @param string $fullPath
|
15 |
* @return bool
|
16 |
*/
|
17 |
+
public function replaceFileFromVcs( $fullPath ) :bool {
|
18 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
19 |
+
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $fullPath );
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
24 |
+
* @param string $fullPath
|
25 |
* @return bool
|
26 |
* @throws \InvalidArgumentException
|
27 |
*/
|
28 |
+
public function verifyFileContents( $fullPath ) :bool {
|
29 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
30 |
+
return !empty( $tmpFile )
|
31 |
&& ( new Services\Utilities\File\Compare\CompareHash() )
|
32 |
+
->isEqualFiles( $tmpFile, $fullPath );
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* @param string $fullPath
|
37 |
* @return string
|
38 |
*/
|
39 |
+
public function getOriginalFileMd5FromVcs( $fullPath ) {
|
40 |
+
$file = $this->getOriginalFileFromVcs( $fullPath );
|
41 |
+
return empty( $file ) ? null : md5_file( $file );
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
+
* @param string $fullPath
|
46 |
* @return string|null
|
47 |
*/
|
48 |
+
abstract public function getOriginalFileFromVcs( $fullPath );
|
49 |
|
50 |
/**
|
51 |
* Gets the path of the plugin file relative to its own home plugin dir. (not wp-content/plugins/)
|
52 |
* @param string $file
|
53 |
* @return string
|
54 |
*/
|
55 |
+
abstract public function getRelativeFilePathFromItsInstallDir( $file );
|
56 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/PluginThemeVersionsBase.php
CHANGED
@@ -20,19 +20,19 @@ abstract class PluginThemeVersionsBase {
|
|
20 |
* @return string[]
|
21 |
*/
|
22 |
public function allVersionsUrls() {
|
23 |
-
$
|
24 |
-
$
|
25 |
-
if ( !empty( $
|
26 |
try {
|
27 |
-
$
|
28 |
-
->setWorkingSlug( $
|
29 |
->getInfo();
|
30 |
-
$
|
31 |
}
|
32 |
-
catch ( \Exception $
|
33 |
}
|
34 |
}
|
35 |
-
return is_array( $
|
36 |
}
|
37 |
|
38 |
/**
|
@@ -56,9 +56,9 @@ abstract class PluginThemeVersionsBase {
|
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
* @param string $
|
60 |
-
* @param bool $
|
61 |
* @return bool
|
62 |
*/
|
63 |
-
abstract public function exists( $
|
64 |
}
|
20 |
* @return string[]
|
21 |
*/
|
22 |
public function allVersionsUrls() {
|
23 |
+
$versions = [];
|
24 |
+
$slug = $this->getWorkingSlug();
|
25 |
+
if ( !empty( $slug ) ) {
|
26 |
try {
|
27 |
+
$info = $this->getApi()
|
28 |
+
->setWorkingSlug( $slug )
|
29 |
->getInfo();
|
30 |
+
$versions = $info->versions ?? [];
|
31 |
}
|
32 |
+
catch ( \Exception $e ) {
|
33 |
}
|
34 |
}
|
35 |
+
return is_array( $versions ) ? $versions : [];
|
36 |
}
|
37 |
|
38 |
/**
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* @param string $version
|
60 |
+
* @param bool $verifyUrl
|
61 |
* @return bool
|
62 |
*/
|
63 |
+
abstract public function exists( $version, $verifyUrl = false );
|
64 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/RepoBase.php
CHANGED
@@ -4,55 +4,73 @@ 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 |
-
* @param string $
|
15 |
-
* @param string $
|
16 |
-
* @param bool $
|
17 |
* @return string|null
|
18 |
*/
|
19 |
-
public function downloadFromVcs( $
|
20 |
-
$
|
21 |
try {
|
22 |
-
$
|
23 |
-
->checkUrl( $
|
24 |
-
->downloadUrl( $
|
25 |
}
|
26 |
-
catch ( \Exception $
|
27 |
-
$
|
28 |
}
|
29 |
-
return $
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
-
* @param string $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
* WordPress or the plugin dir if it's a plugin.
|
35 |
-
* @param string $
|
36 |
-
* @param bool $
|
37 |
* @return bool
|
38 |
*/
|
39 |
-
public function existsInVcs( $
|
40 |
-
$
|
41 |
try {
|
42 |
-
( new Services\Utilities\HttpUtil() )->checkUrl( $
|
43 |
-
$
|
44 |
}
|
45 |
-
catch ( \Exception $
|
46 |
-
$
|
47 |
}
|
48 |
-
return $
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
-
* @param string $
|
53 |
-
* @param string $
|
54 |
-
* @param bool $
|
55 |
* @return string
|
56 |
*/
|
57 |
-
abstract protected function getVcsUrlForFileAndVersion( $
|
58 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
abstract class RepoBase {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $fileFragment
|
11 |
+
* @param string $version
|
12 |
+
* @param bool $useSiteLocale
|
13 |
* @return string|null
|
14 |
*/
|
15 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
16 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
17 |
try {
|
18 |
+
$tmpFile = ( new Services\Utilities\HttpUtil() )
|
19 |
+
->checkUrl( $url )
|
20 |
+
->downloadUrl( $url );
|
21 |
}
|
22 |
+
catch ( \Exception $e ) {
|
23 |
+
$tmpFile = null;
|
24 |
}
|
25 |
+
return $tmpFile;
|
26 |
}
|
27 |
|
28 |
/**
|
29 |
+
* @param string $fileFragment
|
30 |
+
* @param string $version
|
31 |
+
* @param bool $useSiteLocale
|
32 |
+
* @return string|null
|
33 |
+
*/
|
34 |
+
public function getContentFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
35 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
36 |
+
$content = null;
|
37 |
+
try {
|
38 |
+
$downloadedFile = ( new Services\Utilities\HttpUtil() )
|
39 |
+
->checkUrl( $url )
|
40 |
+
->downloadUrl( $url );
|
41 |
+
if ( is_string( $downloadedFile ) ) {
|
42 |
+
$content = Services\Services::WpFs()->getFileContent( $downloadedFile );
|
43 |
+
}
|
44 |
+
}
|
45 |
+
catch ( \Exception $e ) {
|
46 |
+
}
|
47 |
+
return $content;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param string $fileFragment - path relative to the root dir of the object being tested. E.g. ABSPATH for
|
52 |
* WordPress or the plugin dir if it's a plugin.
|
53 |
+
* @param string $version - leave empty to use the current version
|
54 |
+
* @param bool $useSiteLocale
|
55 |
* @return bool
|
56 |
*/
|
57 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
+
$url = $this->getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale );
|
59 |
try {
|
60 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( $url );
|
61 |
+
$exists = true;
|
62 |
}
|
63 |
+
catch ( \Exception $e ) {
|
64 |
+
$exists = false;
|
65 |
}
|
66 |
+
return $exists;
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
+
* @param string $fileFragment
|
71 |
+
* @param string $version
|
72 |
+
* @param bool $useSiteLocale
|
73 |
* @return string
|
74 |
*/
|
75 |
+
abstract protected function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true );
|
76 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/VersionsBase.php
CHANGED
@@ -4,10 +4,6 @@ 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 |
/**
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
abstract class VersionsBase {
|
8 |
|
9 |
/**
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Download.php
CHANGED
@@ -8,42 +8,42 @@ use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
|
8 |
class Download {
|
9 |
|
10 |
/**
|
11 |
-
* @param string $
|
12 |
* @return string
|
13 |
* @throws \Exception
|
14 |
*/
|
15 |
-
public function version( $
|
16 |
-
$
|
17 |
|
18 |
try {
|
19 |
-
$
|
20 |
-
if ( !empty( $
|
21 |
-
$
|
22 |
-
->downloadUrl( $
|
23 |
}
|
24 |
}
|
25 |
-
catch ( \Exception $
|
26 |
}
|
27 |
-
return $
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
-
* @param $
|
32 |
* @return string|null
|
33 |
*/
|
34 |
-
private function getZipDownloadUrl( $
|
35 |
-
$
|
36 |
-
$
|
37 |
-
|
38 |
-
if ( is_array( $
|
39 |
-
foreach ( $
|
40 |
-
if ( $
|
41 |
-
$
|
42 |
break;
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
return $
|
48 |
}
|
49 |
}
|
8 |
class Download {
|
9 |
|
10 |
/**
|
11 |
+
* @param string $version
|
12 |
* @return string
|
13 |
* @throws \Exception
|
14 |
*/
|
15 |
+
public function version( $version ) {
|
16 |
+
$tmpFile = null;
|
17 |
|
18 |
try {
|
19 |
+
$url = $this->getZipDownloadUrl( $version );
|
20 |
+
if ( !empty( $version ) ) {
|
21 |
+
$tmpFile = ( new HttpUtil() )
|
22 |
+
->downloadUrl( $url );
|
23 |
}
|
24 |
}
|
25 |
+
catch ( \Exception $e ) {
|
26 |
}
|
27 |
+
return $tmpFile;
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
+
* @param $version
|
32 |
* @return string|null
|
33 |
*/
|
34 |
+
private function getZipDownloadUrl( $version ) {
|
35 |
+
$url = null;
|
36 |
+
$versions = @json_decode( Services::HttpRequest()->getContent( Repo::GetUrlForVersions() ), true );
|
37 |
+
|
38 |
+
if ( is_array( $versions ) ) {
|
39 |
+
foreach ( $versions as $version ) {
|
40 |
+
if ( $version[ 'tag_name' ] == $version ) {
|
41 |
+
$url = $version[ 'zipball_url' ];
|
42 |
break;
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
return $url;
|
48 |
}
|
49 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Files.php
CHANGED
@@ -4,23 +4,19 @@ 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 $
|
15 |
* @return string|null
|
16 |
* @throws \InvalidArgumentException
|
17 |
*/
|
18 |
-
public function getOriginalFileFromVcs( $
|
19 |
-
if ( !Services\Services::CoreFileHashes()->isCoreFile( $
|
20 |
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
21 |
}
|
22 |
return ( new Repo() )->downloadFromVcs(
|
23 |
-
Services\Services::WpFs()->getPathRelativeToAbsPath( $
|
24 |
);
|
25 |
}
|
26 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Files extends Services\Utilities\WpOrg\Wp\Files {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $filePath
|
11 |
* @return string|null
|
12 |
* @throws \InvalidArgumentException
|
13 |
*/
|
14 |
+
public function getOriginalFileFromVcs( $filePath ) {
|
15 |
+
if ( !Services\Services::CoreFileHashes()->isCoreFile( $filePath ) ) {
|
16 |
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
17 |
}
|
18 |
return ( new Repo() )->downloadFromVcs(
|
19 |
+
Services\Services::WpFs()->getPathRelativeToAbsPath( $filePath )
|
20 |
);
|
21 |
}
|
22 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Repo.php
CHANGED
@@ -4,10 +4,6 @@ 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';
|
@@ -39,43 +35,43 @@ class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* @param string $
|
43 |
-
* @param string $
|
44 |
-
* @param bool $
|
45 |
* @return string|null
|
46 |
*/
|
47 |
-
public function downloadFromVcs( $
|
48 |
-
$sFile = parent::downloadFromVcs( $
|
49 |
-
if ( $
|
50 |
-
$sFile = parent::downloadFromVcs( $
|
51 |
}
|
52 |
return $sFile;
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
-
* @param string $
|
57 |
-
* @param string $
|
58 |
-
* @param bool $
|
59 |
* @return bool
|
60 |
*/
|
61 |
-
public function existsInVcs( $
|
62 |
-
$sFile = parent::existsInVcs( $
|
63 |
-
if ( $
|
64 |
-
$sFile = parent::existsInVcs( $
|
65 |
}
|
66 |
return $sFile;
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
-
* @param string $
|
71 |
-
* @param string $
|
72 |
-
* @param bool $
|
73 |
* @return string
|
74 |
*/
|
75 |
-
protected function getVcsUrlForFileAndVersion( $
|
76 |
-
if ( empty( $
|
77 |
-
$
|
78 |
}
|
79 |
-
return sprintf( '%s/%s', static::GetUrlForFiles( $
|
80 |
}
|
81 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
|
9 |
const URL_VCS_ROOT = 'https://raw.githubusercontent.com/ClassicPress/ClassicPress-release';
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* @param string $fileFragment
|
39 |
+
* @param string $version
|
40 |
+
* @param bool $useSiteLocale
|
41 |
* @return string|null
|
42 |
*/
|
43 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
44 |
+
$sFile = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
45 |
+
if ( $useSiteLocale && empty( $sFile ) ) {
|
46 |
+
$sFile = parent::downloadFromVcs( $fileFragment, $version, false );
|
47 |
}
|
48 |
return $sFile;
|
49 |
}
|
50 |
|
51 |
/**
|
52 |
+
* @param string $fileFragment
|
53 |
+
* @param string $version - leave empty to use the current version
|
54 |
+
* @param bool $useSiteLocale
|
55 |
* @return bool
|
56 |
*/
|
57 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
58 |
+
$sFile = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
59 |
+
if ( $useSiteLocale && empty( $sFile ) ) {
|
60 |
+
$sFile = parent::existsInVcs( $fileFragment, $version, false );
|
61 |
}
|
62 |
return $sFile;
|
63 |
}
|
64 |
|
65 |
/**
|
66 |
+
* @param string $fileFragment
|
67 |
+
* @param string $version
|
68 |
+
* @param bool $useSiteLocale - not yet used for ClassicPress
|
69 |
* @return string
|
70 |
*/
|
71 |
+
protected function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true ) {
|
72 |
+
if ( empty( $version ) ) {
|
73 |
+
$version = Services\Services::WpGeneral()->getVersion();
|
74 |
}
|
75 |
+
return sprintf( '%s/%s', static::GetUrlForFiles( $version ), ltrim( $fileFragment, '/' ) );
|
76 |
}
|
77 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Cp/Versions.php
CHANGED
@@ -4,46 +4,43 @@ 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 $
|
15 |
-
* @param bool $
|
16 |
* @return bool
|
17 |
*/
|
18 |
-
public function exists( $
|
19 |
-
$
|
20 |
-
if ( $
|
21 |
try {
|
22 |
-
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $
|
23 |
}
|
24 |
catch ( \Exception $oE ) {
|
25 |
-
$
|
26 |
}
|
27 |
}
|
28 |
-
return $
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* @return array
|
33 |
*/
|
34 |
protected function downloadVersions() {
|
35 |
-
$
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
},
|
43 |
-
$
|
44 |
);
|
45 |
}
|
46 |
|
47 |
-
return $
|
48 |
}
|
49 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Versions extends Services\Utilities\WpOrg\Base\VersionsBase {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $version
|
11 |
+
* @param bool $isVerifyURL
|
12 |
* @return bool
|
13 |
*/
|
14 |
+
public function exists( $version, $isVerifyURL = false ) {
|
15 |
+
$exists = in_array( $version, $this->all() );
|
16 |
+
if ( $exists && $isVerifyURL ) {
|
17 |
try {
|
18 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $version ) );
|
19 |
}
|
20 |
catch ( \Exception $oE ) {
|
21 |
+
$exists = false;
|
22 |
}
|
23 |
}
|
24 |
+
return $exists;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
* @return array
|
29 |
*/
|
30 |
protected function downloadVersions() {
|
31 |
+
$versions = [];
|
32 |
+
$versionsRaw = @json_decode(
|
33 |
+
Services\Services::HttpRequest()->getContent( Repo::GetUrlForVersions() ), true
|
34 |
+
);
|
35 |
+
if ( is_array( $versionsRaw ) ) {
|
36 |
+
$versions = array_map(
|
37 |
+
function ( $versionData ) {
|
38 |
+
return $versionData[ 'tag_name' ];
|
39 |
},
|
40 |
+
$versionsRaw
|
41 |
);
|
42 |
}
|
43 |
|
44 |
+
return $versions;
|
45 |
}
|
46 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Api.php
CHANGED
@@ -6,8 +6,6 @@ use FernleafSystems\Utilities\Data\Adapter\DynProperties;
|
|
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 {
|
6 |
use FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin\VOs\PluginInfoVO;
|
7 |
|
8 |
/**
|
|
|
|
|
9 |
* @property array $fields
|
10 |
*/
|
11 |
class Api {
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Base.php
CHANGED
@@ -5,34 +5,30 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
|
5 |
use FernleafSystems\Wordpress\Services\Core\VOs\Assets\WpPluginVo;
|
6 |
use FernleafSystems\Wordpress\Services\Services;
|
7 |
|
8 |
-
/**
|
9 |
-
* Trait Base
|
10 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
11 |
-
*/
|
12 |
trait Base {
|
13 |
|
14 |
/**
|
15 |
* @var string
|
16 |
*/
|
17 |
-
private $
|
18 |
|
19 |
/**
|
20 |
* @var string
|
21 |
*/
|
22 |
-
private $
|
23 |
|
24 |
/**
|
25 |
* @return string
|
26 |
*/
|
27 |
public function getWorkingSlug() {
|
28 |
-
return $this->
|
29 |
}
|
30 |
|
31 |
/**
|
32 |
* @return string
|
33 |
*/
|
34 |
public function getWorkingVersion() {
|
35 |
-
$version = $this->
|
36 |
if ( empty( $version ) ) {
|
37 |
$p = Services::WpPlugins()->getPluginAsVo( $this->getWorkingSlug() );
|
38 |
if ( $p instanceof WpPluginVo ) {
|
@@ -43,20 +39,20 @@ trait Base {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
* @param string $
|
47 |
* @return $this
|
48 |
*/
|
49 |
-
public function setWorkingSlug( $
|
50 |
-
$this->
|
51 |
return $this;
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
-
* @param string $
|
56 |
* @return $this
|
57 |
*/
|
58 |
-
public function setWorkingVersion( $
|
59 |
-
$this->
|
60 |
return $this;
|
61 |
}
|
62 |
}
|
5 |
use FernleafSystems\Wordpress\Services\Core\VOs\Assets\WpPluginVo;
|
6 |
use FernleafSystems\Wordpress\Services\Services;
|
7 |
|
|
|
|
|
|
|
|
|
8 |
trait Base {
|
9 |
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
+
private $workingPluginSlug;
|
14 |
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
+
private $workingPluginVersion;
|
19 |
|
20 |
/**
|
21 |
* @return string
|
22 |
*/
|
23 |
public function getWorkingSlug() {
|
24 |
+
return $this->workingPluginSlug;
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
* @return string
|
29 |
*/
|
30 |
public function getWorkingVersion() {
|
31 |
+
$version = $this->workingPluginVersion;
|
32 |
if ( empty( $version ) ) {
|
33 |
$p = Services::WpPlugins()->getPluginAsVo( $this->getWorkingSlug() );
|
34 |
if ( $p instanceof WpPluginVo ) {
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @param string $slug
|
43 |
* @return $this
|
44 |
*/
|
45 |
+
public function setWorkingSlug( $slug ) {
|
46 |
+
$this->workingPluginSlug = $slug;
|
47 |
return $this;
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @param string $version
|
52 |
* @return $this
|
53 |
*/
|
54 |
+
public function setWorkingVersion( $version ) {
|
55 |
+
$this->workingPluginVersion = $version;
|
56 |
return $this;
|
57 |
}
|
58 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Download.php
CHANGED
@@ -4,23 +4,19 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
6 |
|
7 |
-
/**
|
8 |
-
* Class Download
|
9 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Plugin
|
10 |
-
*/
|
11 |
class Download {
|
12 |
|
13 |
use Base;
|
14 |
|
15 |
/**
|
16 |
-
* @param string $
|
17 |
* @return string|null
|
18 |
*/
|
19 |
-
public function getDownloadUrlForVersion( $
|
20 |
-
$
|
21 |
->setWorkingSlug( $this->getWorkingSlug() )
|
22 |
->allVersionsUrls();
|
23 |
-
return empty( $
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -28,19 +24,19 @@ class Download {
|
|
28 |
* @throws \Exception
|
29 |
*/
|
30 |
public function latest() {
|
31 |
-
$
|
32 |
->setWorkingSlug( $this->getWorkingSlug() )
|
33 |
->latest();
|
34 |
-
return empty( $
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
* @param string $
|
39 |
* @return string
|
40 |
* @throws \Exception
|
41 |
*/
|
42 |
-
public function version( $
|
43 |
-
$
|
44 |
-
return empty( $
|
45 |
}
|
46 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Download {
|
8 |
|
9 |
use Base;
|
10 |
|
11 |
/**
|
12 |
+
* @param string $version
|
13 |
* @return string|null
|
14 |
*/
|
15 |
+
public function getDownloadUrlForVersion( $version ) {
|
16 |
+
$all = ( new Versions() )
|
17 |
->setWorkingSlug( $this->getWorkingSlug() )
|
18 |
->allVersionsUrls();
|
19 |
+
return empty( $all[ $version ] ) ? null : $all[ $version ];
|
20 |
}
|
21 |
|
22 |
/**
|
24 |
* @throws \Exception
|
25 |
*/
|
26 |
public function latest() {
|
27 |
+
$url = ( new Versions() )
|
28 |
->setWorkingSlug( $this->getWorkingSlug() )
|
29 |
->latest();
|
30 |
+
return empty( $url ) ? null : ( new HttpUtil() )->downloadUrl( $url );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @param string $version
|
35 |
* @return string
|
36 |
* @throws \Exception
|
37 |
*/
|
38 |
+
public function version( $version ) {
|
39 |
+
$url = $this->getDownloadUrlForVersion( $version );
|
40 |
+
return empty( $url ) ? null : ( new HttpUtil() )->downloadUrl( $url );
|
41 |
}
|
42 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Files.php
CHANGED
@@ -4,23 +4,19 @@ 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 extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
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 $
|
18 |
* @return Services\Core\VOs\Assets\WpPluginVo|null
|
19 |
*/
|
20 |
-
public function findPluginFromFile( $
|
21 |
$thePlugin = null;
|
22 |
|
23 |
-
$fragment = $this->getPluginPathFragmentFromPath( $
|
24 |
|
25 |
if ( !empty( $fragment ) && strpos( $fragment, '/' ) > 0 ) {
|
26 |
$WPP = Services\Services::WpPlugins();
|
@@ -59,48 +55,48 @@ class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* @param string $
|
63 |
* @return bool
|
64 |
*/
|
65 |
-
public function replaceFileFromVcs( $
|
66 |
-
$tmpFile = $this->getOriginalFileFromVcs( $
|
67 |
-
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
-
* @param string $
|
72 |
* @return string|null
|
73 |
*/
|
74 |
-
public function getOriginalFileFromVcs( $
|
75 |
$tmpFile = null;
|
76 |
-
$thePlugin = $this->findPluginFromFile( $
|
77 |
-
if ( $thePlugin
|
78 |
$tmpFile = ( new Repo() )
|
79 |
->setWorkingSlug( $thePlugin->slug )
|
80 |
->setWorkingVersion( ( $thePlugin->svn_uses_tags ? $thePlugin->Version : 'trunk' ) )
|
81 |
-
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $
|
82 |
}
|
83 |
return $tmpFile;
|
84 |
}
|
85 |
|
86 |
/**
|
87 |
-
* @param string $
|
88 |
* @return string|null - the path to the file relative to Plugins Dir.
|
89 |
*/
|
90 |
-
public function getPluginPathFragmentFromPath( $
|
91 |
-
$
|
92 |
|
93 |
-
if ( !Services\Services::WpFs()->isAbsPath( $
|
94 |
-
$
|
95 |
}
|
96 |
-
$
|
97 |
-
$
|
98 |
|
99 |
-
if ( strpos( $
|
100 |
-
$
|
101 |
}
|
102 |
|
103 |
-
return $
|
104 |
}
|
105 |
|
106 |
/**
|
@@ -108,7 +104,7 @@ class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
|
108 |
* @param string $file
|
109 |
* @return string
|
110 |
*/
|
111 |
-
|
112 |
$sRelDirFragment = $this->getPluginPathFragmentFromPath( $file );
|
113 |
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
114 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
8 |
|
9 |
use Base;
|
10 |
|
11 |
/**
|
12 |
* Given a full root path on the file system for a file, locate the plugin to which this file belongs.
|
13 |
+
* @param string $fullPath
|
14 |
* @return Services\Core\VOs\Assets\WpPluginVo|null
|
15 |
*/
|
16 |
+
public function findPluginFromFile( string $fullPath ) {
|
17 |
$thePlugin = null;
|
18 |
|
19 |
+
$fragment = $this->getPluginPathFragmentFromPath( $fullPath );
|
20 |
|
21 |
if ( !empty( $fragment ) && strpos( $fragment, '/' ) > 0 ) {
|
22 |
$WPP = Services\Services::WpPlugins();
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* @param string $fullPath
|
59 |
* @return bool
|
60 |
*/
|
61 |
+
public function replaceFileFromVcs( $fullPath ) :bool {
|
62 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
63 |
+
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $fullPath );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
+
* @param string $fullPath
|
68 |
* @return string|null
|
69 |
*/
|
70 |
+
public function getOriginalFileFromVcs( $fullPath ) {
|
71 |
$tmpFile = null;
|
72 |
+
$thePlugin = $this->findPluginFromFile( $fullPath );
|
73 |
+
if ( !empty( $thePlugin ) ) {
|
74 |
$tmpFile = ( new Repo() )
|
75 |
->setWorkingSlug( $thePlugin->slug )
|
76 |
->setWorkingVersion( ( $thePlugin->svn_uses_tags ? $thePlugin->Version : 'trunk' ) )
|
77 |
+
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $fullPath ) );
|
78 |
}
|
79 |
return $tmpFile;
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* @param string $file - can either be absolute, or relative to ABSPATH
|
84 |
* @return string|null - the path to the file relative to Plugins Dir.
|
85 |
*/
|
86 |
+
public function getPluginPathFragmentFromPath( $file ) {
|
87 |
+
$fragment = null;
|
88 |
|
89 |
+
if ( !Services\Services::WpFs()->isAbsPath( $file ) ) { // assume it's relative to ABSPATH
|
90 |
+
$file = path_join( ABSPATH, $file );
|
91 |
}
|
92 |
+
$file = wp_normalize_path( $file );
|
93 |
+
$pluginsDir = wp_normalize_path( WP_PLUGIN_DIR );
|
94 |
|
95 |
+
if ( strpos( $file, $pluginsDir ) === 0 ) {
|
96 |
+
$fragment = ltrim( str_replace( $pluginsDir, '', $file ), '/' );
|
97 |
}
|
98 |
|
99 |
+
return $fragment;
|
100 |
}
|
101 |
|
102 |
/**
|
104 |
* @param string $file
|
105 |
* @return string
|
106 |
*/
|
107 |
+
public function getRelativeFilePathFromItsInstallDir( $file ) {
|
108 |
$sRelDirFragment = $this->getPluginPathFragmentFromPath( $file );
|
109 |
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
110 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Repo.php
CHANGED
@@ -4,10 +4,6 @@ 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;
|
@@ -16,55 +12,55 @@ class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
|
16 |
const URL_DOWNLOAD_SVN_FILE = 'https://plugins.svn.wordpress.org/%s/tags/%s/%s';
|
17 |
|
18 |
/**
|
19 |
-
* @param string $
|
20 |
* @return string
|
21 |
*/
|
22 |
-
public static function GetUrlForPlugin( $
|
23 |
-
return sprintf( '%s/%s', static::URL_VCS_ROOT, $
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
* @param string $
|
28 |
-
* @param string $
|
29 |
* @return string
|
30 |
*/
|
31 |
-
public static function GetUrlForPluginVersion( $
|
32 |
-
if ( $
|
33 |
-
$
|
34 |
}
|
35 |
-
return sprintf( '%s/%s', static::GetUrlForPlugin( $
|
36 |
}
|
37 |
|
38 |
/**
|
39 |
-
* @param string $
|
40 |
* @return string
|
41 |
*/
|
42 |
-
public static function GetUrlForPluginVersions( $
|
43 |
-
return static::GetUrlForPluginVersion( $
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* @param string $
|
48 |
-
* @param string $
|
49 |
-
* @param bool $
|
50 |
* @return string
|
51 |
* @throws \Exception
|
52 |
*/
|
53 |
-
protected function getVcsUrlForFileAndVersion( $
|
54 |
-
if ( empty( $
|
55 |
throw new \InvalidArgumentException( 'Plugin file fragment path provided is empty' );
|
56 |
}
|
57 |
-
if ( empty( $
|
58 |
-
$
|
59 |
}
|
60 |
-
if ( empty( $
|
61 |
-
$
|
62 |
->setWorkingSlug( $this->getWorkingSlug() )
|
63 |
->latest();
|
64 |
}
|
65 |
return sprintf( '%s/%s',
|
66 |
-
rtrim( static::GetUrlForPluginVersion( $this->getWorkingSlug(), $
|
67 |
-
ltrim( $
|
68 |
);
|
69 |
}
|
70 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
|
9 |
use Base;
|
12 |
const URL_DOWNLOAD_SVN_FILE = 'https://plugins.svn.wordpress.org/%s/tags/%s/%s';
|
13 |
|
14 |
/**
|
15 |
+
* @param string $slug
|
16 |
* @return string
|
17 |
*/
|
18 |
+
public static function GetUrlForPlugin( $slug ) {
|
19 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
20 |
}
|
21 |
|
22 |
/**
|
23 |
+
* @param string $slug
|
24 |
+
* @param string $version
|
25 |
* @return string
|
26 |
*/
|
27 |
+
public static function GetUrlForPluginVersion( $slug, $version ) {
|
28 |
+
if ( $version != 'trunk' ) {
|
29 |
+
$version = sprintf( 'tags/%s', $version );
|
30 |
}
|
31 |
+
return sprintf( '%s/%s', static::GetUrlForPlugin( $slug ), $version );
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* @param string $slug
|
36 |
* @return string
|
37 |
*/
|
38 |
+
public static function GetUrlForPluginVersions( $slug ) {
|
39 |
+
return static::GetUrlForPluginVersion( $slug, '' );
|
40 |
}
|
41 |
|
42 |
/**
|
43 |
+
* @param string $fileFragment - relative to the working plugin directory
|
44 |
+
* @param string $version
|
45 |
+
* @param bool $useSiteLocale - unused
|
46 |
* @return string
|
47 |
* @throws \Exception
|
48 |
*/
|
49 |
+
protected function getVcsUrlForFileAndVersion( $fileFragment, $version = null, $useSiteLocale = true ) {
|
50 |
+
if ( empty( $fileFragment ) ) {
|
51 |
throw new \InvalidArgumentException( 'Plugin file fragment path provided is empty' );
|
52 |
}
|
53 |
+
if ( empty( $version ) ) {
|
54 |
+
$version = $this->getWorkingVersion();
|
55 |
}
|
56 |
+
if ( empty( $version ) ) {
|
57 |
+
$version = ( new Versions() )
|
58 |
->setWorkingSlug( $this->getWorkingSlug() )
|
59 |
->latest();
|
60 |
}
|
61 |
return sprintf( '%s/%s',
|
62 |
+
rtrim( static::GetUrlForPluginVersion( $this->getWorkingSlug(), $version ), '/' ),
|
63 |
+
ltrim( $fileFragment, '/' )
|
64 |
);
|
65 |
}
|
66 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Plugin/Versions.php
CHANGED
@@ -17,15 +17,15 @@ class Versions extends PluginThemeVersionsBase {
|
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
* @param string $
|
21 |
-
* @param bool $
|
22 |
* @return bool
|
23 |
*/
|
24 |
-
public function exists( $
|
25 |
-
$bExists = in_array( $
|
26 |
-
if ( $bExists && $
|
27 |
try {
|
28 |
-
( new HttpUtil() )->checkUrl( Repo::GetUrlForPluginVersion( $this->getWorkingSlug(), $
|
29 |
}
|
30 |
catch ( \Exception $oE ) {
|
31 |
$bExists = false;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* @param string $version
|
21 |
+
* @param bool $verifyUrl
|
22 |
* @return bool
|
23 |
*/
|
24 |
+
public function exists( $version, $verifyUrl = false ) {
|
25 |
+
$bExists = in_array( $version, $this->all() );
|
26 |
+
if ( $bExists && $verifyUrl ) {
|
27 |
try {
|
28 |
+
( new HttpUtil() )->checkUrl( Repo::GetUrlForPluginVersion( $this->getWorkingSlug(), $version ) );
|
29 |
}
|
30 |
catch ( \Exception $oE ) {
|
31 |
$bExists = false;
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Api.php
CHANGED
@@ -7,8 +7,6 @@ use FernleafSystems\Wordpress\Services\Services;
|
|
7 |
use FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme\VOs\ThemeInfoVO;
|
8 |
|
9 |
/**
|
10 |
-
* Class Api
|
11 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme
|
12 |
* @property array $fields
|
13 |
*/
|
14 |
class Api {
|
@@ -34,17 +32,17 @@ class Api {
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
-
* @param string $
|
38 |
* @return ThemeInfoVO
|
39 |
* @throws \Exception
|
40 |
*/
|
41 |
-
public function run( $
|
42 |
include_once( ABSPATH.'wp-admin/includes/theme.php' );
|
43 |
|
44 |
$params = $this->getRawData();
|
45 |
$params[ 'slug' ] = $this->getWorkingSlug();
|
46 |
|
47 |
-
$response = \themes_api( $
|
48 |
Services::DataManipulation()->mergeArraysRecursive( $this->defaultParams(), $params ) );
|
49 |
|
50 |
if ( \is_wp_error( $response ) ) {
|
7 |
use FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme\VOs\ThemeInfoVO;
|
8 |
|
9 |
/**
|
|
|
|
|
10 |
* @property array $fields
|
11 |
*/
|
12 |
class Api {
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* @param string $cmd
|
36 |
* @return ThemeInfoVO
|
37 |
* @throws \Exception
|
38 |
*/
|
39 |
+
public function run( $cmd ) {
|
40 |
include_once( ABSPATH.'wp-admin/includes/theme.php' );
|
41 |
|
42 |
$params = $this->getRawData();
|
43 |
$params[ 'slug' ] = $this->getWorkingSlug();
|
44 |
|
45 |
+
$response = \themes_api( $cmd,
|
46 |
Services::DataManipulation()->mergeArraysRecursive( $this->defaultParams(), $params ) );
|
47 |
|
48 |
if ( \is_wp_error( $response ) ) {
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Base.php
CHANGED
@@ -4,58 +4,54 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
7 |
-
/**
|
8 |
-
* Trait Base
|
9 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme
|
10 |
-
*/
|
11 |
trait Base {
|
12 |
|
13 |
/**
|
14 |
* @var string
|
15 |
*/
|
16 |
-
private $
|
17 |
|
18 |
/**
|
19 |
* @var string
|
20 |
*/
|
21 |
-
private $
|
22 |
|
23 |
/**
|
24 |
* @return string
|
25 |
*/
|
26 |
public function getWorkingSlug() {
|
27 |
-
return $this->
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
* @return string
|
32 |
*/
|
33 |
public function getWorkingVersion() {
|
34 |
-
$
|
35 |
-
if ( empty( $
|
36 |
-
$
|
37 |
-
if ( $
|
38 |
-
$
|
39 |
}
|
40 |
}
|
41 |
-
return $
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* @param string $
|
46 |
* @return $this
|
47 |
*/
|
48 |
-
public function setWorkingSlug( $
|
49 |
-
$this->
|
50 |
return $this;
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
* @param string $
|
55 |
* @return $this
|
56 |
*/
|
57 |
-
public function setWorkingVersion( $
|
58 |
-
$this->
|
59 |
return $this;
|
60 |
}
|
61 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
trait Base {
|
8 |
|
9 |
/**
|
10 |
* @var string
|
11 |
*/
|
12 |
+
private $workingSlug;
|
13 |
|
14 |
/**
|
15 |
* @var string
|
16 |
*/
|
17 |
+
private $workingVersion;
|
18 |
|
19 |
/**
|
20 |
* @return string
|
21 |
*/
|
22 |
public function getWorkingSlug() {
|
23 |
+
return $this->workingSlug;
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
* @return string
|
28 |
*/
|
29 |
public function getWorkingVersion() {
|
30 |
+
$version = $this->workingVersion;
|
31 |
+
if ( empty( $version ) ) {
|
32 |
+
$theme = Services::WpThemes()->getTheme( $this->getWorkingSlug() );
|
33 |
+
if ( $theme instanceof \WP_Theme ) {
|
34 |
+
$version = $theme->get( 'Version' );
|
35 |
}
|
36 |
}
|
37 |
+
return $version;
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* @param string $slug
|
42 |
* @return $this
|
43 |
*/
|
44 |
+
public function setWorkingSlug( $slug ) {
|
45 |
+
$this->workingSlug = $slug;
|
46 |
return $this;
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @param string $version
|
51 |
* @return $this
|
52 |
*/
|
53 |
+
public function setWorkingVersion( $version ) {
|
54 |
+
$this->workingVersion = $version;
|
55 |
return $this;
|
56 |
}
|
57 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Download.php
CHANGED
@@ -4,23 +4,19 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
6 |
|
7 |
-
/**
|
8 |
-
* Class Download
|
9 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme
|
10 |
-
*/
|
11 |
class Download {
|
12 |
|
13 |
use Base;
|
14 |
|
15 |
/**
|
16 |
-
* @param string $
|
17 |
* @return string|null
|
18 |
*/
|
19 |
-
public function getDownloadUrlForVersion( $
|
20 |
-
$
|
21 |
->setWorkingSlug( $this->getWorkingSlug() )
|
22 |
->allVersionsUrls();
|
23 |
-
return empty( $
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -28,19 +24,19 @@ class Download {
|
|
28 |
* @throws \Exception
|
29 |
*/
|
30 |
public function latest() {
|
31 |
-
$
|
32 |
->setWorkingSlug( $this->getWorkingSlug() )
|
33 |
->latest();
|
34 |
-
return empty( $
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
-
* @param string $
|
39 |
* @return string
|
40 |
* @throws \Exception
|
41 |
*/
|
42 |
-
public function version( $
|
43 |
-
$
|
44 |
-
return empty( $
|
45 |
}
|
46 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services\Utilities\HttpUtil;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Download {
|
8 |
|
9 |
use Base;
|
10 |
|
11 |
/**
|
12 |
+
* @param string $version
|
13 |
* @return string|null
|
14 |
*/
|
15 |
+
public function getDownloadUrlForVersion( $version ) {
|
16 |
+
$all = ( new Versions() )
|
17 |
->setWorkingSlug( $this->getWorkingSlug() )
|
18 |
->allVersionsUrls();
|
19 |
+
return empty( $all[ $version ] ) ? null : $all[ $version ];
|
20 |
}
|
21 |
|
22 |
/**
|
24 |
* @throws \Exception
|
25 |
*/
|
26 |
public function latest() {
|
27 |
+
$url = ( new Versions() )
|
28 |
->setWorkingSlug( $this->getWorkingSlug() )
|
29 |
->latest();
|
30 |
+
return empty( $url ) ? null : ( new HttpUtil() )->downloadUrl( $url );
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @param string $version
|
35 |
* @return string
|
36 |
* @throws \Exception
|
37 |
*/
|
38 |
+
public function version( $version ) {
|
39 |
+
$url = $this->getDownloadUrlForVersion( $version );
|
40 |
+
return empty( $url ) ? null : ( new HttpUtil() )->downloadUrl( $url );
|
41 |
}
|
42 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Files.php
CHANGED
@@ -4,30 +4,26 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
7 |
-
/**
|
8 |
-
* Class Files
|
9 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme
|
10 |
-
*/
|
11 |
class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
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 $
|
18 |
* @return Services\Core\VOs\Assets\WpThemeVo|null
|
19 |
*/
|
20 |
-
public function findThemeFromFile( string $
|
21 |
$theTheme = null;
|
22 |
|
23 |
-
$
|
24 |
|
25 |
-
if ( !empty( $
|
26 |
-
$
|
27 |
-
$dir = substr( $
|
28 |
-
foreach ( $
|
29 |
if ( $dir == $theme->get_stylesheet() ) {
|
30 |
-
$theTheme = $
|
31 |
break;
|
32 |
}
|
33 |
}
|
@@ -59,39 +55,38 @@ class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
-
* @param string $
|
63 |
* @return bool
|
64 |
*/
|
65 |
-
public function replaceFileFromVcs( $
|
66 |
-
$
|
67 |
-
return !empty( $
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
72 |
-
* @param string $
|
73 |
* @return bool
|
74 |
* @throws \InvalidArgumentException
|
75 |
*/
|
76 |
-
public function verifyFileContents( $
|
77 |
-
$
|
78 |
-
return !empty( $
|
79 |
-
&& ( new Services\Utilities\File\Compare\CompareHash() )
|
80 |
-
->isEqualFilesMd5( $sTmpFile, $sFullFilePath );
|
81 |
}
|
82 |
|
83 |
/**
|
84 |
-
* @param string $
|
85 |
* @return string|null
|
86 |
*/
|
87 |
-
public function getOriginalFileFromVcs( $
|
88 |
$tmpFile = null;
|
89 |
-
$theTheme = $this->findThemeFromFile( $
|
90 |
if ( $theTheme instanceof Services\Core\VOs\Assets\WpThemeVo ) {
|
91 |
$tmpFile = ( new Repo() )
|
92 |
->setWorkingSlug( $theTheme->stylesheet )
|
93 |
->setWorkingVersion( $theTheme->version )
|
94 |
-
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $
|
95 |
}
|
96 |
return $tmpFile;
|
97 |
}
|
@@ -121,7 +116,7 @@ class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
|
121 |
* @param string $file
|
122 |
* @return string
|
123 |
*/
|
124 |
-
|
125 |
$sRelDirFragment = $this->getThemePathFragmentFromPath( $file );
|
126 |
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
127 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Files extends Services\Utilities\WpOrg\Base\PluginThemeFilesBase {
|
8 |
|
9 |
use Base;
|
10 |
|
11 |
/**
|
12 |
* Given a full root path on the file system for a file, locate the plugin to which this file belongs.
|
13 |
+
* @param string $fullPath
|
14 |
* @return Services\Core\VOs\Assets\WpThemeVo|null
|
15 |
*/
|
16 |
+
public function findThemeFromFile( string $fullPath ) {
|
17 |
$theTheme = null;
|
18 |
|
19 |
+
$fragment = $this->getThemePathFragmentFromPath( $fullPath );
|
20 |
|
21 |
+
if ( !empty( $fragment ) && strpos( $fragment, '/' ) > 0 ) {
|
22 |
+
$WPT = Services\Services::WpThemes();
|
23 |
+
$dir = substr( $fragment, 0, strpos( $fragment, '/' ) );
|
24 |
+
foreach ( $WPT->getThemes() as $theme ) {
|
25 |
if ( $dir == $theme->get_stylesheet() ) {
|
26 |
+
$theTheme = $WPT->getThemeAsVo( $dir );
|
27 |
break;
|
28 |
}
|
29 |
}
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* @param string $fullPath
|
59 |
* @return bool
|
60 |
*/
|
61 |
+
public function replaceFileFromVcs( $fullPath ) :bool {
|
62 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
63 |
+
return !empty( $tmpFile ) && Services\Services::WpFs()->move( $tmpFile, $fullPath );
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* Verifies the file exists on the SVN repository for the particular version that's installed.
|
68 |
+
* @param string $fullPath
|
69 |
* @return bool
|
70 |
* @throws \InvalidArgumentException
|
71 |
*/
|
72 |
+
public function verifyFileContents( $fullPath ) :bool {
|
73 |
+
$tmpFile = $this->getOriginalFileFromVcs( $fullPath );
|
74 |
+
return !empty( $tmpFile )
|
75 |
+
&& ( new Services\Utilities\File\Compare\CompareHash() )->isEqualFiles( $tmpFile, $fullPath );
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* @param string $fullPath
|
80 |
* @return string|null
|
81 |
*/
|
82 |
+
public function getOriginalFileFromVcs( $fullPath ) {
|
83 |
$tmpFile = null;
|
84 |
+
$theTheme = $this->findThemeFromFile( $fullPath );
|
85 |
if ( $theTheme instanceof Services\Core\VOs\Assets\WpThemeVo ) {
|
86 |
$tmpFile = ( new Repo() )
|
87 |
->setWorkingSlug( $theTheme->stylesheet )
|
88 |
->setWorkingVersion( $theTheme->version )
|
89 |
+
->downloadFromVcs( $this->getRelativeFilePathFromItsInstallDir( $fullPath ) );
|
90 |
}
|
91 |
return $tmpFile;
|
92 |
}
|
116 |
* @param string $file
|
117 |
* @return string
|
118 |
*/
|
119 |
+
public function getRelativeFilePathFromItsInstallDir( $file ) {
|
120 |
$sRelDirFragment = $this->getThemePathFragmentFromPath( $file );
|
121 |
return substr( $sRelDirFragment, strpos( $sRelDirFragment, '/' ) + 1 );
|
122 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Repo.php
CHANGED
@@ -4,60 +4,56 @@ namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme;
|
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
7 |
-
/**
|
8 |
-
* Class Repo
|
9 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Theme
|
10 |
-
*/
|
11 |
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
12 |
|
13 |
use Base;
|
14 |
const URL_VCS_ROOT = 'https://themes.svn.wordpress.org';
|
15 |
|
16 |
/**
|
17 |
-
* @param string $
|
18 |
* @return string
|
19 |
*/
|
20 |
-
public static function GetUrlForTheme( $
|
21 |
-
return sprintf( '%s/%s', static::URL_VCS_ROOT, $
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
* @param string $
|
26 |
-
* @param string $
|
27 |
* @return string
|
28 |
*/
|
29 |
-
public static function GetUrlForThemeVersion( $
|
30 |
-
return sprintf( '%s/%s', static::GetUrlForTheme( $
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
* @param string $
|
35 |
* @return string
|
36 |
*/
|
37 |
-
public static function GetUrlForThemeVersions( $
|
38 |
-
return static::GetUrlForThemeVersion( $
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* @param string $
|
43 |
-
* @param string $
|
44 |
-
* @param bool $
|
45 |
* @return string
|
46 |
* @throws \Exception
|
47 |
*/
|
48 |
-
protected function getVcsUrlForFileAndVersion( $
|
49 |
-
if ( empty( $
|
50 |
throw new \InvalidArgumentException( 'Theme file fragment path provided is empty' );
|
51 |
}
|
52 |
-
if ( empty( $
|
53 |
-
$
|
54 |
}
|
55 |
-
if ( empty( $
|
56 |
-
$
|
57 |
->setWorkingSlug( $this->getWorkingSlug() )
|
58 |
->latest();
|
59 |
}
|
60 |
return sprintf( '%s/%s',
|
61 |
-
static::GetUrlForThemeVersion( $this->getWorkingSlug(), $
|
62 |
}
|
63 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
|
9 |
use Base;
|
10 |
const URL_VCS_ROOT = 'https://themes.svn.wordpress.org';
|
11 |
|
12 |
/**
|
13 |
+
* @param string $slug
|
14 |
* @return string
|
15 |
*/
|
16 |
+
public static function GetUrlForTheme( $slug ) {
|
17 |
+
return sprintf( '%s/%s', static::URL_VCS_ROOT, $slug );
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* @param string $slug
|
22 |
+
* @param string $version
|
23 |
* @return string
|
24 |
*/
|
25 |
+
public static function GetUrlForThemeVersion( $slug, $version ) {
|
26 |
+
return sprintf( '%s/%s', static::GetUrlForTheme( $slug ), $version );
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
+
* @param string $slug
|
31 |
* @return string
|
32 |
*/
|
33 |
+
public static function GetUrlForThemeVersions( $slug ) {
|
34 |
+
return static::GetUrlForThemeVersion( $slug, '' );
|
35 |
}
|
36 |
|
37 |
/**
|
38 |
+
* @param string $fileFragment - relative to the working plugin directory
|
39 |
+
* @param string $version
|
40 |
+
* @param bool $useSiteLocale - unused
|
41 |
* @return string
|
42 |
* @throws \Exception
|
43 |
*/
|
44 |
+
protected function getVcsUrlForFileAndVersion( $fileFragment, $version = null, $useSiteLocale = true ) {
|
45 |
+
if ( empty( $fileFragment ) ) {
|
46 |
throw new \InvalidArgumentException( 'Theme file fragment path provided is empty' );
|
47 |
}
|
48 |
+
if ( empty( $version ) ) {
|
49 |
+
$version = $this->getWorkingVersion();
|
50 |
}
|
51 |
+
if ( empty( $version ) ) {
|
52 |
+
$version = ( new Versions() )
|
53 |
->setWorkingSlug( $this->getWorkingSlug() )
|
54 |
->latest();
|
55 |
}
|
56 |
return sprintf( '%s/%s',
|
57 |
+
static::GetUrlForThemeVersion( $this->getWorkingSlug(), $version ), ltrim( $fileFragment, '/' ) );
|
58 |
}
|
59 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Theme/Versions.php
CHANGED
@@ -17,20 +17,20 @@ class Versions extends PluginThemeVersionsBase {
|
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
-
* @param string $
|
21 |
-
* @param bool $
|
22 |
* @return bool
|
23 |
*/
|
24 |
-
public function exists( $
|
25 |
-
$
|
26 |
-
if ( $
|
27 |
try {
|
28 |
-
( new HttpUtil() )->checkUrl( Repo::GetUrlForThemeVersion( $this->getWorkingSlug(), $
|
29 |
}
|
30 |
-
catch ( \Exception $
|
31 |
-
$
|
32 |
}
|
33 |
}
|
34 |
-
return $
|
35 |
}
|
36 |
}
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
+
* @param string $version
|
21 |
+
* @param bool $verifyUrl
|
22 |
* @return bool
|
23 |
*/
|
24 |
+
public function exists( $version, $verifyUrl = false ) {
|
25 |
+
$exists = in_array( $version, $this->all() );
|
26 |
+
if ( $exists && $verifyUrl ) {
|
27 |
try {
|
28 |
+
( new HttpUtil() )->checkUrl( Repo::GetUrlForThemeVersion( $this->getWorkingSlug(), $version ) );
|
29 |
}
|
30 |
+
catch ( \Exception $e ) {
|
31 |
+
$exists = false;
|
32 |
}
|
33 |
}
|
34 |
+
return $exists;
|
35 |
}
|
36 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Base.php
CHANGED
@@ -2,10 +2,6 @@
|
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
|
5 |
-
/**
|
6 |
-
* Trait Base
|
7 |
-
* @package FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp
|
8 |
-
*/
|
9 |
trait Base {
|
10 |
|
11 |
}
|
2 |
|
3 |
namespace FernleafSystems\Wordpress\Services\Utilities\WpOrg\Wp;
|
4 |
|
|
|
|
|
|
|
|
|
5 |
trait Base {
|
6 |
|
7 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Download.php
CHANGED
@@ -10,38 +10,38 @@ class Download {
|
|
10 |
const URL_DOWNLOAD = 'https://%swordpress.org/wordpress-%s%s.zip';
|
11 |
|
12 |
/**
|
13 |
-
* @param string $
|
14 |
-
* @param string $
|
15 |
* @return string
|
16 |
* @throws \Exception
|
17 |
*/
|
18 |
-
public function version( $
|
19 |
-
$
|
20 |
|
21 |
-
$
|
22 |
-
if ( $
|
23 |
-
$
|
24 |
}
|
25 |
|
26 |
-
$
|
27 |
|
28 |
-
if ( strpos( $
|
29 |
-
list( $pt1, $pt2 ) = explode( '_', $
|
30 |
-
$
|
31 |
}
|
32 |
|
33 |
-
$
|
34 |
static::URL_DOWNLOAD,
|
35 |
-
( empty( $
|
36 |
-
$
|
37 |
-
( empty( $
|
38 |
);
|
39 |
|
40 |
try {
|
41 |
-
$
|
42 |
}
|
43 |
-
catch ( \Exception $
|
44 |
}
|
45 |
-
return $
|
46 |
}
|
47 |
}
|
10 |
const URL_DOWNLOAD = 'https://%swordpress.org/wordpress-%s%s.zip';
|
11 |
|
12 |
/**
|
13 |
+
* @param string $version
|
14 |
+
* @param string $locale - defaults to en_US
|
15 |
* @return string
|
16 |
* @throws \Exception
|
17 |
*/
|
18 |
+
public function version( $version, $locale = '' ) {
|
19 |
+
$tmpFile = null;
|
20 |
|
21 |
+
$locale = strtolower( $locale );
|
22 |
+
if ( $locale == 'en_us' ) {
|
23 |
+
$locale = '';
|
24 |
}
|
25 |
|
26 |
+
$locale = str_replace( '-', '_', $locale );
|
27 |
|
28 |
+
if ( strpos( $locale, '_' ) ) {
|
29 |
+
list( $pt1, $pt2 ) = explode( '_', $locale );
|
30 |
+
$locale = $pt1.'_'.strtoupper( $pt2 );
|
31 |
}
|
32 |
|
33 |
+
$url = sprintf(
|
34 |
static::URL_DOWNLOAD,
|
35 |
+
( empty( $locale ) ? '' : $locale.'.' ),
|
36 |
+
$version,
|
37 |
+
( empty( $locale ) ? '' : '-'.$locale )
|
38 |
);
|
39 |
|
40 |
try {
|
41 |
+
$tmpFile = ( new HttpUtil() )->downloadUrl( $url );
|
42 |
}
|
43 |
+
catch ( \Exception $e ) {
|
44 |
}
|
45 |
+
return $tmpFile;
|
46 |
}
|
47 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Files.php
CHANGED
@@ -4,37 +4,33 @@ 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 $
|
15 |
* @return string|null
|
16 |
* @throws \InvalidArgumentException
|
17 |
*/
|
18 |
-
public function getOriginalFileFromVcs( $
|
19 |
-
if ( !Services\Services::CoreFileHashes()->isCoreFile( $
|
20 |
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
21 |
}
|
22 |
return ( new Repo() )->downloadFromVcs(
|
23 |
-
Services\Services::WpFs()->getPathRelativeToAbsPath( $
|
24 |
);
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
* @param string $
|
29 |
* @return bool
|
30 |
* @throws \InvalidArgumentException
|
31 |
*/
|
32 |
-
public function replaceFileFromVcs( $
|
33 |
-
$sTmp = $this->getOriginalFileFromVcs( $
|
34 |
return !empty( $sTmp )
|
35 |
&& Services\Services::WpFs()->move(
|
36 |
$sTmp,
|
37 |
-
Services\Services::CoreFileHashes()->getAbsolutePathFromFragment( $
|
38 |
);
|
39 |
}
|
40 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Files {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $filePath
|
11 |
* @return string|null
|
12 |
* @throws \InvalidArgumentException
|
13 |
*/
|
14 |
+
public function getOriginalFileFromVcs( $filePath ) {
|
15 |
+
if ( !Services\Services::CoreFileHashes()->isCoreFile( $filePath ) ) {
|
16 |
throw new \InvalidArgumentException( 'File provided is not actually a core file.' );
|
17 |
}
|
18 |
return ( new Repo() )->downloadFromVcs(
|
19 |
+
Services\Services::WpFs()->getPathRelativeToAbsPath( $filePath )
|
20 |
);
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
+
* @param string $filePath
|
25 |
* @return bool
|
26 |
* @throws \InvalidArgumentException
|
27 |
*/
|
28 |
+
public function replaceFileFromVcs( $filePath ) {
|
29 |
+
$sTmp = $this->getOriginalFileFromVcs( $filePath );
|
30 |
return !empty( $sTmp )
|
31 |
&& Services\Services::WpFs()->move(
|
32 |
$sTmp,
|
33 |
+
Services\Services::CoreFileHashes()->getAbsolutePathFromFragment( $filePath )
|
34 |
);
|
35 |
}
|
36 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Repo.php
CHANGED
@@ -4,25 +4,21 @@ 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 $
|
18 |
-
* @param bool $
|
19 |
* @return string
|
20 |
*/
|
21 |
-
public static function GetUrlForVersion( $
|
22 |
return sprintf(
|
23 |
'%s/tags/%s',
|
24 |
-
$
|
25 |
-
$
|
26 |
);
|
27 |
}
|
28 |
|
@@ -34,43 +30,43 @@ class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
|
34 |
}
|
35 |
|
36 |
/**
|
37 |
-
* @param string $
|
38 |
-
* @param string $
|
39 |
-
* @param bool $
|
40 |
* @return string|null
|
41 |
*/
|
42 |
-
public function downloadFromVcs( $
|
43 |
-
$
|
44 |
-
if ( $
|
45 |
-
$
|
46 |
}
|
47 |
-
return $
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* @param string $
|
52 |
-
* @param string $
|
53 |
-
* @param bool $
|
54 |
* @return bool
|
55 |
*/
|
56 |
-
public function existsInVcs( $
|
57 |
-
$
|
58 |
-
if ( $
|
59 |
-
$
|
60 |
}
|
61 |
-
return $
|
62 |
}
|
63 |
|
64 |
/**
|
65 |
-
* @param string $
|
66 |
-
* @param string $
|
67 |
-
* @param bool $
|
68 |
* @return string
|
69 |
*/
|
70 |
-
protected function getVcsUrlForFileAndVersion( $
|
71 |
-
if ( empty( $
|
72 |
-
$
|
73 |
}
|
74 |
-
return sprintf( '%s/%s', static::GetUrlForVersion( $
|
75 |
}
|
76 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Repo extends Services\Utilities\WpOrg\Base\RepoBase {
|
8 |
|
9 |
const URL_VCS_ROOT = 'https://core.svn.wordpress.org';
|
10 |
const URL_VCS_ROOT_IL8N = 'https://i18n.svn.wordpress.org';
|
11 |
|
12 |
/**
|
13 |
+
* @param string $version
|
14 |
+
* @param bool $useLocale
|
15 |
* @return string
|
16 |
*/
|
17 |
+
public static function GetUrlForVersion( $version, $useLocale = true ) {
|
18 |
return sprintf(
|
19 |
'%s/tags/%s',
|
20 |
+
$useLocale ? static::URL_VCS_ROOT_IL8N : static::URL_VCS_ROOT,
|
21 |
+
$useLocale ? $version.'/dist' : $version
|
22 |
);
|
23 |
}
|
24 |
|
30 |
}
|
31 |
|
32 |
/**
|
33 |
+
* @param string $fileFragment
|
34 |
+
* @param string $version
|
35 |
+
* @param bool $useSiteLocale
|
36 |
* @return string|null
|
37 |
*/
|
38 |
+
public function downloadFromVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
39 |
+
$file = parent::downloadFromVcs( $fileFragment, $version, $useSiteLocale );
|
40 |
+
if ( $useSiteLocale && empty( $file ) ) {
|
41 |
+
$file = parent::downloadFromVcs( $fileFragment, $version, false );
|
42 |
}
|
43 |
+
return $file;
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* @param string $fileFragment
|
48 |
+
* @param string $version - leave empty to use the current version
|
49 |
+
* @param bool $useSiteLocale
|
50 |
* @return bool
|
51 |
*/
|
52 |
+
public function existsInVcs( $fileFragment, $version = null, $useSiteLocale = true ) {
|
53 |
+
$file = parent::existsInVcs( $fileFragment, $version, $useSiteLocale );
|
54 |
+
if ( $useSiteLocale && empty( $file ) ) {
|
55 |
+
$file = parent::existsInVcs( $fileFragment, $version, false );
|
56 |
}
|
57 |
+
return $file;
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* @param string $fileFragment
|
62 |
+
* @param string $version
|
63 |
+
* @param bool $useSiteLocale
|
64 |
* @return string
|
65 |
*/
|
66 |
+
protected function getVcsUrlForFileAndVersion( $fileFragment, $version, $useSiteLocale = true ) {
|
67 |
+
if ( empty( $version ) ) {
|
68 |
+
$version = Services\Services::WpGeneral()->getVersion();
|
69 |
}
|
70 |
+
return sprintf( '%s/%s', static::GetUrlForVersion( $version, $useSiteLocale ), ltrim( $fileFragment, '/' ) );
|
71 |
}
|
72 |
}
|
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Wp/Versions.php
CHANGED
@@ -4,24 +4,20 @@ 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 $
|
15 |
-
* @param bool $
|
16 |
* @return bool
|
17 |
*/
|
18 |
-
public function exists( $
|
19 |
-
$bExists = in_array( $
|
20 |
-
if ( $bExists && $
|
21 |
try {
|
22 |
-
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $
|
23 |
}
|
24 |
-
catch ( \Exception $
|
25 |
$bExists = false;
|
26 |
}
|
27 |
}
|
@@ -32,39 +28,36 @@ class Versions extends Services\Utilities\WpOrg\Base\VersionsBase {
|
|
32 |
* @return string[]
|
33 |
*/
|
34 |
protected function downloadVersions() {
|
35 |
-
$
|
36 |
->getContent( 'https://api.wordpress.org/core/stable-check/1.0/' );
|
37 |
|
38 |
-
if ( empty( $
|
39 |
-
$
|
40 |
}
|
41 |
else {
|
42 |
-
$
|
43 |
}
|
44 |
|
45 |
-
return $
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
protected function downloadVersionsAlt() {
|
52 |
-
$aV = [];
|
53 |
-
$sSvnVersionsContent = Services\Services::HttpRequest()->getContent( Repo::GetUrlForVersions() );
|
54 |
|
55 |
-
if ( !empty( $
|
56 |
$oSvnDom = new \DOMDocument();
|
57 |
-
$oSvnDom->loadHTML( $
|
58 |
|
59 |
foreach ( $oSvnDom->getElementsByTagName( 'a' ) as $oElem ) {
|
60 |
/** @var \DOMElement $oElem */
|
61 |
$sHref = $oElem->getAttribute( 'href' );
|
62 |
if ( $sHref != '../' && !filter_var( $sHref, FILTER_VALIDATE_URL ) ) {
|
63 |
-
$
|
64 |
}
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
return $
|
69 |
}
|
70 |
}
|
4 |
|
5 |
use FernleafSystems\Wordpress\Services;
|
6 |
|
|
|
|
|
|
|
|
|
7 |
class Versions extends Services\Utilities\WpOrg\Base\VersionsBase {
|
8 |
|
9 |
/**
|
10 |
+
* @param string $version
|
11 |
+
* @param bool $isVerifyUrl
|
12 |
* @return bool
|
13 |
*/
|
14 |
+
public function exists( $version, $isVerifyUrl = false ) {
|
15 |
+
$bExists = in_array( $version, $this->all() );
|
16 |
+
if ( $bExists && $isVerifyUrl ) {
|
17 |
try {
|
18 |
+
( new Services\Utilities\HttpUtil() )->checkUrl( Repo::GetUrlForVersion( $version ) );
|
19 |
}
|
20 |
+
catch ( \Exception $e ) {
|
21 |
$bExists = false;
|
22 |
}
|
23 |
}
|
28 |
* @return string[]
|
29 |
*/
|
30 |
protected function downloadVersions() {
|
31 |
+
$data = ( new Services\Utilities\HttpRequest() )
|
32 |
->getContent( 'https://api.wordpress.org/core/stable-check/1.0/' );
|
33 |
|
34 |
+
if ( empty( $data ) ) {
|
35 |
+
$versions = $this->downloadVersionsAlt();
|
36 |
}
|
37 |
else {
|
38 |
+
$versions = array_keys( json_decode( trim( $data ), true ) );
|
39 |
}
|
40 |
|
41 |
+
return $versions;
|
42 |
}
|
43 |
|
44 |
+
protected function downloadVersionsAlt() :array {
|
45 |
+
$versions = [];
|
46 |
+
$svnVersionsContent = Services\Services::HttpRequest()->getContent( Repo::GetUrlForVersions() );
|
|
|
|
|
|
|
47 |
|
48 |
+
if ( !empty( $svnVersionsContent ) ) {
|
49 |
$oSvnDom = new \DOMDocument();
|
50 |
+
$oSvnDom->loadHTML( $svnVersionsContent );
|
51 |
|
52 |
foreach ( $oSvnDom->getElementsByTagName( 'a' ) as $oElem ) {
|
53 |
/** @var \DOMElement $oElem */
|
54 |
$sHref = $oElem->getAttribute( 'href' );
|
55 |
if ( $sHref != '../' && !filter_var( $sHref, FILTER_VALIDATE_URL ) ) {
|
56 |
+
$versions[] = trim( $sHref, '/' );
|
57 |
}
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
return $versions;
|
62 |
}
|
63 |
}
|
templates/twig/snippets/plugin_vulnerability.twig
CHANGED
@@ -13,7 +13,11 @@
|
|
13 |
<td>{{ vuln.title }}</td>
|
14 |
<td>{{ vuln.vuln_type }}</td>
|
15 |
<td>{{ vuln.fixed_in }}</td>
|
16 |
-
<td
|
|
|
|
|
|
|
|
|
17 |
</tr>
|
18 |
{% endfor %}
|
19 |
</table>
|
13 |
<td>{{ vuln.title }}</td>
|
14 |
<td>{{ vuln.vuln_type }}</td>
|
15 |
<td>{{ vuln.fixed_in }}</td>
|
16 |
+
<td>
|
17 |
+
{% if vuln.url|default('') is not empty %}
|
18 |
+
<a href="{{ vuln.url }}" target="_blank">{{ strings.more_info }}</a>
|
19 |
+
{% endif %}
|
20 |
+
</td>
|
21 |
</tr>
|
22 |
{% endfor %}
|
23 |
</table>
|