second commit
This commit is contained in:
parent
d975e212f9
commit
12d8e33009
9 changed files with 266 additions and 0 deletions
42
similverifica_votazioni_atleti/includes/security.php
Normal file
42
similverifica_votazioni_atleti/includes/security.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
session_start();
|
||||
function checkPost()
|
||||
{
|
||||
unset($_SESSION["error"]);
|
||||
|
||||
if (empty($_POST["nome"]) || empty($_POST["eta"]) || empty($_POST["sesso"])) {
|
||||
$_SESSION["error"] = "Dati mancanti";
|
||||
}
|
||||
|
||||
if ($_POST["eta"] < 18) {
|
||||
$_SESSION["error"] = "Devi avere 18 anni per entrare";
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue