<?php

// ------------------------------------------------------------------------- //
// Lire un source HTML.                                                      //
// ------------------------------------------------------------------------- //
// Auteur: Stéphane Chardès                                                  //
// Email:  schardes@free.fr                                                  //
// Web:    http://schardes.free.fr/                                          //
// ------------------------------------------------------------------------- //

?>

<html>
<head>
<title>Lire un source HTML</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h3 align="center"><i><b>Lire un source HTML</b></i> </h3>
<form method="post" action="">
  <div align="center">URL
    <input type="text" name="url">
    <input type="submit" name="lire" value="Lire">
  </div>
</form>
<hr width="50%" align="center">
<?
if (strlen($url)!=0)
{
    echo
"<h3 align=\"center\"><i>URL passée : $url</i></h3>";
    echo
"<hr width=\"50%\" align=\"center\">";
    
// Ajout de http:// si cela a été omis
    
if (substr($url,0,7)!='http://')
    {
        
$url='http://'.$url;
    }
    
// Lire une page web dans un tableau, et l'afficher
    
$contenu = file( $url );
    while ( list(
$numero_ligne, $ligne ) = each( $contenu ) )
    {
        echo
"<B>Ligne $numero_ligne:</B> ".htmlspecialchars( $ligne ) . "<br>";
    }
}
?>

</body>
</html>