'); // email emetteur des newsletter define('DOMAINE_MAIL','www.aussonne.fr'); // nom de domaine quienvoie les mails define('DOMAINE_NAME','www.aussonne.fr'); // nom de domaine indiqué dans le corps des mails define('SESSION_NAME','AUSSONNE'); // nom de domaine indiqué dans le corps des mailsESSION_NAME ///////////////////////////////////////////////////////////////////////////////////// // Configurations du traitement des mails ///////////////////////////////////////////////////////////////////////////////////// define('DELAIS_DELESTAGE','1 month'); // delais qui détermine les mails a vider define('NB_MAILS_LOTS','50'); // nombre de mails constituant un lot de traitements define('DELAIS_LAPS_DELESTAGE','1 week'); // delais minimum entre 2 vidages de piles define('MAILS_ERREUR','support-web@agoravita.com'); // email qui recoit les alerte d'erreur define('SEUIL_TENTATIVE','10'); // seuils de tentative avant erreur ///////////////////////////////////////////////////////////////////////////////////// // Captcha ///////////////////////////////////////////////////////////////////////////////////// $cryptinstall="crypt/cryptographp.fct.php"; define('ACTUALISERCRYPT','0'); // 0 ou 1 pour le rendre visible define('WIDTHCRYPT','250'); // Largeur define('HEIGHTCRYPT','30'); // Hauteur define('BACKGROUDCOLORRED','255'); // Couleur R (0->255) define('BACKGROUDCOLORGREEN','255'); // Couleur V (0->255) define('BACKGROUDCOLORBLUE','255'); // Couleur B (0->255) define('BACKGROUNDTRANSPARENT',false); // Fond transparent (true/false) define('CADREBORDER',''); // Ajoute un cadre de l'image (true/false) define('BORDERCOLORCRYPT','ffffff'); // Couleur du border de l'image en hexa define('BACKGROUNDIMG',''); // Image de fond du cryptogramme define('CHARCOLORRED','170'); // Couleur R (0->255) define('CHARCOLORGREEN','0'); // Couleur V (0->255) define('CHARCOLORBLUE','0'); // Couleur B (0->255) define('TYPOCHAR','luggerbu.ttf'); // SCRAWL.TTF ou luggerbu.ttf ou WAVY.TTF ?> base = $base; $this->host = $host; $this->user = $user; $this->pass = $pass; $this->link = mysql_pconnect($this->host, $this->user, $this->pass); mysql_select_db($this->base); $this->result = mysql_query("SET NAMES latin1", $this->link); return $this->link; } // Lancement de requètes SQL function query($query) { $this->query = $query; $this->result = mysql_query($query, $this->link); if (!$this->result) { echo 'Erreur sur la requète :

'; $this->debug(); echo '

Erreur : ' . mysql_error($this->link); echo '

