# Changelog ## Changes 4/16 Refactor API endpoints and modularize controllers and models - Reorganized project structure to separate API logic into dedicated controllers and models: - Created adminController, userController, fileController, folderController, uploadController, and authController. - Created corresponding models (AdminModel, UserModel, FileModel, FolderModel, UploadModel, AuthModel) for business logic. - Consolidated API endpoints under the /public/api folder with subfolders for admin, auth, file, folder, and upload endpoints. - Added inline OpenAPI annotations to document key endpoints (e.g., getConfig.php, updateConfig.php) for improved API documentation. - Updated configuration retrieval and update logic in AdminModel and AdminController to handle OIDC and login option booleans consistently, fixing issues with basic auth settings not updating on the login page. - Updated the client-side auth.js to correctly reference API endpoints (adjusted query selectors to reflect new document root) and load admin configuration from the updated API endpoints. - Minor improvements to CSRF token handling, error logging, and overall code readability. This refactor improves maintainability, testability, and documentation clarity across all API endpoints. ### Refactor fixes and adjustments - Added fallback checks for disableFormLogin / disableBasicAuth / disableOIDCLogin when coming in either at the top level or under loginOptions. - Updated auth.js to read and store the nested loginOptions booleans correctly in localStorage, then show/hide the Basic‑Auth and OIDC buttons as configured. - Changed the logout controller to header("Location: /index.html?logout=1") so after /api/auth/logout.php it lands on the root index.html, not under /api/auth/. - Switched your share modal code to use a leading slash ("/api/file/share.php") so it generates absolute URLs instead of relative /share.php. - In the shared‑folder gallery, adjusted the client‑side image path to point at /uploads/... instead of /api/folder/uploads/... - Updated both AdminModel defaults and the AuthController to use the exact full path - Network Utilities Overhaul swapped out the old fetch wrapper for one that always reads the raw response, tries to JSON.parse it, and then either returns the parsed object on ok or throws it on error. - Adjusted your submitLogin .catch() to grab the thrown object (or string) and pass that through to showToast, so now “Invalid credentials” actually shows up. - Pulled the common session‑setup and “remember me” logic into two new helpers, finalizeLogin() (for AJAX/form/basic/TOTP) and finishBrowserLogin() (for OIDC redirects). That removed tons of duplication and ensures every path calls the same permission‑loading code. - Ensured that after you POST just a totp_code, we pick up pending_login_user/pending_login_secret, verify it, then immediately call finalizeLogin(). - Expanded checkAuth.php Response now returns all three flags—folderOnly, readOnly, and disableUpload so client can handle every permission. - In auth.js’s updateAuthenticatedUI(), write all three flags into localStorage whenever you land on the app (OIDC, basic or form). That guarantees consistent behavior across page loads. - Made sure the OIDC handler reads the live config via AdminModel::getConfig() and pushes you through the TOTP flow if needed, then back to /index.html. --- ## Changes 4/15/2025 - Adjust Gallery View max columns based on screen size - Adjust headerTitle to update globally ## Changes 4/14/2025 - Fix Gallery View: medium screen devices get 3 max columns and small screen devices 2 max columns. - Ensure gallery view toggle button displays after refresh page. - Force resumable chunk size & fix chunk cleanup ### filePreview.js Enhancements **Modal Layout Overhaul:** - **Left Panel:** Holds zoom in/out controls at the top and the "prev" button at the bottom. - **Center Panel:** Always centers the preview image. - **Right Panel:** Contains rotate left/right controls at the top and the "next" button at the bottom. **Consistent Control Presence:** - Both left and right panels are always included. When there’s only one image, placeholders are inserted in place of missing navigation buttons to ensure the image remains centered and that rotate controls are always visible. **Improved Transform Behavior:** - Transformation values (scale and rotation) are reset on each navigation event, ensuring predictable behavior and consistent presentation. --- ## Changes 4/13/2025 v1.1.3 - Decreased header height some more and clickable logo. - authModals.js fully updated with i18n.js keys. - main.js added Dark & Light mode i18n.js keys. - New Admin section Header Settings to change Header Title. - Admin Panel confirm unsaved changes. - Added translations and data attributes for almost all user-facing text - Extend i18n support: Add new translation keys for Download and Share modals - **Slider Integration:** - Added a slider UI (range input, label, and value display) directly above the gallery grid. - The slider allows users to adjust the number of columns in the gallery from 1 to 6. - **Dynamic Grid Updates:** - The gallery grid’s CSS is updated in real time via the slider’s value by setting the grid-template-columns property. - As the slider value changes, the layout instantly reflects the new column count. - **Dynamic Image Resizing:** - Introduced a helper function (getMaxImageHeight) that calculates the maximum image height based on the current column count. - The max height of each image is updated immediately when the slider is adjusted to create a more dynamic display. - **Image Caching:** - Implemented an image caching mechanism using a global window.imageCache object. - Images are cached on load (via an onload event) to prevent unnecessary reloading, improving performance. - **Event Handling:** - The slider’s event listener is set up to update both the gallery grid layout and the dimensions of the thumbnails dynamically. - Share button event listeners remain attached for proper functionality across the updated gallery view. - **Input Validation & Security:** - Used `filter_input()` to sanitize and validate incoming GET parameters (token, pass, page). - Validated file system paths using `realpath()` and ensured the shared folder lies within `UPLOAD_DIR`. - Escaped all dynamic outputs with `htmlspecialchars()` to prevent XSS. - **Share Link Verification:** - Loaded and validated share records from the JSON file. - Handled expiration and password protection (with proper HTTP status codes for errors). - **Pagination:** - Implemented pagination by slicing the full file list into a limited number of files per page (default of 10). - Calculated total pages and current page to create navigation links. - **View Toggle (List vs. Gallery):** - Added a toggle button that switches between a traditional list view and a gallery view. - Maintained two separate view containers (`#listViewContainer` and `#galleryViewContainer`) to support this switching. - **Gallery View with Image Caching:** - For the gallery view, implemented a JavaScript function that creates a grid of image thumbnails. - Each image uses a cache-busting query string on first load and caches its URL in a global `window.imageCache` for subsequent renders. - **Persistent Pagination Controls:** - Moved the pagination controls outside the individual view containers so that they remain visible regardless of the selected view. --- ## Changes 4/12/2025 - Moved Gallery view toggle button into header. - Removed css entries that are not needed anymore for Gallery View Toggle. - Change search box text when enabling advanced search. - Advanced/Basic search button as material icon on same row as search bar. ### Advanced Search Implementation - **Advanced Search Toggle:** - Added a global toggle (`window.advancedSearchEnabled`) and a UI button to switch between basic and advanced search modes. - The toggle button label changes between "Advanced Search" and "Basic Search" to reflect the active mode. - **Fuse.js Integration Updates:** - Modified the `searchFiles()` function to conditionally include the `"content"` key in the Fuse.js keys only when advanced search mode is enabled. - Adjusted Fuse.js options by adding `ignoreLocation: true`, adjusting the `threshold`, and optionally assigning weights (e.g., a lower weight for `name` and a higher weight for `content`) to prioritize matches in file content. - **Backend (PHP) Enhancements:** - Updated **getFileList.php** to read the content of text-based files (e.g., `.txt`, `.html`, `.md`, etc.) using `file_get_contents()`. - Added a `"content"` property to the JSON response for eligible files to allow for full-text search in advanced mode. ### Fuse.js Integration for Indexed Real-Time Searching** - **Added Fuse.js Library:** Included Fuse.js via a CDN `