\n";
print "Go to index";
}
sub procadmin {
$submitpass = $cgiVals{'submitpass'};
if ($submitpass ne $password) {
return;
}
#figure out commands....
@newpollnames = ();
foreach $pname (@allpollnames) {
$command = $cgiVals{$pname};
if ($command eq 'activate') {
$allpollstatus{$pname} = "active";
@newpollnames = (@newpollnames, $pname);
}
if ($command eq 'deactivate') {
$allpollstatus{$pname} = "inactive";
@newpollnames = (@newpollnames, $pname);
}
if ($command eq 'delete') {
delete $allpollstatus{$pname};
delete $allpolltitles{$pname};
delete $allpollfiles{$pname};
}
}
@allpollnames = @newpollnames;
&writedatafile;
}
# printaddform
# Prints the form used to add a poll
sub printaddform {
print < ";
}
# printvoteresult
# Prints a display of a poll file after recording vote
sub printvoteresult {
$votedoption = $cgiVals{'option'};
$pollvotes[$votedoption]++;
$tally++;
&writepollfile;
&printdisplay;
}
#printindex
# Prints an index of all polls registered
sub printindex {
&readdatafile;
print < $pollquestion Poll results for....
$pollquestion
$pollquestion Please vote!
Sorry, password incorrect. No changes recorded.
\n";
return;
}
@options = split(/\n/,$newpolloptions);
@polloptions = (" ", @options);
$pollnumoptions = scalar(@polloptions) - 1;
for ($i=1; $i<=$pollnumoptions; $i++) {
$pollvotes[$i] = 0;
}
#write the new data to the new file
&writepollfile;
open(DATA, ">>$polldatafile");
print (DATA "name=$pollname\n");
print (DATA "title=$polltitle\n");
print (DATA "file=$datafile\n");
print (DATA "status=active\n");
close(DATA);
#ack to user
print "Changes recorded!
\n";
print "To view new poll, click ";
print "here
Current polls:
EndOfHTML
;
#print first item specially
$firstpoll = shift(@allpollnames);
$curpollbgcolor = "#FFCCFF";
print "
\n";
print " \n\n";
#print the rest of the polls...
foreach $pname (@allpollnames) {
print "$allpolltitles{$firstpoll} \n";
print "\n";
print "[Vote!]\n \n";
print "\n";
print "[View Results]\n \n";
print "\n";
print " \n\n";
}
print <$allpolltitles{$pname} \n";
print "\n";
if ($allpollstatus{$pname} eq 'active') {
print "[Vote!] \n";
}
else {
print "[Inactive]\n";
}
print "\n";
print "[View Results] \n";
print "
\n";
for($i=1; $i<=$pollnumoptions; $i++) {
print "$polloptions[$i]: $pollvotes[$i]
\n";
}
}
# printdisplay
# Prints a display of a poll file
sub printdisplay {
print <
$polltitle
EndOfHTML
;
#print out results
for($i=1; $i<=$pollnumoptions; $i++) {
print "
\n\n";
}
print <$polloptions[$i] \n";
print "\n";
if ($tally != 0) {
$percent = $pollvotes[$i] / $tally;
}
else {
$percent = 0;
}
$percent = $percent * 100;
$percent = int($percent);
print " $pollvotes[$i] votes ($percent%)
More polls
EndOfHTML
;
}
# printbriefballot
# Prints a *brief* ballot for a poll file
sub printbriefballot {
print <