173 lines
5 KiB
Markdown
173 lines
5 KiB
Markdown
|
|
# 🧠 Software-Blogs — A Lightweight, Transparent PHP Blog System
|
|||
|
|
|
|||
|
|
**Software-Blogs** is a minimal, self-hosted PHP blog framework designed for technical writers and developers who value simplicity, transparency, and total control over their stack.
|
|||
|
|
|
|||
|
|
Each post is its own self-contained directory with its own SQLite comment database, while shared logic like the comment system lives in modular PHP files that are dynamically included at runtime.
|
|||
|
|
|
|||
|
|
This setup embraces the UNIX-style philosophy:
|
|||
|
|
|
|||
|
|
> “Do one thing well. Then link it dynamically.”
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🚀 Features
|
|||
|
|
|
|||
|
|
* **Per-post isolation:** each post directory has its own `index.php` and `comments.db`.
|
|||
|
|
* **Modular comment system:** all comment logic is centralized in `/modules/comments.php`.
|
|||
|
|
* **Zero external dependencies:** uses built-in PHP + SQLite only.
|
|||
|
|
* **LAN-aware admin system:** restricts comment deletion to your local or ISP IP range.
|
|||
|
|
* **Clean mentalnet.xyz-style dark theme ready for embedding.**
|
|||
|
|
* **Perfect for personal dev blogs, technical essays, or transparent documentation.**
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🧩 Directory Structure
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
software-blogs/
|
|||
|
|
├── modules/
|
|||
|
|
│ ├── comments.php # Shared comment system
|
|||
|
|
├── opensource-future/
|
|||
|
|
│ ├── index.php
|
|||
|
|
│ └── comments.db
|
|||
|
|
├── dephell/
|
|||
|
|
│ ├── index.php
|
|||
|
|
│ └── comments.db
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Each post is completely portable — move its folder anywhere and it will still work.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ⚙️ How It Works
|
|||
|
|
|
|||
|
|
When you load a post, the page dynamically imports the core module:
|
|||
|
|
|
|||
|
|
```php
|
|||
|
|
<?php require_once __DIR__ . '/../modules/comments.php'; ?>
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
That module:
|
|||
|
|
|
|||
|
|
1. Initializes or creates a `comments.db` SQLite database in the same directory.
|
|||
|
|
2. Handles POST requests for new comments and admin deletions.
|
|||
|
|
3. Exposes variables like `$comments`, `$error`, and `$is_admin` to the main page.
|
|||
|
|
4. Is not usable standalone — it’s meant to be dynamically linked, not directly served.
|
|||
|
|
|
|||
|
|
Think of it like dynamic linking in compiled languages:
|
|||
|
|
|
|||
|
|
* `index.php` is the binary.
|
|||
|
|
* `modules/comments.php` is your shared library.
|
|||
|
|
* PHP’s `require_once()` is your runtime linker.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 💬 Comment System Overview
|
|||
|
|
|
|||
|
|
Each post maintains its own `comments.db` schema:
|
|||
|
|
|
|||
|
|
```sql
|
|||
|
|
CREATE TABLE IF NOT EXISTS comments (
|
|||
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|||
|
|
name TEXT NOT NULL,
|
|||
|
|
comment TEXT NOT NULL,
|
|||
|
|
ip TEXT NOT NULL,
|
|||
|
|
date TEXT NOT NULL
|
|||
|
|
);
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Key details:
|
|||
|
|
|
|||
|
|
* Max comment length: **250 characters** (configurable).
|
|||
|
|
* One comment per IP or name — prevents spam flood.
|
|||
|
|
* Admin access is determined by IP pattern (`192.168.86.*` by default).
|
|||
|
|
* Comments are stored locally; no external services or trackers.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🛠️ Setup
|
|||
|
|
|
|||
|
|
1. Clone or copy this repo into your web root:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
git clone https://github.com/youruser/software-blogs.git /var/www/html/blog
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
2. Ensure PHP has SQLite enabled:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
php -m | grep sqlite
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
3. Make post directories writable for SQLite and make sure they are owned by the correct webuser running your server:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
chmod 755 -R /var/www/html/blog
|
|||
|
|
chown -R www-data:www-data /var/www/html/blog
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
4. Visit your post at `http://your-ip/blog/dephell/`.
|
|||
|
|
|
|||
|
|
You’ll see your article, comments section, and dynamic SQLite comments instantly.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🌐 Hosting Context
|
|||
|
|
|
|||
|
|
This project assumes you’re running it:
|
|||
|
|
|
|||
|
|
* On your **ISP-assigned public IP** (e.g. a home server or self-hosted VPS), or
|
|||
|
|
* Within a **LAN environment** accessible via IP (e.g. 192.168.x.x).
|
|||
|
|
|
|||
|
|
The admin check uses simple IP prefix matching for maintainability — intentionally lightweight and transparent.
|
|||
|
|
If you host publicly, **change the IPs in `modules/comments.php`** to your static or dynamic DNS IP range.
|
|||
|
|
|
|||
|
|
This design trades enterprise-grade auth for simplicity and control — a deliberate choice for personal or small-scale tech blogs.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🧱 Adding a New Blog Post
|
|||
|
|
|
|||
|
|
1. Copy an existing post folder:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cp -r dephell new_article
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
2. Edit `new_article/index.php` and replace the content section.
|
|||
|
|
|
|||
|
|
3. Access it via `http://your-ip/blog/new_article/`.
|
|||
|
|
|
|||
|
|
A new `comments.db` will be generated automatically when someone comments.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 🔒 Security Note
|
|||
|
|
|
|||
|
|
This system is designed for **simplicity and transparency**, not for multi-user or high-traffic production setups.
|
|||
|
|
|
|||
|
|
If you expose it to the public internet:
|
|||
|
|
|
|||
|
|
* Always restrict admin deletion to your IP.
|
|||
|
|
* Keep directory permissions strict.
|
|||
|
|
* Consider placing `/modules/` outside your web root or use `.htaccess` to block direct access.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📜 License
|
|||
|
|
|
|||
|
|
MIT License — open and educational.
|
|||
|
|
Feel free to fork, remix, and host your own “transparent blog” setup.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🧠 Philosophy
|
|||
|
|
|
|||
|
|
Software-Blogs isn’t about convenience — it’s about *understanding*.
|
|||
|
|
Each post is a living, self-contained artifact.
|
|||
|
|
You can open it, read it, and **see how it works**.
|
|||
|
|
|
|||
|
|
If you’re tired of opaque CMS systems and bloated blogging platforms, this setup gives you something more honest — a blog where you can see every moving part, line by line.
|
|||
|
|
|
|||
|
|
> “Abstractions rot. Understanding scales.”
|