Initial Commit

This commit is contained in:
mrkmntal 2025-10-31 19:43:56 -04:00
commit 5e95975af4
8 changed files with 578 additions and 0 deletions

173
README.md Normal file
View file

@ -0,0 +1,173 @@
# 🧠 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 — its 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.
* PHPs `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/`.
Youll see your article, comments section, and dynamic SQLite comments instantly.
---
## 🌐 Hosting Context
This project assumes youre 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 isnt about convenience — its about *understanding*.
Each post is a living, self-contained artifact.
You can open it, read it, and **see how it works**.
If youre 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.”

BIN
dephell/bringitonapt.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
dephell/comments.db Normal file

Binary file not shown.

157
dephell/index.php Normal file
View file

@ -0,0 +1,157 @@
<?php require_once __DIR__ . '/../modules/comments.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MentalNet.xyz Blog | Dependency Hell and the Mirror Test</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=UnifrakturCook:wght@700&amp;family=Press+Start+2P&amp;family=Roboto:wght@300;400;700&amp;display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-image: radial-gradient(ellipse at top, #0a141f 0%, #000000 75%);
background-size: cover;
color: #e0e0e0;
max-width: 800px;
margin: 0 auto;
padding: 2em;
line-height: 1.6;
}
a { color: #5ec4ff; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 {
font-family: "UnifrakturCook";
color: white;
text-shadow: 0 0 12px rgba(255,100,0,0.8), 0 0 30px rgba(255,120,0,0.5);
margin-bottom: 10px;
text-transform: uppercase;
}
blockquote {
border-left: 3px solid #444;
padding-left: 1em;
color: #aaa;
font-style: italic;
}
section { margin-bottom: 3em; }
form {
margin-top: 2em;
background: #111;
padding: 1em;
border-radius: 10px;
}
input, textarea {
width: 100%;
background: #1b1b1b;
color: #fff;
border: 1px solid #333;
padding: .5em;
margin-bottom: .5em;
border-radius: 5px;
}
button {
background: #c74100;
color: #fff;
border: none;
padding: .6em 1.2em;
border-radius: 5px;
cursor: pointer;
}
button:hover { opacity: 0.8; }
.comment {
background: #151515;
border: 1px solid #222;
padding: 1em;
border-radius: 8px;
margin-top: 1em;
}
.comment small { color: #888; }
.error {
background: #3a0a0a;
color: #ff7b7b;
padding: .5em 1em;
border-radius: 8px;
margin-bottom: 1em;
}
.delete-btn {
background: #333;
color: #ff6666;
border: none;
padding: 0.3em 0.6em;
border-radius: 4px;
font-size: 0.8em;
cursor: pointer;
float: right;
}
.delete-btn:hover { background: #600; }
.honeypot { display: none; }
</style>
</head>
<body>
<h1 style="text-align:center;">Dependency Hell and the Mirror Test</h1>
<div style="text-align:center;">
<img src="bringitonapt.jpg" alt="Debian Osaka Bring It On APT" width="280px"/>
</div>
<p style="text-align:center;"><i>Published October 31 2025 on MentalNet.xyz</i></p>
<section>
<p>Every developer dreams of clean installs, smooth dependency trees, and stable builds until one day, <code>apt</code> decides to summon the flames of dependency hell. Thats when you realize the real bug isnt in the system its in your assumptions.</p>
<p>This is the story of a looping dpkg install and the realization that sometimes the only way out of dependency hell is to look in the mirror and ask, “What did I make, and how did I mess up?</p>
</section>
<h2>The Fire Starts Small</h2>
<p>It began with a metapackage called <strong>live-update</strong>, meant to pull in the latest components of my system. It depended on small helper packages things like <strong>mysql-binlog-cfg</strong> and <strong>proxyconfig</strong> which only ran setup scripts. They didnt install any files.</p>
<p>dpkg saw that and said, “Well, you installed nothing, so you dont exist. Then apt tried to reinstall them, forever. A perfect feedback loop of install vanish reinstall vanish. It wasnt broken it was just doing exactly what I told it to do.</p>
<h2>The Mirror Test</h2>
<p>The moment of truth comes when you stop blaming <code>apt</code> and start realizing <strong>you built the dependency furnace yourself</strong>. The fix was surprisingly humble: drop a tiny marker file like <code>/usr/share/mysql-binlog-cfg/marker.txt</code>. Suddenly, dpkg has something real to hold onto.</p>
<p>But it also made me think about how easily we build fragile systems just because we dont fully understand whats under the hood. We stack abstractions until we forget what were orchestrating.</p>
<h2>Facing the Flames</h2>
<p>Modern development culture tries to avoid these lessons. Everything gets containerized, abstracted, and outsourced to layers that promise safety. But abstraction without understanding is just dependency hell waiting for a trigger.</p>
<p>When you face problems like this, you learn more than you ever could hiding behind a container runtime. You start designing systems that <em>leverage</em> their foundation instead of avoiding it. Thats what makes an ecosystem strong not escaping the heat, but learning to harness it.</p>
<h2>Bring It On, APT</h2>
<p>So yeah Ill take dependency hell any day over blind abstraction. Because when you finally stare into the dpkg logs and see whats actually happening, you gain something most engineers never do: understanding. Real control. And a bit of pride in the flames you tamed.</p>
<p style="text-align:center; font-weight:bold; color:#ff914d;">Bring it on, APT.</p>
<hr>
<h2>Comments</h2>
<?php if ($error): ?>
<div class="error"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="POST">
<label>Name:</label>
<input type="text" name="name" required>
<label>Comment:</label>
<textarea name="comment" rows="4" maxlength="250" required></textarea>
<div class="honeypot">
<label>Website:</label>
<input type="text" name="website" value="">
</div>
<button type="submit">Post Comment</button>
</form>
<?php foreach ($comments as $c): ?>
<div class="comment">
<strong><?=htmlspecialchars($c['name'])?></strong>
<small> <?=htmlspecialchars($c['date'])?></small>
<?php if ($is_admin): ?>
<a class="delete-btn" href="?delete=<?=$c['id']?>" onclick="return confirm('Delete this comment?');">Delete</a>
<?php endif; ?>
<p><?=nl2br(htmlspecialchars($c['comment']))?></p>
</div>
<?php endforeach; ?>
</body>
</html>

BIN
modules/comments.db Normal file

Binary file not shown.

61
modules/comments.php Normal file
View file

@ -0,0 +1,61 @@
<?php
// modules/comments.php
// Shared MentalNet comment system module
// Configuration defaults
$COMMENT_DB_PATH = __DIR__ . '/../' . basename(getcwd()) . '/comments.db';
$COMMENT_MAX_LENGTH = 250;
$ADMIN_IP_PREFIXES = ['192.168.86.1', '192.168.86.']; // adjust as needed
// Initialize database
$db = new PDO('sqlite:' . $COMMENT_DB_PATH);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("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
)");
$error = '';
$ip = $_SERVER['REMOTE_ADDR'];
$is_admin = false;
foreach ($ADMIN_IP_PREFIXES as $prefix) {
if (str_starts_with($ip, $prefix)) { $is_admin = true; break; }
}
// Handle deletions
if (isset($_GET['delete']) && $is_admin) {
$del_id = intval($_GET['delete']);
$stmt = $db->prepare("DELETE FROM comments WHERE id = ?");
$stmt->execute([$del_id]);
header("Location: " . strtok($_SERVER["REQUEST_URI"], '?'));
exit;
}
// Handle new comments
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = trim($_POST['name']);
$comment = trim($_POST['comment']);
if (strlen($comment) > $COMMENT_MAX_LENGTH) {
$error = "Whoa there, sysadmin — keep it under $COMMENT_MAX_LENGTH characters!";
} elseif ($name && $comment) {
$check = $db->prepare("SELECT COUNT(*) FROM comments WHERE ip = ? OR name = ?");
$check->execute([$ip, $name]);
if ($check->fetchColumn() > 0) {
$error = "One post per person — let other engineers join the thread.";
} else {
$stmt = $db->prepare("INSERT INTO comments (name, comment, ip, date) VALUES (?, ?, ?, datetime('now','localtime'))");
$stmt->execute([$name, $comment, $ip]);
header("Location: " . $_SERVER['REQUEST_URI']);
exit;
}
}
}
// Fetch existing comments
$comments = $db->query("SELECT * FROM comments ORDER BY id DESC")->fetchAll(PDO::FETCH_ASSOC);
?>

Binary file not shown.

187
opensource-future/index.php Normal file
View file

@ -0,0 +1,187 @@
<?php require_once __DIR__ . '/../modules/comments.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MentalNet.xyz Blog | When Freedom Lives in the Shadows</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=UnifrakturCook:wght@700&amp;family=Press+Start+2P&amp;family=Roboto:wght@300;400;700&amp;display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: 'Roboto', sans-serif;
background-image: radial-gradient(ellipse at top, #0a141f 0%, #000000 75%);
background-size: cover;
color: #e0e0e0;
max-width: 800px;
margin: 0 auto;
padding: 2em;
line-height: 1.6;
}
a { color: #5ec4ff; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 {
font-family: "UnifrakturCook";
font-size: 2.5rem;
color: white;
text-shadow: 0 0 12px rgba(0,200,255,0.8), 0 0 30px rgba(0,200,255,0.5);
margin-bottom: 10px;
text-transform: uppercase;
}
blockquote {
border-left: 3px solid #444;
padding-left: 1em;
color: #aaa;
font-style: italic;
}
section {
margin-bottom: 3em;
}
form {
margin-top: 2em;
background: #111;
padding: 1em;
border-radius: 10px;
}
input, textarea {
width: 100%;
background: #1b1b1b;
color: #fff;
border: 1px solid #333;
padding: .5em;
margin-bottom: .5em;
border-radius: 5px;
}
button {
background: #066580;
color: #fff;
border: none;
padding: .6em 1.2em;
border-radius: 5px;
cursor: pointer;
}
button:hover {
opacity: 0.7;
}
.comment {
background: #151515;
border: 1px solid #222;
padding: 1em;
border-radius: 8px;
margin-top: 1em;
}
.comment small {
color: #888;
}
.error {
background: #3a0a0a;
color: #ff7b7b;
padding: .5em 1em;
border-radius: 8px;
margin-bottom: 1em;
}
.delete-btn {
background: #333;
color: #ff6666;
border: none;
padding: 0.3em 0.6em;
border-radius: 4px;
font-size: 0.8em;
cursor: pointer;
float: right;
}
.delete-btn:hover {
background: #600;
}
.honeypot {
display: none;
}
</style>
</head>
<body>
<h1 style="text-align:center;">When Freedom Lives in the Shadows</h1>
<div style="text-align: center;">
<img src="https://mentalnet.xyz/funnies/uploads/comic_69039a3022abe.jpg" alt="Debian Osaka Comic" width="250px"/>
</div>
<p style="text-align:center;"><i>Published October 30 2025 on MentalNet.xyz</i></p>
<section>
<p>Every few months, someone declares that <strong>open source is dying</strong>. They point to burnout, unpaid maintainers, or corporate interference. But listen closer what they really mean is, “I wish open source would stop making me feel responsible. Because true openness forces participation, and participation means accountability.</p>
<p>Most of these critics dont hate open source they just want it to behave like a product. They want Linux to be a frictionless, pretty front end for their gaming rigs. They want a distro that never asks them a question. They want <em>freedom</em> without <em>understanding</em>.</p>
<p>But open source was never about comfort. Its about curiosity, discovery, and sometimes chaos. Thats where the real magic happens not in polished GUIs, but in that moment when you break something, stare at the logs, and realize you actually <em>get</em> it now.</p>
</section>
<h2>Flatpaks, Abstractions, and the Death of Craft</h2>
<p>The Flatpak era symbolizes something deeper a shift from curiosity to avoidance. Developers say “its not our job to package for Debian, and users applaud because they think it means less work. But every layer of abstraction is also a layer of lost understanding. You dont solve problems anymore you containerize them.</p>
<p>Reading logs, tracing dependencies, debugging services those used to be rites of passage. Now theyre treated as eccentric hobbies. The person who still reads man pages is the odd one out, even though theyre the one keeping the system alive.</p>
<p>Projects that make those tasks easier like tools that help you build <code>.deb</code> packages or visualize dependencies get labeled as “overkill. But theyre not. Theyre bridges between developers and maintainers. They make creation more transparent. And transparency, in computing, is freedom.</p>
<blockquote>
A small act of curiosity can ripple across projects.
When I was experimenting with OpenBSD in a VM, I noticed that <strong>oh-my-bash</strong>s alias for <code>mkdir -pv</code> didnt work, because BSDs <code>mkdir</code> doesnt support <code>-v</code>.
I reported it in <a href="https://github.com/ohmybash/oh-my-bash/issues/351" target="_blank">Issue #351</a>, and maintainer <strong>@akinomyoga</strong> implemented a smarter, cross-platform detection function that checks for <code>-v</code> before applying the alias.
That single change turned a failing command into a robust, portable one and now the project cites that issue as part of its ongoing work to keep BSD compatibility intact.
Moments like that show what open source is really about: not grand rewrites or flashy announcements, but dozens of quiet, thoughtful fixes that make the ecosystem stronger.
</blockquote>
<h2>Two Kinds of Hackers</h2>
<p>This split starts long before anyone touches production code. It starts in high school.</p>
<p>One kid decides to major in computer science because its a “stable, well-paying job. They hear about frameworks, APIs, and tech stacks. It all sounds safe, predictable, structured.</p>
<p>The other kid finds an old laptop with a broken hard drive. They have no money. So they grab a USB stick, download a Linux ISO, and boot into a live system. Thats how they learn. When the bootloader fails, they learn what GRUB is. When the installer cant see the drive, they learn about partitions. They dont study computing they <em>live</em> it.</p>
<p>And that difference never fades. The first person learns to depend on platforms. The second learns to depend on themselves. One panics when something breaks; the other leans in and says, “Okay, lets see what happened. Thats the essence of the open-source spirit curiosity in the face of chaos.</p>
<h2>The Creative Trance</h2>
<p>Theres something spiritual about coding in that “trance” when youre just you and the machine, iterating, testing, feeling your way forward. Its like a conversation between two minds, one silicon and one human. Mistakes dont feel like failures; theyre just feedback. You stop fearing them and start learning from them.</p>
<p>People who only work within pre-defined frameworks will never understand that flow. They see it as messy, unstructured, inefficient. But thats how discovery works. Real breakthroughs rarely come from polished corporate environments they come from experimentation, from intuition, from those long nights where something finally clicks because you stopped overthinking and started <em>building</em>.</p>
<h2>Freedom Doesnt Die in Darkness It Survives There</h2>
<p>People love to say “freedom dies in darkness, but in the open-source world, thats exactly where it <em>lives</em>. Its in the basements, the IRC servers still humming at 2 a.m., the Git repos maintained by one dedicated person who just loves making things work. Its in the communities that dont care about hype only about code that runs clean and honest.</p>
<p>Freedom doesnt need a marketing department. It doesnt need polish. It just needs people willing to keep learning when everyone else decides its not worth the effort.</p>
<p>So when someone says open source is dying, theyre really just admitting theyve stopped looking for it. Its not dead its underground, alive, and whispering to those who still care enough to listen.</p>
<p>Thats where the real hackers live not in boardrooms, not in app stores, but in that quiet, flickering glow of a terminal screen. And thats where freedom still burns.</p>
<hr>
<h2>Comments</h2>
<?php if ($error): ?>
<div class="error"><?=htmlspecialchars($error)?></div>
<?php endif; ?>
<form method="POST">
<label>Name:</label>
<input type="text" name="name" required>
<label>Comment:</label>
<textarea name="comment" rows="4" maxlength="250" required></textarea>
<div class="honeypot">
<label>Website:</label>
<input type="text" name="website" value="">
</div>
<button type="submit">Post Comment</button>
</form>
<?php foreach ($comments as $c): ?>
<div class="comment">
<strong><?=htmlspecialchars($c['name'])?></strong>
<small> <?=htmlspecialchars($c['date'])?></small>
<?php if ($is_admin): ?>
<a class="delete-btn" href="?delete=<?=$c['id']?>" onclick="return confirm('Delete this comment?');">Delete</a>
<?php endif; ?>
<p><?=nl2br(htmlspecialchars($c['comment']))?></p>
</div>
<?php endforeach; ?>
</body>
</html>