Les Allergies
Alimentaires
Posez votre question Signaler

Pbm avec PHP pour un moteur de recherche

albah 78Messages postés 6 avril 2004Date d'inscription - Dernière réponse le 12 mai 2004 à 16:43
Bonjour,
J'ai un script PHP pour un moteur de recherchequi ne fonctionne pas... Dedans, on trouve le commentaire suivant:

*/this script is written to work with php3 - if you are running php4, simply remove the 3 from the file name reference
make the same modification in the form tag on our search page*/

Mon hébergeur m'impose PHP4.1.1, mais a priori ce n'est pas un pbm de compatibilité.

Voici le message d'erreur lors du lancement d'une recherche:

Warning: OpenDir: Permission denied (errno 13) in /easyonline/www/www.koppen-lethem.fr/htdocs/reponse.php on line 28

Warning: Supplied argument is not a valid Directory resource in /easyonline/www/www.koppen-lethem.fr/htdocs/reponse.php on line 29

Warning: Supplied argument is not a valid Directory resource in /easyonline/www/www.koppen-lethem.fr/htdocs/reponse.php on line 91

Quelqun peut il ma'ider SVP, s'agit il d'un pbm de compatibilité en tre PHP3 et 4, d'un pbm de configuratin du script ou d'autre chose...?

Merci d'avance
Lire la suite 

Pbm avec PHP pour un moteur de recherche »

10 réponses
Réponse
+0
moins plus
Si tu nous donnais au moins les lignes en question ça pourrait nous aider...

.::: "A trop vouloir feindre de faire fi, on finit 
par faire fi de vouloir feindre." 
:::.
albah- 12 mai 2004 à 15:10
Voilà le code. Il y'a une autre page .php mais je ne crois pas qu'elle soit intéressante, elle envoie juste la valeur remplie dans le champ.
Si tu peux m'aider avec ca, merci....


<?
if (!empty($keywords))
{
?> </font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">
Vous recherchiez <b><? print ($keywords); ?></b> <?

/* this script must reside in your root directory and will search recursively down through your web site
this script is written to work with php3 - if you are running php4, simply remove the 3 from the file name reference
make the same modification in the form tag on our search page*/

$key = escapeshellcmd ($keywords); // let's make sure any metacharacters get escaped so as not to wreak havoc with our host
$tcount = 0; // initialize our file count

function scroll($current, $terms, &$total)
{ //print $terms;
$handle=opendir($current); // open the directory passed as the first argument
while (($file = readdir($handle))!=false) // keep cycling through all the files
{ $first = ""; // initialize first occurance of the match
$fcount = 0; // initialize number of matches per file
$found = false; // initialize flag - true or false
$no_title = true;
$file_p = $current . "/" . $file; // create the path to the file for the a href
if (($file != ".") && ($file != "..")) // ignore . and .. files
{
if (is_file($file_p) && (substr($file,0,1) != "_") && ((substr(strrev($file),0,1) == "l") || (substr(strrev($file),0,1) == "m") ||(substr(strrev($file),0,3) == "php"))) // limit our search to
// php3, php, html, htm and txt files
{
$file_b = fopen($file_p, "r"); // open the file for reading
while (!feof($file_b)) // continue to end of line
{ $line = fgets($file_b, 2000); // try and remove all data between <> when reading
$line = trim($line); // trim any leading or trailing white space
if (!empty($line))
{ //print $line;
if ($no_title == true)
{ preg_match ("/title+[\w\W]*title+/i", $line, $matches);
if ($matches)
{ $title = $matches[0];
$no_title = false;}
}
$newline = eregi_replace ("(<'.*>)", "", $line);
if ((strpos($newline , $terms) >=0 ) && (strpos($newline , $terms))) // check that line for a match, using the keywords, the line, and returning an array of the matches
{//print "match found" . strpos($newline , $terms);
$found = true; // set flag
$fcount++; //increment total found for this file
if ($first == "")
{
$first = $newline ; // set the variable to display the first line where the match occurred
}
}
}
}
if ($found == true)
{ $len = strlen($file_p); // this allows us to print the link, ignoring the starting /
$this_title = ereg_replace ("title", "", $title);
$this_title = preg_replace ("/>/", "", $this_title);
$this_title = preg_replace ("/</", "", $this_title);
$this_title = eregi_replace ("<", "", $this_title);
$this_title = eregi_replace (">", "", $this_title);
$this_title = eregi_replace ("/", "", $this_title);
$this_title = ereg_replace ("/", "", $this_title);
$t_len = strlen($this_title);
$total++; // increment total number of file matches
print ("<p><a href ='" . $file_p . "'>" . $this_title. "</a> contient ". $fcount . " correspondance(s).");
}
}
$found = false;
$no_title = true;
// this is the recursive call
if ((is_dir($file_p)) && (dirname($file_p) != "_private") && (dirname($file_p) != "_someothername"))// if the file is a directory and not a private one
{
$new_dir = $current . "/" . $file;
if (($new_dir != "./mysql") && ($new_dir !="./easyonline/www/www.koppen-lethem.fr/htdocs"))
scroll ($new_dir, $terms, &$total); // call the function recursively when it is a directory
}
// end of if (($file != ".") && ($file != ".."))
}
// end of while (($file = readdir($handle))!=false)
}
closedir($handle); // close the directory
// end of function
}

// print $key;

scroll(".", $key, $tcount); // initial call to the function, passing it the current directory as the start, the cleaned up search terms and the total number of files found - this is passed by reference so it can be incremeneted script-level
if ($tcount > 0)
{
print ("<p>Résultat(s) trouvé(s) : " . $tcount . " correspondant(s).");}
else
{
print ("Pas de réponse pour cette recherche.");}
}
else
{
print ("<p>#");
} // end of keywords not empty

