How would I do that in cgi - something I could put, perhaps, in footer.shtml?
Your statement is somewhat contradictory. CGI/PERL is on the server. Anything in the footer is client-side on the browser like Javascript.
There are a few ways to do what you want...
JavascriptIn your header file, in one of your Javascripts, you can set a Javascript variable with an SSI call. You'll only need the single line in blue if you put it inside an existing JS. SSI will either work on your server or it won't... just try it.
<script language="JavaScript"><!--
portSSL = "<!--#echo var="SERVER_PORT" -->";
//-->
</script>
The port will be either 443 (https) or 80 (http). That "portSSL" variable will be just the number 80 or 443.
Then in your footer, you can run your if/then logic using Javascript.
ALTERNATELY....
PERLYou can write your own CGI/PERL script or modify one of the TTX modules.
Just reference the server environment variable directly within the PERL program.
$ENV{SERVER_PORT};
Then run your if/then login within the PERL
OR ALTERNATELY AGAIN...
PERL/Javascript comboYou could use some combination of the two by passing variables between the CGI/PERL on the server and the Javascript in the browser. Using SSI to call the function maybe and macros to pass some variables back into the Javascript.
And depending on what your IF/THEN is supposed to do:
You could just edit the .htaccess file (Unix) on the server to do all sorts of neat re-direct tricks depending on the URL. Unfortunately it ignores the port number as far as I know BUT if you're on a shared SSL certificate, your entire URL will be different anyway.