1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
| <?php
///////////////////////////////////////////////////////////////////////////////////////////
///Script PHP/MYSQL de gestion de petites annonces développé par Script PAG
///Script PAG tout droits réservé. Utilisation sous licence. http://www.script-pag.com
///////////////////////////////////////////////////////////////////////////////////////////
############################################################
require_once('includes/all_functions.php');
///////////////////////////////////
//Detruire la session
//////////////////////////////////
foreach($_SESSION as $k => $v)
{
if($k != 'connect' && $k != 'email_con' && $k != 'prenom' && $k != 'offset_une_type' && $k != 'valid_admin' && $k != 'disc' && $k != 'nb_ann_selection')
unset($_SESSION[$k]);
}
///////////////////////////////////
//Validation du Type de la recherche
//////////////////////////////////
if (isset($_GET['type']))
{
$type = (int) $_GET['type'];
if ($type !=1 && $type != 2 && $type != 3 && $type != 4)
$type = 1;
if($type == 1) $_SESSION['offres'] = 1;
if($type == 2) $_SESSION['recherches'] = 1;
if($type == 3) $_SESSION['echanges'] = 1;
if($type == 4) $_SESSION['dons'] = 1;
}
else $type = 1;
///////////////////////////////////
//Validation du choix particulier ou professionnel
//////////////////////////////////
if (isset($_GET['f']))
{
$f = (int) $_GET['f'];
if ($f != 1 && $f != 2)
$f = 0;
}
else $f = 0;
///////////////////////////////////
//Validation du tri par date ou par prix
//////////////////////////////////
if (isset($_GET['tri']))
{
$tri = (int) $_GET['tri'];
if ($tri != 1 && $tri != 2)
$tri = 1;
}
else $tri = 1;
///////////////////////////////////
//Validation de la page
//////////////////////////////////
if (isset($_GET['page']))
{
$page_num = (int) $_GET['page'];
if ($page_num <= 0)
$page_num = 1;
}
else $page_num = 1;
///////////////////////////////////
//Connexion à la base de données
//////////////////////////////////
$conn = db_connect();
///////////////////////////////////
//Obtenir le nombre d'annonce à la une, pro et particulier
//////////////////////////////////
$nb_ann = get_nb_annonce_type($type, $tri);
$nb_ann['par'] = $nb_ann[0]['count_par'];
$nb_ann['pro'] = $nb_ann[0]['count_pro'];
$total = $nb_ann[0]['count_par'] + $nb_ann[0]['count_pro'];
///////////////////////////////////
//Obtenir le nombre de résultats par page
//////////////////////////////////
$limit = (int) $param_gen['nb_ann'];
if ($f == 1)
$max_page = ceil($nb_ann['par']/$limit);
elseif ($f == 2)
$max_page = ceil($nb_ann['pro']/$limit);
else $max_page = ceil($total/$limit);
if ($max_page > 0 && $page_num > $max_page)
$page_num = $max_page;
$offset = ($page_num - 1) * $limit;
///////////////////////////////////
//Obtenir les annonces
//////////////////////////////////
$annonces_array = get_annonces_type($type, $f, $offset, $limit, $tri, 0);
///////////////////////////////////
//Obtenir les annonces à la une
//////////////////////////////////
if($param_gen['active_une'] == 1)
{
if(isset($_SESSION['offset_une_type']) && $_SESSION['offset_une_type'] + 5 >= $nb_ann[0]['count_une'])
$_SESSION['offset_une_type'] = 0;
elseif(isset($_SESSION['offset_une_type']))
$_SESSION['offset_une_type'] = $_SESSION['offset_une_type'] + 5;
else $_SESSION['offset_une_type'] = 0;
$search_array_une = get_annonces_type($type, $f, $_SESSION['offset_une_type'], 5, $tri, 1);
}
///////////////////////////////////
//Fermeture de la connexion à la base de données
//////////////////////////////////
$conn = null;
///////////////////////////////////
//Titre, description , mots clés et info de la page
//////////////////////////////////
if ($type == 1)
{
$title = $language['titre_page_offre'];
$description = $language['description_page_offre'];
$words = $language['mot_cles_page_offre'];
$info_page = $language['infos_page_offre'];
}
if ($type == 2)
{
$title = $language['titre_page_recherche'];
$description = $language['description_page_recherche'];
$words = $language['mot_cles_page_recherche'];
$info_page = $language['infos_page_recherche'];
}
if ($type == 3)
{
$title = $language['titre_page_echange'];
$description = $language['description_page_echange'];
$words = $language['mot_cles_page_echange'];
$info_page = $language['infos_page_echange'];
}
if ($type == 4)
{
$title = $language['titre_page_don'];
$description = $language['description_page_don'];
$words = $language['mot_cles_page_don'];
$info_page = $language['infos_page_don'];
}
///////////////////////////////////
//Inclusion des fonctions html
//////////////////////////////////
htm_header($title, $description, $words);
if($param_gen['active_une'] == 1) htm_top_ads($search_array_une);
display_type_infos($type, $f, $limit, $page_num, $info_page, $nb_ann);
if($total != 0)
{
if($f == 0)
{
display_type_links($type, $f, $max_page, $page_num, $limit, 1, $tri);
display_all($annonces_array);
display_type_links($type, $f, $max_page, $page_num, $limit, 2, $tri);
right_pub('', '', '', '', '');
}
elseif($f == 1 && $nb_ann['par'] != 0)
{
display_type_links($type, $f, $max_page, $page_num, $limit, 1, $tri);
display_all($annonces_array);
display_type_links($type, $f, $max_page, $page_num, $limit, 2, $tri);
right_pub('', '', '', '', '');
}
elseif($f == 2 && $nb_ann['pro']!= 0)
{
display_type_links($type, $f, $max_page, $page_num, $limit, 1, $tri);
display_all($annonces_array);
display_type_links($type, $f, $max_page, $page_num, $limit, 2, $tri);
right_pub('', '', '', '', '');
}
else
{
display_text_no($language['not_ann']);
right_pub('', '', '', '', '');
}
}
else
{
display_text_no($language['not_ann']);
right_pub('', '', '', '', '');
}
htm_categories();
htm_footer(); |
Partager