par
Invité » 01 oct. 2006, 09:25
j'ai actuellement un script de liens sur lequel je veux ra jouter du code html suivant le lien , celà donne
Code : Tout sélectionner
if ($PID == 2681){require('http://www.myste.info/linksphp/html/page2681.htm');}
donc si la catégorie n°2681 est atteinte on rajoute le fichier page2681.html
1er pb : on m'a dit qu'il ne fallait pas faire comme çà mais avec ceci :
Code : Tout sélectionner
$handle = fopen ('http://www.myste.info/linksphp/html/page2681.htm', "rb");
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$myLine .= $data;
} while(true);
fclose ($handle);
if(empty($myLine))
{ echo "error fetching";exit;
}
// $myLine now has the entire page, possibly you only want a
// portion of the page, to do that you need to find somthing
// in the code that is unique before and after the text.
// You'll have to view the html source of what you are
// fetching to get it perfect. To get everying within
// a simple a table, might look like this.
$start = '<table><tr><td>';
$end = '</td></tr></table>';
$start_position=strpos($myLine, $start);
$end_position=strpos($myLine, $end)+strlen($end);
$length=$end_position-$start_position;
$myLine=substr($myLine, $start_position, $length);
// you can strip out or alter other stuff if needed
// replace one string with another
$myLine=ereg_replace("95%", "90%", $myLine);
//get rid of html , except for italics & bold
$myLine=strip_tags($myLine, '<i>', '<b>');
}
mais celà ne marche plus qu'ai je loupé ?
j'ai actuellement un script de liens sur lequel je veux ra jouter du code html suivant le lien , celà donne
[code] if ($PID == 2681){require('http://www.myste.info/linksphp/html/page2681.htm');}[/code]
donc si la catégorie n°2681 est atteinte on rajoute le fichier page2681.html
1er pb : on m'a dit qu'il ne fallait pas faire comme çà mais avec ceci :[code]
$handle = fopen ('http://www.myste.info/linksphp/html/page2681.htm', "rb");
do {
$data = fread($handle, 8192);
if (strlen($data) == 0) {
break;
}
$myLine .= $data;
} while(true);
fclose ($handle);
if(empty($myLine))
{ echo "error fetching";exit;
}
// $myLine now has the entire page, possibly you only want a
// portion of the page, to do that you need to find somthing
// in the code that is unique before and after the text.
// You'll have to view the html source of what you are
// fetching to get it perfect. To get everying within
// a simple a table, might look like this.
$start = '<table><tr><td>';
$end = '</td></tr></table>';
$start_position=strpos($myLine, $start);
$end_position=strpos($myLine, $end)+strlen($end);
$length=$end_position-$start_position;
$myLine=substr($myLine, $start_position, $length);
// you can strip out or alter other stuff if needed
// replace one string with another
$myLine=ereg_replace("95%", "90%", $myLine);
//get rid of html , except for italics & bold
$myLine=strip_tags($myLine, '<i>', '<b>');
}
[/code]
mais celà ne marche plus qu'ai je loupé ?