Bonjour, suite à un projet j'aimerai me connecter au proxy de mon école automatiquement avec mes login mais je doit le faire en PHP or je ne suis pas un doué du PHP =). J'ai quand même trouvé un programme mais j'ai du mal à le comprendre ^^.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?php 
 
$url = 'http://www.google.fr'; 
$timeout = 5; 
 
$proxy_host = '192.168.3.4:8080'; // IP:port de mon école
$proxy_ident = 'cyril.goud*****:mot de passe'; // nom:mot de passe à moi
 
$ch = curl_init($url); 
 
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
 
if (preg_match('`^https://`i', $url)) // je sais pas si il faut mettre quelque chose içi
{ 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
} 
 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
 
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true); 
 
// Définition de l'adresse du proxy 
curl_setopt($ch, CURLOPT_PROXY, $proxy_host); 
 
// Définition des identifiants si le proxy requiert une identification 
if ($proxy_ident) 
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_ident); 
 
$page_content = curl_exec($ch); 
 
curl_close($ch); 
 
echo $page_content; 
 
?>
Merci d'avance si vous pouvez m'aider.