RemoteSSI.cgi

Here is the current version of the source code for remoteSSI.cgi, as originally proposed by User:Grayden.Maclennan in his blog

Please make use of the Discussion page for suggestions!

 
#!/usr/bin/perl
use CGI qw(:standard); # provides header
use LWP::Simple; # provides getprint
 
 
###########################################################
## This work is licensed under the                       ##
## Creative Commons Attribution License.                 ##
## To view a copy of this license, visit                 ##
## http://creativecommons.org/licenses/by/2.0/           ##
## or send a letter to:                                  ##
##     Creative Commons                                  ##
##     559 Nathan Abbott Way                             ##
##     Stanford, California 94305, USA.                  ##
##                                                       ##
## Essentially this means you can do whatever            ##
## you want with the code as long as you credit          ##
## Grayden MacLennan (grayden.maclennan@case.edu)        ##
## as the original author.                               ##
##                                                       ##
## This document was last modified on September 26, 2005 ##
###########################################################
 
 
######
# remoteSSI.cgi
# by Grayden MacLennan
# grayden.maclennan@case.edu
#
# 2005-09-21
#
# This is a VERY simple program that grabs content from any
# http-accessible source and spits it out again.
#
# The original motivation behind this program was to allow
# me to do Server Side Includes (SSI) on one server while the
# included content sits on another server.  Normally, SSI only
# works within a local file system, so this program in effect
# gives a LOCAL path to a REMOTE resource.
#
#
# --Example of usage--
#
#  What you'd do for a normal local file:
#
#    <!--#include virtual="/somepath/includefile.inc" -->
#
#  What you'd LOVE to do but can't:
#
#    <!--#include virtual="http://remote.server.com/somepath/includefile.inc" -->
#
#  What you do to get around the problem:
#
#    <!--#include virtual="/cgi-bin/remoteSSI.cgi?url=http://remote.server.com/somepath/includefile.inc" -->
#
######
 
# Step 1 - print a header so the CGI won't throw an Internal Server Error 500
print header;
 
# Step 2 - if we can establish that this is being used for SSI purposes,
#          reprint anything it finds at the URL (bad URL generates nothing)
if ( $ENV{"SERVER_PROTOCOL"} eq "INCLUDED" ) {
        getprint( param("url") );
}
else {
        print "Hey - this isn't a proxy server!";
}
 
# Step 3 - There is no Step 3!

Case Referrers

Blog Entries
This page has been accessed 1,966 times.
This page was last modified 16:36, September 26, 2005 by Grayden MacLennan.
About | Disclaimers