WillMaster Possibillites Logo EzineSeek Award
Master Remote Content Delivery
by
Mari Bontrager

Permission is granted to reprint this article in its entirety, provided no reprints are sent in conjunction with unsolicited bulk email, provided no fee or other value is exchanged, provided no changes are made to the article, and provided the author's name, signature lines, and copyright line are printed with the article; except you may change the article's title.

Correction: Last week's "Dealing With CGI Installation Jitters" article had a typo in the code. Alert reader, Robert, found it. Somehow, during copying from my testing file into the mailing script, I dropped a colon character. If you tried to install the script and it gave you an Internal Server Error, here is the corrected code:

#!/usr/bin/perl 
$Message = "<h1>Congratulations, my friend!</h1>"; 
print "Content-type: text/html\n\n"; 
print "<html><body>$Message</body></html>";

Imagine having an online store that other people want. Now you can let them display your store at their site with their own URL, selling products for you at whatever financial arrangements you agree upon.

If you have a directory or information site that you've been wanting to let others display with their own URL, now you can that, too.

You control the content. They display it at their site.

The content can be one or many pages. Multiple pages of content may be interlinked.

Your content can include most JavaScript, images, forms, and sound. Any standard HTML is acceptable. Just ensure all URLs are absolute http://... URLs. Relative URLs can't be used. (An exception to the URL rule is links to other pages of multi-page content. See "How To Interlink Multiple-Pages Of Content" below.)

Affiliate URLs can be customized for the site displaying your content.

The default content, the "index" page, can be submitted to and crawled by search engine indexing spiders.

A remote publishing site demonstration is at http://willmaster.com/a/15/pl.pl?art151demo

How It Works

Our example uses two domains. One is the source for the content. The other publishes the content. We'll call them the "source domain" and the "publishing domain."

There are two CGI scripts. MRCDsource.cgi for the source domain and MRCDpub.cgi for the publishing domain.

(There can be any number of publishing domains for any one source domain. Each would install its own copy of MRCDpub.cgi)

The first thing that happens is that a publishing site visitor clicks a link. That link could be directly to MRCDpub.cgi or to an SSI page that calls the script.

When MRCDpub.cgi is launched, it immediately contacts the script at the source domain and requests some content.

The source domain has the content somewhere on its site. The MRCDsource.cgi script's job is to retrieve content whenever requested and hand it over to the publishing domain's script. So that's what it does.

The publishing domain's script receives the content and sends it to the visitor's browser. The visitor sees the content and, hopefully, says, "Ah! This is exactly what I've been looking for!"

Note that the URL in the visitor's browser is the URL of the publishing domain.

Deciding Whether Or Not To Use an SSI Page

If the publishing domain wants search engines to index the URL where the content will be displayed, then an SSI page should be created with the following line:

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

Replace "/cgi-bin/MRCDpub.cgi" with the correct URL to the publishing domain's installation of MRCDpub.cgi

An example SSI page is included with the Master Remote Content Delivery ZIPped download file. The download URL is near the end of this article.

Deciding Whether Or Not To Use a Template Page

The publishing domain can have a template page within which the content will be inserted. Simply put a [[INSERT_CONTENT_HERE]] placeholder where you want the content to be put.

With a template page, the publishing domain can provide logos, site navigation links, and so forth. Without a template page, the content will appear by itself.

The content domain might publish entire pages, including HEAD content. In that case, the publishing domain would not use a template page -- because the incoming content contains all page elements.

If the content domain publishes only portions of pages, a template page can instruct the script where to insert those portions.

The Master Remote Content Delivery ZIPped download file has an example template page.

If you make a template page, ensure all URLs are absolute http://... URLs, including images and links and URLs to exterior JavaScript and CSS files. Relative URLs won't work.

Installing MRCDsource.cgi On the Source Domain

Make all edits with a plain text word processor like NotePad or BBEdit.

Ensure the first line of the script points to your server's installation of Perl. Then, specify three items at the places indicated:

  1. The file name for the default content (without the file name extension).

  2. The file name extension that all valid content files will have.

  3. The complete server path to the directory where all valid content resides.

