Журнал изменений
Major refactoring of admin panel modules and core functions to improve type safety, security, and code quality with PHP 8.4 strict types. Admin Module Improvements:
- Refactored lang.php: Modernized language editor with strict typing
- Added type hints for all functions (int, string, array returns)
- Improved navigation with lang_navi() parameter typing
- Better path handling with lang_get_path() helper
- Enhanced bracket notation support in getVar() for arrays
- Refactored users.php: Complete rewrite with modern practices
- Replaced func_get_args() with explicit typed parameters
- Improved user management functions with strict types
- Better security validation and input filtering
- Refactored groups.php: Enhanced group management
- Added strict type declarations throughout
- Improved permission handling logic
- Better error handling and validation
- Refactored fields.php: Custom fields management improvements
- Type-safe field processing
- Enhanced validation and sanitization
- Added changelog.php: New changelog management module
- Git commit history viewer and analyzer
- Export functionality (TXT, Markdown formats)
- Filtering by author, date, files, search
- Pagination and statistics display
- Enhanced database.php: Database management improvements
- Better query optimization tracking
- Improved backup functionality
- Updated admins.php, blocks.php, comments.php, sitemap.php:
- Copyright year updates (2005-2026)
- Minor code quality improvements Core System Enhancements:
- core.php: Modernized core functions
- setArticleNumbers(): Full parameter typing, removed func_get_args()
- Improved category-based pagination with proper type casting
- Better SQL query building with parameter support
- Enhanced fields_in() and fields_out() with new config paths
- security.php: Major security improvements
- Enhanced getVar() with bracket notation support for arrays
- field[0]: Get specific array index
- field[]: Get entire filtered array
- Array filtering with element-level validation
- Improved type validation for num, let, word, name, title, text
- Better URL and boolean filtering
- More secure input handling Configuration Changes:
- Enhanced getVar() with bracket notation support for arrays
- Renamed config_fields.php → fields.php (shorter, cleaner)
- Renamed config_users.php → users.php (consistency)
- Added changelog.php: Changelog module configuration
- Updated config_lang.php: Language settings improvements
- Updated all includes to use new config file names Frontend/JavaScript:
- Updated jquery.slaed.js: Code formatting and optimization
- Better readability and structure
- Maintained backward compatibility Technical Details: Modified files:
- admin/links/links.admin.php: Minor improvements
- admin/modules/admins.php: Copyright update
- admin/modules/blocks.php: Code quality
- admin/modules/comments.php: Type safety
- admin/modules/database.php: +205 lines (new features)
- admin/modules/fields.php: Refactored 216 lines
- admin/modules/groups.php: Refactored 352 lines
- admin/modules/lang.php: Refactored 522 lines (major rewrite)
- admin/modules/sitemap.php: Minor update
- admin/modules/users.php: Refactored 1048 lines (complete rewrite)
- core/core.php: Enhanced 29 lines
- core/security.php: Enhanced 94 lines
- plugins/jquery/jquery.slaed.js: Refactored 366 lines New files:
- admin/modules/changelog.php: New module for Git history
- config/changelog.php: Module configuration Renamed files:
- config/config_fields.php → config/fields.php
- config/config_users.php → config/users.php Impact:
- Better type safety reduces runtime errors
- Improved security through enhanced input validation
- Easier maintenance with cleaner, typed functions
- New changelog module improves development workflow
- Full PHP 8.4 compatibility maintained
- No breaking changes for existing functionality Breaking changes: None (backward compatible)
Extended coding rules with comprehensive Git commit standards:
- Enforce English language for all commit messages
- Define detailed commit structure with multiple sections
- Include example of well-formatted commit message
- Add commit message requirements to AI checklist Guidelines include:
- Brief summary line (50-72 characters)
- Detailed description of changes and reasoning
- Technical details section (files, functions, database)
- Impact analysis (performance, security, breaking changes)
- Mandatory detailed commits (no "fix bug" or "update code") Benefits:
- Improved project history readability
- Better understanding of changes over time
- Easier debugging and rollback procedures
- International team compatibility
- Professional standard alignment Updated files:
- .
- . This ensures all future commits follow professional standards with comprehensive documentation of what, why, where, and impact of changes.
Hauptänderungen:
1. Helper-Funktion zur Code-Deduplizierung
- Neue Funktion lang_get_path() eliminiert doppelte Path-Logik
- Wird in lang_file() und lang_save() verwendet
- Konsistente Path-Konstruktion über beide Funktionen
2. URL-Parameter Modernisierung
- Alte Parameter: mod_dir, lng_wh (enthielten volle Pfade)
- Neue Parameter: mod, typ (nur Modulname/Typ)
- Saubere URLs: ?op=lang_file&mod=faq&typ=admin
- Path-Konstruktion erfolgt intern in den Funktionen
3. Pagination-System (PHP max_input_vars)
- Problem: 562 Konstanten × 6 Sprachen = 3372+ Felder (> 1000 Limit)
- Lösung: Pagination mit max 100 Konstanten pro Seite (~600 Vars)
- Pagination-Navigation mit Seitenlinks
- Partial Update: Nur bearbeitete Konstanten aktualisieren
- Bestehende Konstanten bleiben beim Speichern erhalten
4. Konfigurierbare Pagination
- Neue Einstellung: per_page in lang_conf()
- Speicherung in config/config_lang.php
- Default: 100, Range: 10-500
5. Absolute Pfade mit BASE_DIR
- Problem: Relative Pfade führten zu Working-Directory-Fehlern
- Lösung: BASE_DIR für alle Dateizugriffe
- Konsistente Pfade: BASE_DIR.'/modules', BASE_DIR.'/'.$mod_dir
- Eliminiert opendir() Fehler
6. Quote-Konsistenz (PHP Best Practice)
- Alle String-Literale: "" → ''
- Schnellere Parsing-Performance
- Keine Interpolation bei statischen Strings
7. Regex-Robustheit für Konstanten
- Alt: #define("(.)"\s,\s*"(.*)");#
- Neu: #define("'["']\s*,\s*"'["']);#sU
- Erkennt beide: define("NAME","value") und define('NAME','value')
- Korrekte Zählung: 562 statt 560 Konstanten
8. Konstanten-Ausgabe mit Single Quotes
- Output-Format: define('NAME','value') statt define("NAME","value")
- Proper Escaping: str_replace("'", "'", $value)
- Verhindert Syntax-Errors bei Apostrophen im Text
9. Variable Optimization
- Removed: $out = []; $out[1] = ...; $out[2] = ...;
- Neu: $cnst und $translations mit direkter Initialisierung
- Beschreibende Namen statt numerische Indices
- Bessere Code-Lesbarkeit
10. Dead Code Removal
- Removed: $adm_fl Variable (was never used)
- Cleaner Code without unnötige Variablen
11. Modernisierung lang_main()
- scandir() statt opendir()/readdir()
- Array-Initialisierung: $modbase = [], $who_view = []
- isset() Guards gegen undefined index warnings
- Bessere HTML-String-Formatierung
- Ternärer Operator für cleanen Code
12. Redirect-Verbesserung
- lang_save() redirected zurück zur gleichen Seite
- Erhält Pagination-State: &page=$page
- Bessere UX beim Speichern
Technische Details:
- PHP 8.0+ Kompatibilität
- Null Coalescing Operator: ?? 100
- Array Destructuring: [$mod_dir, $lng_wh] = lang_get_path()
- Type Hints: string $mod, string $typ
- Return Types: array
String literal modernization (PHP Best Practice):
- Template functions:
- Line 91: tpl_warn() → setTemplateWarning() (missed)
- Line 89, 169: String concatenation with single quotes
- String literals "" → '':
- Line 98: $cnst_tmp initialization
- Line 116: Ternary operator defaults
- Line 117: isset() default value
- Line 121: trim() default
- Line 123-127: CSS class names
- Line 163-165: Array literals
- Line 168: PHP closing tag
- Line 170: fopen() mode
- Line 174: referer() URL
- Line 181: end_chmod() path Best Practice:
- Use '' for strings without variable interpolation
- Faster parsing, cleaner code
- Consistent with modern PHP standards
Missed modernizations from previous commit:
- lang_main() templates:
- Line 33: tpl_eval('open') → setTemplateBasic('open')
- Line 66: tpl_eval("close", "") → setTemplateBasic('close')
- lang_file() array syntax:
- Line 86: array() → []
- Line 103: array() → [] All array() and tpl_eval() now modernized consistently.
Applied MODERNISIERUNG_RULES v2.0:
- Modern Array Syntax (Kapitel 11)
- array() → [] (6 occurrences)
- Lines: 13, 14, 78, 79, 127, 151, 163, 164
- Function Return Types (Kapitel 12)
- lang_main(): void
- lang_file(): void
- lang_save(): void
- lang_conf(): void
- lang_info(): void
- Modern Template Functions (Kapitel 16)
- tpl_eval('open') → setTemplateBasic('open')
- tpl_eval('close') → setTemplateBasic('close')
- tpl_warn() → setTemplateWarning() with array parameters Changes:
- All array() syntax replaced with []
- All functions typed with void return type
- Modern template API throughout
- Consistent with MODERNISIERUNG_RULES v2.0
Added 11 new chapters based on admins.php analysis: 11. Modern PHP Array Syntax - array() → [] (PHP 7+ standard) 12. Function Return Types - void, string, int, array, bool - Type safety for all functions 13. getVar() mit 'req' Source - GET/POST flexible parameter handling - Use case: Edit forms with ID from GET 14. PDO Prepared Statements - Parameter-Formatierung - Inline: ≤3 parameters - Multi-line: ≥4 parameters for readability 15. Boolean zu Integer Konvertierung für DB - Checkboxen: bool → TINYINT(1) - Pattern: getVar('bool', 0) ? 1 : 0 16. Template-Funktionen (Modern) - setTemplateWarning() statt tpl_warn() - setTemplateBasic() statt tpl_eval() 17. getAdminTabs() statt navi_gen() - Modern API with [] instead of '' - Shorter parameter list 18. Header Redirects mit dynamischen Query-Parametern - Optional parameters: ($send ?? '') 19. Validation Arrays - $stop[] pattern für Fehlersammlung - Better UX: Show all errors at once 20. Zusammenfassung erweiterte Regeln - ✅ DO: 8 additional patterns - ❌ DON'T: 5 additional anti-patterns 21. Vollständiges Beispiel (admins.php Style) - Complete function with all modern patterns Version: 1.0 → 2.0 Total: 21 chapters, 600+ lines Reference: admins.php as complete example
Modernized all input handling and config save:
- lang_navi()
- func_get_args() → typed parameters
- Added return type: string
- lang_file()
- $_GET['mod_dir'] → getVar('get', 'mod_dir', 'var', '')
- $_GET['adm_fl'] → getVar('get', 'adm_fl', 'bool', false)
- $_GET['lng_wh'] → getVar('get', 'lng_wh', 'var', '')
- lang_save()
- $_POST['mod_dir'] → getVar('post', 'mod_dir', 'var', '')
- $_POST['lwh'] → getVar('post', 'lwh', 'var', '')
- $_POST['lcn'] → getVar('post', 'lcn[]', 'var') (bracket notation)
- $_POST['cnst'] → getVar('post', 'cnst[]', 'var')
- $_POST['lng'] → getVar('post', 'lng', 'var', [])
- lang_conf_save()
- $_POST → getVar() for all inputs
- save_conf() → setConfigFile() (modern API)
- Compact array-based config structure
- Added void return type Benefits:
- Consistent input filtering across module
- Type safety with modern PHP 8 patterns
- Bracket notation for arrays
- Secure config file handling
Created MODERNISIERUNG_RULES.md with complete guidelines for:
- getVar() Array Handling
- FILTER_REQUIRE_ARRAY → getVar('post', 'field[]', 'num')
- Bracket notation patterns
- Compact Config-Save Functions
- Inline getVar() in $cont arrays
- Elvis operator for defaults
- Eliminate intermediate variables
- Remove Redundant Code
- intval() checks when using getVar('num')
- stripslashes() (PHP 8+)
- array_map('intval') after filtered arrays
- Modern PHP Patterns
- Typed function parameters
- setConfigFile() 4th parameter
- Inline processing
- Migration Checklist
- Step-by-step modernization guide
- DO/DON'T rules
- Commit message templates Purpose: Enable consistent modernization across different code instances (work/home environments)
Core improvements:
- core.php: Modernize setArticleNumbers() with typed parameters
- func_get_args() → named parameters with types
- Improved SQL with prepared statements support
- Better category access control logic
- security.php: Fix config path
- config_users.php → users.php (consistent naming)
- config/users.php: Add modern users config file Admin modules:
- database.php: Add new database() overview function
- SHOW TABLE STATUS with detailed metrics
- Exact row counts via COUNT(*)
- Size calculations (Data + Index + Free)
- Support for optimize/repair operations
- groups.php: Code formatting + setConfigFile() fix
- Multi-line if → one-liner (consistency)
- SQL arrays formatted inline
- setConfigFile() now receives $confu parameter