#!/usr/bin/perl # # posServer CGI for the ZazaMap applet. # Copyright (C) 2001 Brian Rudy (brudyNO@SPAMpraecogito.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # # Requires: poslib.pl # # ## Revision History ## # 0.31 8-15-2001 # Added support for basic vote listing for debugging. # # 0.30 8-14-2001 # Replaced simple CGI form parsing with CGI::Request. Initial support # for sendgoal. Added test mode switch. Added shared goal retreival # from poslib with popgoals(). # # 0.22 8-10-2001 # Initial poslib support with poppos(), now it really works! # # 0.21 8-2-2001 # Added info URL to goals (x,y,name,URL,,) # # 0.20 7-30-2001 # Basic goal point support (x,y,name,,) # # 0.10 7-24-2001 # First working version. Random position generation for testing. # require "/home/brudy/posServer/poslib.pl"; use CGI::Request; # Simple interface: (combines SendHeaders, new and import_names) $req = GetRequest($pkg); # Full Interface: $req = new CGI::Request; # fetch and parse request # Setup data (goals) if ($req->param('setup') eq 'yes') { my @appletgoals = popgoals(); for $j (0 .. $#appletgoals) { print join(",",$appletgoals[$j]{Appletx}, $appletgoals[$j]{Applety}, $appletgoals[$j]{Name}, $appletgoals[$j]{URL}) . ",,\n"; } } # Position if ($req->param('getpos') eq 'yes') { my ($x,$y,$theta) = poppos(); printf("%.0f,", $x); printf("%.0f,", $y); printf("%.0f,,\n", $theta); } # Goal request if ($req->param('sendgoal') ne '') { my $clientip = $req->cgi->var("REMOTE_ADDR"); if ($clientip eq '') { # Bad client request. Discourage potential hackers... print "Go away"; if ($clientip ne '') { print " " . $clientip . "!"; } else { print "!"; } } else { my @appletgoals = popgoals(); my $goalreq = $req->param('sendgoal'); if (($goalreq >= 0) && ($goalreq <= $#appletgoals)) { votegoal($goalreq, $clientip); print "Registered vote for number " . $goalreq . ", " . $appletgoals[$goalreq]{Name} . ".\n"; } else { print "Sorry " . $clientip . " that goal is not available.\n"; } } } # print out formatted list of clients and the goals they voted on if ($req->param('printvotes') ne '') { my $clientip = $req->cgi->var("REMOTE_ADDR"); if (isuberclient($clientip)) { print "

Current Votes<\/h1><\/center>\n"; print "
\n";
    tallyvotes();
    print "
\n"; printvotes(); print "<\/pre>\n"; } else { print "Sorry, $clientip you are not allowed to view the vote table.\n"; } }