From 752eea2c0dade5c545ab1274d5092738fb35fbf8 Mon Sep 17 00:00:00 2001 From: Andrii Riabchenko Date: Sat, 4 Jul 2026 13:59:07 +0300 Subject: [PATCH 1/2] Update README.md to enhance installation instructions and add frontend asset management details --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0392876..4ffce94 100755 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ - **MVC Architecture:** Clean separation of concerns with models, views, and controllers to organize code logically. - **Core Components:** Includes essential libraries for handling sessions, database connections, request processing, and URL routing. +- **Secure by Default:** Twig auto-escaping, CSRF tokens, hardened sessions, and strict route validation out of the box. +- **Modern Frontend Build:** Tailwind CSS 4 + daisyUI bundled with Vite, with automatic cache busting. - **Migration System:** Built-in system for managing database schema changes and versioning. - **Installer:** Interactive installer for quick setup, including `.env` generation, Composer installation, and database migration execution. - **Easy to Install and Configure:** Minimal setup required for developers to get started quickly. @@ -20,32 +22,51 @@ - PHP 8+ - A web server (e.g., Apache, Nginx) - MySQL +- Node.js 20+ and npm (only for building frontend assets) ## Installation 1. Clone the repository: ```bash - git clone https://github.com/yourusername/PHPapp.git + git clone https://github.com/and-ri/phpapp.git ``` 2. Navigate to the project directory: ```bash - cd PHPapp + cd phpapp ``` -3. Install dependencies: +3. Install dependencies and build frontend assets: ```bash composer install + npm install npm run build ``` 4. Run the installer: Open `http://yourdomain.com/installer.php` in your browser and follow the on-screen instructions to set up the database and configuration. -5. Done! +5. Done! For security, delete `installer.php` from the `www` directory after installation (it refuses to run again while `.env` exists, but removing it entirely is safer). + +## Frontend Assets + +Frontend sources live in `static/css/style.css` and `static/js/app.js` and are bundled by Vite (Tailwind CSS 4 + daisyUI) into `www/assets/`: + +```bash +npm run dev # rebuild automatically on changes (vite build --watch) +npm run build # one-off production build +``` + +Templates reference the built assets through `$this->staticfile->getAssetUri('css/app.css')`, which appends a cache-busting `?v=` parameter. The built files in `www/assets/` are committed to the repository, so remember to run `npm run build` before committing frontend changes. + +## Templating and Security + +- Twig **auto-escaping is enabled**: any variable printed with `{{ ... }}` is HTML-escaped. Pass trusted HTML (e.g. output of another controller) through `$this->view->raw($html)` — `Load::controller()` already does this for you. +- Every form should include the CSRF field with `{{ csrf }}` and validate it with `$this->session->validateToken($this->request->post['csrf'])` (see `app/controller/catalog/csrf_protection.php` for a complete example). +- Request data (`$this->request->get/post/cookie`) is raw. Escape at the output layer: Twig handles HTML, and use `$this->db->escape()` or `$this->db->execute($sql, $params)` (prepared statements) for SQL. ## Core Components @@ -58,7 +79,8 @@ ### Libraries - **app.php**: Manages the application lifecycle, including initialization and configuration. -- **db.php**: Provides methods for database queries and connection handling. +- **cache.php**: Simple file-based cache with optional TTL (`get`, `set`, `delete`, `deleteAll`). +- **db.php**: Provides methods for database queries and connection handling, including prepared statements via `execute()`. - **env.php**: Handles environment variables and configuration settings. - **google_auth.php**: Handles the Google authentication process for the application. - **language.php**: Loads and manages language files for multi-language support. @@ -66,19 +88,36 @@ - **pagination.php**: Provides simple pagination functionality. - **request.php**: Handles incoming HTTP requests. - **response.php**: Manages HTTP responses and headers. -- **session.php**: Facilitates session management (start, get, set, remove, etc.). -- **staticfile.php**: Serves static files (CSS, JS, images). +- **session.php**: Facilitates session management (start, get, set, remove, etc.) and CSRF tokens. +- **staticfile.php**: Serves static files (CSS, JS, images) and generates cache-busted URIs for built assets. - **url.php**: Generates URLs and manages routing. - **log.php**: Provides centralized logging functionality using Monolog. - **meta.php**: Manages SEO metadata including page titles, descriptions, Open Graph tags, and robots directives using the Melbahja/Seo package. -### New Features +## Migrations + +Create a migration by copying `migrations/template.php` to a new file (e.g. `migrations/2026_07_04_create_users.php`). A migration returns an anonymous class with `up()` and `down()` methods: + +```php +return new class { + public function up($db) { + $db->query("CREATE TABLE ..."); + } + + public function down($db) { + $db->query("DROP TABLE ..."); + } +}; +``` + +Then run: -- **Migration System:** Manage database schema changes with ease. Use `php migrate.php migrate` to apply migrations, `php migrate.php rollback` to undo the last migration, and `php migrate.php status` to check migration status. -- **Interactive Installer:** Quickly set up your application by providing database and web configuration details in a user-friendly web installer. -- **Centralized Logging:** Monitor application events, errors, and debugging information using the integrated Monolog-based logging system. -- **SEO Management:** Easily manage page metadata, title tags, Open Graph properties, and other SEO essentials using the integrated meta.php library powered by Melbahja/Seo package. +```bash +php migrate.php migrate # apply pending migrations +php migrate.php rollback # undo the last migration +php migrate.php status # show applied and pending migrations +``` ## License -This project is licensed under the MIT License. \ No newline at end of file +This project is licensed under the MIT License. From 7c5941a8aa76058a49d20ecc9f09c013a6a8b99b Mon Sep 17 00:00:00 2001 From: Andrii Riabchenko Date: Sat, 4 Jul 2026 14:06:55 +0300 Subject: [PATCH 2/2] Add new libraries for validation, file upload, flash messaging, and email handling - Introduced `Validator` class for data validation with customizable rules and error messages. - Added `Upload` class for secure file uploads with MIME type checking and error handling. - Implemented `Flash` class for one-time session messages to facilitate user feedback. - Created `Mail` class utilizing PHPMailer for sending emails with SMTP support and attachments. - Updated `bootstrap.php` to register new classes in the application registry. --- .env.example | 9 + README.md | 4 + app/controller/catalog/csrf_protection.php | 21 +- app/language/en/catalog/csrf_protection.php | 4 +- composer.json | 5 +- composer.lock | 544 ++++++++------------ core/bootstrap.php | 4 + core/library/flash.php | 61 +++ core/library/mail.php | 83 +++ core/library/upload.php | 129 +++++ core/library/validator.php | 125 +++++ 11 files changed, 651 insertions(+), 338 deletions(-) create mode 100644 core/library/flash.php create mode 100644 core/library/mail.php create mode 100644 core/library/upload.php create mode 100644 core/library/validator.php diff --git a/.env.example b/.env.example index a39c7fa..cfcc5f8 100755 --- a/.env.example +++ b/.env.example @@ -6,6 +6,15 @@ DB_NAME="database" DB_PORT="3306" DB_PREFIX="prefix_" +# Mail (leave MAIL_HOST empty to use PHP mail()) +MAIL_HOST="" +MAIL_PORT="587" +MAIL_USER="" +MAIL_PASS="" +MAIL_ENCRYPTION="tls" +MAIL_FROM="" +MAIL_FROM_NAME="" + # Google API Key GOOGLE_AUTH_CLIENT_ID="" GOOGLE_AUTH_CLIENT_SECRET="" diff --git a/README.md b/README.md index 4ffce94..9db1723 100755 --- a/README.md +++ b/README.md @@ -82,15 +82,19 @@ Templates reference the built assets through `$this->staticfile->getAssetUri('cs - **cache.php**: Simple file-based cache with optional TTL (`get`, `set`, `delete`, `deleteAll`). - **db.php**: Provides methods for database queries and connection handling, including prepared statements via `execute()`. - **env.php**: Handles environment variables and configuration settings. +- **flash.php**: One-time session messages for the POST -> redirect -> GET pattern. - **google_auth.php**: Handles the Google authentication process for the application. - **language.php**: Loads and manages language files for multi-language support. - **load.php**: Loads models and controllers dynamically. +- **mail.php**: Sends email via SMTP or PHP `mail()` using PHPMailer (configured through `.env`). - **pagination.php**: Provides simple pagination functionality. - **request.php**: Handles incoming HTTP requests. - **response.php**: Manages HTTP responses and headers. - **session.php**: Facilitates session management (start, get, set, remove, etc.) and CSRF tokens. - **staticfile.php**: Serves static files (CSS, JS, images) and generates cache-busted URIs for built assets. +- **upload.php**: Stores uploaded files safely (finfo MIME check, extension allowlist, random names). - **url.php**: Generates URLs and manages routing. +- **validator.php**: Rule-based input validation (`required|email|min:8|...`) with per-field error messages. - **log.php**: Provides centralized logging functionality using Monolog. - **meta.php**: Manages SEO metadata including page titles, descriptions, Open Graph tags, and robots directives using the Melbahja/Seo package. diff --git a/app/controller/catalog/csrf_protection.php b/app/controller/catalog/csrf_protection.php index f460f3e..eec6dfd 100755 --- a/app/controller/catalog/csrf_protection.php +++ b/app/controller/catalog/csrf_protection.php @@ -12,12 +12,16 @@ public function index() { $this->data['action'] = $this->url->link('catalog/csrf_protection'); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) { - $this->data['success'] = $this->language->get('text_success'); - } else { - $this->data['error'] = isset($this->error['csrf_token']) ? $this->error['csrf_token'] : ''; - $this->data['email'] = isset($this->request->post['email']) ? $this->request->post['email'] : ''; + // POST -> redirect -> GET: the message survives the redirect in a flash + $this->flash->set('success', $this->language->get('text_success')); + + $this->response->redirect($this->data['action']); } + $this->data['success'] = $this->flash->get('success'); + $this->data['error'] = implode(' ', $this->error); + $this->data['email'] = isset($this->request->post['email']) ? $this->request->post['email'] : ''; + $this->data['header'] = $this->load->controller('common/header'); $this->data['footer'] = $this->load->controller('common/footer'); @@ -29,6 +33,13 @@ protected function validate() { $this->error['csrf_token'] = $this->language->get('error_csrf_token'); } + if (!$this->validator->validate($this->request->post, array( + 'email' => 'required|email', + 'password' => 'required|min:8' + ))) { + $this->error = array_merge($this->error, $this->validator->errors()); + } + return !$this->error; } -} \ No newline at end of file +} diff --git a/app/language/en/catalog/csrf_protection.php b/app/language/en/catalog/csrf_protection.php index 4c1e059..c252703 100755 --- a/app/language/en/catalog/csrf_protection.php +++ b/app/language/en/catalog/csrf_protection.php @@ -8,7 +8,9 @@ 'entry_email' => 'Email', 'entry_password' => 'Password', 'button_submit' => 'Submit', - 'error_csrf_token' => 'Invalid CSRF token', + 'error_csrf_token' => 'Invalid CSRF token.', + 'error_validation_email' => 'Please enter a valid email address.', + 'error_validation_min' => 'The %field% must be at least %param% characters.', 'text_success' => 'Success! CSRF token is valid', 'text_help' => 'This form is protected by CSRF protection. To submit the form, you need to provide a valid CSRF token. The token is generated when the form is loaded and is stored in the session. When the form is submitted, the token is validated. If the token is invalid, the form submission is rejected.', ]; \ No newline at end of file diff --git a/composer.json b/composer.json index 0748dd7..82bf205 100755 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "vlucas/phpdotenv": "^5.6", "google/apiclient": "^2.0", "monolog/monolog": "^3.9", - "melbahja/seo": "^2.1" + "melbahja/seo": "^2.1", + "phpmailer/phpmailer": "^7.1" }, "repositories": [ { @@ -28,4 +29,4 @@ "config": { "vendor-dir": "core/vendor" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 8ca7018..e3a01c5 100755 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9d1a888853d0c154f8ba4d3abc38fd45", + "content-hash": "c5396a890d34e33f7799823d8c3a2ba9", "packages": [ { "name": "firebase/php-jwt", - "version": "v6.11.1", + "version": "v7.1.0", "source": { "type": "git", - "url": "https://github.com/firebase/php-jwt.git", - "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66" + "url": "https://github.com/googleapis/php-jwt.git", + "reference": "b374a5d1a4f1f67fadc2165cdb284645945e2fc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", - "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", + "url": "https://api.github.com/repos/googleapis/php-jwt/zipball/b374a5d1a4f1f67fadc2165cdb284645945e2fc0", + "reference": "b374a5d1a4f1f67fadc2165cdb284645945e2fc0", "shasum": "" }, "require": { @@ -25,6 +25,8 @@ }, "require-dev": { "guzzlehttp/guzzle": "^7.4", + "phpfastcache/phpfastcache": "^9.2", + "phpseclib/phpseclib": "~3.0", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", "psr/cache": "^2.0||^3.0", @@ -33,7 +35,8 @@ }, "suggest": { "ext-sodium": "Support EdDSA (Ed25519) signatures", - "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present", + "phpseclib/phpseclib": "Support PS256 (RSASSA-PSS) signatures" }, "type": "library", "autoload": { @@ -58,56 +61,58 @@ } ], "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", - "homepage": "https://github.com/firebase/php-jwt", + "homepage": "https://github.com/googleapis/php-jwt", "keywords": [ "jwt", "php" ], "support": { - "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.11.1" + "issues": "https://github.com/googleapis/php-jwt/issues", + "source": "https://github.com/googleapis/php-jwt/tree/v7.1.0" }, - "time": "2025-04-09T20:32:01+00:00" + "time": "2026-06-11T17:54:14+00:00" }, { "name": "google/apiclient", - "version": "v2.18.3", + "version": "v2.19.4", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client.git", - "reference": "4eee42d201eff054428a4836ec132944d271f051" + "reference": "f745b310113d556c19d5e54ccc48b5821d1e2622" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/4eee42d201eff054428a4836ec132944d271f051", - "reference": "4eee42d201eff054428a4836ec132944d271f051", + "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/f745b310113d556c19d5e54ccc48b5821d1e2622", + "reference": "f745b310113d556c19d5e54ccc48b5821d1e2622", "shasum": "" }, "require": { - "firebase/php-jwt": "^6.0", + "firebase/php-jwt": "^6.0||^7.0", "google/apiclient-services": "~0.350", "google/auth": "^1.37", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.6", "monolog/monolog": "^2.9||^3.0", - "php": "^8.0", - "phpseclib/phpseclib": "^3.0.36" + "php": "^8.1" }, "require-dev": { "cache/filesystem-adapter": "^1.1", - "composer/composer": "^1.10.23", + "composer/composer": "^2.9", "phpcompatibility/php-compatibility": "^9.2", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "squizlabs/php_codesniffer": "^3.8", - "symfony/css-selector": "~2.1", - "symfony/dom-crawler": "~2.1" + "symfony/css-selector": "^5.4", + "symfony/dom-crawler": "^5.4" }, "suggest": { "cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)" }, "type": "library", "extra": { + "component": { + "entry": "src/Client.php" + }, "branch-alias": { "dev-main": "2.x-dev" } @@ -134,26 +139,26 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client/issues", - "source": "https://github.com/googleapis/google-api-php-client/tree/v2.18.3" + "source": "https://github.com/googleapis/google-api-php-client/tree/v2.19.4" }, - "time": "2025-04-08T21:59:36+00:00" + "time": "2026-06-29T08:12:37+00:00" }, { "name": "google/apiclient-services", - "version": "v0.396.0", + "version": "v0.448.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "ceb2e432e4326c6775d24f62d554395a1a9ad3dd" + "reference": "00c3d6814497ec09eaf29af42102455a85338507" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/ceb2e432e4326c6775d24f62d554395a1a9ad3dd", - "reference": "ceb2e432e4326c6775d24f62d554395a1a9ad3dd", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/00c3d6814497ec09eaf29af42102455a85338507", + "reference": "00c3d6814497ec09eaf29af42102455a85338507", "shasum": "" }, "require": { - "php": "^8.0" + "php": "^8.1" }, "require-dev": { "phpunit/phpunit": "^9.6" @@ -178,43 +183,44 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.396.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.448.0" }, - "time": "2025-02-24T01:10:27+00:00" + "time": "2026-06-28T01:44:38+00:00" }, { "name": "google/auth", - "version": "v1.47.0", + "version": "v1.52.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "d6389aae7c009daceaa8da9b7942d8df6969f6d9" + "reference": "7a7e5ab2ff2d9449a252eab587d4dae978c22a77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/d6389aae7c009daceaa8da9b7942d8df6969f6d9", - "reference": "d6389aae7c009daceaa8da9b7942d8df6969f6d9", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/7a7e5ab2ff2d9449a252eab587d4dae978c22a77", + "reference": "7a7e5ab2ff2d9449a252eab587d4dae978c22a77", "shasum": "" }, "require": { - "firebase/php-jwt": "^6.0", + "firebase/php-jwt": "^6.0||^7.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", - "php": "^8.0", + "php": "^8.1", "psr/cache": "^2.0||^3.0", "psr/http-message": "^1.1||^2.0", - "psr/log": "^3.0" + "psr/log": "^2.0||^3.0" }, "require-dev": { "guzzlehttp/promises": "^2.0", - "kelvinmo/simplejwt": "0.7.1", + "kelvinmo/simplejwt": "^1.1.0", "phpseclib/phpseclib": "^3.0.35", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", "sebastian/comparator": ">=1.2.3", - "squizlabs/php_codesniffer": "^3.5", + "squizlabs/php_codesniffer": "^4.0", + "symfony/filesystem": "^6.3||^7.3", "symfony/process": "^6.0||^7.0", - "webmozart/assert": "^1.11" + "webmozart/assert": "^1.11||^2.0" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." @@ -239,30 +245,30 @@ "support": { "docs": "https://cloud.google.com/php/docs/reference/auth/latest", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.47.0" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.52.0" }, - "time": "2025-04-15T21:47:20+00:00" + "time": "2026-06-23T16:43:15+00:00" }, { "name": "graham-campbell/result-type", - "version": "v1.1.3", + "version": "v1.1.4", "source": { "type": "git", "url": "https://github.com/GrahamCampbell/Result-Type.git", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945" + "reference": "e01f4a821471308ba86aa202fed6698b6b695e3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/3ba905c11371512af9d9bdd27d99b782216b6945", - "reference": "3ba905c11371512af9d9bdd27d99b782216b6945", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/e01f4a821471308ba86aa202fed6698b6b695e3b", + "reference": "e01f4a821471308ba86aa202fed6698b6b695e3b", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3" + "phpoption/phpoption": "^1.9.5" }, "require-dev": { - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + "phpunit/phpunit": "^8.5.41 || ^9.6.22 || ^10.5.45 || ^11.5.7" }, "type": "library", "autoload": { @@ -291,7 +297,7 @@ ], "support": { "issues": "https://github.com/GrahamCampbell/Result-Type/issues", - "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.3" + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.1.4" }, "funding": [ { @@ -303,29 +309,30 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:45:45+00:00" + "time": "2025-12-27T19:43:20+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "7.9.3", + "version": "7.13.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" + "reference": "55901a76dfd2006a0cc012b9e3c5b487f796478d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", - "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/55901a76dfd2006a0cc012b9e3c5b487f796478d", + "reference": "55901a76dfd2006a0cc012b9e3c5b487f796478d", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.3", - "guzzlehttp/psr7": "^2.7.0", + "guzzlehttp/promises": "^2.5", + "guzzlehttp/psr7": "^2.12.3", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-client-implementation": "1.0" @@ -334,8 +341,9 @@ "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", "guzzle/client-integration-tests": "3.0.2", + "guzzlehttp/test-server": "^0.6", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "phpunit/phpunit": "^8.5.52 || ^9.6.34", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -413,7 +421,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.9.3" + "source": "https://github.com/guzzle/guzzle/tree/7.13.1" }, "funding": [ { @@ -429,28 +437,29 @@ "type": "tidelift" } ], - "time": "2025-03-27T13:37:11+00:00" + "time": "2026-06-29T20:14:18+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.2.0", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + "reference": "4360e982f87f5f258bf872d094647791db2f4c8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", - "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "url": "https://api.github.com/repos/guzzle/promises/zipball/4360e982f87f5f258bf872d094647791db2f4c8e", + "reference": "4360e982f87f5f258bf872d094647791db2f4c8e", "shasum": "" }, "require": { - "php": "^7.2.5 || ^8.0" + "php": "^7.2.5 || ^8.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "type": "library", "extra": { @@ -496,7 +505,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.2.0" + "source": "https://github.com/guzzle/promises/tree/2.5.0" }, "funding": [ { @@ -512,27 +521,29 @@ "type": "tidelift" } ], - "time": "2025-03-27T13:27:01+00:00" + "time": "2026-06-02T12:23:43+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.7.1", + "version": "2.12.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + "reference": "7ec62dc3f44aa218487dbed81a9bf9bc647be55d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", - "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/7ec62dc3f44aa218487dbed81a9bf9bc647be55d", + "reference": "7ec62dc3f44aa218487dbed81a9bf9bc647be55d", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" + "ralouphie/getallheaders": "^3.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/polyfill-php80": "^1.25" }, "provide": { "psr/http-factory-implementation": "1.0", @@ -540,8 +551,9 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "0.9.0", - "phpunit/phpunit": "^8.5.39 || ^9.6.20" + "http-interop/http-factory-tests": "1.1.0", + "jshttp/mime-db": "1.54.0.1", + "phpunit/phpunit": "^8.5.52 || ^9.6.34" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -612,7 +624,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.7.1" + "source": "https://github.com/guzzle/psr7/tree/2.12.3" }, "funding": [ { @@ -628,7 +640,7 @@ "type": "tidelift" } ], - "time": "2025-03-27T12:30:47+00:00" + "time": "2026-06-23T15:21:08+00:00" }, { "name": "melbahja/seo", @@ -692,16 +704,16 @@ }, { "name": "monolog/monolog", - "version": "3.9.0", + "version": "3.10.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6" + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/10d85740180ecba7896c87e06a166e0c95a0e3b6", - "reference": "10d85740180ecba7896c87e06a166e0c95a0e3b6", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/b321dd6749f0bf7189444158a3ce785cc16d69b0", + "reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0", "shasum": "" }, "require": { @@ -719,7 +731,7 @@ "graylog2/gelf-php": "^1.4.2 || ^2.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.2", - "mongodb/mongodb": "^1.8", + "mongodb/mongodb": "^1.8 || ^2.0", "php-amqplib/php-amqplib": "~2.4 || ^3", "php-console/php-console": "^3.1.8", "phpstan/phpstan": "^2", @@ -779,7 +791,7 @@ ], "support": { "issues": "https://github.com/Seldaek/monolog/issues", - "source": "https://github.com/Seldaek/monolog/tree/3.9.0" + "source": "https://github.com/Seldaek/monolog/tree/3.10.0" }, "funding": [ { @@ -791,137 +803,102 @@ "type": "tidelift" } ], - "time": "2025-03-24T10:02:05+00:00" + "time": "2026-01-02T08:56:05+00:00" }, { - "name": "paragonie/constant_time_encoding", - "version": "v3.0.0", + "name": "phpmailer/phpmailer", + "version": "v7.1.1", "source": { "type": "git", - "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "df1e7fde177501eee2037dd159cf04f5f301a512" + "url": "https://github.com/PHPMailer/PHPMailer.git", + "reference": "1bc1716a507a65e039d4ac9d9adebbbd0d346e15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/df1e7fde177501eee2037dd159cf04f5f301a512", - "reference": "df1e7fde177501eee2037dd159cf04f5f301a512", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/1bc1716a507a65e039d4ac9d9adebbbd0d346e15", + "reference": "1bc1716a507a65e039d4ac9d9adebbbd0d346e15", "shasum": "" }, "require": { - "php": "^8" + "ext-ctype": "*", + "ext-filter": "*", + "ext-hash": "*", + "php": ">=5.5.0" }, "require-dev": { - "phpunit/phpunit": "^9", - "vimeo/psalm": "^4|^5" + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "doctrine/annotations": "^1.2.6 || ^1.13.3", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "squizlabs/php_codesniffer": "^3.13.5", + "yoast/phpunit-polyfills": "^1.0.4" + }, + "suggest": { + "decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication", + "directorytree/imapengine": "For uploading sent messages via IMAP, see gmail example", + "ext-imap": "Needed to support advanced email address parsing according to RFC822", + "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "ext-openssl": "Needed for secure SMTP sending and DKIM signing", + "greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication", + "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", + "league/oauth2-google": "Needed for Google XOAUTH2 authentication", + "psr/log": "For optional PSR-3 debug logging", + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", + "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, "type": "library", "autoload": { "psr-4": { - "ParagonIE\\ConstantTime\\": "src/" + "PHPMailer\\PHPMailer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "LGPL-2.1-only" ], "authors": [ { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com", - "role": "Maintainer" + "name": "Marcus Bointon", + "email": "phpmailer@synchromedia.co.uk" + }, + { + "name": "Jim Jagielski", + "email": "jimjag@gmail.com" }, { - "name": "Steve 'Sc00bz' Thomas", - "email": "steve@tobtu.com", - "homepage": "https://www.tobtu.com", - "role": "Original Developer" + "name": "Andy Prevost", + "email": "codeworxtech@users.sourceforge.net" + }, + { + "name": "Brent R. Matzelle" } ], - "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", - "keywords": [ - "base16", - "base32", - "base32_decode", - "base32_encode", - "base64", - "base64_decode", - "base64_encode", - "bin2hex", - "encoding", - "hex", - "hex2bin", - "rfc4648" - ], + "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/constant_time_encoding/issues", - "source": "https://github.com/paragonie/constant_time_encoding" - }, - "time": "2024-05-08T12:36:18+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v7.1.1" }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + "funding": [ { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" + "url": "https://github.com/Synchro", + "type": "github" } ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" + "time": "2026-05-18T08:06:14+00:00" }, { "name": "phpoption/phpoption", - "version": "1.9.3", + "version": "1.9.5", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54" + "reference": "75365b91986c2405cf5e1e012c5595cd487a98be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/e3fac8b24f56113f7cb96af14958c0dd16330f54", - "reference": "e3fac8b24f56113f7cb96af14958c0dd16330f54", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/75365b91986c2405cf5e1e012c5595cd487a98be", + "reference": "75365b91986c2405cf5e1e012c5595cd487a98be", "shasum": "" }, "require": { @@ -929,7 +906,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.39 || ^9.6.20 || ^10.5.28" + "phpunit/phpunit": "^8.5.44 || ^9.6.25 || ^10.5.53 || ^11.5.34" }, "type": "library", "extra": { @@ -971,7 +948,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.3" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.5" }, "funding": [ { @@ -983,117 +960,7 @@ "type": "tidelift" } ], - "time": "2024-07-20T21:41:07+00:00" - }, - { - "name": "phpseclib/phpseclib", - "version": "3.0.43", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "709ec107af3cb2f385b9617be72af8cf62441d02" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/709ec107af3cb2f385b9617be72af8cf62441d02", - "reference": "709ec107af3cb2f385b9617be72af8cf62441d02", - "shasum": "" - }, - "require": { - "paragonie/constant_time_encoding": "^1|^2|^3", - "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": ">=5.6.1" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "suggest": { - "ext-dom": "Install the DOM extension to load XML formatted public keys.", - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "type": "library", - "autoload": { - "files": [ - "phpseclib/bootstrap.php" - ], - "psr-4": { - "phpseclib3\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "support": { - "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.43" - }, - "funding": [ - { - "url": "https://github.com/terrafrost", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpseclib", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", - "type": "tidelift" - } - ], - "time": "2024-12-14T21:12:59+00:00" + "time": "2025-12-27T19:41:33+00:00" }, { "name": "psr/cache", @@ -1400,16 +1267,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.1", + "version": "v3.7.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" + "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d", + "reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d", "shasum": "" }, "require": { @@ -1422,7 +1289,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.7-dev" } }, "autoload": { @@ -1447,7 +1314,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1" }, "funding": [ { @@ -1458,25 +1325,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2026-06-05T06:23:12+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.32.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" + "reference": "141046a8f9477948ff284fa65be2095baafb94f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2", + "reference": "141046a8f9477948ff284fa65be2095baafb94f2", "shasum": "" }, "require": { @@ -1526,7 +1397,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.37.0" }, "funding": [ { @@ -1537,25 +1408,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.32.0", + "version": "v1.38.2", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", + "reference": "d3d318bad5e7a1bfbd026009c8bfb8d8f99ae6b6", "shasum": "" }, "require": { @@ -1607,7 +1482,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.38.2" }, "funding": [ { @@ -1618,25 +1493,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-12-23T08:48:59+00:00" + "time": "2026-05-27T06:59:30+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.32.0", + "version": "v1.37.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", - "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dfb55726c3a76ea3b6459fcfda1ec2d80a682411", + "reference": "dfb55726c3a76ea3b6459fcfda1ec2d80a682411", "shasum": "" }, "require": { @@ -1687,7 +1566,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.37.0" }, "funding": [ { @@ -1698,25 +1577,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-01-02T08:10:11+00:00" + "time": "2026-04-10T16:19:22+00:00" }, { "name": "twig/twig", - "version": "v3.21.1", + "version": "v3.28.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d" + "reference": "597c12ed286fb9d1701a36684ce6e0cbe28ebc8b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/285123877d4dd97dd7c11842ac5fb7e86e60d81d", - "reference": "285123877d4dd97dd7c11842ac5fb7e86e60d81d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/597c12ed286fb9d1701a36684ce6e0cbe28ebc8b", + "reference": "597c12ed286fb9d1701a36684ce6e0cbe28ebc8b", "shasum": "" }, "require": { @@ -1726,7 +1609,8 @@ "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { - "phpstan/phpstan": "^2.0", + "php-cs-fixer/shim": "^3.0@stable", + "phpstan/phpstan": "^2.0@stable", "psr/container": "^1.0|^2.0", "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, @@ -1770,7 +1654,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.21.1" + "source": "https://github.com/twigphp/Twig/tree/v3.28.0" }, "funding": [ { @@ -1782,30 +1666,30 @@ "type": "tidelift" } ], - "time": "2025-05-03T07:21:55+00:00" + "time": "2026-07-03T20:44:34+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v5.6.2", + "version": "v5.6.3", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af" + "reference": "955e7815d677a3eaa7075231212f2110983adecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/24ac4c74f91ee2c193fa1aaa5c249cb0822809af", - "reference": "24ac4c74f91ee2c193fa1aaa5c249cb0822809af", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/955e7815d677a3eaa7075231212f2110983adecc", + "reference": "955e7815d677a3eaa7075231212f2110983adecc", "shasum": "" }, "require": { "ext-pcre": "*", - "graham-campbell/result-type": "^1.1.3", + "graham-campbell/result-type": "^1.1.4", "php": "^7.2.5 || ^8.0", - "phpoption/phpoption": "^1.9.3", - "symfony/polyfill-ctype": "^1.24", - "symfony/polyfill-mbstring": "^1.24", - "symfony/polyfill-php80": "^1.24" + "phpoption/phpoption": "^1.9.5", + "symfony/polyfill-ctype": "^1.26", + "symfony/polyfill-mbstring": "^1.26", + "symfony/polyfill-php80": "^1.26" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", @@ -1854,7 +1738,7 @@ ], "support": { "issues": "https://github.com/vlucas/phpdotenv/issues", - "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.2" + "source": "https://github.com/vlucas/phpdotenv/tree/v5.6.3" }, "funding": [ { @@ -1866,7 +1750,7 @@ "type": "tidelift" } ], - "time": "2025-04-30T23:37:27+00:00" + "time": "2025-12-27T19:49:13+00:00" } ], "packages-dev": [], @@ -1879,5 +1763,5 @@ "php": "^8.0" }, "platform-dev": {}, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/core/bootstrap.php b/core/bootstrap.php index 1ccd15c..53aa610 100755 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -47,6 +47,10 @@ $registry->set('google_auth', new google_auth($registry)); $registry->set('meta', new Meta()); $registry->set('cache', new Cache()); +$registry->set('validator', new Validator($registry)); +$registry->set('flash', new Flash($registry)); +$registry->set('upload', new Upload()); +$registry->set('mail', new Mail($registry)); $registry->set('view', new View($registry)); diff --git a/core/library/flash.php b/core/library/flash.php new file mode 100644 index 0000000..d647169 --- /dev/null +++ b/core/library/flash.php @@ -0,0 +1,61 @@ + redirect -> GET pattern: + * + * $this->flash->set('success', 'Saved!'); + * $this->response->redirect($this->url->link('some/page')); + * + * and after the redirect: + * + * $this->data['success'] = $this->flash->get('success'); + */ +class Flash { + protected $registry; + + public function __construct($registry) { + $this->registry = $registry; + } + + public function set($key, $message) { + $flash = $this->session()->get('_flash') ?: array(); + + $flash[$key] = $message; + + $this->session()->set('_flash', $flash); + } + + public function get($key, $default = '') { + $flash = $this->session()->get('_flash') ?: array(); + + if (!array_key_exists($key, $flash)) { + return $default; + } + + $message = $flash[$key]; + + unset($flash[$key]); + + $this->session()->set('_flash', $flash); + + return $message; + } + + public function has($key) { + $flash = $this->session()->get('_flash') ?: array(); + + return array_key_exists($key, $flash); + } + + public function all() { + $flash = $this->session()->get('_flash') ?: array(); + + $this->session()->set('_flash', array()); + + return $flash; + } + + protected function session() { + return $this->registry->get('session'); + } +} diff --git a/core/library/mail.php b/core/library/mail.php new file mode 100644 index 0000000..87e72b3 --- /dev/null +++ b/core/library/mail.php @@ -0,0 +1,83 @@ +mail->send('user@example.com', 'Subject', '

