alpha_full/_include/_mail/lireContent.php
2026-04-06 22:58:51 +02:00

54 lines
1.8 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
$faireCurl=1;
if (isset($debug[1]) && $debug[1] == '1' ) { $debugMsg .= monDebug(2, [ 'url' => $url ], 'lireContent');}
// ---------------------------------------------------
// Curl
// ---------------------------------------------------
if ($faireCurl==1) {
function curl_get_contents($url) {
global $data;
$ch = curl_init();
// pas de de encode url : sinon il lit plus
curl_setopt($ch, CURLOPT_URL, ($url));
// curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 30);
curl_setopt ($ch, CURLOPT_CUSTOMREQUEST , "GET");
$data = curl_exec($ch);
if (isset($debug[1]) && $debug[1] == '1' ) {
print_r($data);
print curl_error($ch);
}
curl_close($ch);
return $data;
}
$lire = (curl_get_contents($url));
}
// ---------------------------------------------------
// Ou fopen wrappers
// ---------------------------------------------------
// ---------------------------------------------------
// ---------------------------------------------------
else {
$opts = array('https'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
// Basically adding headers to the request
$context = stream_context_create($opts);
$lire = mb_convert_encoding (file_get_contents($url, false, $context), 'ISO-8859-1', 'UTF-8');
}
// ---------------------------------------------------
// Nettoyer le resultat
// ---------------------------------------------------
$lire = str_replace ('<?php','',$lire);
$lire = str_replace ('?>','',$lire);
$lire = str_replace ('echo ','',$lire);
$lire = str_replace (';' ,'',$lire);
$lire = str_replace ('\'','',$lire);
?>