#!/usr/bin/perl -w

use CGI qw(:standard);

if (param()) {
	$teksti = param('teksti');
	$teksti =~ s\&\&amp;\g;
	$teksti =~ s\<\&lt;\g;
	$teksti =~ s\>\&gt;\g;

	$font = param('font');
	$size = param('size');
	$color = param('color');
	$x = int(rand(100));
	$y = int(rand(100));
#	$url = param('url');
	$z = int(rand(100));
	
    open(NFILE, ">> tekstit.ssi") or print "Virhe: $!";

    flock(NFILE, 2);


print NFILE <<OMAA;
<div style='font-family: "$font"; color: $color; font-size: $size; position: absolute; left: $x%; top: $y%; z-index: $z'>
$teksti
</div>
OMAA

    flock(NFILE, 8);

print "Location: ./\n";
    	print "Content-type: text/html\n\n";
print '<html><head><title>WC:n seinä</title></head><body><h1><a href="./">WC:n seinä</a></h1></body></html>';


}

else {

print STDOUT <<OMAA;
Content-type: text/html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>Ei löydy</title>
</head>
<body>
<h1>Ei löydy</h1>
OMAA

}
