[PHP] problème dans un script

Fermé
Laorra Messages postés 195 Date d'inscription dimanche 12 novembre 2006 Statut Membre Dernière intervention 18 juillet 2011 - 4 juin 2008 à 17:15
Laorra Messages postés 195 Date d'inscription dimanche 12 novembre 2006 Statut Membre Dernière intervention 18 juillet 2011 - 4 juin 2008 à 22:36
Bonjour,


J'ai un script php qui permet de tester tout les liens d'un site.
Seulement il a un problème, il boucle sur le premier liens apparement. J'ai longuement cherché et je ne vois pas d'ou ça viens...

<?php
$ADRESSE = "https://www.terresens.com/";
$array = array();

function getA($cha){
global $array;
while ($ligne = fgets($cha)){
$tab = preg_split("/href=\"/", $ligne);
for ($i = 1; $i < count($tab); $i++){
if (preg_match("/^(\S+)\"/", $tab[$i], $out)){
if (!($out[1] == "#" || $out[1] == "")){
if (!isset($array[$out[1]])) $array[$out[1]] = 0;
}
}
}
}
}

function checkUrl($adress){
global $ADRESSE;
global $array;

$cha = fopen ($adress, "r");
getA($cha);
fclose($cha);

$i = 0;
foreach ($array as $keys => $value){
if ($value == 0){
if (!preg_match("/http:\/\//", $keys)){
$vari = $ADRESSE . $keys;
$cha1 = @fopen($vari, "r");
$array[$keys] = $http_response_header[0];
@fclose($cha1);
} else {
$vari = $keys;
$cha1 = @fopen($vari, "r");
$array[$keys] = $http_response_header[0];
@fclose($cha1);
}
}
}
}

checkUrl($ADRESSE);
?>
<table border="1">
<?php
foreach ($array as $key => $value){
echo "<tr><td>" . $key . "</td><td>" . $value . "</td></tr>";
}
?>
</table>



Bonne chance à ceux qui se pencherons dessus, et merci!
A voir également:

1 réponse

Laorra Messages postés 195 Date d'inscription dimanche 12 novembre 2006 Statut Membre Dernière intervention 18 juillet 2011 107
4 juin 2008 à 22:36
UP?
0