finished similverifica atleti

This commit is contained in:
Bildcraft1 2024-11-06 21:12:42 +01:00
parent 185f31601e
commit ba05612a57
5 changed files with 74 additions and 12 deletions

View file

@ -14,18 +14,36 @@ function createVotesDb()
if (empty($votes)) {
$votes = [
"Pellegrini" => 0,
"Egonu" => 0,
"Vio" => 0,
"Totti" => 0,
"Tamberi" => 0,
"Rossi" => 0
"voto_Pellegrini" => 0,
"voto_Egonu" => 0,
"voto_Vio" => 0,
"voto_Totti" => 0,
"voto_Tamberi" => 0,
"voto_Rossi" => 0
];
file_put_contents("votes.json", json_encode($votes));
}
}
function addVote($votes, $sex)
{
// Add the vote to the counter
if (strcmp($sex, 'M') == 0) {
setcookie("votiMaschili", $_COOKIE['votiMaschili'] + 1, time() + 60 * 60 * 24 * 30);
} else {
setcookie("votiFemminili", $_COOKIE['votiFemminili'] + 1, time() + 60 * 60 * 24 * 30);
}
foreach ($votes as $key => $value) {
global $votes;
$votes[$key] += $value;
}
file_put_contents("votes.json", json_encode($votes));
}
function checkPost()
{
unset($_SESSION["error"]);
@ -46,8 +64,8 @@ function checkPost()
function checkSession()
{
if (empty($_SESSION["nome"]) || empty($_SESSION["code"]) || empty($_SESSION["film"]) || empty($_SESSION["voto"])) {
$_SESSION["error"] = true;
if (empty($_SESSION["nome"]) || empty($_SESSION["sesso"])) {
$_SESSION["error"] = "Errore interno (Sessione non trovata)";
header("Location: login.php");
exit();
}