Skip to content
Extraits de code Groupes Projets
Valider 7f302481 rédigé par Fil's avatar Fil
Parcourir les fichiers

proxy authentifiant (Jerome Fenal)

parent edacf422
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -382,8 +382,12 @@ if ($options == 'avancees') { ...@@ -382,8 +382,12 @@ if ($options == 'avancees') {
debut_cadre_trait_couleur("base-24.gif", false, "", _T('info_sites_proxy').aide ("confhttpproxy")); debut_cadre_trait_couleur("base-24.gif", false, "", _T('info_sites_proxy').aide ("confhttpproxy"));
$http_proxy=entites_html(lire_meta("http_proxy"));
// Masquer un eventuel password authentifiant
if ($http_proxy = lire_meta("http_proxy")) {
include_ecrire ("inc_sites.php3");
$http_proxy=entites_html(no_password_proxy_url($http_proxy));
}
echo "<div class='verdana2'>"; echo "<div class='verdana2'>";
echo _T('texte_proxy'); echo _T('texte_proxy');
......
...@@ -146,7 +146,7 @@ function afficher_choix($nom, $valeur_actuelle, $valeurs, $sep = "<br>") { ...@@ -146,7 +146,7 @@ function afficher_choix($nom, $valeur_actuelle, $valeurs, $sep = "<br>") {
function appliquer_modifs_config() { function appliquer_modifs_config() {
global $clean_link, $connect_id_auteur; global $clean_link, $connect_id_auteur;
global $adresse_site, $email_webmaster, $email_envoi, $post_dates, $tester_proxy, $test_proxy, $activer_moteur; global $adresse_site, $email_webmaster, $email_envoi, $post_dates, $tester_proxy, $test_proxy, $http_proxy, $activer_moteur;
global $forums_publics, $forums_publics_appliquer; global $forums_publics, $forums_publics_appliquer;
global $charset, $charset_custom, $langues_auth; global $charset, $charset_custom, $langues_auth;
...@@ -172,6 +172,11 @@ function appliquer_modifs_config() { ...@@ -172,6 +172,11 @@ function appliquer_modifs_config() {
ecrire_meta('accepter_visiteurs', 'oui'); ecrire_meta('accepter_visiteurs', 'oui');
// Test du proxy : $tester_proxy est le bouton "submit" // Test du proxy : $tester_proxy est le bouton "submit"
// http_proxy : ne pas prendre en compte la modif si le password est '****'
if (preg_match(',:\*\*\*\*@,', $http_proxy))
$http_proxy = lire_meta('http_proxy');
if ($tester_proxy) { if ($tester_proxy) {
if (!$test_proxy) { if (!$test_proxy) {
echo _T('info_adresse_non_indiquee'); echo _T('info_adresse_non_indiquee');
...@@ -182,7 +187,7 @@ function appliquer_modifs_config() { ...@@ -182,7 +187,7 @@ function appliquer_modifs_config() {
if ($page) if ($page)
echo "<pre>".entites_html($page)."</pre>"; echo "<pre>".entites_html($page)."</pre>";
else else
echo _T('info_impossible_lire_page', array('test_proxy' => $test_proxy))."<html>$http_proxy</html></tt>.".aide('confhttpproxy'); echo _T('info_impossible_lire_page', array('test_proxy' => $test_proxy))." <tt>".no_password_proxy_url($http_proxy)."</tt>.".aide('confhttpproxy');
exit; exit;
} }
} }
......
...@@ -27,6 +27,43 @@ if (!_DIR_RESTREINT AND $GLOBALS['connect_statut'] == '0minirezo') { ...@@ -27,6 +27,43 @@ if (!_DIR_RESTREINT AND $GLOBALS['connect_statut'] == '0minirezo') {
WHERE id_syndic_article='$ajouter_lien'"); WHERE id_syndic_article='$ajouter_lien'");
} }
// Function glue_url : le pendant de parse_url (cf doc spip.net/parse_url)
function glue_url ($url){
if (!is_array($url)){
return false;
}
// scheme
$uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : '';
// user & pass
if (!empty($url['user'])){
$uri .= $url['user'].':'.$url['pass'].'@';
}
// host
$uri .= $url['host'];
// port
$port = (!empty($url['port'])) ? ':'.$url['port'] : '';
$uri .= $port;
// path
$uri .= $url['path'];
// fragment or query
if (isset($url['fragment'])){
$uri .= '#'.$url['fragment'];
} elseif (isset($url['query'])){
$uri .= '?'.$url['query'];
}
return $uri;
}
// Ne pas afficher la partie 'password' du proxy
function no_password_proxy_url($http_proxy) {
if ($p = @parse_url($http_proxy)
AND $p['pass']) {
$p['pass'] = '****';
$http_proxy = glue_url($p);
}
return $http_proxy;
}
// //
// Recupere une page sur le net // Recupere une page sur le net
// et au besoin l'encode dans le charset local // et au besoin l'encode dans le charset local
...@@ -53,8 +90,10 @@ function recuperer_page($url, $munge_charset=false) { ...@@ -53,8 +90,10 @@ function recuperer_page($url, $munge_charset=false) {
if (!($path = $t['path'])) $path = "/"; if (!($path = $t['path'])) $path = "/";
if ($http_proxy) { if ($http_proxy) {
$t2 = @parse_url($http_proxy); $t2 = @parse_url($http_proxy);
$proxy_host = $t2['host']; $proxy_host = $t2['host'];
$proxy_user = $t2['user'];
$proxy_pass = $t2['pass'];
if (!($proxy_port = $t2['port'])) $proxy_port = 80; if (!($proxy_port = $t2['port'])) $proxy_port = 80;
$f = @fsockopen($proxy_host, $proxy_port); $f = @fsockopen($proxy_host, $proxy_port);
} else } else
...@@ -68,8 +107,17 @@ function recuperer_page($url, $munge_charset=false) { ...@@ -68,8 +107,17 @@ function recuperer_page($url, $munge_charset=false) {
fputs($f, "Host: $host\r\n"); fputs($f, "Host: $host\r\n");
fputs($f, "User-Agent: SPIP-".$GLOBALS['spip_version_affichee']." (http://www.spip.net/)\r\n"); fputs($f, "User-Agent: SPIP-".$GLOBALS['spip_version_affichee']." (http://www.spip.net/)\r\n");
// Proxy authentifiant
if ($proxy_user) {
fputs($f, "Proxy-Authorization: Basic "
. base64_encode($proxy_user . ":" . $proxy_pass) . "\r\n");
}
// Referer = c'est nous !
if ($referer = lire_meta("adresse_site")) if ($referer = lire_meta("adresse_site"))
fputs($f, "Referer: $referer/\r\n"); fputs($f, "Referer: $referer/\r\n");
// Fin des entetes
fputs($f,"\r\n"); fputs($f,"\r\n");
$s = trim(fgets($f, 16384)); $s = trim(fgets($f, 16384));
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter