Skip to content

Commit 75388f3

Browse files
committed
29 Jan 2024
1) Library updates - JWT, WebAuthn, WebPush 2) New NFC login module 3) Small UI updates to user login/account pages. 4) LIB-NFCIN - Will now check valid user before creating hash.
1 parent 9ab67dd commit 75388f3

File tree

133 files changed

+1291
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1291
-718
lines changed

README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
Core Boxx is a PHP framework built with the concept of simplicity and modularity. Install and load only what you need, not bloated with unused features.
33
<br><br>
44

5+
## :white_check_mark: "OUT OF THE BOX" FEATURES
6+
1) Pretty URL and routing.
7+
2) API endpoints with CORS support.
8+
3) Installable Progressive Web App.
9+
4) JSON Web Token sessions.
10+
5) Bootstrap HTML template.
11+
<br><br>
12+
513
## :camera: SCREENSHOTS
614
<p float="left">
715
<img width="250" src="https://github.com/code-boxx/Core-Boxx-PHP-Framework/blob/main/core/assets/core-boxx-1.png">
@@ -11,11 +19,6 @@ Core Boxx is a PHP framework built with the concept of simplicity and modularity
1119
<img width="250" src="https://github.com/code-boxx/Core-Boxx-PHP-Framework/blob/main/core/assets/core-boxx-5.png">
1220
<img width="250" src="https://github.com/code-boxx/Core-Boxx-PHP-Framework/blob/main/core/assets/core-boxx-6.png">
1321
</p>
14-
<br>
15-
16-
## :floppy_disk: INSTALLATION
17-
- Copy the contents of `core/` into your HTTP folder.
18-
- Access `http://your-site.com/` in the browser and walk through the installer.
1922
<br><br>
2023

2124
## :ballot_box_with_check: REQUIREMENTS
@@ -26,6 +29,11 @@ Core Boxx is a PHP framework built with the concept of simplicity and modularity
2629
5) At least PHP 8.0
2730
<br><br>
2831

32+
## :floppy_disk: INSTALLATION
33+
1) Manually download or git clone into your `http` folder.
34+
2) Access `http://your-site.com/` in the browser and walk through the installer.
35+
<br><br>
36+
2937
## :electric_plug: MODULES
3038
The rest of the folders are optional modules. To install the modules, check out their respective `README.md` files.
3139

@@ -46,16 +54,9 @@ The rest of the folders are optional modules. To install the modules, check out
4654
* `web push` Send push notifications.
4755
<br><br>
4856

