bare-site/html/lng/en/start.phtml
cclohmar b93de83519 bare-site v1.0 — zero-dependency PHP micro-framework
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
2026-06-25 14:12:46 +00:00

85 lines
4.5 KiB
PHTML

<section class="content-section">
<h2 class="section-title">Get Started</h2>
<div class="section-content">
<h3>⚠️ Step 1: Configure your web server</h3>
<p><strong>This is not optional.</strong> bare-site's entire security model depends on the web server blocking direct access to PHP files. The framework <em>will not work</em> without these rules.</p>
<h4>nginx (recommended)</h4>
<p>Copy <code>nginx/default.conf</code> to your server and update the paths. The three critical rules:</p>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.85rem;line-height:1.5;"># 1. ONLY index.php can execute — all other PHP files are blocked
location = /index.php {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ \.php$ { return 404; } # ← blocks config.php, functions.php, etc.
# 2. Everything routes through index.php
location / { try_files $uri $uri/ /index.php?$query_string; }</pre>
<h4>Apache (.htaccess)</h4>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.85rem;">RewriteEngine On
# Route everything through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
# Block direct access to PHP files except index.php
RewriteCond %{REQUEST_URI} !^/index\.php$
RewriteRule \.php$ - [R=404,L]</pre>
<h4>Caddy</h4>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.85rem;">your-domain.com {
root * /var/www/html
php_fastcgi unix//run/php/php8.4-fpm.sock
file_server
# Block direct PHP access except index.php
@blockedPhp path_regexp /(?!index\.php$).*\.php$
respond @blockedPhp 404
}</pre>
<h3>2. Drop the files on a server</h3>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.9rem;">git clone https://your-repo/bare-site.git /var/www/html/
# or just copy the html/ directory contents</pre>
<h3>3. Edit your config</h3>
<p>Open <code>class/config.php</code> and set:</p>
<ul>
<li><code>SITE_NAME</code> — your site title</li>
<li><code>SITE_DESCRIPTION</code> — meta description</li>
<li>Page slugs (<code>PAGE_00_SLUG</code> through <code>PAGE_05_SLUG</code>)</li>
<li>Supported languages in <code>$languages</code> array</li>
<li>Optional: <code>GEO_KEY</code> for visitor location, <code>TELEGRAM_*</code> for notifications</li>
</ul>
<h3>4. Create your pages</h3>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.9rem;">lng/en/
├── menu.php # navigation labels + error messages
├── home.phtml # your content — raw HTML, no template engine
├── about.phtml # another page
└── start.phtml</pre>
<p>Content files are plain HTML inside a <code>&lt;section&gt;</code>. No template syntax to learn. You can use PHP inline if needed — <code>&lt;?php echo date('Y'); ?&gt;</code>.</p>
<h3>5. Add a language</h3>
<pre style="background:#f5f5f5;padding:1rem;border-radius:6px;font-size:0.9rem;"># 1. Add to config.php:
$languages = ['en' => 'English', 'de' => 'Deutsch'];
# 2. Create the directory and copy files:
mkdir lng/de/ && cp lng/en/* lng/de/
# 3. Translate menu.php + .phtml files
# Done — appears in the nav dropdown automatically.</pre>
<h3>Optional features</h3>
<table style="width:100%;border-collapse:collapse;margin:1rem 0;">
<tr style="border-bottom:1px solid #e2e8f0;"><td style="padding:0.5rem;"><strong>Geo-location</strong></td><td style="padding:0.5rem;">Set <code>GEO_KEY</code> (free at ipgeolocation.io)</td></tr>
<tr style="border-bottom:1px solid #e2e8f0;"><td style="padding:0.5rem;"><strong>Telegram alerts</strong></td><td style="padding:0.5rem;">Set <code>TELEGRAM_BOT_TOKEN</code> + <code>TELEGRAM_CHAT_ID</code></td></tr>
<tr style="border-bottom:1px solid #e2e8f0;"><td style="padding:0.5rem;"><strong>Weekly logs</strong></td><td style="padding:0.5rem;">Auto-rotated: <code>logs/errors_2026-W26.log</code></td></tr>
<tr style="border-bottom:1px solid #e2e8f0;"><td style="padding:0.5rem;"><strong>Article sub-pages</strong></td><td style="padding:0.5rem;">Create <code>lng/en/start/{slug}.phtml</code> → routed at <code>/start/{slug}</code></td></tr>
<tr><td style="padding:0.5rem;"><strong>Multi-language</strong></td><td style="padding:0.5rem;">Auto-detect from <code>Accept-Language</code> header. This demo ships with 7 languages.</td></tr>
</table>
</div>
</section>