Commit Graph
20 Commits
Author SHA1 Message Date
Divarion-D 7e5732cdcb chore(psr4): phase 0 — Composer PSR-4 autoloader foundation
Introduce a committed Composer PSR-4 autoloader without changing class
resolution behavior, as the foundation for the incremental PSR-4 migration.

- src/composer.json: PSR-4 (XcVm\ -> ./, M3uParser\, Chrisyue\PhpM3u8\),
  platform php 8.1.33 (deploy runtime), optimize-autoloader/classmap-authoritative
  false (live path resolution, no class-map cache). autoload.files left empty:
  global functions are still loaded by existing require glue; moving them is
  deferred until that glue is removed.
- src/vendor/ + src/composer.lock: committed (deploy path has no Composer);
  generated with 'composer update' from src/. Regenerate with dump-autoload.
- src/bootstrap.php, tests/bootstrap.php: require vendor/autoload.php first,
  then the legacy autoload.php.
- src/autoload.php: drop the igbinary disk cache (enableFileCache/saveCache/
  shutdown handler/root-chown + bottom call); register at the END of the SPL
  queue (prepend=false) so Composer wins for XcVm\* and only still-global
  classes fall through to the in-memory scanner.
- Makefile: add vendor to LB_DIRS so load-balancer archives ship the loader.
- phpstan.dist.neon: exclude src/vendor/* from analysis.
- .gitignore: document that src/vendor/ is intentionally tracked.
- ci.yml: add composer-audit job (no-op until real require deps exist).

Verified: php -l clean; Composer first / XC_Autoloader last in the SPL stack;
tmp/cache/autoload_map no longer written; PHPUnit 292/292; PHPStan no errors.
2026-06-24 19:07:37 +03:00
Divarion-D b9e911e7e8 fix(phpstan): resolve false positives and real bugs (988 → 622)
Systemic fixes (cascade across modules):
- Type `$db` params as \DatabaseHandler in 38 files (was `object`), so
  PHPStan resolves get_row()/query() and stops inferring closed array
  shapes — clears offsetAccess.notFound clusters.
- Database/DatabaseHandler: correct get_row()/clean_row() PHPDoc to
  array<string,mixed>, and query() $buffered param to mixed (it is the
  first positional bind value via func_get_args, not a bool flag).
- constants stub generator: explicit type overrides (HOST/PAGE_NAME →
  string, PHP_ERRORS → bool) to avoid null/mixed false positives.
- phpstan.dist.neon: scanFiles autoload.php/bootstrap.php; ignore
  unactionable FPs (dynamic require paths, proprietary XC_VM ioncube
  class, MaxMind vendor lib, ext-inotify stub gap).

Real bugs fixed:
- streaming/ConnectionLimiter: appended the whole accumulated UUID array
  instead of a single uuid, breaking per-stream temp-file cleanup.
- streaming/TimeshiftClient: dead `|| $x == 3` branch (always redundant).
- streaming/AsyncFileOperations: redundant is_array after === false.
- core/Storage/DropboxClient: @param callback → callable|null.

streaming module is clean (0 errors); infrastructure 39 → 27.
2026-06-23 19:46:33 +03:00
Divarion-D 198b35bdf6 docs(core/Http,bootstrap): add English DocBlocks (19 methods)
ApiClient, CurlClient, StreamContext pipeline ctx, and bootstrap boot
sequences/polyfill. Completes core DocBlock coverage. No behavior change.
2026-06-22 11:21:56 +03:00
Divarion-D b7d4261807 feat(bootstrap): wire domain DI, container health check, and BootContext enum
wireDomainDatabase() called after container population — injects the db
service into all 32 domain classes and 6 module cron classes via their
static setDb() method so no domain code needs global \$db at runtime.

assertContainerHealth() added as a fail-fast guard after populateContainer():
verifies 'events' is always present, 'db' when database is ready, 'redis'
when Redis is ready. Throws RuntimeException listing all missing services.

BootContext enum replaces the CONTEXT_* string constants; bootstrap now uses
BootContext::ADMIN, CLI, STREAM, MINIMAL throughout for type safety.
2026-06-15 18:06:55 +03:00
Divarion-D d243587d08 fix(bootstrap.php): create symlink for legacy 'reseller' assets to 'admin' 2026-06-14 15:21:14 +03:00
Divarion-D 93677ca087 Refactor code structure for improved readability and maintainability 2026-06-14 12:59:28 +03:00
Divarion-D 8f796254ed Refactor configuration handling and database connections
- Removed ConfigLoader.php and transitioned to using ConfigReader for configuration management.
- Updated DatabaseHandler instantiation to no longer rely on global $_INFO, instead using default parameters.
- Enhanced Database and MigrationRunner classes to improve error handling and connection management.
- Simplified RedisManager connection logic by utilizing XC_VM::redis_connect().
- Adjusted various controllers and services to align with the new configuration and database connection methods.
- Removed unnecessary global variables and improved code readability across multiple files.
- Updated comments and documentation to reflect changes in configuration handling and database connections.
2026-06-12 00:54:31 +03:00
Divarion-D 2b499bbd47 refactor(bootstrap): extract StreamingRequestBootstrap and WebApiBootstrap
- StreamingRequestBootstrap: unified entry for streaming endpoints
- WebApiBootstrap: unified entry for web API requests
- index.php: use new bootstrap classes instead of direct requires
- www/init.php, www/stream/init.php: mark as deprecated shims
- StatusCommand: use StreamingRequestBootstrap::init()
- autoload.php, bootstrap.php: register new classes
2026-04-20 20:34:19 +03:00
Divarion-D 788ec37637 refactor: replace DEVELOPMENT flag, fix bootstrap and logging
- Remove DEVELOPMENT constant from AppConfig.php; introduce DB_ACCESS_ENABLED
  (controls phpMiniAdmin access in admin panel only, not core DB connections)
- Detach bootstrap.php from www/constants.php: load core/Config/* and
  core/Logging/Logger directly; define PHP_ERRORS fallback
- Switch Logger::init() to PHP_ERRORS in bootstrap.php, stream/init.php,
  RequestGuard.php; remove leftover TODO comment
- Logger: always set error_reporting(E_ALL); UI visibility controlled
  separately via display_errors; rename $development -> $showErrors
- MigrationRunner: track applied/failed counts separately; failed migrations
  are not marked as applied
- Replace DEVELOPMENT with DB_ACCESS_ENABLED in admin settings.php and
  database.php (phpMiniAdmin gate)
- Replace DEVELOPMENT with PHP_ERRORS in CertbotCronJob
- Docs (en/ru): add DB_ACCESS_ENABLED flag description; update feature-flags,
  updates_checklist, http-request-handling; remove DEVELOPMENT references
- MIGRATION.md: mark L-1 as done, remove from backlog and wave A;
  unblock L-2; renumber steps
2026-04-19 18:13:56 +03:00
Divarion-D 6cc892f9a7 refactor: eliminate proxy functions, migrate to direct class method calls
312 files changed, 2866 insertions(+), 24110 deletions(-)

Proxy function replacements (130+ functions):
- goHome() -> AdminHelpers::goHome()
- checkPermissions() -> PageAuthorization::checkPermissions()
- getBouquet/getCategory/etc -> Service::getById()
- deleteStream/deleteLine/etc -> Repository/Service::delete()
- APIRequest/systemapirequest -> ApiClient::request/systemRequest()
- prepareArray/preparecolumn -> QueryHelper methods
- confirmIDs/parserelease/etc -> AdminHelpers methods
- getSettings/clearSettingsCache -> SettingsManager methods
- destroySession -> SessionManager::clearContext()
- getMag/getEnigma/deleteMAG/etc -> MagService/EnigmaService
- getSeriesTrailer/getMovieTMDB/etc -> TMDbService methods

Removed legacy files:
- src/includes/admin.php (main proxy hub)
- src/includes/libs/ (35+ files moved to core/modules)
- src/includes/python/ (moved to bin/python)
- src/includes/api/ (moved to Controllers)
- src/includes/ts.php, reseller_api.php
- src/infrastructure/legacy/admin_proxies.php
- tools/run_scan.sh, update_redis_conf.sh

Additional fixes:
- SQL query placeholder migration (BouquetService, CategoryService)
- PHP 8.x null-safe access (live.php, server_view.php, stream.php)
- TmdbCron: extracted variable for repeated similar_text calls
2026-04-09 21:24:48 +03:00
Divarion-D 59bfb6f942 Add EventDispatcher integration to bootstrap and module loader
- Updated the XC_Bootstrap class to include the EventDispatcher class in the service container.
- Modified the ModuleLoader class to utilize the EventDispatcher for subscribing to events, enhancing the event handling mechanism.
2026-04-07 21:48:20 +03:00
Divarion-D 738973c5db docs(php): add standardized file headers across codebase
- Add @author, @copyright, @link, @version, @license to 399 PHP files
- MERGE mode: inject metadata into 243 existing docblocks (preserving docs)
- INSERT mode: create new docblocks for 156 files without headers
- Skip 3 files that already had correct headers
- Exclude third-party libs (TMDb, mobiledetect, Dropbox, etc.)
- Exclude bin/, ministra/, content/, tmp/, resources/, module views
- Update tools/add_headers.php to v2 with MERGE strategy
2026-04-05 22:38:36 +03:00
Divarion-D d2c439df81 chore: remove stalker dead code, translate bootstrap comments to English 2026-03-20 16:10:47 +03:00
Divarion-D 3c876d4551 fix(bootstrap): add missing defineStatusConstants() call in CONTEXT_ADMIN
During bootstrap layer migration, `defineStatusConstants()` was moved to `XC_Bootstrap` but its invocation was not added to `boot()`. This left `STATUS_SUCCESS`, `STATUS_FAILURE` and other status constants undefined, causing a fatal error on admin login.

Added `self::defineStatusConstants()` to the `CONTEXT_ADMIN` branch before `initAdminGlobals()`.
2026-03-18 22:04:02 +03:00
Divarion-D 2dd8d3bd1e refactor: absorb includes/bootstrap/ into XC_Bootstrap
Merge the three legacy bootstrap files into XC_Bootstrap::boot(CONTEXT_ADMIN):

- admin_session.php → already covered by XC_Bootstrap::initSession()
- admin_runtime.php (status constants) → already covered by defineStatusConstants()
- admin_runtime.php (globals) → new initAdminGlobals() method
- admin_bootstrap.php (orchestrator) → eliminated, admin.php calls XC_Bootstrap directly

New private methods in XC_Bootstrap:
- initAdminGlobals(): MobileDetect, timeouts, servers, protocol, translator, admin_constants
- detectProtocol(): inlined issecure()+getProtocol() logic

Updated:
- includes/admin.php: require bootstrap.php + XC_Bootstrap::boot() instead of bridge
- Makefile: remove includes/bootstrap from LB_DIRS_TO_REMOVE
- ARCHITECTURE.md: remove bootstrap/ from tree and LB example
- docs/{en,ru}/builds/build_system.md: remove row from LB tables
- Comments in admin_functions_fc.php, functions.php

Deleted:
- includes/bootstrap/admin_bootstrap.php
- includes/bootstrap/admin_runtime.php
- includes/bootstrap/admin_session.php
2026-03-18 21:34:00 +03:00
Divarion-D d75080ddc5 refactor: move langs/ from includes/ to resources/
Migrate 7 locale .ini files (bg, de, en, es, fr, pt, ru) from
src/includes/langs/ to src/resources/langs/ per ARCHITECTURE.md
migration map.

Updated references:
- bootstrap.php: Translator::init() path
- includes/bootstrap/admin_runtime.php: Translator::init() path
- Makefile: removed includes/langs from LB_DIRS_TO_REMOVE
- ARCHITECTURE.md: marked migration as done, updated LB example
- docs/en/builds/build_system.md: updated excluded dirs table
- docs/ru/builds/build_system.md: updated excluded dirs table

Removed empty src/includes/langs/ directory.
2026-03-18 21:10:08 +03:00
Divarion-D 3d8abedafd Stage 8 has been completed 2026-03-07 21:53:45 +03:00
Divarion-D 80a25d3140 Complete stage 8.1 and 8.2 2026-03-03 20:00:34 +03:00
Divarion-D e2c9cb97ce Stage 7 has been completed 2026-02-27 22:32:39 +03:00
Divarion-D c54d322a89 Refactor database interactions and logging mechanisms across streaming and playlist modules
- Replaced instances of `Database` with `DatabaseHandler` in `playlist.php` and `xplugin.php` for improved database handling.
- Updated logging calls from `StreamingUtilities::clientLog` to `DatabaseLogger::clientLog` in various stream handling files (`auth.php`, `live.php`, `vod.php`, `timeshift.php`, `rtmp.php`) to centralize logging functionality.
- Refactored bruteforce checking methods to utilize `BruteforceGuard` instead of `CoreUtilities` for consistency and better encapsulation.
- Enhanced error handling by ensuring all relevant error logs are captured through the new logging structure.
2026-02-20 19:56:08 +03:00