FireBird34 has asked for the wisdom of the Perl Monks concerning the following question:

I have some shtml pages calling a script I made. Not knowing much in the lines of DB, I just have some simple lines of code that prevent outside access to some sections on my site. If a particular user accesses the information outside of a certain area, he will get an access denied message.

Now, several people were telling me that the code was being shown, instead of the proper page itself (this was when they were in cgi format)... thus my converting to shtml. Problem being, when the access denied message comes up, the html page itself still shows up. (bit confusing, so here's the question)

How do I stop an html page from loading up through a cgi script, when the cgi script is being called from the html page (SSI)?

Replies are listed 'Best First'.
Re: Stopping HTML via Perl
by pfaut (Priest) on Dec 28, 2002 at 22:14 UTC

    The situation you describe won't work. I don't think there is any way for a program invoked by a server-parsed html file to tell the web server not to return the page.

    If you want to keep a page from being presented to non-local users, your best bet is to do it through web server settings. I don't know of a web server that won't allow you to limit access by IP address. It may also be possible on a per-directory basis using .htaccess files.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
Re: Stopping HTML via Perl
by Zaxo (Archbishop) on Dec 28, 2002 at 22:19 UTC

    I'm unaware of any way to make httpd give up serving a page midway through with SSI. Perhaps you would do better to look into the server's authentication mechanisms. Those are more a matter of configuration than of cgi.

    After Compline,
    Zaxo

      Ok thanks. I have a friend that gave me what I needed in PHP, so I'll probably end up putting some PHP in there, instead of config'ing with things that are over my head atm.