', $pos1);
if ($pos2 == false) {
break;
}
$pos2 += 4;
if (substr_count($contenu, $discriminant, $pos1, $pos2 - $pos1) > 0) {
$pos3 = strpos($contenu, '>', $pos1) + 1;
if ($pos3 == $pos2 - 1) {
$pos1 = $pos2;
continue;
}
$rep = strip_tags(substr($contenu, $pos3, $pos2 - $pos3 - 4));
$contenu = substr_replace($contenu, $rep, $pos1, $pos2 - $pos1);
$pos1 += strlen($rep);
} else {
$pos1 = $pos2;
}
}
return $contenu;
}
function bdf_loadpage($url)
{
try {
$client = new Zend_Http_Client($url);
$response = $client->request('GET');
if ( $response->isSuccessful() ) {
$output = $response->getBody();
} else {
$output = false;
}
} catch (Zend_Http_Client_Exception $e) {
$output = false;
}
$output = utf8_encode($output);
$output = preg_replace('/(.*)\bdf_removeblock($output);
$output = $this->removeTag('html', $output, true, false);
$output = $this->removeTag('head', $output, true, false);
$output = $this->removeTag('body', $output, true, false);
$output = $this->removeTag('meta', $output, false, false);
$output = $this->removeTag('title', $output, true, true);
$output = $this->removeTag('script', $output, true, true);
//$output = changeLinkToLowerCase($output);
$output = $this->bdf_lien_siren($output);
$output = stripslashes($output);
return $output;
}
function bdf_removeblock($content)
{
$output = $content;
$output = $this->enleveLiens($output, '#nullepart');
$output = $this->enleveLiens($output, 'window.print');
$output = str_replace('/PROTECTEL/FIBEN20110207/',
$this->host.'/PROTECTEL/FIBEN20110207/', $output);
return $output;
}
function removeTag($balise, $content, $endOfTag = true, $removeContent = true)
{
if( $endOfTag )
{
if( $removeContent)
$output = preg_replace('@<'.$balise.'[^>]*?>.*?'.$balise.'>@si','',$content);
else
$output = preg_replace(array('@<'.$balise.'[^>]*?>@', '@'.$balise.'>@'),'',$content);
}
else
{
$output = preg_replace('@<'.$balise.'[^>]*?>@','',$content);
}
return $output;
}
function changeLinkToLowerCase($content)
{
//$pattern = "/\< *[img][^\>]*[href] *= *[\"\']{0,1}([^\"\'\ >]*)/i";
$pattern = '/(\].*?>)/ie';
$replace = "strtolower('\\1')";
$content = preg_replace($pattern,$replace,$content);
$pattern = '/(\