Fichier: ' . $_SERVER['PHP_SELF'] . ''; } return $this->result; } // Retourner simplement le result de mysql_query function getResult() { return $this->result; } function setResult($res) { $this->result = $res; } // Retourner le résultat sous forme d'un tableau function fetchR() { return mysql_fetch_row($this->result); } // Retourner le résultat sous forme d'un objet function fetchO() { return mysql_fetch_object($this->result); } function fetchA() { return mysql_fetch_array($this->result,MYSQL_ASSOC); } // Quand une requète retourne un seul résultat function getResultat() { $resultat = mysql_fetch_array($this->result,MYSQL_NUM); $this->un_resultat = $resultat[0]; return $this->un_resultat; } // Nombre d'enregistrements retournés par la requère function nbL() { $this->nb_lignes = mysql_num_rows($this->result); return $this->nb_lignes; } // Identifiant du dernier enregistrement inséré function lastId() { return mysql_insert_id($this->link); } // Code de retour d'erreur function erreur_num() { return mysql_errno(); } // Valeurs d'un champs enum /** * @return array * @param string $table * @param string $field * @desc Retourne les valeurs d'un champs MySql de type ENUM */ function mysql_enum_values($table, $field) { $sql = "SHOW COLUMNS FROM $table LIKE '$field'"; $sql_res = mysql_query($sql); $row = mysql_fetch_assoc($sql_res); mysql_free_result($sql_res); return(explode("','", preg_replace("/.*\('(.*)'\)/", "\\1", $row["Type"]))); } function AffectedRows() { return mysql_affected_rows($this->link); } // Protection des champs function Ss($chaine) { if(get_magic_quotes_gpc()){ $chaine = stripslashes($chaine); } $chaine = mysql_real_escape_string($chaine,$this->link); return $chaine; } // Fermeture de la connection function close() { //mysql_free_result($this->link); mysql_close($this->link); } function debug($query = '') { if ($query) $this->query = $query; $query = preg_replace("/['\"]([^'\"]*)['\"]/i", "'$1'", $this->query, -1); $query = str_replace( array ( '*', 'SELECT ', 'UPDATE ', 'DELETE ', 'INSERT ', 'INTO', 'VALUES', 'FROM', 'LEFT', 'JOIN', 'WHERE', 'LIMIT', 'GROUP BY', 'ORDER BY', 'BETWEEN', ' AND ', 'OR ', 'DESC', 'ASC', 'ON ' ), array ( "*", "SELECT ", "UPDATE ", "DELETE ", "INSERT ", "INTO", "VALUES", "FROM", "LEFT", "JOIN", "WHERE", "LIMIT", "GROUP BY", "ORDER BY", "BETWEEN", " AND ", "OR ", "DESC", "ASC", "ON " ), $query ); echo nl2br($query); } } ?> $wm){ $r = $wm / $w; $hn = $r * $h; $wn = $wm; } if(($hn > $hm) or ($hn > $h)){ $r = $hm / $h; $wn = $r * $w; $hn = $hm; } echo ''.$alt.''; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux tableaux // cherche une occurrence de l'élement elt dans le tableau array function array_search_occur($elt,$array) { if (!is_array($array)) return FALSE; end($array); $found = FALSE; $return = FALSE; do { $v = current($array); if (eregi($elt,$v)) { $return = TRUE; $found = TRUE; } } while (prev($array) && !$found); return $return; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux adresses mails // test la validité d'une adresse email function checkEmail($email){ if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)){ return FALSE; } if(ON_LINE){ list($Username, $Domain) = split("@",$email); if(getmxrr($Domain, $MXHost)){ return TRUE; }else{ return FALSE; } }else{ return TRUE; } } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux traitement d'un texte // inverse de la fonction nl2br function br2nl($text) { return preg_replace('//i', '\n', $text); } // Nettoie une chaine de caractere pour affichage function nettoie($texte) { $texte = trim($texte); $texte = stripslashes($texte); $texte = str_replace("#NOM?","",$texte); //$texte = strip_tags($texte); $texte = str_replace("’","'",$texte); $texte = htmlentities($texte,ENT_QUOTES); //Rempacement pour guillemets /*$texte = str_replace('"','"',$texte);*/ return $texte; } // Nettoie une chaine de caractere pour l'utiliser dans des RSS function nettoieRss($texte) { $texte = trim($texte); $texte = stripslashes($texte); $texte = str_replace("#NOM?","",$texte); //$texte = strip_tags($texte); $texte = str_replace("’","'",$texte); /*$texte = htmlentities($texte,ENT_QUOTES);*/ //Rempacement pour guillemets /*$texte = str_replace('"','"',$texte);*/ return $texte; } // Encode une chaine de caractere pour l'utiliser dans des fonctions javascript function encodeJavascript($texte){ $texte = trim($texte); $texte = nettoie($texte); //$texte = nettoie($texte); $texte = addslashes($texte); return $texte; } // Convertit un texte HTML en un texte simple avec retour a la ligne en BR function html2TxtBR($texte){ $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = strip_tags($texte); $texte = str_replace("[BR]","
",$texte); return $texte; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux nombres // Affichage d'un nombre, n'affichant que l'entier si aucune décimale n'est présente function affichageNbArrondi($valeur){ $valeur_t=round($valeur); if($valeur_t==$valeur){ $valeur=$valeur_t; } return $valeur; } // Remplace , par . function nettoieVirgule($valeur){ $valeur=str_replace(",",".",$valeur); return $valeur; } // Remplace . par , function nettoiePoint($valeur){ //$valeur=number_format($valeur,2,'.',' '); $valeur=str_replace(".",",",$valeur); return $valeur; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux fichiers // Récupère l'extension d'un fichier function getExtension($fichier) { $bouts = explode(".", $fichier); $extension = array_pop($bouts); return $extension; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux dates // Transforme une date en format lettre //Transforme une date en format lettre function getDateLettre($date,$args = "%A %e %B %Y") { setlocale(LC_TIME,"fr_FR@euro","fr_FR","fr","fre","fra","french","france"); return strftime($args, strtotime($date)); } // Transforme une date en format US function dateFRtoUS($dateFR) { if(ereg ("([0-9]{1,2})-([0-9]{1,2})-([0-9]{2,4})", $dateFR, $date_us) or ereg ("([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $dateFR, $date_us)) { $date = $date_us[3]."-".$date_us[2]."-".$date_us[1]; return date("Y-m-d",strtotime($date)); } else { return false; } } // Transforme une date en format français function dateUStoFR($dateUS) { if(ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateUS, $date_fr) or ereg ("([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})", $dateUS, $date_fr)) { $date = $date_fr[3]."/".$date_fr[2]."/".$date_fr[1]; return $date; } else { return false; } } // Transforme un datetime en tableau function dateUStoTable($dateUS) { if(ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $dateUS, $date_fr) or ereg ("([0-9]{4})/([0-9]{1,2})/([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $dateUS, $date_fr)) { return $date_fr; } elseif(ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateUS, $date_fr) or ereg ("([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})", $dateUS, $date_fr)) { return $date_fr; } else { return false; } } // retourne l'annee de la date function getAnnee($dateUS){ if(ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateUS, $date_fr) or ereg ("([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})", $dateUS, $date_fr)) { $date = $date_fr[1]; return $date; } else { return false; } } // Transforme une date en format français function affichageDate($dateUS,$format="FR",$separateur=".") { /*switch($format){ case "US" : $date = dateFRtoUS(dateUStoFR($dateUS)); break; case "FR" : $date = dateUStoFR($dateUS); break; } $date = str_replace("-",$separateur,$date); $date = str_replace("/",$separateur,$date); */ $time = strtotime($dateUS); $date = date("d M Y",$time); return $date; } // fonction qui retourne le numéro correspondant a un mois function numericMois($mois){ switch($mois){ case 'january': $n = "01"; break; case 'february': $n = "02"; break; case 'march': $n = "03"; break; case 'april': $n = "04"; break; case 'may': $n = "05"; break; case 'june': $n = "06"; break; case 'july': $n = "07"; break; case 'august': $n = "08"; break; case 'september': $n = "09"; break; case 'october': $n = "10"; break; case 'november': $n = "11"; break; case 'december': $n = "12"; break; } return $n; } // fonction qui retourne le mois correspondant a un numéro function stringMois($numero){ switch($numero){ case '01': $n = "january"; break; case '02': $n = "february"; break; case '03': $n = "march"; break; case '04': $n = "april"; break; case '05': $n = "may"; break; case '06': $n = "june"; break; case '07': $n = "july"; break; case '08': $n = "august"; break; case '09': $n = "september"; break; case '10': $n = "october"; break; case '11': $n = "november"; break; case '12': $n = "december"; break; } return $n; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux découpage d'un texte // retourne les nbCar premier caractères d'un texte function decoupeTexte($texte,$nbCar) { $src = $texte; $texte = html_entity_decode($texte); $fin = true; if(strlen($texte)>$nbCar){ $i = $nbCar; while($fin){ $car = substr($texte,($i - 1),1); if($car == " " or $i>strlen($texte)){ $fin = false; }else{ $i++; } } $texte = substr($texte,0,$i); } if($src != $texte){ $texte.=" ..."; } return nl2br($texte); } // retourne les nombre de caractère d'un texte function nbCarTexte($texte) { $texte = html_entity_decode($texte); return strlen($texte); } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions relatives aux mot de passe // Génere un mot de passe function genererPassword(){ $tableau = array("a","N","z","B","o","e","V","r","C","4","t","X","y","W","u","P","5","i","I","p","U","q","Y","2","s","T","d","R","f","E","g","Z","9","h","A","j","M","7","k","L","K","m","J","6","w","H","x","G","c","F","8","v","D","b","S","n","Q","3",); $valeurs_aleatoires = array_rand($tableau, 8); $mot_de_passe = ""; foreach($valeurs_aleatoires as $i){ $mot_de_passe = $mot_de_passe . $tableau[$i]; } return $mot_de_passe; } ?>query("SELECT * FROM avgc_bloc WHERE id_bloc='$id_bloc'"); $b = $sql->fetchO(); $id_module = $b->id_module; $chaine = nettoie($b->chaine_bloc); $texte = $b->texte_bloc; $media = $b->media_bloc; $ancre = nettoie($b->ancre_bloc); // info module $sql->query("SELECT * FROM avgc_module WHERE id_module='$id_module'"); $m = $sql->fetchO(); $type_module = $m->type_module; $rep_module = $m->rep_module; $lib_module = $m->lib_module; // titre $titre = false; // if(!$titre and $texte){ $titre=$texte; } if(!$titre and $ancre){ $titre=$ancre; } if(!$titre and $media){ $titre=nomFile($media); } if(!$titre and $chaine){ $titre=$chaine; } if(!$titre and $lib_module){ $titre=$lib_module; } if(!$titre){ $titre=" "; } $titre = decoupeTexteBR($titre,20); if($rep_module=="annuaire"){ $id_contact=$chaine; $sql->query("SELECT nom_contact as nom, prenom_contact as prenom FROM annuaire_contact WHERE id_contact='$id_contact'"); $elt=$sql->fetchO(); $nom=nettoie($elt->nom." ".$elt->prenom); $titre=$nom; } ////////////////////////////// // LE CODE // récupération du bloc $contenu = ""; if($type_module=="zone"){ $handle = fopen(URL.AVGC_REP."inc/bloc-saisie-zone.inc.php", "r"); $contenu = writeBloc($id_bloc,$sql,true); }else{ $handle = fopen(URL.AVGC_REP."inc/bloc-saisie.inc.php", "r"); } $bloc = ''; if($handle!==false){ while (!feof($handle)) { $bloc .= fread($handle, 8192); } fclose($handle); } // on construit le bloc $bloc = str_replace("[ID]",$id_bloc,$bloc); $bloc = str_replace("[CONTENT]",$contenu,$bloc); $bloc = str_replace("[TITRE]",$titre,$bloc); // retour return $bloc; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ecrire le contenu d'un bloc function writeBloc($id_bloc,$sql,$saisie=false){ ////////////////////////////// // LES INFOS // info bloc $sql->query("SELECT * FROM avgc_bloc WHERE id_bloc='$id_bloc'"); $b = $sql->fetchA(); foreach($b as $lib=>$valeur){ $$lib = $valeur; } // info module $sql->query("SELECT * FROM avgc_module WHERE id_module='$id_module'"); $m = $sql->fetchO(); $type_module = $m->type_module; $rep_module = $m->rep_module; $champs_plus = $m->champs_plus; ////////////////////////////// // LE BLOC // récupération du chemin vers le bloc switch($type_module){ case 'zone' : $chemin = AVGC_REP_ZONES.$rep_module."/"; if($saisie){ $chemin.="code-admin.inc.php"; }else{ $chemin.="code.inc.php?id_bloc=".$id_bloc; } break; case 'module' : $chemin = AVGC_REP_MODULES.$rep_module."/code.inc.php"; break; } // récupération du contenu du bloc $bloc = ''; if($chemin){ $handle = fopen(URL.AVGC_REP.$chemin, "r"); if($handle!==false){ while (!feof($handle)) { $bloc .= fread($handle, 8192); } fclose($handle); } } // les styles $chemin = PATH.AVGC_REP."style/modules/style.inc.php"; if(is_file($chemin)){ include($chemin); } $classe1 = ""; if($alignement1_bloc){ $classe1 .= " ".$alignement1_bloc; } if($style1_bloc){ $classe1 .= " ".$style1_bloc; } $classe1 = substr($classe1,1); $styl_col_1 = ""; $styl_col_2 = ""; $styl_col_3 = ""; if($color1_bloc){ $styl_col_1 .= "border:1px solid ".$color1_bloc.";"; } if($color2_bloc){ $styl_col_1 .= "background-color:".$color2_bloc.";"; } if($color3_bloc){ $styl_col_2 .= "border:1px solid ".$color3_bloc.";"; } if($color4_bloc){ $styl_col_2 .= "background-color:".$color4_bloc.";"; } if($color5_bloc){ $styl_col_3 .= "border:1px solid ".$color5_bloc.";"; } if($color6_bloc){ $styl_col_3 .= "background-color:".$color6_bloc.";"; } if($color7_bloc){ $styl_col_4 .= "border:1px solid ".$color7_bloc.";"; } if($color8_bloc){ $styl_col_4 .= "background-color:".$color8_bloc.";"; } if($styl_col_1!=""){ $styl_col_1 = 'style="'.$styl_col_1.'"'; } if($styl_col_2!=""){ $styl_col_2 = 'style="'.$styl_col_2.'"'; } if($styl_col_3!=""){ $styl_col_3 = 'style="'.$styl_col_3.'"'; } if($styl_col_4!=""){ $styl_col_4 = 'style="'.$styl_col_4.'"'; } $style_color_1 = ""; if($color1_bloc){ $style_color_1 = 'style="color:'.$color1_bloc.';"'; } $style_contour_1 = ""; if($color1_bloc and $param2_bloc){ $style_contour_1 = 'style="border:'.$param2_bloc.'px solid '.$color1_bloc.';"'; } // annuaire if($rep_module=="annuaire"){ $id_contact=$chaine_bloc; $sql->query("SELECT texte_contact FROM annuaire_contact WHERE id_contact='$id_contact'"); $texte=$sql->getResultat(); $bloc = str_replace("[CHAINE]",$texte,$bloc); } // lien $debut_lien = ""; $fin_lien = ""; if($media_bloc and $chaine_bloc){ $debut_lien = ''; $fin_lien = ''; } // picto if(strpos($bloc,"[PICTO]") and $param1_bloc){ $chemin = AVGC_REP_MODULES.$rep_module."/code-picto.inc.php"; $blocpicto = ''; if($chemin){ $handle = fopen(URL.AVGC_REP.$chemin, "r"); if($handle!==false){ while (!feof($handle)) { $blocpicto .= fread($handle, 8192); } fclose($handle); } } $urlpicto = $style_pdf_rep.$param1_bloc; $blocpicto = str_replace("[URLPICTO]",$urlpicto,$blocpicto); $blocpicto = str_replace("[CLASSLIENIMAGE]","lienImage",$blocpicto); } $bloc = str_replace("[PICTO]",$blocpicto,$bloc); // media if(strpos($bloc,"[MEDIA]")){ // nom du fichier $nomfile = rewriteNomMedia($media_bloc); // traitement par type de fichier $extfile = strtolower(getExtension($nomfile)); $zoomable = false; switch($extfile){ case 'jpg' : $media = rewritePhotoRedim($media_bloc,$param1_bloc); $zoomable = true; break; case 'gif' : $media = rewritePhoto($media_bloc); $zoomable = true; break; case 'flv' : $media = rewriteVideo($media_bloc); break; default : $media = rewriteDocument($media_bloc); break; } // zoom if($param5_bloc=="1" and $zoomable){ $debut_lien = ''; $fin_lien = ''; } // on traite le media $bloc = str_replace("[MEDIA]",$media,$bloc); // les taille si le fichier est une vidéo if($extfile=="flv"){ $sql->query("SELECT width_redim,height_redim FROM av_medias_redim WHERE id_redim='$param1_bloc'"); $r = $sql->fetchO(); $width = $r->width_redim; $height = $r->height_redim; if(!$width or $width<=0){ $width=400; } if(!$height or $height<=0){ $height=300; } $bloc = str_replace("[WIDTH]",$width,$bloc); $bloc = str_replace("[HEIGHT]",$height,$bloc); $bloc = str_replace("[URL]",URL,$bloc); } // traitement de la légende pour les images if($extfile=="jpg" or $extfile=="gif"){ $sql->query("SELECT legende_file,chemin_file FROM av_medias_file WHERE id_file='$media_bloc'"); $f = $sql->fetchO(); $legend = $f->legende_file; $bloc = str_replace("[MEDIA_LEGEND]",$legend,$bloc); $debut_lien = str_replace("[MEDIA_LEGEND]",$legend,$debut_lien); if($extfile=="jpg"){ $chemin = $f->chemin_file; $chemin = PATH."medias/.".$param1_bloc.".".$chemin; $size = @getimagesize($chemin); $width = $size[0]; $height = $size[1]; }else{ $width = ""; $height = ""; } $bloc = str_replace("[WIDTH]",$width,$bloc); $bloc = str_replace("[HEIGHT]",$height,$bloc); } } // liste a puce if($champs_plus=="liste"){ $texte_bloc = writeListe($texte_bloc); } // on construit le bloc $bloc = str_replace("[ID]",$id_bloc,$bloc); $bloc = str_replace("[CHAINE]",nl2br($chaine_bloc),$bloc); $bloc = str_replace("[CLASSE_1]",$classe1,$bloc); $bloc = str_replace("[CLASSE_IMAGE1]",$classe_image1,$bloc); $bloc = str_replace("[ALIGNEMENT1]",$alignement1_bloc,$bloc); $bloc = str_replace("[ALIGNEMENT2]",$alignement2_bloc,$bloc); if($styles_titre_n_nv[$param1_bloc]){ $bloc = str_replace("[PARAM1]",$styles_titre_n_nv[$param1_bloc],$bloc); }else{ $bloc = str_replace("[PARAM1]",$param1_bloc,$bloc); } //$bloc = str_replace("[OPTION2]",$option2,$bloc); //$bloc = str_replace("[OPTION3]",$option3,$bloc); $bloc = str_replace("[TEXTE]",$texte_bloc,$bloc); $bloc = str_replace("[STYLE_COL_1]",$styl_col_1,$bloc); $bloc = str_replace("[STYLE_COLOR1]",$style_color_1,$bloc); $bloc = str_replace("[STYLE_CONTOUR1]",$style_contour_1,$bloc); $bloc = str_replace("[STYLE_COL_2]",$styl_col_2,$bloc); $bloc = str_replace("[STYLE_COL_3]",$styl_col_3,$bloc); $bloc = str_replace("[STYLE_COL_4]",$styl_col_4,$bloc); $bloc = str_replace("[CLASSE_TABLE]",$style1_bloc,$bloc); $bloc = str_replace("[LIEN_DEBUT]",$debut_lien,$bloc); $bloc = str_replace("[LIEN_FIN]",$fin_lien,$bloc); $bloc = str_replace("
","
",$bloc); if($ancre_bloc!=''){ $bloc = ''.$bloc; } ////////////////////////////// // LES SOUS-BLOCS // on remplit les colonnes le cas echéant if($type_module=='zone'){ // pour chaque colonne for($c=1;$c<=4;$c++){ // recup des ids des sous blocs de la colonne $ids = array(); $sql->query("SELECT id_bloc FROM avgc_bloc WHERE id_bloc_parent='$id_bloc' AND position_bloc='$c' ORDER BY ordre_bloc"); while($res = $sql->fetchO()){ $ids[] = $res->id_bloc; } // recup des contenu $blocs = ""; foreach($ids as $id){ if($saisie){ $blocs .= writeBlocSaisie($id,$sql); }else{ $blocs .= writeBloc($id,$sql); } } // on rempli la colonne $bloc = str_replace("[COLONNE_".$c."]",$blocs,$bloc); } } ////////////////////////////// // RETOUR return $bloc; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // retourne les nbCar premier caractères d'un texte en gardant les retour a la ligne function decoupeTexteBR($texte,$nbCar){ $src = $texte; $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = str_replace("
","[BR]",$texte); $texte = strip_tags($texte); $fin = true; if(strlen($texte)>$nbCar){ $i = $nbCar; while($fin){ $car = substr($texte,($i - 1),1); if($car == " " or $i>strlen($texte)){ $fin = false; }else{ $i++; } } $texte = substr($texte,0,$i); } if($src != $texte){ $texte.=" ..."; } $texte = str_replace("[BR]","
",$texte); return $texte; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ecrire le contenu d'un bloc function supprimerBloc($id_bloc,$sql){ // recups de tout les sous-blocs a supprimer $ids = array(); $sql->query("SELECT id_bloc FROM avgc_bloc WHERE id_bloc_parent='$id_bloc'"); while($res = $sql->fetchO()){ $ids[] = $res->id_bloc; } // suppression de tout les sous-blocs foreach($ids as $id){ supprimerBloc($id,$sql); } // supression du bloc $sql->query("DELETE FROM avgc_bloc WHERE id_bloc='$id_bloc'"); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // FONCTION RELATIVES AUX LISTES ///////////////////////////////////////////////////////////// // fonction qui va retourner le code d'une liste function writeListe($texte){ // on nettoie le texte $texte = wlNettoieTexte($texte); // on transforme le texte en liste de ligne $liste = wlArray2Liste($texte,"-"); $liste = wlTraitementListe($liste,"*"); // on construit le html if(is_array($liste)){ $html = wlMakeListeHTML($liste); } return $html; } ///////////////////////////////////////////////////////////// // nettoie un texte html function wlNettoieTexte($texte){ // on traite les saut de lignes $texte = str_replace("
","
",$texte); $texte = str_replace("
","
",$texte); $texte = str_replace("
","
",$texte); $texte = str_replace("
","
",$texte); $texte = str_replace("
","
",$texte); // retour return $texte; } ///////////////////////////////////////////////////////////// // on transforme le texte html en tableau de lignes function wlHtml2Array($texte){ $retour = false; if(strpos($texte,"
")!==false){ $retour = explode("
",$texte); } return $retour; } ///////////////////////////////////////////////////////////// // on met en forme un niveau de liste a puce function wlArray2Liste($texte,$marqueur){ $array = wlHtml2Array($texte); $liste = array(); $texte_hors = ""; if(is_array($array)){ $lc = ""; $tx = true; foreach($array as $j=>$l){ if(substr(trim($l),0,1)==$marqueur){ if($lc!=""){ if($tx){ if(substr($lc,0,6)=="
"){ $texte_hors = substr($lc,6); }else{ $texte_hors = $lc; } $lc = ""; }else{ $liste[]['texte'] = $lc; $lc = ""; } } $lc .= substr(trim($l),1); $tx = false; }else{ //if(trim($l)!=""){ $lc .= "
".trim($l); //} } } if($lc!=""){ if($tx){ $texte_hors = substr($lc,6); $lc = ""; $tx = false; }else{ $liste[]['texte'] = $lc; $lc = ""; } } }else{ $texte_hors = $texte; } return array("texte"=>$texte_hors,"liste"=>$liste); } ///////////////////////////////////////////////////////////// // on traite une liste function wlTraitementListe($liste,$marqueur){ $laliste = $liste["liste"]; if(is_array($laliste)){ foreach($laliste as $i=>$a){ // on transforme le texte en tableau de lignes $texte = $a['texte']; //$array = wlHtml2Array($texte); // on construit le tableau de second niveau $laliste[$i] = wlArray2Liste($texte,$marqueur); } } $liste["liste"] = $laliste; return $liste; } ///////////////////////////////////////////////////////////// // on transforme la liste en html function wlMakeListeHTML($liste){ $array = $liste["liste"]; $html = ""; $html .= $liste['texte']; if(is_array($array)){ if(count($array)>0){ $html .= ""; } } return $html; } ?>\n"; $head .= "Content-Type: ".$type."; charset=iso-8859-1\n"; $head .= "X-Sender: <".DOMAINE_MAIL.">\n"; $head .= "X-Mailer: PHP\n"; $head .= "X-auth-smtp-user: ".EMAIL."\n"; $head .= "X-abuse-contact: ".EMAIL; // on hash le contenu du mail $message = wordwrap($message, 70); // envoi du mail $result = mail($to,$subject,$message,$head); // retour return $result; } ////////////////////////////////////////////////////////////////////////////////// // récupère le contenu d'un mail html function getMailContentHTML($mail){ $handle = fopen(URL."mail-content/".$mail, "r"); $content = ''; if($handle!==false){ while (!feof($handle)) { $content .= fread($handle, 8192); } fclose($handle); } return $content; } ///////////////////////////////////////////////////////////////////////////////////////////////////// // MAIL DE VALIDATION DE PAGE ////////////////////////////////////////////////////////////////////////////////// // envoi un mail function sendMailValidation($nom_user,$nom_page,$arbo,$email){ // récupération du contenu du mail $message = getMailContentHTML("mail-validation-page.php"); $message = str_replace("[NOM]",$nom_user,$message); $message = str_replace("[PAGE]",$nom_page,$message); $message = str_replace("[ARBO]",$arbo,$message); // envoi du mail $result = sendMail($email,"Validation de page",$message,EMAIL); // retour return $result; } ///////////////////////////////////////////////////////////////////////////////////////////////////// // MAIL CONTACT ////////////////////////////////////////////////////////////////////////////////// // envoi le mail de contact function setDataContentMail($datas,$content){ foreach($datas as $lib=>$val){ $content = str_replace("[".strtoupper($lib)."]",stripslashes($val),$content); } return $content; } ////////////////////////////////////////////////////////////////////////////////// // fonction d'envoi de mail en fonction d'un modèle HTML function sendMailModeleHTML($to,$subject,$modele,$datas,$from,$returnpath = EMAIL){ // récupération du contenu du mail $content = getMailContentHTML($modele); // injection des données envoyés $content = setDataContentMail($datas,$content); // envoi du mail $result = sendMail($to,$subject,$content,$from,"text/html",$returnpath); // retour return $result; } ///////////////////////////////////////////////////////////////////////////////////////////////////// // PILE ENVOI ////////////////////////////////////////////////////////////////////////////////// function envoyerMail($sql,$destinataire,$titre,$texte,$emetteur = EMAIL){ ///////////////////////////////////////////// // init // init des variables $destinataire = addslashes(stripslashes($destinataire)); $titre = addslashes(stripslashes($titre)); $texte = addslashes(stripslashes($texte)); $emetteur = addslashes(stripslashes($emetteur)); ///////////////////////////////////////////// // ajout a la pile $sql->query("INSERT INTO mails_pile_envoi(id_envoi,destinataire_mail,titre_mail,texte_mail,emetteur_mail,date_ajout) VALUES ('','$destinataire','$titre','$texte','$emetteur',NOW())"); } ///////////////////////////////////////////////////////////////////////////////// // FONCTIONS QUI VA ENVOYER LES MAILS PAR LOTS function traiter_lots_mails($sql,$nb_lot=NB_MAILS_LOTS){ if(ON_LINE){ ///////////////////////////////////////////// // init // as-t-on envoyé des mails $mails_envoye = false; // header des mails $head = "From: [DESTINATAIRE]\n"; $head .= "MIME-Version: 1.0\n"; $head .= "Return-Path: <".EMAIL.">\n"; $head .= "Content-Type: text/html; charset=iso-8859-1\n"; $head .= "X-Sender: <".DOMAINE_MAIL.">\n"; $head .= "X-Mailer: PHP\n"; $head .= "X-auth-smtp-user: ".EMAIL."\n"; $head .= "X-abuse-contact: ".EMAIL; ///////////////////////////////////////////// // selections des mails a envoyer $mails = true; $i=0; while($mails and $i<$nb_lot){ // recupération d'un mail $sql->query("SELECT * FROM mails_pile_envoi WHERE envoye='0' AND nb_tentative<='".(SEUIL_TENTATIVE+12)."' ORDER BY date_ajout ASC LIMIT 1"); if($sql->nbL()!=0){ $m = $sql->fetchO(); $id_envoi = $m->id_envoi; $titre = $m->titre_mail; $texte = $m->texte_mail; $destinataire = $m->destinataire_mail; $emetteur = $m->emetteur_mail; $header = str_replace("[DESTINATAIRE]",$emetteur,$head); // envoi du mail $result = mail($destinataire,$titre,$texte,$header); // traitement du résultat if($result){ if(!$mails_envoye){ $sql->query("INSERT INTO mails_operations(id_ope,type_ope,date_ope) VALUES ('','send_lot',NOW())"); } $mails_envoye = true; $sql->query("UPDATE mails_pile_envoi SET nb_tentative=nb_tentative+1,date_derniere_tentative=NOW(),envoye='1',date_envoi=NOW() WHERE id_envoi='$id_envoi'"); }else{ $sql->query("UPDATE mails_pile_envoi SET nb_tentative=nb_tentative+1,date_derniere_tentative=NOW() WHERE id_envoi='$id_envoi'"); } }else{ $mails = false; } // incrémentation $i++; } ///////////////////////////////////////////// // on regarde si il y a des problème d'envoi $sql->query("SELECT * FROM mails_pile_envoi WHERE envoye='0' AND nb_tentative>='".SEUIL_TENTATIVE."'"); if($sql->nbL()>0){ $result = mail(MAILS_ERREUR,"Portiques de sécurité : erreur de mails","Erreur de mails sur le site de ".URL." (système de pile)",EMAIL); } } } ///////////////////////////////////////////////////////////////////////////////// // FONCTIONS QUI VIDE LA PILE D'ENVOI DE MAIL // cette fonction ne videras que les élements les plus anciens function viderPile($sql){ ///////////////////////////////////////////// // controle de la necessité ou non de faire une opération de délestage $laps_delestage = date("Y-m-d 00:00:00",strtotime("-".DELAIS_LAPS_DELESTAGE)); $sql->query("SELECT id_ope FROM mails_operations WHERE type_ope='delestage' AND date_ope>='$laps_delestage'"); if($sql->nbL()==0){ ///////////////////////////////////////////// // vidage de la pile $date_delestage = date("Y-m-d 00:00:00",strtotime("-".DELAIS_DELESTAGE)); $sql->query("DELETE FROM mails_pile_envoi WHERE envoye='1' AND date_envoi<='$date_delestage'"); // on enregistre l'opération $sql->query("INSERT INTO mails_operations(id_ope,type_ope,date_ope) VALUES ('','delestage',NOW())"); } } ?>0){ $s = array_shift($temp); $es = $decoupe_end[$s]; asort($es); $e = array_shift($es); $t = $temp; $p = array_shift($t); while($p and $p<=($e+1)){ $p = array_shift($temp); $ep = $decoupe_end[$p]; asort($ep); $e = array_shift($ep); $p = array_shift($t); } $decoupe_segments[] = array("s"=>$s,"e"=>$e); } // segmentation $segments = array(); $reste = $titre; while(count($decoupe_segments)>0){ $d = array_pop($decoupe_segments); $s = $d['s']; $e = $d['e']; $l = $e-$s; $deb = substr($reste,0,$s); $mt = substr($reste,$s,$l); $fin = substr($reste,$e); $segments[] = array("text"=>$fin,"type"=>''); $segments[] = array("text"=>$mt,"type"=>'highlight'); $reste = $deb; } $segments[] = array("text"=>$reste,"type"=>''); // reconstruction du texte krsort($segments); $titre = ""; foreach($segments as $s){ $txt = $s['text']; $typ = $s['type']; if($typ=='highlight'){ $titre .= '' . $txt . ''; }else{ $titre .= $txt; } } //retour return $titre; } function afficherResultatTexte($texte,$recherche){ // texte nettoyé $texte_wash = wash_name(html_entity_decode($texte)); // les mots recherché $word_array = convertirTexte2ArrayWords($recherche); // position du premier mot trouvé $pos1 = false; for($i=0;$i[...]'; }else{ if($pos1<=$moitie){ $p = strpos($texte," ",$taille); $texte = nl2br(trim(substr($texte,0,$p))).' [...]'; }else{ $p1 = $pos1 - $moitie; $p1a = strpos($texte," ",$p1); $p1b = strpos($texte,"\n",$p1); if($p1b>=$pos1){ if(($pos1 - $taille)>0){ $p1b = strpos($texte,"\n",($pos1 - $taille)); }else{ $p1b = 0; } } if($p1a>$p1b){ $p1 = $p1a; }else{ $p1 = $p1b; } $p2 = $pos1 + $moitie; if($p2>$len){ $texte = '[...] '.nl2br(trim(substr($texte,$p1))); }else{ $p2a = strpos($texte," ",$p2); $p2b = strpos($texte,"\n",$moitie); if($p2b<=$pos1){ $p2b = strpos($texte,"\n",($pos2 + $taille)); } if($p2a>$p2b){ $p2 = $p2a; }else{ $p2 = $p2b; } $texte = '[...] '.nl2br(trim(substr($texte,$p1,($p2-$p1)))).' [...]'; } } } } $texte_wash = wash_name(html_entity_decode($texte)); // COLORATION // recup des segments $decoupe_start = array(); $decoupe_end = array(); for($i=0;$i0){ $s = array_shift($temp); $es = $decoupe_end[$s]; asort($es); $e = array_shift($es); $t = $temp; $p = array_shift($t); while($p and $p<=($e+1)){ $p = array_shift($temp); $ep = $decoupe_end[$p]; asort($ep); $e = array_shift($ep); $p = array_shift($t); } $decoupe_segments[] = array("s"=>$s,"e"=>$e); } // segmentation $segments = array(); $reste = $texte; while(count($decoupe_segments)>0){ $d = array_pop($decoupe_segments); $s = $d['s']; $e = $d['e']; $l = $e-$s; $deb = substr($reste,0,$s); $mt = substr($reste,$s,$l); $fin = substr($reste,$e); $segments[] = array("text"=>$fin,"type"=>''); $segments[] = array("text"=>$mt,"type"=>'highlight'); $reste = $deb; } $segments[] = array("text"=>$reste,"type"=>''); // reconstruction du texte krsort($segments); $texte = ""; foreach($segments as $s){ $txt = $s['text']; $typ = $s['type']; if($typ=='highlight'){ $texte .= '' . $txt . ''; }else{ $texte .= $txt; } } //retour return $texte; } // fonction qui va convertir un texte libre en tableau de mots de plus de X lettres function convertirTexte2ArrayWords($texte,$x = 3){ $texte = trim($texte); $words=explode(" ",$texte); $word_array=array(); foreach($words as $word){ if(strlen($word)>=$x){ $word_array[] = $word; } } return $word_array; } ////////////////////////////////////////////////////////////////////////////////////////////// // Fonctions effectuants la recherche // fonction de recherche en fonction de la pertinence function rechercheAvecPertinence($sql,$word_array,$id_table,$query){ // exécution de la requete et récupération des resultats $sql->query($query); $resultats = $sql->getResult(); // init de la recherche $nbre=0; $rec_id=array(); $pert=array(); $resultat=array(); // traitement while($array = mysql_fetch_array($resultats)){ for($i=0;$i$v){ $resultat[] = $i; } // retour return $resultat; } // fonction de recherche function recherche($sql,$word_array,$id_table,$query){ // exécution de la requete et récupération des resultats $sql->query($query); $resultats = $sql->getResult(); // init de la recherche $nbre=0; $rec_id=array(); $pert=array(); $resultat=array(); // traitement while($array = mysql_fetch_array($resultats)){ for($i=0;$i$v){ $resultat[] = $i; } // retour return $resultat; } // fonction permettant de lancer la recherche sur les publications function rechercheLibre($sql,$recherche,$query){ // les mots recherché $word_array = convertirTexte2ArrayWords($recherche); // la recherche $result = rechercheAvecPertinence($sql,$word_array,"id",$query); // retour return $result; } ?>