first commit
This commit is contained in:
commit
d975e212f9
35 changed files with 813 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.idea
|
13
h1-h6.php
Normal file
13
h1-h6.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
for($i = 1; $i <= 6; $i++){
|
||||||
|
echo "<h$i> Ciao mamma </h$i>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
36
login/amici.php
Normal file
36
login/amici.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
include('includes/security.php');
|
||||||
|
global $users;
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"])) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php require "includes/navbar.php" ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Lista Amici</h1>
|
||||||
|
<h2>Ecco i tuoi amici</h2>
|
||||||
|
|
||||||
|
<?php foreach ($users as $user => $x) { ?>
|
||||||
|
<p><?php if (strcmp($user, $_SESSION["nome"]) !== 0) echo $user ?></p>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
42
login/foto.php
Normal file
42
login/foto.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
include('includes/security.php');
|
||||||
|
global $users;
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"])) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cartella_foto = "./uploads";
|
||||||
|
$files = array_slice(scandir($cartella_foto), 2);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php require "includes/navbar.php" ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Foto dell'amministratore</h1>
|
||||||
|
<div>
|
||||||
|
<?php
|
||||||
|
foreach ($files as $file) {
|
||||||
|
echo '<a href="' . $cartella_foto . '/' . $file . '" data-fancybox="gallery" data-caption="Caption #1">';
|
||||||
|
echo '<img src="' . $cartella_foto . '/' . $file . '" alt="' . $file . '" style="width:200px;height:200px;">';
|
||||||
|
echo '</a>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
66
login/home.php
Normal file
66
login/home.php
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
include "includes/security.php";
|
||||||
|
global $users;
|
||||||
|
if ((!isset($_POST["nome"]) || !isset($_POST["password"]) and !isset($_SESSION["loggedIn"]))) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"]) || $_SESSION["loggedIn"] !== true) {
|
||||||
|
foreach ($users as $nome => $password) {
|
||||||
|
if (strcmp($nome, $_POST["nome"]) == 0 and strcmp($password, $_POST["password"]) == 0) {
|
||||||
|
$_SESSION["nome"] = $nome;
|
||||||
|
$_SESSION["loggedIn"] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($_POST["nome"], array_keys($users)) == 0) {
|
||||||
|
$users[$_POST["nome"]] = $_POST["password"];
|
||||||
|
$json = json_encode($users);
|
||||||
|
file_put_contents("users.json", $json);
|
||||||
|
$_SESSION["nome"] = $_POST['nome'];
|
||||||
|
$_SESSION["loggedIn"] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"])) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp($_SESSION["nome"], "admin") == 0) {
|
||||||
|
$_SESSION["admin"] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_COOKIE["lastSeen"])) {
|
||||||
|
setcookie("lastSeen", date("d/m/Y H:i:s"), time() + 60, "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SESSION["loggedIn"] === true) {
|
||||||
|
$_COOKIE["lastSeen"] = date("d/m/Y H:i:s");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php require "includes/navbar.php" ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Home Page</h1>
|
||||||
|
<h2>Benvenuto <?= $_SESSION["nome"] ?></h2>
|
||||||
|
<h2>L'ultima volta in cui hai fatto l'accesso: <?= $_COOKIE["lastSeen"] ?></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
8
login/includes/footer.php
Normal file
8
login/includes/footer.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
Fancybox.bind("[data-fancybox]", {
|
||||||
|
// Your custom options
|
||||||
|
});
|
||||||
|
</script>
|
7
login/includes/head.php
Normal file
7
login/includes/head.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css"
|
||||||
|
/>
|
32
login/includes/navbar.php
Normal file
32
login/includes/navbar.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<nav class="navbar navbar-expand-lg bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="#">Facebook 2</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
|
||||||
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="home.php">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="amici.php">Amici</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="foto.php">Foto</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item d-flex me-2">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['admin']) && $_SESSION['admin']) {
|
||||||
|
echo '<li class="nav-item">
|
||||||
|
<a class="nav-link" href="upload.php">Admin</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
4
login/includes/security.php
Normal file
4
login/includes/security.php
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$users = json_decode(file_get_contents("users.json"),true);
|
39
login/index.php
Normal file
39
login/index.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php require "includes/security.php" ?>
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION["error"])) {
|
||||||
|
?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
Errore! Riprova
|
||||||
|
</div>
|
||||||
|
<?php }
|
||||||
|
session_unset();
|
||||||
|
?>
|
||||||
|
<form action="home.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nome" class="form-label">Nome Utente</label>
|
||||||
|
<input type="text" class="form-control" id="nome" name="nome">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="password" class="form-label">Password</label>
|
||||||
|
<input type="password" class="form-control" id="password" name="password">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
6
login/logout.php
Normal file
6
login/logout.php
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
session_destroy();
|
||||||
|
|
||||||
|
header('Location: index.php');
|
||||||
|
exit();
|
46
login/register.php
Normal file
46
login/register.php
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
include "includes/security.php";
|
||||||
|
global $users;
|
||||||
|
|
||||||
|
if ((!isset($_POST["nome"]) || !isset($_POST["password"]) and !isset($_SESSION["loggedIn"]))) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"]) || $_SESSION["loggedIn"] !== true) {
|
||||||
|
foreach ($users as $nome => $password) {
|
||||||
|
if (strcmp($nome, $_POST["nome"]) == 0 and strcmp($password, $_POST["password"]) == 0) {
|
||||||
|
$_SESSION["nome"] = $nome;
|
||||||
|
$_SESSION["loggedIn"] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"])) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php require "includes/navbar.php" ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Home Page</h1>
|
||||||
|
<h2>Benvenuto <?= $_SESSION["nome"] ?></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
94
login/upload.php
Normal file
94
login/upload.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
include('includes/security.php');
|
||||||
|
global $users;
|
||||||
|
|
||||||
|
if (!isset($_SESSION["loggedIn"]) and !isset($_SESSION["admin"])) {
|
||||||
|
$_SESSION["error"] = true;
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$_SESSION["admin"]) {
|
||||||
|
header("Location: index.php");
|
||||||
|
exit();
|
||||||
|
} else if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
$target_dir = "uploads/";
|
||||||
|
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
|
||||||
|
$uploadOk = 1;
|
||||||
|
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
// Check if image file is a actual image or fake image
|
||||||
|
if (isset($_POST["submit"])) {
|
||||||
|
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
||||||
|
if ($check !== false) {
|
||||||
|
echo "File is an image - " . $check["mime"] . ".";
|
||||||
|
$uploadOk = 1;
|
||||||
|
} else {
|
||||||
|
echo "File is not an image.";
|
||||||
|
$uploadOk = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file already exists
|
||||||
|
if (file_exists($target_file)) {
|
||||||
|
echo "Sorry, file already exists.";
|
||||||
|
$uploadOk = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check file size
|
||||||
|
if ($_FILES["fileToUpload"]["size"] > 500000) {
|
||||||
|
echo "Sorry, your file is too large.";
|
||||||
|
$uploadOk = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow certain file formats
|
||||||
|
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
|
||||||
|
&& $imageFileType != "gif" && $imageFileType != "mp4") {
|
||||||
|
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
|
||||||
|
$uploadOk = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if $uploadOk is set to 0 by an error
|
||||||
|
if ($uploadOk == 0) {
|
||||||
|
echo "Sorry, your file was not uploaded.";
|
||||||
|
// if everything is ok, try to upload file
|
||||||
|
} else {
|
||||||
|
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
|
||||||
|
echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded.";
|
||||||
|
} else {
|
||||||
|
echo "Sorry, there was an error uploading your file.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php require "includes/navbar.php" ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Upload di Foto</h1>
|
||||||
|
<div class="mb-3">
|
||||||
|
<form method="post" action="upload.php" enctype="multipart/form-data">
|
||||||
|
<label for="formFile" class="form-label">Default file input example</label>
|
||||||
|
<input class="form-control" type="file" name="fileToUpload" id="fileToUpload">
|
||||||
|
<button type="submit" class="btn btn-primary">Carica il File</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
BIN
login/uploads/photo_2023-06-20_03-40-00.jpg
Normal file
BIN
login/uploads/photo_2023-06-20_03-40-00.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 106 KiB |
BIN
login/uploads/photo_2024-10-07_19-50-24.jpg
Normal file
BIN
login/uploads/photo_2024-10-07_19-50-24.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
1
login/users.json
Normal file
1
login/users.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"admin":"admin","mario":"sturniolo"}
|
27
nomi-voti.php
Normal file
27
nomi-voti.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Nome</td>
|
||||||
|
<td>Voto</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
$voti = array("Piero"=>3, "Paolo"=>9, "Luca"=>7, "Roberto"=>3);
|
||||||
|
$media = 0;
|
||||||
|
foreach($voti as $name => $voto){
|
||||||
|
$media+= $voto;
|
||||||
|
echo "<tr>
|
||||||
|
<td>$name</td>
|
||||||
|
<td>$voto</td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
$media = $media / count($voti);
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo $media;
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
</html>
|
26
prestito/conferma.php
Normal file
26
prestito/conferma.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Conferma</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Riepilogo del Prestito</h1>
|
||||||
|
<p>Nome: <?= $_SESSION["nome"] ?></p>
|
||||||
|
<p>Cognome: <?= $_SESSION["cognome"] ?></p>
|
||||||
|
<p>Prestito: <?= $_SESSION["cifra"] ?>€</p>
|
||||||
|
<p>Durata: <?php if($_SESSION["prestito"] == 1) echo "Prestito Mensile"; else echo "Prestito Annuale"?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
13
prestito/errore.php
Normal file
13
prestito/errore.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Prestito</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="bg-danger">
|
||||||
|
<h2> Errore dati insufficienti </h2>
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
3
prestito/includes/footer.php
Normal file
3
prestito/includes/footer.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||||
|
crossorigin="anonymous"></script>
|
2
prestito/includes/head.php
Normal file
2
prestito/includes/head.php
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
27
prestito/index.php
Normal file
27
prestito/index.php
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Prestito</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Banca Bruschetta</h1>
|
||||||
|
<h2>Form Prestito</h2>
|
||||||
|
<form action="prestito.php" method="post">
|
||||||
|
Name: <input type="text" name="nome"><br>
|
||||||
|
Cognome: <input type="text" name="cogn"><br><br>
|
||||||
|
Prestito Annuale <input type="radio" name="prestito" value="12"> (365gg) 4%<br>
|
||||||
|
Prestito Mensile <input type="radio" name="prestito" value="1"> 830gg) 5%<br><br>
|
||||||
|
Cifra: <input type="text" name="cifra"><br><br>
|
||||||
|
<input type="submit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
39
prestito/prestito.php
Normal file
39
prestito/prestito.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!isset($_POST["prestito"]) or ($_POST["cifra"] == "")) {
|
||||||
|
header("Location: errore.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["nome"] = $_POST["nome"];
|
||||||
|
$_SESSION["cognome"] = $_POST["cogn"];
|
||||||
|
$_SESSION["prestito"] = $_POST["prestito"];
|
||||||
|
$_SESSION["cifra"] = $_POST["cifra"];
|
||||||
|
|
||||||
|
if ($_POST["prestito"] == 12) {
|
||||||
|
$temp = $_POST["cifra"] * 1.04;
|
||||||
|
} else {
|
||||||
|
$temp = $_POST["cifra"] * 1.004167;
|
||||||
|
}
|
||||||
|
$_SESSION["cifraCalcolata"] = $temp;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Prestito</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Calcolo saldo del prestito richiesto</h1>
|
||||||
|
<p>Benvenuto <?php echo $_POST["nome"] . " " . $_POST["cogn"]; ?><br>
|
||||||
|
il saldo del tuo prestito di <?php echo $_POST["cifra"] ?> tra xx giorni sarà di:
|
||||||
|
<?= $_SESSION["cifraCalcolata"] ?> €
|
||||||
|
</p>
|
||||||
|
<a class="btn btn-primary" href="conferma.php" role="button">Conferma Prestito</a>
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
8
similverifica/includes/footer.php
Normal file
8
similverifica/includes/footer.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
Fancybox.bind("[data-fancybox]", {
|
||||||
|
// Your custom options
|
||||||
|
});
|
||||||
|
</script>
|
7
similverifica/includes/head.php
Normal file
7
similverifica/includes/head.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
|
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css"
|
||||||
|
/>
|
BIN
similverifica/includes/imgs/avengers.jpg
Normal file
BIN
similverifica/includes/imgs/avengers.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
similverifica/includes/imgs/napoleon.jpg
Normal file
BIN
similverifica/includes/imgs/napoleon.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
similverifica/includes/imgs/walle.jpg
Normal file
BIN
similverifica/includes/imgs/walle.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
32
similverifica/includes/navbar.php
Normal file
32
similverifica/includes/navbar.php
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
<nav class="navbar navbar-expand-lg bg-light">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="#">Facebook 2</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
|
||||||
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="home.php">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="amici.php">Amici</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="foto.php">Foto</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item d-flex me-2">
|
||||||
|
<a class="nav-link" href="logout.php">Logout</a>
|
||||||
|
</li>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION['admin']) && $_SESSION['admin']) {
|
||||||
|
echo '<li class="nav-item">
|
||||||
|
<a class="nav-link" href="upload.php">Admin</a>
|
||||||
|
</li>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
42
similverifica/includes/security.php
Normal file
42
similverifica/includes/security.php
Normal 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));
|
||||||
|
}
|
44
similverifica/index.php
Normal file
44
similverifica/index.php
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
include "includes/security.php";
|
||||||
|
|
||||||
|
checkPost();
|
||||||
|
|
||||||
|
$_SESSION["nome"] = $_POST["nome"];
|
||||||
|
$_SESSION["code"] = $_POST["code"];
|
||||||
|
$_SESSION["film"] = $_POST["film"];
|
||||||
|
$_SESSION["voto"] = $_POST["voto"];
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php if (checkHasVoted()) { ?>
|
||||||
|
<div class="container">
|
||||||
|
<h1>Conferma Voto</h1>
|
||||||
|
<h2>Nome utente: <?php echo $_SESSION["nome"] ?></h2>
|
||||||
|
<h2>Film: <?php echo $_SESSION["film"] ?></h2>
|
||||||
|
<h2>Voto: <?php echo $_SESSION["voto"] ?></h2>
|
||||||
|
<form action="thanks.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nome" class="form-label">Vuoi confermare il voto?</label>
|
||||||
|
<button type="submit" class="btn btn-primary">Invia voto</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php } else { ?>
|
||||||
|
<script>
|
||||||
|
alert("Hai già votato, non puoi votare una seconda volta")
|
||||||
|
window.location.href = "login.php"
|
||||||
|
</script>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
64
similverifica/login.php
Normal file
64
similverifica/login.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php require "includes/security.php" ?>
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<h3><a href="statistics.php">Statistiche</a></h3>
|
||||||
|
<?php
|
||||||
|
if (isset($_SESSION["error"])) {
|
||||||
|
?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
Errore! Riprova
|
||||||
|
</div>
|
||||||
|
<?php }
|
||||||
|
session_destroy();
|
||||||
|
?>
|
||||||
|
<form action="index.php" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nome" class="form-label">Nome Utente</label>
|
||||||
|
<input type="text" class="form-control" id="nome" name="nome">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nome" class="form-label">Codice di accesso</label>
|
||||||
|
<input type="password" class="form-control" id="code" name="code">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<figure class="figure">
|
||||||
|
<img src="includes/imgs/avengers.jpg" class="figure-img img-fluid rounded" alt="...">
|
||||||
|
<figcaption class="figure-caption">A caption for the above image.</figcaption>
|
||||||
|
</figure>
|
||||||
|
<figure class="figure">
|
||||||
|
<img src="includes/imgs/walle.jpg" class="figure-img img-fluid rounded" alt="...">
|
||||||
|
<figcaption class="figure-caption">A caption for the above image.</figcaption>
|
||||||
|
</figure>
|
||||||
|
<figure class="figure">
|
||||||
|
<img src="includes/imgs/napoleon.jpg" class="figure-img img-fluid rounded" alt="...">
|
||||||
|
<figcaption class="figure-caption">A caption for the above image.</figcaption>
|
||||||
|
</figure>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label for="film">Seleziona il fim da votare:</label>
|
||||||
|
<select name="film" id="film">
|
||||||
|
<option value="avengers">avengers</option>
|
||||||
|
<option value="walle">walle</option>
|
||||||
|
<option value="napoleon">napoelon</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<input type="number" id="voto" name="voto" min="1" max="5"/>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">Invia voto</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
49
similverifica/statistics.php
Normal file
49
similverifica/statistics.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
global $votes;
|
||||||
|
include "includes/security.php";
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Statistiche dei voti</h1>
|
||||||
|
<canvas id="statistiche"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ctx = document.getElementById('statistiche');
|
||||||
|
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: ['Avengers', 'Wall-E', 'Napoleon'],
|
||||||
|
datasets: [{
|
||||||
|
label: '# of Votes',
|
||||||
|
data: [<?= $votes["avengers"] ?>, <?= $votes["walle"] ?>, <?= $votes["napoleon"] ?>,],
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
34
similverifica/thanks.php
Normal file
34
similverifica/thanks.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
include "includes/security.php";
|
||||||
|
|
||||||
|
checkSession();
|
||||||
|
|
||||||
|
if (!isset($_COOKIE["hasVoted"])) {
|
||||||
|
setcookie("hasVoted", true, time() + 60, "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
addVote($_SESSION["film"], $_SESSION["voto"]);
|
||||||
|
|
||||||
|
session_destroy();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Login</title>
|
||||||
|
<?php require "includes/head.php" ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>Grazie per aver votato</h1>
|
||||||
|
<h2>Per controllare i voti controlla la pagina <a href="statistics.php">statistiche</a></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require "includes/footer.php" ?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
1
similverifica/votes.json
Normal file
1
similverifica/votes.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"avengers":9,"walle":2,"napoleon":3}
|
Loading…
Add table
Reference in a new issue