1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<?php
//définition des variables
$url_int="locale";
//$url_ext="http://www.debian.org";
//proxy
$proxy_url="proxy.qqch.ch:9090";
$user="user";
$pass="pass";
$domaine="intra.qqch.ch";
function recuperer_page_http($url, $proxy) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch,CURLOPT_PROXYPORT,9090);
curl_setopt($ch,CURLOPT_PROXYUSERPWD,'user:pass');
$ret = curl_exec($ch);
if (!$ret) {
curl_error($ch);
}
curl_close($ch);
return $ret;
}
//Option d'authentification pour le serveur proxy
$options= array(
//option du proxy
'proxyhost' => $proxy_url,
'proxytype' => 'HTTP_PROXY_HTTP',
'proxyauth' => $user.':'.$pass
);
//http_request($url_ext,$options);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$url_link="http://www.debian.org";
$proxy="proxy.qqch.ch:9090";
echo recuperer_page_http($url_link,$proxy);
//Lit la page web
//$code_html= file_get_contents ($url_int);
// Lit un fichier, et le place dans une chaîne
/*filename = "/usr/local/something.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);*/
// AFFICHE PAGE
//print_r($code_html);
//AFFICHAGE CODE de la page
/*foreach ($code_html as $num_ligne => $ligne) {
echo "Ligne<b>$num_ligne</b> : " . htmlspecialchars($ligne) . "<br>\n";
} */
?>
</body>
</html> |
Partager