X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fconfiguration%2Frelayeur.php;fp=www%2Fecrire%2Fconfiguration%2Frelayeur.php;h=b7283f3ac6ff1ecd22613600f5a50d04722224a0;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c diff --git a/www/ecrire/configuration/relayeur.php b/www/ecrire/configuration/relayeur.php new file mode 100644 index 0000000..b7283f3 --- /dev/null +++ b/www/ecrire/configuration/relayeur.php @@ -0,0 +1,151 @@ +" + . "" + . "

" + . "\n

" + . "" + . "

"; + + if($retour_proxy) { + $res .= debut_boite_info(true) + . $retour_proxy + . fin_boite_info(true); + } + $submit = array('valider_proxy' => _T('bouton_valider'), + 'tester_proxy' => _T('bouton_test_proxy')); + } + } + + $encours = "' ; + $exemple = ""; + $res = "\n
" + . propre(_T('texte_proxy', array('proxy_en_cours' => "$encours"))) + . "
" + . "\n
" + . "" + . "
" + . propre(_T('pas_de_proxy_pour', array('exemple' => "$exemple"))) + . "" + . $res + . "
"; + + $res = debut_cadre_trait_couleur("base-24.gif", true, "", _T('info_sites_proxy').aide ("confhttpproxy")) + . ajax_action_post('configurer_relayeur', 0, 'config_fonctions', '', $res, $submit) + . fin_cadre_trait_couleur(true); + + return ajax_action_greffe("configurer_relayeur", 0, $res); +} + +function configuration_relayeur_post ($http_proxy, $http_noproxy, $test_proxy, $tester_proxy) +{ + // http_proxy : ne pas prendre en compte la modif si le password est '****' + if (preg_match(',:\*\*\*\*@,', $http_proxy)) + $http_proxy = $GLOBALS['meta']['http_proxy']; + + $retour = $page = ''; + + if ($tester_proxy AND preg_match(",https?://,", $http_proxy)) { + include_spip('inc/distant'); + $t = parse_url($test_proxy); + + if (!@$t['host']) { + $retour = _T('info_adresse_non_indiquee'); + } elseif (!need_proxy($t['host'])) { + + $retour = "

"._T('page_pas_proxy')."

\n"; + } elseif ($page = recuperer_page($test_proxy, true)) { + include_spip('inc/texte'); // pour aide, couper, lang + $retour = "

"._T('info_proxy_ok')."

\n" + . couper(entites_html($page),300).""; + } else $retour = _T('info_impossible_lire_page', + array('test_proxy' => $test_proxy)) + . " ".no_password_proxy_url($http_proxy)."." + . aide('confhttpproxy'); + } + + if ($http_proxy !== NULL) { + ecrire_meta('http_proxy', $http_proxy); + } + if ($http_noproxy !== NULL) { + ecrire_meta('http_noproxy', $http_noproxy); + } + if ($page) { + include_spip('install/etape_fin'); + $retour .= install_verifier_htaccess(); + } + return $retour; +} + +// Function glue_url : le pendant de parse_url +// http://doc.spip.org/@glue_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 +// http://doc.spip.org/@no_password_proxy_url +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; +} +?>