HTML body

', [ + * 'text' => 'Plain text alternative', + * 'reply_to' => 'support@example.com', + * 'attachments' => ['/path/to/file.pdf'] + * ]); + */ +class Mail { + protected $registry; + + public function __construct($registry) { + $this->registry = $registry; + } + + public function __get($key) { + return $this->registry->get($key); + } + + public function send($to, $subject, $html, $options = array()) { + $mailer = new PHPMailer(true); + + try { + if ($this->env->get('MAIL_HOST')) { + $mailer->isSMTP(); + $mailer->Host = $this->env->get('MAIL_HOST'); + $mailer->Port = (int)$this->env->get('MAIL_PORT', 587); + + if ($this->env->get('MAIL_USER')) { + $mailer->SMTPAuth = true; + $mailer->Username = $this->env->get('MAIL_USER'); + $mailer->Password = $this->env->get('MAIL_PASS', ''); + } + + $encryption = $this->env->get('MAIL_ENCRYPTION', 'tls'); + + if ($encryption == 'ssl') { + $mailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; + } elseif ($encryption == 'tls') { + $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; + } + } + + $mailer->CharSet = PHPMailer::CHARSET_UTF8; + + $from = $this->env->get('MAIL_FROM', 'noreply@' . (defined('DOMAIN') && DOMAIN ? DOMAIN : 'localhost')); + + $mailer->setFrom($from, $this->env->get('MAIL_FROM_NAME', '')); + + foreach ((array)$to as $address) { + $mailer->addAddress($address); + } + + if (!empty($options['reply_to'])) { + $mailer->addReplyTo($options['reply_to']); + } + + foreach ((array)($options['attachments'] ?? array()) as $attachment) { + $mailer->addAttachment($attachment); + } + + $mailer->Subject = $subject; + $mailer->isHTML(true); + $mailer->Body = $html; + $mailer->AltBody = !empty($options['text']) ? $options['text'] : strip_tags($html); + + $mailer->send(); + + return true; + } catch (PHPMailerException $e) { + $this->log->error('Mail error: ' . $e->getMessage()); + + return false; + } + } +} diff --git a/core/library/upload.php b/core/library/upload.php new file mode 100644 index 0000000..b72672f --- /dev/null +++ b/core/library/upload.php @@ -0,0 +1,129 @@ +upload->save($this->request->files['avatar'], [ + * 'dir' => DIR_DATA . 'uploads/', + * 'extensions' => ['jpg', 'jpeg', 'png', 'webp'], + * 'max_size' => 2 * 1024 * 1024 + * ]); + * + * if ($result) { ... $result['path'] ... } else { ... $this->upload->errors() ... } + * + * The stored file always gets a random name; the real MIME type is + * checked with finfo, and script extensions are never allowed. + */ +class Upload { + protected $errors = array(); + + // Never stored, whatever the caller allows + protected $forbidden = array('php', 'php3', 'php4', 'php5', 'php7', 'php8', 'phtml', 'phar', 'pht', 'cgi', 'pl', 'sh', 'asp', 'aspx', 'jsp', 'htaccess'); + + // Known extension => acceptable MIME types + protected $mime_map = array( + 'jpg' => array('image/jpeg'), + 'jpeg' => array('image/jpeg'), + 'png' => array('image/png'), + 'gif' => array('image/gif'), + 'webp' => array('image/webp'), + 'svg' => array('image/svg+xml'), + 'pdf' => array('application/pdf'), + 'txt' => array('text/plain'), + 'csv' => array('text/csv', 'text/plain'), + 'zip' => array('application/zip'), + 'mp3' => array('audio/mpeg'), + 'mp4' => array('video/mp4'), + 'doc' => array('application/msword'), + 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), + 'xls' => array('application/vnd.ms-excel'), + 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'), + ); + + public function save($file, $options = array()) { + $this->errors = array(); + + $dir = isset($options['dir']) ? $options['dir'] : DIR_DATA . 'uploads/'; + $extensions = isset($options['extensions']) ? array_map('strtolower', $options['extensions']) : array('jpg', 'jpeg', 'png', 'gif', 'webp'); + $max_size = isset($options['max_size']) ? (int)$options['max_size'] : 5 * 1024 * 1024; + + if (!is_array($file) || !isset($file['tmp_name'])) { + $this->errors[] = 'No file was uploaded.'; + return false; + } + + if (isset($file['error']) && $file['error'] !== UPLOAD_ERR_OK) { + $this->errors[] = $this->uploadErrorMessage($file['error']); + return false; + } + + if ($file['size'] > $max_size) { + $this->errors[] = 'The file exceeds the maximum allowed size.'; + return false; + } + + $original = basename((string)$file['name']); + $extension = strtolower(pathinfo($original, PATHINFO_EXTENSION)); + + if (!$extension || in_array($extension, $this->forbidden) || !in_array($extension, $extensions)) { + $this->errors[] = 'The file type is not allowed.'; + return false; + } + + // From here on the file itself is touched: make sure it really + // came through an HTTP upload before reading it + if (!is_uploaded_file($file['tmp_name'])) { + $this->errors[] = 'Invalid upload.'; + return false; + } + + $finfo = new finfo(FILEINFO_MIME_TYPE); + $mime = $finfo->file($file['tmp_name']); + + if (isset($this->mime_map[$extension]) && !in_array($mime, $this->mime_map[$extension])) { + $this->errors[] = 'The file content does not match its extension.'; + return false; + } + + if (!is_dir($dir)) { + mkdir($dir, 0755, true); + } + + $name = bin2hex(random_bytes(16)) . '.' . $extension; + $path = rtrim($dir, '/') . '/' . $name; + + if (!move_uploaded_file($file['tmp_name'], $path)) { + $this->errors[] = 'Could not store the uploaded file.'; + return false; + } + + chmod($path, 0644); + + return array( + 'name' => $name, + 'path' => $path, + 'original' => $original, + 'extension' => $extension, + 'mime' => $mime, + 'size' => $file['size'], + ); + } + + public function errors() { + return $this->errors; + } + + protected function uploadErrorMessage($code) { + switch ($code) { + case UPLOAD_ERR_INI_SIZE: + case UPLOAD_ERR_FORM_SIZE: + return 'The file exceeds the maximum allowed size.'; + case UPLOAD_ERR_PARTIAL: + return 'The file was only partially uploaded.'; + case UPLOAD_ERR_NO_FILE: + return 'No file was uploaded.'; + default: + return 'The file could not be uploaded.'; + } + } +} diff --git a/core/library/validator.php b/core/library/validator.php new file mode 100644 index 0000000..2769642 --- /dev/null +++ b/core/library/validator.php @@ -0,0 +1,125 @@ +registry = $registry; + } + + public function __get($key) { + return $this->registry->get($key); + } + + /** + * Validate data against rules. + * + * $this->validator->validate($this->request->post, [ + * 'email' => 'required|email', + * 'password' => 'required|min:8', + * 'confirm' => 'match:password', + * 'age' => 'integer', + * 'role' => 'in:admin,editor,viewer' + * ]); + * + * Returns true when everything passed; otherwise errors() holds + * a message per failed field. + */ + public function validate($data, $rules) { + $this->errors = array(); + + foreach ($rules as $field => $field_rules) { + $value = isset($data[$field]) ? $data[$field] : null; + + foreach (explode('|', $field_rules) as $rule) { + $param = null; + + if (strpos($rule, ':') !== false) { + list($rule, $param) = explode(':', $rule, 2); + } + + // Skip all other rules for optional empty fields + if ($rule != 'required' && ($value === null || $value === '')) { + continue; + } + + if (!$this->check($rule, $value, $param, $data)) { + $this->addError($field, $rule, $param); + + break; // First failed rule per field is enough + } + } + } + + return !$this->errors; + } + + public function errors() { + return $this->errors; + } + + public function error($field) { + return isset($this->errors[$field]) ? $this->errors[$field] : ''; + } + + protected function check($rule, $value, $param, $data) { + switch ($rule) { + case 'required': + return $value !== null && $value !== '' && $value !== array(); + case 'email': + return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; + case 'url': + return filter_var($value, FILTER_VALIDATE_URL) !== false; + case 'numeric': + return is_numeric($value); + case 'integer': + return filter_var($value, FILTER_VALIDATE_INT) !== false; + case 'min': + return mb_strlen((string)$value) >= (int)$param; + case 'max': + return mb_strlen((string)$value) <= (int)$param; + case 'match': + return isset($data[$param]) && $value === $data[$param]; + case 'in': + return in_array((string)$value, explode(',', (string)$param), true); + case 'regex': + return (bool)preg_match($param, (string)$value); + default: + trigger_error('Validator: unknown rule ' . $rule . '!', E_USER_WARNING); + return true; + } + } + + protected function addError($field, $rule, $param) { + // A language key like error_validation_min overrides the default text + $key = 'error_validation_' . $rule; + + $language = $this->registry->get('language'); + + if ($language && $language->get($key) != $key) { + $message = $language->get($key); + } else { + $message = $this->defaultMessage($rule); + } + + $this->errors[$field] = str_replace(array('%field%', '%param%'), array($field, (string)$param), $message); + } + + protected function defaultMessage($rule) { + $messages = array( + 'required' => 'The %field% field is required.', + 'email' => 'The %field% field must be a valid email address.', + 'url' => 'The %field% field must be a valid URL.', + 'numeric' => 'The %field% field must be a number.', + 'integer' => 'The %field% field must be an integer.', + 'min' => 'The %field% field must be at least %param% characters.', + 'max' => 'The %field% field must be at most %param% characters.', + 'match' => 'The %field% field must match the %param% field.', + 'in' => 'The %field% field contains an invalid value.', + 'regex' => 'The %field% field has an invalid format.', + ); + + return isset($messages[$rule]) ? $messages[$rule] : 'The %field% field is invalid.'; + } +}