b5ef4ac0cb
Admin-scoped users (answers: who can create a 'user' account, only super or also an admin within their own scope?): - New owner_admin_id column on users (migration 004). NULL means created by super (company-wide, previous behavior); otherwise scoped to that admin's own codes. - Users::addUser/editUser/deleteUser now allow an 'admin' session, but force type='user' and owner_admin_id to their own id regardless of submitted input. user.php/users.php open up to admins with a restricted UI (no type picker, listing limited to their own created users). - New qr_compute_scope_owner_id()/qr_apply_owner_scope()/qr_has_full_visibility() helpers in includes/security.php, replacing the ad-hoc type==='admin' checks in index.php, dynamic_qrcodes.php, static_qrcodes.php and bulk_action.php. A 'user' account created by an admin is now scoped to that admin's codes instead of seeing everything company-wide. Qr code storage hardening: images were served as plain static files under the document root with no auth check at all. Storage now lives outside the web root; qrcode_image.php and qrcode_zip_download.php gate access with the same permission model as the list pages, and the bulk zip download is bound to the session that generated it. PHP 8.4 + chillerlan/php-qrcode 6.0.1: bumped since this is a dockerized app, so the PHP version shipped doesn't matter to end users. Note: the 6.0.1 tag itself only requires PHP 8.2 - the earlier "needs 8.4" read was from an unpinned clone of master, which has since moved past the tag. Fixed along the way, surfaced by testing on 8.4: - The hardcoded Imagick build (an old pinned master commit, workaround for 3.7.0 being broken on PHP 8.3+) no longer compiles on 8.4. Imagick 3.8.1 is now a normal stable release, so the workaround is gone. - config.php had display_errors=On + error_reporting(E_ALL), so PHP 8.4's new deprecation notices got dumped straight into the response before session_start() could run, breaking login outright. Also an info-disclosure risk on its own. Now logged instead of displayed. - MysqliDb::insertMulti() had an implicit nullable parameter, now explicit. - includes/auth_validate.php redirected unauthenticated requests but never called exit(), so the rest of the script kept running. - Dockerfile.fpm was missing both git (needed to clone chillerlan/php-qrcode) and the imagick extension entirely. Also removes the unused sample qr code images that shipped in the original repo; storage now lives outside the document root so they were never going to be served again. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
103 lines
5.1 KiB
PHP
103 lines
5.1 KiB
PHP
|
|
<aside class="main-sidebar sidebar-dark-primary elevation-4">
|
|
<!-- Brand Logo -->
|
|
<a href="./index.php" class="brand-link">
|
|
<img src="dist/img/Symbol_WhiteBlue.png" alt="Logo" class="brand-image"
|
|
style="opacity: .8">
|
|
<span class="brand-text font-weight-light">Qrcode Generator</span>
|
|
</a>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="sidebar">
|
|
<!--Sidebar user panel (optional)
|
|
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
|
|
<div class="image">
|
|
<img src="dist/img/avatar5.png" class="img-circle elevation-2" alt="User Image">
|
|
</div>
|
|
<div class="info">
|
|
<a href="#" class="d-block">Superadmin</a>
|
|
</div>
|
|
</div>
|
|
|
|
-->
|
|
<!-- Sidebar Menu -->
|
|
<nav class="mt-2">
|
|
<ul class="nav nav-pills nav-sidebar flex-column nav-legacy" data-widget="treeview" role="menu" data-accordion="false">
|
|
<!-- Add icons to the links using the .nav-icon class
|
|
with font-awesome or any other icon font library -->
|
|
<li class="nav-item">
|
|
<a href="./index.php" <?php echo ((substr(CURRENT_PAGE, 0, 9) == 'index.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="nav-icon fas fa-tachometer-alt"></i>
|
|
<p>
|
|
Dashboard
|
|
</p>
|
|
</a>
|
|
</li>
|
|
<?php if ($_SESSION['type'] !== 'user' || !empty($_SESSION['can_view_dynamic'])): ?>
|
|
<li <?php echo ((substr(CURRENT_PAGE, 0, 19) == 'dynamic_qrcodes.php') || (substr(CURRENT_PAGE, 0, 18) == 'dynamic_qrcode.php')) ? ' class="nav-item has-treeview menu-open"' : ' class="nav-item has-treeview"'; ?>>
|
|
<a href="#" <?php echo ((substr(CURRENT_PAGE, 0, 19) == 'dynamic_qrcodes.php') || (substr(CURRENT_PAGE, 0, 18) == 'dynamic_qrcode.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="nav-icon fa fa-qrcode"></i>
|
|
<p>
|
|
Dynamic Qr codes
|
|
<i class="right fas fa-angle-left"></i>
|
|
</p>
|
|
</a>
|
|
<ul class="nav nav-treeview">
|
|
<li class="nav-item">
|
|
<a href="./dynamic_qrcodes.php" <?php echo ((substr(CURRENT_PAGE, 0, 19) == 'dynamic_qrcodes.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="far fa-circle nav-icon"></i>
|
|
<p>List all</p>
|
|
</a>
|
|
</li>
|
|
<?php if ($_SESSION['type'] !== 'user'): ?>
|
|
<li class="nav-item">
|
|
<a href="./dynamic_qrcode.php" <?php echo (CURRENT_PAGE == 'dynamic_qrcode.php') ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="far fa-circle nav-icon"></i>
|
|
<p>Add new</p>
|
|
</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if ($_SESSION['type'] !== 'user' || !empty($_SESSION['can_view_static'])): ?>
|
|
<li <?php echo ((substr(CURRENT_PAGE, 0, 18) == 'static_qrcodes.php') || (substr(CURRENT_PAGE, 0, 17) == 'static_qrcode.php')) ? ' class="nav-item has-treeview menu-open"' : ' class="nav-item has-treeview"'; ?>>
|
|
<a href="#" <?php echo ((substr(CURRENT_PAGE, 0, 18) == 'static_qrcodes.php') || (substr(CURRENT_PAGE, 0, 17) == 'static_qrcode.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="nav-icon fa fa-qrcode"></i>
|
|
<p>
|
|
Static Qr codes
|
|
<i class="right fas fa-angle-left"></i>
|
|
</p>
|
|
</a>
|
|
<ul class="nav nav-treeview">
|
|
<li class="nav-item">
|
|
<a href="./static_qrcodes.php" <?php echo ((substr(CURRENT_PAGE, 0, 18) == 'static_qrcodes.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="far fa-circle nav-icon"></i>
|
|
<p>List all</p>
|
|
</a>
|
|
</li>
|
|
<?php if ($_SESSION['type'] !== 'user'): ?>
|
|
<li class="nav-item">
|
|
<a href="./static_qrcode.php" <?php echo (CURRENT_PAGE == 'static_qrcode.php') ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="far fa-circle nav-icon"></i>
|
|
<p>Add new</p>
|
|
</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</li>
|
|
<?php endif; ?>
|
|
<?php if (in_array($_SESSION['type'], ['super', 'admin'], true)): ?>
|
|
<li class="nav-item">
|
|
<a href="./users.php" <?php echo ((substr(CURRENT_PAGE, 0, 15) == 'users.php') || (substr(CURRENT_PAGE, 0, 14) == 'user.php')) ? ' class="nav-link active"' : ' class="nav-link"'; ?>>
|
|
<i class="fas fa-users nav-icon"></i>
|
|
<p>Users</p>
|
|
</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</nav>
|
|
<!-- /.sidebar-menu -->
|
|
</div>
|
|
<!-- /.sidebar -->
|
|
</aside>
|