Shield Security for WordPress - Version 16.1.10

Version Description

Download this release

Release Info

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

Code changes from version 16.1.9 to 16.1.10

cl.json CHANGED
@@ -127,6 +127,24 @@
127
  }
128
  ],
129
  "patches": [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  {
131
  "version": "9",
132
  "released_at": 1664366000,
127
  }
128
  ],
129
  "patches": [
130
+ {
131
+ "version": "10",
132
+ "released_at": 1666622000,
133
+ "items": [
134
+ {
135
+ "title": "Accessibility of user 2FA setup form has been improved for screen readers.",
136
+ "type": "improved"
137
+ },
138
+ {
139
+ "title": "Improved the data used to construct the QR codes for Google Authenticator setup.",
140
+ "type": "improved"
141
+ },
142
+ {
143
+ "title": "Bug where Import/Export would fail where certain restrictions existed on site hosting.",
144
+ "type": "fixed"
145
+ }
146
+ ]
147
+ },
148
  {
149
  "version": "9",
150
  "released_at": 1664366000,
config/deprecated/audit_trail.php CHANGED
@@ -32,12 +32,6 @@
32
  "wpcli": {
33
  "enabled": true
34
  },
35
- "menu_items": [
36
- {
37
- "title": "Activity Log",
38
- "slug": "audit-redirect"
39
- }
40
- ],
41
  "custom_redirects": [
42
  {
43
  "source_mod_page": "audit-redirect",
32
  "wpcli": {
33
  "enabled": true
34
  },
 
 
 
 
 
 
35
  "custom_redirects": [
36
  {
37
  "source_mod_page": "audit-redirect",
config/deprecated/hack_protect.php CHANGED
@@ -35,12 +35,6 @@
35
  "enabled": true,
36
  "root": "hack_guard"
37
  },
38
- "menu_items": [
39
- {
40
- "title": "Scans",
41
- "slug": "scans-redirect"
42
- }
43
- ],
44
  "custom_redirects": [
45
  {
46
  "source_mod_page": "scans-redirect",
35
  "enabled": true,
36
  "root": "hack_guard"
37
  },
 
 
 
 
 
 
38
  "custom_redirects": [
39
  {
40
  "source_mod_page": "scans-redirect",
config/deprecated/insights.php CHANGED
@@ -19,6 +19,33 @@
19
  "skip_processor": true,
20
  "tracking_exclude": true
21
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  "wpcli": {
23
  "enabled": false
24
  },
19
  "skip_processor": true,
20
  "tracking_exclude": true
21
  },
22
+ "menu_items": [
23
+ {
24
+ "title": "Configuration",
25
+ "slug": "redirect-config"
26
+ },
27
+ {
28
+ "title": "IP Manager",
29
+ "slug": "redirect-ips"
30
+ },
31
+ {
32
+ "title": "Scans",
33
+ "slug": "redirect-scans_results"
34
+ },
35
+ {
36
+ "title": "Activity Log",
37
+ "slug": "redirect-audit_trail"
38
+ },
39
+ {
40
+ "title": "Traffic Log",
41
+ "slug": "redirect-traffic"
42
+ },
43
+ {
44
+ "title": "Go PRO!",
45
+ "slug": "redirect-license",
46
+ "highlight": true
47
+ }
48
+ ],
49
  "wpcli": {
50
  "enabled": false
51
  },
config/deprecated/ips.php CHANGED
@@ -30,12 +30,6 @@
30
  "wpcli": {
31
  "enabled": true
32
  },
33
- "menu_items": [
34
- {
35
- "title": "IP Manager",
36
- "slug": "ips-redirect"
37
- }
38
- ],
39
  "custom_redirects": [
40
  {
41
  "source_mod_page": "ips-redirect",
30
  "wpcli": {
31
  "enabled": true
32
  },
 
 
 
 
 
 
33
  "custom_redirects": [
34
  {
35
  "source_mod_page": "ips-redirect",
config/deprecated/license.php CHANGED
@@ -30,13 +30,6 @@
30
  "type": "error"
31
  }
32
  },
33
- "menu_items": [
34
- {
35
- "title": "Go PRO!",
36
- "slug": "pro-redirect",
37
- "highlight": true
38
- }
39
- ],
40
  "custom_redirects": [
41
  {
42
  "source_mod_page": "pro-redirect",
30
  "type": "error"
31
  }
32
  },
 
 
 
 
 
 
 
33
  "custom_redirects": [
34
  {
35
  "source_mod_page": "pro-redirect",
config/deprecated/plugin.php CHANGED
@@ -73,15 +73,6 @@
73
  "can_dismiss": false,
74
  "type": "error"
75
  },
76
- "compat-sgoptimize": {
77
- "id": "compat-sgoptimize",
78
- "schedule": "conditions",
79
- "valid_admin": true,
80
- "plugin_admin": "ignore",
81
- "plugin_page_only": false,
82
- "can_dismiss": false,
83
- "type": "warning"
84
- },
85
  "plugin-mailing-list-signup": {
86
  "id": "plugin-mailing-list-signup",
87
  "min_install_days": 5,
73
  "can_dismiss": false,
74
  "type": "error"
75
  },
 
 
 
 
 
 
 
 
 
76
  "plugin-mailing-list-signup": {
77
  "id": "plugin-mailing-list-signup",
78
  "min_install_days": 5,
config/deprecated/reporting.php CHANGED
@@ -18,10 +18,6 @@
18
  "wpcli": {
19
  "enabled": true
20
  },
21
- "menu_items": [
22
- ],
23
- "custom_redirects": [
24
- ],
25
  "sections": [
26
  {
27
  "slug": "section_timings",
18
  "wpcli": {
19
  "enabled": true
20
  },
 
 
 
 
21
  "sections": [
22
  {
23
  "slug": "section_timings",
config/deprecated/traffic.php CHANGED
@@ -30,12 +30,6 @@
30
  "wpcli": {
31
  "enabled": true
32
  },
33
- "menu_items": [
34
- {
35
- "title": "Traffic Log",
36
- "slug": "traffic-redirect"
37
- }
38
- ],
39
  "custom_redirects": [
40
  {
41
  "source_mod_page": "traffic-redirect",
30
  "wpcli": {
31
  "enabled": true
32
  },
 
 
 
 
 
 
33
  "custom_redirects": [
34
  {
35
  "source_mod_page": "traffic-redirect",
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: 16.1.9
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: 16.1.10
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": "16.1.9",
4
- "release_timestamp": 1664366000,
5
- "build": "202209.2803",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "text_domain": "wp-simple-firewall",
@@ -196,8 +196,6 @@
196
  "wp-jquery"
197
  ]
198
  },
199
- "tp/qrcode.min": {
200
- },
201
  "plugin": {
202
  "deps": [
203
  "bootstrap",
@@ -215,6 +213,11 @@
215
  },
216
  "lz-string.min": {},
217
  "jquery/fileDownload": {},
 
 
 
 
 
218
  "jquery/smartwizard": {
219
  "url": "https://cdn.jsdelivr.net/npm/smartwizard@6/dist/js/jquery.smartWizard.min.js",
220
  "deps": [
@@ -331,7 +334,7 @@
331
  "shield/userprofile": {
332
  "deps": [
333
  "u2f-bundle",
334
- "tp/qrcode.min",
335
  "shield/dialog"
336
  ],
337
  "footer": true
1
  {
2
  "properties": {
3
+ "version": "16.1.10",
4
+ "release_timestamp": 1666622000,
5
+ "build": "202210.2401",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "text_domain": "wp-simple-firewall",
196
  "wp-jquery"
197
  ]
198
  },
 
 
199
  "plugin": {
200
  "deps": [
201
  "bootstrap",
213
  },
214
  "lz-string.min": {},
215
  "jquery/fileDownload": {},
216
+ "jquery/jquery.qrcode": {
217
+ "deps": [
218
+ "wp-jquery"
219
+ ]
220
+ },
221
  "jquery/smartwizard": {
222
  "url": "https://cdn.jsdelivr.net/npm/smartwizard@6/dist/js/jquery.smartWizard.min.js",
223
  "deps": [
334
  "shield/userprofile": {
335
  "deps": [
336
  "u2f-bundle",
337
+ "jquery/jquery.qrcode",
338
  "shield/dialog"
339
  ],
340
  "footer": true
plugin.json CHANGED
@@ -1,8 +1,8 @@
1
  {
2
  "properties": {
3
- "version": "16.1.9",
4
- "release_timestamp": 1664366000,
5
- "build": "202209.2803",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "text_domain": "wp-simple-firewall",
@@ -196,8 +196,6 @@
196
  "wp-jquery"
197
  ]
198
  },
199
- "tp/qrcode.min": {
200
- },
201
  "plugin": {
202
  "deps": [
203
  "bootstrap",
@@ -215,6 +213,11 @@
215
  },
216
  "lz-string.min": {},
217
  "jquery/fileDownload": {},
 
 
 
 
 
218
  "jquery/smartwizard": {
219
  "url": "https://cdn.jsdelivr.net/npm/smartwizard@6/dist/js/jquery.smartWizard.min.js",
220
  "deps": [
@@ -331,7 +334,7 @@
331
  "shield/userprofile": {
332
  "deps": [
333
  "u2f-bundle",
334
- "tp/qrcode.min",
335
  "shield/dialog"
336
  ],
337
  "footer": true
1
  {
2
  "properties": {
3
+ "version": "16.1.10",
4
+ "release_timestamp": 1666622000,
5
+ "build": "202210.2401",
6
  "slug_parent": "icwp",
7
  "slug_plugin": "wpsf",
8
  "text_domain": "wp-simple-firewall",
196
  "wp-jquery"
197
  ]
198
  },
 
 
199
  "plugin": {
200
  "deps": [
201
  "bootstrap",
213
  },
214
  "lz-string.min": {},
215
  "jquery/fileDownload": {},
216
+ "jquery/jquery.qrcode": {
217
+ "deps": [
218
+ "wp-jquery"
219
+ ]
220
+ },
221
  "jquery/smartwizard": {
222
  "url": "https://cdn.jsdelivr.net/npm/smartwizard@6/dist/js/jquery.smartWizard.min.js",
223
  "deps": [
334
  "shield/userprofile": {
335
  "deps": [
336
  "u2f-bundle",
337
+ "jquery/jquery.qrcode",
338
  "shield/dialog"
339
  ],
340
  "footer": true
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: 6.0
11
- Stable tag: 16.1.9
12
 
13
  Bad Bots Are Your #1 Security Risk. Stop playing whack-a-mole with malware and vulnerabilities. Discover the advantage of putting real security before marketing.
14
 
8
  Requires PHP: 7.0
9
  Recommended PHP: 7.4
10
  Tested up to: 6.0
11
+ Stable tag: 16.1.10
12
 
13
  Bad Bots Are Your #1 Security Risk. Stop playing whack-a-mole with malware and vulnerabilities. Discover the advantage of putting real security before marketing.
14
 
resources/js/jquery/jquery.qrcode.js ADDED
@@ -0,0 +1,1327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //---------------------------------------------------------------------
2
+ // QRCode for JavaScript
3
+ //
4
+ // Copyright (c) 2009 Kazuhiko Arase
5
+ //
6
+ // URL: http://www.d-project.com/
7
+ //
8
+ // Licensed under the MIT license:
9
+ // http://www.opensource.org/licenses/mit-license.php
10
+ //
11
+ // The word "QR Code" is registered trademark of
12
+ // DENSO WAVE INCORPORATED
13
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
14
+ //
15
+ //---------------------------------------------------------------------
16
+
17
+ //---------------------------------------------------------------------
18
+ // QR8bitByte
19
+ //---------------------------------------------------------------------
20
+
21
+ function QR8bitByte(data) {
22
+ this.mode = QRMode.MODE_8BIT_BYTE;
23
+ this.data = data;
24
+ }
25
+
26
+ QR8bitByte.prototype = {
27
+
28
+ getLength : function(buffer) {
29
+ return this.data.length;
30
+ },
31
+
32
+ write : function(buffer) {
33
+ for (var i = 0; i < this.data.length; i++) {
34
+ // not JIS ...
35
+ buffer.put(this.data.charCodeAt(i), 8);
36
+ }
37
+ }
38
+ };
39
+
40
+ //---------------------------------------------------------------------
41
+ // QRCode
42
+ //---------------------------------------------------------------------
43
+
44
+ function QRCode(typeNumber, errorCorrectLevel) {
45
+ this.typeNumber = typeNumber;
46
+ this.errorCorrectLevel = errorCorrectLevel;
47
+ this.modules = null;
48
+ this.moduleCount = 0;
49
+ this.dataCache = null;
50
+ this.dataList = new Array();
51
+ }
52
+
53
+ QRCode.prototype = {
54
+
55
+ addData : function(data) {
56
+ var newData = new QR8bitByte(data);
57
+ this.dataList.push(newData);
58
+ this.dataCache = null;
59
+ },
60
+
61
+ isDark : function(row, col) {
62
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
63
+ throw new Error(row + "," + col);
64
+ }
65
+ return this.modules[row][col];
66
+ },
67
+
68
+ getModuleCount : function() {
69
+ return this.moduleCount;
70
+ },
71
+
72
+ make : function() {
73
+ // Calculate automatically typeNumber if provided is < 1
74
+ if (this.typeNumber < 1 ){
75
+ var typeNumber = 1;
76
+ for (typeNumber = 1; typeNumber < 40; typeNumber++) {
77
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
78
+
79
+ var buffer = new QRBitBuffer();
80
+ var totalDataCount = 0;
81
+ for (var i = 0; i < rsBlocks.length; i++) {
82
+ totalDataCount += rsBlocks[i].dataCount;
83
+ }
84
+
85
+ for (var i = 0; i < this.dataList.length; i++) {
86
+ var data = this.dataList[i];
87
+ buffer.put(data.mode, 4);
88
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) );
89
+ data.write(buffer);
90
+ }
91
+ if (buffer.getLengthInBits() <= totalDataCount * 8)
92
+ break;
93
+ }
94
+ this.typeNumber = typeNumber;
95
+ }
96
+ this.makeImpl(false, this.getBestMaskPattern() );
97
+ },
98
+
99
+ makeImpl : function(test, maskPattern) {
100
+
101
+ this.moduleCount = this.typeNumber * 4 + 17;
102
+ this.modules = new Array(this.moduleCount);
103
+
104
+ for (var row = 0; row < this.moduleCount; row++) {
105
+
106
+ this.modules[row] = new Array(this.moduleCount);
107
+
108
+ for (var col = 0; col < this.moduleCount; col++) {
109
+ this.modules[row][col] = null;//(col + row) % 3;
110
+ }
111
+ }
112
+
113
+ this.setupPositionProbePattern(0, 0);
114
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
115
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
116
+ this.setupPositionAdjustPattern();
117
+ this.setupTimingPattern();
118
+ this.setupTypeInfo(test, maskPattern);
119
+
120
+ if (this.typeNumber >= 7) {
121
+ this.setupTypeNumber(test);
122
+ }
123
+
124
+ if (this.dataCache == null) {
125
+ this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
126
+ }
127
+
128
+ this.mapData(this.dataCache, maskPattern);
129
+ },
130
+
131
+ setupPositionProbePattern : function(row, col) {
132
+
133
+ for (var r = -1; r <= 7; r++) {
134
+
135
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
136
+
137
+ for (var c = -1; c <= 7; c++) {
138
+
139
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
140
+
141
+ if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
142
+ || (0 <= c && c <= 6 && (r == 0 || r == 6) )
143
+ || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
144
+ this.modules[row + r][col + c] = true;
145
+ } else {
146
+ this.modules[row + r][col + c] = false;
147
+ }
148
+ }
149
+ }
150
+ },
151
+
152
+ getBestMaskPattern : function() {
153
+
154
+ var minLostPoint = 0;
155
+ var pattern = 0;
156
+
157
+ for (var i = 0; i < 8; i++) {
158
+
159
+ this.makeImpl(true, i);
160
+
161
+ var lostPoint = QRUtil.getLostPoint(this);
162
+
163
+ if (i == 0 || minLostPoint > lostPoint) {
164
+ minLostPoint = lostPoint;
165
+ pattern = i;
166
+ }
167
+ }
168
+
169
+ return pattern;
170
+ },
171
+
172
+ createMovieClip : function(target_mc, instance_name, depth) {
173
+
174
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
175
+ var cs = 1;
176
+
177
+ this.make();
178
+
179
+ for (var row = 0; row < this.modules.length; row++) {
180
+
181
+ var y = row * cs;
182
+
183
+ for (var col = 0; col < this.modules[row].length; col++) {
184
+
185
+ var x = col * cs;
186
+ var dark = this.modules[row][col];
187
+
188
+ if (dark) {
189
+ qr_mc.beginFill(0, 100);
190
+ qr_mc.moveTo(x, y);
191
+ qr_mc.lineTo(x + cs, y);
192
+ qr_mc.lineTo(x + cs, y + cs);
193
+ qr_mc.lineTo(x, y + cs);
194
+ qr_mc.endFill();
195
+ }
196
+ }
197
+ }
198
+
199
+ return qr_mc;
200
+ },
201
+
202
+ setupTimingPattern : function() {
203
+
204
+ for (var r = 8; r < this.moduleCount - 8; r++) {
205
+ if (this.modules[r][6] != null) {
206
+ continue;
207
+ }
208
+ this.modules[r][6] = (r % 2 == 0);
209
+ }
210
+
211
+ for (var c = 8; c < this.moduleCount - 8; c++) {
212
+ if (this.modules[6][c] != null) {
213
+ continue;
214
+ }
215
+ this.modules[6][c] = (c % 2 == 0);
216
+ }
217
+ },
218
+
219
+ setupPositionAdjustPattern : function() {
220
+
221
+ var pos = QRUtil.getPatternPosition(this.typeNumber);
222
+
223
+ for (var i = 0; i < pos.length; i++) {
224
+
225
+ for (var j = 0; j < pos.length; j++) {
226
+
227
+ var row = pos[i];
228
+ var col = pos[j];
229
+
230
+ if (this.modules[row][col] != null) {
231
+ continue;
232
+ }
233
+
234
+ for (var r = -2; r <= 2; r++) {
235
+
236
+ for (var c = -2; c <= 2; c++) {
237
+
238
+ if (r == -2 || r == 2 || c == -2 || c == 2
239
+ || (r == 0 && c == 0) ) {
240
+ this.modules[row + r][col + c] = true;
241
+ } else {
242
+ this.modules[row + r][col + c] = false;
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ },
249
+
250
+ setupTypeNumber : function(test) {
251
+
252
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
253
+
254
+ for (var i = 0; i < 18; i++) {
255
+ var mod = (!test && ( (bits >> i) & 1) == 1);
256
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
257
+ }
258
+
259
+ for (var i = 0; i < 18; i++) {
260
+ var mod = (!test && ( (bits >> i) & 1) == 1);
261
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
262
+ }
263
+ },
264
+
265
+ setupTypeInfo : function(test, maskPattern) {
266
+
267
+ var data = (this.errorCorrectLevel << 3) | maskPattern;
268
+ var bits = QRUtil.getBCHTypeInfo(data);
269
+
270
+ // vertical
271
+ for (var i = 0; i < 15; i++) {
272
+
273
+ var mod = (!test && ( (bits >> i) & 1) == 1);
274
+
275
+ if (i < 6) {
276
+ this.modules[i][8] = mod;
277
+ } else if (i < 8) {
278
+ this.modules[i + 1][8] = mod;
279
+ } else {
280
+ this.modules[this.moduleCount - 15 + i][8] = mod;
281
+ }
282
+ }
283
+
284
+ // horizontal
285
+ for (var i = 0; i < 15; i++) {
286
+
287
+ var mod = (!test && ( (bits >> i) & 1) == 1);
288
+
289
+ if (i < 8) {
290
+ this.modules[8][this.moduleCount - i - 1] = mod;
291
+ } else if (i < 9) {
292
+ this.modules[8][15 - i - 1 + 1] = mod;
293
+ } else {
294
+ this.modules[8][15 - i - 1] = mod;
295
+ }
296
+ }
297
+
298
+ // fixed module
299
+ this.modules[this.moduleCount - 8][8] = (!test);
300
+
301
+ },
302
+
303
+ mapData : function(data, maskPattern) {
304
+
305
+ var inc = -1;
306
+ var row = this.moduleCount - 1;
307
+ var bitIndex = 7;
308
+ var byteIndex = 0;
309
+
310
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
311
+
312
+ if (col == 6) col--;
313
+
314
+ while (true) {
315
+
316
+ for (var c = 0; c < 2; c++) {
317
+
318
+ if (this.modules[row][col - c] == null) {
319
+
320
+ var dark = false;
321
+
322
+ if (byteIndex < data.length) {
323
+ dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
324
+ }
325
+
326
+ var mask = QRUtil.getMask(maskPattern, row, col - c);
327
+
328
+ if (mask) {
329
+ dark = !dark;
330
+ }
331
+
332
+ this.modules[row][col - c] = dark;
333
+ bitIndex--;
334
+
335
+ if (bitIndex == -1) {
336
+ byteIndex++;
337
+ bitIndex = 7;
338
+ }
339
+ }
340
+ }
341
+
342
+ row += inc;
343
+
344
+ if (row < 0 || this.moduleCount <= row) {
345
+ row -= inc;
346
+ inc = -inc;
347
+ break;
348
+ }
349
+ }
350
+ }
351
+
352
+ }
353
+
354
+ };
355
+
356
+ QRCode.PAD0 = 0xEC;
357
+ QRCode.PAD1 = 0x11;
358
+
359
+ QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
360
+
361
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
362
+
363
+ var buffer = new QRBitBuffer();
364
+
365
+ for (var i = 0; i < dataList.length; i++) {
366
+ var data = dataList[i];
367
+ buffer.put(data.mode, 4);
368
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) );
369
+ data.write(buffer);
370
+ }
371
+
372
+ // calc num max data.
373
+ var totalDataCount = 0;
374
+ for (var i = 0; i < rsBlocks.length; i++) {
375
+ totalDataCount += rsBlocks[i].dataCount;
376
+ }
377
+
378
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
379
+ throw new Error("code length overflow. ("
380
+ + buffer.getLengthInBits()
381
+ + ">"
382
+ + totalDataCount * 8
383
+ + ")");
384
+ }
385
+
386
+ // end code
387
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
388
+ buffer.put(0, 4);
389
+ }
390
+
391
+ // padding
392
+ while (buffer.getLengthInBits() % 8 != 0) {
393
+ buffer.putBit(false);
394
+ }
395
+
396
+ // padding
397
+ while (true) {
398
+
399
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
400
+ break;
401
+ }
402
+ buffer.put(QRCode.PAD0, 8);
403
+
404
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
405
+ break;
406
+ }
407
+ buffer.put(QRCode.PAD1, 8);
408
+ }
409
+
410
+ return QRCode.createBytes(buffer, rsBlocks);
411
+ }
412
+
413
+ QRCode.createBytes = function(buffer, rsBlocks) {
414
+
415
+ var offset = 0;
416
+
417
+ var maxDcCount = 0;
418
+ var maxEcCount = 0;
419
+
420
+ var dcdata = new Array(rsBlocks.length);
421
+ var ecdata = new Array(rsBlocks.length);
422
+
423
+ for (var r = 0; r < rsBlocks.length; r++) {
424
+
425
+ var dcCount = rsBlocks[r].dataCount;
426
+ var ecCount = rsBlocks[r].totalCount - dcCount;
427
+
428
+ maxDcCount = Math.max(maxDcCount, dcCount);
429
+ maxEcCount = Math.max(maxEcCount, ecCount);
430
+
431
+ dcdata[r] = new Array(dcCount);
432
+
433
+ for (var i = 0; i < dcdata[r].length; i++) {
434
+ dcdata[r][i] = 0xff & buffer.buffer[i + offset];
435
+ }
436
+ offset += dcCount;
437
+
438
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
439
+ var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
440
+
441
+ var modPoly = rawPoly.mod(rsPoly);
442
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
443
+ for (var i = 0; i < ecdata[r].length; i++) {
444
+ var modIndex = i + modPoly.getLength() - ecdata[r].length;
445
+ ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
446
+ }
447
+
448
+ }
449
+
450
+ var totalCodeCount = 0;
451
+ for (var i = 0; i < rsBlocks.length; i++) {
452
+ totalCodeCount += rsBlocks[i].totalCount;
453
+ }
454
+
455
+ var data = new Array(totalCodeCount);
456
+ var index = 0;
457
+
458
+ for (var i = 0; i < maxDcCount; i++) {
459
+ for (var r = 0; r < rsBlocks.length; r++) {
460
+ if (i < dcdata[r].length) {
461
+ data[index++] = dcdata[r][i];
462
+ }
463
+ }
464
+ }
465
+
466
+ for (var i = 0; i < maxEcCount; i++) {
467
+ for (var r = 0; r < rsBlocks.length; r++) {
468
+ if (i < ecdata[r].length) {
469
+ data[index++] = ecdata[r][i];
470
+ }
471
+ }
472
+ }
473
+
474
+ return data;
475
+
476
+ }
477
+
478
+ //---------------------------------------------------------------------
479
+ // QRMode
480
+ //---------------------------------------------------------------------
481
+
482
+ var QRMode = {
483
+ MODE_NUMBER : 1 << 0,
484
+ MODE_ALPHA_NUM : 1 << 1,
485
+ MODE_8BIT_BYTE : 1 << 2,
486
+ MODE_KANJI : 1 << 3
487
+ };
488
+
489
+ //---------------------------------------------------------------------
490
+ // QRErrorCorrectLevel
491
+ //---------------------------------------------------------------------
492
+
493
+ var QRErrorCorrectLevel = {
494
+ L : 1,
495
+ M : 0,
496
+ Q : 3,
497
+ H : 2
498
+ };
499
+
500
+ //---------------------------------------------------------------------
501
+ // QRMaskPattern
502
+ //---------------------------------------------------------------------
503
+
504
+ var QRMaskPattern = {
505
+ PATTERN000 : 0,
506
+ PATTERN001 : 1,
507
+ PATTERN010 : 2,
508
+ PATTERN011 : 3,
509
+ PATTERN100 : 4,
510
+ PATTERN101 : 5,
511
+ PATTERN110 : 6,
512
+ PATTERN111 : 7
513
+ };
514
+
515
+ //---------------------------------------------------------------------
516
+ // QRUtil
517
+ //---------------------------------------------------------------------
518
+
519
+ var QRUtil = {
520
+
521
+ PATTERN_POSITION_TABLE : [
522
+ [],
523
+ [6, 18],
524
+ [6, 22],
525
+ [6, 26],
526
+ [6, 30],
527
+ [6, 34],
528
+ [6, 22, 38],
529
+ [6, 24, 42],
530
+ [6, 26, 46],
531
+ [6, 28, 50],
532
+ [6, 30, 54],
533
+ [6, 32, 58],
534
+ [6, 34, 62],
535
+ [6, 26, 46, 66],
536
+ [6, 26, 48, 70],
537
+ [6, 26, 50, 74],
538
+ [6, 30, 54, 78],
539
+ [6, 30, 56, 82],
540
+ [6, 30, 58, 86],
541
+ [6, 34, 62, 90],
542
+ [6, 28, 50, 72, 94],
543
+ [6, 26, 50, 74, 98],
544
+ [6, 30, 54, 78, 102],
545
+ [6, 28, 54, 80, 106],
546
+ [6, 32, 58, 84, 110],
547
+ [6, 30, 58, 86, 114],
548
+ [6, 34, 62, 90, 118],
549
+ [6, 26, 50, 74, 98, 122],
550
+ [6, 30, 54, 78, 102, 126],
551
+ [6, 26, 52, 78, 104, 130],
552
+ [6, 30, 56, 82, 108, 134],
553
+ [6, 34, 60, 86, 112, 138],
554
+ [6, 30, 58, 86, 114, 142],
555
+ [6, 34, 62, 90, 118, 146],
556
+ [6, 30, 54, 78, 102, 126, 150],
557
+ [6, 24, 50, 76, 102, 128, 154],
558
+ [6, 28, 54, 80, 106, 132, 158],
559
+ [6, 32, 58, 84, 110, 136, 162],
560
+ [6, 26, 54, 82, 110, 138, 166],
561
+ [6, 30, 58, 86, 114, 142, 170]
562
+ ],
563
+
564
+ G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
565
+ G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
566
+ G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
567
+
568
+ getBCHTypeInfo : function(data) {
569
+ var d = data << 10;
570
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
571
+ d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) );
572
+ }
573
+ return ( (data << 10) | d) ^ QRUtil.G15_MASK;
574
+ },
575
+
576
+ getBCHTypeNumber : function(data) {
577
+ var d = data << 12;
578
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
579
+ d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) );
580
+ }
581
+ return (data << 12) | d;
582
+ },
583
+
584
+ getBCHDigit : function(data) {
585
+
586
+ var digit = 0;
587
+
588
+ while (data != 0) {
589
+ digit++;
590
+ data >>>= 1;
591
+ }
592
+
593
+ return digit;
594
+ },
595
+
596
+ getPatternPosition : function(typeNumber) {
597
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
598
+ },
599
+
600
+ getMask : function(maskPattern, i, j) {
601
+
602
+ switch (maskPattern) {
603
+
604
+ case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0;
605
+ case QRMaskPattern.PATTERN001 : return i % 2 == 0;
606
+ case QRMaskPattern.PATTERN010 : return j % 3 == 0;
607
+ case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0;
608
+ case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0;
609
+ case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0;
610
+ case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0;
611
+ case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0;
612
+
613
+ default :
614
+ throw new Error("bad maskPattern:" + maskPattern);
615
+ }
616
+ },
617
+
618
+ getErrorCorrectPolynomial : function(errorCorrectLength) {
619
+
620
+ var a = new QRPolynomial([1], 0);
621
+
622
+ for (var i = 0; i < errorCorrectLength; i++) {
623
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) );
624
+ }
625
+
626
+ return a;
627
+ },
628
+
629
+ getLengthInBits : function(mode, type) {
630
+
631
+ if (1 <= type && type < 10) {
632
+
633
+ // 1 - 9
634
+
635
+ switch(mode) {
636
+ case QRMode.MODE_NUMBER : return 10;
637
+ case QRMode.MODE_ALPHA_NUM : return 9;
638
+ case QRMode.MODE_8BIT_BYTE : return 8;
639
+ case QRMode.MODE_KANJI : return 8;
640
+ default :
641
+ throw new Error("mode:" + mode);
642
+ }
643
+
644
+ } else if (type < 27) {
645
+
646
+ // 10 - 26
647
+
648
+ switch(mode) {
649
+ case QRMode.MODE_NUMBER : return 12;
650
+ case QRMode.MODE_ALPHA_NUM : return 11;
651
+ case QRMode.MODE_8BIT_BYTE : return 16;
652
+ case QRMode.MODE_KANJI : return 10;
653
+ default :
654
+ throw new Error("mode:" + mode);
655
+ }
656
+
657
+ } else if (type < 41) {
658
+
659
+ // 27 - 40
660
+
661
+ switch(mode) {
662
+ case QRMode.MODE_NUMBER : return 14;
663
+ case QRMode.MODE_ALPHA_NUM : return 13;
664
+ case QRMode.MODE_8BIT_BYTE : return 16;
665
+ case QRMode.MODE_KANJI : return 12;
666
+ default :
667
+ throw new Error("mode:" + mode);
668
+ }
669
+
670
+ } else {
671
+ throw new Error("type:" + type);
672
+ }
673
+ },
674
+
675
+ getLostPoint : function(qrCode) {
676
+
677
+ var moduleCount = qrCode.getModuleCount();
678
+
679
+ var lostPoint = 0;
680
+
681
+ // LEVEL1
682
+
683
+ for (var row = 0; row < moduleCount; row++) {
684
+
685
+ for (var col = 0; col < moduleCount; col++) {
686
+
687
+ var sameCount = 0;
688
+ var dark = qrCode.isDark(row, col);
689
+
690
+ for (var r = -1; r <= 1; r++) {
691
+
692
+ if (row + r < 0 || moduleCount <= row + r) {
693
+ continue;
694
+ }
695
+
696
+ for (var c = -1; c <= 1; c++) {
697
+
698
+ if (col + c < 0 || moduleCount <= col + c) {
699
+ continue;
700
+ }
701
+
702
+ if (r == 0 && c == 0) {
703
+ continue;
704
+ }
705
+
706
+ if (dark == qrCode.isDark(row + r, col + c) ) {
707
+ sameCount++;
708
+ }
709
+ }
710
+ }
711
+
712
+ if (sameCount > 5) {
713
+ lostPoint += (3 + sameCount - 5);
714
+ }
715
+ }
716
+ }
717
+
718
+ // LEVEL2
719
+
720
+ for (var row = 0; row < moduleCount - 1; row++) {
721
+ for (var col = 0; col < moduleCount - 1; col++) {
722
+ var count = 0;
723
+ if (qrCode.isDark(row, col ) ) count++;
724
+ if (qrCode.isDark(row + 1, col ) ) count++;
725
+ if (qrCode.isDark(row, col + 1) ) count++;
726
+ if (qrCode.isDark(row + 1, col + 1) ) count++;
727
+ if (count == 0 || count == 4) {
728
+ lostPoint += 3;
729
+ }
730
+ }
731
+ }
732
+
733
+ // LEVEL3
734
+
735
+ for (var row = 0; row < moduleCount; row++) {
736
+ for (var col = 0; col < moduleCount - 6; col++) {
737
+ if (qrCode.isDark(row, col)
738
+ && !qrCode.isDark(row, col + 1)
739
+ && qrCode.isDark(row, col + 2)
740
+ && qrCode.isDark(row, col + 3)
741
+ && qrCode.isDark(row, col + 4)
742
+ && !qrCode.isDark(row, col + 5)
743
+ && qrCode.isDark(row, col + 6) ) {
744
+ lostPoint += 40;
745
+ }
746
+ }
747
+ }
748
+
749
+ for (var col = 0; col < moduleCount; col++) {
750
+ for (var row = 0; row < moduleCount - 6; row++) {
751
+ if (qrCode.isDark(row, col)
752
+ && !qrCode.isDark(row + 1, col)
753
+ && qrCode.isDark(row + 2, col)
754
+ && qrCode.isDark(row + 3, col)
755
+ && qrCode.isDark(row + 4, col)
756
+ && !qrCode.isDark(row + 5, col)
757
+ && qrCode.isDark(row + 6, col) ) {
758
+ lostPoint += 40;
759
+ }
760
+ }
761
+ }
762
+
763
+ // LEVEL4
764
+
765
+ var darkCount = 0;
766
+
767
+ for (var col = 0; col < moduleCount; col++) {
768
+ for (var row = 0; row < moduleCount; row++) {
769
+ if (qrCode.isDark(row, col) ) {
770
+ darkCount++;
771
+ }
772
+ }
773
+ }
774
+
775
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
776
+ lostPoint += ratio * 10;
777
+
778
+ return lostPoint;
779
+ }
780
+
781
+ };
782
+
783
+
784
+ //---------------------------------------------------------------------
785
+ // QRMath
786
+ //---------------------------------------------------------------------
787
+
788
+ var QRMath = {
789
+
790
+ glog : function(n) {
791
+
792
+ if (n < 1) {
793
+ throw new Error("glog(" + n + ")");
794
+ }
795
+
796
+ return QRMath.LOG_TABLE[n];
797
+ },
798
+
799
+ gexp : function(n) {
800
+
801
+ while (n < 0) {
802
+ n += 255;
803
+ }
804
+
805
+ while (n >= 256) {
806
+ n -= 255;
807
+ }
808
+
809
+ return QRMath.EXP_TABLE[n];
810
+ },
811
+
812
+ EXP_TABLE : new Array(256),
813
+
814
+ LOG_TABLE : new Array(256)
815
+
816
+ };
817
+
818
+ for (var i = 0; i < 8; i++) {
819
+ QRMath.EXP_TABLE[i] = 1 << i;
820
+ }
821
+ for (var i = 8; i < 256; i++) {
822
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4]
823
+ ^ QRMath.EXP_TABLE[i - 5]
824
+ ^ QRMath.EXP_TABLE[i - 6]
825
+ ^ QRMath.EXP_TABLE[i - 8];
826
+ }
827
+ for (var i = 0; i < 255; i++) {
828
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i;
829
+ }
830
+
831
+ //---------------------------------------------------------------------
832
+ // QRPolynomial
833
+ //---------------------------------------------------------------------
834
+
835
+ function QRPolynomial(num, shift) {
836
+
837
+ if (num.length == undefined) {
838
+ throw new Error(num.length + "/" + shift);
839
+ }
840
+
841
+ var offset = 0;
842
+
843
+ while (offset < num.length && num[offset] == 0) {
844
+ offset++;
845
+ }
846
+
847
+ this.num = new Array(num.length - offset + shift);
848
+ for (var i = 0; i < num.length - offset; i++) {
849
+ this.num[i] = num[i + offset];
850
+ }
851
+ }
852
+
853
+ QRPolynomial.prototype = {
854
+
855
+ get : function(index) {
856
+ return this.num[index];
857
+ },
858
+
859
+ getLength : function() {
860
+ return this.num.length;
861
+ },
862
+
863
+ multiply : function(e) {
864
+
865
+ var num = new Array(this.getLength() + e.getLength() - 1);
866
+
867
+ for (var i = 0; i < this.getLength(); i++) {
868
+ for (var j = 0; j < e.getLength(); j++) {
869
+ num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) );
870
+ }
871
+ }
872
+
873
+ return new QRPolynomial(num, 0);
874
+ },
875
+
876
+ mod : function(e) {
877
+
878
+ if (this.getLength() - e.getLength() < 0) {
879
+ return this;
880
+ }
881
+
882
+ var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) );
883
+
884
+ var num = new Array(this.getLength() );
885
+
886
+ for (var i = 0; i < this.getLength(); i++) {
887
+ num[i] = this.get(i);
888
+ }
889
+
890
+ for (var i = 0; i < e.getLength(); i++) {
891
+ num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio);
892
+ }
893
+
894
+ // recursive call
895
+ return new QRPolynomial(num, 0).mod(e);
896
+ }
897
+ };
898
+
899
+ //---------------------------------------------------------------------
900
+ // QRRSBlock
901
+ //---------------------------------------------------------------------
902
+
903
+ function QRRSBlock(totalCount, dataCount) {
904
+ this.totalCount = totalCount;
905
+ this.dataCount = dataCount;
906
+ }
907
+
908
+ QRRSBlock.RS_BLOCK_TABLE = [
909
+
910
+ // L
911
+ // M
912
+ // Q
913
+ // H
914
+
915
+ // 1
916
+ [1, 26, 19],
917
+ [1, 26, 16],
918
+ [1, 26, 13],
919
+ [1, 26, 9],
920
+
921
+ // 2
922
+ [1, 44, 34],
923
+ [1, 44, 28],
924
+ [1, 44, 22],
925
+ [1, 44, 16],
926
+
927
+ // 3
928
+ [1, 70, 55],
929
+ [1, 70, 44],
930
+ [2, 35, 17],
931
+ [2, 35, 13],
932
+
933
+ // 4
934
+ [1, 100, 80],
935
+ [2, 50, 32],
936
+ [2, 50, 24],
937
+ [4, 25, 9],
938
+
939
+ // 5
940
+ [1, 134, 108],
941
+ [2, 67, 43],
942
+ [2, 33, 15, 2, 34, 16],
943
+ [2, 33, 11, 2, 34, 12],
944
+
945
+ // 6
946
+ [2, 86, 68],
947
+ [4, 43, 27],
948
+ [4, 43, 19],
949
+ [4, 43, 15],
950
+
951
+ // 7
952
+ [2, 98, 78],
953
+ [4, 49, 31],
954
+ [2, 32, 14, 4, 33, 15],
955
+ [4, 39, 13, 1, 40, 14],
956
+
957
+ // 8
958
+ [2, 121, 97],
959
+ [2, 60, 38, 2, 61, 39],
960
+ [4, 40, 18, 2, 41, 19],
961
+ [4, 40, 14, 2, 41, 15],
962
+
963
+ // 9
964
+ [2, 146, 116],
965
+ [3, 58, 36, 2, 59, 37],
966
+ [4, 36, 16, 4, 37, 17],
967
+ [4, 36, 12, 4, 37, 13],
968
+
969
+ // 10
970
+ [2, 86, 68, 2, 87, 69],
971
+ [4, 69, 43, 1, 70, 44],
972
+ [6, 43, 19, 2, 44, 20],
973
+ [6, 43, 15, 2, 44, 16],
974
+
975
+ // 11
976
+ [4, 101, 81],
977
+ [1, 80, 50, 4, 81, 51],
978
+ [4, 50, 22, 4, 51, 23],
979
+ [3, 36, 12, 8, 37, 13],
980
+
981
+ // 12
982
+ [2, 116, 92, 2, 117, 93],
983
+ [6, 58, 36, 2, 59, 37],
984
+ [4, 46, 20, 6, 47, 21],
985
+ [7, 42, 14, 4, 43, 15],
986
+
987
+ // 13
988
+ [4, 133, 107],
989
+ [8, 59, 37, 1, 60, 38],
990
+ [8, 44, 20, 4, 45, 21],
991
+ [12, 33, 11, 4, 34, 12],
992
+
993
+ // 14
994
+ [3, 145, 115, 1, 146, 116],
995
+ [4, 64, 40, 5, 65, 41],
996
+ [11, 36, 16, 5, 37, 17],
997
+ [11, 36, 12, 5, 37, 13],
998
+
999
+ // 15
1000
+ [5, 109, 87, 1, 110, 88],
1001
+ [5, 65, 41, 5, 66, 42],
1002
+ [5, 54, 24, 7, 55, 25],
1003
+ [11, 36, 12],
1004
+
1005
+ // 16
1006
+ [5, 122, 98, 1, 123, 99],
1007
+ [7, 73, 45, 3, 74, 46],
1008
+ [15, 43, 19, 2, 44, 20],
1009
+ [3, 45, 15, 13, 46, 16],
1010
+
1011
+ // 17
1012
+ [1, 135, 107, 5, 136, 108],
1013
+ [10, 74, 46, 1, 75, 47],
1014
+ [1, 50, 22, 15, 51, 23],
1015
+ [2, 42, 14, 17, 43, 15],
1016
+
1017
+ // 18
1018
+ [5, 150, 120, 1, 151, 121],
1019
+ [9, 69, 43, 4, 70, 44],
1020
+ [17, 50, 22, 1, 51, 23],
1021
+ [2, 42, 14, 19, 43, 15],
1022
+
1023
+ // 19
1024
+ [3, 141, 113, 4, 142, 114],
1025
+ [3, 70, 44, 11, 71, 45],
1026
+ [17, 47, 21, 4, 48, 22],
1027
+ [9, 39, 13, 16, 40, 14],
1028
+
1029
+ // 20
1030
+ [3, 135, 107, 5, 136, 108],
1031
+ [3, 67, 41, 13, 68, 42],
1032
+ [15, 54, 24, 5, 55, 25],
1033
+ [15, 43, 15, 10, 44, 16],
1034
+
1035
+ // 21
1036
+ [4, 144, 116, 4, 145, 117],
1037
+ [17, 68, 42],
1038
+ [17, 50, 22, 6, 51, 23],
1039
+ [19, 46, 16, 6, 47, 17],
1040
+
1041
+ // 22
1042
+ [2, 139, 111, 7, 140, 112],
1043
+ [17, 74, 46],
1044
+ [7, 54, 24, 16, 55, 25],
1045
+ [34, 37, 13],
1046
+
1047
+ // 23
1048
+ [4, 151, 121, 5, 152, 122],
1049
+ [4, 75, 47, 14, 76, 48],
1050
+ [11, 54, 24, 14, 55, 25],
1051
+ [16, 45, 15, 14, 46, 16],
1052
+
1053
+ // 24
1054
+ [6, 147, 117, 4, 148, 118],
1055
+ [6, 73, 45, 14, 74, 46],
1056
+ [11, 54, 24, 16, 55, 25],
1057
+ [30, 46, 16, 2, 47, 17],
1058
+
1059
+ // 25
1060
+ [8, 132, 106, 4, 133, 107],
1061
+ [8, 75, 47, 13, 76, 48],
1062
+ [7, 54, 24, 22, 55, 25],
1063
+ [22, 45, 15, 13, 46, 16],
1064
+
1065
+ // 26
1066
+ [10, 142, 114, 2, 143, 115],
1067
+ [19, 74, 46, 4, 75, 47],
1068
+ [28, 50, 22, 6, 51, 23],
1069
+ [33, 46, 16, 4, 47, 17],
1070
+
1071
+ // 27
1072
+ [8, 152, 122, 4, 153, 123],
1073
+ [22, 73, 45, 3, 74, 46],
1074
+ [8, 53, 23, 26, 54, 24],
1075
+ [12, 45, 15, 28, 46, 16],
1076
+
1077
+ // 28
1078
+ [3, 147, 117, 10, 148, 118],
1079
+ [3, 73, 45, 23, 74, 46],
1080
+ [4, 54, 24, 31, 55, 25],
1081
+ [11, 45, 15, 31, 46, 16],
1082
+
1083
+ // 29
1084
+ [7, 146, 116, 7, 147, 117],
1085
+ [21, 73, 45, 7, 74, 46],
1086
+ [1, 53, 23, 37, 54, 24],
1087
+ [19, 45, 15, 26, 46, 16],
1088
+
1089
+ // 30
1090
+ [5, 145, 115, 10, 146, 116],
1091
+ [19, 75, 47, 10, 76, 48],
1092
+ [15, 54, 24, 25, 55, 25],
1093
+ [23, 45, 15, 25, 46, 16],
1094
+
1095
+ // 31
1096
+ [13, 145, 115, 3, 146, 116],
1097
+ [2, 74, 46, 29, 75, 47],
1098
+ [42, 54, 24, 1, 55, 25],
1099
+ [23, 45, 15, 28, 46, 16],
1100
+
1101
+ // 32
1102
+ [17, 145, 115],
1103
+ [10, 74, 46, 23, 75, 47],
1104
+ [10, 54, 24, 35, 55, 25],
1105
+ [19, 45, 15, 35, 46, 16],
1106
+
1107
+ // 33
1108
+ [17, 145, 115, 1, 146, 116],
1109
+ [14, 74, 46, 21, 75, 47],
1110
+ [29, 54, 24, 19, 55, 25],
1111
+ [11, 45, 15, 46, 46, 16],
1112
+
1113
+ // 34
1114
+ [13, 145, 115, 6, 146, 116],
1115
+ [14, 74, 46, 23, 75, 47],
1116
+ [44, 54, 24, 7, 55, 25],
1117
+ [59, 46, 16, 1, 47, 17],
1118
+
1119
+ // 35
1120
+ [12, 151, 121, 7, 152, 122],
1121
+ [12, 75, 47, 26, 76, 48],
1122
+ [39, 54, 24, 14, 55, 25],
1123
+ [22, 45, 15, 41, 46, 16],
1124
+
1125
+ // 36
1126
+ [6, 151, 121, 14, 152, 122],
1127
+ [6, 75, 47, 34, 76, 48],
1128
+ [46, 54, 24, 10, 55, 25],
1129
+ [2, 45, 15, 64, 46, 16],
1130
+
1131
+ // 37
1132
+ [17, 152, 122, 4, 153, 123],
1133
+ [29, 74, 46, 14, 75, 47],
1134
+ [49, 54, 24, 10, 55, 25],
1135
+ [24, 45, 15, 46, 46, 16],
1136
+
1137
+ // 38
1138
+ [4, 152, 122, 18, 153, 123],
1139
+ [13, 74, 46, 32, 75, 47],
1140
+ [48, 54, 24, 14, 55, 25],
1141
+ [42, 45, 15, 32, 46, 16],
1142
+
1143
+ // 39
1144
+ [20, 147, 117, 4, 148, 118],
1145
+ [40, 75, 47, 7, 76, 48],
1146
+ [43, 54, 24, 22, 55, 25],
1147
+ [10, 45, 15, 67, 46, 16],
1148
+
1149
+ // 40
1150
+ [19, 148, 118, 6, 149, 119],
1151
+ [18, 75, 47, 31, 76, 48],
1152
+ [34, 54, 24, 34, 55, 25],
1153
+ [20, 45, 15, 61, 46, 16]
1154
+ ];
1155
+
1156
+ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
1157
+
1158
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
1159
+
1160
+ if (rsBlock == undefined) {
1161
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
1162
+ }
1163
+
1164
+ var length = rsBlock.length / 3;
1165
+
1166
+ var list = new Array();
1167
+
1168
+ for (var i = 0; i < length; i++) {
1169
+
1170
+ var count = rsBlock[i * 3 + 0];
1171
+ var totalCount = rsBlock[i * 3 + 1];
1172
+ var dataCount = rsBlock[i * 3 + 2];
1173
+
1174
+ for (var j = 0; j < count; j++) {
1175
+ list.push(new QRRSBlock(totalCount, dataCount) );
1176
+ }
1177
+ }
1178
+
1179
+ return list;
1180
+ }
1181
+
1182
+ QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
1183
+
1184
+ switch(errorCorrectLevel) {
1185
+ case QRErrorCorrectLevel.L :
1186
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1187
+ case QRErrorCorrectLevel.M :
1188
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1189
+ case QRErrorCorrectLevel.Q :
1190
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1191
+ case QRErrorCorrectLevel.H :
1192
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1193
+ default :
1194
+ return undefined;
1195
+ }
1196
+ }
1197
+
1198
+ //---------------------------------------------------------------------
1199
+ // QRBitBuffer
1200
+ //---------------------------------------------------------------------
1201
+
1202
+ function QRBitBuffer() {
1203
+ this.buffer = new Array();
1204
+ this.length = 0;
1205
+ }
1206
+
1207
+ QRBitBuffer.prototype = {
1208
+
1209
+ get : function(index) {
1210
+ var bufIndex = Math.floor(index / 8);
1211
+ return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
1212
+ },
1213
+
1214
+ put : function(num, length) {
1215
+ for (var i = 0; i < length; i++) {
1216
+ this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
1217
+ }
1218
+ },
1219
+
1220
+ getLengthInBits : function() {
1221
+ return this.length;
1222
+ },
1223
+
1224
+ putBit : function(bit) {
1225
+
1226
+ var bufIndex = Math.floor(this.length / 8);
1227
+ if (this.buffer.length <= bufIndex) {
1228
+ this.buffer.push(0);
1229
+ }
1230
+
1231
+ if (bit) {
1232
+ this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
1233
+ }
1234
+
1235
+ this.length++;
1236
+ }
1237
+ };
1238
+
1239
+ (function( $ ){
1240
+ $.fn.qrcode = function(options) {
1241
+ // if options is string,
1242
+ if( typeof options === 'string' ){
1243
+ options = { text: options };
1244
+ }
1245
+
1246
+ // set default values
1247
+ // typeNumber < 1 for automatic calculation
1248
+ options = $.extend( {}, {
1249
+ render : "canvas",
1250
+ width : 256,
1251
+ height : 256,
1252
+ typeNumber : -1,
1253
+ correctLevel : QRErrorCorrectLevel.H,
1254
+ background : "#ffffff",
1255
+ foreground : "#000000"
1256
+ }, options);
1257
+
1258
+ var createCanvas = function(){
1259
+ // create the qrcode itself
1260
+ var qrcode = new QRCode(options.typeNumber, options.correctLevel);
1261
+ qrcode.addData(options.text);
1262
+ qrcode.make();
1263
+
1264
+ // create canvas element
1265
+ var canvas = document.createElement('canvas');
1266
+ canvas.width = options.width;
1267
+ canvas.height = options.height;
1268
+ var ctx = canvas.getContext('2d');
1269
+
1270
+ // compute tileW/tileH based on options.width/options.height
1271
+ var tileW = options.width / qrcode.getModuleCount();
1272
+ var tileH = options.height / qrcode.getModuleCount();
1273
+
1274
+ // draw in the canvas
1275
+ for( var row = 0; row < qrcode.getModuleCount(); row++ ){
1276
+ for( var col = 0; col < qrcode.getModuleCount(); col++ ){
1277
+ ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background;
1278
+ var w = (Math.ceil((col+1)*tileW) - Math.floor(col*tileW));
1279
+ var h = (Math.ceil((row+1)*tileH) - Math.floor(row*tileH));
1280
+ ctx.fillRect(Math.round(col*tileW),Math.round(row*tileH), w, h);
1281
+ }
1282
+ }
1283
+ // return just built canvas
1284
+ return canvas;
1285
+ }
1286
+
1287
+ // from Jon-Carlos Rivera (https://github.com/imbcmdth)
1288
+ var createTable = function(){
1289
+ // create the qrcode itself
1290
+ var qrcode = new QRCode(options.typeNumber, options.correctLevel);
1291
+ qrcode.addData(options.text);
1292
+ qrcode.make();
1293
+
1294
+ // create table element
1295
+ var $table = $('<table></table>')
1296
+ .css("width", options.width+"px")
1297
+ .css("height", options.height+"px")
1298
+ .css("border", "0px")
1299
+ .css("border-collapse", "collapse")
1300
+ .css('background-color', options.background);
1301
+
1302
+ // compute tileS percentage
1303
+ var tileW = options.width / qrcode.getModuleCount();
1304
+ var tileH = options.height / qrcode.getModuleCount();
1305
+
1306
+ // draw in the table
1307
+ for(var row = 0; row < qrcode.getModuleCount(); row++ ){
1308
+ var $row = $('<tr></tr>').css('height', tileH+"px").appendTo($table);
1309
+
1310
+ for(var col = 0; col < qrcode.getModuleCount(); col++ ){
1311
+ $('<td></td>')
1312
+ .css('width', tileW+"px")
1313
+ .css('background-color', qrcode.isDark(row, col) ? options.foreground : options.background)
1314
+ .appendTo($row);
1315
+ }
1316
+ }
1317
+ // return just built canvas
1318
+ return $table;
1319
+ }
1320
+
1321
+
1322
+ return this.each(function(){
1323
+ var element = options.render == "canvas" ? createCanvas() : createTable();
1324
+ $(element).appendTo(this);
1325
+ });
1326
+ };
1327
+ })( jQuery );
resources/js/tp/qrcode.min.js DELETED
@@ -1,2 +0,0 @@
1
- /** https://github.com/datalog/qrcode-svg under MIT license */
2
- 'use strict';function QRCode(r){var n,t,o,e,a=[],f=[],i=Math.max,u=Math.min,h=Math.abs,v=Math.ceil,c=/^[0-9]*$/,s=/^[A-Z0-9 $%*+.\/:-]*$/,l="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",g=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],d=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],m={L:[0,1],M:[1,0],Q:[2,3],H:[3,2]},p=function(r,n){for(var t=0,o=8;o--;)t=t<<1^285*(t>>>7)^(n>>>o&1)*r;return t},C=function(r,n){for(var t=[],o=r.length,e=o;e;)for(var a=r[o-e--]^t.shift(),f=n.length;f--;)t[f]^=p(n[f],a);return t},w=function(r){for(var n=[function(){return 0==(t+o)%2},function(){return 0==t%2},function(){return 0==o%3},function(){return 0==(t+o)%3},function(){return 0==((t/2|0)+(o/3|0))%2},function(){return 0==t*o%2+t*o%3},function(){return 0==(t*o%2+t*o%3)%2},function(){return 0==((t+o)%2+t*o%3)%2}][r],t=e;t--;)for(var o=e;o--;)f[t][o]||(a[t][o]^=n())},b=function(){for(var r=function(r,n){n[6]||(r+=e),n.shift(),n.push(r)},n=function(n,o,a){return n&&(r(o,a),o=0),r(o+=e,a),t(a)},t=function(r){var n=r[5],t=n>0&&r[4]==n&&r[3]==3*n&&r[2]==n&&r[1]==n;return(t&&r[6]>=4*n&&r[0]>=n?1:0)+(t&&r[0]>=4*n&&r[6]>=n?1:0)},o=0,f=e*e,i=0,u=e;u--;){for(var c=[0,0,0,0,0,0,0],s=[0,0,0,0,0,0,0],l=!1,g=!1,d=0,m=0,p=e;p--;){a[u][p]==l?5==++d?o+=3:d>5&&o++:(r(d,c),o+=40*t(c),d=1,l=a[u][p]),a[p][u]==g?5==++m?o+=3:m>5&&o++:(r(m,s),o+=40*t(s),m=1,g=a[p][u]);var C=a[u][p];C&&i++,p&&u&&C==a[u][p-1]&&C==a[u-1][p]&&C==a[u-1][p-1]&&(o+=3)}o+=40*n(l,d,c)+40*n(g,m,s)}return o+=10*(v(h(20*i-10*f)/f)-1)},A=function(r,n,t){for(;n--;)t.push(r>>>n&1)},M=function(r,n){return r.numBitsCharCount[(n+7)/17|0]},B=function(r,n){return 0!=(r>>>n&1)},x=function(r,n){for(var t=0,o=r.length;o--;){var e=r[o],a=M(e,n);if(1<<a<=e.numChars)return 1/0;t+=4+a+e.bitData.length}return t},D=function(r){if(r<1||r>40)throw"Version number out of range";var n=(16*r+128)*r+64;if(r>=2){var t=r/7|2;n-=(25*t-10)*t-55,r>=7&&(n-=36)}return n},I=function(r,n){for(var t=2;-2<=t;t--)for(var o=2;-2<=o;o--)E(r+o,n+t,1!=i(h(o),h(t)))},H=function(r,n){for(var t=4;-4<=t;t--)for(var o=4;-4<=o;o--){var a=i(h(o),h(t)),f=r+o,u=n+t;0<=f&&f<e&&0<=u&&u<e&&E(f,u,2!=a&&4!=a)}},$=function(r){for(var n=t[1]<<3|r,o=n,a=10;a--;)o=o<<1^1335*(o>>>9);var f=21522^(n<<10|o);if(f>>>15!=0)throw"Assertion error";for(a=0;a<=5;a++)E(8,a,B(f,a));E(8,7,B(f,6)),E(8,8,B(f,7)),E(7,8,B(f,8));for(a=9;a<15;a++)E(14-a,8,B(f,a));for(a=0;a<8;a++)E(e-1-a,8,B(f,a));for(a=8;a<15;a++)E(8,e-15+a,B(f,a));E(8,e-8,1)},O=function(){for(var r=e;r--;)E(6,r,0==r%2),E(r,6,0==r%2);for(var t=function(){var r=[];if(n>1)for(var t=2+(n/7|0),o=32==n?26:2*v((e-13)/(2*t-2));t--;)r[t]=t*o+6;return r}(),o=r=t.length;o--;)for(var a=r;a--;)0==a&&0==o||0==a&&o==r-1||a==r-1&&0==o||I(t[a],t[o]);H(3,3),H(e-4,3),H(3,e-4),$(0),function(){if(!(7>n)){for(var r=n,t=12;t--;)r=r<<1^7973*(r>>>11);var o=n<<12|r;if(t=18,o>>>18!=0)throw"Assertion error";for(;t--;){var a=e-11+t%3,f=t/3|0,i=B(o,t);E(a,f,i),E(f,a,i)}}}()},Q=function(r){if(r.length!=V(n,t))throw"Invalid argument";for(var o=d[t[0]][n],e=g[t[0]][n],a=D(n)/8|0,f=o-a%o,i=a/o|0,u=[],h=function(r){var n=1,t=[];t[r-1]=1;for(var o=0;o<r;o++){for(var e=0;e<r;e++)t[e]=p(t[e],n)^t[e+1];n=p(n,2)}return t}(e),v=0,c=0;v<o;v++){var s=r.slice(c,c+i-e+(v<f?0:1));c+=s.length;var l=C(s,h);v<f&&s.push(0),u.push(s.concat(l))}var m=[];for(v=0;v<u[0].length;v++)for(var w=0;w<u.length;w++)(v!=i-e||w>=f)&&m.push(u[w][v]);return m},S=function(r){for(var n=[],t=(r=encodeURI(r),0);t<r.length;t++)"%"!=r.charAt(t)?n.push(r.charCodeAt(t)):(n.push(parseInt(r.substr(t+1,2),16)),t+=2);return n},V=function(r,n){return(D(r)/8|0)-g[n[0]][r]*d[n[0]][r]},E=function(r,n,t){a[n][r]=t?1:0,f[n][r]=1},R=function(r){for(var n=[],t=0,o=r;t<o.length;t++){var e=o[t];A(e,8,n)}return{modeBits:4,numBitsCharCount:[8,16,16],numChars:r.length,bitData:n}},Z=function(r){if(!c.test(r))throw"String contains non-numeric characters";for(var n=[],t=0;t<r.length;){var o=u(r.length-t,3);A(parseInt(r.substr(t,o),10),3*o+1,n),t+=o}return{modeBits:1,numBitsCharCount:[10,12,14],numChars:r.length,bitData:n}},z=function(r){if(!s.test(r))throw"String contains unencodable characters in alphanumeric mode";var n,t=[];for(n=0;n+2<=r.length;n+=2){var o=45*l.indexOf(r.charAt(n));o+=l.indexOf(r.charAt(n+1)),A(o,11,t)}return n<r.length&&A(l.indexOf(r.charAt(n)),6,t),{modeBits:2,numBitsCharCount:[9,11,13],numChars:r.length,bitData:t}},L=function(r,n,t,o){var e=function(r){return""==r?[]:c.test(r)?[Z(r)]:s.test(r)?[z(r)]:[R(S(r))]}(r);return U(e,n,t,o)},N=function(r,i,u,h){t=i,o=h;for(var v=e=4*(n=r)+17;v--;)a[v]=[],f[v]=[];if(O(),function(r){for(var n=0,t=1,o=e-1,i=o;i>0;i-=2){6==i&&--i;for(var u=0>(t=-t)?o:0,h=0;h<e;++h){for(var v=i;v>i-2;--v)f[u][v]||(a[u][v]=B(r[n>>>3],7-(7&n)),++n);u+=t}}}(Q(u)),0>o){var c=1e9;for(v=8;v--;){w(v),$(v);var s=b();c>s&&(c=s,o=v),w(v)}}w(o),$(o),f=[]},U=function(r,n,t,o,e,a){if(void 0===e&&(e=1),void 0===a&&(a=40),void 0===o&&(o=-1),void 0===t&&(t=!0),!(1<=e&&e<=a&&a<=40)||o<-1||o>7)throw"Invalid value";for(var f=[],i=236,h=[],v=e;;){var c=x(r,v);if(c<=8*V(v,n))break;if(v>=a)throw"Data too long";v++}if(t)for(var s=(l=[m.H,m.Q,m.M]).length;s--;)c<=8*V(v,l[s])&&(n=l[s]);for(var l=0;l<r.length;l++){var g=r[l];A(g.modeBits,4,f),A(g.numChars,M(g,v),f);for(var d=0,p=g.bitData;d<p.length;d++)f.push(p[d])}if(f.length!=c)throw"Assertion error";var C=8*V(v,n);if(f.length>C)throw"Assertion error";if(A(0,u(4,C-f.length),f),A(0,(8-f.length%8)%8,f),f.length%8!=0)throw"Assertion error";for(;f.length<C;)A(i,8,f),i^=253;for(s=f.length;s--;)h[s>>>3]|=f[s]<<7-(7&s);return N(v,n,h,o)};return function(){function n(r){return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(r)}function t(r,n){for(var t in r=document.createElementNS(s,r),n||{})r.setAttribute(t,n[t]);return r}var o,f,i,u,v,c,s="http://www.w3.org/2000/svg",l="",g="string"==typeof r?{msg:r}:r||{},d=g.pal||["#000"],p=h(g.dim)||256,C=[1,0,0,1,c=(c=h(g.pad))>-1?c:4,c],w=n(w=d[0])?w:"#000",b=n(b=d[1])?b:0,A=g.vrb?0:1;for(L(g.msg||"",m[g.ecl]||m.M,0==g.ecb?0:1,g.mtx),v=e+2*c,i=e;i--;)for(u=0,f=e;f--;)a[i][f]&&(A?(u++,a[i][f-1]||(l+="M"+f+","+i+"h"+u+"v1h-"+u+"v-1z",u=0)):l+="M"+f+","+i+"h1v1h-1v-1z");return o=t("svg",{viewBox:[0,0,v,v].join(" "),width:p,height:p,fill:w,"shape-rendering":"crispEdges",xmlns:s,version:"1.1"}),b&&o.appendChild(t("path",{fill:b,d:"M0,0V"+v+"H"+v+"V0H0Z"})),o.appendChild(t("path",{transform:"matrix("+C+")",d:l})),o}()}
 
 
src/lib/src/Controller/Controller.php CHANGED
@@ -559,7 +559,7 @@ class Controller extends DynPropertiesClass {
559
  public function getInstallationID() :array {
560
  $WP = Services::WpGeneral();
561
  $urlParts = wp_parse_url( $WP->getWpUrl() );
562
- $url = $urlParts[ 'host' ].trim( $urlParts[ 'path' ], '/' );
563
  $optKey = $this->prefixOption( 'shield_site_id' );
564
 
565
  $IDs = $WP->getOption( $optKey );
559
  public function getInstallationID() :array {
560
  $WP = Services::WpGeneral();
561
  $urlParts = wp_parse_url( $WP->getWpUrl() );
562
+ $url = $urlParts[ 'host' ].trim( $urlParts[ 'path' ] ?? '', '/' );
563
  $optKey = $this->prefixOption( 'shield_site_id' );
564
 
565
  $IDs = $WP->getOption( $optKey );
src/lib/src/Modules/LoginGuard/Lib/TwoFactor/Provider/GoogleAuth.php CHANGED
@@ -67,7 +67,11 @@ class GoogleAuth extends BaseProvider {
67
 
68
  private function getQrUrl() :string {
69
  $secret = $this->getGaSecret();
70
- return sprintf( 'otpauth://totp/test?secret=%s&issuer=%s&label=%s', $secret->getSecretKey(), $secret->getIssuer(), $secret->getLabel() );
 
 
 
 
71
  }
72
 
73
  private function getQrImage() :string {
@@ -175,8 +179,8 @@ class GoogleAuth extends BaseProvider {
175
  if ( !isset( $this->oWorkingSecret ) ) {
176
  $this->oWorkingSecret = ( new SecretFactory() )
177
  ->create(
178
- sanitize_user( $this->getUser()->user_login ),
179
- preg_replace( '#[^\da-z]#i', '', Services::WpGeneral()->getSiteName() )
180
  );
181
  }
182
  return $this->oWorkingSecret;
67
 
68
  private function getQrUrl() :string {
69
  $secret = $this->getGaSecret();
70
+ return add_query_arg( [
71
+ 'secret' => $secret->getSecretKey(),
72
+ 'issuer' => $secret->getIssuer(),
73
+ 'label' => $secret->getLabel(),
74
+ ], sprintf( 'otpauth://totp/%s', urlencode( $secret->getIssuer().':'.$secret->getAccountName() ) ) );
75
  }
76
 
77
  private function getQrImage() :string {
179
  if ( !isset( $this->oWorkingSecret ) ) {
180
  $this->oWorkingSecret = ( new SecretFactory() )
181
  ->create(
182
+ preg_replace( '#[^\da-z]#i', '', Services::WpGeneral()->getSiteName() ),
183
+ sanitize_user( $this->getUser()->user_login )
184
  );
185
  }
186
  return $this->oWorkingSecret;
src/lib/src/Modules/Plugin/Lib/ImportExport/Import.php CHANGED
@@ -5,6 +5,7 @@ namespace FernleafSystems\Wordpress\Plugin\Shield\Modules\Plugin\Lib\ImportExpor
5
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
6
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Plugin;
7
  use FernleafSystems\Wordpress\Services\Services;
 
8
 
9
  class Import {
10
 
@@ -131,12 +132,12 @@ class Import {
131
  // Ensure we have entries for 'scheme' and 'host'
132
  $urlParts = wp_parse_url( $masterURL );
133
  $hasParts = !empty( $urlParts )
134
- && count(
135
- array_filter( array_intersect_key(
136
- $urlParts,
137
- array_flip( [ 'scheme', 'host' ] )
138
- ) )
139
- ) === 2;
140
  if ( !$hasParts ) {
141
  throw new \Exception( "Couldn't parse the URL.", 4 );
142
  }
@@ -160,7 +161,7 @@ class Import {
160
  }
161
 
162
  { // Make the request
163
- $response = @json_decode( Services::HttpRequest()->getContent( add_query_arg( $data, $masterURL ) ), true );
164
  if ( empty( $response ) ) {
165
  throw new \Exception( "Request failed as we couldn't parse the response.", 5 );
166
  }
5
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\ModConsumer;
6
  use FernleafSystems\Wordpress\Plugin\Shield\Modules\Plugin;
7
  use FernleafSystems\Wordpress\Services\Services;
8
+ use FernleafSystems\Wordpress\Services\Utilities\URL;
9
 
10
  class Import {
11
 
132
  // Ensure we have entries for 'scheme' and 'host'
133
  $urlParts = wp_parse_url( $masterURL );
134
  $hasParts = !empty( $urlParts )
135
+ && count(
136
+ array_filter( array_intersect_key(
137
+ $urlParts,
138
+ array_flip( [ 'scheme', 'host' ] )
139
+ ) )
140
+ ) === 2;
141
  if ( !$hasParts ) {
142
  throw new \Exception( "Couldn't parse the URL.", 4 );
143
  }
161
  }
162
 
163
  { // Make the request
164
+ $response = @json_decode( Services::HttpRequest()->getContent( URL::Build( $masterURL, $data ) ), true );
165
  if ( empty( $response ) ) {
166
  throw new \Exception( "Request failed as we couldn't parse the response.", 5 );
167
  }
src/lib/vendor/composer/autoload_classmap.php CHANGED
@@ -1393,6 +1393,7 @@ return array(
1393
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
1394
  'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
1395
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Ssl' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Ssl.php',
 
1396
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Users\\UserMeta' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Users/UserMeta.php',
1397
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Uuid' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Uuid.php',
1398
  'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\ApiBase' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/ApiBase.php',
1393
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
1394
  'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
1395
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Ssl' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Ssl.php',
1396
+ 'FernleafSystems\\Wordpress\\Services\\Utilities\\URL' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/URL.php',
1397
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Users\\UserMeta' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Users/UserMeta.php',
1398
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Uuid' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/Uuid.php',
1399
  'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\ApiBase' => $vendorDir . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/ApiBase.php',
src/lib/vendor/composer/autoload_static.php CHANGED
@@ -1588,6 +1588,7 @@ class ComposerStaticInit4fc2c6daaffaf40b64b79b6d26830171
1588
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
1589
  'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
1590
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Ssl' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Ssl.php',
 
1591
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Users\\UserMeta' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Users/UserMeta.php',
1592
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Uuid' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Uuid.php',
1593
  'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\ApiBase' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/ApiBase.php',
1588
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Render' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Render.php',
1589
  'FernleafSystems\\Wordpress\\Services\\Utilities\\ServiceProviders' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/ServiceProviders.php',
1590
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Ssl' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Ssl.php',
1591
+ 'FernleafSystems\\Wordpress\\Services\\Utilities\\URL' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/URL.php',
1592
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Users\\UserMeta' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Users/UserMeta.php',
1593
  'FernleafSystems\\Wordpress\\Services\\Utilities\\Uuid' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/Uuid.php',
1594
  'FernleafSystems\\Wordpress\\Services\\Utilities\\WpOrg\\Base\\ApiBase' => __DIR__ . '/..' . '/fernleafsystems/wordpress-services/src/Utilities/WpOrg/Base/ApiBase.php',
src/lib/vendor/composer/installed.json CHANGED
@@ -288,17 +288,17 @@
288
  },
289
  {
290
  "name": "fernleafsystems/wordpress-services",
291
- "version": "2.30.5",
292
- "version_normalized": "2.30.5.0",
293
  "source": {
294
  "type": "git",
295
  "url": "git@gitlab.com:fernleafsystems/wordpress/wordpress-services.git",
296
- "reference": "66eee2db7f2926132bf84b1c438e4c72df24b96e"
297
  },
298
  "dist": {
299
  "type": "zip",
300
- "url": "https://gitlab.com/api/v4/projects/fernleafsystems%2Fwordpress%2Fwordpress-services/repository/archive.zip?sha=66eee2db7f2926132bf84b1c438e4c72df24b96e",
301
- "reference": "66eee2db7f2926132bf84b1c438e4c72df24b96e",
302
  "shasum": ""
303
  },
304
  "require": {
@@ -317,7 +317,7 @@
317
  "symfony/yaml": "~3.0",
318
  "twig/twig": "^1.42"
319
  },
320
- "time": "2022-09-28T11:51:56+00:00",
321
  "type": "library",
322
  "installation-source": "dist",
323
  "autoload": {
288
  },
289
  {
290
  "name": "fernleafsystems/wordpress-services",
291
+ "version": "2.31.1",
292
+ "version_normalized": "2.31.1.0",
293
  "source": {
294
  "type": "git",
295
  "url": "git@gitlab.com:fernleafsystems/wordpress/wordpress-services.git",
296
+ "reference": "69938425dcb0143dad90b76ddfe6055c31e7b904"
297
  },
298
  "dist": {
299
  "type": "zip",
300
+ "url": "https://gitlab.com/api/v4/projects/fernleafsystems%2Fwordpress%2Fwordpress-services/repository/archive.zip?sha=69938425dcb0143dad90b76ddfe6055c31e7b904",
301
+ "reference": "69938425dcb0143dad90b76ddfe6055c31e7b904",
302
  "shasum": ""
303
  },
304
  "require": {
317
  "symfony/yaml": "~3.0",
318
  "twig/twig": "^1.42"
319
  },
320
+ "time": "2022-10-24T12:16:53+00:00",
321
  "type": "library",
322
  "installation-source": "dist",
323
  "autoload": {
src/lib/vendor/composer/installed.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php return array(
2
  'root' => array(
3
- 'pretty_version' => 'dev-master',
4
- 'version' => 'dev-master',
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => '3f9fbc046a50da149acef24ecc0b61296882b37a',
9
  'name' => 'apto-shield/requirements',
10
  'dev' => true,
11
  ),
@@ -20,12 +20,12 @@
20
  'dev_requirement' => false,
21
  ),
22
  'apto-shield/requirements' => array(
23
- 'pretty_version' => 'dev-master',
24
- 'version' => 'dev-master',
25
  'type' => 'library',
26
  'install_path' => __DIR__ . '/../../',
27
  'aliases' => array(),
28
- 'reference' => '3f9fbc046a50da149acef24ecc0b61296882b37a',
29
  'dev_requirement' => false,
30
  ),
31
  'christian-riesen/base32' => array(
@@ -74,12 +74,12 @@
74
  'dev_requirement' => false,
75
  ),
76
  'fernleafsystems/wordpress-services' => array(
77
- 'pretty_version' => '2.30.5',
78
- 'version' => '2.30.5.0',
79
  'type' => 'library',
80
  'install_path' => __DIR__ . '/../fernleafsystems/wordpress-services',
81
  'aliases' => array(),
82
- 'reference' => '66eee2db7f2926132bf84b1c438e4c72df24b96e',
83
  'dev_requirement' => false,
84
  ),
85
  'fernleafsystems/zxcvbn-php' => array(
1
  <?php return array(
2
  'root' => array(
3
+ 'pretty_version' => 'dev-develop',
4
+ 'version' => 'dev-develop',
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '6cdb22524231e2cd7dd7f796762d20a93e0ef514',
9
  'name' => 'apto-shield/requirements',
10
  'dev' => true,
11
  ),
20
  'dev_requirement' => false,
21
  ),
22
  'apto-shield/requirements' => array(
23
+ 'pretty_version' => 'dev-develop',
24
+ 'version' => 'dev-develop',
25
  'type' => 'library',
26
  'install_path' => __DIR__ . '/../../',
27
  'aliases' => array(),
28
+ 'reference' => '6cdb22524231e2cd7dd7f796762d20a93e0ef514',
29
  'dev_requirement' => false,
30
  ),
31
  'christian-riesen/base32' => array(
74
  'dev_requirement' => false,
75
  ),
76
  'fernleafsystems/wordpress-services' => array(
77
+ 'pretty_version' => '2.31.1',
78
+ 'version' => '2.31.1.0',
79
  'type' => 'library',
80
  'install_path' => __DIR__ . '/../fernleafsystems/wordpress-services',
81
  'aliases' => array(),
82
+ 'reference' => '69938425dcb0143dad90b76ddfe6055c31e7b904',
83
  'dev_requirement' => false,
84
  ),
85
  'fernleafsystems/zxcvbn-php' => array(
src/lib/vendor/fernleafsystems/wordpress-services/src/Core/Fs.php CHANGED
@@ -175,52 +175,52 @@ class Fs {
175
  }
176
 
177
  /**
178
- * @param string $sContent
179
  * @return bool
180
  */
181
- public function putContent_WpConfig( $sContent ) {
182
- return $this->putFileContent( Services::WpGeneral()->getPath_WpConfig(), $sContent );
183
  }
184
 
185
  /**
186
- * @param string $sUrl
187
- * @param bool $bSecure
188
  * @return bool
189
  */
190
- public function getIsUrlValid( $sUrl, $bSecure = false ) {
191
- $sSchema = $bSecure ? 'https://' : 'http://';
192
- $sUrl = ( strpos( $sUrl, 'http' ) !== 0 ) ? $sSchema.$sUrl : $sUrl;
193
- return Services::HttpRequest()->get( $sUrl );
194
  }
195
 
196
  /**
197
  * @return bool
198
  */
199
  public function getCanWpRemoteGet() {
200
- $bCan = false;
201
- $aUrlsToTest = [
202
  'https://www.microsoft.com',
203
  'https://www.google.com',
204
  'https://www.facebook.com'
205
  ];
206
- foreach ( $aUrlsToTest as $sUrl ) {
207
- if ( Services::HttpRequest()->get( $sUrl ) ) {
208
- $bCan = true;
209
  break;
210
  }
211
  }
212
- return $bCan;
213
  }
214
 
215
  public function getCanDiskWrite() {
216
- $sFilePath = __DIR__.'/testfile.'.rand().'txt';
217
- $sContents = "Testing icwp file read and write.";
218
 
219
  // Write, read, verify, delete.
220
- if ( $this->putFileContent( $sFilePath, $sContents ) ) {
221
- $sFileContents = $this->getFileContent( $sFilePath );
222
- if ( !is_null( $sFileContents ) && $sFileContents === $sContents ) {
223
- return $this->deleteFile( $sFilePath );
224
  }
225
  }
226
  return false;
@@ -273,43 +273,43 @@ class Fs {
273
  }
274
 
275
  /**
276
- * @param string $sFilePath
277
  * @return null|bool
278
  */
279
- public function getCanReadWriteFile( $sFilePath ) {
280
- if ( !file_exists( $sFilePath ) ) {
281
  return null;
282
  }
283
 
284
- $nFileSize = filesize( $sFilePath );
285
- if ( $nFileSize === 0 ) {
286
  return null;
287
  }
288
 
289
- $sFileContent = $this->getFileContent( $sFilePath );
290
- if ( empty( $sFileContent ) ) {
291
  return false; //can't even read the file!
292
  }
293
- return $this->putFileContent( $sFilePath, $sFileContent );
294
  }
295
 
296
  /**
297
- * @param string $sFilePath
298
- * @param bool $bIsCompressed
299
  * @return string|null
300
  */
301
- public function getFileContent( $sFilePath, $bIsCompressed = false ) {
302
  $contents = null;
303
  $FS = $this->getWpfs();
304
  if ( $FS ) {
305
- $contents = $FS->get_contents( $sFilePath );
306
  }
307
 
308
  if ( empty( $contents ) && function_exists( 'file_get_contents' ) ) {
309
- $contents = file_get_contents( $sFilePath );
310
  }
311
 
312
- if ( !empty( $contents ) && $bIsCompressed && function_exists( 'gzinflate' ) ) {
313
  $contents = gzinflate( $contents );
314
  }
315
 
@@ -331,60 +331,60 @@ class Fs {
331
  }
332
 
333
  /**
334
- * @param $filePath
335
  * @return bool
336
  */
337
- public function getFileSize( $filePath ) {
338
  $oFs = $this->getWpfs();
339
- if ( $oFs && ( $oFs->size( $filePath ) > 0 ) ) {
340
- return $oFs->size( $filePath );
341
  }
342
- return @filesize( $filePath );
343
  }
344
 
345
  /**
346
- * @param string $sDir
347
- * @param int $nMaxDepth - set to zero for no max
348
- * @param \RecursiveDirectoryIterator $oDirIterator
349
  * @return \SplFileInfo[]
350
  */
351
- public function getFilesInDir( $sDir, $nMaxDepth = 1, $oDirIterator = null ) {
352
- $aList = [];
353
 
354
  try {
355
- if ( empty( $oDirIterator ) ) {
356
- $oDirIterator = new \RecursiveDirectoryIterator( $sDir );
357
- if ( method_exists( $oDirIterator, 'setFlags' ) ) {
358
- $oDirIterator->setFlags( \RecursiveDirectoryIterator::SKIP_DOTS );
359
  }
360
  }
361
 
362
- $oRecurIter = new \RecursiveIteratorIterator( $oDirIterator );
363
- $oRecurIter->setMaxDepth( $nMaxDepth - 1 ); //since they start at zero.
364
 
365
  /** @var \SplFileInfo $oFile */
366
- foreach ( $oRecurIter as $oFile ) {
367
- $aList[] = clone $oFile;
368
  }
369
  }
370
- catch ( \Exception $oE ) { // UnexpectedValueException, RuntimeException, Exception
371
  }
372
 
373
- return $aList;
374
  }
375
 
376
  /**
377
- * @param string|null $sBaseDir
378
- * @param string $sPrefix
379
  * @param string $outsRandomDir
380
  * @return bool|string
381
  */
382
- public function getTempDir( $sBaseDir = null, $sPrefix = '', &$outsRandomDir = '' ) {
383
- $sTemp = rtrim( ( is_null( $sBaseDir ) ? get_temp_dir() : $sBaseDir ), DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR;
384
 
385
  $sCharset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz0123456789';
386
  do {
387
- $sDir = $sPrefix;
388
  for ( $i = 0 ; $i < 8 ; $i++ ) {
389
  $sDir .= $sCharset[ ( rand()%strlen( $sCharset ) ) ];
390
  }
@@ -400,69 +400,69 @@ class Fs {
400
  }
401
 
402
  /**
403
- * @param string $sFilePath
404
- * @param string $sContents
405
- * @param bool $bCompressed
406
  * @return bool
407
  */
408
- public function putFileContent( $sFilePath, $sContents, $bCompressed = false ) {
409
 
410
- if ( $bCompressed && function_exists( 'gzdeflate' ) ) {
411
- $sContents = gzdeflate( $sContents );
412
  }
413
 
414
- $oFs = $this->getWpfs();
415
- if ( $oFs && $oFs->put_contents( $sFilePath, $sContents, FS_CHMOD_FILE ) ) {
416
  return true;
417
  }
418
 
419
  if ( function_exists( 'file_put_contents' ) ) {
420
- return file_put_contents( $sFilePath, $sContents ) !== false;
421
  }
422
  return false;
423
  }
424
 
425
  /**
426
  * Recursive delete
427
- * @param string $sDir
428
  * @return bool
429
  */
430
- public function deleteDir( $sDir ) {
431
- $oFs = $this->getWpfs();
432
- if ( $oFs && $oFs->rmdir( $sDir, true ) ) {
433
  return true;
434
  }
435
- return @rmdir( $sDir );
436
  }
437
 
438
  /**
439
- * @param string $sFilePath
440
  * @return bool|null
441
  */
442
- public function deleteFile( $sFilePath ) {
443
- $oFs = $this->getWpfs();
444
- if ( $oFs && $oFs->delete( $sFilePath ) ) {
445
  return true;
446
  }
447
- return function_exists( 'unlink' ) ? @unlink( $sFilePath ) : null;
448
  }
449
 
450
  /**
451
- * @param string $sFilePathSource
452
- * @param string $sFilePathDestination
453
  * @return bool|null
454
  */
455
- public function move( $sFilePathSource, $sFilePathDestination ) {
456
- $oFs = $this->getWpfs();
457
- if ( $oFs && $oFs->move( $sFilePathSource, $sFilePathDestination ) ) {
458
  return true;
459
  }
460
- return function_exists( 'rename' ) ? @rename( $sFilePathSource, $sFilePathDestination ) : null;
461
  }
462
 
463
  public function isDir( string $path ) :bool {
464
  return ( $this->hasWpfs() && $this->getWpfs()->is_dir( $path ) )
465
- || ( function_exists( 'is_dir' ) ? is_dir( $path ) : false );
466
  }
467
 
468
  public function isFile( $path ) :bool {
175
  }
176
 
177
  /**
178
+ * @param string $content
179
  * @return bool
180
  */
181
+ public function putContent_WpConfig( $content ) {
182
+ return $this->putFileContent( Services::WpGeneral()->getPath_WpConfig(), $content );
183
  }
184
 
185
  /**
186
+ * @param string $url
187
+ * @param bool $secure
188
  * @return bool
189
  */
190
+ public function getIsUrlValid( $url, $secure = false ) {
191
+ $schema = $secure ? 'https://' : 'http://';
192
+ $url = ( strpos( $url, 'http' ) !== 0 ) ? $schema.$url : $url;
193
+ return Services::HttpRequest()->get( $url );
194
  }
195
 
196
  /**
197
  * @return bool
198
  */
199
  public function getCanWpRemoteGet() {
200
+ $can = false;
201
+ $urls = [
202
  'https://www.microsoft.com',
203
  'https://www.google.com',
204
  'https://www.facebook.com'
205
  ];
206
+ foreach ( $urls as $url ) {
207
+ if ( Services::HttpRequest()->get( $url ) ) {
208
+ $can = true;
209
  break;
210
  }
211
  }
212
+ return $can;
213
  }
214
 
215
  public function getCanDiskWrite() {
216
+ $path = __DIR__.'/testfile.'.rand().'txt';
217
+ $contents = "Testing icwp file read and write.";
218
 
219
  // Write, read, verify, delete.
220
+ if ( $this->putFileContent( $path, $contents ) ) {
221
+ $fileContents = $this->getFileContent( $path );
222
+ if ( !is_null( $fileContents ) && $fileContents === $contents ) {
223
+ return $this->deleteFile( $path );
224
  }
225
  }
226
  return false;
273
  }
274
 
275
  /**
276
+ * @param string $path
277
  * @return null|bool
278
  */
279
+ public function getCanReadWriteFile( $path ) {
280
+ if ( !file_exists( $path ) ) {
281
  return null;
282
  }
283
 
284
+ $fileSize = filesize( $path );
285
+ if ( $fileSize === 0 ) {
286
  return null;
287
  }
288
 
289
+ $content = $this->getFileContent( $path );
290
+ if ( empty( $content ) ) {
291
  return false; //can't even read the file!
292
  }
293
+ return $this->putFileContent( $path, $content );
294
  }
295
 
296
  /**
297
+ * @param string $path
298
+ * @param bool $uncompress
299
  * @return string|null
300
  */
301
+ public function getFileContent( $path, $uncompress = false ) {
302
  $contents = null;
303
  $FS = $this->getWpfs();
304
  if ( $FS ) {
305
+ $contents = $FS->get_contents( $path );
306
  }
307
 
308
  if ( empty( $contents ) && function_exists( 'file_get_contents' ) ) {
309
+ $contents = file_get_contents( $path );
310
  }
311
 
312
+ if ( !empty( $contents ) && $uncompress && function_exists( 'gzinflate' ) ) {
313
  $contents = gzinflate( $contents );
314
  }
315
 
331
  }
332
 
333
  /**
334
+ * @param $path
335
  * @return bool
336
  */
337
+ public function getFileSize( $path ) {
338
  $oFs = $this->getWpfs();
339
+ if ( $oFs && ( $oFs->size( $path ) > 0 ) ) {
340
+ return $oFs->size( $path );
341
  }
342
+ return @filesize( $path );
343
  }
344
 
345
  /**
346
+ * @param string $dir
347
+ * @param int $maxDepth - set to zero for no max
348
+ * @param \RecursiveDirectoryIterator $dirIterator
349
  * @return \SplFileInfo[]
350
  */
351
+ public function getFilesInDir( $dir, $maxDepth = 1, $dirIterator = null ) {
352
+ $list = [];
353
 
354
  try {
355
+ if ( empty( $dirIterator ) ) {
356
+ $dirIterator = new \RecursiveDirectoryIterator( $dir );
357
+ if ( method_exists( $dirIterator, 'setFlags' ) ) {
358
+ $dirIterator->setFlags( \RecursiveDirectoryIterator::SKIP_DOTS );
359
  }
360
  }
361
 
362
+ $recurIter = new \RecursiveIteratorIterator( $dirIterator );
363
+ $recurIter->setMaxDepth( $maxDepth - 1 ); //since they start at zero.
364
 
365
  /** @var \SplFileInfo $oFile */
366
+ foreach ( $recurIter as $file ) {
367
+ $list[] = clone $file;
368
  }
369
  }
370
+ catch ( \Exception $e ) { // UnexpectedValueException, RuntimeException, Exception
371
  }
372
 
373
+ return $list;
374
  }
375
 
376
  /**
377
+ * @param string|null $baseDir
378
+ * @param string $prefix
379
  * @param string $outsRandomDir
380
  * @return bool|string
381
  */
382
+ public function getTempDir( $baseDir = null, $prefix = '', &$outsRandomDir = '' ) {
383
+ $sTemp = rtrim( ( is_null( $baseDir ) ? get_temp_dir() : $baseDir ), DIRECTORY_SEPARATOR ).DIRECTORY_SEPARATOR;
384
 
385
  $sCharset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz0123456789';
386
  do {
387
+ $sDir = $prefix;
388
  for ( $i = 0 ; $i < 8 ; $i++ ) {
389
  $sDir .= $sCharset[ ( rand()%strlen( $sCharset ) ) ];
390
  }
400
  }
401
 
402
  /**
403
+ * @param string $path
404
+ * @param string $contents
405
+ * @param bool $compress
406
  * @return bool
407
  */
408
+ public function putFileContent( $path, $contents, $compress = false ) {
409
 
410
+ if ( $compress && function_exists( 'gzdeflate' ) ) {
411
+ $contents = gzdeflate( $contents );
412
  }
413
 
414
+ $FS = $this->getWpfs();
415
+ if ( $FS && $FS->put_contents( $path, $contents, FS_CHMOD_FILE ) ) {
416
  return true;
417
  }
418
 
419
  if ( function_exists( 'file_put_contents' ) ) {
420
+ return file_put_contents( $path, $contents ) !== false;
421
  }
422
  return false;
423
  }
424
 
425
  /**
426
  * Recursive delete
427
+ * @param string $dir
428
  * @return bool
429
  */
430
+ public function deleteDir( $dir ) {
431
+ $FS = $this->getWpfs();
432
+ if ( $FS && $FS->rmdir( $dir, true ) ) {
433
  return true;
434
  }
435
+ return @rmdir( $dir );
436
  }
437
 
438
  /**
439
+ * @param string $path
440
  * @return bool|null
441
  */
442
+ public function deleteFile( $path ) {
443
+ $FS = $this->getWpfs();
444
+ if ( $FS && $FS->delete( $path ) ) {
445
  return true;
446
  }
447
+ return function_exists( 'unlink' ) ? @unlink( $path ) : null;
448
  }
449
 
450
  /**
451
+ * @param string $pathSource
452
+ * @param string $pathDestination
453
  * @return bool|null
454
  */
455
+ public function move( $pathSource, $pathDestination ) {
456
+ $FS = $this->getWpfs();
457
+ if ( $FS && $FS->move( $pathSource, $pathDestination ) ) {
458
  return true;
459
  }
460
+ return function_exists( 'rename' ) ? @rename( $pathSource, $pathDestination ) : null;
461
  }
462
 
463
  public function isDir( string $path ) :bool {
464
  return ( $this->hasWpfs() && $this->getWpfs()->is_dir( $path ) )
465
+ || ( function_exists( 'is_dir' ) && is_dir( $path ) );
466
  }
467
 
468
  public function isFile( $path ) :bool {
src/lib/vendor/fernleafsystems/wordpress-services/src/Utilities/URL.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare( strict_types=1 );
2
+
3
+ namespace FernleafSystems\Wordpress\Services\Utilities;
4
+
5
+ class URL {
6
+
7
+ public static function AddParam( string $url, string $param, $value ) :string {
8
+ return self::Build( $url, [ $param => $value ] );
9
+ }
10
+
11
+ public static function Build( string $url, array $data = [], bool $urlEncodeIt = true, bool $urlEncodeRaw = true ) :string {
12
+ if ( $urlEncodeIt ) {
13
+ $data = $urlEncodeRaw ? array_map( 'rawurlencode_deep', $data ) : array_map( 'urlencode_deep', $data );
14
+ }
15
+ return add_query_arg( $data, $url );
16
+ }
17
+
18
+ public static function RemoveParam( string $url, string $param ) :string {
19
+ return remove_query_arg( $param, $url );
20
+ }
21
+
22
+ public static function RemoveParams( string $url, array $params ) :string {
23
+ return remove_query_arg( $params, $url );
24
+ }
25
+ }
templates/twig/admin/user/profile/mfa/mfa_email.twig CHANGED
@@ -1,62 +1,68 @@
1
  <style>
2
  .switch {
3
- display: inline-block;
4
- height: 34px;
5
- position: relative;
6
- width: 60px;
7
- margin: 0 20px;
8
- }
9
- .switch.disabled {
10
- opacity: 0.5;
11
- }
12
- .switch input {
13
- display: none;
14
- }
15
- .shield_slider {
16
- background-color: #ccc;
17
- bottom: 0;
18
- cursor: pointer;
19
- left: 0;
20
- position: absolute;
21
- right: 0;
22
- top: 0;
23
- transition: .4s;
24
- }
25
- .shield_slider:before {
26
- background-color: #fff;
27
- bottom: 4px;
28
- content: "";
29
- height: 26px;
30
- left: 4px;
31
- position: absolute;
32
- transition: .4s;
33
- width: 26px;
34
- }
35
- input:checked + .shield_slider {
36
- background-color: #66bb6a;
37
- }
38
- input:checked + .shield_slider:before {
39
- transform: translateX(26px);
40
- }
41
- .shield_slider.round {
42
- border-radius: 34px;
43
- }
44
- .shield_slider.round:before {
45
- border-radius: 50%;
46
- }
 
 
 
 
 
 
47
  </style>
48
  <tr>
49
  <th>
50
  <label for="shield_enable_mfaemail" class="form-label"
51
- {% if flags.is_enforced %}style="pointer-events: none;"{% endif %}
52
  >{{ strings.label_email_authentication }}</label>
53
  </th>
54
  <td>
55
  <label class="switch form-label {% if flags.is_enforced %}disabled{% endif %}"
56
- for="shield_enable_mfaemail">
57
 
58
  <input type="checkbox" name="shield_enable_mfaemail" id="shield_enable_mfaemail" value="Y"
59
- {% if flags.is_profile_active %}checked="checked"{% endif %}
60
  {% if flags.is_enforced %}
61
  style="opacity:0.5;pointer-events: none;"
62
  disabled="disabled"
@@ -69,8 +75,8 @@
69
  {% if flags.show_explanatory_text %}
70
  <p class="description">{{ strings.description_email_authentication_checkbox }}</p>
71
  {% if flags.is_enforced %}
72
- <p class="description">{{ strings.is_enforced }}</p>
73
- {% endif %}
74
  {% endif %}
75
  </td>
76
  </tr>
1
  <style>
2
  .switch {
3
+ display: inline-block;
4
+ height: 34px;
5
+ position: relative;
6
+ width: 60px;
7
+ margin: 0 20px;
8
+ }
9
+ .switch.disabled {
10
+ opacity: 0.5;
11
+ }
12
+ /** https://www.sarasoueidan.com/blog/inclusively-hiding-and-styling-checkboxes-and-radio-buttons/#hiding-the-checkboxes-inclusively */
13
+ .switch input {
14
+ position: absolute;
15
+ opacity: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ margin: 0;
19
+ z-index: 1;
20
+ }
21
+ .shield_slider {
22
+ background-color: #ccc;
23
+ bottom: 0;
24
+ cursor: pointer;
25
+ left: 0;
26
+ position: absolute;
27
+ right: 0;
28
+ top: 0;
29
+ transition: .4s;
30
+ }
31
+ .shield_slider:before {
32
+ background-color: #fff;
33
+ bottom: 4px;
34
+ content: "";
35
+ height: 26px;
36
+ left: 4px;
37
+ position: absolute;
38
+ transition: .4s;
39
+ width: 26px;
40
+ }
41
+ input:checked + .shield_slider {
42
+ background-color: #66bb6a;
43
+ }
44
+ input:checked + .shield_slider:before {
45
+ transform: translateX(26px);
46
+ }
47
+ .shield_slider.round {
48
+ border-radius: 34px;
49
+ }
50
+ .shield_slider.round:before {
51
+ border-radius: 50%;
52
+ }
53
  </style>
54
  <tr>
55
  <th>
56
  <label for="shield_enable_mfaemail" class="form-label"
57
+ {% if flags.is_enforced %}style="pointer-events: none;"{% endif %}
58
  >{{ strings.label_email_authentication }}</label>
59
  </th>
60
  <td>
61
  <label class="switch form-label {% if flags.is_enforced %}disabled{% endif %}"
62
+ for="shield_enable_mfaemail">
63
 
64
  <input type="checkbox" name="shield_enable_mfaemail" id="shield_enable_mfaemail" value="Y"
65
+ {% if flags.is_profile_active %}checked="checked"{% endif %}
66
  {% if flags.is_enforced %}
67
  style="opacity:0.5;pointer-events: none;"
68
  disabled="disabled"
75
  {% if flags.show_explanatory_text %}
76
  <p class="description">{{ strings.description_email_authentication_checkbox }}</p>
77
  {% if flags.is_enforced %}
78
+ <p class="description">{{ strings.is_enforced }}</p>
79
+ {% endif %}
80
  {% endif %}
81
  </td>
82
  </tr>
templates/twig/admin/user/profile/mfa/mfa_ga.twig CHANGED
@@ -35,15 +35,11 @@
35
  <tr>
36
  <th><label for="shield_gacode" class="form-label">{{ strings.title }}</label></th>
37
  <td>
38
- <div style="width: 350px; margin-bottom: 15px; text-align: center" id="SvgQrCode">
39
- <div style="margin: auto;width: fit-content;text-align: center;"
40
- id="shield_ga_secret">{{ vars.ga_secret }}</div>
41
- </div>
42
-
43
  <script>
44
- /** https://github.com/datalog/qrcode-svg */
45
- svgNode = QRCode( '{{ hrefs.qr_code_auth|raw }}' );
46
- document.getElementById( "SvgQrCode" ).prepend( svgNode );
47
  </script>
48
 
49
  <input class="regular-text"
35
  <tr>
36
  <th><label for="shield_gacode" class="form-label">{{ strings.title }}</label></th>
37
  <td>
38
+ <div style="width: 350px; margin-bottom: 8px; text-align: center" id="SvgQrCode"></div>
39
+ <div style="width: fit-content; text-align: center; padding: 8px 4px; margin: 7px auto;" id="shield_ga_secret">{{ vars.ga_secret }}</div>
 
 
 
40
  <script>
41
+ /** https://github.com/jeromeetienne/jquery-qrcode **/
42
+ jQuery( '#SvgQrCode' ).qrcode( '{{ hrefs.qr_code_auth|raw }}' );
 
43
  </script>
44
 
45
  <input class="regular-text"