|
|
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";
}
if (isset($_GET['page']))
{
$page =$_GET['page'];}
else{
$page ="";
}
if (isset($_GET['Selecti']))
{
$Selecti =$_GET['Selecti'];}
else{
$Selecti ="";
}
if (isset($_GET['Selecto']))
{
$Selecto =$_GET['Selecto'];}
else{
$Selecto ="";
}
if (isset($_GET['selecto1']))
{
$selecto1 =$_GET['selecto1'];}
else{
$selecto1 ="";
}
if (isset($_GET['action']))
{
$action =$_GET['action'];}
else{
$action ="";
}
if (isset($_GET['operateur']))
{
$operateur =$_GET['operateur'];}
else{
$operateur ="AND";
}
if (isset($_GET['FRecherche']))
{
$FRecherche =$_GET['FRecherche'];
} else{
$FRecherche ="";
}
if (isset($_GET['FRechercheori']))
{
$FRechercheori =$_GET['FRechercheori'];
} else{
$FRechercheori ="";
}
//$moid3=$_GET['moid3'];
$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 feed";
$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();
$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
$FRecherche = trim($FRecherche);
/*
$TRecherche = trim($TRecherche);
$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 feed";
/*
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]%' ";
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 "Résultats : ";
//echo "$FRecherche";
}
$test = $page * $affi_page;
if ($test > $nb_t)
{
$page_c = $page - 1;
$affi_page = $nb_t - ($affi_page * $page_c);
/*
if ($affi_page < 0) {
$affi_page =$affi_page * -1; }
echo "$nb_t $affi_page $page_c $affi_page * $page_c";
*/
}
$select = "SELECT * ";
$from = " FROM feed";
/*
if ($IDRecherche != " ") {
$where = " WHERE ID > '$IDRecherche'";
}else{
*/
$where = " WHERE ID > 0";
//}
//$where = " WHERE ID > 0";
if ($FRecherche != "") { // Some search text was specified
$where .= " AND texte_long like '%$tab[0]%' ";
for($i=1 ; $i<$nbref; $i++)
{
$where .="$operateur texte_long like \"%$tab[$i]%\" ";
// on boucle pour integrer tous les mots dans la requête
}
$Selecti .= "&FRecherche=$FRechercheori";
}
$where .= " ORDER BY date DESC LIMIT $debut,$affi_page ";
//echo( " $nb_t article(s) trouvé(s).");
$selecto1= str_replace(" ", "+", trim($FRecherche)); // on remplace les + par des espaces ;
$Selecto="FRecherche=$selecto1&operateur=AND&submit=Search";
//if (!empty($jokes))
$jokes = mysql_query($select . $from . $where);
if (!$jokes) {
echo("Error retrieving jokes from database! ".
"Error: " . mysql_error());
exit();
}
while ($joke = mysql_fetch_array($jokes)) {
echo(" \n");
$id = $joke["ID"];
$tite = $joke["tit"];
$titre = $joke["titre"];
$joketext1 = $joke["petit"];
$joketext = $joke["texte_long"];
$text2= $joke["texte_court"];
$idte = $joke["ID"];
$dte = $joke["date"];
$year1=substr($dte,0,4);
$mois1=substr($dte,5,2);
$jour1=substr($dte,8,2);
$jokedt = "$jour1-$mois1-$year1";
// Bold and italics
$joketext = eregi_replace("\[b]","",$joketext);
$joketext = eregi_replace("\[eb]","",$joketext);
$joketext = eregi_replace("\[i]","",$joketext);
$joketext = eregi_replace("\[ei]","",$joketext);
// Paragraphs and line breaks
$joketext = ereg_replace("\r","",$joketext);
$joketext = ereg_replace("\n\n","",$joketext);
$joketext = ereg_replace("\n","",$joketext);
$joketext = ereg_replace(" ","",$joketext);
$joketext = ereg_replace(" ","",$joketext);
$joketext = ereg_replace(" ","",$joketext);
$joketext = ereg_replace("","",$joketext);
$joketext = ereg_replace("","",$joketext);
$joketext = ereg_replace(" ","",$joketext);
$joketext = ereg_replace("","",$joketext);
$joketext = ereg_replace(" ","",$joketext);
$joketext = ereg_replace("class=lien","",$joketext);
$joketext = ereg_replace("hspace='2'>","hspace='2'/>",$joketext);
$joketext = ereg_replace("","",$joketext);
$joketext = ereg_replace("&","&",$joketext);
// Hyperlinks
$joketext = ereg_replace(
"\[L]([-_./a-zA-Z0-9!&%#?,'=:~]+)\[EL]",
"\\1", $joketext);
$joketext = ereg_replace(
"\[L=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
"([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[EL]",
"\\2", $joketext);
echo(" | \n");
echo("$titre $joketext Lire :
| \n");
echo(" \n");
echo("\n");
echo(" | \n");
echo(" ");
echo (" ");
/*
$comon .= "- ";
$comon .="\n";
$comon .=' ';
$comon .=$tete;
$comon .=' ';
$comon .="\n";
$comon .= "$petit ";
$comon .="\n";
$comon .= "$dtt";
$comon .= "http://www.medicms.be/dt4/$tite";
$comon .=".htm";
$comon .="\n";
$comon .= "
";
$comon .="\n";
*/
}
/*
$comon .= "";
$comon = ereg_replace("&","&",$comon);
$comon = ereg_replace("é","é",$comon);
$comon = ereg_replace("à","à",$comon);
$comon = ereg_replace("ê","ê",$comon);
$comon = ereg_replace("î","î",$comon);
$comon = ereg_replace("Ï","ï",$comon);
$comon = ereg_replace("ï","ï",$comon);
$comon = ereg_replace("è","è",$comon);
$comon = ereg_replace("ç","ç",$comon);
$comon = ereg_replace("û","û",$comon);
$comon = ereg_replace("ù","ù",$comon);
$comon = ereg_replace("ô","ô",$comon);
$comon = ereg_replace("â","â",$comon);
//mysql_close;
$comon1 = '<';
$comon1 .= '?';
$comon1 .= 'xml version="1.0" encoding="utf-8" ';
$comon1 .= '?>';
$comon3 .= '<';
$comon3 .= 'rss version="2.0"';
$comon3 .= '>';
$comon2 = "$comon1" . "$comon3" . "$racine" . "$comon" ;
*/
//mysql_free_result;
echo(" | | \n");
echo(" \n");
}
if($page != 1)
{
$n_page = $page - 1;
/*
if ($IDRecherche != "") {
$where = " WHERE ID > '$IDRecherche'";
}else{
*/
$where = " WHERE ID > 0";
//}
$selecto1= str_replace(" ", "+", trim($FRechercheori)); // on remplace les espaces par des + ;
$Selecto="&FRecherche=$selecto1&operateur=AND&submit=Search";
//echo "selecto $Selecto";
echo(" page précédente ");
}
if($test < $nb_t)
{
$n_page = $page + 1;
/*
if ($IDRecherche != "") {
$where = " WHERE ID > '$IDRecherche'";
}else{
*/
$where = " WHERE ID > 0";
//}
$selecto1= str_replace(" ", "+", trim($FRechercheori)); // on remplace les espaces par des + ;
$Selecto="&FRecherche=$selecto1&operateur=AND&submit=Search";
echo( " |
page suivante ");
}
//}
?>
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'
|
|