# Concerns & Technical Debt — rank24.pl ## Security — CRITICAL ### Hardcoded Credentials (must fix before any public exposure) | Secret | Location | Risk | |--------|---------|------| | MySQL password | `config.php` lines 2-5 | Full DB access if repo leaked | | FTP password | `.vscode/ftp-kr.json`, `.vscode/sftp.json` | Full server access | | DataForSEO API key | `autoload/class.Cron.php` ~lines 160, 262, 354 | API abuse / billing fraud | | SMTP password | `autoload/class.S.php` ~lines 293-300 | Email spoofing | **Remediation**: move all secrets to environment variables or a `.env` file excluded from VCS. ### SQL Injection - `autoload/class.Cron.php` ~line 200: raw string concatenation in DELETE query - `autoload/class.GoogleRank.php` lines 74, 96, 100, 136, 158, 162: raw string concat in UPDATE queries - `autoload/class.DataBase.php` lines 15, 47, 82: mixed OPD with string building **Remediation**: use Medoo's parameterized methods or PDO `bindValue()` for all dynamic values. ### Other Security Issues (MEDIUM) - **Weak password hashing**: `md5($pass1)` in `autoload/class.DataBase.php` line 31 — use `password_hash()` - **No CSRF protection**: state-changing AJAX operations in `ajax.php` lack CSRF tokens - **Path traversal**: `autoload/class.DataBase.php` ~line 57 — user-supplied `image_folder` concatenated into file path without validation - **Client-supplied MIME type**: file type validation in `class.DataBase.php` checks `$file['type']` (attacker-controlled) - **Insecure deserialization**: `@unserialize()` used in `autoload/class.FileCache.php` line 43 and `autoload/opd.statement.php` - **XSS**: `\S::get()` reads raw `$_POST`/`$_GET` without sanitization; values reach HTML output in multiple templates ## Technical Debt ### God Classes - `autoload/class.S.php` — 700+ lines; handles sessions, email, DNS, CSV, URL, string utils, DB helpers. Should be split. - `autoload/class.GoogleRank.php` — 300+ lines; proxy selection logic repeated 4+ times with no extraction. - `autoload/class.Cron.php` — 400+ lines; hardcoded credentials, multiple large functions. ### Code Duplication - Proxy selection + backoff UPDATE query repeated verbatim ~4 times in `class.GoogleRank.php` - Google block-detection strings (`"Our systems have detected unusual traffic"`) duplicated in multiple methods ### Global State Anti-Pattern Every class does `global $db, $mdb, $user, $config, $cache;` — no DI, no service container. Makes refactoring and testing very difficult. ### Two ORM Layers Both `$db` (OPD) and `$mdb` (Medoo) are initialized and used. Older code paths use OPD raw queries; newer paths use Medoo. Inconsistent access patterns throughout. ### Deprecated PHP Patterns - Old-style constructor: `function DataEdit()` in `autoload/class.DataEdit.php` line 32 (should be `__construct()`) - `global` variable injection instead of constructor parameters - Short open tags `