Do you see how security concerns are addressed? The script will only retrieve content from files with one specific file name extension and only from files residing in one specific directory.

Snoopers are foiled. The script discards attempts to use relative URLs to download files in other directories.

Once edits are complete, upload the script into a directory allowed to run Perl CGI programs. Use FTP and upload as plain text. Set the script's permission to 755, global execute.

Installing MRCDpub.cgi On the Publishing Domain

The publishing domain's server must have Perl module LWP::Simple installed. Most hosting company's have it installed as a matter of standard procedure. But some don't. Ask the hosting company's tech support, if uncertain, or use Master Pre-Installation Tester from http://willmaster.com/a/15/pl.pl?mpits

Make all edits with a plain text word processor like NotePad or BBEdit.

Ensure the first line of the script points to your server's installation of Perl. Then, specify four items at the places indicated:

  1. The complete http://... URL of this MRCDpub.cgi script that will be installed on the publishing domain.

  2. The complete http://... URL of the MRCDsource.cgi script installed at the source domain.

  3. The server location of the publishing domain's template page. If no template page will be used, type two apostrophes with nothing between them.

  4. The publishing domain webmaster's affiliate code. If not applicable, specify anything, a series of X characters, for example.

Once edits are complete, upload the script into a directory allowed to run Perl CGI programs. Use FTP and upload as plain text. Set the script's permission to 755, global execute.

The Source Domain's Content

The content the source domain will serve to the publishing domain is HTML formatted, ready for display on the publishing domain's site. Put the HTML content is all one directory.

Only HTML formatted content is sent to the publishing domain. Images and other page objects can be anywhere on the internet; use http://... URLs to put them on the page.

How To Insert Custom Affiliate Codes

The source domain puts an [[AFFILIATE_CODE]] placeholder into the source content wherever the affiliate code should go. For example, the affiliate link for this article's demonstration content site is:

http://hop.clickbank.net/hop.cgi?[[AFFILIATE_CODE]]/willmaster

When the publishing domain's script receives the content, it scans for such placeholders and replaces them with the affiliate code already specified in its MRCDpub.cgi script.

How To Interlink Multiple-Pages Of Content

Link between pages of multi-page content requires a special technique.

The script on the publishing domain is the one that requests pages from the source domain. Therefore, the link to another page of the multi-page content set must contain the URL of the script on the publishing domain.

Because there may be more than one publishing domain, and there is only one set of source pages, a special placeholder needs to be used for that variable URL. When the script at the publishing domain receives content, it scans the content for that special placeholder and replaces it with the URL to itself.

The source domain uses [[URL]]?pagefilename to specify a link to another content page. The pagefilename does not include the file name extension. Example:

<a href="[[URL]]?definitions">
Click for definitions
</a>

When the publishing domain's script receives the content, each [[URL]] placeholder is replaced with the URL to the publishing domain's MRCDpub.cgi script. Clicking on the link then instructs the pair of scripts to deliver that specific content.

Recap

The source domain and the publishing domain install their respective scripts.

The publishing domain can optionally use a template page within which to insert content received from the source domain.

The source domain makes content available. It puts affiliate code placeholders into the content wherever applicable. And it puts appropriate URL placeholders when interlinking with other pages of the content.

The publishing domain can link directly to it's copy of MRCDpub.cgi or it can use an SSI page that calls the script.

When launched, MRCDpub.cgi asks MRCDsource.cgi for content to publish. MRCDsource.cgi provides the content. MRCDpub.cgi scans the content for placeholders and then sends the customized content to the visitor's browser.

Downloading Master Remote Content Delivery

You can download the source code and examples at http://willmaster.com/a/15/pl.pl?rcd This article is the majority of the instructions. A short README.txt file is also included in the ZIP file download.

The page at the above URL also contains a link to a remote publishing site demonstration.

There is no charge for downloading and using Master Remote Content Delivery.

By: Will Bontrager

Copyright 2002 Bontrager Connection, LLC
http://willmaster.com/possibilities/
subscribe-possibilities@willmaster.com