commit 1d85bf6663fc3167c2193bdb3ea0783187f8da8b
Author: mrkmntal
Date: Sat Oct 25 15:10:38 2025 -0400
Initial Commit
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..de59942
--- /dev/null
+++ b/README.md
@@ -0,0 +1,129 @@
+
+# π§ MentalNet Funnies
+
+**A lightweight PHP + SQLite web app for hosting MentalNet Original comic strips.**
+Built for simplicity, security, and self-hosting β no external dependencies, just pure PHP, HTML, and CSS.
+
+---
+
+## π Overview
+
+**MentalNet Funnies** is a micro-comic CMS that serves as the home for *Debian Osaka*, *Tux*, *Miku*, and other MentalNet.xyz comics.
+Itβs designed for local hosting on Apache + PHP setups and includes a tiny password-protected admin panel for uploads.
+
+### β¨ Features
+
+* πΌ Upload, title, and describe new comics via a web form
+* πΎ SQLite database β no external DB needed
+* π Password-protected admin area
+* π± Mobile-friendly front page (`index.php`)
+* πͺΆ Compact iframe version (`funnies-frame.php`) for embedding
+* βοΈ One-click database initializer (`init_db.php`)
+
+---
+
+## π Directory Structure
+
+```
+/var/www/html/funnies/
+βββ index.php # Main public comic viewer
+βββ funnies-frame.php # Small-width iframe-friendly viewer
+βββ uploads/ # Comic image storage
+βββ mentalnet_funnies.db # SQLite database file
+βββ admin/
+β βββ auth.php # Login handler
+β βββ config.php # Config & DB setup
+β βββ upload.php # Upload interface
+β βββ init_db.php # Manual DB table initializer
+βββ README.md # This file
+```
+
+---
+
+## βοΈ Installation
+
+1. **Create directory & set permissions**
+
+ ```bash
+ sudo mkdir -p /var/www/html/funnies/uploads
+ sudo chown -R www-data:www-data /var/www/html/funnies
+ sudo chmod -R 755 /var/www/html/funnies
+ ```
+
+2. **Set up the admin password**
+ Generate a bcrypt hash:
+
+ ```bash
+ php -r 'echo password_hash("YourStrongPassword", PASSWORD_DEFAULT), PHP_EOL;'
+ ```
+
+ Then place that hash inside `admin/config.php` under:
+
+ ```php
+ $ADMIN_PASS_HASH = '$2y$10$replace_with_real_hash';
+ ```
+
+3. **Initialize the database**
+ Visit:
+ `https://yourdomain.com/funnies/admin/init_db.php`
+ Or run the init script via command-line:
+ `php init_db.php`
+ It will create the `comics` table or confirm if it already exists.
+
+4. **Upload a comic**
+ Visit:
+ `https://yourdomain.com/funnies/admin/auth.php`
+ Log in and use the form to upload images and descriptions.
+
+5. **View your comics**
+
+ * Main gallery: `https://yourdomain.com/funnies/`
+ * Iframe feed: `https://yourdomain.com/funnies/funnies-frame.php`
+
+---
+
+## πͺ Embedding the Funnies Frame
+
+The iframe viewer (`funnies-frame.php`) is optimized for small layouts (β 325 px).
+Example embed:
+
+```html
+
+```
+
+> π‘ You can adjust image width inside `funnies-frame.php` (default: 250 px for compact display).
+
+---
+
+## π‘ Security Notes
+
+* Only the admin section (`/admin/`) requires authentication.
+* Use strong passwords and HTTPS.
+* The upload form restricts to images only.
+* SQLite DB and uploads folder should be owned by `www-data` with 755 perms.
+
+---
+
+## π§© Customization Ideas
+
+* Add a βView All Comics ββ link inside the iframe version.
+* Include navigation buttons (Next / Previous comic).
+* Implement tags or short titles for categorization.
+* Add a JSON API endpoint for future integration with other MentalNet services.
+
+---
+
+## π§° License
+
+MIT License β free to modify and self-host.
+Created by **MarkMental** as part of the **mentalnet.xyz** web ecosystem.
+
+> βIn the MentalNet, Tux is root β and Miku too.β π§π€
+
+
diff --git a/admin/auth.php b/admin/auth.php
new file mode 100644
index 0000000..16d4d73
--- /dev/null
+++ b/admin/auth.php
@@ -0,0 +1,33 @@
+
+
+
+Login - MentalNet Funnies Admin
+
+π MentalNet Funnies Admin
+
+$error
"; ?>
+
+
+
+
diff --git a/admin/config.php b/admin/config.php
new file mode 100644
index 0000000..6557ea7
--- /dev/null
+++ b/admin/config.php
@@ -0,0 +1,22 @@
+exec("CREATE TABLE comics (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ title TEXT NOT NULL,
+ filename TEXT NOT NULL,
+ description TEXT,
+ date_added DATETIME DEFAULT CURRENT_TIMESTAMP
+ )");
+} else {
+ $db = new SQLite3($db_file);
+}
+?>
+
diff --git a/admin/init_db.php b/admin/init_db.php
new file mode 100644
index 0000000..8930b02
--- /dev/null
+++ b/admin/init_db.php
@@ -0,0 +1,20 @@
+querySingle("SELECT name FROM sqlite_master WHERE type='table' AND name='comics'");
+
+if ($result) {
+ echo "βΉοΈ Table 'comics' already exists.";
+} else {
+ $db->exec("CREATE TABLE comics (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ title TEXT NOT NULL,
+ filename TEXT NOT NULL,
+ description TEXT,
+ date_added DATETIME DEFAULT CURRENT_TIMESTAMP
+ )");
+ echo "β
Table 'comics' created.";
+}
+?>
+
diff --git a/admin/upload.php b/admin/upload.php
new file mode 100644
index 0000000..7789226
--- /dev/null
+++ b/admin/upload.php
@@ -0,0 +1,40 @@
+prepare("INSERT INTO comics (title, filename, description) VALUES (:t,:f,:d)");
+ $stmt->bindValue(':t',$title,SQLITE3_TEXT);
+ $stmt->bindValue(':f',$fname,SQLITE3_TEXT);
+ $stmt->bindValue(':d',$desc,SQLITE3_TEXT);
+ $stmt->execute();
+ $msg = "β
Uploaded '$title'";
+ } else $msg = "Upload failed.";
+}
+?>
+
+
+Upload Comic - MentalNet Funnies
+
+π§ Upload Comic
+=htmlspecialchars($msg)?>
+
+β View Site
+
+
+
diff --git a/funnies-frame.php b/funnies-frame.php
new file mode 100644
index 0000000..bd73cf9
--- /dev/null
+++ b/funnies-frame.php
@@ -0,0 +1,72 @@
+query('SELECT * FROM comics ORDER BY date_added DESC LIMIT 3'); // show latest 3 for compactness
+?>
+
+
+
+
+
+MentalNet Funnies Frame
+
+
+
+fetchArray()): ?>
+
+
= htmlspecialchars($row['title']) ?>
+
![<?= htmlspecialchars($row['title']) ?>](uploads/<?= htmlspecialchars($row['filename']) ?>)
+
+
= nl2br(htmlspecialchars($row['description'])) ?>
+
+
= htmlspecialchars(date('M j, Y', strtotime($row['date_added']))) ?>
+
+
+
+
+
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..931edd4
--- /dev/null
+++ b/index.php
@@ -0,0 +1,61 @@
+query('SELECT * FROM comics ORDER BY date_added DESC');
+?>
+
+
+
+
+
+MentalNet Funnies
+
+
+
+π§ MentalNet Funnies
+fetchArray()): ?>
+
+
= htmlspecialchars($row['title']) ?>
+
![<?= htmlspecialchars($row['title']) ?>](uploads/<?= htmlspecialchars($row['filename']) ?>)
+
= nl2br(htmlspecialchars($row['description'])) ?>
+
= htmlspecialchars($row['date_added']) ?>
+
+
+
+
+