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 '
'; } 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]; } ?>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é.
Commencez par ajouter les photos de votre véhicule. Attention, les photos doivent être au format JPG avec un poid maximal de 4 Mo.
';
$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 .= '
|
';
$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 .= '
|