User Control Panel
Advertisements

HELP US, HELP YOU!

CGI caller?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Fri Mar 25, 2005 7:28 pm    Post subject: Reply with quote

How would you find out whether or not a CGI file (.pl or .cgi) is being required by another file or is being executed by itself?

For example, if you had an index.cgi and it requires settings.pl for all its configuration (for example, YaBB forum does this). And so if settings.pl is accessed all by itself, it would print something out (maybe redirecting you back to index.cgi), but if index.cgi requires it, it won't print that.

What I tried so far was something like this:
Code:
if ($0 eq 'settings.pl') {<br />   print "Content-Type: text/html\r\n\r\n";<br />   print "<b>error:</b> use index.cgi instead.";<br />   exit(0);<br />}


The idea was that if index.cgi required settings.pl, $0 would equal 'index.cgi' - but $0 isn't only the file's name, it's the path on the server (like G:\www-aichaos\new\settings.pl on my local server and like /home/public_html/new/settings.pl on a remote host).

Are there any other ways to find out whether or not a file is being executed alone or from another file?

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Fri Mar 25, 2005 11:16 pm    Post subject: Reply with quote

rather than

print "Content-Type: text/html\r\n\r\n";

you can do this

print header;

if you are using CGI.pm.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group