par
blinz » 04 août 2016, 21:00
Salut à tous.
Bon je ne suis pas un pro du php mais j'ai finis mon projet et je souhaite arranger un peu parceque le temps d'éxécution de la page est long et en analysant la page on voit que ca vient des requetes sql, images et js nikel compression, taille tout, le seul problème est mon code PHP.
Si quelqu'un se sent de jeter un oeil ça serait vraiment sympa à lui.
PS: le copier/coller dans un éditeur est plus lisible je trouve
La page:
<?php
$path = NULL;
if(empty($bdd)) {
session_start();
include("include/conndb.php");
include("include/variables.php");
$path = '../';
}
if(!empty($_POST['ville'])) {
header('Location: /sortie/region-'.$_REQUEST['region'].'/ville-de-'.simplification($_POST['ville']).'.html');
}
if(empty($_POST['ville'])) {
if(empty($_POST['ville'])) $erreurs['ville'] = 'Renseigner une ville'; //vérification du pseudo
}
// Nombre d'annonce
$count_annonce = "SELECT * FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1";
$count_annonce .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$count_annonce .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL;
$count_annonce .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL;
$count_annonce .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`id_type_loisirs` = "'.$_REQUEST['loisir'].'"' : NULL;
$req = $bdd->query($count_annonce);
$nb = $req->rowCount();
$result = 'Actuellement près de '.$nb.' annonces';
$result .= !empty($region_id) && array_key_exists($region_id, $aRegion) ? ' en '.$aRegion[$region_id].'. ' : NULL;
$result .= !empty($_REQUEST['departement']) ? ' en '.$depts[$_REQUEST['departement']] .'. ': NULL;
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
// meta desc
$meta_desc = !empty($_REQUEST['region']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? ' Idée de sortie en '.$aRegion[$region_id].'. Votre weekend va être chargé! Concert, brocante, expostition ... Ca se passe en '.$aRegion[$region_id].'. Trouver la sortie de vos envies!' : NULL;
$meta_desc .= !empty($_REQUEST['region']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) ? 'Que faire à '.ucfirst(strtolower($_REQUEST['ville'])).' ? En famille, en couple ou entre amis trouver votre sortie ! Aujourd\'hui ça va bouger à '.ucfirst(strtolower($_REQUEST['ville'])).'. Concert, exposition, vide-grenier, marché, visite ... Trouver une idée de sortie n\'a jamais était aussi simple qu\'avec lasortie.fr' : NULL;
$meta_desc .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? 'Envie d\'une sortie '.strtolower($_REQUEST['loisir']).' à '.ucfirst ($_REQUEST['ville']).' ? Besoin de vous changez les idées ? Trouvez une idée de sortie à '.ucfirst ($_REQUEST['ville']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? ucfirst(strtolower($_REQUEST['loisir'])).' en '.$aRegion[$region_id].'. Trouvez une sortie '.strtolower($_REQUEST['loisir']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) ? 'Retrouvez tous les sorties '.$_REQUEST['loisir'].' en '.$depts[$_REQUEST['departement']].' - '.$_REQUEST['departement'].'. Sortir en '.$depts[$_REQUEST['departement']].' n\'a jamais était aussi simple, trouver votre sortie facilement dès maintenant!' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($aRegion[$region_id]) ? 'A la recherche d\'une idée pour sortir à '.ucfirst ($_REQUEST['ville']).'. Changez vous les idées en trouvant une sortie à faire entre amis ou en famille sur lasortie.fr' : NULL; // Le département
$meta_desc .= empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) ? 'Sortir en '.$depts[$_REQUEST['departement']].' ('.($_REQUEST['departement']).'). Des idées de sorties pour les grands et les petits. Vide-grenier, concert, exposition, marché, loto ...': NULL; // Le département
// Meta facebook OPEN GRAPH
$meta_facebook = !empty($_REQUEST['region']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? ' Franchement t\'en a pas marre de te retrouver en week end et ne pas savoir quoi faire ? Ton weekend va être chargé avec lasortie.fr, concert, exposition, brocante, marché, activité sportive ....' : NULL; // Région
$meta_facebook .= !empty($_REQUEST['region']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) ? 'Idées de sortie sur '.ucfirst ($_REQUEST['ville']).' ! T\'es à la recherche d\'une sortie concert, vide-grenier, expo ... Où peut être à la recherche d\'une visite à faire en famille. Ca se passe sur lasortie.fr' : NULL;
$meta_facebook .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? 'Envie d\'une sortie '.strtolower($_REQUEST['loisir']).' à '.ucfirst ($_REQUEST['ville']).' ? Besoin de vous changez les idées ? Trouvez une idée de sortie à '.ucfirst ($_REQUEST['ville']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? ucfirst(strtolower($_REQUEST['loisir'])).' en '.$aRegion[$region_id].'. Trouvez une sortie '.strtolower($_REQUEST['loisir']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) ? 'Retrouvez tous les sorties '.$_REQUEST['loisir'].' en '.$depts[$_REQUEST['departement']].' - '.$_REQUEST['departement'].'. Sortir en '.$depts[$_REQUEST['departement']].' n\'a jamais était aussi simple, trouver votre sortie facilement dès maintenant!' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($aRegion[$region_id]) ? 'Sorties '.ucfirst ($_REQUEST['ville']).'. Changez vous les idées en trouvant une sortie à faire entre amis ou en famille sur lasortie.fr' : NULL; // Le département
$meta_facebook .= empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) ? 'Sortir en '.$depts[$_REQUEST['departement']].' ('.($_REQUEST['departement']).'). Des idées de sorties pour les grands et les petits. Vide-grenier, concert, exposition, marché, loto ...': NULL; // Le département
if (empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
$titre = 'Idée de sortie: Ca va bouger ce week-end !';
}else{
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
// Region
$titre = !empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && empty($_REQUEST['departement']) ? " Sortir en ".$aRegion[$region_id].': Concert, visite, brocante, festival … ' : NULL;
// Region et departement
$titre .= !empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir'])? 'Sortir en '.ucfirst ($depts[$_REQUEST['departement']]).' ('.($_REQUEST['departement']).') - lasortie.fr' : NULL;
// Region et loisirs
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? ucfirst(strtolower($_REQUEST['loisir'])).' en ' .$aRegion[$region_id].' - lasortie.fr' : NULL;
// departement et loisirs
$titre .= !empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? 'Sortie '.strtolower($_REQUEST['loisir']).' en ' .$depts[$_REQUEST['departement']].' - lasortie.fr' : NULL; // Le département
// ville
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir'])? 'Sortir à '.ucfirst(strtolower($_REQUEST['ville'])).' - Que faire à '.ucfirst(strtolower($_REQUEST['ville'])).' - '.lasortie.'.fr': NULL;
// ville
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? ucfirst(strtolower($_REQUEST['loisir'])).' à '.ucfirst(strtolower($_REQUEST['ville'])).' - lasortie.fr' : NULL; // Le département
}?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php header( 'content-type: text/html; charset=utf-8' ); ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index,follow" />
<title><?php echo $titre ; ?></title>
<meta name="description" content="<?php echo $meta_desc ;?>"/>
<?php $monUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?><link rel="canonical" href="<?php echo $monUrl ; ?>" />
<meta property="og:title" content="<?php echo $titre ; ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo $monUrl ; ?>" />
<meta property="og:image" content="http://www.lasortie.fr/img/image-logo-small.png" />
<meta property="og:description" content="<?php echo $meta_facebook ;?>" />
<link rel="icon" type="image/png" href="/img/favicon-op.png" />
<?php
$system_pagination = str_replace('.html' ,'',$monUrl);
if (empty($_GET['page'])) {
echo '<link rel="next" href="'.$system_pagination.'-page-2.html"/>';
}else{
$system_pagination = str_replace('-page-'.$_GET['page'].'.html' ,'',$monUrl);
echo '<link rel="prev" href="'.$system_pagination.'-page-'.($_GET['page']-1).'.html"/>';
echo '<link rel="next" href="'.$system_pagination.'-page-'.($_GET['page']+1).'.html"/>';
}
?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55674769-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body class="category-page">
<?php include("include/header-inner.php"); ?>
<div id="page">
<div class="breadcrumbs" itemprop="breadcrumb">
<div class="container">
<div class="row">
<div class="col-xs-12">
<ul>
<?php
// Région
if (!empty($_REQUEST['region'])) {
echo '<li class="home"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'.html" title="sortir en '.$aRegion[$region_id].'">'.$aRegion[$region_id].'</a><span>/</span></li>';
}else{NULL;}
// Département
if (!empty($_REQUEST['departement'])) {
echo '<li class="category1599"><a href="sorties-du-'.$_REQUEST['departement'].'.html" title="sortir en '.ucfirst($depts[$_REQUEST['departement']]).' ('.$_REQUEST['departement'].')">'.ucfirst($depts[$_REQUEST['departement']]).' - '.$_REQUEST['departement'].'</a><span>/ </span> </li>';
}else{NULL;}
if (!empty($_REQUEST['region']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
echo '<li class="category1599"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/activite-'.simplification($_REQUEST['loisir']).'.html" title="'.ucfirst($_REQUEST['loisir']).' en '.$aRegion[$region_id].' ('.$_REQUEST['departement'].')">'.ucfirst($_REQUEST['loisir']).'</a><span>/ </span> </li>';
}else{NULL;}
// Loisir
if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/activite-'.simplification($_REQUEST['loisir']).'/sorties-du-'.$_REQUEST['departement'].'.html" title="'.$_REQUEST['loisir'].' en '.$aRegion[$region_id].'">'.ucfirst($_REQUEST['loisir']).'</a><span>/</span> </li>';
}else{NULL;}
if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['ville'])){
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($_REQUEST['loisir']).'.html" title="'.ucfirst($_REQUEST['loisir']).' à '.ucfirst($_REQUEST['ville']).'">'.ucfirst($_REQUEST['loisir']).'</a><span>/</span> </li>';
}else{NULL;}
// ville
if (!empty($_REQUEST['ville'])) {
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/ville-de-'.simplification($_REQUEST['ville']).'.html" title="sortie '.ucfirst($_REQUEST['ville']).'">Sortie '.ucfirst($_REQUEST['ville']).'</a><span>/</span> </li>';
}else{NULL;}
?>
</ul>
</div>
</div>
</div>
</div>
<section class="main-container col2-left-layout">
<div class="container">
<div class="row">
<div class="col-sm-9 col-sm-push-3">
<?php
$parPage = 15;
$du = !empty($_REQUEST['du']) ? $_REQUEST['du'] : NULL;
$au = !empty($_REQUEST['au']) ? $_REQUEST['au'] : NULL;
$page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1;
if(!empty($_REQUEST['datetimepicker'])) {
$date = DateTime::createFromFormat('d/m/Y', $_REQUEST['datetimepicker']);
$du = $au = $date->format('Y-m-d');
}
$_REQUEST['departement'] = !empty($_REQUEST['departement']) ? $_REQUEST['departement'] : NULL;
$_REQUEST['departement'] = !empty($_SESSION['membre']) && empty($_REQUEST['departement']) && empty($_REQUEST['region']) ? $_SESSION['membre']['id_departements'] :$_REQUEST['departement'];
$sql = 'SELECT * FROM loisirs JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE loisirs.date_fin_sortie > NOW() AND loisirs.valide = 1';
// region
if(!empty($_REQUEST['region'])){
// FIXME : sql injectin spoted
$sql .= ' AND regions.url = \''.$_REQUEST['region'].'\'' ;
}
if(!empty($_REQUEST['departement'])){
$sql .= ' AND loisirs.id_departements = '.$_REQUEST['departement'];
}
if(!empty($_REQUEST['loisir']) ){
// FIXME : sql injectin spoted
$sql .= ' AND loisirs.genre_loisir = \''.$_REQUEST['loisir'].'\'' ; // loisir
}
// FIXME : sql injectin spoted
if(!empty($du) && !empty($au)) {
$sql .= ' AND (DATE_FORMAT(loisirs.date_debut_sortie, \'%Y-%m-%d\') <= \''.$du.'\' AND DATE_FORMAT(loisirs.date_fin_sortie, \'%Y-%m-%d\') >= \''.$au.'\')';
}
// Recherche par ville
if(!empty($_REQUEST['ville'])) {
$sql .= ' AND loisirs.city = \''. getRealValue($_REQUEST['ville']). '\'';
}
$req = $bdd->query($sql);
// on affiche le nombre de sorties en fonction des filtres
$nb = $req->rowCount();
if ($req->fetchColumn() > 0) {
// on affiche le h1 en fonction de la region
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
$region_id = !empty($_SESSION['membre']['id_region']) && empty($_REQUEST['region']) ? $_SESSION['membre']['id_region'] : $region_id;
$h1 = $nb;
// Par ville
$h1 .= empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($_REQUEST['region']) ? ' <h1 class="page-heading"> annonces pour trouver une idée de sortie !</h1>' : NULL; // La ville
$h1 .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region'])? ' <h1 class="page-heading"> annonces pour sortir à '. ucfirst($_REQUEST['ville']).'</h1>' : NULL; // La ville
$h1 .= !empty($_REQUEST['ville']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? '<h1 class="page-heading"> sorties pour '.ucfirst($_REQUEST['loisir']).' à '. ucfirst ($_REQUEST['ville']).' </h1>' : NULL; // La ville
$h1 .= !empty($region_id) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<h1 class="page-heading"> sorties pour sortir en ' .$aRegion[$region_id] .'</h1>': NULL; // La région
$h1 .= !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['ville']) ? ' <h1 class="page-heading"> sorties ' .strtolower($_REQUEST['loisir']).' en ' .$aRegion[$region_id] .' </h1>': NULL; // Le type de sortie
// Département
$h1 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) ? '<h1 class="page-heading"> des sorties ' .ucfirst($_REQUEST['loisir']).' en '.$depts[$_REQUEST['departement']].' ('.$_REQUEST['departement'].')</a></h1>' : NULL; // Le département
$h1 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<h1 class="page-heading"> sortir en '.$depts[$_REQUEST['departement']].' ('.$_REQUEST['departement'].')</h1>' : NULL; // Le département
// Affichage de la date en fr du datepicker
$h1 .= !empty($du) ? " le <strong>" .date('d/m/Y', strtotime($du))."</strong>" : NULL; // La date choisis selon les filtres
echo '<div class="col-md-12 result-search"><div class="col-md-5 pad-15"> '.$h1.'</div>'?>
<form method="POST">
<div class="col-md-3 col-sm-12 max">
<div class="input-group">
<input class="search-motor form-control" title="Recherche de sortie par date "id="datetimepicker2" name="datetimepicker" placeholder="Recherche par date" type="text" readonly value="<?php echo !empty($_REQUEST['datetimepicker']) ? $_REQUEST['datetimepicker'] : NULL; ?>">
<span class="input-group-addon custom">
<button class="btn btn-default search-btn" type="submit"><i class="fa fa-calendar-o"></i></button>
</span>
</div>
</div>
</form>
<div class="col-md-4 col-sm-12 max">
<form id="choice" method="POST" action="">
<div class="input-group">
<input title="Recherche par ville" placeholder="Recherche par ville" class="search-motor form-control" value="<?php echo !empty($_REQUEST['ville']) ? $_REQUEST['ville'] : NULL;?>" name="ville" id="ville" type="search">
<span class="input-group-btn">
<button name="submit_city" id="submit_city" type="submit" class="btn btn-default search-btn">GO !</button>
</span>
</div>
</form>
</div>
</div>
<article class="col-main">
<?php include("include/optimisation.php"); ?>
<?php echo '<div class="category-products">
<ol class="products-list" id="products-list">'."\n";
}
// Si il n y a que la région de demandée
if (!empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
$valeur_paginate = 'region-'.$_REQUEST['region'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement'])) {
$valeur_paginate = 'activite-'.$_REQUEST['loisir'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['ville'])) {
$valeur_paginate = 'ville-de-'.simplification($_REQUEST['ville']);
}
?>
<?php
$nbre_annonces_par_page = 15;
$nbre_pages_max_gauche_et_droite = 4;
$last_page = ceil($nb / $nbre_annonces_par_page);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page_num = $_GET['page'];
} else {
$page_num = 1;
}
if($page_num < 1){
$page_num = 1;
} else if($page_num > $last_page) {
$page_num = $last_page;
}
$limit = 'LIMIT '.($page_num - 1) * $nbre_annonces_par_page. ',' . $nbre_annonces_par_page;
$pagination = '';
if($last_page != 1){
if($page_num > 1){
$previous = $page_num - 1;
$pagination .= '<a href="'.$valeur_paginate.($previous > 1 ? '-page-'.$previous : null).'.html" class="page" data-page="'.$previous.'" data-du="'.$du.'" data-au="'.$au.'"><i class="fa fa-angle-left"></i></a> ';
for($i = $page_num - $nbre_pages_max_gauche_et_droite; $i < $page_num; $i++){
if($i > 0){
$pagination .= '<a href="'.$valeur_paginate.($i > 1 ? '-page-'.$i : null).'.html" class="page" data-page="'.$i.'" data-du="'.$du.'" data-au="'.$au.'">'.$i.'</a> ';
}
}
}
$pagination .= '<span class="active">'.$page_num.'</span> ';
for($i = $page_num+1; $i <= $last_page; $i++){
$pagination .= '<a href="'.$valeur_paginate.'-page-'.$i.'.html" class="page" data-page="'.$i.'" data-du="'.$du.'" data-au="'.$au.'">'.$i.'</a> ';
if($i >= $page_num + $nbre_pages_max_gauche_et_droite){
break;
}
}
if($page_num != $last_page){
$next = $page_num + 1;
$pagination .= '<a href="'.$valeur_paginate.'-page-'.$next.'.html" class="page" data-page="'.$next.'" data-du="'.$du.'" data-au="'.$au.'"><i class="fa fa-angle-right"></i></a> ';
}
}
// Ordre d'affichage
if (!empty($_REQUEST['ville'])) {
$sql .= " ORDER BY CASE
WHEN heart = 1 THEN 3
WHEN id_simply_user != 999 THEN 2
WHEN id_simply_user = 999 THEN 1
END DESC
LIMIT ".intval(($page-1)*$parPage).", ".$parPage;
// Si il n y a pas de ville de renseignée
}else{
$sql .= "ORDER BY loisirs.id_loisirs DESC LIMIT ".intval(($page-1)*$parPage).", ".$parPage ;;
}
$req = $bdd->query($sql);
$nb2 = $req->rowCount();
if($nb2 > 0) {
$req = $bdd->query($sql);
while($ligne = $req->fetch(PDO::FETCH_ASSOC)){
$date = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_debut_sortie']);
$image = !empty($ligne['photo']) && file_exists('img/img-big-format/miniature/'.$ligne['photo']) ? 'img/img-big-format/miniature/'.$ligne['photo'] : 'img/remplacement/'.simplification($aLoisirs[$ligne['id_type_loisirs']]).'.jpg';
// Si l'annonce est en cours
$encours = ($ligne['date_debut_sortie'] != $ligne['date_fin_sortie']) ? 'Depuis le' : 'One shot';
$encours = (strtotime($ligne['date_debut_sortie']) > time()) ? '' : $encours;
$lien = "".$ligne["url_rewrite"]."/".$ligne["id_loisirs"];
$dated = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_debut_sortie']);
$datef = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_fin_sortie']);
$la_variable_qui_vas_bien = "";
if($ligne['date_debut_sortie'] != "0000-00-00 00:00:00") {
$la_variable_qui_vas_bien = $ligne['date_debut_sortie'] = ucfirst($jour[$dated->format('N')]).' '.$dated->format('d').' '.ucfirst($mois[$dated->format('n')]).' '.$dated->format('Y');
} else {
$la_variable_qui_vas_bien = "Jusqu'au " .ucfirst($jour[$datef->format('N')]).' '.$datef->format('d').' '.ucfirst($mois[$datef->format('n')]).' '.$datef->format('Y');
}
$ligne['description'] = str_replace($mots, $remplacements, $ligne['description']);
$recherche_pour_url = $ligne['titre'];
$remplacement_url = str_replace ( ' ', '-', $recherche_pour_url);
$salle = !empty($ligne['manufacturer']) ? $ligne['manufacturer'] : NULL;
if (!empty ($ligne['url_fnac'])) {
echo ' <li class="item first">
<div class="product-image"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html"><img class="img-responsive" src="'.$ligne['photo'].'" alt="'.$ligne['titre'].'" title="'.$aLoisirs[$ligne['id_type_loisirs']].', '.$ligne['titre'].'"></a></div>
<div class="product-shop">
<h3 class="product-name"><a href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification($ligne["city"])."/".$ligne["id_loisirs"].'.html" title="'.ucfirst(strtolower($ligne['titre'])).'">'.ucfirst($ligne['titre']).'</a></h3>
<div class="ratings"><i class="fa fa-calendar-o" aria-hidden="true"></i> '.$encours.' '.$la_variable_qui_vas_bien.'</div>
<div class="desc std">
<p>'. stripslashes(cutTexte($ligne['description'], 500, '...')).'<a class="link-learn" title="" href="/'.$lien.'"></a> </p>
</div>
<p class="hash"><i class="fa fa-map-marker"></i><span class="sortir_city"> '.$salle.' - <span class="sortir_city"> <a href="http://lasortie.fr/sortie/region-'.simplification($aRegion[$region_id]).'/ville-de-'.simplification($ligne['city']).'.html"> <strong>'.ucfirst(mb_strtolower($ligne['city'], 'UTF-8')).'</strong></a></span> ('.str_pad($ligne['id_departements'], 2, "0", STR_PAD_LEFT).')</span></p>
<div class="actions">
<a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification($ligne["genre_loisir"])."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html"><button class="button btn-cart ajx-cart" title="'.ucfirst(strtolower($ligne['titre'])).' à '.ucfirst(strtolower($ligne['city'])).'" type="button"><span>En détails</span></button></a>
<span class="add-to-links"> <a rel="nofollow" title="Add to Wishlist" class="button link-wishlist" href="/add_favoris.php?idfav='.$ligne['id_loisirs'].'"><span>Ajouter aux favoris</span></a></span> </div>
</div></li>'."\n";
}else{
echo' <li class="item first">
<div class="product-image"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification($ligne["city"])."/".$ligne["id_loisirs"].'.html"><img class="img-responsive" src="/'.$image.'" alt="'.$ligne['titre'].'" title="'.$aLoisirs[$ligne['id_type_loisirs']].', '.$ligne['titre'].'"></a></div>
<div class="product-shop">
<h3 class="product-name"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" title="'.ucfirst(strtolower($ligne['titre'])).'">'.ucfirst($ligne['titre']).'</a></h3>
<div class="ratings"><i class="fa fa-calendar-o" aria-hidden="true"></i> '.$encours.' '.$la_variable_qui_vas_bien.'</div>
<div class="desc std">
<p>'. stripslashes(cutTexte($ligne['description'], 500, '...')).'<a class="link-learn" title="" href="/'.$lien.'"></a> </p>
</div>
<p class="hash"><i class="fa fa-map-marker"></i><span class="sortir_city"><strong> <a href="http://lasortie.fr/sortie/region-'.simplification($aRegion[$region_id]).'/ville-de-'.simplification($ligne['city']).'.html"> Sortie '.ucfirst(mb_strtolower($ligne['city'], 'UTF-8')).' </a></strong> ('.str_pad($ligne['id_departements'], 2, "0", STR_PAD_LEFT).')</span></p>
<div class="actions">
<a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification(mb_strtolower($ligne['city'], 'UTF-8'))."/".$ligne["id_loisirs"].'.html"><button class="button btn-cart ajx-cart" title="'.ucfirst(strtolower($ligne['titre'])).' à '.ucfirst(strtolower($ligne['city'])).'" type="button"><span>En détails</span></button></a>
<span class="add-to-links"> <a rel="nofollow" title="Add to Wishlist" class="button link-wishlist" href="/add_favoris.php?idfav='.$ligne['id_loisirs'].'"><span>Ajouter aux favoris</span></a></span> </div>
</div></li>'."\n";
}
}
echo '</ol><div class="pagination col-md-12">
<div class="row">
'.$pagination.'
</div>
</div>
';
$req->closeCursor();
} else {
echo '<div class="pad15"><div class="alert alert-danger" role="alert"> <i class="fa fa-frown-o"></i>
Actuellement aucune sortie ne correspond à votre recherche</div></div>';
}
?>
</div>
</article>
</div>
<div class="col-left sidebar col-sm-3 col-xs-12 col-sm-pull-9">
<div class="side-nav-categories">
<div class="block-title"> Categories <div class="fb-share-button pull-right" data-href="<?php echo $page_name;?>" data-layout="button_count"></div>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.5";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script></div>
<div class="dropdown-marg">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<?php
if (empty($_REQUEST['ville'])) {
if (!empty($_REQUEST['departement'])){
echo 'Département '. $depts[$_REQUEST['departement']].'-'.$_REQUEST['departement'];
}else{
echo'Choisir un département';
}
echo'
<span class="caret"></span></button>
<ul class="dropdown-menu">';
foreach($aDepartement[regionByUrl($_REQUEST['region'])] as $id => $dep){
// on affiche les sorties selon le département et le loisir demandée
if (!empty($_REQUEST['region']) && empty($_GET['page']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && empty($_GET['page']) && !empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && !empty($_GET['page']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="region-'.$_REQUEST['region'].'/sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && !empty($_GET['page']) && empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
echo '<li><a href="region-'.$_REQUEST['region'].'/sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
else{
// Si il n y a pas de region de renseignée
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>'."\n";
}
}
}else{
echo '<h2>Activités '.ucfirst(strtolower($_REQUEST['ville'])).'</h2>';
}
?>
</ul></div>
<div class="box-content box-category">
<ul>
<?php
// Si il n y a pas de ville de renseignée
if (empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && !empty($_REQUEST['region'])) {
$liste = $bdd->query("SELECT id_type_loisirs,COUNT(*) as nb FROM loisirs WHERE id_region = ".$region_id." AND `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1 GROUP BY id_type_loisirs " );
while($row = $liste->fetch(PDO::FETCH_ASSOC)) {
$count[$row['id_type_loisirs']] = $row['nb'];
}
asort($aLoisirs);
foreach($aLoisirs as $k => $v) {;
$nb = array_key_exists($k, $count) ? $count[$k] : 0;
if ($nb>=1) {
// Si il y a un loisir de renseignée et aucune page demandée
if (!empty($_REQUEST['loisir']) && empty($_GET['page']) && empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a une page de renseignée
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ) {
echo '<li><a href="ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a une page de renseignée
else if(!empty($_GET['page']) && !empty($_REQUEST['loisir'])){
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])){
echo '<li><a href="region-'.$_REQUEST['region'].'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="../../region-'.$_REQUEST['region'].'/activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(!empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
else{
// Si il n y a pas de region de renseignée
echo '<li><a href="region-'.$_REQUEST['region'].'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
}
}
}
elseif (empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region'])) {
$liste = "SELECT id_type_loisirs, COUNT(id_type_loisirs) as nb FROM loisirs";
$liste.= " WHERE id_departements = '".$_REQUEST['departement']."' AND date_fin_sortie > NOW() AND valide = 1 ";
$liste.= " GROUP BY id_type_loisirs HAVING COUNT(id_type_loisirs) >= 1 ORDER BY nb DESC LIMIT 0,30";
$req = $bdd->query($liste);
while($row = $req->fetch(PDO::FETCH_ASSOC)){
if (empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="../region-'.$_REQUEST['region'].'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
elseif (!empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['ville'])) {
echo '<li><a href="../activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
}
}
else {
$_REQUEST['ville'] = str_replace('-', ' ', $_REQUEST['ville']); // on remplace les espaces par des tirets
$liste = "SELECT id_type_loisirs, COUNT(id_type_loisirs) as nb FROM loisirs";
$liste.= " WHERE city = '".$_REQUEST['ville']."' AND date_fin_sortie > NOW() AND valide = 1 ";
$liste.= " GROUP BY id_type_loisirs HAVING COUNT(id_type_loisirs) >= 1 ORDER BY nb DESC LIMIT 0,30";
$req = $bdd->query($liste);
while($row = $req->fetch(PDO::FETCH_ASSOC)){
// Si il y a un loisir de renseignée et aucune page demandée
if (empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
else if (!empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
else if (empty($_REQUEST['loisir']) && !empty($_GET['page']) && !empty($_GET['ville']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="ville-de-'.$_REQUEST['ville'].'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(!empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region'])){
echo '<li><a href="activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
}
}
?>
</ul>
</div>
</div>
<?php
$h2 = empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($aRegion[$region_id]) ?' <strong> activités</strong>' : NULL; // Le département
$h2 .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville']) ? " <strong> activités</strong> EN ".$aRegion[$region_id] : NULL; // Sortir en "nom de la région"
$h2 .= !empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) ? ' SORTIES '.$depts[$_REQUEST['departement']] : NULL; // Le département
$h2 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<a title="Sortie '.ucfirst($_REQUEST['loisir']).' en '.$depts[$_REQUEST['departement']].'" href="toutes-les-sorties-du-departement-'.$_REQUEST['departement'].'-'.$_REQUEST['loisir'].'.html"><strong>'.ucfirst($_REQUEST['loisir']).' <span class="normal-weight">' .$depts[$_REQUEST['departement']].'</span></strong></a>' : NULL; // Le département
$h2 .= !empty($_REQUEST['ville']) && !empty($aRegion[$region_id]) && empty($_REQUEST['loisir']) ?' <strong>SORTIES '.ucfirst ($_REQUEST['ville']).'</strong>' : NULL; // ville
$h2 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($aLoisirs[$_REQUEST['loisir']]).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= empty($_REQUEST['departement']) && !empty($aRegion[$region_id]) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($_REQUEST['loisir']).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= empty($_REQUEST['departement']) && empty($aRegion[$region_id]) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($aLoisirs[$_REQUEST['loisir']]).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($aRegion[$region_id]) ?' <strong>IDÉES DE SORTIES '.ucfirst ($_REQUEST['ville']) .'</strong>': NULL; // Le département
echo '
<div class="block block-compare">
<div class="block-title "><h2>'.$h2.'</h2></div>
<div class="block-content">
<ul>
<ol id="compare-items">';?>
<?php
$pub = "SELECT * FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1";
$pub .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL; // region
$pub .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL; // dep
$pub .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`genre_loisir` = "'.$_REQUEST['loisir'].'"' : NULL; // loisir
$pub .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$pub .= " ORDER BY RAND () DESC LIMIT 0, 10";
$req = $bdd->query($pub);
if($req->rowCount() > 0) {
while($ligne = $req->fetch(PDO::FETCH_ASSOC)){
if (!empty ($ligne['url_fnac'])) {
echo '<li class="item odd"><a rel="nofollow" href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" class="product-name">'. ucfirst(cutTexte($ligne['titre'], 40, '...')).'</a><div class="adjust-titre"></div></li>';
}else{
echo '<li class="item odd"><a rel="nofollow" href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" class="product-name"> '. ucfirst(cutTexte($ligne['titre'], 40, '...')).'</a><div class="adjust-titre"> </div></li>';
}
}
}
?>
</ol>
</ul>
</div></div>
<div class="block block-tags">
<div class="block-title"> VILLES ACTIVES <?php if (!empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) { echo $aRegion[$region_id]; }?>
</div>
<div class="block-content">
<ul>
<?php
$actu_ville = "SELECT DISTINCT city, count(*) as nb_annonces FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region`";
$actu_ville .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL;
$actu_ville .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL;
$actu_ville .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`id_type_loisirs` = "'.$_REQUEST['loisir'].'"' : NULL;
$actu_ville .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$actu_ville .= " GROUP BY city HAVING nb_annonces >10 ORDER BY nb_annonces DESC LIMIT 0,15";
$req = $bdd->query($actu_ville);
$nb_annonces = $req->rowCount();
if($req->rowCount() > 0) {
while($recent_actu = $req->fetch(PDO::FETCH_ASSOC)){
if (empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
echo '<li><a class="follow_actu_sortie" href="region-'.$_REQUEST['region'].'/ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
elseif (empty($_REQUEST['loisir']) && !empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
echo '<li><a class="follow_actu_sortie" href="region-'.$_REQUEST['region'].'/ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
else {
echo '<li><a class="follow_actu_sortie" href="ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
}
}else{ echo 'Aucune annonce enregistrée '; }
?>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include("include/footer-inner.php"); ?>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Raleway:600,500,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/style.css" media="all">
<link rel="stylesheet" href="/css/jquery.datetimepicker.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script async type="text/javascript" src="/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/jquery.datetimepicker-min.js"></script>
<script async type="text/javascript" src="/js/moment.js"></script>
<script async type="text/javascript">
jQuery('#datetimepicker2').datetimepicker({
datepicker:true,
timepicker:false,
closeOnDateSelect:true,
format:'d/m/Y'
});
</script>
</body>
</html>
Salut à tous.
Bon je ne suis pas un pro du php mais j'ai finis mon projet et je souhaite arranger un peu parceque le temps d'éxécution de la page est long et en analysant la page on voit que ca vient des requetes sql, images et js nikel compression, taille tout, le seul problème est mon code PHP.
Si quelqu'un se sent de jeter un oeil ça serait vraiment sympa à lui.
PS: le copier/coller dans un éditeur est plus lisible je trouve
La page:
[php]<?php
$path = NULL;
if(empty($bdd)) {
session_start();
include("include/conndb.php");
include("include/variables.php");
$path = '../';
}
if(!empty($_POST['ville'])) {
header('Location: /sortie/region-'.$_REQUEST['region'].'/ville-de-'.simplification($_POST['ville']).'.html');
}
if(empty($_POST['ville'])) {
if(empty($_POST['ville'])) $erreurs['ville'] = 'Renseigner une ville'; //vérification du pseudo
}
// Nombre d'annonce
$count_annonce = "SELECT * FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1";
$count_annonce .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$count_annonce .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL;
$count_annonce .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL;
$count_annonce .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`id_type_loisirs` = "'.$_REQUEST['loisir'].'"' : NULL;
$req = $bdd->query($count_annonce);
$nb = $req->rowCount();
$result = 'Actuellement près de '.$nb.' annonces';
$result .= !empty($region_id) && array_key_exists($region_id, $aRegion) ? ' en '.$aRegion[$region_id].'. ' : NULL;
$result .= !empty($_REQUEST['departement']) ? ' en '.$depts[$_REQUEST['departement']] .'. ': NULL;
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
// meta desc
$meta_desc = !empty($_REQUEST['region']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? ' Idée de sortie en '.$aRegion[$region_id].'. Votre weekend va être chargé! Concert, brocante, expostition ... Ca se passe en '.$aRegion[$region_id].'. Trouver la sortie de vos envies!' : NULL;
$meta_desc .= !empty($_REQUEST['region']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) ? 'Que faire à '.ucfirst(strtolower($_REQUEST['ville'])).' ? En famille, en couple ou entre amis trouver votre sortie ! Aujourd\'hui ça va bouger à '.ucfirst(strtolower($_REQUEST['ville'])).'. Concert, exposition, vide-grenier, marché, visite ... Trouver une idée de sortie n\'a jamais était aussi simple qu\'avec lasortie.fr' : NULL;
$meta_desc .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? 'Envie d\'une sortie '.strtolower($_REQUEST['loisir']).' à '.ucfirst ($_REQUEST['ville']).' ? Besoin de vous changez les idées ? Trouvez une idée de sortie à '.ucfirst ($_REQUEST['ville']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? ucfirst(strtolower($_REQUEST['loisir'])).' en '.$aRegion[$region_id].'. Trouvez une sortie '.strtolower($_REQUEST['loisir']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) ? 'Retrouvez tous les sorties '.$_REQUEST['loisir'].' en '.$depts[$_REQUEST['departement']].' - '.$_REQUEST['departement'].'. Sortir en '.$depts[$_REQUEST['departement']].' n\'a jamais était aussi simple, trouver votre sortie facilement dès maintenant!' : NULL; // Choix du type d'évènement
$meta_desc .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($aRegion[$region_id]) ? 'A la recherche d\'une idée pour sortir à '.ucfirst ($_REQUEST['ville']).'. Changez vous les idées en trouvant une sortie à faire entre amis ou en famille sur lasortie.fr' : NULL; // Le département
$meta_desc .= empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) ? 'Sortir en '.$depts[$_REQUEST['departement']].' ('.($_REQUEST['departement']).'). Des idées de sorties pour les grands et les petits. Vide-grenier, concert, exposition, marché, loto ...': NULL; // Le département
// Meta facebook OPEN GRAPH
$meta_facebook = !empty($_REQUEST['region']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? ' Franchement t\'en a pas marre de te retrouver en week end et ne pas savoir quoi faire ? Ton weekend va être chargé avec lasortie.fr, concert, exposition, brocante, marché, activité sportive ....' : NULL; // Région
$meta_facebook .= !empty($_REQUEST['region']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) ? 'Idées de sortie sur '.ucfirst ($_REQUEST['ville']).' ! T\'es à la recherche d\'une sortie concert, vide-grenier, expo ... Où peut être à la recherche d\'une visite à faire en famille. Ca se passe sur lasortie.fr' : NULL;
$meta_facebook .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? 'Envie d\'une sortie '.strtolower($_REQUEST['loisir']).' à '.ucfirst ($_REQUEST['ville']).' ? Besoin de vous changez les idées ? Trouvez une idée de sortie à '.ucfirst ($_REQUEST['ville']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ? ucfirst(strtolower($_REQUEST['loisir'])).' en '.$aRegion[$region_id].'. Trouvez une sortie '.strtolower($_REQUEST['loisir']).' n\'a jamais était aussi simple avec lasortie.fr' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) ? 'Retrouvez tous les sorties '.$_REQUEST['loisir'].' en '.$depts[$_REQUEST['departement']].' - '.$_REQUEST['departement'].'. Sortir en '.$depts[$_REQUEST['departement']].' n\'a jamais était aussi simple, trouver votre sortie facilement dès maintenant!' : NULL; // Choix du type d'évènement
$meta_facebook .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($aRegion[$region_id]) ? 'Sorties '.ucfirst ($_REQUEST['ville']).'. Changez vous les idées en trouvant une sortie à faire entre amis ou en famille sur lasortie.fr' : NULL; // Le département
$meta_facebook .= empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) ? 'Sortir en '.$depts[$_REQUEST['departement']].' ('.($_REQUEST['departement']).'). Des idées de sorties pour les grands et les petits. Vide-grenier, concert, exposition, marché, loto ...': NULL; // Le département
if (empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
$titre = 'Idée de sortie: Ca va bouger ce week-end !';
}else{
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
// Region
$titre = !empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && empty($_REQUEST['departement']) ? " Sortir en ".$aRegion[$region_id].': Concert, visite, brocante, festival … ' : NULL;
// Region et departement
$titre .= !empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && empty($_REQUEST['loisir'])? 'Sortir en '.ucfirst ($depts[$_REQUEST['departement']]).' ('.($_REQUEST['departement']).') - lasortie.fr' : NULL;
// Region et loisirs
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? ucfirst(strtolower($_REQUEST['loisir'])).' en ' .$aRegion[$region_id].' - lasortie.fr' : NULL;
// departement et loisirs
$titre .= !empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? 'Sortie '.strtolower($_REQUEST['loisir']).' en ' .$depts[$_REQUEST['departement']].' - lasortie.fr' : NULL; // Le département
// ville
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && !empty($_REQUEST['ville']) && empty($_REQUEST['loisir'])? 'Sortir à '.ucfirst(strtolower($_REQUEST['ville'])).' - Que faire à '.ucfirst(strtolower($_REQUEST['ville'])).' - '.lasortie.'.fr': NULL;
// ville
$titre .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['loisir'])? ucfirst(strtolower($_REQUEST['loisir'])).' à '.ucfirst(strtolower($_REQUEST['ville'])).' - lasortie.fr' : NULL; // Le département
}?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php header( 'content-type: text/html; charset=utf-8' ); ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index,follow" />
<title><?php echo $titre ; ?></title>
<meta name="description" content="<?php echo $meta_desc ;?>"/>
<?php $monUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?><link rel="canonical" href="<?php echo $monUrl ; ?>" />
<meta property="og:title" content="<?php echo $titre ; ?>" />
<meta property="og:type" content="article" />
<meta property="og:url" content="<?php echo $monUrl ; ?>" />
<meta property="og:image" content="http://www.lasortie.fr/img/image-logo-small.png" />
<meta property="og:description" content="<?php echo $meta_facebook ;?>" />
<link rel="icon" type="image/png" href="/img/favicon-op.png" />
<?php
$system_pagination = str_replace('.html' ,'',$monUrl);
if (empty($_GET['page'])) {
echo '<link rel="next" href="'.$system_pagination.'-page-2.html"/>';
}else{
$system_pagination = str_replace('-page-'.$_GET['page'].'.html' ,'',$monUrl);
echo '<link rel="prev" href="'.$system_pagination.'-page-'.($_GET['page']-1).'.html"/>';
echo '<link rel="next" href="'.$system_pagination.'-page-'.($_GET['page']+1).'.html"/>';
}
?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-55674769-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body class="category-page">
<?php include("include/header-inner.php"); ?>
<div id="page">
<div class="breadcrumbs" itemprop="breadcrumb">
<div class="container">
<div class="row">
<div class="col-xs-12">
<ul>
<?php
// Région
if (!empty($_REQUEST['region'])) {
echo '<li class="home"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'.html" title="sortir en '.$aRegion[$region_id].'">'.$aRegion[$region_id].'</a><span>/</span></li>';
}else{NULL;}
// Département
if (!empty($_REQUEST['departement'])) {
echo '<li class="category1599"><a href="sorties-du-'.$_REQUEST['departement'].'.html" title="sortir en '.ucfirst($depts[$_REQUEST['departement']]).' ('.$_REQUEST['departement'].')">'.ucfirst($depts[$_REQUEST['departement']]).' - '.$_REQUEST['departement'].'</a><span>/ </span> </li>';
}else{NULL;}
if (!empty($_REQUEST['region']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
echo '<li class="category1599"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/activite-'.simplification($_REQUEST['loisir']).'.html" title="'.ucfirst($_REQUEST['loisir']).' en '.$aRegion[$region_id].' ('.$_REQUEST['departement'].')">'.ucfirst($_REQUEST['loisir']).'</a><span>/ </span> </li>';
}else{NULL;}
// Loisir
if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/activite-'.simplification($_REQUEST['loisir']).'/sorties-du-'.$_REQUEST['departement'].'.html" title="'.$_REQUEST['loisir'].' en '.$aRegion[$region_id].'">'.ucfirst($_REQUEST['loisir']).'</a><span>/</span> </li>';
}else{NULL;}
if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['ville'])){
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($_REQUEST['loisir']).'.html" title="'.ucfirst($_REQUEST['loisir']).' à '.ucfirst($_REQUEST['ville']).'">'.ucfirst($_REQUEST['loisir']).'</a><span>/</span> </li>';
}else{NULL;}
// ville
if (!empty($_REQUEST['ville'])) {
echo '<li class="category1600"><a href="http://lasortie.fr/sortie/region-'.simplification($_REQUEST['region']).'/ville-de-'.simplification($_REQUEST['ville']).'.html" title="sortie '.ucfirst($_REQUEST['ville']).'">Sortie '.ucfirst($_REQUEST['ville']).'</a><span>/</span> </li>';
}else{NULL;}
?>
</ul>
</div>
</div>
</div>
</div>
<section class="main-container col2-left-layout">
<div class="container">
<div class="row">
<div class="col-sm-9 col-sm-push-3">
<?php
$parPage = 15;
$du = !empty($_REQUEST['du']) ? $_REQUEST['du'] : NULL;
$au = !empty($_REQUEST['au']) ? $_REQUEST['au'] : NULL;
$page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1;
if(!empty($_REQUEST['datetimepicker'])) {
$date = DateTime::createFromFormat('d/m/Y', $_REQUEST['datetimepicker']);
$du = $au = $date->format('Y-m-d');
}
$_REQUEST['departement'] = !empty($_REQUEST['departement']) ? $_REQUEST['departement'] : NULL;
$_REQUEST['departement'] = !empty($_SESSION['membre']) && empty($_REQUEST['departement']) && empty($_REQUEST['region']) ? $_SESSION['membre']['id_departements'] :$_REQUEST['departement'];
$sql = 'SELECT * FROM loisirs JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE loisirs.date_fin_sortie > NOW() AND loisirs.valide = 1';
// region
if(!empty($_REQUEST['region'])){
// FIXME : sql injectin spoted
$sql .= ' AND regions.url = \''.$_REQUEST['region'].'\'' ;
}
if(!empty($_REQUEST['departement'])){
$sql .= ' AND loisirs.id_departements = '.$_REQUEST['departement'];
}
if(!empty($_REQUEST['loisir']) ){
// FIXME : sql injectin spoted
$sql .= ' AND loisirs.genre_loisir = \''.$_REQUEST['loisir'].'\'' ; // loisir
}
// FIXME : sql injectin spoted
if(!empty($du) && !empty($au)) {
$sql .= ' AND (DATE_FORMAT(loisirs.date_debut_sortie, \'%Y-%m-%d\') <= \''.$du.'\' AND DATE_FORMAT(loisirs.date_fin_sortie, \'%Y-%m-%d\') >= \''.$au.'\')';
}
// Recherche par ville
if(!empty($_REQUEST['ville'])) {
$sql .= ' AND loisirs.city = \''. getRealValue($_REQUEST['ville']). '\'';
}
$req = $bdd->query($sql);
// on affiche le nombre de sorties en fonction des filtres
$nb = $req->rowCount();
if ($req->fetchColumn() > 0) {
// on affiche le h1 en fonction de la region
$region_id = !empty($_REQUEST['region']) ? regionByUrl($_REQUEST['region']) : NULL;
$region_id = !empty($_SESSION['membre']['id_region']) && empty($_REQUEST['region']) ? $_SESSION['membre']['id_region'] : $region_id;
$h1 = $nb;
// Par ville
$h1 .= empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($_REQUEST['region']) ? ' <h1 class="page-heading"> annonces pour trouver une idée de sortie !</h1>' : NULL; // La ville
$h1 .= !empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region'])? ' <h1 class="page-heading"> annonces pour sortir à '. ucfirst($_REQUEST['ville']).'</h1>' : NULL; // La ville
$h1 .= !empty($_REQUEST['ville']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) ? '<h1 class="page-heading"> sorties pour '.ucfirst($_REQUEST['loisir']).' à '. ucfirst ($_REQUEST['ville']).' </h1>' : NULL; // La ville
$h1 .= !empty($region_id) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<h1 class="page-heading"> sorties pour sortir en ' .$aRegion[$region_id] .'</h1>': NULL; // La région
$h1 .= !empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['ville']) ? ' <h1 class="page-heading"> sorties ' .strtolower($_REQUEST['loisir']).' en ' .$aRegion[$region_id] .' </h1>': NULL; // Le type de sortie
// Département
$h1 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) ? '<h1 class="page-heading"> des sorties ' .ucfirst($_REQUEST['loisir']).' en '.$depts[$_REQUEST['departement']].' ('.$_REQUEST['departement'].')</a></h1>' : NULL; // Le département
$h1 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<h1 class="page-heading"> sortir en '.$depts[$_REQUEST['departement']].' ('.$_REQUEST['departement'].')</h1>' : NULL; // Le département
// Affichage de la date en fr du datepicker
$h1 .= !empty($du) ? " le <strong>" .date('d/m/Y', strtotime($du))."</strong>" : NULL; // La date choisis selon les filtres
echo '<div class="col-md-12 result-search"><div class="col-md-5 pad-15"> '.$h1.'</div>'?>
<form method="POST">
<div class="col-md-3 col-sm-12 max">
<div class="input-group">
<input class="search-motor form-control" title="Recherche de sortie par date "id="datetimepicker2" name="datetimepicker" placeholder="Recherche par date" type="text" readonly value="<?php echo !empty($_REQUEST['datetimepicker']) ? $_REQUEST['datetimepicker'] : NULL; ?>">
<span class="input-group-addon custom">
<button class="btn btn-default search-btn" type="submit"><i class="fa fa-calendar-o"></i></button>
</span>
</div>
</div>
</form>
<div class="col-md-4 col-sm-12 max">
<form id="choice" method="POST" action="">
<div class="input-group">
<input title="Recherche par ville" placeholder="Recherche par ville" class="search-motor form-control" value="<?php echo !empty($_REQUEST['ville']) ? $_REQUEST['ville'] : NULL;?>" name="ville" id="ville" type="search">
<span class="input-group-btn">
<button name="submit_city" id="submit_city" type="submit" class="btn btn-default search-btn">GO !</button>
</span>
</div>
</form>
</div>
</div>
<article class="col-main">
<?php include("include/optimisation.php"); ?>
<?php echo '<div class="category-products">
<ol class="products-list" id="products-list">'."\n";
}
// Si il n y a que la région de demandée
if (!empty($_REQUEST['region']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
$valeur_paginate = 'region-'.$_REQUEST['region'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['loisir']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['departement'])) {
$valeur_paginate = 'activite-'.$_REQUEST['loisir'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville'])) {
$valeur_paginate = 'sorties-du-'.$_REQUEST['departement'];
}
// Si il y a une région de demandée et un loisir
else if (!empty($_REQUEST['region']) && !empty($_REQUEST['ville'])) {
$valeur_paginate = 'ville-de-'.simplification($_REQUEST['ville']);
}
?>
<?php
$nbre_annonces_par_page = 15;
$nbre_pages_max_gauche_et_droite = 4;
$last_page = ceil($nb / $nbre_annonces_par_page);
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page_num = $_GET['page'];
} else {
$page_num = 1;
}
if($page_num < 1){
$page_num = 1;
} else if($page_num > $last_page) {
$page_num = $last_page;
}
$limit = 'LIMIT '.($page_num - 1) * $nbre_annonces_par_page. ',' . $nbre_annonces_par_page;
$pagination = '';
if($last_page != 1){
if($page_num > 1){
$previous = $page_num - 1;
$pagination .= '<a href="'.$valeur_paginate.($previous > 1 ? '-page-'.$previous : null).'.html" class="page" data-page="'.$previous.'" data-du="'.$du.'" data-au="'.$au.'"><i class="fa fa-angle-left"></i></a> ';
for($i = $page_num - $nbre_pages_max_gauche_et_droite; $i < $page_num; $i++){
if($i > 0){
$pagination .= '<a href="'.$valeur_paginate.($i > 1 ? '-page-'.$i : null).'.html" class="page" data-page="'.$i.'" data-du="'.$du.'" data-au="'.$au.'">'.$i.'</a> ';
}
}
}
$pagination .= '<span class="active">'.$page_num.'</span> ';
for($i = $page_num+1; $i <= $last_page; $i++){
$pagination .= '<a href="'.$valeur_paginate.'-page-'.$i.'.html" class="page" data-page="'.$i.'" data-du="'.$du.'" data-au="'.$au.'">'.$i.'</a> ';
if($i >= $page_num + $nbre_pages_max_gauche_et_droite){
break;
}
}
if($page_num != $last_page){
$next = $page_num + 1;
$pagination .= '<a href="'.$valeur_paginate.'-page-'.$next.'.html" class="page" data-page="'.$next.'" data-du="'.$du.'" data-au="'.$au.'"><i class="fa fa-angle-right"></i></a> ';
}
}
// Ordre d'affichage
if (!empty($_REQUEST['ville'])) {
$sql .= " ORDER BY CASE
WHEN heart = 1 THEN 3
WHEN id_simply_user != 999 THEN 2
WHEN id_simply_user = 999 THEN 1
END DESC
LIMIT ".intval(($page-1)*$parPage).", ".$parPage;
// Si il n y a pas de ville de renseignée
}else{
$sql .= "ORDER BY loisirs.id_loisirs DESC LIMIT ".intval(($page-1)*$parPage).", ".$parPage ;;
}
$req = $bdd->query($sql);
$nb2 = $req->rowCount();
if($nb2 > 0) {
$req = $bdd->query($sql);
while($ligne = $req->fetch(PDO::FETCH_ASSOC)){
$date = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_debut_sortie']);
$image = !empty($ligne['photo']) && file_exists('img/img-big-format/miniature/'.$ligne['photo']) ? 'img/img-big-format/miniature/'.$ligne['photo'] : 'img/remplacement/'.simplification($aLoisirs[$ligne['id_type_loisirs']]).'.jpg';
// Si l'annonce est en cours
$encours = ($ligne['date_debut_sortie'] != $ligne['date_fin_sortie']) ? 'Depuis le' : 'One shot';
$encours = (strtotime($ligne['date_debut_sortie']) > time()) ? '' : $encours;
$lien = "".$ligne["url_rewrite"]."/".$ligne["id_loisirs"];
$dated = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_debut_sortie']);
$datef = DateTime::createFromFormat('Y-m-d H:i:s', $ligne['date_fin_sortie']);
$la_variable_qui_vas_bien = "";
if($ligne['date_debut_sortie'] != "0000-00-00 00:00:00") {
$la_variable_qui_vas_bien = $ligne['date_debut_sortie'] = ucfirst($jour[$dated->format('N')]).' '.$dated->format('d').' '.ucfirst($mois[$dated->format('n')]).' '.$dated->format('Y');
} else {
$la_variable_qui_vas_bien = "Jusqu'au " .ucfirst($jour[$datef->format('N')]).' '.$datef->format('d').' '.ucfirst($mois[$datef->format('n')]).' '.$datef->format('Y');
}
$ligne['description'] = str_replace($mots, $remplacements, $ligne['description']);
$recherche_pour_url = $ligne['titre'];
$remplacement_url = str_replace ( ' ', '-', $recherche_pour_url);
$salle = !empty($ligne['manufacturer']) ? $ligne['manufacturer'] : NULL;
if (!empty ($ligne['url_fnac'])) {
echo ' <li class="item first">
<div class="product-image"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html"><img class="img-responsive" src="'.$ligne['photo'].'" alt="'.$ligne['titre'].'" title="'.$aLoisirs[$ligne['id_type_loisirs']].', '.$ligne['titre'].'"></a></div>
<div class="product-shop">
<h3 class="product-name"><a href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification($ligne["city"])."/".$ligne["id_loisirs"].'.html" title="'.ucfirst(strtolower($ligne['titre'])).'">'.ucfirst($ligne['titre']).'</a></h3>
<div class="ratings"><i class="fa fa-calendar-o" aria-hidden="true"></i> '.$encours.' '.$la_variable_qui_vas_bien.'</div>
<div class="desc std">
<p>'. stripslashes(cutTexte($ligne['description'], 500, '...')).'<a class="link-learn" title="" href="/'.$lien.'"></a> </p>
</div>
<p class="hash"><i class="fa fa-map-marker"></i><span class="sortir_city"> '.$salle.' - <span class="sortir_city"> <a href="http://lasortie.fr/sortie/region-'.simplification($aRegion[$region_id]).'/ville-de-'.simplification($ligne['city']).'.html"> <strong>'.ucfirst(mb_strtolower($ligne['city'], 'UTF-8')).'</strong></a></span> ('.str_pad($ligne['id_departements'], 2, "0", STR_PAD_LEFT).')</span></p>
<div class="actions">
<a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification($ligne["genre_loisir"])."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html"><button class="button btn-cart ajx-cart" title="'.ucfirst(strtolower($ligne['titre'])).' à '.ucfirst(strtolower($ligne['city'])).'" type="button"><span>En détails</span></button></a>
<span class="add-to-links"> <a rel="nofollow" title="Add to Wishlist" class="button link-wishlist" href="/add_favoris.php?idfav='.$ligne['id_loisirs'].'"><span>Ajouter aux favoris</span></a></span> </div>
</div></li>'."\n";
}else{
echo' <li class="item first">
<div class="product-image"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification($ligne["city"])."/".$ligne["id_loisirs"].'.html"><img class="img-responsive" src="/'.$image.'" alt="'.$ligne['titre'].'" title="'.$aLoisirs[$ligne['id_type_loisirs']].', '.$ligne['titre'].'"></a></div>
<div class="product-shop">
<h3 class="product-name"><a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" title="'.ucfirst(strtolower($ligne['titre'])).'">'.ucfirst($ligne['titre']).'</a></h3>
<div class="ratings"><i class="fa fa-calendar-o" aria-hidden="true"></i> '.$encours.' '.$la_variable_qui_vas_bien.'</div>
<div class="desc std">
<p>'. stripslashes(cutTexte($ligne['description'], 500, '...')).'<a class="link-learn" title="" href="/'.$lien.'"></a> </p>
</div>
<p class="hash"><i class="fa fa-map-marker"></i><span class="sortir_city"><strong> <a href="http://lasortie.fr/sortie/region-'.simplification($aRegion[$region_id]).'/ville-de-'.simplification($ligne['city']).'.html"> Sortie '.ucfirst(mb_strtolower($ligne['city'], 'UTF-8')).' </a></strong> ('.str_pad($ligne['id_departements'], 2, "0", STR_PAD_LEFT).')</span></p>
<div class="actions">
<a href="http://lasortie.fr/sortie/'.$ligne["url_rewrite"]."/".simplification(strtolower($aLoisirs[$ligne["id_type_loisirs"]]))."/".simplification(mb_strtolower($ligne['city'], 'UTF-8'))."/".$ligne["id_loisirs"].'.html"><button class="button btn-cart ajx-cart" title="'.ucfirst(strtolower($ligne['titre'])).' à '.ucfirst(strtolower($ligne['city'])).'" type="button"><span>En détails</span></button></a>
<span class="add-to-links"> <a rel="nofollow" title="Add to Wishlist" class="button link-wishlist" href="/add_favoris.php?idfav='.$ligne['id_loisirs'].'"><span>Ajouter aux favoris</span></a></span> </div>
</div></li>'."\n";
}
}
echo '</ol><div class="pagination col-md-12">
<div class="row">
'.$pagination.'
</div>
</div>
';
$req->closeCursor();
} else {
echo '<div class="pad15"><div class="alert alert-danger" role="alert"> <i class="fa fa-frown-o"></i>
Actuellement aucune sortie ne correspond à votre recherche</div></div>';
}
?>
</div>
</article>
</div>
<div class="col-left sidebar col-sm-3 col-xs-12 col-sm-pull-9">
<div class="side-nav-categories">
<div class="block-title"> Categories <div class="fb-share-button pull-right" data-href="<?php echo $page_name;?>" data-layout="button_count"></div>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/sdk.js#xfbml=1&version=v2.5";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script></div>
<div class="dropdown-marg">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
<?php
if (empty($_REQUEST['ville'])) {
if (!empty($_REQUEST['departement'])){
echo 'Département '. $depts[$_REQUEST['departement']].'-'.$_REQUEST['departement'];
}else{
echo'Choisir un département';
}
echo'
<span class="caret"></span></button>
<ul class="dropdown-menu">';
foreach($aDepartement[regionByUrl($_REQUEST['region'])] as $id => $dep){
// on affiche les sorties selon le département et le loisir demandée
if (!empty($_REQUEST['region']) && empty($_GET['page']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && empty($_GET['page']) && !empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && !empty($_GET['page']) && empty($_REQUEST['departement']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="region-'.$_REQUEST['region'].'/sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a une page de renseignée
else if (!empty($_REQUEST['region']) && !empty($_GET['page']) && empty($_REQUEST['departement']) && !empty($_REQUEST['loisir'])) {
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])){
echo '<li><a href="region-'.$_REQUEST['region'].'/sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>';
}
else{
// Si il n y a pas de region de renseignée
echo '<li><a href="sorties-du-'.$id.'.html">'.$id.' '.$dep.'</a></li>'."\n";
}
}
}else{
echo '<h2>Activités '.ucfirst(strtolower($_REQUEST['ville'])).'</h2>';
}
?>
</ul></div>
<div class="box-content box-category">
<ul>
<?php
// Si il n y a pas de ville de renseignée
if (empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && !empty($_REQUEST['region'])) {
$liste = $bdd->query("SELECT id_type_loisirs,COUNT(*) as nb FROM loisirs WHERE id_region = ".$region_id." AND `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1 GROUP BY id_type_loisirs " );
while($row = $liste->fetch(PDO::FETCH_ASSOC)) {
$count[$row['id_type_loisirs']] = $row['nb'];
}
asort($aLoisirs);
foreach($aLoisirs as $k => $v) {;
$nb = array_key_exists($k, $count) ? $count[$k] : 0;
if ($nb>=1) {
// Si il y a un loisir de renseignée et aucune page demandée
if (!empty($_REQUEST['loisir']) && empty($_GET['page']) && empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a une page de renseignée
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region']) ) {
echo '<li><a href="ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a une page de renseignée
else if(!empty($_GET['page']) && !empty($_REQUEST['loisir'])){
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])){
echo '<li><a href="region-'.$_REQUEST['region'].'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="../../region-'.$_REQUEST['region'].'/activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(!empty($_GET['page']) && empty($_REQUEST['loisir']) && !empty($_REQUEST['region']) && !empty($_REQUEST['departement'])){
echo '<li><a href="activite-'.simplification($v).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
else{
// Si il n y a pas de region de renseignée
echo '<li><a href="region-'.$_REQUEST['region'].'/activite-'.simplification($v).'.html">'.$v.'</a><span class="subDropdown plus">'.$nb.'</span></li>'."\n";
}
}
}
}
elseif (empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region'])) {
$liste = "SELECT id_type_loisirs, COUNT(id_type_loisirs) as nb FROM loisirs";
$liste.= " WHERE id_departements = '".$_REQUEST['departement']."' AND date_fin_sortie > NOW() AND valide = 1 ";
$liste.= " GROUP BY id_type_loisirs HAVING COUNT(id_type_loisirs) >= 1 ORDER BY nb DESC LIMIT 0,30";
$req = $bdd->query($liste);
while($row = $req->fetch(PDO::FETCH_ASSOC)){
if (empty($_REQUEST['ville']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['loisir'])) {
echo '<li><a href="../region-'.$_REQUEST['region'].'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
elseif (!empty($_REQUEST['loisir']) && !empty($_REQUEST['departement']) && !empty($_REQUEST['region']) && empty($_REQUEST['ville'])) {
echo '<li><a href="../activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'/sorties-du-'.$_REQUEST['departement'].'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
}
}
else {
$_REQUEST['ville'] = str_replace('-', ' ', $_REQUEST['ville']); // on remplace les espaces par des tirets
$liste = "SELECT id_type_loisirs, COUNT(id_type_loisirs) as nb FROM loisirs";
$liste.= " WHERE city = '".$_REQUEST['ville']."' AND date_fin_sortie > NOW() AND valide = 1 ";
$liste.= " GROUP BY id_type_loisirs HAVING COUNT(id_type_loisirs) >= 1 ORDER BY nb DESC LIMIT 0,30";
$req = $bdd->query($liste);
while($row = $req->fetch(PDO::FETCH_ASSOC)){
// Si il y a un loisir de renseignée et aucune page demandée
if (empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="ville-de-'.simplification($_REQUEST['ville']).'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
else if (!empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
else if (empty($_REQUEST['loisir']) && !empty($_GET['page']) && !empty($_GET['ville']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement'])) {
echo '<li><a href="ville-de-'.$_REQUEST['ville'].'/activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
// Si il y a un département de renseignée et aucune page
else if(!empty($_GET['page']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) && !empty($_REQUEST['region'])){
echo '<li><a href="activite-'.simplification($aLoisirs[$row['id_type_loisirs']]).'.html">'.$aLoisirs[$row['id_type_loisirs']].'</a><span class="subDropdown plus">'.$row['nb'].'</span></li>'."\n";
}
}
}
?>
</ul>
</div>
</div>
<?php
$h2 = empty($_REQUEST['ville']) && empty($_REQUEST['departement']) && empty($aRegion[$region_id]) ?' <strong> activités</strong>' : NULL; // Le département
$h2 .= !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville']) ? " <strong> activités</strong> EN ".$aRegion[$region_id] : NULL; // Sortir en "nom de la région"
$h2 .= !empty($_REQUEST['departement']) && empty($_REQUEST['loisir']) ? ' SORTIES '.$depts[$_REQUEST['departement']] : NULL; // Le département
$h2 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) && empty($_REQUEST['ville']) ? '<a title="Sortie '.ucfirst($_REQUEST['loisir']).' en '.$depts[$_REQUEST['departement']].'" href="toutes-les-sorties-du-departement-'.$_REQUEST['departement'].'-'.$_REQUEST['loisir'].'.html"><strong>'.ucfirst($_REQUEST['loisir']).' <span class="normal-weight">' .$depts[$_REQUEST['departement']].'</span></strong></a>' : NULL; // Le département
$h2 .= !empty($_REQUEST['ville']) && !empty($aRegion[$region_id]) && empty($_REQUEST['loisir']) ?' <strong>SORTIES '.ucfirst ($_REQUEST['ville']).'</strong>' : NULL; // ville
$h2 .= !empty($_REQUEST['departement']) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($aLoisirs[$_REQUEST['loisir']]).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= empty($_REQUEST['departement']) && !empty($aRegion[$region_id]) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($_REQUEST['loisir']).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= empty($_REQUEST['departement']) && empty($aRegion[$region_id]) && !empty($_REQUEST['loisir']) && !empty($_REQUEST['ville']) ? ucfirst($aLoisirs[$_REQUEST['loisir']]).' à ' .ucfirst ($_REQUEST['ville']) : NULL; // ville
$h2 .= !empty($_REQUEST['ville']) && empty($_REQUEST['loisir']) && empty($_REQUEST['departement']) && empty($aRegion[$region_id]) ?' <strong>IDÉES DE SORTIES '.ucfirst ($_REQUEST['ville']) .'</strong>': NULL; // Le département
echo '
<div class="block block-compare">
<div class="block-title "><h2>'.$h2.'</h2></div>
<div class="block-content">
<ul>
<ol id="compare-items">';?>
<?php
$pub = "SELECT * FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region` WHERE `loisirs`.`date_fin_sortie` > NOW() AND `loisirs`.`valide` = 1";
$pub .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL; // region
$pub .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL; // dep
$pub .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`genre_loisir` = "'.$_REQUEST['loisir'].'"' : NULL; // loisir
$pub .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$pub .= " ORDER BY RAND () DESC LIMIT 0, 10";
$req = $bdd->query($pub);
if($req->rowCount() > 0) {
while($ligne = $req->fetch(PDO::FETCH_ASSOC)){
if (!empty ($ligne['url_fnac'])) {
echo '<li class="item odd"><a rel="nofollow" href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" class="product-name">'. ucfirst(cutTexte($ligne['titre'], 40, '...')).'</a><div class="adjust-titre"></div></li>';
}else{
echo '<li class="item odd"><a rel="nofollow" href="'.$ligne["url_rewrite"]."/".$ligne["genre_loisir"]."/".simplification(strtolower($ligne["city"]))."/".$ligne["id_loisirs"].'.html" class="product-name"> '. ucfirst(cutTexte($ligne['titre'], 40, '...')).'</a><div class="adjust-titre"> </div></li>';
}
}
}
?>
</ol>
</ul>
</div></div>
<div class="block block-tags">
<div class="block-title"> VILLES ACTIVES <?php if (!empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) { echo $aRegion[$region_id]; }?>
</div>
<div class="block-content">
<ul>
<?php
$actu_ville = "SELECT DISTINCT city, count(*) as nb_annonces FROM `loisirs` JOIN `regions` ON `regions`.`region_id` = `loisirs`.`id_region`";
$actu_ville .= !empty($_REQUEST['region']) ? ' AND `regions`.`url` = "'.$_REQUEST['region'].'"' : NULL;
$actu_ville .= !empty($_REQUEST['departement']) ? ' AND `loisirs`.`id_departements` = '.$_REQUEST['departement'] : NULL;
$actu_ville .= !empty($_REQUEST['loisir']) ? ' AND `loisirs`.`id_type_loisirs` = "'.$_REQUEST['loisir'].'"' : NULL;
$actu_ville .= !empty($_REQUEST['ville']) ? ' AND `loisirs`.`city` = "'.getRealValue($_REQUEST['ville']).'"' : NULL;
$actu_ville .= " GROUP BY city HAVING nb_annonces >10 ORDER BY nb_annonces DESC LIMIT 0,15";
$req = $bdd->query($actu_ville);
$nb_annonces = $req->rowCount();
if($req->rowCount() > 0) {
while($recent_actu = $req->fetch(PDO::FETCH_ASSOC)){
if (empty($_REQUEST['loisir']) && empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
echo '<li><a class="follow_actu_sortie" href="region-'.$_REQUEST['region'].'/ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
elseif (empty($_REQUEST['loisir']) && !empty($_GET['page']) && !empty($_REQUEST['region']) && empty($_REQUEST['departement']) && empty($_REQUEST['ville'])) {
echo '<li><a class="follow_actu_sortie" href="region-'.$_REQUEST['region'].'/ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
else {
echo '<li><a class="follow_actu_sortie" href="ville-de-'.simplification($recent_actu['city']).'.html">Sortir à '.ucfirst(mb_strtolower($recent_actu['city'], 'UTF-8')).'</a></li>';
}
}
}else{ echo 'Aucune annonce enregistrée '; }
?>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>
<?php include("include/footer-inner.php"); ?>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link href='https://fonts.googleapis.com/css?family=Raleway:600,500,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/style.css" media="all">
<link rel="stylesheet" href="/css/jquery.datetimepicker.css">
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script async type="text/javascript" src="/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/jquery.datetimepicker-min.js"></script>
<script async type="text/javascript" src="/js/moment.js"></script>
<script async type="text/javascript">
jQuery('#datetimepicker2').datetimepicker({
datepicker:true,
timepicker:false,
closeOnDateSelect:true,
format:'d/m/Y'
});
</script>
</body>
</html>[/php]