?>
Ajouter un commentaire
Réponse
+0
moins plus
C'est un problème de droits, tu n'as pas les droits nécessaires pour ouvrir un répertoire.


.::: "A trop vouloir feindre de faire fi, on finit 
par faire fi de vouloir feindre." 
:::.
albah- 12 mai 2004 à 15:38
peux tu alors me dire quels sont les choses a faire pour résoudre ce problème?
dois je contacter mon hébergeur?

Merci de tont aide
Ajouter un commentaire
Réponse
+0
moins plus
Pour changer les droits en php il y a bien la fonction chmod(), mais si tu n'as pas les droits nécessaires pour ouvir un répertoire, tu n'auras pas les droits non plus pour changer ces droits.

Essaie toujours de contacter ton hébergeur, oui.


.::: "A trop vouloir feindre de faire fi, on finit 
par faire fi de vouloir feindre." 
:::.
Ajouter un commentaire
Réponse
+0
moins plus
j'ai 751 comme attribut pourle répertoire qui contient tous les dossiers de mon site... et 644 pour mes deux fichiers php...
je peux changer ces droits... mais que dios je mettre et à quels dossiers...?

Merci
Ajouter un commentaire
Réponse
+0
moins plus
dois je rendre l'exeution possible pour le groupe ou le publique?
Ajouter un commentaire
Réponse
+0
moins plus
Laisse 751 pour le répertoire mais il faut donner les droits au public.

.::: "A trop vouloir feindre de faire fi, on finit 
par faire fi de vouloir feindre." 
:::.
albah- 12 mai 2004 à 15:57
J'ai essayé de donner les droits au publique pour le fichier php et ca ne marche toujours pas...?

Mission impossible?
Ajouter un commentaire
Réponse
+0
moins plus
qqn peut m'aider SVP. Je peux changer les droits mais ca ne marche toujours pas
Ajouter un commentaire
Ce document intitulé « pbm avec PHP pour un moteur de recherche » issu de CommentCaMarche (www.commentcamarche.net) est mis à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de cette page, dans les conditions fixées par la licence, tant que cette note apparaît clairement.
Dossier à la une
Passage au tout numérique : quel coût pour les particuliers ?