#!/usr/bin/perl -w read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); $rating = substr($buffer,0,1); $table = substr($buffer,1,(length($buffer)+1)); $temp = "$table" . "ips" . ".txt"; $temp1 = "$table" . "results" . ".txt"; $ipaddress = $ENV{'REMOTE_ADDRESS'}; $IPcheck = 0; open(TABLEIP, "<$temp"); #test IP addresses while() { $thisline = $_; chomp($thisline); if($thisline == $ipaddress) { $IPcheck = 1; {last} } else { $IPcheck = 0; } } close(TABLEIP); #if ip address is already used it responds they already voted else it adds the ip address to the data list if($IPcheck == 1) { print "Content-type:text/html\n\n"; print < $table
You already voted on this table.
EndOfHTML exit (0); } else { open(TABLEIP, ">>temp"); print TABLEIP "ipaddress"; close(TABLEIP); } open(TABLERESULTS, "$temp1"); $rating = $rating + 1; $counter = 0; while() { $thisline = $_; $counter++; if($counter == 1) { $scoretotal = chomp($thisline); } if($counter == 2) { $votetotal = chomp($thisline); } if($counter > 2) { {last} } } close(TABLERESULTS); $scoretotal = $scoretotal + $rating; $votetotal = $votetotal + 1; $newrating = $scoretotal / $votetotal; print "Content-type:text/html\n\n"; print < $table
The score of this table is $newrating
There was $votetotal votes
Your rating was $rating
EndOfHTML open(TABLERESULTS, ">temp1"); $counter1 = 1; until($counter1 == 3) { if($counter1 == 1) { print TABLERESULTS "$scoretotal\n"; } if($counter1 == 2) { print TABLERESULTS "$votetotal\n"; } $counter++; } close(TABLERESULTS); }