Журнал изменений

Журнал изменений

Фильтр и поиск

Всего: 1098 Доступных коммитов | Отфильтровано: 1098 Коммиты | Страница: 88 / 110
20.02.2026
Fix: Harden logging system in security.php
Автор: Eduard Laas | Дата: 12:37 20.02.2026

All 6 log functions unified and hardened: paths moved to LOGS_DIR, extensions renamed from .txt to .log, rotation logic corrected with proper fclose-before-compress pattern, and exception/fatal-error handlers added for complete error coverage.

Core changes:

  1. Log path and extension migration (core/security.php):
  2. config/logs/.txt → LOGS_DIR/.log for all 6 channels

    • log.log, error_site.log, error_sql.log, hack.log, warn.log, error_php.log
  3. Log rotation hardening (core/security.php):
  4. zip_compress() + unlink() → addCompress(dir, src, name, 'auto', true, true)

    • Proper fclose() before compression in all 6 functions
    • fopen() re-check after rotation (fhandle !== false guard)
  5. log_size fallback unified to 10 MB (was 1 MB in log_report)
  6. filesize() comparison unified to >= (was inconsistent > vs >=)
  7. Archive timestamp format unified to Y-m-d_H-i-s
  8. Error handler extensions (core/security.php):
  9. set_exception_handler() added — catches all uncaught exceptions → error_php.log
  10. register_shutdown_function() added — catches E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR
  11. set_error_handler() extended: cases 256 (USER_ERROR), 512 (USER_WARNING), 1024 (USER_NOTICE), 4096 (RECOVERABLE_ERROR), 16384 (USER_DEPRECATED)

  12. Variable shadowing fixed in error_sql_log(): $log parameter renamed to $sql

Benefits:

  • Fatal errors and uncaught exceptions now logged reliably
  • No file corruption from compress-while-open race condition
  • All log channels use consistent paths and size limits
  • Archives carry second-precision timestamps to prevent collisions

Technical notes:

  • LOGS_DIR constant must point to storage/logs/
  • addCompress() with $del=true handles archive and source deletion atomically
  • error_php.log used for both exception handler and shutdown function
Chore: Expand .gitattributes to enforce LF for all text files
Автор: Eduard Laas | Дата: 10:11 20.02.2026

Adds explicit eol=lf rules for all relevant text file types and marks binary assets to prevent line ending conversion.

Core changes:

  1. .gitattributes:
  2. Added global fallback: * text=auto eol=lf
  3. Added eol=lf for html, css, js, json, sql, xml, tpl, md, txt, ini, yaml, .htaccess
  4. Added binary markers for images, fonts, archives, pdf

    • Prevents Git from treating binaries as text and corrupting them

Benefits:

  • Consistent LF line endings across all editors and OS
  • No CRLF creep on Windows checkouts
  • Binary files protected from line ending conversion
Fix: Harden error_reporting_log() in security.php
Автор: Eduard Laas | Дата: 10:04 20.02.2026

Fixes error suppression, inconsistent comparisons and naming in the PHP error log rotation block of error_reporting_log().

Core changes:

  1. error_reporting_log() (core/security.php):
  2. Removed @ from fopen() calls, replaced with explicit !== false checks

    • Follows rule 2.8: never use error suppression operator
  3. Renamed \$path -> \$log for consistency with addErrorFile() in system.php
  4. Moved \$cfg = \$conf['security'] ?? [] inside if (\$error_write) block

    • \$cfg only needed when actually writing; skipped for NOTICE etc.
  5. Extracted \$max = \$cfg['log_size'] ?? 10485760 as named variable
  6. Changed filesize comparison > to >= (consistent with addErrorFile())
  7. Replaced \$ts/\$rot pattern with clean \$safe via pathinfo()

    • Result: error_php_2024-01-01_12-00-00.zip instead of error_php.log.20240101_120000.zip
  8. Updated addCompress() call to use \$bak=true for .bak fallback

Benefits:

  • No error suppression antipattern
  • Consistent variable naming across both log rotation functions
  • Cleaner archive filenames without double extension
  • .bak fallback guaranteed when no compression available

Technical notes:

  • Behavior identical when fopen() succeeds and compression is available
  • \$cfg scoped to write path only: minor efficiency gain on non-write errors
Fix: Harden addCompress(), addErrorFile() and addFile() logic
Автор: Eduard Laas | Дата: 10:03 20.02.2026

Addresses multiple correctness and safety issues in the compression and error-logging pipeline discovered during systematic code review.

