my $template;
+sub setprotocolparam {
+ {
+ no warnings 'uninitialized';
+ if( length $ENV{HTTPS} ) {
+ $template->param(PROTOCOL => "https");
+ }
+ else {
+ $template->param(PROTOCOL => "http");
+ }
+ }
+}
+
sub printpage {
$template->param(COINLIFETIME => $COINLIFETIME);
$template->param(FLIPPEDCOINSINDB => $flippedcoinsindb);
$template->param(COINSINDB => $coinsindb);
- $template->param(HTTP_HOST => $ENV{HTTP_HOST});
+
+ my $rootloc = $ENV{SCRIPT_FILENAME};
+ $rootloc =~ s/$ENV{DOCUMENT_ROOT}//g;
+ $rootloc =~ s/\/[^\/]*$//g;
+ $template->param( ROOTURL => $ENV{HTTP_HOST} . $rootloc );
+
print "Content-type: text/html\n\n", $template->output;
}
$template = HTML::Template->new(filename => 'created.html');
$template->param(NEWCOINID => $newcoinid);
+ setprotocolparam();
}
elsif ( length($requestedcoinid) > 0 ) {
if ( ! exists $coins_db{$requestedcoinid} ) {
$template->param(REQUESTEDCOINID => $requestedcoinid);
$template->param(COINCREATIONTIME => localtime($coininfo[0])."");
+ setprotocolparam();
if ( $coininfosize == 1 && $requestedaction eq "" ) {
$template->param(STATUS_NOTYETFLIPPED => 1);
patchme@flipacoin.org</a>.
</font>
<hr>
-<h3><a href=/><font color=black><!-- TMPL_VAR NAME=HTTP_HOST --></font></a> - The Internet's first two-party coinflipping service.</h3>
+<h3><a href=/><font color=black><!-- TMPL_VAR NAME=ROOTURL --></font></a> - The Internet's first two-party coinflipping service.</h3>
<a href=/<!-- TMPL_VAR NAME=NEWCOINID -->>
<font style="BACKGROUND-COLOR: yellow" color=blue>
- <b>http://<!-- TMPL_VAR NAME=HTTP_HOST -->/<!-- TMPL_VAR NAME=NEWCOINID --></b></font></a>
+ <b><!-- TMPL_VAR NAME=PROTOCOL -->://<!-- TMPL_VAR NAME=ROOTURL -->/<!-- TMPL_VAR NAME=NEWCOINID --></b></font></a>
for you.<br><br>
Send the coin to the other party and tell them to flip it to make a decision.
<a href=/<!-- TMPL_VAR NAME=REQUESTEDCOINID -->>
<font style="BACKGROUND-COLOR: yellow" color=blue>
- <b>http://<!-- TMPL_VAR NAME=HTTP_HOST -->/<!-- TMPL_VAR NAME=REQUESTEDCOINID --></b></font></a>
+ <b><!-- TMPL_VAR NAME=PROTOCOL -->://<!-- TMPL_VAR NAME=ROOTURL -->/<!-- TMPL_VAR NAME=REQUESTEDCOINID --></b></font></a>
<br>