# CodePress CMS **[๐Ÿ‡ณ๐Ÿ‡ฑ Dutch](README.md) | [๐Ÿ‡ฌ๐Ÿ‡ง English](#)** A lightweight, file-based content management system built with PHP (โ‰ฅ8.0). **Version:** 2.6.5 | **License:** AGPL v3 / Commercial ## โœจ Features - ๐Ÿ“ **Multi-format Content** - Markdown, PHP and HTML files - ๐Ÿงญ **Dynamic Navigation** - Automatic menu generation - ๐ŸŒ **Multi-language** - NL/EN/DE support - ๐Ÿ” **Search** - Full-text search - ๐Ÿ“ฑ **Responsive** - Bootstrap 5 themes - ๐Ÿ”’ **Security** - 100/100 pentest score - ๐Ÿ›ก๏ธ **Admin Console** - CodeMirror editor, media management, themes, plugins - ๐Ÿ‘ฅ **User Roles** - Admin, Content Manager, BI Manager, Site Admin - ๐Ÿ“Š **Analytics** - Visitor statistics with GeoIP - ๐Ÿค– **BotGuard** - Bot/AI protection - ๐Ÿ“ˆ **Logging** - Comprehensive logging system - ๐Ÿ”Œ **Plugin System** - Sidebar plugins with own CSS/SCSS, Twig templates ## ๐Ÿš€ Quick Start ```bash # Install dependencies composer install # Start server with router for clean URLs (local only) php -S localhost:8080 cms/router.php ``` **Website:** `http://localhost:8080` **Admin:** `http://localhost:8080/admin` (login: `admin` / `admin`) ## ๐Ÿ“ฆ Installation ### Requirements - **PHP** โ‰ฅ 8.0 with extensions: `json`, `mbstring` - **Composer** (PHP dependency manager) - Web server: **Apache 2.4+** with `mod_rewrite` or **Nginx** with PHP-FPM - Optional: `opcache` (recommended for performance), `git` (for content versioning), `zip` extension (for ZIP backup/restore) ### Step 1 โ€” Code and dependencies ```bash git clone codepress cd codepress composer install ``` ### Step 2 โ€” Configuration ```bash cp config.json.example config.json ``` Edit `config.json` with your site title, language and plugins. On the first visit to `/admin`, `admin/config/admin.json` is created automatically with a random password that is shown on the login screen. Save this password safely and change it immediately after login. ### Step 3a โ€” Apache 2.4+ The webroot is the `public/` directory. Example vhost (`/etc/apache2/sites-available/codepress.conf`): ```apache ServerName example.com DocumentRoot /var/www/codepress/public AllowOverride All Require all granted ErrorLog ${APACHE_LOG_DIR}/codepress_error.log CustomLog ${APACHE_LOG_DIR}/codepress_access.log combined ``` Required Apache modules: ```bash sudo a2enmod rewrite headers sudo systemctl restart apache2 ``` - `mod_rewrite` โ€” for clean URLs (`/nl/page`) and asset-serving - `mod_headers` โ€” for security headers - `AllowOverride All` โ€” so the `.htaccess` in `public/` is applied ### Step 3b โ€” Nginx Example server block (`/etc/nginx/sites-available/codepress`): ```nginx server { listen 80; server_name example.com; root /var/www/codepress/public; index index.php; # Clean URLs: language-prefixed pages location ~ ^/(nl|en|de)(/(.+))?$ { try_files $uri /index.php?lang=$1&page=$2; } # Admin routes location /admin { try_files $uri /admin.php?$args; } # Asset-serving via asset.php (themes/plugins/admin outside webroot) location ~ ^/(themes|plugins)/([^/]+)/assets/(.+)$ { try_files $uri /asset.php; } location ~ ^/admin/assets/(.+)$ { try_files $uri /asset.php; } # PHP via FPM location ~ \.php$ { fastcgi_pass unix:/run/php/php8.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # Security: block access to sensitive directories location ~ ^/(content|cms|admin/src|admin/config|admin/storage|var|vendor)/ { deny all; return 403; } location ~ /\.(git|htaccess) { deny all; } } ``` **Note:** Nginx does not use `.htaccess`. Security headers must be set in the Nginx config: ```nginx add_header X-Content-Type-Options nosniff; add_header X-Frame-Options SAMEORIGIN; add_header X-XSS-Protection "1; mode=block"; add_header Referrer-Policy strict-origin-when-cross-origin; add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';"; ``` ### Step 4 โ€” Directory permissions Make sure the web server has write access to the runtime directories: ```bash chown -R www-data:www-data var/ admin/storage/ content/ chmod -R 755 . ``` ### Step 5 โ€” Test Open the website in your browser. With an empty content directory you'll see a welcome page. The admin console is available at `/admin` (login `admin`/`admin`). ## ๐Ÿ“š Documentation See **[guide/](guide/)** for extensive documentation per role: | Role | Guide | |------|-------| | ๐Ÿ“ Content Editor | [Content Manager](guide/en/content-beheerder.md) | | โš™๏ธ Administrator | [Admin Manager](guide/en/admin-beheerder.md) | | ๐ŸŽจ Theme Developer | [Theme Developer](guide/en/theme-developer.md) | | ๐Ÿ’ป Developer | [CodePress Developer](guide/en/codepress-developer.md) | Each guide has sub-topics in separate folders with sidebar navigation. ## ๐Ÿ‘ฅ User Roles | Role | Permissions | |------|------------| | **Admin** | Full access (everything) | | **Content Manager** | Content management, guide | | **BI Manager** | Statistics, logs, guide | | **Site Admin** | Theme, plugins, statistics, logs, update, guide | ## ๐Ÿ“ Project Structure ``` codepress/ โ”œโ”€โ”€ cms/ # Core CMS engine โ”‚ โ”œโ”€โ”€ core/class/ # CMS classes (CodePressCMS, ThemeManager, etc.) โ”‚ โ”œโ”€โ”€ core/plugin/ # Plugin system (PluginManager, CMSAPI) โ”‚ โ””โ”€โ”€ router.php # PHP dev server router (clean URLs) โ”œโ”€โ”€ language/ # Translation files (nl/, en/, de/ โ€” each with site.php + admin.php) โ”œโ”€โ”€ admin/ # Admin console โ”‚ โ”œโ”€โ”€ config/ # Admin configuration (admin.json) โ”‚ โ”œโ”€โ”€ src/AdminAuth.php # Authentication, roles, permissions โ”‚ โ”œโ”€โ”€ static/ # Static files (404.html) โ”‚ โ”œโ”€โ”€ storage/ # Logs, cache, geoip โ”‚ โ””โ”€โ”€ theme/default/ # Admin theme โ”‚ โ”œโ”€โ”€ assets/ # CSS, JS, fonts, codemirror โ”‚ โ”œโ”€โ”€ views/ # Twig templates (layouts, pages) โ”‚ โ””โ”€โ”€ theme.json # Admin theme configuration โ”œโ”€โ”€ themes/ # Website themes โ”‚ โ”œโ”€โ”€ default/ # Default theme โ”‚ โ”‚ โ”œโ”€โ”€ theme.json # Layout mapping, colors โ”‚ โ”‚ โ”œโ”€โ”€ base.twig # Main layout โ”‚ โ”‚ โ”œโ”€โ”€ *.twig # Layout templates โ”‚ โ”‚ โ”œโ”€โ”€ partials/ # Header, navigation, footer โ”‚ โ”‚ โ””โ”€โ”€ assets/ # SCSS, CSS, JS, img โ”œโ”€โ”€ plugins/ # Plugins โ”‚ โ”œโ”€โ”€ HTMLBlock/ # Example sidebar plugin โ”‚ โ””โ”€โ”€ Navigation/ # Essential navigation plugin (protected) โ”‚ โ”œโ”€โ”€ Navigation.php # Plugin code โ”‚ โ”œโ”€โ”€ plugin.json # Plugin metadata โ”‚ โ”œโ”€โ”€ assets/scss/ # Plugin SCSS source โ”‚ โ””โ”€โ”€ assets/css/ # Plugin CSS โ”œโ”€โ”€ content/ # Website content (.md, .php, .html) โ”œโ”€โ”€ public/ # Web root โ”‚ โ”œโ”€โ”€ index.php # Website entry point โ”‚ โ””โ”€โ”€ admin.php # Admin entry point + routing โ”œโ”€โ”€ guide/ # Documentation (nl/en) โ”‚ โ”œโ”€โ”€ nl/ # Dutch guides โ”‚ โ””โ”€โ”€ en/ # English guides โ”œโ”€โ”€ cli/test/ # Test suites โ”œโ”€โ”€ var/ # Cache (twig) โ”œโ”€โ”€ config.json # Site configuration โ”œโ”€โ”€ composer.json # PHP dependencies โ””โ”€โ”€ version.php # Version information ``` ## โš™๏ธ Configuration ### config.json ```json { "site_title": "CodePress", "active_theme": "default", "default_page": "auto", "language": { "default": "nl", "available": ["nl", "en"] }, "enabled_plugins": ["HTMLBlock", "Navigation"], "features": { "search_enabled": true, "breadcrumbs_enabled": true }, "security": { "block_ai_bots": true, "rate_limit_enabled": true }, "analytics": { "enabled": true }, "logging": { "enabled": true } } ``` ## ๐Ÿ”ง Dependencies - **PHP โ‰ฅ8.0** with extensions: json, mbstring - **Composer** packages: - twig/twig (templating) - scssphp/scssphp (SCSS compilation) - league/commonmark (Markdown with HeadingPermalinks) - maxmind-db/reader (GeoIP) ## ๐Ÿ” Security - โœ… XSS prevention (htmlspecialchars) - โœ… CSRF tokens (admin forms) - โœ… Path traversal prevention (realpath checks) - โœ… Secure cookies (HttpOnly, SameSite) - โœ… Security headers (X-Frame-Options, CSP) - โœ… Bot/AI protection (BotGuard) - โœ… Rate limiting per IP - โœ… Role-based access control (RBAC) ## ๐Ÿ”Œ Plugins ### Plugin structure ``` plugins/MyPlugin/ โ”œโ”€โ”€ MyPlugin.php # Plugin code (name = plugin name) โ”œโ”€โ”€ plugin.json # Plugin metadata โ”œโ”€โ”€ assets/scss/ # Plugin SCSS source โ””โ”€โ”€ assets/css/ # Plugin CSS (after compilation) ``` ### Essential plugins The **Navigation** plugin is an essential plugin and cannot be disabled, edited, or deleted. This plugin automatically generates sidebar navigation for guides and content. ### Plugin CSS Plugin CSS is automatically loaded after theme CSS, so themes can override plugin styling. ## ๐Ÿ“ Content Examples ### Markdown with frontmatter ```markdown --- layout: full_content plugins: HTMLBlock, Navigation --- # Page title Content in Markdown format... ``` ### PHP content ```php getAllPages(); echo "

My Page

"; echo "

Number of pages: " . count($pages) . "

"; ``` ## ๐Ÿงช Testing ```bash # Penetration tests cli/test/pentest/security-test.sh # Accessibility tests (WCAG 2.1 AA) cli/test/accessibility.sh # Functional tests cli/test/functional/*.sh ``` ## ๐Ÿ“ž Support - **Documentation:** [guide/](guide/) - **Issues:** Git repository - **Contact:** commercial@noorlander.info ## ๐Ÿ“„ License **Dual-licensed:** - **AGPL v3** - For open-source projects - **Commercial** - For proprietary use See [LICENSE](LICENSE) for details. --- **CodePress CMS** - Built by E.Noorlander / CodePress Development Team