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

+

+
+

+

+

+

+
+

← 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']) ?> + +

+ +

+
+ + + + 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']) ?> +

+

+
+ + + +