Game-Jaming/Backend/Controllers/Polls/Vote.php

30 lines
539 B
PHP
Raw Normal View History

2021-03-12 13:05:31 +00:00
<?php
2021-03-16 11:46:44 +00:00
require_once "../../../bootstrap.php";
2021-04-19 07:15:15 +00:00
2021-03-12 13:05:31 +00:00
use \Backend\Models\Group;
/**
* @param string $voteId
* @return bool
*/
function VoteCheck(string $voteId): bool
{
$votes = array();
2021-04-19 07:15:15 +00:00
if (isset($_COOKIE["VotingReg"])) {
2021-03-12 13:05:31 +00:00
$votes = unserialize($_COOKIE["VotingReg"]);
2021-04-19 07:15:15 +00:00
foreach ($votes as $vote) {
2021-03-12 13:05:31 +00:00
2021-04-19 07:15:15 +00:00
if ($voteId === $vote) {
2021-03-12 13:05:31 +00:00
return false;
}
}
}
2021-04-19 07:15:15 +00:00
array_push($votes, $voteId);
2021-03-12 13:05:31 +00:00
setcookie("VotingReg", serialize($votes), time() + 86400, "/");
return true;
}