This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prodotto.php
99 lines (92 loc) · 4.45 KB
/
prodotto.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
session_start();
require_once "PHP/class.php";
if (isset($_GET["prod"])) {
$replace = $keywords = "";
$result = Access::getProduct($_GET["prod"]);
$result1 = Access::getProductImages($_GET["prod"]);
$result3 = Access::getKeyWordsProdotto($_GET["prod"]);
if (!empty($result)) {
$nome = $result[0]['Nome'];
$desc = $result[0]['Descrizione'];
$idprod = $result[0]['id_prodotto'];
$idcat = $result[0]['id_categoria'];
$isLogged = "";
$slideshow = "";
if (!empty($result3)) {
for ($i = 0; $i < count($result3); $i++) {
if ($i == count($result3) - 1) {
$keywords .= $result3[$i]["Nome"];
} else {
$keywords .= $result3[$i]["Nome"] . ", ";
}
}
}
if (isset($_SESSION["username"])) {
$template = Access::getHeader($nome, "Lista prodotti di una categoria scelta.", "Categorie, Prodotti, Oggettistica di vetro, " . $keywords, $_SESSION["ruolo"], Access::getCategoryName($idcat), "categorie.php?cat=" . $idcat, "Prodotti", "categorie.php");
} else {
$template = Access::getHeader($nome, "Lista prodotti di una categoria scelta.", "Categorie, Prodotti, Oggettistica di vetro, " . $keywords, null, Access::getCategoryName($idcat), "categorie.php?cat=" . $idcat, "Prodotti", "categorie.php");
}
$template .= file_get_contents("HTML/prodotto.html");
if (!empty($result1)) {
$slide = '<div class="slideshow-container">
<div class="position-container">';
$dotContainer = '<div class="slideshow-dots">';
for ($i = 0; $i < count($result1); $i++) {
$slide .= "<div class=\"mySlides-home fade\">
<img src=\"" . $result[$i]["path"] . "\" alt=\"" . $result[$i]["alt_img"] . "\" width=\"400\" height=\"400\"/></div>";
$dotContainer .= '<span class="dot" data-slide-index="' . $i . '"></span>';
}
$dotContainer .= '</div>';
$slide .= '<a class="prev-home" >❮</a>
<a class="next-home">❯</a>
</div>
</div>';
$template = str_replace('<!--slideShow-->', $slide, $template);
$template = str_replace('<!--dots-->', $dotContainer, $template);
}
if (isset($_SESSION["username"]) && $_SESSION["ruolo"] != "admin") {
$result2 = Access::isInWishList($idprod, $idcat, $_SESSION["username"]);
if ($result2 == null) {
$result2 = false;
}
($result2) ? $testoButton = "Togli dalla Lista" : $testoButton = "Aggiungi alla Lista";
$isLogged = "<button type=\"button\" id=\"button\" class=\"button\">
<span class=\"button__text\" id=\"buttonid\">" . $testoButton . "</span>
</button>
<div id=\"msgWish2\" role=\"alert\"></div>";
}
$replace = array(
"Titolo" => $nome,
"Nome Prodotto" => $nome,
"Descrizione Prodotto" => $desc,
"<div>img</div>" => $slideshow,
"<!--Wish-->" => $isLogged,
'<form action="contatti.php" id="contact-form" method="post"></form>' =>
(isset($_SESSION["username"]) && $_SESSION["ruolo"] == "admin") ? "" :
'<form action="contatti.php" id="contact-form" method="post">
<fieldset>
<legend>
<h4>
Per Informazioni
</h4>
</legend>
<input type="hidden" class="product_id" name="product_id" id="product_id"
value="' . $idprod . '" />
<input type="hidden" class="categ_id" name="categoria" id="categ_id"
value="' . $idcat . '" />
<div class="submit">
<input type="submit" id="informazioni" name="informazioni_prodotto"
value="Richiedi Informazioni" />
</div>
</fieldset>
</form>'
);
} else {
header("Location: categorie.php");
}
}
foreach ($replace as $key => $value)
$template = str_replace($key, $value, $template);
echo $template;
?>