-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparagraphe_old.php
118 lines (95 loc) · 4.87 KB
/
paragraphe_old.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php $page = "paragraphe";
include("entete.php");
$idMarquePage =0;
if ($_SESSION["connected"]) {
if(isset($_GET['id']) && isset($_SESSION['id_histoire_enCours'])){
$id_parag = htmlspecialchars($_GET['id']);
// Vérification de si il y a réellement un paragraphe, si oui on l'affiche, si non, on a un code erreur
$reqTest = "SELECT * from paragraphe WHERE id_histoire = ?";
$prepTest = $BDD -> prepare ($reqTest);
$prepTest -> execute(array($_SESSION['id_histoire_enCours']));
$tabTest = $prepTest -> fetchAll();
$test = false;
foreach ($tabTest as $key => $ligne){
if($ligne['parag_numero']==$_GET['id']){
$test = true;
}
}
if($test == false){
$_SESSION['erreur_histoire'] = true;
header('Location: histoire.php?id='.$_SESSION['id_histoire_enCours']);
}
// =============================================== //
$reqParag = "SELECT * FROM paragraphe WHERE id_histoire=? AND parag_numero=?";
$prepParag = $BDD -> prepare($reqParag);
$prepParag -> execute(array($_SESSION['id_histoire_enCours'],$id_parag));
$ligneParag = $prepParag ->fetch();
$verifExistence = "SELECT * FROM marquePage WHERE id_user = ?";
$prep = $BDD -> prepare($verifExistence);
$prep-> execute(array($_SESSION["id_user"]));
$tab = $prep->fetchAll();
$test = false;
//$n = $prep->rowCount();
foreach ($tab as $key => $ligneMarquePage ){
$verif = "SELECT * FROM paragraphe WHERE id=?";
$prep = $BDD -> prepare($verif);
$prep-> execute(array($ligneMarquePage["id_paragraphe"]));
$ligne = $prep->fetch();
if($ligne['id_histoire']==$_SESSION['id_histoire_enCours']){
$verifUser= "UPDATE marquePage SET id_paragraphe=? WHERE id_user=? AND id_paragraphe=? ";
$prepUser = $BDD -> prepare($verifUser);
$prepUser -> execute(array($ligneParag["id"],$_SESSION["id_user"],$ligneMarquePage['id_paragraphe']));
$idMarquePage = $ligneMarquePage['id'];
$test = true;
break;
}
}
if ($test == false){
$verifReq = "INSERT INTO `marquePage`(id_paragraphe,id_user) VALUES (?,?)";
$prepReq = $BDD -> prepare($verifReq);
$prepReq -> execute(array($ligneParag['id'],$_SESSION["id_user"]));
$idMarquePage = $BDD->lastInsertId();
}
$verif = "SELECT * FROM paragraphe WHERE parag_numero =? AND id_histoire = ?";
$prep = $BDD -> prepare($verif);
$prep-> execute(array($_GET['id'],$_SESSION['id_histoire_enCours']));
$ligne = $prep->fetch();
?>
<?php include("scripts/script_MAJ_Chemin.php"); ?>
<div class="text-center"><h2><?=$ligne["parag_nom"]?></h2></div>
<div class="container text-white">
<div class="row">
<?php if ($ligne['parag_image']!=NULL){?>
<div class="col-md-5 col-sm-7 ml-2 d-flex">
<img class="img-fluid histoireImage w-30 h-30" src="images/<?=$ligne['parag_image']?>" alt="<?=$ligne['parag_nom']?>" />
</div>
<?php }?>
<div class="col-md-7 col-sm-5 mr-2 pl-1">
<p class="p-3"><?=$ligne['parag_contenu'] ?> </p>
</div>
<div class="d-flex justify-content-around mt-4">
<?php
// Si on a indiqué qu'il y aurait une suite au paragraphe
if($ligne["suiteHistoire"] == "continuer"){
$requete = "SELECT * FROM lien WHERE id_parag_debut =? AND id_histoire=?";
$prep = $BDD -> prepare($requete);
$prep-> execute(array($_GET['id'], $_SESSION['id_histoire_enCours']));
$tab = $prep->fetchAll();
foreach ($tab as $key => $ligneLien) { ?>
<button onclick="location.href='paragraphe.php?id=<?=$ligneLien['id_parag_cible']?>'" type="button" class="btn btn-outline-info"><?=$ligneLien['lien_nomaction']?></button>
<?php
}}
else if($ligne["suiteHistoire"] == "victoire")
{?>
<button onclick="location.href='victoire.php?id=<?=$idMarquePage?>'" type="button" class="btn btn-outline-success">Continuer</button>
<?php }
else{ ?>
<button onclick="location.href='defaite.php?id=<?=$idMarquePage?>'" type="button" class="btn btn-outline-warning">Continuer</button>
<?php }
?>
</div>
</div>
</div>
<?php } ?>
<?php }
include("footer.php") ?>