pearweb_election
[ class tree: pearweb_election ] [ index: pearweb_election ] [ all elements ]

Source for file info.php

Documentation is available at info.php

  1. <?php
  2. if (!isset($auth_user|| !$auth_user{
  3.     if (isset($_GET['vote'])) {
  4.         if (strlen($_SERVER['QUERY_STRING'])) {
  5.             $query '?' strip_tags($_SERVER['QUERY_STRING']);
  6.         else {
  7.             $query '';
  8.         }
  9.  
  10.         require PEARWEB_TEMPLATEDIR . '/election/register.tpl.php';
  11.  
  12.         exit;
  13.     }
  14. }
  15.  
  16. require 'election/pear-voter.php';
  17.  
  18. $voter &new PEAR_Voter;
  19.  
  20. if (isset($_POST['confirm'])) {
  21.     // display vote confirmation page
  22.     if (!$voter->electionExists($_POST['election'])) {
  23.         $currentelections $voter->listCurrentElections();
  24.         $completedelections $voter->listCompletedElections();
  25.         $allelections $voter->listAllElections();
  26.         $error 'No such election id: ' htmlspecialchars($_GET['election']);
  27.         $retrieval = false;
  28.         $old = false;
  29.         require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  30.         exit;
  31.     }
  32.  
  33.     if ($voter->hasVoted($_POST['election'])) {
  34.         $currentelections $voter->listCurrentElections();
  35.         $completedelections $voter->listCompletedElections();
  36.         $allelections $voter->listAllElections();
  37.         $error 'You have already voted in this election';
  38.         $retrieval = false;
  39.         $old = false;
  40.         require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  41.         exit;
  42.     }
  43.  
  44.     $info $voter->electionInfo($_POST['election']);
  45.  
  46.     if (!isset($_POST['vote'])) {
  47.         $_POST['vote'= array();
  48.     }
  49.  
  50.     if (isset($_POST['abstain'])) {
  51.         $info['abstain'= true;
  52.         $info['vote'= array();
  53.     else {
  54.         if (!is_array($_POST['vote'])) {
  55.             $_POST['vote'= array($_POST['vote']);
  56.         }
  57.         if (count($_POST['vote']$info['minimum_choices'||
  58.               count($_POST['vote']$info['maximum_choices']{
  59.             $error 'You voted for ' count($_POST['vote']' choices, but must vote ' .
  60.                 'for at least ' $info['minimum_choices'' choices, and at most ' .
  61.                 $info['maximum_choices'' choices';
  62.             require PEARWEB_TEMPLATEDIR . '/election/dovote.tpl.php';
  63.             exit;
  64.         }
  65.         $info['abstain'= false;
  66.         $info['vote'$_POST['vote'];
  67.     }
  68.  
  69.     require PEARWEB_TEMPLATEDIR . '/election/confirm.tpl.php';
  70.     exit;
  71. }
  72.  
  73. if (isset($_POST['finalvote'])) {
  74.     // vote has been confirmed
  75.     // generate salt for hash
  76.     if (!$voter->electionExists($_POST['election'])) {
  77.         $currentelections $voter->listCurrentElections();
  78.         $completedelections $voter->listCompletedElections();
  79.         $allelections $voter->listAllElections();
  80.         $error 'No such election id: ' htmlspecialchars($_GET['election']);
  81.         $retrieval = false;
  82.         $old = false;
  83.  
  84.         require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  85.  
  86.         exit;
  87.     }
  88.  
  89.     if ($voter->hasVoted($_POST['election'])) {
  90.         $currentelections $voter->listCurrentElections();
  91.         $completedelections $voter->listCompletedElections();
  92.         $allelections $voter->listAllElections();
  93.         $error 'You have already voted in this election';
  94.         $retrieval = false;
  95.         $old = false;
  96.  
  97.         require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  98.  
  99.         exit;
  100.     }
  101.  
  102.     if (!isset($_POST['vote']|| !is_array($_POST['vote'])) {
  103.         $_POST['vote'= array();
  104.     }
  105.  
  106.     if (!isset($_POST['abstain'])) {
  107.         $_POST['abstain'= false;
  108.     }
  109.  
  110.     $info $voter->electionInfo($_POST['election']);
  111.     $info['vote'$_POST['vote'];
  112.     $info['abstain'$_POST['abstain'];
  113.     $salt $voter->getVoteSalt();
  114.  
  115.     if ($info['abstain']{
  116.         $success $voter->abstain($_POST['election']);
  117.     else {
  118.         $success $voter->vote($_POST['election']$_POST['vote']);
  119.     }
  120.  
  121.     require PEARWEB_TEMPLATEDIR . '/election/confirmed.tpl.php';
  122.  
  123.     exit;
  124. }
  125.  
  126. if (!isset($_GET['election'])) {
  127.     $old = isset($_GET['oldones']);
  128.  
  129.     // display summary
  130.     $currentelections $voter->listCurrentElections();
  131.     $completedelections $voter->listCompletedElections($old);
  132.     $allelections $voter->listAllElections();
  133.     $retrieval = false;
  134.  
  135.  
  136.     require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  137.  
  138.     exit;
  139. }
  140.  
  141. if (!$voter->electionExists($_GET['election']&& is_int($_GET['election'])) {
  142.     // display summary
  143.     $currentelections $voter->listCurrentElections();
  144.     $completedelections $voter->listCompletedElections();
  145.     $allelections $voter->listAllElections();
  146.     $error 'No such election id: ' htmlspecialchars($_GET['election']);
  147.     $retrieval = false;
  148.     $old = false;
  149.  
  150.     require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  151.  
  152.     exit;
  153. }
  154.  
  155. if (isset($_GET['vote'])) {
  156.     $info $voter->electionInfo($_GET['election']);
  157.  
  158.     if ($voter->hasVoted($_GET['election'])) {
  159.         $currentelections $voter->listCurrentElections();
  160.         $completedelections $voter->listCompletedElections();
  161.         $allelections $voter->listAllElections();
  162.         $error 'You cannot vote twice in the same election';
  163.         $retrieval = false;
  164.         $old = false;
  165.  
  166.         require PEARWEB_TEMPLATEDIR . '/election/vote.tpl.php';
  167.  
  168.         exit;
  169.     elseif ($voter->pendingElection($_GET['election'])) {
  170.         $info $voter->electionInfo($_GET['election']);
  171.  
  172.         require PEARWEB_TEMPLATEDIR . '/election/pending.tpl.php';
  173.     elseif ($voter->canVote($_GET['election'])) {
  174.         require PEARWEB_TEMPLATEDIR . '/election/dovote.tpl.php';
  175.     else {
  176.         $info $voter->electionInfo($_GET['election']);
  177.  
  178.         require PEARWEB_TEMPLATEDIR . '/election/showresults.tpl.php';
  179.     }
  180. }
  181.  
  182. if (isset($_GET['results'])) {
  183.     $info $voter->electionInfo($_GET['election']);
  184.  
  185.     require PEARWEB_TEMPLATEDIR . '/election/showresults.tpl.php';
  186. }
  187.  
  188. response_footer();

Documentation generated on Mon, 11 Mar 2019 15:34:35 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.