CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in
Add ListingModify ListingTell A FriendLink to TPASubscribeNew ListingsCool ListingsTop RatedRandom Link
Newest Reviews
  • review
  • hagen software
  • NOT GPL!
  • Hagan Software
  • Wasted Time with ...
  • poor pre-sale sup...
  • no response
  • rating the offer
  • Good Stuff
  • Good idea but use...


  •  
    Perl Archive : TLC : Programming : Apache : Server Side Includes: What you can do with them
    Guide Search entire directory 
     

    Date Published: 1999-11-01

    by D. Jasmine Merced
    TNS Group, Inc. Previously, we discussed what Server Side Includes (SSI) are. This month, we're building on that discussion to explain to you some of the many things you can do with SSI. Please note that SSI is (obviously) a server-side issue -- you'll need to have a web server with SSI enabled to perform any of the functions mentioned below.
    Global Website Updates
    One of the coolest things about SSI is the ability to make your life easy. Have you ever had the "New Year's" craze, needing to change all of your copyrights from the current year to the new year? Using SSI can make this one of the easiest tasks of the year instead of one of the most dreaded.

    SSI makes this task easy by allowing you to "include" an external file into your html document. For example, you have a footer (with that copyright) that you would like to show on every page in a web site. You have named the footer file footer.txt. In your main html document (let's call it index.shtml), you would type:

    <!--#include file="footer.txt"-->

    What this command does is insert the footer.txt file in the exact location where you've placed the SSI code (commonly called "ssi call") on your web page.

    On some servers, you'll need to use include virtual instead of include file.

    Insert Dynamic Server and User Information
    In addition to being able to include other static files into your html pages, you can include some information that is relevant to your visitor or the time of day. For example, if you put the following code onto your web page:

    You are calling from <!--#echo var="REMOTE_ADDR"-->

    will show your web site visitor their current IP#... here's yours:

    You are calling from 54.227.141.230

    Many people like to include the current date and time on their web page.

    <!--#echo var="DATE_LOCAL"-->

    will show "Wednesday, 23-Apr-2014 22:21:58 PDT".

    You can also show the date that your page was last update. Here's the code that's present on this page:

    This page was last updated on <!--#flastmod file="whateverfile.html"-->

    which yields:

    This page was last updated on [an error occurred while processing this directive]

    Run a cgi program
    You can execute a CGI program. This is highly contingent on your host. When you use this, your script has to be tight and have no security holes. For example, if you have a "Quote of the Moment" script, which inserts a new quote every time your page is reloaded. Some people make you go to a specific page to look at your random quotes, but SSI allows you to insert your random quote into your .shtml page. The command would look like

    <!--#exec cgi="cgi-bin/randomquote.cgi"-->

    This is also to display counters to your page. In order for your <!--#exec cgi= command to work, you need to make sure that your script is working. Make sure that permissions are at least 755 (rwxrw-rw-) or higher (depending on your web host), and if possible, try to run the program first, before including it into your document.

    These are just a few things that you can do with SSI. If you'd like to continue your SSI education, may we suggest WDVL's SSI Directives article.  

    D. Jasmine Merced is a partner in Tintagel Net Solutions Group, Inc. and the administrator of The Perl Archive. She also serves as a Director of the World Organization of Webmasters. She can be reached at admin@perlarchive.com.

     
     


    About The Perl ArchiveLink Validation ProcessSearch Tips
    Web Applications & Managed Hosting Powered by Gossamer Threads
    Visit our Mailing List Archives