Core changes:

  1. addCompress() (core/system.php):
  2. Added bool \$bak = false parameter for .bak fallback on no-compression

    • When \$algo === 'none' and \$bak=true: rename source to name.bak
    • Replaces broken array_intersect_key logic in callers
  3. Replaced temp-file ZIP string path with addFromString()

    • Eliminates temp file creation, write, and cleanup risk
  4. Added unlink() result check in ZIP file and gz/bz2 delete branches

    • Logs _ERR_DELETE on failure instead of silently ignoring
  5. addErrorFile() (core/system.php):
  6. Added static \$running recursion guard

    • Prevents addCompress->addErrorFile->addCompress infinite loop
    • Falls back to error_log() on recursive call
  7. Replaced hardcoded 10485760 with \$conf['security']['log_size']
  8. Replaced broken checkCompress()/array_intersect_key rotation block

    • New: addCompress(..., 'auto', true, true) with .bak fallback
  9. addFile() (core/system.php):
  10. Fixed bool-to-int coercion: return addCompress() ? 0 : 3

    • Previously false coerced to 0, masking compression errors
  11. addBackupDb() (core/system.php):
  12. Return value of addCompress() now checked

    • Returns false on compression failure instead of silently succeeding

Benefits:

  • Eliminates infinite recursion risk in error logging
  • Consistent error codes in addFile() (0=ok, 1=read, 2=write, 3=compress)
  • No temp file leaks in ZIP string compression path
  • .bak fallback guaranteed when no compression extension available

Technical notes:

  • \$bak parameter default false: backward compatible for all existing callers
  • Recursion guard uses static variable: resets correctly after each call
Refactor: Harden checkFileChmod() with ownership and writability checks
Автор: Eduard Laas | Дата: 08:57 20.02.2026

Replaces the unconditional chmod() calls with an ownership-aware guard using posix_geteuid(). This prevents the function from silently failing or changing permissions on files owned by another process, and eliminates string-based octal literals in favor of proper octdec() conversion for reliable permission mode handling.

Core changes:

  1. Permission checker (core/system.php):
  2. Replaced string octal '0'.\$chm with octdec((string)\$chm)

    • Ensures valid integer mode is passed to chmod()
  3. Added posix_geteuid() call with graceful fallback (-1) when unavailable
  4. Added file_put_contents() return value check before proceeding
  5. Added fileowner() comparison against current process UID

    • chmod() on temp probe file only when owned by current process
    • Falls back to is_writable() when posix functions unavailable
  6. Applied same ownership check before chmod() on target directory

    • \$cdir guards chmod(\$dir, \$mode) analogously to probe file guard
  7. Moved unlink() inside the file_put_contents() success branch

    • Prevents unlink() attempt when file creation failed

Benefits:

  • Eliminates silent chmod() failures on foreign-owned files
  • Correct permission integer conversion via octdec()
  • Robust probe-file lifecycle (create, test, cleanup on success only)

Technical notes:

  • posix_geteuid() may not be available on Windows; -1 signals fallback
  • Behavior unchanged when process owns all files and chmod is supported
Fix: Guard nullable config keys in admininfo() and shop module
Автор: Eduard Laas | Дата: 08:57 20.02.2026

Prevents undefined index notices when \$confst or \$confr are not initialized or incomplete. The shop module similarly guards against a missing 'defis' key in \$confso by falling back to \$conf['defis'] and then a safe default. Both fixes align with the project's pattern of defensive config access.

Core changes:

  1. Admin info panel (core/admin.php):
  2. Added \$confst to global variable declaration in admininfo()

    • Was missing, causing potential undefined variable notice
  3. Guarded \$confst['stat'] with is_array() + isset() check

    • Falls back to 0 if key is absent
  4. Guarded \$confr['refer'] with is_array() + isset() check

    • Falls back to 0 if key is absent
  5. Shop module (modules/shop/index.php):
  6. Replaced direct \$confso['defis'] with null-coalescing expression

    • Falls back to \$conf['defis'] then '-' as safe default
    • Applied consistently in shop() and view() functions

Benefits:

  • Eliminates undefined index PHP notices in admin dashboard
  • Safe fallback for missing shop separator config
  • Consistent defensive config access pattern

Technical notes:

  • No functional behavior change when config keys are present
  • Backward compatible with existing config structures
Fix: Add open_basedir-aware /proc access guard in monitor
Автор: Eduard Laas | Дата: 08:57 20.02.2026

Replaces silent error-suppressed @file_get_contents('/proc/...') calls with an explicit is_proc_readable() check that respects open_basedir restrictions. This eliminates suppressed errors and avoids undefined behavior when PHP runs with restricted filesystem access.

