Skip to content
Snippets Groups Projects
Commit c2323f0c authored by DAprile Thomas's avatar DAprile Thomas
Browse files

Ajout cookie

parent 56c26ea6
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ RewriteEngine On
#
# RewriteBase indispensable sur webetu :
# RewriteBase /www/username0/mywishlist
#RewriteBase /www/daprile3u/ProjetPhp
#
......
......@@ -89,6 +89,7 @@ CREATE TABLE `liste` (
`description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`expiration` date DEFAULT NULL,
`token` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL
`token_edition` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
......
This diff is collapsed.
......@@ -3,3 +3,5 @@ username=root
password=
host=localhost
database=basewish
charset=utf8
collation=utf8_unicode_ci
......@@ -37,13 +37,15 @@ class CreationController {
$liste->description = $desc;
$liste->expiration = $expiration;
$liste->token = bin2hex(random_bytes(4));
setcookie("liste_cree[{$liste->token}]", "{$liste->token}");
$liste->token_edition = bin2hex(random_bytes(4));
$liste->token_partage = bin2hex(random_bytes(4));
$liste->user_id = 0;
$liste->save();
$vue = new VueCreation([$liste->toArray()], $this->containter);
$html = $vue->render(2);
$rs->getBody()->write($html);
......@@ -98,8 +100,8 @@ class CreationController {
$urlIt = filter_var($data['url'], FILTER_SANITIZE_STRING);
$listeId = filter_var($data['liste_id'], FILTER_SANITIZE_STRING);//A completer
$tarif = filter_var($data['tarif'], FILTER_SANITIZE_STRING);//A completer
$item = new Liste();
$item->titre = $nom;
$item = new Item();
$item->nom = $nom;
$item->descr = $desc;
$item->liste_id = $listeId;
$item->url = $urlIt;
......
......@@ -21,7 +21,7 @@ class VueCreation
public function formulaireListe():string {
$url = $this->container->router->pathFor('traiteFormListe');
$content = "<form method='POST' action='$url'>".
"<input type='text' name='nom' placeholder='Titre de la liste'/>".
"<input type='text' name='titre' placeholder='Titre de la liste'/>".
"<input type='text' name='description' placeholder='Description de la liste'/>".
"<input type='date' name='expiration' />".
"<button type='submit' name='valider'>Creer la liste</button>".
......@@ -38,7 +38,7 @@ class VueCreation
"<input type='text' name='liste_id' placeholder='Id de la liste'/>".
"<input type='text' name='url' placeholder='Url de l item' />".
"<input type='text' name='tarif' placeholder='Tarif de l item' />".
"<button type='submit' name='valider'>Creer la liste</button>".
"<button type='submit' name='valider'>Creer l item</button>".
"</form>";
return $content;
......
......@@ -75,10 +75,19 @@ class VueParticipant {
if ($trouve === true) {
$url_item = $this->container->router->pathFor('affUnItem', ['id' => $i['id']]);
if($itemNom->message === "") {
if (isset($_COOKIE["liste_cree"]["{$l['token']}}"])){
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span> Item réservé</span> </article></li>\n";
}else {
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span>Item réservé par $itemNom->nom</span>; </article></li>\n";
}
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span>Item réservé par $itemNom->nom</span>; </article></li>\n";
} else {
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span>Item réservé par $itemNom->nom</span>; <span>Avec le message suivant : $itemNom->message</span> </article></li>\n";
if (isset($_COOKIE["liste_cree"]["{$l['token']}}"])){//isset($_COOKIE["Liste_cree"][$l['token']])
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span>Item réservé </span> </article></li>\n";
}else {
$content .= "<li><article>{$i['id']} ; {$i['liste_id']} ; {$i['nom']} ; {$i['descr']} ; {$i['url']} ; {$i['tarif']} ; <a href='{$url_item}'>Lien vers l'item</a>;<span>Item réservé par $itemNom->nom</span>; <span>Avec le message suivant : $itemNom->message</span> </article></li>\n";
}
}
} else {
$url_item = $this->container->router->pathFor('affUnItem', ['id' => $i['id']]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment