Hello,
voici la fonction pour inclure le code html dans une page, mais simplifi�e. Si on teste pour le tag html *et* body, ceci peut avoir des r�sultats surprenant. Par exemple, avec une feuille Excel sauv�e en html, taille 47Kb, le processus d�passait 30 secondes... Autrement dit, un s�rieux probl�me de performance.
Si on se contente de lire que ce qui est entre <body> et </body>, �a passe.
Il faut dire que Excel s'arrange pour bourrer la page (la moiti� de la taille) en d�finitions CSS entre <html> et <body>.


<?php
/*    display_html_page.php
  ---------------------
  16/11/2003 - mayv: first release
  01/02/2004 - mayv: only what is in the body

  display a html page content, removing header, html and body tags.
  Usage:
  1) include the fct code in the html/php main file:
      <?php require_once("display_html_page.php"); ?>
  2) select the embedded html file, as:

$file = "./lot_of_files/test0001.html";

- or -
$file = "http://www.included.com/result.html";
Note : open file not only text on another server can give surprising result.
The local references are anyway lost!


  3) use the fct call:
      <?php  display_html_page($file); ?>


*/ function display_html_page($file_name) { $fp = @fopen($file_name, 'rb'); if ($fp==0) die("<H2>Error 404 - Can't open file: " . $file_name ."</h2> "); $body = @fread($fp, filesize($file_name)); //any size //$body = @fread($fp, 100000); // max 100 k

  // regex issued in: http://www.phpinfo.net/regex/index.html
  $body =
  eregi_replace('(^.*<body[^>]*>)|(</body[^>]*>.*$)', '', $body);
  echo $body;
}

?>

--
/********************************************************************/
/* Yves Masur - Ch de Faug 2 - CH 1805 JONGNY - 021 9228491; FAX:93 */
/* Professionnel: +41 21 631 82 43 mobile: +41 79 479 92 48         */
/* [EMAIL PROTECTED] - homepage: http://yves.masur.microclub.ch/  */
/* Sites: www.aspeda.ch, www.svehk.ch,                              */
/* www.microclub.ch et www.fanfaredechardonnejongny.ch              */
/********************************************************************/


_______________________________________________ microclub-web mailing list [EMAIL PROTECTED] http://lists.alphanet.ch/mailman/listinfo/microclub-web

Répondre à