Core changes:

  1. Monitor module (admin/modules/monitor.php):
  2. Added is_proc_readable(string \$path): bool helper function

    • Validates path starts with /proc/
    • Checks against open_basedir entries if set
    • Returns is_readable() result only when access is permitted
  3. Replaced @file_get_contents('/proc/meminfo') with guarded call

    • Suppressor removed; function handles restriction transparently
  4. Replaced @file_get_contents('/proc/net/dev') with guarded call
  5. Replaced @file_get_contents('/proc/uptime') with guarded call
  6. Added missing ':' presence check before explode() in meminfo parser

    • Prevents "Undefined offset" warnings on empty/malformed lines

Benefits:

  • Eliminates error suppression antipattern for /proc reads
  • Correct behavior under open_basedir=restricted environments
  • Prevents PHP warnings from malformed /proc/meminfo lines

Technical notes:

  • open_basedir path separator is PATH_SEPARATOR (OS-aware)
  • Fallback: if open_basedir is empty, only is_readable() is checked
Fix: Add is_dir() guard in module file scanner
Автор: Eduard Laas | Дата: 08:56 20.02.2026

Prevents false positives when scandir() returns non-directory entries (e.g. files or symlinks) inside the modules/ directory. Without the is_dir() check, is_file() on a path like modules/file.txt/index.php could cause unexpected behavior or warnings.

Core changes:

  1. Module scanner (admin/modules/lang.php):
  2. Added is_dir() check before is_file() in the modules loop

    • Ensures only real subdirectories are treated as modules
    • Eliminates potential warnings from invalid path constructions
19.02.2026
Chore: Update docs, tooling, and tests for config restructure
Автор: Eduard Laas | Дата: 23:35 19.02.2026

Align documentation, static analysis config, and tests with the renamed config files and the \$afile variable that replaced \$aroute.

Core changes:

  1. CONTRIBUTING.md / UPGRADING.md:
  2. Replace all \$aroute references with \$afile (current variable name)
  3. .gitignore:
  4. Remove /config/lang.php exclusion (lang config is now tracked)
  5. phpstan.neon:
  6. Remove outdated ignore rule for config/config_uploads.php path
  7. templates/index.html:
  8. Update meta-refresh URL: http://www.slaed.net -> https://slaed.net
  9. tests/ConfigValidationTest.php:
  10. Rename camelCase properties/methods to snake_case (\$basePath -> \$base_path)
  11. Update scanConfigFiles -> scanconfig_files; testRequiredConfigFilesExist -> testRequiredconfig_filesExist (PSR-consistent project style)

  12. config/security.php / config/users.php:
  13. Cosmetic alignment of => operators for readability

Benefits:

  • Docs reflect the actual current variable name (\$afile)
  • PHPStan no longer reports false positives for removed paths
  • Tests use consistent naming convention with the rest of the project

Technical notes:

  • No functional changes; docs, config cosmetics, and test naming only
Refactor: Extend config aliases and improve error logging in core
Автор: Eduard Laas | Дата: 23:35 19.02.2026

Add missing global config aliases to security.php bootstrap and overhaul the PHP error log rotation to use addCompress() with the new bak fallback. Update doSitemap() to read config via return value and fix all remaining config_rewrite.php path references.

Core changes:

  1. core/security.php:
  2. Add \$confup (uploads), \$conftp (filetype), \$confla (lang) aliases so modules can rely on these without separate includes

  3. Update comment: 'set once here; include becomes a no-op' -> clearer
  4. error_reporting_log(): switch from global \$confs to \$conf['security']
  5. Log path: config/logs/error.txt -> LOGS_DIR/error_php.log
  6. Use addCompress(... true, true) for log rotation with .bak fallback
  7. Add clearstatcache() before filesize(); re-open handle after rotation
  8. core/system.php:
  9. addCompress(): add bool \$bak = false parameter; when compression unavailable and \$bak is true, rename source to .bak instead of error

  10. doSitemap(): capture return value of include('config/sitemap.php') and extract \$confma from it instead of relying on global pollution

  11. Fix empty mod check: use ($modules_raw === '') guard
  12. Replace 3x include('config/config_rewrite.php') with 'config/rewrite.php'
  13. addErrorFile(): use addCompress(... true, true) — drop inline fallback

Benefits:

  • Eliminates global variable leakage from include() in doSitemap
  • Log rotation is now atomic and compression-aware
  • Modules for uploads/filetype/lang no longer need separate includes

Technical notes:

  • addCompress() signature: (dir, src, name, mode, del, bak) — backward compat
  • .bak fallback only triggers when algo === 'none' (no compressor available)

Всего: 1098 на 110 страницах по 10 на каждой странице

1 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 110
Хотите опробовать SLAED CMS в действии?
Идеи и предложения
Обратная связь
Подтверждение

Поделиться
QR-код