Laziness often helps you figure out funny ways to solve problems. Put it this way. I’ve found a hack to create a lightweight CMS in PHP that uses .txt files and query strings. Yes, you publish through a URL, and the persistence happens inside a text file. Not a MySQL database. Crazy! It works.
I know it’s a little frustrating (at least for me) to login into a CMS, or your host’s FTP to change a line on your static page to something else. Well, you can do it with a simple query string. Here’s the setup. It’s not fault tolerant in anyway, but it just works!
With this idea in mind, it is possible to a create a quite useful CMS with flat files and query strings. The potential use-cases for such a system are landing pages, short messages, or static one page websites which require constant updates.
<?php //get the password $write = $_GET['write']; //if password is correct if ($write=="password") { //get content $current = $_GET['content']; //store content in variable $file = 'content.txt'; //if content is written to file if (file_put_contents($file, $current)) { echo "Updated\n"; } else { echo "Failed\n"; } } ?> <!DOCTYPE html> <html> <head> <title> Lightweight CMS </title> </head> <body> <p> <?php echo $current = file_get_contents('content.txt'); ?> </p><br> </body> </html>