I developed an easy way to create a templated web site using a template and text files. Then to modify those text files, I developed a simple editor and updater. It is very simple and the user only needs to know HTML. There is no need for a database. This batch of code is for 4 pages. Read teh comments for directions. Check it out....
By : zensmile
/* First off, design your template page in your text editor or WYSIWYG editor of choice. Where you want the "content" to show up within the page, include this code: */
/************************ Begin Code ************************/
/************************ End Code ************************/
/*All of your links should look like this:
template.php?page=whatever
Where the link reads "whatever", replace with a file name without the .txt extension. For example, template.php?page=faq, would include "faq.txt" within your template page.
Create a "data" directory and put all of your content files within that directory. The .txt files will contain all of the "meat an potatoes" of your site...formatted in HTML *without* the <HTML><HEAD> or <BODY> tags. All of those tags are within your template.php. For example, you might have a contact page, a faq page, and a downloads page. You would have a faq.txt, contact.txt, and a downloads,txt within your data directory. So your links would look like this:
/* this next batch of code should be in a file called update.php within your "data" directory. You use this page to edit your .txt files within "data". You would access it by typing in...
http://www.whatever.com/data/update.php
You will then be asked for a login and password. Here is the script for update.php: */
/************************ Begin Code ************************/
<?php
//Check to see if $PHP_AUTH_USER already contains info
/************************ End Code ************************/
/* Here is the code for "modify.php", which is also located in the "data" directory. Modify.php is the "action" for the upate.php file. You choose a file to modify and then the information is passed to modify.php. Here is the code: */
/************************ Begin Code ************************/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html lang="en"> <head> <title>Your Title Here</title> </head> <body>
<h3>Modify Data Document</h3>
<p>Carefully read the text below, edit, and then submit to publish to web site. All changes are final! Please make sure that you have spell checked document and all "curley quotes and apostrophes" have been eliminated.
<p>You must also use HTML markup in the document. Please, read an HTML manual before getting "freaky" with the editing.
/************************ End Code ************************/
/* Here is the code for "write.php". It is, again, located within the "data" directory. Write.php is the action for "modify.php". After you have made your changes to the .txt file, the changes are written and then you are redirected to the update.php page. Here is the code: */
/************************ Begin Code ************************/
/************************ End Code ************************/
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.