first commit

This commit is contained in:
Bildcraft1 2024-10-31 10:47:12 +01:00
commit d975e212f9
35 changed files with 813 additions and 0 deletions

View file

@ -0,0 +1,42 @@
<?php
session_start();
$votes = json_decode(file_get_contents("votes.json"), true);
function checkPost()
{
if (empty($_POST["nome"]) || empty($_POST["code"]) || empty($_POST["film"]) || empty($_POST["voto"])) {
$_SESSION["error"] = true;
header("Location: login.php");
exit();
}
if (trim($_POST["code"]) !== "a123") {
$_SESSION["error"] = true;
header("Location: login.php");
exit();
}
}
function checkSession()
{
if (empty($_SESSION["nome"]) || empty($_SESSION["code"]) || empty($_SESSION["film"]) || empty($_SESSION["voto"])) {
$_SESSION["error"] = true;
header("Location: login.php");
exit();
}
}
function checkHasVoted()
{
if (isset($_COOKIE["hasVoted"]) && $_COOKIE["hasVoted"]) {
$_SESSION["error"] = true;
return false;
}
return true;
}
function addVote($film, $vote)
{
global $votes;
$votes[$film] += $vote;
file_put_contents("votes.json", json_encode($votes));
}