From ae70c27b946139061e6cf12f3a936a8be32f708a Mon Sep 17 00:00:00 2001 From: nox Date: Sat, 9 Nov 2019 23:23:19 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20de=20la=20connexion=20de?= =?UTF-8?q?=20l'utilisateur=20sur=20les=20diff=C3=A9rents=20=C3=A9crans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/ajax/connexion.php | 2 + public/ajax/readRecords.php | 73 +++---- public/ajax/readRecords2.php | 190 +++++++++--------- public/js/connex.js | 5 +- src/Auth/Action/LogoutAction.php | 2 + src/Gmarche/Actions/AntenneShowAction.php | 8 +- src/Gmarche/Actions/RegionIndexAction.php | 9 +- src/Product/Actions/ProductIndexAction.php | 9 +- src/Product/Actions/RechIndexAction.php | 15 +- src/Product/views/admin/products/index.twig | 27 +-- src/Product/views/admin/recherches/index.twig | 14 +- views/layout.twig | 10 +- 12 files changed, 181 insertions(+), 183 deletions(-) diff --git a/public/ajax/connexion.php b/public/ajax/connexion.php index 00fd3f0..075bfc7 100644 --- a/public/ajax/connexion.php +++ b/public/ajax/connexion.php @@ -15,6 +15,8 @@ try { $query->execute($params); $row = $query->fetch(PDO::FETCH_ASSOC); if (password_verify($_POST['mdp'],$row['password'])) { + session_start(); + $_SESSION['user']=$row['username']; echo '{"valide":true,"username":"'.$row['username'].'"}'; } else { echo '{"valide":false}'; diff --git a/public/ajax/readRecords.php b/public/ajax/readRecords.php index 123b641..8077419 100644 --- a/public/ajax/readRecords.php +++ b/public/ajax/readRecords.php @@ -1,25 +1,23 @@ - - No. - Bien / service - Photo - Vendeur - Clé publique - Quantité - Prix en junes'; + ini_set('display_errors', 0); + include '../../config/conf.php'; + $antenne_slug = $_GET['antenne_slug']; + $nom_connecte = $_GET['nom_connecte']; + $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); + // Affichage des intitulés de colonnes + $data = ' + + + + + + + + '; $params["antenne_slug"] = $antenne_slug; - $requete = "SELECT products.*, users.username, users.pubkey + $requete = "SELECT products.*, users.username, users.pubkey FROM products LEFT JOIN antennes ON antennes.id = products.antenne_id @@ -31,11 +29,10 @@ $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); $stmt->execute($params); $stmt2->execute($params); $count = $stmt->rowCount(); + $affich_actions = false; while ($row2 = $stmt2->fetch(PDO::FETCH_ASSOC)) { if ($row2['username'] == $nom_connecte) { $affich_actions = true; - } else { - $affich_actions = false; } } if ($affich_actions) { @@ -50,8 +47,7 @@ $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $data .= " - "; - + "; $prix = $row['prix']; $vendeur = $row['username']; $produit = $row['name']; @@ -65,7 +61,7 @@ $bdd = new \PDO("mysql:host=$host;dbname=$database_name", $username, $password); $data .= ''; $data .= ''; $data .= ''; - if ($row['username'] == $_GET['nom_connecte'] ) { + if ($row['username'] == $_GET['nom_connecte'] ) { $data .= ' + + + + + + + '; -// Design initial table header -$data = '
No.Bien / servicePhotoVendeurClé publiqueQuantitéPrix en junes
$number$number'.$cle_pub_format.''.$row['quantite'].''.$prix.''; $data .= '
No.Bien/service recherchéPhotoAcheteurClé publiqueQuantitéPrix en Ğ1
- - - - - - - - - - '; - -$params["antenne_slug"] = $antenne_slug; - -$requete = "SELECT souhaits.*, users.username, users.pubkey - FROM souhaits - LEFT JOIN antennes - ON antennes.id = souhaits.antenne_id - LEFT JOIN users - ON users.id = souhaits.user_id - WHERE antennes.slug = :antenne_slug"; -$stmt = $bdd->prepare($requete); -$stmt->execute($params); -$count = $stmt->rowCount(); - -if ($count > 0) -{ - $number = 1; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - - $data .= " - "; - - $prix = $row['prix']; - $vendeur = $row['username']; - $produit = $row['name']; - $pubkey = $row['pubkey']; - $vendeur_format = "$vendeur"; - - $pubkeyShort = substr($pubkey, 0, 8); - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ' + "; + $prix = $row['prix']; + $vendeur = $row['username']; + $produit = $row['name']; + $pubkey = $row['pubkey']; + $vendeur_format = "$vendeur"; + $pubkeyShort = substr($pubkey, 0, 8); + $data .= ''; + $data .= ''; + $data .= ''; + $data .= ''; + $data .= ''; + $data .= ''; + if ($row['username'] == $_GET['nom_connecte'] ) { + $data .= '
No.Bien/service recherchéPhotoAcheteurClé publiqueQuantitéPrix en Ğ1Actions
$number'.$produit.''.$vendeur_format.''.$pubkeyShort.'...'.$row['quantite'].''.$prix.''; - $data .= ''; - $data .= ''; - $data .= '
$number'.$produit.''.$vendeur_format.''.$pubkeyShort.'...'.$row['quantite'].''.$prix.''; + $data .= '