|
|
include"confcms2.php";
$db = mysql_connect("$dbchemin","$dbuser","$dbpass") or mysql_die("Connexion impossible");
$err = mysql_error();
if ($err) {
echo "Uh oh! There's an error! news Here it is: ";
echo "$err";
}
mysql_select_db("$dbname");
$err = mysql_error();
if ($err) {
echo "Uh oh! There's an error! basenews Here it is: ";
echo "$err";
}
$selecto1="";
$FRechercheori="";
if (isset($_GET['action']))
{
$action =$_GET['action'];}
else{
$action ="";
}
if (isset($_GET['FRecherche']))
{
$FRecherche =$_GET['FRecherche'];}
else{
$FRecherche ="";
}
if (isset($_GET['page']))
{
$page =$_GET['page'];}
else{
$page ="";
}
if (isset($_GET['Selecti']))
{
$Selecti =$_GET['Selecti'];}
else{
$Selecti ="";
}
if (isset($_GET['operateur']))
{
$operateur =$_GET['operateur'];}
else{
$operateur ="";
}
if (isset($_GET['Selecto']))
{
$Selecto =$_GET['Selecto'];}
else{
$Selecto ="";
}
//$bla2 = $_REQUEST["operateur"];
//echo $_REQUEST["ppp page"];
$comon = 'Recherche Contexte';
$comon .='';
//if (!isset($debut)) $debut = 0;
if (!empty($FRecherche))
{
$FRechercheori ="$FRecherche";
$FRecherche=strtolower($FRecherche); // on passe les mots recherchés en minuscules
$mots = str_replace("+", " ", trim($FRecherche)); // on remplace les + par des espaces
$mots = str_replace("\"", " ", $mots); // on remplace les " par des espaces
$mots = str_replace(",", " ", $mots); // on remplace les , par des espaces
$mots = str_replace(":", " ", $mots); // on remplace les : par des espaces
$tab=explode(" " , $mots); // on place les differents mots dans un tableau
$nbref=count($tab); // on compte le nbr d'élément du tableau.
$FRecherche=rawurlencode($FRecherche);
//echo "$nbref ";
}
$authors = mysql_query("SELECT id, Name FROM authors");
$cats = mysql_query("SELECT id, Name FROM categories");
$ans = mysql_query("SELECT id, Name FROM an");
$ans1 = mysql_query("SELECT id, Name FROM an");
$ans2 = mysql_query("SELECT id, Name FROM an");
$moi = mysql_query("SELECT id, Name FROM mois");
$mooi1 = mysql_query("SELECT id, Name FROM mois");
$mooi2 = mysql_query("SELECT id, Name FROM mois");
$mooi3 = mysql_query("SELECT id, Name FROM mois");
$mooi4 = mysql_query("SELECT id, Name FROM mois");
$mot = mysql_query("SELECT id, Name FROM motcle3");
$requete="select max(ID) from artbrnew";
$result1 = mysql_query($requete);
if ($result1){
//echo "$result1";
$idmax=mysql_result($result1,0,"max(ID)");
//echo " Maxi $idmax";
$idnew="$idmax" -10;
}
if($action != "recherche")
{
$action="recherche";
$arr=date("Y-m");
$year1=substr($arr,0,4);
$year2=substr($arr,2,4);
$month1=substr($arr,5,6);
$poi="voit22.php?id=";
$arr11=date("m");
//$arr11=$month1;
$arr12=$arr11-1;
$arr13=$arr11-2;
$arr14=$arr11-3;
$arr15=$arr11-4;
$arr20=$arr11+1;
//$year1=substr($arr,0,4);
/*
$today=getdate(time());
- $jour_today = $today["mday"];
- $mois_today = $today["mon"];
- $annee_today = $today["year"];
*/
$today = getdate();
$day = $today["mday"];
if ($day < 10) {
$day = "0$day";
}
$month = $today["mon"];
if ($month < 10) {
$month = "0$month";
}
$year = $today["year"];
$hour = $today["hours"];
$min = $today["minutes"];
$sec = "00";
$SQL = "SELECT id FROM an where trim(Name)='$year1'";
$result = mysql_query($SQL);
$nb_news = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$id = trim($row["id"]);
$anid = "$id";
//echo "$id $anid";
$moid = "$arr11";
}
if($action == "recherche")
{
$arr=date("Y-m");
$year1=substr($arr,0,4);
$arr11=date("m");
//$arr11=$month1;
$arr12=$arr11-1;
$arr13=$arr11-2;
$arr14=$arr11-3;
$arr15=$arr11-4;
$SQL = "SELECT id FROM an where trim(Name)='$year1'";
$result = mysql_query($SQL);
$nb_news = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$id = trim($row["id"]);
$Nb_msg_page = "5";
/*
if ($IDRecherche != "") {
$Nb_msg_page = "100";
}
*/
// Traitement de la chaine
if ($FRecherche != "") {
$FRecherche = trim($FRecherche);
}
/*
if ($TRecherche != "") {
$TRecherche = trim($TRecherche);
}
if ($ARecherche != "") {
$ARecherche = trim($ARecherche);
}
*/
$affi_page = "$Nb_msg_page";
// Gestionnaire de pages
if ($page == "" or $page == "1")
{
$page = "1";
$debut = "0";
}
else
{
$debut = ($page - 1) * $affi_page;
}
// The basic SELECT statement
$select = "SELECT * ";
$from = " FROM artbrnew";
/*
if ($IDRecherche != " ") {
$where = " WHERE ID > '$IDRecherche'";
//echo "where $where";
}else{
*/
$where = " WHERE ID > 0";
//echo "where $where";
// }
/*
if ($moid3 < 10) {
$moid3 = "0$moid3";
}
if ($moid4 < 10) {
$moid4 = "0$moid4";
}
*/
if ($FRecherche != "") { // Some search text was specified
//if ($searchtext != "") { // Some search text was specified
//$where .= " AND texte_long LIKE '%$FRecherche%' ";
$where .= " AND texte_long like '%$tab[0]%' ";
//echo "nb $nb_t";
for($i=1 ; $i<$nbref; $i++)
{
$where .="$operateur texte_long like \"%$tab[$i]%\" ";
// on boucle pour integrer tous les mots dans la requête
}
}
$mysql_result = mysql_query($select . $from . $where);
// Nb total d'articles trouvés
$nb_t = mysql_num_rows($mysql_result);
//echo "Nombre de resultats : $nb_t ";
if ($nb_t < 1) {
$anid = "$id";
$moid = "$arr12";
if ($arr11 == 1) {
$arr11 = 12;
$year1=$year1-1;
$anid = $id-1;
$moid = "$arr11";
}
// echo "Erreur ";
//echo "document.write(\"\"\n";
}else{
//echo '
if($action == "recherche")
{
if($page != 1)
{
$n_page = $page - 1;
echo(" page précédente ");
}
if($test < $nb_t)
{
$n_page = $page + 1;
echo( " page suivante ");
} }
echo'
|
|