<?php //Copyright ©2015 Anouk Stein, M.D. $getq = $_GET["q"]; include "SaveElection.php"; echo '<script src="elections.js"></script>'; connect(); $parseQ = explode("-", $getq); $q = $parseQ[0]; $functionName = $parseQ[1]; switch ($functionName) { case "showVoteInput": showVoteInput($q); break; case "saveVote": saveVote($q); break; case "saveAllForMap": saveAllForMap(); break; case "showSpreadsheet": showSpreadsheet(); break; } function showVoteInput($q) { $info = explode(".", $q); $district = $info[0]; $machine = $info[1]; echo "<center><h1 class='title'>Enter Election Results for District: <span class='big'>{$district}</span>, Machine: <span class='big'>{$machine}</span></h1></center>"; echo "<form action = './saveInputs.php' method ='post'>";
/** * This file contains xxxxxxxxxxxxxxxxxxxxxxxxxxx. * @version xxx * @package RSGallery2 * @copyright (C) 2003 - 2006 RSGallery2 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * RSGallery is Free Software */ defined('_JEXEC') or die('Direct Access to this location is not allowed.'); require_once JPATH_RSGALLERY2_SITE . '/lib/rsgvoting/rsgvoting.class.php'; $cid = rsgInstance::getInt('cid', array(0)); $task = rsgInstance::getVar('task', ''); $id = rsgInstance::getInt('id', ''); switch ($task) { case 'save': saveVote($option); break; } function test($id) { echo "<pre>"; print_r($_COOKIE); echo "</pre>"; $cookie_prefix = strval("rsgvoting_" . $id); echo $cookie_prefix; if (!isset($_COOKIE[$cookie_prefix])) { //Cookie valid for 1 year! setcookie($cookie_prefix, $id, time() + 60 * 60 * 24 * 365, "/"); } } function saveVote($option)
$ch = curl_init($url); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($doc)); curl_setopt($ch, CURLOPT_USERPWD, COUCH_USER . ":" . COUCH_PASS); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // Conflict update means someone tried to vote twice. :-( if ($code != '201') { _log("*** HTTP response code: {$code} ***"); return false; } return true; } // If the caller uses the voice channel, there is no initialText. if (!$currentCall->initialText) { $vote = ask("Please enter the number of the selection you wish to vote for.", array("choices" => "1,2,3,4,5,6", "attempts" => 3)); } else { $vote = ask("", array("choices" => "[ANY]", "attempts" => 1)); } // Save the vote. if (saveVote($currentCall->callerID, $vote->value)) { if ($currentCall->channel == "VOICE") { say("Thank you, your vote has been recorded."); } else { _log("*** Vote recorded for " . $currentCall->callerID . " ***"); } } else { say("Sorry, there was a problem saving your vote."); }