Content Management Code
  Home arrow Content Management Code arrow Easy Content Management
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CONTENT MANAGEMENT CODE

Easy Content Management
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2002-05-29

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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 ************************/

    <?php

    $thefile = "data/$page.txt";
    if (file_exists($thefile))
    {
    include("$thefile");
    }
    else
    {
    include("data/error.txt");
    }

    ?>

    /************************ 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:

    template.php?page=faq
    template.php?page=contacts
    template.php?page=downloads
    */

    /* 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

    if (!isset($PHP_AUTH_USER)) {
    //If empty send header causing dialog box to appear
    header('WWW-Authenticate: Basic realm="Private Stuff"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization required.';
    exit;
    }

    //If not empty, do something else

    else {

    //Try to validate the values of $PHP_AUTH_USER and
    //$PHP_AUTH_PW against hard-coded values
    //please change login and password to whatever you want

    if (($PHP_AUTH_USER == "login") && ($PHP_AUTH_PW == "password")) {

    echo "
    <html lang=\"en\">
    <head>
    <title>Enter Your Title Here</title>
    </head>
    <body>

    <h3>Header</h3>

    <p>Please be very careful when editing these files. Be particularly careful when editing the PHP files.

    <p>Choose a page to edit and then hit the submit button.

    <p>

    <form action=\"modify.php\" method=\"post\">

    <table width=\"500\" border=\"1\" cellspacing=\"1\" cellpadding=\"5\">\n
    <tr bgcolor=\"#CCCCCC\"><th>Pick</th><th>File Name</th><th>Last Edited or Uploaded</th></tr>\n
    ";
    $handle=opendir('.');
    while (false!==($file = readdir($handle))) {
    if ($file != "." && $file != ".."
    && $file != "update.php" && $file != "write.php" && $file != "modify.php") {
    $filename = str_replace("_"," ",$file);
    $fTime = filemtime($file);
    $today = getdate($fTime);
    $month = $today['month'];
    $mday = $today['mday'];
    $year = $today['year'];
    echo "<tr><td align=\"center\"><input type=\"radio\" value=\"$filename\" name=\"working\"></td><td align=\"center\"><b>$filename</b></td><td align=\"center\">$month $mday,
    $year</td></tr>\n
    ";
    }
    }
    closedir($handle);

    echo "</table>\n";
    echo "<p><input type=\"submit\" value=\"Submit\">";
    echo "</form>";

    echo " </body>
    </html>";

    }

    else {

    echo "You are not authorized!";

    }

    }

    ?>

    /************************ 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.

    <form method="post" action="write.php">
    <textarea name="message" rows="20" cols="60">
    <?php

    $contents=file($working);
    for ($i=0; $i<sizeof($contents);$i++){
    echo htmlentities($contents[$i]);
    }
    echo "</textarea>\n";

    echo "<input type=\"hidden\" value=\"$working\" name=\"working\">";
    ?>
    <p>
    <input type="submit">
    </form>

    </body>
    </html>

    /************************ 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 ************************/

    <?php

    $writeme=fopen("$working","w");
    fputs($writeme, stripslashes($message));
    fclose($writeme);
    header("Location: http://www.yourdomain.com/data/update.php\n\n");

    ?>

    /************************ 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.

    More Content Management Code Articles
    More By Codewalkers

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Calling all CC Power Users – and those that would like to be!

    Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development
    FREE! Go There Now!


    NEW! Evaluate IBM Lotus Sametime Standard V8.0

    Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration.
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Developer for System i V7.1

    Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications.
    FREE! Go There Now!


    NEW! Evaluate IBM Rational Software Analyzer V7.0

    Download a free trial version of IBM Rational Software Analyzer Developer Edition V7.0 to identify bug defects earlier in the software development cycle. Rational Software Analyzer is an extensible software development solution that reduces the expense of bug-fixes by enabling static analysis code reviews and bug identification very early in the development cycle.
    FREE! Go There Now!


    NEW! Evaluate Rational Business Developer V7.1

    Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities.
    FREE! Go There Now!


    NEW! The dirty dozen: preventing common application-level hack attacks

    As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications.
    FREE! Go There Now!


    NEW! Trial download: IBM Lotus Forms V3.0

    Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format.
    FREE! Go There Now!


    NEW! Webcast: Introducing the new Information Server and Solutions community: LeverageInformation

    User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges.
    FREE! Go There Now!


    NEW! Webcast: What is new in Viper 2 for developers?

    Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications.
    FREE! Go There Now!


    Refresh! IBM Rational Systems Development Solution eKit

    With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    CONTENT MANAGEMENT CODE ARTICLES

    - V2 CMS - Content Management System
    - VSNS Lemon
    - Country List For Forms Using SQL
    - eggblog
    - Table generation class
    - STP Simple Template Parser
    - class Vision_To_Form_Elements
    - Cascade Drop Down
    - Cura - CMS
    - Syntax Desktop
    - 216 color table
    - Simple Mini Poll class library (SimPoll)
    - Regex Generator
    - Siteseed
    - Company WebSite Builder PRO





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek