BLACKSITE
:
216.73.216.68
:
54.36.91.62 / www.econfortplus.fr
:
Linux webm012.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
:
/
home
/
econfoy
/
www
/
Upload File:
files >> /home/econfoy/www/submit_rating.php
<?php //submit_rating.php $connect = new PDO("mysql:host=econfoy568.mysql.db;dbname=econfoy568", "econfoy568", "Cherifamine1996"); // include "admin/conn.php"; if(isset($_POST["rating_data"])) { $customerkey=$_POST["user_name"]; $check_query = "SELECT * FROM customers WHERE customer_key = :customer_key"; $check_statement = $connect->prepare($check_query); $check_statement->execute([':customer_key' => $customerkey]); // Si la clé n'existe pas, afficher une alerte if ($check_statement->rowCount() == 0) { echo "Clé introuvable. Vous n'êtes pas un client enregistré. Veuillez vérifier votre clé."; } else { // Récupérer le nom du client $result = $check_statement->fetch(PDO::FETCH_ASSOC); $customer_name = $result['nom_prenom']; $customer_id = $result['id']; $data = array( ':user_name' => $customer_name, ':user_rating' => $_POST["rating_data"], ':user_review' => $_POST["user_review"], ':customer_id' => $customer_id, ':is_approved' => 0, ':datetime' => time() ); $query = " INSERT INTO review_table (user_name, user_rating, user_review, datetime,is_approved,customer_id) VALUES (:user_name, :user_rating, :user_review, :datetime,:is_approved,:customer_id) "; $statement = $connect->prepare($query); //$statement->execute($data); if ($statement->execute($data)) { echo "Votre avis et votre note ont été envoyés avec succès. Sera posté au plus tard dans 24 heures"; // Détails de l'email $to = "m.cherif142@laposte.net"; // Remplacez par l'email du responsable $subject = "Nouvel Avis Client Recu"; $message = " Bonjour, Un nouveau commentaire a été soumis : Client : {$customer_name} Étoiles : {$_POST["rating_data"]} Avis : {$_POST["user_review"]} Connectez-vous pour approuver ou répondre à cet avis. Merci. "; $headers = "From: noreply@econfortplus.fr\r\n"; $headers .= "Content-Type: text/plain; charset=UTF-8\r\n"; // Envoi de l'email mail($to, $subject, $message, $headers); } } } if(isset($_POST["action"])) { $average_rating = 0; $total_review = 0; $five_star_review = 0; $four_star_review = 0; $three_star_review = 0; $two_star_review = 0; $one_star_review = 0; $total_user_rating = 0; $review_content = array(); $query = " SELECT * FROM review_table WHERE is_approved = 1 ORDER BY review_id DESC "; $result = $connect->query($query, PDO::FETCH_ASSOC); foreach($result as $row) { // Définir la locale à français setlocale(LC_TIME, 'fr_FR.UTF-8'); // Sur Linux ou Mac // setlocale(LC_TIME, 'fr_FR'); // Sur certains systèmes Windows // Formater la date en français $datetime_fr = strftime('%d %B %Y %H:%M:%S', $row["datetime"]); $review_content[] = array( 'user_name' => $row["user_name"], 'user_review' => $row["user_review"], 'rating' => $row["user_rating"], 'admin_reply' => $row["admin_reply"], 'datetime' => $datetime_fr ); if($row["user_rating"] == '5') { $five_star_review++; } if($row["user_rating"] == '4') { $four_star_review++; } if($row["user_rating"] == '3') { $three_star_review++; } if($row["user_rating"] == '2') { $two_star_review++; } if($row["user_rating"] == '1') { $one_star_review++; } $total_review++; $total_user_rating = $total_user_rating + $row["user_rating"]; } $average_rating = $total_user_rating / $total_review; $output = array( 'average_rating' => number_format($average_rating, 1), 'total_review' => $total_review, 'five_star_review' => $five_star_review, 'four_star_review' => $four_star_review, 'three_star_review' => $three_star_review, 'two_star_review' => $two_star_review, 'one_star_review' => $one_star_review, 'review_data' => $review_content ); echo json_encode($output); } ?>