49-
## :white_check_mark: "OUT OF THE BOX" FEATURES
50-
1) Pretty URL and routing.
51-
2) API endpoints with CORS support.
52-
3) Installable Progressive Web App.
53-
4) JSON Web Token sessions.
54-
5) Bootstrap HTML template.
55-
<br><br>
56-
5757
## :star: SUPPORT
58-
Like this project? Just give it a star. That will indirectly help grow my blog a little bit. :wink:
58+
1) Just give this project a star. That will indirectly drive more traffic a little bit. :wink:
59+
2) [Sponsor this project](https://github.com/sponsors/code-boxx). Even a small one time amount helps.
5960
<br><br>
6061

6162
## :bulb: DOCUMENTATION & CREDITS
@@ -83,4 +84,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8384
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8485
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8586
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
86-
SOFTWARE.
87+
SOFTWARE.

core/assets/core-boxx-1.png

-24.6 KB
Loading

core/assets/core-boxx-2.png

-22.4 KB
Loading

core/assets/core-boxx-3.png

-909 Bytes
Loading

core/assets/core-boxx-4.png

29.9 KB
Loading

core/assets/head-core-boxx.webp

-5.69 KB
Binary file not shown.

core/lib/JWT/autoload.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
require_once __DIR__ . '/composer/autoload_real.php';
2424

25-
return ComposerAutoloaderInit4227a9262042b7b77c23e4da01de8cd1::getLoader();
25+
return ComposerAutoloaderInitc4b25d4c67ba5f31d25bdba015db7cda::getLoader();

core/lib/JWT/composer/autoload_real.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit4227a9262042b7b77c23e4da01de8cd1
5+
class ComposerAutoloaderInitc4b25d4c67ba5f31d25bdba015db7cda
66
{
77
private static $loader;
88

@@ -24,12 +24,12 @@ public static function getLoader()
2424

2525
require __DIR__ . '/platform_check.php';
2626

27-
spl_autoload_register(array('ComposerAutoloaderInit4227a9262042b7b77c23e4da01de8cd1', 'loadClassLoader'), true, true);
27+
spl_autoload_register(array('ComposerAutoloaderInitc4b25d4c67ba5f31d25bdba015db7cda', 'loadClassLoader'), true, true);
2828
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29-
spl_autoload_unregister(array('ComposerAutoloaderInit4227a9262042b7b77c23e4da01de8cd1', 'loadClassLoader'));
29+
spl_autoload_unregister(array('ComposerAutoloaderInitc4b25d4c67ba5f31d25bdba015db7cda', 'loadClassLoader'));
3030

3131
require __DIR__ . '/autoload_static.php';
32-
call_user_func(\Composer\Autoload\ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1::getInitializer($loader));
32+
call_user_func(\Composer\Autoload\ComposerStaticInitc4b25d4c67ba5f31d25bdba015db7cda::getInitializer($loader));
3333

3434
$loader->register(true);
3535

core/lib/JWT/composer/autoload_static.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1
7+
class ComposerStaticInitc4b25d4c67ba5f31d25bdba015db7cda
88
{
99
public static $prefixLengthsPsr4 = array (
1010
'F' =>
@@ -27,9 +27,9 @@ class ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1
2727
public static function getInitializer(ClassLoader $loader)
2828
{
2929
return \Closure::bind(function () use ($loader) {
30-
$loader->prefixLengthsPsr4 = ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1::$prefixLengthsPsr4;
31-
$loader->prefixDirsPsr4 = ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1::$prefixDirsPsr4;
32-
$loader->classMap = ComposerStaticInit4227a9262042b7b77c23e4da01de8cd1::$classMap;
30+
$loader->prefixLengthsPsr4 = ComposerStaticInitc4b25d4c67ba5f31d25bdba015db7cda::$prefixLengthsPsr4;
31+
$loader->prefixDirsPsr4 = ComposerStaticInitc4b25d4c67ba5f31d25bdba015db7cda::$prefixDirsPsr4;
32+
$loader->classMap = ComposerStaticInitc4b25d4c67ba5f31d25bdba015db7cda::$classMap;
3333

3434
}, null, ClassLoader::class);
3535
}

core/pages/PAGE-home.php

+28-27
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
require PATH_PAGES . "TEMPLATE-top.php"; ?>
44
<!-- (A) HEADER -->
55
<h1 class="mb-0">CORE BOXX</h1>
6-
<div class="text-secondary mb-4">open source modular php framework</div>
7-
<img class="img-fluid d-block mx-auto mb-4" style="max-height:450px;" src="<?=HOST_ASSETS?>head-core-boxx.webp">
6+
<div class="text-secondary mb-4"><small>
7+
open source modular php framework
8+
</small></div>
89

9-
<!-- (B) HOW TO USE -->
10+
<!-- (B) QUICKSTART -->
1011
<h5 class="text-danger mb-2">
11-
<i class="ico-sm icon-power"></i> HOW TO USE CORE BOXX
12+
<i class="ico-sm icon-power"></i> QUICKSTART
1213
</h5>
1314
<div class="bg-white border p-4 mb-4">
14-
<div class="fw-bold mb-2">BASICS</div>
15-
<ul class="mb-4">
15+
<ul class="mb-0">
1616
<li><a href="https://code-boxx.com/core-boxx-php-framework/#sec-tut" target="_blank">
1717
Very Fast Tutorial
1818
</a></li>
@@ -31,10 +31,18 @@
3131
PHP Variables
3232
</a>
3333
</li>
34+
<li><a href="<?=HOST_BASE?>demo/clean">
35+
Delete all demo files, give me a clean installation.
36+
</a></li>
3437
</ul>
38+
</div>
3539

36-
<div class="fw-bold mb-2">DIVE DEEPER</div>
37-
<ul class="mb-4">
40+
<!-- (C) MORE @TODO -->
41+
<h5 class="text-danger mb-2">
42+
<i class="ico-sm icon-search"></i> DIVE DEEPER
43+
</h5>
44+
<div class="bg-white border p-4 mb-4">
45+
<ul class="mb-0">
3846
<li><a href="https://code-boxx.com/core-boxx-core-library-reference/" target="_blank">
3947
Core Concepts
4048
</a></li>
@@ -48,32 +56,28 @@
4856
JWT Sessions
4957
</a></li>
5058
</ul>
51-
52-
<div class="fw-bold mb-2">NAH, I AM GOOD.</div>
53-
<ul class="mb-0">
54-
<li><a href="<?=HOST_BASE?>demo/clean">
55-
Delete all demo files, give me a clean installation.
56-
</a></li>
57-
</ul>
5859
</div>
5960

60-
<!-- (C) SUPPORT -->
61+
<!-- (D) SUPPORT -->
6162
<h5 class="text-danger mb-2">
6263
<i class="ico-sm icon-heart"></i> SUPPORT
6364
</h5>
65+
<div class="text-secondary mb-2"><small>
66+
* Help keep Core Boxx alive, even if it is just a little bit.
67+
</small></div>
6468
<div class="bg-white border p-4 mb-4">
6569
<a class="my-1 btn btn-danger d-flex-inline" href="https://www.paypal.com/paypalme/wstoh/5" target="_blank">
6670
<i class="ico-sm icon-mug"></i> Buy me a coffee
6771
</a>
68-
<a class="my-1 btn btn-danger d-flex-inline" href="https://payhip.com/codeboxx" target="_blank">
69-
<i class="ico-sm icon-cart"></i> Code Boxx Store
70-
</a>
7172
<a class="my-1 btn btn-danger d-flex-inline" href="https://github.com/sponsors/code-boxx" target="_blank">
7273
<i class="ico-sm icon-heart"></i> GitHub Sponsor
7374
</a>
75+
<a class="my-1 btn btn-danger d-flex-inline" href="https://payhip.com/codeboxx" target="_blank">
76+
<i class="ico-sm icon-cart"></i> Code Boxx Store
77+
</a>
7478
</div>
7579

76-
<!-- (D) ALL OTHER LINKS -->
80+
<!-- (E) ALL OTHER LINKS -->
7781
<h5 class="text-danger mb-2">
7882
<i class="ico-sm icon-sphere"></i> ALL THE LINKS
7983
</h5>
@@ -84,7 +88,7 @@
8488
FAQ
8589
</a></li>
8690
<li><a href="https://github.com/code-boxx/Core-Boxx-PHP-Framework/issues/new/choose" target="_blank">
87-
Report a bug
91+
Report a bug / Feature Request
8892
</a></li>
8993
</ul>
9094

@@ -93,19 +97,16 @@
9397
<li><a href="https://code-boxx.com/" target="_blank">Code Boxx</a></li>
9498
<li><a href="https://www.youtube.com/c/CodeBoxx" target="_blank">YouTube</a></li>
9599
<li><a href="https://www.pinterest.com/codeboxx/" target="_blank">Pinterest</a></li>
96-
<li><a href="https://rumble.com/c/c-5298498" target="_blank">Rumble</a></li>
100+
<li><a href="https://www.facebook.com/real.code.boxx/" target="_blank">Facebook</a></li>
97101
<li><a href="https://github.com/code-boxx/" target="_blank">GitHub</a></li>
98102
<li><a href="https://codepen.io/code-boxx" target="_blank">CodePen</a></li>
99-
<li><a href="https://dev.to/codeboxx" target="_blank">DEV</a></li>
100-
<li><a href="https://facebook.com/real.code.boxx" target="_blank">Facebook</a></li>
101103
</ul>
102104

103-
<div class="fw-bold mb-2">CREDITS (BUILT WITH)</div>
105+
<div class="fw-bold mb-2">CREDITS / BUILT WITH</div>
104106
<ul class="mb-0">
105107
<li><a href="https://getbootstrap.com/" target="_blank">Bootstrap</a></li>
106108
<li><a href="https://icomoon.io/" target="_blank">IcoMoon</a></li>
107109
<li><a href="https://github.com/firebase/php-jwt" target="_blank">PHP JWT</a></li>
108110
</ul>
109111
</div>
110-
111-
<?php require PATH_PAGES . "TEMPLATE-bottom.php"; ?>
112+
<?php require PATH_PAGES . "TEMPLATE-bottom.php"; ?>

login with nfc/lib/LIB-NFCIN.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ function __construct ($core) {
1010
// (B) CREATE NEW NFC LOGIN TOKEN
1111
// $id : user id
1212
function add ($id) {
13-
// (B1) UPDATE TOKEN
13+
// (B1) CHECK VALID USER
14+
if (!is_array($this->Users->get($id))) {
15+
$this->error = "Invalid user";
16+
return false;
17+
}
18+
19+
// (B2) UPDATE TOKEN
1420
$token = $this->Core->random($this->nlen);
1521
$this->Users->hashAdd($id, "NFC", password_hash($token, PASSWORD_DEFAULT));
1622

17-
// (B2) RETURN ENCODED TOKEN
23+
// (B3) RETURN ENCODED TOKEN
1824
require PATH_LIB . "JWT/autoload.php";
1925
return Firebase\JWT\JWT::encode([$id, $token], JWT_SECRET, JWT_ALGO);
2026
}

login with qr/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## CORE BOXX LOGIN WITH QR MODULE
2+
https://code-boxx.com/core-boxx-qr-login-module/
3+
4+
## REQUIREMENTS
5+
* [Core Boxx](https://github.com/code-boxx/Core-Boxx-PHP-Framework/tree/main/core)
6+
* [Users Module](https://github.com/code-boxx/Core-Boxx-PHP-Framework/tree/main/users)
7+
* [Admin Module](https://github.com/code-boxx/Core-Boxx-PHP-Framework/tree/main/admin)
8+
9+
## INSTALL
10+
* Copy this module into your existing Core Boxx project folder.
11+
* Access `http://your-site.com/install/QRIN`, this will automatically:
12+
- Modify `pages/ADM-users.php`, load additional JS for QR.
13+
- Add "QR Login" button to `pages/ADM-users-list.php`.
14+
- Modify `pages/PAGE-login.php`, load additional JS and add "QR login" button.
15+
- Delete `PAGE-install-QRIN.php` itself.
16+
17+
## NOTES
18+
* Access admin users, select a user, "QR login".
19+
* Create a QR token for the user.
20+
* That's all, give the token to the user - Just scan to login.
21+
22+
## LICENSE
23+
Copyright by Code Boxx
24+
25+
Permission is hereby granted, free of charge, to any person obtaining a copy
26+
of this software and associated documentation files (the "Software"), to deal
27+
in the Software without restriction, including without limitation the rights
28+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29+
copies of the Software, and to permit persons to whom the Software is
30+
furnished to do so, subject to the following conditions:
31+
32+
The above copyright notice and this permission notice shall be included in all
33+
copies or substantial portions of the Software.
34+
35+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41+
SOFTWARE.

login with qr/assets/ADM-users-qr.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var uqr = {
2+
// (A) SHOW WRITE QR PAGE
3+
hqNull : null, // html null token button
4+
show : id => cb.load({
5+
page : "admin/users/qr", target : "cb-page-2",
6+
data : { id : id },
7+
onload : () => {
8+
uqr.hqNull = document.getElementById("qr-null");
9+
cb.page(2);
10+
}
11+
}),
12+
13+
// (B) NULLIFY QR TOKEN
14+
null : id => cb.api({
15+
mod : "qrin", act : "del",
16+
data : { id : id },
17+
passmsg : "Login token nullified.",
18+
onpass : res => uqr.hqNull.disabled = true
19+
})
20+
};

login with qr/assets/PAGE-login-qr.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
var qrscan = {
2+
// (A) PROPERTIES
3+
scanner : null, // scanner object
4+
5+
// (B) INITIALIZE
6+
init : after => {
7+
// (B1) ATTACH HTML
8+
let hScan = document.createElement("div");
9+
hScan.id = "qr-wrapA";
10+
hScan.className = "d-none tran-zoom bg-dark";
11+
hScan.innerHTML = `<div id="qr-wrapB">
12+
<h3 class="mb-3 text-white">SCAN QR CODE</h3>
13+
<div id="qr-cam" class="bg-light"></div>
14+
<button type="button" class="mt-4 btn btn-danger d-flex-inline" onclick="qrscan.hide()">
15+
<i class="ico-sm icon-cross"></i> Cancel
16+
</button>
17+
</div>`;
18+
document.body.appendChild(hScan);
19+
20+
// (B2) CREATE QR SCANNER OBJECT
21+
qrscan.scanner = new Html5QrcodeScanner("qr-cam", { fps: 10, qrbox: 250 });
22+
qrscan.scanner.render((txt, res) => {
23+
qrscan.hide();
24+
after(txt);
25+
});
26+
},
27+
28+
// (C) SHOW SCANNER
29+
show : () => cb.transit(() => {
30+
document.getElementById("qr-wrapA").classList.remove("d-none");
31+
document.body.classList.add("overflow-hidden");
32+
}),
33+
34+
// (D) HIDE QR SCANNER
35+
hide : () => {
36+
// (D1) SEEMINGLY NO SMART WAY TO "STOP SCANNING"
37+
let stop = document.getElementById("html5-qrcode-button-camera-stop"),
38+
wrap = document.getElementById("qr-wrapA");
39+
if (stop != null) {
40+
if (stop.style.display!="none") { stop.click(); }
41+
}
42+
43+
// (D2) HIDE SCANNER
44+
cb.transit(() => {
45+
wrap.classList.add("d-none");
46+
document.body.classList.remove("overflow-hidden");
47+
});
48+
},
49+
50+
// (E) INITIALIZE QR LOGIN
51+
go : () => {
52+
if (qrscan.scanner==null) {
53+
qrscan.init(token => cb.api({
54+
mod : "qrin", act : "login",
55+
data : { token : token },
56+
passmsg : false,
57+
onpass : () => location.href = cbhost.base
58+
}));
59+
}
60+
qrscan.show();
61+
}
62+
};

login with qr/assets/PAGE-qrscan.css

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#qr-wrapA {
2+
position: fixed; top: 0; left: 0;
3+
width:100vw; height: 100vh; z-index: 999;
4+
background: #fff;
5+
}
6+
#qr-wrapB {
7+
max-width: 600px; padding: 30px;
8+
margin: 0 auto;
9+
}

login with qr/assets/html5-qrcode.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

login with qr/assets/qrcode.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)