Forum Moderators: coopster & phranque

Message Too Old, No Replies

possible to use ssi within a cgi script

         

jeremy goodrich

2:52 am on Jun 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have been reading everything I can find, and can't seem to find information on doing this.

if (condition} =~ /$pattern/)
{
<!--#include file="/myfile.html" -->
}
else {
<!--#include file="/myotherfile.html" -->
}

If I can't embed the ssi calls like this, how else could I accomplish the same thing?

Brett_Tabke

3:46 am on Jun 22, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Do the same thing from perl:

#!/usr/bin/perl
#<!--#include virtual="/mytester.cgi"-->

$file1 ="/path/to/file/one";
$file2 ="/path/to/file/two";

if ($ENV{'HTTP_USER_AGENT'} =~ /googlebot/i) {
$ifile =$file1;
}
else {
$ifile =$file2;
}

open FILE, $ifile;
@o=<FILE>;
close FILE;
foreach (@o) {
print $_;
}

sea

4:15 am on Jul 3, 2001 (gmt 0)



Not sure if this falls exactly along the same lines, but I have a question about inserting an SSI command within a cloaked page.

For instance, some of my pages are cloaked and some aren't, it's easy to use SSI on the uncloaked pages, but I haven't figured out how to use an include on a cloaked page. Using ICS I can only have one include on the main page which then directs a visitor or spider a predefined page. Since I can't put SSI in the main cloaked page, and it doesn't work when I put it in the "human version" of the same page...what now?

I've tried adding an absolute path and also putting a copy of the page.html that I'm trying to include in the "human version"...I'm lost.

toolman

5:40 am on Jul 3, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sea,
SSI won't work from the cloaked page no matter what you try. You might try javascript to do whatever it is you want to do.

Bolotomus

5:43 am on Jul 16, 2001 (gmt 0)

10+ Year Member



You didn't say what web server you are running, but Apache purposely makes sure that you CANNOT do that... because it's a giant security hole.

E.g., a typical CGI script might say "Sorry, but dsafdsadsa@dasfdsa is not a valid email address." What do you think would happen if somebody typed in some SSI for their email address, perhaps with a mind to delete files from your server? That script would output it in the HTML, which would then get run by the SSI engine... eeeek!

The solution: make your CGI program do everything all by itself. Whatever job the SSI is suppose to accomplish, your CGI program can accomplish it to. After all, it's generating all of the other output, why not generate those last few bits?

Bolotomus