ID) { if(isset($_GET['annonce'])) { $annonce = sanitize_text_field($_GET['annonce']); $xmlfile = 'https://www.annonces-automobile.com/script/xml/annonce.php?key=aA$Xm1&annonce='.$annonce; $xml = simplexml_load_file($xmlfile); $vehicule = htmlentities($xml->marque.' '.$xml->serie.' '.$xml->finition); return $vehicule.' - n°'.$annonce; } } else if($pagelisting==$post->ID) { if(isset($_GET['plisting'])) { $plisting = sanitize_text_field($_GET['plisting']); return $post->post_title.' - Page '.$plisting; } else { return false; } } else { return false; } } function annoncesautomobile_new_rel_canonical() { global $post; $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } if($pagedetail==$post->ID) { if(isset($_GET['annonce'])) { $annonce = sanitize_text_field($_GET['annonce']); $xmlfile = 'https://www.annonces-automobile.com/script/xml/annonce.php?key=aA$Xm1&annonce='.$annonce; $xml = simplexml_load_file($xmlfile); $vehicule = htmlentities($xml->marque.' '.$xml->serie.' '.$xml->finition); $link = 'https://www.annonces-automobile.com/acheter/voiture/'.annoncesautomobile_stripspecialchar($vehicule).'-'.$annonce; echo ''."\n"; } } else if($pagelisting==$post->ID) { $pos = strpos($_SERVER['REQUEST_URI'], '?'); if($pos!==false){ echo ''."\n"; } echo ''."\n"; } else { echo ''."\n"; } } function annoncesautomobile_recherche_register_widget() { register_widget('annoncesautomobile_recherche_widget'); } class annoncesautomobile_recherche_widget extends WP_Widget { function __construct() { parent::__construct( 'annoncesautomobile_recherche_widget', __('Annonces Automobile recherche', ' hstngr_widget_domain'), array( 'description' => __( 'Ajoutez un moteur de recherche pour vos annonces', 'hstngr_widget_domain' ), ) ); } public function widget( $args, $instance ) { $affichage = ''; $affichageparam = ''; $pagelisting = ''; $pagedetail = ''; $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } $tmarque = array(); $xmlfile = 'https://www.annonces-automobile.com/script/xml/marques.php?key=aA$Xm1'; if($affichage=='marque'){ $xmlfile .= '&marque='.$affichageparam; } if($affichage=='client' && !empty($affichageparam)){ $xmlfile .= '&client='.$affichageparam; } $xml = simplexml_load_file($xmlfile); foreach($xml->marque as $m){ $tmarque[] = array($m->id, $m->nom); } $tmodele = array(); if(isset($_GET['marque'])) { $getmarque = sanitize_text_field($_GET['marque']); $xmlfile = 'https://www.annonces-automobile.com/script/xml/series.php?key=aA$Xm1&marque='.$getmarque; if($affichage=='client' && !empty($affichageparam)){ $xmlfile .= '&client='.$affichageparam; } $xml = simplexml_load_file($xmlfile); foreach($xml->serie as $m){ $tmodele[] = array($m->id, $m->nom); } } else if($affichage=='marque' && count(explode(',', $affichageparam))==1) { $xmlfile = 'https://www.annonces-automobile.com/script/xml/series.php?key=aA$Xm1&marque='.$affichageparam; $xml = simplexml_load_file($xmlfile); foreach($xml->serie as $m){ $tmodele[] = array($m->id, $m->nom); } } $tcategorie = array(); $xmlfile = 'https://www.annonces-automobile.com/script/xml/categories.php?key=aA$Xm1'; if($affichage=='categorie'){ $xmlfile .= '&categorie='.$affichageparam; } $xml = simplexml_load_file($xmlfile); foreach($xml->categorie as $c){ $tcategorie[] = array($c->id, $c->nom); } $tenergie = array(); $xmlfile = 'https://www.annonces-automobile.com/script/xml/energies.php?key=aA$Xm1'; $xml = simplexml_load_file($xmlfile); foreach($xml->energie as $e){ $tenergie[] = array($e->id, $e->nom); } echo '

Rechercher une voiture

'; if($affichage!='marque' || ($affichage=='marque' && count(explode(',', $affichageparam))>1)) { echo '
'; } echo '
'; if($affichage!='categorie' || ($affichage=='categorie' && count(explode(',', $affichageparam))>1)) { echo '
'; } echo '



'; } public function form($instance){} public function update($new_instance, $old_instance){} } function annoncesautomobile_admin_menu() { add_menu_page('Annonces Automobile', 'Annonces Automobile', 'manage_options', 'annonces-automobile/admin.php', 'annoncesautomobile_admin_page', 'dashicons-performance', 6 ); } function annoncesautomobile_admin_page() { $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $annonceschoice = 'all|'; $affichage = ''; $affichageparam = ''; $pagelisting = ''; $pagedetail = ''; $nbparpage = 10; $tmarque = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/marques.php?key=aA$Xm1'); foreach($xml->marque as $m){ $tmarque[] = array($m->id, $m->nom); } $tcategorie = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/categories.php?key=aA$Xm1'); foreach($xml->categorie as $c){ $tcategorie[] = array($c->id, $c->nom); } if(isset($_POST['action'])){ $postaction = sanitize_text_field($_POST['action']); } if(isset($_POST['annonceschoice'])){ $postannonceschoice = sanitize_text_field($_POST['annonceschoice']); } if(isset($postaction) && $postaction=='annonces-automobile-param' && isset($postannonceschoice)) { $choice = 'all|'; switch($postannonceschoice) { case 'all': $choice = 'all|'; break; case 'marque': if(isset($_POST['marques'])){ $postmarques = array_map('sanitize_text_field', wp_unslash($_POST['marques'])); } if(isset($postmarques)) { $choice = 'marque|'.implode(',',$postmarques); } break; case 'categorie': if(isset($_POST['categories'])){ $postcategories = array_map('sanitize_text_field', wp_unslash($_POST['categories'])); } if(isset($postcategories)) { $choice = 'categorie|'.implode(',',$postcategories); } break; case 'client': if(isset($_POST['client'])){ $postclient = sanitize_text_field($_POST['client']); } if(isset($postclient)) { $choice = 'client|'.$postclient; } break; default: $choice = 'all|'; break; } if(isset($_POST['listing'])){ $postlisting = sanitize_text_field($_POST['listing']); } if(isset($_POST['detail'])){ $postdetail = sanitize_text_field($_POST['detail']); } if(isset($_POST['nbparpage'])){ $postnbparpage = sanitize_text_field($_POST['nbparpage']); } if(isset($_POST['depot'])){ $postdepot = sanitize_text_field($_POST['depot']); } $choice .= '|'.intval($postlisting).'|'.intval($postdetail).'|'.intval($postnbparpage).'|'.intval($postdepot); file_put_contents($annoncesautomobilepath.'listing.txt', $choice); } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } if(isset($tabchoice[5])){ $pagedepot = $tabchoice[5]; } ?>

