par
Lilou000 » 12 avr. 2013, 08:58
Ci-dessous je mets les fichiers concernés, peut-être que ça pourra donner une piste à quelqu'un
Merci en tout cas !
PAGE INDEX.PHP qui contient le moteur de recherche et affiche les résultats:
<?php
session_cache_limiter('private, must-revalidate');
include 'include/config.php';
$vh->nbParPage = 16;
if(!$_GET['back'])
{
////////// Récupération page en cours
if(!$_GET['page']) {
$page = 1;
$vh->reset();
}
else{
$page = $_GET['page'];
}
////////Récupération des données POST
if(!empty($_POST)) {
/* hack pour les prix min et max */
if($_POST['mini'] != '~')
{
$_POST['prix_min'] = $_POST['mini'];
}
if($_POST['maxi'] != '~')
{
$_POST['prix_max'] = $_POST['maxi'];
}
$vh->loadPostData($_POST);
}
////////// Récupération des données GET
else $vh->loadGetData($_GET);
//////// Récupération des annonces
$vh->page = $page;
}
$annonces = $vh->search();
$navLinks = $vh->getNavLinks();
$priceList = array(
2000,
4000,
6000,
8000,
10000,
12000,
14000,
16000,
18000,
20000,
25000,
30000,
35000,
40000,
50000,
100000
);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>xxxxxxxx</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--STYLES-->
<link rel="stylesheet" type="text/css" href="../css/styles.css" />
<!--TYPOS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css'>
<!--MODERNIZR-->
<script type="text/javascript" src="../js/modernizr.custom.24399.js"></script>
<!--JQUERY-->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!--SCRIPT NAVIGATION-->
<link rel="stylesheet" href="../css/megamenu.css">
<script type="text/javascript" src="../js/megamenu_plugins.js"></script>
<script type="text/javascript" src="../js/megamenu.js"></script>
<script>
$(document).ready(function($){
$('.megamenu').megaMenuCompleteSet({
menu_speed_show : 300,
menu_speed_hide : 200,
menu_speed_delay : 200,
menu_effect : 'hover_slide',
menu_click_outside : 1,
menu_show_onload : 0
});
});
</script>
<!-- LOADER IMAGE -->
<script src="/js/jquery.preloadify.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$(".loading-photo").preloadify({ force_icon:true
});
});
</script>
<!--CRITERES SUPPLEMENTAIRES-->
<script type="text/javascript">
$(document).ready(function(){
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
});
});
</script>
<!-- SLIDER PRIX -->
<script charset="utf-8" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript" src="../js/selectToUISlider.jQuery.js"></script>
<link rel="stylesheet" href="../css/slider-prix/redmond/jquery-ui-1.7.1.custom.css" type="text/css" />
<link rel="Stylesheet" href="../css/slider-prix/ui.slider.extras.css" type="text/css" />
<!--SOCIAL-->
<link rel="stylesheet" media="screen" href="../arscode-social-slider/fblb.css"/>
<!--[if lte IE 7]>
<link rel="stylesheet" media="screen" href="../arscode-social-slider/ie7.css?ver=3.2.1" />
<![endif]-->
<script type="text/javascript" src="../arscode-social-slider/js/userscripts.js"></script>
<!--[if lte IE 7]>
<script type="text/javascript" src="../arscode-social-slider/js/userscripts-ie7.js"></script>
<![endif]-->
<!--VIDEO BACKGROUND
<script type="text/javascript" src="../js/jquery.mb.YTPlayer.js"></script>
<link href="../css/YTPlayer.css" media="all" rel="stylesheet" type="text/css">
<script>
jQuery(function(){
jQuery(".player").mb_YTPlayer();
});
</script>-->
</head>
<body>
<!--HEADER-->
<?php include("../inc/header.php");?>
<!--FIN HEADER-->
<!--NAVIGATION-->
<?php include("../inc/menu.php");?>
<!--FIN NAVIGATION-->
<!--CONTENEUR PAGE-->
<div id="conteneur-page" style="padding-top:0px;">
<!--MOTEUR DE RECHERCHE-->
<div id="conteneur-moteur">
<form action="../occasions/index.php" method="post" id="moteur_form2">
<!--COLONNE CHAMPS 1-->
<div id="conteneur-champs">
<!--CHAMPS MARQUE-->
<div class="champs">
<label for="marque">MARQUE</label>
<select name="marque" id="marque" onchange="loadModeles(this)">
<option value="">Toutes les marques</option>
<?php
$marques = $vh->getPopulatedMarques();
$_DATA['marques'] = $marques;
foreach($marques as $marque) {
if($marque)
if(strtoupper($vh->marque) == $marque) echo '<option value="'.$marque.'" selected="selected">'.ucfirst(strtolower($marque)).'</option>';
else echo '<option value="'.$marque.'">'.ucfirst(strtolower($marque)).'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS MARQUE-->
<div class="champs">
<label for="modele">MODÈLE</label>
<select name="modele"<?=((empty($vh->marque))?' disabled="disabled"':null)?> id="modele" >
<option value="">Tous les modèles</option>
<?
if(!empty($vh->marque)){
$modeles=$vh->getPopulatedModeles($vh->marque);
foreach($modeles as $modele){
echo '<option value="'.$modele.'"'.((strtoupper($vh->modele)==$modele)?' selected="selected"':null).'>'.$modele.'</option>';
}
}
?>
</select>
</div>
</div>
<!--FIN COLONNE CHAMPS 1-->
<!--COLONNE CHAMPS 2-->
<div id="conteneur-champs">
<!--CHAMPS CATEGORIE-->
<div class="champs">
<label for="categorie">CATÉGORIE</label>
<select name="categorie" id="categorie">
<option value="">Toutes les catégories</option>
<?php
$categories=$vh->getCategories();
foreach($categories as $categorie){
echo "<option value=\"$categorie\" ".((strtolower($categorie) == strtolower($vh->categorie))?'selected="selected"':'').">". ucfirst(strtolower($categorie)) . "</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS CATEGORIE-->
<div class="champs">
<label for="modele">ÉNERGIE</label>
<select name="motorisation" id="energie">
<option value="">Toutes les énergies</option>
<?php
$motorisations=$vh->getMotorisations();
foreach($motorisations as $motorisation){
echo "<option value=\"$motorisation\" ".(($motorisation == $vh->motorisation)?'selected="selected"':'').">$motorisation</option>";
}
?>
</select>
</div>
</div>
<!--FIN COLONNE CHAMPS 2-->
<!--COLONNE CHAMPS 3-->
<div class="champs" style="padding-left:40px;">
<div id="wrapperslider" style="width:405px; margin-top:10px;">
<p align="center" style="font-family: 'Montserrat', sans-serif; color:#232323;"><label for="mini">VOTRE BUDGET</label></p>
<div style=" margin-top:-10px;">
<select name="mini" id="mini" style="visibility:hidden; height:1px;">
<option value="0" selected="selected" >0 €</option>
<?php foreach($priceList as $price) { ?>
<option value="<?=$price?>" <?php if($price == $vh->prix_min) { ?> selected="selected" <?php } ?>><?=$price?> €</option>
<?php } ?>
<option value="~">+ 100.000€</option>
</select>
<select name="maxi" id="maxi" style="visibility:hidden; height:1px;">
<option value="null">Prix maximum</option>
<?php foreach($priceList as $price) { ?>
<option value="<?=$price?>" <?php if($price == $vh->prix_max) { ?> selected="selected" <?php } ?>><?=$price?> €</option>
<?php } ?>
<option value="~" <?php if(!$vh->prix_max || !in_array($vh->prix_max, $priceList) || $vh->prix_max == '~') { ?> selected="selected" <?php } ?>>+ 100000 €</option>
</select>
</div>
</div>
</div>
<!--[if IE]>
<div id="btn-recherche-generale" style="padding-top:50px;"><input type="submit" name="submit" value="submit" /></div>
<![endif]-->
<!--[if !IE]><!-->
<div id="btn-recherche-generale"><input type="submit" name="submit" value="submit" /></div><!--<![endif]-->
<!--FIN COLONNE CHAMPS 3-->
</div>
<div id="panel">
<!--CHAMPS SUPPLEMENTAIRES-->
<div id="conteneur-champs" style="width:140px;">
<!--CHAMPS KMS-->
<div class="champs" style="width:140px;">
<label class="l2 km">Kilométrage minimum</label>
<select name="kms_min" class="kms" id="kms_min" onchange="updateKmsMax(this.value);" >
<?
$selected=($vh->kms_min)?$vh->kms_min:0;
for($i=0;$i<=95000;$i+=5000){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.(($i==100000)?'+ de ':null).number_format($i,0,'',' ').'</option>';
}
?>
</select>
</div>
<div class="champs">
<label style="float:left" class="l2 an">Année de</label>
<select name="millesime_min" id="an_min" class="an" onchange="updateAnMax(this.value);" style="clear:both; float:left">
<?
$selected=($_POST['millesime_min'])?$_POST['millesime_min']:1990;
for($i=1985;$i<=intval(date('Y'))-1;$i++){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.$i.'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS KMS-->
</div>
<div id="conteneur-champs">
<!--CHAMPS ANNEE-->
<div class="champs">
<label class="l2 km">Kilométrage maximum</label>
<select class="kms" name="kms_max" id="kms_max" onchange="updateKmsMin(this.value);">
<?
$selected=($vh->kms_max)?$vh->kms_max:100000;
for($i=100000;$i>=10000;$i-=5000){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.(($i==100000)?'+ de ':null).number_format($i,0,'',' ').'</option>';
}
?>
</select>
</div>
<div class="champs">
<label style="float:left" class="l2 an">jusqu'à</label>
<select name="millesime_max" class="an" id="an_max" onchange="updateAnMin(this.value);" style="clear:both; float:left">
<?
$selected=($_POST['millesime_max'])?$_POST['millesime_max']:intval(date('Y'));
for($i=intval(date('Y'));$i>=1991;$i--){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.$i.'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS ANNEE-->
</div>
<div id="conteneur-champs">
<!--CHAMPS BOITE-->
<div class="champs">
<label for="vitesses">Boite de vitesse</label>
<select name="boite" id="vitesses">
<?php
$boites = $vh->getPopulatedBoites();
foreach($boites as $key => $boite){
echo "<option value=\"$key\" ".(($key == $vh->boite)?'selected="selected"':'').">$boite</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS BOITE-->
<!--CHAMPS PORTES-->
<div class="champs">
<label for="nbportes">Nombre de portes du vo</label>
<select name="porte" id="nbportes">
<option value="">Toutes</option>
<?php
$portes=$vh->getPopulatedPortes();
foreach($portes as $porte){
echo "<option value=\"$porte\" ".(($porte == $vh->porte)?'selected="selected"':'').">$porte</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS PORTES-->
</div>
<div id="conteneur-champs">
<!--CHAMPS BOITE-->
<div class="champs">
<label for="typesellerie">Type de sellerie</label>
<select name="sellerie" id="typesellerie" style="clear:both; float:left">
<option value="">Toutes</option>
<?php
$selleries=$vh->getPopulatedSelleries();
foreach($selleries as $sellerie){
echo "<option value=\"$sellerie\" ".(($sellerie == $vh->sellerie)?'selected="selected"':'').">$sellerie</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS BOITE-->
<!--CHAMPS EXPO-->
<div class="champs">
<label for="lieuexpo">Lieu d'exposition</label>
<select name="lieu" id="lieuexpo">
<option value="">Tous</option>
<?php
$lieux=$vh->getPopulatedLieux();
foreach($lieux as $lieu){
echo "<option value=\"$lieu\" ".(($lieu == $vh->lieu)?'selected="selected"':'').">$lieu</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS PORTES-->
</div>
<!--COLONNE CHAMPS SUPP 1-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="gps" type="checkbox" name="gps[]"<?php echo (empty($_POST['gps'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="gps">GPS</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="radarderecul" type="checkbox" name="radarderecul[]"<?php echo (empty($_POST['radarderecul'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="radarderecul">RADAR DE RECUL</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 1-->
<!--COLONNE CHAMPS SUPP 2-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs" style="width:130px;">
<input style="padding-right:5px;" id="places7" type="checkbox" name="places7[]"<?php echo (empty($_POST['places7'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="places7" >7 PLACES</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="places9" type="checkbox" name="places9[]"<?php echo (empty($_POST['places9'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="places9">9 PLACES</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 2-->
<!--COLONNE CHAMPS SUPP 3-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="climatisation" type="checkbox" name="climatisation[]"<?php echo (empty($_POST['climatisation'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="climatisation">CLIMATISATION</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="toitouvrant" type="checkbox" name="toitouvrant[]"<?php echo (empty($_POST['toitouvrant'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="toitouvrant">TOIT OUVRANT</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 3-->
<!--COLONNE CHAMPS SUPP 4-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="toitpano" type="checkbox" name="toitpano[]"<?php echo (empty($_POST['toitpano'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="toitpano">TOIT PANORAMIQUE</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 4-->
<!--FIN CHAMPS SUPPLEMENTAIRES-->
</form>
</div>
<p class="slide"><a href="#" class="btn-slide">+ DE CRITÈRES</a></p>
<!--FIN MOTEUR DE RECHERCHE-->
<!--AFFICHAGE STOCK-->
<?php
////// Fonction qui choisi le rewritting à utiliser pour la navigation
function getTempUrl($page,$order = '') {
global $action;
if($_GET['marque'] && $_GET['modele']) return getModeleUrl($_GET['marque'], $_GET['modele'], $page, $order);
elseif($_GET['marque']) return getMarqueUrl($_GET['marque'], $page, $order);
else return getListeAnnoncesUrl($page, $order, substr($action,0,strrpos($action,'.')));
}
?>
<!--SI AUCUN VO EN STOCK CORRESPONDANT A LA RECHERCHE-->
<div style="clear:both"></div>
<?php if(empty($annonces)){ ?>
<div style="padding:10px; float:left;">Il n'y a pas de résultat pour votre recherche.</div>
<span style="color: #53524D; font-size: 14px; margin:10px">Vous pouvez effectuer une nouvelle recherche <a href="index.php">en cliquant ici</a> ou supprimer quelques critères.</span><br /><br />
<!--SINON TRIER LES RESULTATS-->
<?
}
else {
if($vh->order) {
$order = explode('-',$vh->order);
if($order[1] == 'asc') $order[2] = 'desc';
else $order[2] = 'asc';
}
?>
<!--CADRE TRI-->
<div id="cadre-tri">
<p class="pagination-tri"><?php
echo '<span style="float:left;">'.$navLinks['NB'].' résultats - '.$navLinks['NBPAGES'].' pages </span><span style="float:right">';
if($navLinks['DEBUT'] > 1) echo '<a href="'.getTempUrl(1,$_GET['tri']).'" class="nav">|<</a>';
if($page > 1) echo '<a href="'.getTempUrl($page-1,$_GET['tri']).'" class="nav"><</a>';
for($i = $navLinks['DEBUT'];$i <= $navLinks['FIN'];$i++) {
if($i == $page) echo '<a href="'.getTempUrl($i,$_GET['tri']).'" class="current">'.$i.'</a>';
else echo '<a href="'.getTempUrl($i,$_GET['tri']).'">'.$i.'</a>';
}
if($navLinks['FIN'] < $navLinks['NBPAGES']) echo '<a href="'.getTempUrl($page + 1,$_GET['tri']).'" class="nav">></a><a href="'.getTempUrl($navLinks['NBPAGES'],$_GET['tri']).'" class="nav">>|</a></span>';
?></p>
<p class="txt-cadre-tri">TRIER PAR: <a href="<?php echo getTempUrl($page,'km-'.($order[0] == 'km' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'km' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Kilométrage</span></a> | <a href="<?php echo getTempUrl($page,'millesime-'.($order[0] == 'millesime' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'millesime' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Année</span></a> | <a href="<?php echo getTempUrl($page,'prix-'.($order[0] == 'prix' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'prix' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Prix</span></a></p>
</div>
<!--FIN CADRE TRI-->
<div style="clear:both"></div>
<!--CONTENEUR VO-->
<?php
$i = 0;
$j = 0;
foreach($annonces as $annonce) {
$url = getAnnonceUrl($annonce['marque'],$annonce['modele'],$annonce['version'], $annonce['motorisation'], $annonce['id_voiture']);
?>
<div id="conteneur-vo">
<div id="cadre-vo">
<div id="img-cadre-vo" class="loading-photo">
<div id="img-cadre-vo">
<?php if($annonce['photo_1']) {?>
<a href="<?php echo $url ?>">
<img src="<?php echo getUrlPhoto($annonce['id_ext'],$annonce['photo_1'],1); ?>" alt="<?php echo strtoupper($annonce['marque']).' '.$annonce['modele']?> occasion" border="0" class="prevPhoto" width="197" height="148" />
</a>
<?php } ?>
</div>
</div>
<p class="marque-vo">
<a href="<?php echo $url ?>"><?php echo $annonce['marque'].' '.$annonce['modele']?></a>
</p>
<p class="version-vo"><?php echo substr($annonce['version'], 0, 40).'...'; ?></p>
<p class="annee-km-vo"> <?php echo $annonce['millesime'] ? $annonce['millesime'] : 'NC' ?>- <?php echo number_format($annonce['km'], 0, '', ' ') ?> KMS</p>
<p class="energie-vo">
<?php echo $annonce['motorisation'] ?>
</p>
<p class="prix-vo">
<?php echo $annonce['prix'] ? number_format($annonce['prix'], 0, '', ' ') : 'NC' ?>€
</p>
<div id="tag-baisse-de-prix">
<?php
$resultat = $annonce['prix_special'] - $annonce['prix'];
if( $annonce['prix_special'] > $annonce['prix'] )
echo
'
<div style="margin-bottom:5px;background-repeat:no-repeat; background-image:url(/images/tag-promo.png); width:73px; height:72px; padding-top:40px"><span class="tag" align="center" style="color:#FFF; font-size:15px; font-family: \'Montserrat\', sans-serif;">-'.$resultat.' €</span></div>
';
else
echo '';
?>
</div>
</div>
<?php
($i == 0) ? $i++ : $i=0;
$j++;
}
?>
<div style="clear:both"></div>
</div>
<!--FIN CONTENEUR VO-->
<!--CADRE TRI-->
<div id="cadre-tri" style="margin-top:0px;">
<p class="pagination-tri" style="float:right; margin-top:0px;">
<?php
echo '<span style="float:left;">'.$navLinks['NB'].' résultats - '.$navLinks['NBPAGES'].' pages </span><span style="float:right">';
if($navLinks['DEBUT'] > 1) echo '<a href="'.getTempUrl(1,$_GET['tri']).'" class="nav">|<</a>';
if($page > 1) echo '<a href="'.getTempUrl($page-1,$_GET['tri']).'" class="nav"><</a>';
for($i = $navLinks['DEBUT'];$i <= $navLinks['FIN'];$i++) {
if($i == $page) echo '<a href="'.getTempUrl($i,$_GET['tri']).'" class="current">'.$i.'</a>';
else echo '<a href="'.getTempUrl($i,$_GET['tri']).'">'.$i.'</a>';
}
if($navLinks['FIN'] < $navLinks['NBPAGES']) echo '<a href="'.getTempUrl($page + 1,$_GET['tri']).'" class="nav">></a><a href="'.getTempUrl($navLinks['NBPAGES'],$_GET['tri']).'" class="nav">>|</a></span>';
?>
</p>
</div>
<!--FIN CADRE TRI-->
<?php
}
?>
<div style="clear:both"></div>
<!--FIN AFFICHAGE STOCK-->
</div>
<!--FIN CONTENEUR PAGE-->
<!--FOOTER-->
<?php include("../inc/footer.php");?>
<!--FIN FOOTER-->
<?php require_once('../arscode-social-slider/arscode-social-slider.php'); ?>
<script>
jQuery(document).ready(function(){
<!--SCRIPT SLIDER PRIX-->
$(function(){
$('select#mini option[value=null], select#maxi option[value=null]').remove();
$('select#mini, select#maxi').hide().selectToUISlider({labels:2});
});
<!--FIN SCRIPT SLIDER PRIX-->
});
</script>
<script type="text/javascript">
<!--PRIX-->
$(document).ready(function(){
$('select#mini, select#maxi').selectToUISlider();
fixToolTipColor();
});
</script>
<script type="text/javascript">
<!--
$(document).ready(function(){
if($('form#moteur_form input#searchadv_footer_type_vo_input_hidden').attr('value') == '1')
{
$('div#searchadv_footer_type_vo').addClass('searchadv_footer_type_vo_on');
$('div#searchadv_footer_type_vo').removeClass('searchadv_footer_type_vo_off');
}
if($('form#moteur_form input#searchadv_footer_type_utilitaire_input_hidden').attr('value') == '1')
{
$('div#searchadv_footer_type_utilitaire').addClass('searchadv_footer_type_utilitaire_on');
$('div#searchadv_footer_type_utilitaire').removeClass('searchadv_footer_type_utilitaire_off');
}
});
/* gestion du champs modele en fonction de la marque */
function loadModeles(selectElem)
{
if($(selectElem).val() == '')
{
$('select#modele').empty();
$('select#modele').append('<option value="">Tous les modèles</option>');
$('select#modele').attr('disabled', 'disabled');
}
else
{
$.getJSON('../occasions/ajax/loadModele.php', {marque : $(selectElem).val()}, function(data){
$('select#modele').empty();
$('select#modele').append('<option value="">Tous les modèles</option>');
$(data).each(function(i, item){
$('select#modele').append('<option value="' + item + '">' + item +'</option>');
$('select#modele').removeAttr('disabled');
});
});
}
}
/* switch pour les bouttons type de vehicule */
function selectType(buttonName)
{
/* vo */
switch($('div#' + buttonName).attr('class'))
{
case buttonName + '_off' :
$('div#' + buttonName).removeClass(buttonName + '_off');
$('div#' + buttonName).addClass(buttonName + '_on');
$('div#' + getOtherButtonName(buttonName)).removeClass(getOtherButtonName(buttonName) + '_on');
$('div#' + getOtherButtonName(buttonName)).addClass(getOtherButtonName(buttonName) + '_off');
$('form#moteur_form input#' + buttonName + '_input_hidden').attr('value', '1');
$('form#moteur_form input#' + getOtherButtonName(buttonName) + '_input_hidden').attr('value', '0');
$('form select#categorie').attr('disabled', true);
break;
case buttonName + '_on' :
$('div#' + buttonName).removeClass(buttonName + '_on');
$('div#' + buttonName).addClass(buttonName + '_off');
if($('div#' + getOtherButtonName(buttonName)).attr('class') == getOtherButtonName(buttonName) + '_off')
{
$('form select#categorie').attr('disabled', false);
}
$('form#moteur_form input#' + buttonName + '_input_hidden').attr('value', '0');
break;
}
}
/* helper pour la fonction selectType */
function getOtherButtonName(buttonName)
{
switch(buttonName)
{
case 'searchadv_footer_type_vo' :
return 'searchadv_footer_type_utilitaire';
break;
case 'searchadv_footer_type_utilitaire' :
return 'searchadv_footer_type_vo';
break;
}
}
/* gestion des champs de kilometrage */
function updateKmsMax(kmsminval)
{
if(parseInt(kmsminval) >= parseInt($('form#moteur_form select#kms_max').val()))
{
$('form#moteur_form select#kms_max').empty();
for(i=100000;i>=10000;i-=5000)
{
data = '<option value="' + i + '"';
if(i == (parseInt(kmsminval)+5000))
{
data += ' selected=selected ';
}
data += '>';
if(i == 100000)
{
data += '+';
}
data += i + '</option>';
$('form#moteur_form select#kms_max').append(data);
}
}
}
function updateKmsMin(kmsmaxval)
{
if(parseInt(kmsmaxval) <= parseInt($('form#moteur_form select#kms_min').val()))
{
$('form#moteur_form select#kms_min').empty();
for(i=0;i<=95000;i+=5000)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(kmsmaxval)-5000))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#kms_min').append(data);
}
}
}
/* gestion des champs de millesime */
function updateAnMin(annmaxval)
{
if(parseInt(annmaxval) <= parseInt($('form#moteur_form select#an_min').val()))
{
date_object = new Date;
$('form#moteur_form select#an_min').empty();
for(i=date_object.getFullYear();i>=1985;i--)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(annmaxval)-1))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#an_min').append(data);
}
}
}
function updateAnMax(annminval)
{
if(parseInt(annminval) >= parseInt($('form#moteur_form select#an_max').val()))
{
date_object = new Date;
$('form#moteur_form select#an_max').empty();
for(i=1991;i<=(date_object.getFullYear());i++)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(annminval)+1))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#an_max').append(data);
}
}
}
//-->
</script>
</body>
</html>
PAGE FUNCTIONS.PHP:
<?php
/**
* Connexion mysql
*/
function sql_connect($host,$user,$pwd,$db){
$connection=mysql_connect($host,$user,$pwd) or die ('Connexion au serveur de données impossible');
mysql_select_db($db) or die('Connexion à la base de données impossible');
return $connection;
}
/**
* Déconnexion mysql
*/
function sql_close($connection=null){
if(empty($connection)){
mysql_close();
}else{
mysql_close($connection);
}
}
/**
* Exécution d'une requete sur la base
*
*@param string La requete
*@return resource Résultat de la requete
*/
function requete($query) {
$result = mysql_query($query);
if(!$result)
die('Erreur SQL : '.mysql_error());
return $result;
}
function getAnnonceUrl($marque,$modele,$version, $moteur, $id_annonce) {
return '/voiture-occasion/' . string2url($marque . ' - ' . $modele . ' - ' . $version . ' - ' . $moteur) . '/' . $id_annonce . '.html';
}
function getAnnonceContactUrl($marque, $modele, $version, $moteur, $annee, $id_annonce)
{
return '/voiture-occasion/' . string2url($marque . ' - ' . $modele . ' - ' . $version . ' - ' . $moteur . ' - ' . $annee) . '/contacter-vendeur/' . $id_annonce . '.html';
}
function getSelectionUrl($action = false, $id = false)
{
$url = '/ma-selection-annonce-auto-occasion.html';
if($action || $id)
{
$url .= '?';
}
$params = array();
if($action)
{
$params[] = 'action=' . $action;
}
if($id)
{
$params[] = 'id=' . $id;
}
$url .= implode('&', $params);
return $url;
}
function getListeAnnoncesUrl($page, $order, $action='') {
$url = '/voiture-occasion/page-' . $page . '.html';
if($order) $url .= '?order='.$order;
return $url;
}
function getMarqueUrl($marque,$page = 0,$order = false) {
$url = '/voiture-occasion-'.urlencode($marque);
if($page) $url .= '/page-'.$page.'.html';
return $url;
}
function getModeleUrl($marque,$modele,$page = 0,$order = false) {
$url = '/voiture-occasion-'.urlencode($marque).'-'.urlencode($modele);
if($page) $url .= '-page-'.$page.'.html';
return $url;
}
function sql_insert($tab_champs, $table) {
$sql_query = "INSERT INTO `$table` (";
foreach($tab_champs as $champ => $valeur) {
$sql_query .= "`$champ`, ";
}
$sql_query = substr($sql_query, 0, -2);
$sql_query .= ") VALUES (";
foreach($tab_champs as $champ => $valeur) {
$sql_query .= "'$valeur', ";
}
$sql_query = substr($sql_query, 0, -2);
$sql_query .= ")";
$sql_result = @mysql_query($sql_query);
if($sql_result) {
return mysql_insert_id();
}
else {
return false;
}
}
function sql_update($tab_champs, $table, $where) {
$request = "UPDATE `".$table."` SET ";
foreach($tab_champs as $champ => $valeur) {
$request .= "`".$champ."` = '".$valeur."', ";
}
$request = substr($request, 0, -2);
$request .= " ".$where;
if(!mysql_query($request)) {
return "Erreur : ".mysql_error();
}else{
return true;
}
}
function formatNumber($number){
$separator=' ';
$number=(string)($number);
$count=strlen($number);
$formated='';
$j=0;
for($i=$count-1;$i>=0;$i--){
$formated=$number[$i].$formated;
if($j==2){
$formated=$separator.$formated;
$j=0;
}else{
$j++;
}
}
return $formated;
}
function checkIfIsMailAdress($mail)
{
if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", strtolower($mail)))
{
return true;
}
else
{
return false;
}
}
function string2url($chaine) {
$chaine = trim(strtolower($chaine));
$chaine = strtr($chaine,
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
"aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
$chaine = strtr($chaine,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz");
$chaine = preg_replace('#([^.a-z0-9]+)#i', '-', $chaine);
$chaine = preg_replace('#-{2,}#','-',$chaine);
$chaine = preg_replace('#-$#','',$chaine);
$chaine = preg_replace('#^-#','',$chaine);
return $chaine;
}
/**
* Converts a date and time string from one format to another (e.g. d/m/Y => Y-m-d, d.m.Y => Y/d/m, ...)
*
* @param string $date_format1
* @param string $date_format2
* @param string $date_str
* @return string
*/
function convertDates($date_format1, $date_format2, $date_str) {
$base_struc = split('[:/.\ \-]', $date_format1);
$date_str_parts = split('[:/.\ \-]', $date_str );
// print_r( $base_struc ); echo "\n"; // for testing
// print_r( $date_str_parts ); echo "\n"; // for testing
$date_elements = array();
$p_keys = array_keys( $base_struc );
foreach ( $p_keys as $p_key ) {
if ( !empty( $date_str_parts[$p_key] )) {
$date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key];
}
else
return false;
}
// print_r($date_elements); // for testing
if (array_key_exists('M', $date_elements)) {
$Mtom=array(
"Jan"=>"01",
"Feb"=>"02",
"Mar"=>"03",
"Apr"=>"04",
"May"=>"05",
"Jun"=>"06",
"Jul"=>"07",
"Aug"=>"08",
"Sep"=>"09",
"Oct"=>"10",
"Nov"=>"11",
"Dec"=>"12",
);
$date_elements['m']=$Mtom[$date_elements['M']];
}
// print_r($date_elements); // for testing
$dummy_ts = mktime(
$date_elements['H'],
$date_elements['i'],
$date_elements['s'],
$date_elements['m'],
$date_elements['d'],
$date_elements['Y']
);
return date( $date_format2, $dummy_ts );
}
?>
Et la page CONFIG.PHP:
<?
session_start();
/**
Connexion ? la base de donnée
*/
$dbserver = "xxxxxxx";
$dbname = "xxxxxxx";
$dbuser = 'xxxxxxx';
$dbpass = 'xxxxxx';
$db = mysql_connect($dbserver,$dbuser,$dbpass);
mysql_select_db($dbname,$db);
echo mysql_error();
/**
Inclusion des fichiers
*/
include 'functions.php';
include 'class.vehicule.php';
include 'class.tools.php';
/**
Définition des variables globales
*/
define('URL','xxxxxxxxxx');
define('EMAIL_ADMIN','xxxxxxxxxxx');
/**
Création objet Vehicule
*/
if(isset($_SESSION['vh'])) $vh = unserialize($_SESSION['vh']);
else $vh = new Vehicule();
$plage_km = array (0=>0, 25000=>25000, 50000=>50000, 100000=>100000, 250000=>250000);
$plage_prix = array (0=>0, 5000=>5000, 10000=>10000, 15000=>15000, 20000=>20000, 50000=>50000, 100000=>100000);
for($i=1980;$i<=date('Y');$i++) $plage_annees_asc[] = $i;
$plage_annees_desc = $plage_annees_asc;
rsort($plage_annees_desc);
$energies = array ('DIESEL' => 'Diesel', 'ESSENCE' => 'Essence');
Ci-dessous je mets les fichiers concernés, peut-être que ça pourra donner une piste à quelqu'un :wink:
Merci en tout cas !
PAGE INDEX.PHP qui contient le moteur de recherche et affiche les résultats:
[php]<?php
session_cache_limiter('private, must-revalidate');
include 'include/config.php';
$vh->nbParPage = 16;
if(!$_GET['back'])
{
////////// Récupération page en cours
if(!$_GET['page']) {
$page = 1;
$vh->reset();
}
else{
$page = $_GET['page'];
}
////////Récupération des données POST
if(!empty($_POST)) {
/* hack pour les prix min et max */
if($_POST['mini'] != '~')
{
$_POST['prix_min'] = $_POST['mini'];
}
if($_POST['maxi'] != '~')
{
$_POST['prix_max'] = $_POST['maxi'];
}
$vh->loadPostData($_POST);
}
////////// Récupération des données GET
else $vh->loadGetData($_GET);
//////// Récupération des annonces
$vh->page = $page;
}
$annonces = $vh->search();
$navLinks = $vh->getNavLinks();
$priceList = array(
2000,
4000,
6000,
8000,
10000,
12000,
14000,
16000,
18000,
20000,
25000,
30000,
35000,
40000,
50000,
100000
);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>xxxxxxxx</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--STYLES-->
<link rel="stylesheet" type="text/css" href="../css/styles.css" />
<!--TYPOS-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' rel='stylesheet' type='text/css'>
<!--MODERNIZR-->
<script type="text/javascript" src="../js/modernizr.custom.24399.js"></script>
<!--JQUERY-->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!--SCRIPT NAVIGATION-->
<link rel="stylesheet" href="../css/megamenu.css">
<script type="text/javascript" src="../js/megamenu_plugins.js"></script>
<script type="text/javascript" src="../js/megamenu.js"></script>
<script>
$(document).ready(function($){
$('.megamenu').megaMenuCompleteSet({
menu_speed_show : 300,
menu_speed_hide : 200,
menu_speed_delay : 200,
menu_effect : 'hover_slide',
menu_click_outside : 1,
menu_show_onload : 0
});
});
</script>
<!-- LOADER IMAGE -->
<script src="/js/jquery.preloadify.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$(".loading-photo").preloadify({ force_icon:true
});
});
</script>
<!--CRITERES SUPPLEMENTAIRES-->
<script type="text/javascript">
$(document).ready(function(){
$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
});
});
</script>
<!-- SLIDER PRIX -->
<script charset="utf-8" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript" src="../js/selectToUISlider.jQuery.js"></script>
<link rel="stylesheet" href="../css/slider-prix/redmond/jquery-ui-1.7.1.custom.css" type="text/css" />
<link rel="Stylesheet" href="../css/slider-prix/ui.slider.extras.css" type="text/css" />
<!--SOCIAL-->
<link rel="stylesheet" media="screen" href="../arscode-social-slider/fblb.css"/>
<!--[if lte IE 7]>
<link rel="stylesheet" media="screen" href="../arscode-social-slider/ie7.css?ver=3.2.1" />
<![endif]-->
<script type="text/javascript" src="../arscode-social-slider/js/userscripts.js"></script>
<!--[if lte IE 7]>
<script type="text/javascript" src="../arscode-social-slider/js/userscripts-ie7.js"></script>
<![endif]-->
<!--VIDEO BACKGROUND
<script type="text/javascript" src="../js/jquery.mb.YTPlayer.js"></script>
<link href="../css/YTPlayer.css" media="all" rel="stylesheet" type="text/css">
<script>
jQuery(function(){
jQuery(".player").mb_YTPlayer();
});
</script>-->
</head>
<body>
<!--HEADER-->
<?php include("../inc/header.php");?>
<!--FIN HEADER-->
<!--NAVIGATION-->
<?php include("../inc/menu.php");?>
<!--FIN NAVIGATION-->
<!--CONTENEUR PAGE-->
<div id="conteneur-page" style="padding-top:0px;">
<!--MOTEUR DE RECHERCHE-->
<div id="conteneur-moteur">
<form action="../occasions/index.php" method="post" id="moteur_form2">
<!--COLONNE CHAMPS 1-->
<div id="conteneur-champs">
<!--CHAMPS MARQUE-->
<div class="champs">
<label for="marque">MARQUE</label>
<select name="marque" id="marque" onchange="loadModeles(this)">
<option value="">Toutes les marques</option>
<?php
$marques = $vh->getPopulatedMarques();
$_DATA['marques'] = $marques;
foreach($marques as $marque) {
if($marque)
if(strtoupper($vh->marque) == $marque) echo '<option value="'.$marque.'" selected="selected">'.ucfirst(strtolower($marque)).'</option>';
else echo '<option value="'.$marque.'">'.ucfirst(strtolower($marque)).'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS MARQUE-->
<div class="champs">
<label for="modele">MODÈLE</label>
<select name="modele"<?=((empty($vh->marque))?' disabled="disabled"':null)?> id="modele" >
<option value="">Tous les modèles</option>
<?
if(!empty($vh->marque)){
$modeles=$vh->getPopulatedModeles($vh->marque);
foreach($modeles as $modele){
echo '<option value="'.$modele.'"'.((strtoupper($vh->modele)==$modele)?' selected="selected"':null).'>'.$modele.'</option>';
}
}
?>
</select>
</div>
</div>
<!--FIN COLONNE CHAMPS 1-->
<!--COLONNE CHAMPS 2-->
<div id="conteneur-champs">
<!--CHAMPS CATEGORIE-->
<div class="champs">
<label for="categorie">CATÉGORIE</label>
<select name="categorie" id="categorie">
<option value="">Toutes les catégories</option>
<?php
$categories=$vh->getCategories();
foreach($categories as $categorie){
echo "<option value=\"$categorie\" ".((strtolower($categorie) == strtolower($vh->categorie))?'selected="selected"':'').">". ucfirst(strtolower($categorie)) . "</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS CATEGORIE-->
<div class="champs">
<label for="modele">ÉNERGIE</label>
<select name="motorisation" id="energie">
<option value="">Toutes les énergies</option>
<?php
$motorisations=$vh->getMotorisations();
foreach($motorisations as $motorisation){
echo "<option value=\"$motorisation\" ".(($motorisation == $vh->motorisation)?'selected="selected"':'').">$motorisation</option>";
}
?>
</select>
</div>
</div>
<!--FIN COLONNE CHAMPS 2-->
<!--COLONNE CHAMPS 3-->
<div class="champs" style="padding-left:40px;">
<div id="wrapperslider" style="width:405px; margin-top:10px;">
<p align="center" style="font-family: 'Montserrat', sans-serif; color:#232323;"><label for="mini">VOTRE BUDGET</label></p>
<div style=" margin-top:-10px;">
<select name="mini" id="mini" style="visibility:hidden; height:1px;">
<option value="0" selected="selected" >0 €</option>
<?php foreach($priceList as $price) { ?>
<option value="<?=$price?>" <?php if($price == $vh->prix_min) { ?> selected="selected" <?php } ?>><?=$price?> €</option>
<?php } ?>
<option value="~">+ 100.000€</option>
</select>
<select name="maxi" id="maxi" style="visibility:hidden; height:1px;">
<option value="null">Prix maximum</option>
<?php foreach($priceList as $price) { ?>
<option value="<?=$price?>" <?php if($price == $vh->prix_max) { ?> selected="selected" <?php } ?>><?=$price?> €</option>
<?php } ?>
<option value="~" <?php if(!$vh->prix_max || !in_array($vh->prix_max, $priceList) || $vh->prix_max == '~') { ?> selected="selected" <?php } ?>>+ 100000 €</option>
</select>
</div>
</div>
</div>
<!--[if IE]>
<div id="btn-recherche-generale" style="padding-top:50px;"><input type="submit" name="submit" value="submit" /></div>
<![endif]-->
<!--[if !IE]><!-->
<div id="btn-recherche-generale"><input type="submit" name="submit" value="submit" /></div><!--<![endif]-->
<!--FIN COLONNE CHAMPS 3-->
</div>
<div id="panel">
<!--CHAMPS SUPPLEMENTAIRES-->
<div id="conteneur-champs" style="width:140px;">
<!--CHAMPS KMS-->
<div class="champs" style="width:140px;">
<label class="l2 km">Kilométrage minimum</label>
<select name="kms_min" class="kms" id="kms_min" onchange="updateKmsMax(this.value);" >
<?
$selected=($vh->kms_min)?$vh->kms_min:0;
for($i=0;$i<=95000;$i+=5000){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.(($i==100000)?'+ de ':null).number_format($i,0,'',' ').'</option>';
}
?>
</select>
</div>
<div class="champs">
<label style="float:left" class="l2 an">Année de</label>
<select name="millesime_min" id="an_min" class="an" onchange="updateAnMax(this.value);" style="clear:both; float:left">
<?
$selected=($_POST['millesime_min'])?$_POST['millesime_min']:1990;
for($i=1985;$i<=intval(date('Y'))-1;$i++){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.$i.'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS KMS-->
</div>
<div id="conteneur-champs">
<!--CHAMPS ANNEE-->
<div class="champs">
<label class="l2 km">Kilométrage maximum</label>
<select class="kms" name="kms_max" id="kms_max" onchange="updateKmsMin(this.value);">
<?
$selected=($vh->kms_max)?$vh->kms_max:100000;
for($i=100000;$i>=10000;$i-=5000){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.(($i==100000)?'+ de ':null).number_format($i,0,'',' ').'</option>';
}
?>
</select>
</div>
<div class="champs">
<label style="float:left" class="l2 an">jusqu'à</label>
<select name="millesime_max" class="an" id="an_max" onchange="updateAnMin(this.value);" style="clear:both; float:left">
<?
$selected=($_POST['millesime_max'])?$_POST['millesime_max']:intval(date('Y'));
for($i=intval(date('Y'));$i>=1991;$i--){
echo '<option value="'.$i.'"'.(($i==$selected)?' selected="selected"':null).'>'.$i.'</option>';
}
?>
</select>
</div>
<!--FIN CHAMPS ANNEE-->
</div>
<div id="conteneur-champs">
<!--CHAMPS BOITE-->
<div class="champs">
<label for="vitesses">Boite de vitesse</label>
<select name="boite" id="vitesses">
<?php
$boites = $vh->getPopulatedBoites();
foreach($boites as $key => $boite){
echo "<option value=\"$key\" ".(($key == $vh->boite)?'selected="selected"':'').">$boite</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS BOITE-->
<!--CHAMPS PORTES-->
<div class="champs">
<label for="nbportes">Nombre de portes du vo</label>
<select name="porte" id="nbportes">
<option value="">Toutes</option>
<?php
$portes=$vh->getPopulatedPortes();
foreach($portes as $porte){
echo "<option value=\"$porte\" ".(($porte == $vh->porte)?'selected="selected"':'').">$porte</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS PORTES-->
</div>
<div id="conteneur-champs">
<!--CHAMPS BOITE-->
<div class="champs">
<label for="typesellerie">Type de sellerie</label>
<select name="sellerie" id="typesellerie" style="clear:both; float:left">
<option value="">Toutes</option>
<?php
$selleries=$vh->getPopulatedSelleries();
foreach($selleries as $sellerie){
echo "<option value=\"$sellerie\" ".(($sellerie == $vh->sellerie)?'selected="selected"':'').">$sellerie</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS BOITE-->
<!--CHAMPS EXPO-->
<div class="champs">
<label for="lieuexpo">Lieu d'exposition</label>
<select name="lieu" id="lieuexpo">
<option value="">Tous</option>
<?php
$lieux=$vh->getPopulatedLieux();
foreach($lieux as $lieu){
echo "<option value=\"$lieu\" ".(($lieu == $vh->lieu)?'selected="selected"':'').">$lieu</option>";
}
?>
</select>
</div>
<!--FIN CHAMPS PORTES-->
</div>
<!--COLONNE CHAMPS SUPP 1-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="gps" type="checkbox" name="gps[]"<?php echo (empty($_POST['gps'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="gps">GPS</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="radarderecul" type="checkbox" name="radarderecul[]"<?php echo (empty($_POST['radarderecul'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="radarderecul">RADAR DE RECUL</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 1-->
<!--COLONNE CHAMPS SUPP 2-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs" style="width:130px;">
<input style="padding-right:5px;" id="places7" type="checkbox" name="places7[]"<?php echo (empty($_POST['places7'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="places7" >7 PLACES</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="places9" type="checkbox" name="places9[]"<?php echo (empty($_POST['places9'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="places9">9 PLACES</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 2-->
<!--COLONNE CHAMPS SUPP 3-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="climatisation" type="checkbox" name="climatisation[]"<?php echo (empty($_POST['climatisation'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="climatisation">CLIMATISATION</label>
</div>
<div class="champs">
<input style="padding-right:5px;" id="toitouvrant" type="checkbox" name="toitouvrant[]"<?php echo (empty($_POST['toitouvrant'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="toitouvrant">TOIT OUVRANT</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 3-->
<!--COLONNE CHAMPS SUPP 4-->
<div id="conteneur-champs" style="width:150px;">
<div class="champs">
<input style="padding-right:5px;" id="toitpano" type="checkbox" name="toitpano[]"<?php echo (empty($_POST['toitpano'])) ? '' : ' checked="checked"' ?> />
<label style="padding-right:5px;" for="toitpano">TOIT PANORAMIQUE</label>
</div>
</div>
<!--FIN COLONNE CHAMPS SUPP 4-->
<!--FIN CHAMPS SUPPLEMENTAIRES-->
</form>
</div>
<p class="slide"><a href="#" class="btn-slide">+ DE CRITÈRES</a></p>
<!--FIN MOTEUR DE RECHERCHE-->
<!--AFFICHAGE STOCK-->
<?php
////// Fonction qui choisi le rewritting à utiliser pour la navigation
function getTempUrl($page,$order = '') {
global $action;
if($_GET['marque'] && $_GET['modele']) return getModeleUrl($_GET['marque'], $_GET['modele'], $page, $order);
elseif($_GET['marque']) return getMarqueUrl($_GET['marque'], $page, $order);
else return getListeAnnoncesUrl($page, $order, substr($action,0,strrpos($action,'.')));
}
?>
<!--SI AUCUN VO EN STOCK CORRESPONDANT A LA RECHERCHE-->
<div style="clear:both"></div>
<?php if(empty($annonces)){ ?>
<div style="padding:10px; float:left;">Il n'y a pas de résultat pour votre recherche.</div>
<span style="color: #53524D; font-size: 14px; margin:10px">Vous pouvez effectuer une nouvelle recherche <a href="index.php">en cliquant ici</a> ou supprimer quelques critères.</span><br /><br />
<!--SINON TRIER LES RESULTATS-->
<?
}
else {
if($vh->order) {
$order = explode('-',$vh->order);
if($order[1] == 'asc') $order[2] = 'desc';
else $order[2] = 'asc';
}
?>
<!--CADRE TRI-->
<div id="cadre-tri">
<p class="pagination-tri"><?php
echo '<span style="float:left;">'.$navLinks['NB'].' résultats - '.$navLinks['NBPAGES'].' pages </span><span style="float:right">';
if($navLinks['DEBUT'] > 1) echo '<a href="'.getTempUrl(1,$_GET['tri']).'" class="nav">|<</a>';
if($page > 1) echo '<a href="'.getTempUrl($page-1,$_GET['tri']).'" class="nav"><</a>';
for($i = $navLinks['DEBUT'];$i <= $navLinks['FIN'];$i++) {
if($i == $page) echo '<a href="'.getTempUrl($i,$_GET['tri']).'" class="current">'.$i.'</a>';
else echo '<a href="'.getTempUrl($i,$_GET['tri']).'">'.$i.'</a>';
}
if($navLinks['FIN'] < $navLinks['NBPAGES']) echo '<a href="'.getTempUrl($page + 1,$_GET['tri']).'" class="nav">></a><a href="'.getTempUrl($navLinks['NBPAGES'],$_GET['tri']).'" class="nav">>|</a></span>';
?></p>
<p class="txt-cadre-tri">TRIER PAR: <a href="<?php echo getTempUrl($page,'km-'.($order[0] == 'km' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'km' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Kilométrage</span></a> | <a href="<?php echo getTempUrl($page,'millesime-'.($order[0] == 'millesime' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'millesime' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Année</span></a> | <a href="<?php echo getTempUrl($page,'prix-'.($order[0] == 'prix' ? $order[2] : 'asc')); ?>" class="<?=($order[0] == 'prix' ? $order[1] : '')?>"><span style="padding-left:10px; padding-right:10px;">Prix</span></a></p>
</div>
<!--FIN CADRE TRI-->
<div style="clear:both"></div>
<!--CONTENEUR VO-->
<?php
$i = 0;
$j = 0;
foreach($annonces as $annonce) {
$url = getAnnonceUrl($annonce['marque'],$annonce['modele'],$annonce['version'], $annonce['motorisation'], $annonce['id_voiture']);
?>
<div id="conteneur-vo">
<div id="cadre-vo">
<div id="img-cadre-vo" class="loading-photo">
<div id="img-cadre-vo">
<?php if($annonce['photo_1']) {?>
<a href="<?php echo $url ?>">
<img src="<?php echo getUrlPhoto($annonce['id_ext'],$annonce['photo_1'],1); ?>" alt="<?php echo strtoupper($annonce['marque']).' '.$annonce['modele']?> occasion" border="0" class="prevPhoto" width="197" height="148" />
</a>
<?php } ?>
</div>
</div>
<p class="marque-vo">
<a href="<?php echo $url ?>"><?php echo $annonce['marque'].' '.$annonce['modele']?></a>
</p>
<p class="version-vo"><?php echo substr($annonce['version'], 0, 40).'...'; ?></p>
<p class="annee-km-vo"> <?php echo $annonce['millesime'] ? $annonce['millesime'] : 'NC' ?>- <?php echo number_format($annonce['km'], 0, '', ' ') ?> KMS</p>
<p class="energie-vo">
<?php echo $annonce['motorisation'] ?>
</p>
<p class="prix-vo">
<?php echo $annonce['prix'] ? number_format($annonce['prix'], 0, '', ' ') : 'NC' ?>€
</p>
<div id="tag-baisse-de-prix">
<?php
$resultat = $annonce['prix_special'] - $annonce['prix'];
if( $annonce['prix_special'] > $annonce['prix'] )
echo
'
<div style="margin-bottom:5px;background-repeat:no-repeat; background-image:url(/images/tag-promo.png); width:73px; height:72px; padding-top:40px"><span class="tag" align="center" style="color:#FFF; font-size:15px; font-family: \'Montserrat\', sans-serif;">-'.$resultat.' €</span></div>
';
else
echo '';
?>
</div>
</div>
<?php
($i == 0) ? $i++ : $i=0;
$j++;
}
?>
<div style="clear:both"></div>
</div>
<!--FIN CONTENEUR VO-->
<!--CADRE TRI-->
<div id="cadre-tri" style="margin-top:0px;">
<p class="pagination-tri" style="float:right; margin-top:0px;">
<?php
echo '<span style="float:left;">'.$navLinks['NB'].' résultats - '.$navLinks['NBPAGES'].' pages </span><span style="float:right">';
if($navLinks['DEBUT'] > 1) echo '<a href="'.getTempUrl(1,$_GET['tri']).'" class="nav">|<</a>';
if($page > 1) echo '<a href="'.getTempUrl($page-1,$_GET['tri']).'" class="nav"><</a>';
for($i = $navLinks['DEBUT'];$i <= $navLinks['FIN'];$i++) {
if($i == $page) echo '<a href="'.getTempUrl($i,$_GET['tri']).'" class="current">'.$i.'</a>';
else echo '<a href="'.getTempUrl($i,$_GET['tri']).'">'.$i.'</a>';
}
if($navLinks['FIN'] < $navLinks['NBPAGES']) echo '<a href="'.getTempUrl($page + 1,$_GET['tri']).'" class="nav">></a><a href="'.getTempUrl($navLinks['NBPAGES'],$_GET['tri']).'" class="nav">>|</a></span>';
?>
</p>
</div>
<!--FIN CADRE TRI-->
<?php
}
?>
<div style="clear:both"></div>
<!--FIN AFFICHAGE STOCK-->
</div>
<!--FIN CONTENEUR PAGE-->
<!--FOOTER-->
<?php include("../inc/footer.php");?>
<!--FIN FOOTER-->
<?php require_once('../arscode-social-slider/arscode-social-slider.php'); ?>
<script>
jQuery(document).ready(function(){
<!--SCRIPT SLIDER PRIX-->
$(function(){
$('select#mini option[value=null], select#maxi option[value=null]').remove();
$('select#mini, select#maxi').hide().selectToUISlider({labels:2});
});
<!--FIN SCRIPT SLIDER PRIX-->
});
</script>
<script type="text/javascript">
<!--PRIX-->
$(document).ready(function(){
$('select#mini, select#maxi').selectToUISlider();
fixToolTipColor();
});
</script>
<script type="text/javascript">
<!--
$(document).ready(function(){
if($('form#moteur_form input#searchadv_footer_type_vo_input_hidden').attr('value') == '1')
{
$('div#searchadv_footer_type_vo').addClass('searchadv_footer_type_vo_on');
$('div#searchadv_footer_type_vo').removeClass('searchadv_footer_type_vo_off');
}
if($('form#moteur_form input#searchadv_footer_type_utilitaire_input_hidden').attr('value') == '1')
{
$('div#searchadv_footer_type_utilitaire').addClass('searchadv_footer_type_utilitaire_on');
$('div#searchadv_footer_type_utilitaire').removeClass('searchadv_footer_type_utilitaire_off');
}
});
/* gestion du champs modele en fonction de la marque */
function loadModeles(selectElem)
{
if($(selectElem).val() == '')
{
$('select#modele').empty();
$('select#modele').append('<option value="">Tous les modèles</option>');
$('select#modele').attr('disabled', 'disabled');
}
else
{
$.getJSON('../occasions/ajax/loadModele.php', {marque : $(selectElem).val()}, function(data){
$('select#modele').empty();
$('select#modele').append('<option value="">Tous les modèles</option>');
$(data).each(function(i, item){
$('select#modele').append('<option value="' + item + '">' + item +'</option>');
$('select#modele').removeAttr('disabled');
});
});
}
}
/* switch pour les bouttons type de vehicule */
function selectType(buttonName)
{
/* vo */
switch($('div#' + buttonName).attr('class'))
{
case buttonName + '_off' :
$('div#' + buttonName).removeClass(buttonName + '_off');
$('div#' + buttonName).addClass(buttonName + '_on');
$('div#' + getOtherButtonName(buttonName)).removeClass(getOtherButtonName(buttonName) + '_on');
$('div#' + getOtherButtonName(buttonName)).addClass(getOtherButtonName(buttonName) + '_off');
$('form#moteur_form input#' + buttonName + '_input_hidden').attr('value', '1');
$('form#moteur_form input#' + getOtherButtonName(buttonName) + '_input_hidden').attr('value', '0');
$('form select#categorie').attr('disabled', true);
break;
case buttonName + '_on' :
$('div#' + buttonName).removeClass(buttonName + '_on');
$('div#' + buttonName).addClass(buttonName + '_off');
if($('div#' + getOtherButtonName(buttonName)).attr('class') == getOtherButtonName(buttonName) + '_off')
{
$('form select#categorie').attr('disabled', false);
}
$('form#moteur_form input#' + buttonName + '_input_hidden').attr('value', '0');
break;
}
}
/* helper pour la fonction selectType */
function getOtherButtonName(buttonName)
{
switch(buttonName)
{
case 'searchadv_footer_type_vo' :
return 'searchadv_footer_type_utilitaire';
break;
case 'searchadv_footer_type_utilitaire' :
return 'searchadv_footer_type_vo';
break;
}
}
/* gestion des champs de kilometrage */
function updateKmsMax(kmsminval)
{
if(parseInt(kmsminval) >= parseInt($('form#moteur_form select#kms_max').val()))
{
$('form#moteur_form select#kms_max').empty();
for(i=100000;i>=10000;i-=5000)
{
data = '<option value="' + i + '"';
if(i == (parseInt(kmsminval)+5000))
{
data += ' selected=selected ';
}
data += '>';
if(i == 100000)
{
data += '+';
}
data += i + '</option>';
$('form#moteur_form select#kms_max').append(data);
}
}
}
function updateKmsMin(kmsmaxval)
{
if(parseInt(kmsmaxval) <= parseInt($('form#moteur_form select#kms_min').val()))
{
$('form#moteur_form select#kms_min').empty();
for(i=0;i<=95000;i+=5000)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(kmsmaxval)-5000))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#kms_min').append(data);
}
}
}
/* gestion des champs de millesime */
function updateAnMin(annmaxval)
{
if(parseInt(annmaxval) <= parseInt($('form#moteur_form select#an_min').val()))
{
date_object = new Date;
$('form#moteur_form select#an_min').empty();
for(i=date_object.getFullYear();i>=1985;i--)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(annmaxval)-1))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#an_min').append(data);
}
}
}
function updateAnMax(annminval)
{
if(parseInt(annminval) >= parseInt($('form#moteur_form select#an_max').val()))
{
date_object = new Date;
$('form#moteur_form select#an_max').empty();
for(i=1991;i<=(date_object.getFullYear());i++)
{
data = '<option value="' + i + ' "';
if(i == (parseInt(annminval)+1))
{
data += ' selected=selected ';
}
data += '>' + i + '</option>';
$('form#moteur_form select#an_max').append(data);
}
}
}
//-->
</script>
</body>
</html>
[/php]
PAGE FUNCTIONS.PHP:
[php]<?php
/**
* Connexion mysql
*/
function sql_connect($host,$user,$pwd,$db){
$connection=mysql_connect($host,$user,$pwd) or die ('Connexion au serveur de données impossible');
mysql_select_db($db) or die('Connexion à la base de données impossible');
return $connection;
}
/**
* Déconnexion mysql
*/
function sql_close($connection=null){
if(empty($connection)){
mysql_close();
}else{
mysql_close($connection);
}
}
/**
* Exécution d'une requete sur la base
*
*@param string La requete
*@return resource Résultat de la requete
*/
function requete($query) {
$result = mysql_query($query);
if(!$result)
die('Erreur SQL : '.mysql_error());
return $result;
}
function getAnnonceUrl($marque,$modele,$version, $moteur, $id_annonce) {
return '/voiture-occasion/' . string2url($marque . ' - ' . $modele . ' - ' . $version . ' - ' . $moteur) . '/' . $id_annonce . '.html';
}
function getAnnonceContactUrl($marque, $modele, $version, $moteur, $annee, $id_annonce)
{
return '/voiture-occasion/' . string2url($marque . ' - ' . $modele . ' - ' . $version . ' - ' . $moteur . ' - ' . $annee) . '/contacter-vendeur/' . $id_annonce . '.html';
}
function getSelectionUrl($action = false, $id = false)
{
$url = '/ma-selection-annonce-auto-occasion.html';
if($action || $id)
{
$url .= '?';
}
$params = array();
if($action)
{
$params[] = 'action=' . $action;
}
if($id)
{
$params[] = 'id=' . $id;
}
$url .= implode('&', $params);
return $url;
}
function getListeAnnoncesUrl($page, $order, $action='') {
$url = '/voiture-occasion/page-' . $page . '.html';
if($order) $url .= '?order='.$order;
return $url;
}
function getMarqueUrl($marque,$page = 0,$order = false) {
$url = '/voiture-occasion-'.urlencode($marque);
if($page) $url .= '/page-'.$page.'.html';
return $url;
}
function getModeleUrl($marque,$modele,$page = 0,$order = false) {
$url = '/voiture-occasion-'.urlencode($marque).'-'.urlencode($modele);
if($page) $url .= '-page-'.$page.'.html';
return $url;
}
function sql_insert($tab_champs, $table) {
$sql_query = "INSERT INTO `$table` (";
foreach($tab_champs as $champ => $valeur) {
$sql_query .= "`$champ`, ";
}
$sql_query = substr($sql_query, 0, -2);
$sql_query .= ") VALUES (";
foreach($tab_champs as $champ => $valeur) {
$sql_query .= "'$valeur', ";
}
$sql_query = substr($sql_query, 0, -2);
$sql_query .= ")";
$sql_result = @mysql_query($sql_query);
if($sql_result) {
return mysql_insert_id();
}
else {
return false;
}
}
function sql_update($tab_champs, $table, $where) {
$request = "UPDATE `".$table."` SET ";
foreach($tab_champs as $champ => $valeur) {
$request .= "`".$champ."` = '".$valeur."', ";
}
$request = substr($request, 0, -2);
$request .= " ".$where;
if(!mysql_query($request)) {
return "Erreur : ".mysql_error();
}else{
return true;
}
}
function formatNumber($number){
$separator=' ';
$number=(string)($number);
$count=strlen($number);
$formated='';
$j=0;
for($i=$count-1;$i>=0;$i--){
$formated=$number[$i].$formated;
if($j==2){
$formated=$separator.$formated;
$j=0;
}else{
$j++;
}
}
return $formated;
}
function checkIfIsMailAdress($mail)
{
if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", strtolower($mail)))
{
return true;
}
else
{
return false;
}
}
function string2url($chaine) {
$chaine = trim(strtolower($chaine));
$chaine = strtr($chaine,
"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
"aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
$chaine = strtr($chaine,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz");
$chaine = preg_replace('#([^.a-z0-9]+)#i', '-', $chaine);
$chaine = preg_replace('#-{2,}#','-',$chaine);
$chaine = preg_replace('#-$#','',$chaine);
$chaine = preg_replace('#^-#','',$chaine);
return $chaine;
}
/**
* Converts a date and time string from one format to another (e.g. d/m/Y => Y-m-d, d.m.Y => Y/d/m, ...)
*
* @param string $date_format1
* @param string $date_format2
* @param string $date_str
* @return string
*/
function convertDates($date_format1, $date_format2, $date_str) {
$base_struc = split('[:/.\ \-]', $date_format1);
$date_str_parts = split('[:/.\ \-]', $date_str );
// print_r( $base_struc ); echo "\n"; // for testing
// print_r( $date_str_parts ); echo "\n"; // for testing
$date_elements = array();
$p_keys = array_keys( $base_struc );
foreach ( $p_keys as $p_key ) {
if ( !empty( $date_str_parts[$p_key] )) {
$date_elements[$base_struc[$p_key]] = $date_str_parts[$p_key];
}
else
return false;
}
// print_r($date_elements); // for testing
if (array_key_exists('M', $date_elements)) {
$Mtom=array(
"Jan"=>"01",
"Feb"=>"02",
"Mar"=>"03",
"Apr"=>"04",
"May"=>"05",
"Jun"=>"06",
"Jul"=>"07",
"Aug"=>"08",
"Sep"=>"09",
"Oct"=>"10",
"Nov"=>"11",
"Dec"=>"12",
);
$date_elements['m']=$Mtom[$date_elements['M']];
}
// print_r($date_elements); // for testing
$dummy_ts = mktime(
$date_elements['H'],
$date_elements['i'],
$date_elements['s'],
$date_elements['m'],
$date_elements['d'],
$date_elements['Y']
);
return date( $date_format2, $dummy_ts );
}
?>[/php]
Et la page CONFIG.PHP:
[php]<?
session_start();
/**
Connexion ? la base de donnée
*/
$dbserver = "xxxxxxx";
$dbname = "xxxxxxx";
$dbuser = 'xxxxxxx';
$dbpass = 'xxxxxx';
$db = mysql_connect($dbserver,$dbuser,$dbpass);
mysql_select_db($dbname,$db);
echo mysql_error();
/**
Inclusion des fichiers
*/
include 'functions.php';
include 'class.vehicule.php';
include 'class.tools.php';
/**
Définition des variables globales
*/
define('URL','xxxxxxxxxx');
define('EMAIL_ADMIN','xxxxxxxxxxx');
/**
Création objet Vehicule
*/
if(isset($_SESSION['vh'])) $vh = unserialize($_SESSION['vh']);
else $vh = new Vehicule();
$plage_km = array (0=>0, 25000=>25000, 50000=>50000, 100000=>100000, 250000=>250000);
$plage_prix = array (0=>0, 5000=>5000, 10000=>10000, 15000=>15000, 20000=>20000, 50000=>50000, 100000=>100000);
for($i=1980;$i<=date('Y');$i++) $plage_annees_asc[] = $i;
$plage_annees_desc = $plage_annees_asc;
rsort($plage_annees_desc);
$energies = array ('DIESEL' => 'Diesel', 'ESSENCE' => 'Essence');[/php]