NAME
HTML::Ballot::Trusting - HTML-template-based insercure multiple-choice ballot
SYNOPSIS
See "SETTING UP A POLL".
DESCRIPTION
A simple module for inseucre web ballots.
a HTML page of voting options and one of the results of votes so far is generated from a single HTML template, and it is in these pages that ballot status is maintained, so no additional file access is required. This may be extended to include a ballot `time out'.
HTML output into the template is minimal, but all unique entities are given a
class
attribute for easy CSS re-definitions.simple bar charts of results are generated using HTML. Options to have graphs based on single-pixels, or using the
GD
interface will arrive some time in the future.no test is made of who is voting, so users may vote any number of times, or may even vote (and surely will) thousands of times using a
LWP
hack. A more secure version is being constructed, which uses simple e-mail authentication of users, sending ony one voting password to any e-mail address: this may appear asHTML::Ballot::MoreCynical
.
SYNOPSIS
There are three steps to creating a poll:
Create an HTML template file containing the following element inserted where the questions and answers are to be pasted:
<TEMPLATEITEM name='QUESTIONS'></TEMPLATEITEM>
Construct a new HTML::Ballot::Trusting object, and call upon it the
create
method:use HTML::Ballot::Trusting; my $p = new HTML::Ballot::Trusting { RPATH => 'E:/www/leegoddard_com/vote/results.html', SUBMITTO => 'http://localhost/leegoddard_com/vote/vote.pl', TPATH => 'E:/www/leegoddard_com/vote/template.html', QPATH => 'E:/www/leegoddard_com/vote/vote.html', QUESTIONS => [ 'Why?', 'Why not?', 'Why what?' ] }; $p->create(); exit;
See "CONSTRUCTOR (new)" and "METHOD create".
Create a page to call the vote (the script may yet produce such an item):
use HTML::Ballot::Trusting; use CGI; our $VOTING_PAGE = "http://localhost/leegoddard_com/vote/vote.html"; our $cgi = new CGI; if ($cgi->param() and $cgi->param('question') and $cgi->param('rpath') ){ $v = new HTML::Ballot::Trusting ( {RPATH=>$cgi->param('rpath')}); $v->cast_vote($cgi->param('question')); } else { print "Location: $VOTING_PAGE\n\n" } exit;
GLOBAL VARIABLES
CONSTRUCTOR (new)
Requires a reference to the class into which to bless, as well as a hash (or reference to such) with the following key/value content:
- ARTICLE_ROOT
-
can over-ride the global constant of the same name;
- URL_ROOT
-
can over-ride the global constant of the same name;
- QUESTIONS
-
an array of questions to use in the ballot
- TPATH
-
Path the HTML template may be found at
- QPATH
-
Path at which to save the HTML ballot page
- RPATH
-
Path at which to save the HTML results page
- SUBMITTO
-
Path to the script that processes submission of the CGI voting form
METHOD create
Creates the HTML voting page.
Accepts: just the calling object: all properties used should be set during construction (see "CONSTRUCTOR (new)").
Returns: the path to the saved HTML question document.
The template file used to generate the question and answer pages should be an HTML page with the following markup inserted at the point that the FORM
and radio-buttons should appear:
<TEMPLATEITEM name='QUESTIONS'></TEMPLATEITEM>
- QUESTION PAGE
-
The
action
attribute of theFORM
element is set to the CGI environment variable,SCRIPT_NAME
(that is, the location of this script).Form elements are simply seperated by linebreaks (
BR
): use CSS to control the layout: the radio-button HTML elements are set to be classvoteoption
; theSUBMIT
button element is set to be classvotesubmit
. - RESULTS PAGE
-
HTML is used to create bar charts, but this should be easy to replace with a
GD
image, or a stretched single-pixel. Each question is given aTEMPLATEITEM
element, and results will be placed within by thevote
method (see "METHOD vote").CSS:
voteresults
is the layer of the whole results section;votequestion
is the question on the left;votescore
is the number of votes recieved by the item;chart
is the chart....
METHOD cast_vote
Casts a vote and updates the results file.
Accepts: the question voted for, as defined in the HTML vote form's INPUT
/value
.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 201:
'=item' outside of any '=over'
- Around line 282:
You forgot a '=back' before '=head2'