<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
</head>
<body>
<?php
include('config.inc.php');
$j=0;
$fin = 10;
$menu = "";
$moins = "";
$plus = "";
if(isset($_GET['page'])) {
$page=htmlentities($_GET['page']);
}
else {
$page=1;
}
$chaine = str_replace(" ","_",$chaine);
if(isset($_GET['num'])) {
$num=htmlentities($_GET['num']);
$fin2 = $fin + $num;
}
else {
$num=0;
}
$debut=($page*$fin)-$fin;
echo "<Table>
<tr><td>Recherche:</td>
<form action=\"dico2.php\" method=\"get\">";
if(isset($_GET['search'])) {
$value = htmlentities($_GET['search']);
echo "<td><input type=\"text\" name=\"search\" value=\"$value\" size=\"20\" maxlength=\"255\"><td>";
}
else {
echo "<td><input type=\"text\" name=\"search\" size=\"20\" maxlength=\"255\"><td>";
}
echo "<td><input type=\"submit\" value=\"Rechercher\"></td>
<td>(ex: souvenir)</td>
<input type=\"hidden\" name=\"num\" value=\"0\">
<input type=\"hidden\" name=\"page\" value=\"1\">
</form>
</tr></table>";
echo "<center>
<Table border=\"2\" width=\"95%\">
<tr><td>nom du fichier</td>
<td>repertoire</td>
<td>taille</td>
<td>type</td>
<td> <a href=file://192.168.0.4\partage\A%20GRAVER\Carol\MVI_7829.AVI target=_blank >Lien</a> Lien</td>
</tr>";
if(isset($_GET['search'])) {
$search_env = $_GET['search'];
$search_env1 = $_GET['search'];
if(is_numeric($search_env)) {
$req_nb_all = mysql_query("SELECT nom,emplacement,taille,type,creer from brute where nom='$search_env'" ) or die ("erreur sql ".mysql_error());
$rows_req = mysql_num_rows($req_nb_all);
}
else {
if(substr($search_env, -1, 1) == '"' And substr($search_env, 0, 1) == '"') {
$search_env = str_replace('"', "", $search_env);
$req_search_all[0] = mysql_query("SELECT id,langage,type,example,link FROM `brute` WHERE `langage` LIKE '%$search_env%' OR `type` LIKE '$search_env' OR `example` LIKE '%$search_env%'" ) or die ("erreur sql ".mysql_error());
if(isset($rows_req)) {
$rows_req = mysql_num_rows($req_search_all[0]) + $rows_req;
}
else {
$rows_req = mysql_num_rows($req_search_all[0]);
}
$nb=1;
$valide = 1;
}
else {
$search_env = explode(' ' , $search_env);
$nb = count($search_env);
$valide = 0;
for($i = 0; $i < $nb; $i++) {
$req_search_all[$i] = mysql_query("SELECT nom,emplacement,taille,type,creer FROM `brute` WHERE `nom` LIKE '%$search_env[$i]%' OR `type` LIKE '$search_env[$i]' OR `emplacement` LIKE '%$search_env[$i]%'" ) or die ("erreur sql ".mysql_error());
if(isset($rows_req)) {
$rows_req = mysql_num_rows($req_search_all[$i]) + $rows_req;
}
else {
$rows_req = mysql_num_rows($req_search_all[$i]);
}
}
}
}
$nombre_total_de_resultat = $rows_req;
$nombre_de_page=ceil($nombre_total_de_resultat/$fin);
}
else {
$req_all = mysql_query("SELECT nom,emplacement,taille,type,creer from brute" ) or die ("erreur sql ".mysql_error());
}
if(isset($search_env) And is_numeric($search_env)) {
while (list ($nom, $emplacement, $type, $example, $link) = mysql_fetch_row ($req_nb_all)) {
$j++;
echo "<tr><td><center>$nom</center></td>
<td><center>$emplacement</center></td>
<td><center>$type</center></td>
<td>$example</td>
<td>$link</td>
</tr>";
}
echo "il y $j resultat";
}
elseif(isset($_GET['search']) And is_numeric($search_env) == 0) {
for($h = 0; $h < $nb; $h++) {
while (list ($nom1, $emplacement, $type, $example, $link) = mysql_fetch_row ($req_search_all[$h])) {
if ($valide == 0) {
for($i = 0; $i < $nb; $i++) {
$example = str_replace("$search_env[$i]","<span class=\"srch$i\">$search_env[$i]</span>","$example" );
$example = str_replace(strtolower($search_env[$i]),"<span class=\"srch$i\">".strtolower($search_env[$i])."</span>","$example" );
$example = str_replace(strtoupper($search_env[$i]),"<span class=\"srch$i\">".strtoupper($search_env[$i])."</span>","$example" );
$example = str_replace(ucfirst($search_env[$i]),"<span class=\"srch$i\">".ucfirst($search_env[$i])."</span>","$example" );
}
}
elseif ($valide == 1) {
$example = str_replace("$search_env","<span class=\"srch0\">$search_env</span>","$example" );
$example = str_replace(strtolower($search_env),"<span class=\"srch0\">".strtolower($search_env)."</span>","$example" );
$example = str_replace(strtoupper($search_env),"<span class=\"srch0\">".strtoupper($search_env)."</span>","$example" );
$example = str_replace(ucfirst($search_env),"<span class=\"srch0\">".ucfirst($search_env)."</span>","$example" );
}
$lien=$emplacement.$nom1;
$j++;
if($h >= $num and $num < $fin2) {
$num++;
echo "<tr><td><center>$nom1</center></td>
<td><center><a href=file://$lien>telecharger </a></center></td>
<td><center>$type</center></td>
<td>$example</td>
<td><link>$link</td>
</tr>";
}
}
}
echo "il y $j resultat";
}
else {
if(isset($req_all)) {
while (list ($nom, $langage, $type, $example, $link) = mysql_fetch_row ($req_all)) {
echo "<tr><td><center>$nom</center></td>
<td><center>$lien</center></td>
<td><center>$type</center></td>
<td>$example</td>
<td>$link</td>
</tr>";
}
}
}
if(isset($_GET['page']) And $_GET['page']>5 && $_GET['page']<=($nombre_de_page-4)) {$decale=$_GET['page']-5;}
elseif(isset($_GET['page']) And $_GET['page']<5) {$decale=0;}
elseif(isset($_GET['page']) And $_GET['page']>($nombre_de_page-5)) {$decale=$nombre_de_page-9;}
if(isset($nombre_de_page) And isset($decale)) {
$num_moin = $num-($fin+1);
$plus=($page==$nombre_de_page) ? "" : "<a href='dico2.php?search=$search_env1&num=$num&page=".($page+1)."'> suivant </a>";
$moins=($page==1) ? "" : "<a href='dico2.php?search=$search_env1&num=$num_moin&page=".($page-1)."'> précedent </a>";
$fin_de_boucle=($nombre_de_page<10) ? "$nombre_de_page" : "".(9+$decale)."";
for($i=-+$decale;$i<=$fin_de_boucle;$i++){
if($i > 1) {
$num_n = $num_n + $fin;
}
else {
$num_n = 0;
}
$menu.=($i==$page) ? " $i " : " <a href='dico2.php?search=$search_env1&num=$num_n&page=$i'>$i</a> ";
}
}
if(isset($moins) Or isset($menu) Or isset($plus)) {
echo "<table width='85%' border='0' align=\"center\" cellpadding='0' cellspacing='0'>
<tr>
<td align=\"center\">$moins $menu $plus</td>
</tr>
</table>";
}
echo "</table></center>";
?>
</body>
</html>