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
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;
GLOBAL VARIABLES
Several global variables exist as system defaults. Most may be over-riden using the constructor (see the sections ARTICLE_ROOT
, URL_ROOT
, STARTGRAPHIC
, SHEBANG
in "CONSTRUCTOR (new)".>
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
-
the root, in the filesystem, where these HTML pages begin - can over-ride the global constant of the same name;
- URL_ROOT
-
the root, on the internet, where these HTML pages begin - can over-ride the global constant of the same name;
- QUESTIONS
-
an array of questions to use in the ballot
- TPATH
-
Path at which the HTML Template may be found
- QPATH
-
Path at which to save the HTML ballot Questions' page
- RPATH
-
Path at which to save the HTML Results page
- CPATH
-
If you do not use the
SUBMITTO
attribute (below), you must use this: Path at which to save a dynamically-generated perl script that processes form submissions. Obviously must be CGI accessible and CHMOD appropriately. - SUBMITTO
-
If you do not use the
CPATH
attribute (above), you must use this: Path to the script that processes submission of the CGI voting form - SHEBANG
-
Represents the Shebang line you place at the start of your perl scrpts: set this to over-ride the default value taken from the global constant scalar of the same name. Could adjust this to suss the path from
Config.pm
or evenMakeMaker
, if it came to it, but time....
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>
The template should at least define the CSS representation for votehighscorebar
and votebar
as having a coloured background. See also "CSS REFERENCE".
- 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").See also "CSS REFERENCE".
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
.
CSS REFERENCE
votehighscorebar
andvotebar
-
the
TD
within the chart (above) that represent volume of votes cast. These must be defined for results to be visable, though if theNOHTML
flag is set in the constructor, a red background will be used as well.<style type="text/css"> <!-- .votebar { background-color: #990000} .votebar { background-color: red} --> </style>
chart
-
the right-most
TD
, containg the chartTABLE
voteresults
-
the layer of the whole results section;
votequestion
-
the left-most
TD
, containing the text representing the questions; votescore
-
the central
TD
, containing the text representing the number of votes recieved by the item; voteoptionradio
-
The radio button in the question-asking phase.
voteoptiontext
-
The text associated with radio buttons, as above.
voteoptionsubmit
-
The submit button as above.
SEE ALSO
AUTHOR
Lee Goddard (LGoddard@CPAN.org)
COPYRIGHT AND LICENCE
This module and all associated code is Copyright (C) Lee Goddard 2001. All rights reserved.
This is free software and may be used under the same terms as Perl itself with the added condition that it not be used in a commercial setting, to make money, either directly or indirectly, without the advanced and explicit prior signed permission of the author.
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 187:
'=item' outside of any '=over'
- Around line 304:
You forgot a '=back' before '=head2'
- Around line 374:
'=item' outside of any '=over'
- Around line 415:
You forgot a '=back' before '=head1'