Administration Annonces Automobile


Annonces Automobile

Affichez vos annonces sur vos pages par le biais du module Annonces-Automobile.com.

Affichage des annonces

Ci-dessous, choisissez les annonces à afficher en faisant votre choix. Par défaut toutes les annonces seront affichées.

/>

/> :

/> :

/> :

Page de listing

Créez votre page de listing en y insérant dans son contenu le tag ci-dessous.

[annoncesautomobile_listing]

Indiquez la page sur laquelle figure votre tag de listing.

Page de listing :

Nombre d'annonces par page :

Page de détail

Créez votre page de détail en y insérant dans son contenu le tag ci-dessous.

[annoncesautomobile_detail]

Indiquez la page sur laquelle figure votre tag de détail.

Page de détail :

Page de dépôt d'annonce

Créez votre page de dépôt d'annonce en y insérant dans son contenu le tag ci-dessous.

[annoncesautomobile_depot]

Indiquez la page sur laquelle figure votre tag de dépôt.

Page de dépôt d'annonce :

marque as $m){ $tmarque[] = array($m->id, $m->nom); } $tmodele = array(); if(isset($marque) && !empty($marque)) { $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/series.php?key=aA$Xm1&marque='.$marque.'&all=true'); foreach($xml->serie as $m){ $tmodele[] = array($m->id, $m->nom); } } $tenergie = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/energies.php?key=aA$Xm1'); foreach($xml->energie as $e){ $tenergie[] = array($e->id, $e->nom); } $tcategorie = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/categories.php?key=aA$Xm1'); foreach($xml->categorie as $c){ $tcategorie[] = array($c->id, $c->nom); } $tdepartement = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/departements.php?key=aA$Xm1'); foreach($xml->departement as $d){ $tdepartement[] = array($d->id, $d->num.' - '.$d->nom); } $tcommune = array(); if(isset($departement_temp) && !empty($departement_temp)) { $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/communes.php?key=aA$Xm1&departement='.$departement_temp); foreach($xml->commune as $c){ $tcommune[] = array($c->id, $c->nom); } } $currentyear = date("Y"); $tannee = array(); for($i=$currentyear;$i>=($currentyear-60);$i--){ $tannee[] = $i; } $tmois = array(); for($i=1;$i<=12;$i++) { $zero = ""; if(strlen($i)==1){ $zero = "0"; } $tmois[] = $zero.$i; } $tnbmois = array(); for($i=1;$i<=36;$i++){ $tnbmois[] = $i; } $_SESSION['id_client'] = md5($_SERVER['REMOTE_ADDR']); $returnpaiement = false; $reponse = ''; if(isset($_POST['action'])){ $postaction = sanitize_text_field($_POST['action']); } if(isset($postaction) && $postaction=='depot-annonce') { $sendemail = true; $reponsemail = ''; $postetat = ''; $postmarque = ''; $postmodele = ''; $postfinition = ''; $postcategorie = ''; $postenergie = ''; $postmois = ''; $postannee = ''; $postkm = ''; $posttransmission = ''; $postnbportes = ''; $postpuissance_cv = ''; $postpuissance_ch = ''; $postemission_co2 = ''; $postcouleur_ext = ''; $postcouleur_int = ''; $postgarantie_mois = ''; $postgarantie_constructeur = ''; $postdescriptif = ''; $postprix = ''; $postcontact_temp = ''; $postadresse_temp = ''; $postdepartement_temp = ''; $postcommune_temp = ''; $postcp_temp = ''; $posttel1_temp = ''; $posttel2_temp = ''; $postemail1_temp = ''; $postemail2_temp = ''; if(isset($_POST['etat'])){ $postetat = sanitize_text_field($_POST['etat']); } if(isset($_POST['marque'])){ $postmarque = sanitize_text_field($_POST['marque']); } if(isset($_POST['modele'])){ $postmodele = sanitize_text_field($_POST['modele']); } if(isset($_POST['finition'])){ $postfinition = sanitize_text_field($_POST['finition']); } if(isset($_POST['categorie'])){ $postcategorie = sanitize_text_field($_POST['categorie']); } if(isset($_POST['energie'])){ $postenergie = sanitize_text_field($_POST['energie']); } if(isset($_POST['mois'])){ $postmois = sanitize_text_field($_POST['mois']); } if(isset($_POST['annee'])){ $postannee = sanitize_text_field($_POST['annee']); } if(isset($_POST['km'])){ $postkm = sanitize_text_field($_POST['km']); } if(isset($_POST['transmission'])){ $posttransmission = sanitize_text_field($_POST['transmission']); } if(isset($_POST['nbportes'])){ $postnbportes = sanitize_text_field($_POST['nbportes']); } if(isset($_POST['puissance_cv'])){ $postpuissance_cv = sanitize_text_field($_POST['puissance_cv']); } if(isset($_POST['puissance_ch'])){ $postpuissance_ch = sanitize_text_field($_POST['puissance_ch']); } if(isset($_POST['emission_co2'])){ $postemission_co2 = sanitize_text_field($_POST['emission_co2']); } if(isset($_POST['couleur_ext'])){ $postcouleur_ext = sanitize_text_field($_POST['couleur_ext']); } if(isset($_POST['couleur_int'])){ $postcouleur_int = sanitize_text_field($_POST['couleur_int']); } if(isset($_POST['garantie_mois'])){ $postgarantie_mois = sanitize_text_field($_POST['garantie_mois']); } if(isset($_POST['garantie_constructeur'])){ $postgarantie_constructeur = sanitize_text_field($_POST['garantie_constructeur']); } if(isset($_POST['descriptif'])){ $postdescriptif = sanitize_text_field($_POST['descriptif']); } if(isset($_POST['prix'])){ $postprix = sanitize_text_field($_POST['prix']); } if(isset($_POST['contact_temp'])){ $postcontact_temp = sanitize_text_field($_POST['contact_temp']); } if(isset($_POST['adresse_temp'])){ $postadresse_temp = sanitize_text_field($_POST['adresse_temp']); } if(isset($_POST['departement_temp'])){ $postdepartement_temp = sanitize_text_field($_POST['departement_temp']); } if(isset($_POST['commune_temp'])){ $postcommune_temp = sanitize_text_field($_POST['commune_temp']); } if(isset($_POST['cp_temp'])){ $postcp_temp = sanitize_text_field($_POST['cp_temp']); } if(isset($_POST['tel1_temp'])){ $posttel1_temp = sanitize_text_field($_POST['tel1_temp']); } if(isset($_POST['tel2_temp'])){ $posttel2_temp = sanitize_text_field($_POST['tel2_temp']); } if(isset($_POST['email1_temp'])){ $postemail1_temp = sanitize_text_field($_POST['email1_temp']); } if(isset($_POST['email2_temp'])){ $postemail2_temp = sanitize_text_field($_POST['email2_temp']); } $photosmall = array(); $photobig = array(); for($i=1;$i<=11;$i++) { if(file_exists($annoncesautomobilepath.'photos/big/'.$_SESSION["id_client"].'/'.$i.'.jpg')){ $photobig[] = $annoncesautomobileurl.'photos/big/'.$_SESSION["id_client"].'/'.$i.'.jpg'; } } $postphotobig = implode(';',$photobig); $args = array( 'headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' ), 'body' => "key=aA$!n5ert&etat=".$postetat."&marque=".$postmarque."&modele=".$postmodele."&finition=".$postfinition."&categorie=".$postcategorie."&energie=".$postenergie."&mois=".$postmois."&annee=".$postannee."&km=".$postkm."&transmission=".$posttransmission."&nbportes=".$postnbportes."&puissance_cv=".$postpuissance_cv."&puissance_ch=".$postpuissance_ch."&emission_co2=".$postemission_co2."&couleur_ext=".$postcouleur_ext."&couleur_int=".$postcouleur_int."&garantie_mois=".$postgarantie_mois."&garantie_constructeur=".$postgarantie_constructeur."&descriptif=".$postdescriptif."&prix=".$postprix."&contact=".$postcontact_temp."&adresse=".$postadresse_temp."&departement=".$postdepartement_temp."&commune=".$postcommune_temp."&cp=".$postcp_temp."&tel1=".$posttel1_temp."&tel2=".$posttel2_temp."&email1=".$postemail1_temp."&email2=".$postemail2_temp."&photobig=".$postphotobig."&origine=".$_SERVER['HTTP_HOST'] ); $server_output = wp_remote_post('https://www.annonces-automobile.com/script/xml/depot_annonce.php', $args); $reponse = $server_output['body']; if(is_numeric($reponse)) { $reponsemail = $reponse; $returnpaiement = true; } else { $reponsemail = $reponse; } } if($returnpaiement) { $html = '

Validez votre annonce

Votre annonce a bien été enregistrée !

Validez la mise en ligne de votre annonce en procédant au paiement de 29 € grâce au service Stripe.

'; } else { $html = '

Déposez votre annonce sur '.$_SERVER['SERVER_NAME'].' et Annonces-Automobile.com pour 29 € !

Ci-dessous, décrivez votre annonce et ajoutez des photos. Nous vous recommandons d\'être précis dans votre description et d\'ajouter des photos de bonne qualité.

'; $html .= '

Photos du véhicule

Commencez par ajouter les photos de votre véhicule. Attention, les photos doivent être au format JPG avec un poid maximal de 4 Mo.

Photo principale

'; $urlphoto = plugin_dir_url(__FILE__).'images/photo.jpg'; $hidden = ' hidden'; if(file_exists($annoncesautomobilepath.'photos/small/'.$_SESSION["id_client"].'/1.jpg')) { $urlphoto = $annoncesautomobileurl.'photos/small/'.$_SESSION["id_client"].'/1.jpg'; $hidden = ''; } $html .= 'Supprimer la photo Logo

Autres photos

'; $j = 0; for($i=2;$i<=11;$i++) { $j++; $html .= '
'; $urlphoto = plugin_dir_url(__FILE__).'images/photo.jpg'; $hidden = ' hidden'; if(file_exists($annoncesautomobilepath.'photos/small/'.$_SESSION["id_client"].'/'.$i.'.jpg')) { $urlphoto = $annoncesautomobileurl.'photos/small/'.$_SESSION["id_client"].'/'.$i.'.jpg'; $hidden = ''; } $html .= 'Supprimer la photo Logo
'; if($j==2){ $html .= '
'; $j=0; } } $html .= ''; $html .= '

Caractériques de votre véhicule

Type / Etat *
Modèle *
Finition
Catégorie *
Energie *
Mise en circulation
 / 
Kilométrage *
Transmission
CV fiscaux
Emission CO2 (g/km)
Couleur extérieure
Couleur intérieure
Garantie

Prix de vente

Déterminez le prix de votre véhicule qui sera visible par les internautes.

Prix (€ TTC) *
'; $html .= '

Information de compte et coordonnées

Si vous avez déjà un compte sur Annonces-Automobile.com, utilisez le formulaire de connexion. Sinon, remplissez le formulaire d\'inscription.

Attention, les informations de contact (Téléphone et e-mail) que vous saisissez sont importantes ! Elles seront utilisées par les internautes qui seront intéressés par votre annonce de voiture.

Je m\'inscris

Nom et
prénom *
Adresse
Département
ou pays *
Commune *
Code postal
N° de tél. 1 *
N° de tél. 2
E-mail *
Resaisissez votre e-mail *

En vous inscrivant sur Annonces-Automobile.com vous acceptez nos conditions d\'utilisation.

Si vous êtes déjà inscrit, publiez votre annonce depuis le site https://www.annonces-automobile.com


'; if(!empty($reponse)){ $html .= '

'.$reponsemail.'

'; } $html .= '

* Données obligatoires pour valider votre annonce

'; } return $html; } function annoncesautomobile_listing() { $html = ''; $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $annonceschoice = 'all|'; $affichage = ''; $affichageparam = ''; $pagelisting = ''; $pagedetail = ''; $nbparpage = 10; $nbresult = 0; $page = 1; if(isset($_GET['plisting'])){ $getlisting = sanitize_text_field($_GET['plisting']); } if(isset($getlisting)){ $page = $getlisting; } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } $xmlfile = 'https://www.annonces-automobile.com/script/xml/annonces.php?key=aA$Xm1'; if(isset($_GET['marque'])){ $getmarque = sanitize_text_field($_GET['marque']); } if(isset($getmarque)) { $xmlfile .= '&marque='.$getmarque; } if(isset($_GET['modele'])){ $getmodele = sanitize_text_field($_GET['modele']); } if(isset($getmodele)) { $xmlfile .= '&serie='.$getmodele; } if(isset($_GET['energie'])){ $getmodele = sanitize_text_field($_GET['energie']); } if(isset($getmodele)) { $xmlfile .= '&energie='.$getmodele; } if(isset($_GET['km'])){ $getkm = sanitize_text_field($_GET['km']); } if(isset($getkm)) { $xmlfile .= '&km='.$getkm; } if(isset($_GET['prix_max'])){ $getprix_max = sanitize_text_field($_GET['prix_max']); } if(isset($getprix_max)) { $xmlfile .= '&prix_max='.$getprix_max; } if(isset($_GET['prix_min'])){ $getprix_min = sanitize_text_field($_GET['prix_min']); } if(isset($getprix_min)) { $xmlfile .= '&prix_min='.$getprix_min; } if(isset($_GET['categorie'])){ $getcategorie = sanitize_text_field($_GET['categorie']); } if(isset($getcategorie)) { $xmlfile .= '&categorie='.$getcategorie; } if($affichage=='marque') { $xmlfile .= '&marque='.$affichageparam; } else if($affichage=='categorie') { $xmlfile .= '&categorie='.$affichageparam; } else if($affichage=='client') { $xmlfile .= '&client='.$affichageparam; } $xmlcount = simplexml_load_file($xmlfile.'&mode=count'); if(isset($xmlcount[0]) && !empty($xmlcount[0])){ $nbresult = $xmlcount[0]; } if($page==1) { $xmlfile .= '&limit_from='.$nbparpage; } else if($page>1) { $xmlfile .= '&limit_from='.(($page-1)*$nbparpage).'&limit='.$nbparpage; } $xml = simplexml_load_file($xmlfile); foreach($xml->annonce as $ann) { $html .= '
'.$ann->marque.' '.$ann->modele.'
'.number_format(intval($ann->prix), 0, ',', '.').' €
'.$ann->marque.' '.$ann->serie.' '.$ann->finition.'
'; $date = explode('-', $data['mise_circulation']); $descriptif = $ann->categorie.'
'; if(!empty($ann->energie) && $ann->energie!='N. C.'){ $descriptif .= $ann->energie.' - '; } if(!empty($ann->km) && $ann->km!=0){ $descriptif .= number_format(intval($ann->km), 0, ',', '.').' Km - '; } $descriptif .= $ann->annee; $descriptif = trim($descriptif); if(substr($descriptif, -1)=='-'){ $descriptif = substr($descriptif, 0, -1); } $html .= $descriptif; $html .= '
'; } $annoncetrouvee = 'Aucune annonce trouvée pour votre recherche.'; if($nbresult==1){ $annoncetrouvee = '1 annonce trouvée'; } if($nbresult>1){ $annoncetrouvee = $nbresult.' annonces trouvées'; } $html .= '

'.$annoncetrouvee.'

'; $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $html .= annoncesautomobile_numero_page($nbresult, $nbparpage, $page, $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); return $html; } function annoncesautomobile_detail() { $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } $tdepartement = array(); $xml = simplexml_load_file('https://www.annonces-automobile.com/script/xml/departements.php?key=aA$Xm1'); foreach($xml->departement as $d){ $tdepartement[] = array($d->id, $d->nom); } $html = ''; $getannonce = ''; $xmlfile = 'https://www.annonces-automobile.com/script/xml/annonce.php?key=aA$Xm1'; if(isset($_GET['annonce'])){ $getannonce = sanitize_text_field($_GET['annonce']); } if(isset($getannonce) && !empty($getannonce)){ $xmlfile .= '&annonce='.$getannonce; } $xml = simplexml_load_file($xmlfile); $vehicule = htmlentities($xml->marque.' '.$xml->serie.' '.$xml->finition); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $returnemail = false; $sendemail = false; if(isset($_POST['action'])){ $postaction = sanitize_text_field($_POST['action']); } if(isset($postaction) && $postaction=='envoi-email') { $sendemail = true; $reponsemail = ''; $postnom = ''; $postemail = ''; $posttel = ''; $postdepartement = ''; $postmessage = ''; if(isset($_POST['nom'])){ $postnom = sanitize_text_field($_POST['nom']); } if(isset($_POST['email'])){ $postemail = sanitize_text_field($_POST['email']); } if(isset($_POST['tel'])){ $posttel = sanitize_text_field($_POST['tel']); } if(isset($_POST['departement'])){ $postdepartement = sanitize_text_field($_POST['departement']); } if(isset($_POST['message'])){ $postmessage = sanitize_text_field($_POST['message']); } $args = array( 'headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' ), 'body' => "key=aA$!n5ert&nom=".$postnom."&email=".$postemail."&tel=".$posttel."&departement=".$postdepartement."&message=".$postmessage."&annonce=".$getannonce."&origine=".$_SERVER['HTTP_HOST'] ); $server_output = wp_remote_post( 'https://www.annonces-automobile.com/script/xml/email_envoi.php', $args ); $reponse = $server_output['body']; if($reponse!='0') { if($reponse=='1') { $reponsemail = 'Votre message a bien été envoyé'; $returnemail = true; } else { $reponsemail = $reponse; } } } $html .= '

'.$vehicule.'

'; if(intval($xml->prix)>100) { $html .= number_format(intval($xml->prix), 0, ',', '.').' €'; } else { echo 'Prix sur demande'; } $html .= '
'; $i=0; $bigimg = ''; $smallimg = ''; foreach($xml->photos->photo as $photo) { $i++; $itemprop = ''; if($i==1){ $itemprop = ' itemprop="image"'; } $bigimg .= '
  • '; } if($i!=0) { $html .= '
      '.$bigimg.'
    '; } $html .= '
    '; if($xml->client->contrat!='Particulier') { $html .= ''.$xml->client->nom.'
    '.$xml->client->adresse.'
    '.$xml->client->cp.' '.ucfirst($xml->client->ville).'
    Département : '.$xml->client->departement.' ('.$xml->client->departement_num.')'; } else { $html .= 'Particulier
    '.$xml->client->cp.' '.ucfirst($xml->client->ville).'
    Département : '.$xml->client->departement.' ('.$xml->client->departement_num.')'; } $html .= '
    Contacter par téléphone'; if(!$sendemail){ $html .= 'Contacter par e-mail'; } $html .= '

    '; } $html .= '
    Nom & prénom

    N° de téléphone

    Adresse e-mail

    Département

    Message

    '; } else { $html .= '

    '.$reponsemail.'

    '; } $html .= '

    Caractéristiques du véhicule

    Marque '.$xml->marque.' Kilométrage '; if(intval($xml->km)!=0){ $html .= $xml->km.' km'; }else{ $html .= '-'; } $html .= '
    Modèle '.$xml->serie.' Mise en circulation '; if($xml->annee!='00/0000'){ $html .= $xml->annee; }else{ $html .= '-'; } $html .= '
    Finition '; $finition = trim($xml->finition); if(!empty($finition)){ $html .= $finition; }else{ $html .= '-'; } $html .= ' Garantie '; $garantie = trim($xml->garantie); if(!empty($garantie)){ $html .= $garantie; }else{ $html .= '-'; } $html .= '
    Catégorie '.$xml->categorie.' Couleur int. '; $couleur_int = trim($xml->couleur_int); if(!empty($couleur_int)){ $html .= $couleur_int; }else{ $html .= '-'; } $html .= '
    Energie '; $energie = trim($xml->energie); if(!empty($energie)){ $html .= $energie; }else{ $html .= '-'; } $html .= ' Couleur ext. '; $couleur_ext = trim($xml->couleur_ext); if(!empty($couleur_ext)){ $html .= $couleur_ext; }else{ $html .= '-'; } $html .= '
    Transmission '; $transmission = trim($xml->transmission); if(!empty($transmission)){ $html .= $transmission; }else{ $html .= '-'; } $html .= ' Nb. de portes '; if(intval($xml->nb_portes)!=0){ $html .= $xml->nb_portes; }else{ $html .= '-'; } $html .= '
    Puis. fiscale '; if(intval($xml->puissance_fisc)!=0){ $html .= $xml->puissance_fisc.' cv'; }else{ $html .= '-'; } $html .= ' Emission CO2
    Puis. DIN '; if(intval($xml->puissance_din)!=0){ $html .= $xml->puissance_din.' ch ('.ceil($xml->puissance_din*0.736).' kW)'; }else{ $html .= '-'; } $html .= ' Référence '; $reference = trim($xml->reference); if(!empty($reference)){ $html .= $reference; }else{ $html .= '-'; } $html .= '
    '; $descriptif = trim($xml->descriptif); if(!empty($descriptif)) { $html .= '

    Description et équipements

    '.nl2br($descriptif).'

    '; } $html .= '
    '; return $html; } function annoncesautomobile_listing_js() { global $post; $annoncesautomobilepath = annoncesautomobile_wordpress_uploads_directory_path().'annoncesautomobile/'; if(!is_dir($annoncesautomobilepath)) { mkdir($annoncesautomobilepath, 0777, true); $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'w+'); fclose($listingfile); } $listingfile = fopen($annoncesautomobilepath.'listing.txt', 'r+'); $listingline = fgets($listingfile); if(!empty($listingline)){ $annonceschoice = $listingline; } fclose($listingfile); $tabchoice = explode('|', $annonceschoice); if(isset($tabchoice[0])){ $affichage = $tabchoice[0]; } if(isset($tabchoice[1])){ $affichageparam = $tabchoice[1]; } if(isset($tabchoice[2])){ $pagelisting = $tabchoice[2]; } if(isset($tabchoice[3])){ $pagedetail = $tabchoice[3]; } if(isset($tabchoice[4])){ $nbparpage = $tabchoice[4]; } if(isset($tabchoice[5])){ $pagedepot = $tabchoice[5]; } echo ' '; } function annoncesautomobile_stripspecialchar($url) { $url = utf8_decode($url); $url = strtr($url, utf8_decode('ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ()[]\'"~$&%*@ç!?;,:/\^¨€{}<>|+.- `³²� °´#×'), 'aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn -- c --- e ---32 x'); $url = preg_replace('/([^.a-z0-9]+)/i', '-', $url); $url = str_replace(' ', '', $url); $url = str_replace('---', '-', $url); $url = str_replace('--', '-', $url); $url = trim($url, '-'); return strtolower($url); } function annoncesautomobile_numero_page($nbresult, $per_page=15, $page=1, $url) { global $nextpage; global $urlnextpage; global $urlprevpage; // Récupération et traitement de l'url courrante en supprimant la variable "plisting" $url = str_replace('&plisting=', '[*plisting=]', $url); $url = str_replace('?plisting=', '[!plisting=]', $url); $url = str_replace('&plisting', '&[plisting]', $url); $url = str_replace('?plisting', '?[plisting]', $url); $url = str_replace('[*plisting=]', '&plisting=', $url); $url = str_replace('[!plisting=]', '?plisting=', $url); $url = preg_replace('/&plisting(=[^&]*)?|^plisting(=[^&]*)?&?/', '', $url); $url = preg_replace('/&plisting(=[^&]*)?|^plisting(=[^&]*)?&?/', '', $url); $url = preg_replace('/\?plisting(=[^&]*)?|^plisting(=[^&]*)?&?/', '', $url); $url = str_replace('&[plisting]', '&plisting', $url); $url = str_replace('?[plisting]', '?plisting', $url); $url = str_replace('&', '&', $url); $separator = '&'; if(strrpos($url, '?') === false){ $separator = '?'; } $url = $url.$separator; $adjacents = "2"; $prevlabel = "‹"; $nextlabel = "›"; $page = ($page == 0 ? 1 : $page); $start = ($page - 1) * $per_page; $prev = $page - 1; $next = $page + 1; $lastpage = ceil($nbresult/$per_page); $lpm1 = $lastpage - 1; // //last page minus 1 $pagination = ""; if($lastpage > 1){ $pagination .= ""; } return $pagination; }