PluginsClassiques(); } function charger($id, $lang=1){ return $this->getVars("select * from $this->table where id=\"$id\""); } function init(){ $cnx = new Cnx(); $query_commentaires = "CREATE TABLE `commentaires` ( `id` int(11) NOT NULL auto_increment, `commentateur` text NOT NULL, `ville` text NOT NULL, `pays` text NOT NULL, `message` text NOT NULL, `ref` text NOT NULL, `date` datetime NOT NULL, `titre` text NOT NULL, `note` int(1) NOT NULL, `ip` varchar(15) NOT NULL default '000.000.000.000', `valide` char(1) NOT NULL default '0', PRIMARY KEY (`id`) ) AUTO_INCREMENT=1 ;"; $resul_commentaires = mysql_query($query_commentaires, $cnx->link); } function destroy(){ } function boucle($texte, $args){ // récupération des arguments $ref= lireTag($args, "ref"); $deb= lireTag($args, "deb", "int"); $num= lireTag($args, "num", "int"); $classement = lireTag($args, "classement"); if(!$deb) $deb = 0; if($num>0) $limit = "LIMIT $deb, $num"; else $limit = ""; switch($classement) { case 'croissant': $order = "ORDER BY date ASC"; break; case 'decroissant': $order = "ORDER BY date DESC"; break; default: $order = "ORDER BY date ASC"; break; } $search =""; $res=""; // préparation de la requête if($ref!="") $search.=" and ref=\"$ref\" and valide=\"1\""; $commentaire = new Commentaires(); $query_commentaires = "select * from $commentaire->table where 1 $search $order $limit"; $resul_commentaires = mysql_query($query_commentaires, $commentaire->link); $nbres = mysql_numrows($resul_commentaires); if(!$nbres) return ""; while($row = mysql_fetch_object($resul_commentaires)){ $temp = str_replace("#COMMENTATEUR", $row->commentateur, $texte); $temp = str_replace("#VILLE", $row->ville, $temp); $temp = str_replace("#PAYS", $row->pays, $temp); $temp = str_replace("#MESSAGE", $row->message, $temp); $temp = str_replace("#DATE", substr($row->date, 0, 10), $temp); $temp = str_replace("#HEURE", substr($row->date, 11), $temp); $temp = str_replace("#TITRE", $row->titre, $temp); $temp = str_replace("#NOTE", $row->note, $temp); $temp = str_replace("#VALIDE", $row->valide, $temp); $res .= $temp; } return $res; } function action($res){ if(isset($_POST['action']) && $_POST['action'] == "ajcommentaire"){ $commentaire = new Commentaires(); $commentaire->commentateur = strip_tags($_POST['commentaire_nom']); $commentaire->ville = strip_tags($_POST['commentaire_ville']); $commentaire->pays = strip_tags($_POST['commentaire_pays']); $commentaire->message = strip_tags($_POST['commentaire_message']); $commentaire->ref = strip_tags($_POST['commentaire_ref']); $commentaire->titre = strip_tags($_POST["commentaire_titre"]); $commentaire->date = date("Y-m-d H:i:s"); $commentaire->note = strip_tags($_POST["note"]); $commentaire->ip = strip_tags($_SERVER['REMOTE_ADDR']); $commentaire->valide = 0; $commentaire->add(); $emailcontact = new Variable(); $emailcontact->charger("emailcontact"); $nomsite = new Variable(); $nomsite->charger("nomsite"); $mail = new Mail(); $mail->IsMail(); $mail->FromName = $nomsite->valeur; $mail->From = $emailcontact->valeur; $mail->Subject = "nouveau commentaire pour le produit : ".$commentaire->ref; $mail->MsgHTML($commentaire->commentateur." : ".$commentaire->message); $mail->AltBody = $commentaire->commentateur." : ".$commentaire->message; $mail->AddAddress($emailcontact->valeur,$nomsite->valeur); $mail->send(); $cache = new Cache(); $cache->vider("COMMENTAIRES", "%"); } } } ?>