3 lines (of correct syntax) is all that's required:
1. how to include text output of a perl script in webpage
(it's
<!-- #include virtual="myscript.pl" -->
or something.. iirc)
2. the name of the environment variable that gives the time on the
local server
($ENV{Local_Time} or something?)
3. the name of an environment variable from which I could deduce as
accurately as possible, the country from which the web page request
originated
($ENV{HTTP_REFERER}) ??
(I'm writing a short script to only display a contact telephone number
between 9am & 5pm when the page was requested from within the UK,
otherwise display a contact form - but can't quite remember the correct
syntax) |
Clarification of Question by
gan-ga
on
03 Jan 2003 13:34 PST
pseudocode so far, any help to get this done quickly appreciated.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
domainextension = regex on $ENV{'original request from'}
timenow = regex on $ENV{'servers local time'} & convert to numeric variable
if(domainextension=='co.uk'&& timenow >= 900 && timenow <= 1700){
print "Please contact me on xxxxx xxx xxx";
}
else
{
print "<form action ='./cgi-bin/contactform.pl'>\n";
print "Enter email <input type='text' size='30'><br>\n";
print "Enter comment <input type='text' size='30'\n";
print "</form>\n";
}
|
Request for Question Clarification by
jes5199-ga
on
03 Jan 2003 13:39 PST
what web server are you using?
some of these things are done differently with different servers
so, are you using Apache or Microsoft or something else?
~jes5199-ga
|
Clarification of Question by
gan-ga
on
03 Jan 2003 13:50 PST
Hello jes5199,
Unix / Apache as far as I'm aware. I'll check and post back as soon as
I can, give me a few minutes..
Here's what I have so far, can you help me out with getting hold of
the current time on my server & deciding if it's between 9am and 5pm
(the localtime environment variable & maybe a couple of regexes on
it)?
Cheers
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$domainextension = $ENV{'REMOTE_HOST'};
$domainextension =~ tr/A-Z/a-z/;
$domainextension =~ s/.*\.//;
$timenow = regex on $ENV{'servers local time'} & convert 24 hr clock
to 4 digit numeric variable
if($domainextension=='uk'&& $timenow >= 900 && $timenow <= 1700){
print "Please contact me on xxxxx xxx xxx";
}
else
{
print "<form action ='./cgi-bin/contactform.pl'>\n";
print "Enter email <input type='text' size='30'><br>\n";
print "Enter comment <input type='text' size='30'\n";
print "</form>\n";
}
|
Clarification of Question by
gan-ga
on
03 Jan 2003 13:53 PST
Yes, Unix & Apache/1.3.22 Server
|
Clarification of Question by
gan-ga
on
03 Jan 2003 14:15 PST
Just tested the code, works on my server so far. I can see I might run
into trouble deciding on a user's whereabouts on the basis of
REMOTE_HOST, but that's not too important. Avoiding displaying a
contact phone number at night, based on the server's time, is the
really important thing.
I'm stumped now.. over to you?
|