7 languages, 3 pages (What/How/Start), 80-line router, 98KB total.
Features:
- No database, no Composer, no build step — just files on disk
- nginx PHP isolation: only index.php executes
- Bot detection with browser heuristic bypass
- Rate limiting, structured weekly logs, geo-location, Telegram alerts
- Multi-language: Accept-Language auto-detect, nav dropdown
- Article sub-page routing via /start/{slug}
- Apache + Caddy config alternatives documented in Start page
- Sample config — no real keys or secrets
89 lines
3.1 KiB
PHP
89 lines
3.1 KiB
PHP
<?php
|
|
## ./class/config.php — Application Configuration
|
|
## Copy this file to config.php and fill in your values
|
|
|
|
/// DEFAULT TIMEZONE
|
|
date_default_timezone_set('GMT');
|
|
|
|
//== ENVIRONMENT DETECTION
|
|
$host = $_SERVER["HTTP_HOST"] ?? 'localhost';
|
|
$subdomain = '';
|
|
|
|
if (strpos($host, '.') !== false) {
|
|
$parts = explode('.', $host);
|
|
if (count($parts) >= 3) {
|
|
$subdomain = $parts[0];
|
|
}
|
|
}
|
|
|
|
if ($subdomain === 'www' || $subdomain === '') {
|
|
define('ENVIRONMENT', 'production');
|
|
define('DEBUG', false);
|
|
} else {
|
|
define('ENVIRONMENT', 'development');
|
|
define('DEBUG', true);
|
|
}
|
|
|
|
// PHP error reporting
|
|
if (DEBUG) {
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', '1');
|
|
} else {
|
|
error_reporting(0);
|
|
ini_set('display_errors', '0');
|
|
}
|
|
|
|
//== BASICS
|
|
define('__ROOT__', dirname(dirname(__FILE__)));
|
|
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
|
define('__URL__', $scheme . '://' . $host . '/');
|
|
|
|
//== SITE META — customize these for your project
|
|
define('SITE_NAME', 'bare-site');
|
|
define('SITE_DESCRIPTION', 'A zero-dependency PHP micro-framework for static multi-language sites');
|
|
define('SITE_AUTHOR', '');
|
|
define('SITE_KEYWORDS', '');
|
|
|
|
//== API KEYS — optional, leave empty to disable features
|
|
define('GEO_KEY',''); // ipgeolocation.io — for visitor geo-location
|
|
define('TELEGRAM_BOT_TOKEN',''); // Telegram bot token — for visitor notifications
|
|
define('TELEGRAM_CHAT_ID', ''); // Telegram chat ID
|
|
|
|
//== Bot Detection
|
|
define('BLOCK_THRESHOLD', '5');
|
|
define('SUSPICIOUS_THRESHOLD', '3');
|
|
define('ALERT_THRESHOLD', '10');
|
|
|
|
//== SUPPORTED LANGUAGES — add/remove as needed
|
|
$languages = ['en' => 'English', 'de' => 'Deutsch', 'fr' => 'Française', 'it' => 'Italiano', 'nl' => 'Nederlands', 'es' => 'Español', 'pt' => 'Português'];
|
|
define('LANGUAGES', $languages);
|
|
|
|
//== DEFINE GLOBAL SLUGS — map URL paths to page templates
|
|
define('PAGE_00_SLUG','home');
|
|
define('PAGE_01_SLUG','about');
|
|
define('PAGE_02_SLUG','start');
|
|
define('PAGE_03_SLUG','');
|
|
define('PAGE_04_SLUG','');
|
|
define('PAGE_05_SLUG','not-used');
|
|
|
|
//== SECURITY CONSTANTS
|
|
define('BOT_USER_AGENT_PATTERNS', [
|
|
'/bot/i', '/crawl/i', '/spider/i', '/scanner/i', '/monitor/i',
|
|
'/python-requests/i', '/python-urllib/i', '/curl/i', '/wget/i',
|
|
'/zgrab/i', '/httpx/i', '/go-http-client/i', '/java/i',
|
|
'/masscan/i', '/aiohttp/i', '/censysinspect/i', '/amazonbot/i',
|
|
'/dotbot/i', '/360spider/i', '/dnbcrawler/i', '/semrushbot/i',
|
|
'/ahrefsbot/i', '/yandexbot/i', '/facebookexternalhit/i',
|
|
'/facebot/i', '/twitterbot/i', '/bingbot/i', '/duckduckbot/i',
|
|
'/nmap/i', '/nikto/i', '/nessus/i',
|
|
'/(?:libwww-perl|lwp-request)/i', '/screaming frog/i', '/postman/i'
|
|
]);
|
|
|
|
define('BLOCKED_PATHS', [
|
|
'/.env', '/.git', '/wp-admin', '/administrator', '/config',
|
|
'/backup', '/sql', '/database', '/admin', '/cgi-bin',
|
|
'/wp-login.php', '/readme.html', '/license.txt', '/phpinfo.php',
|
|
'/pma', '/phpmyadmin', '/install.php', '/shell.php',
|
|
'/vendor', '/composer.json', '/passwd', '/etc/passwd',
|
|
'/logs', '/velocity.csv'
|
|
]);
|