7 changed files with 201 additions and 194 deletions
@ -1,38 +0,0 @@
|
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
* SPIP, Systeme de publication pour l'internet * |
||||
* * |
||||
* Copyright (c) 2001-2010 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
// Mise a jour de l'option de configuration du proxy |
||||
|
||||
include_spip('configuration/relayeur'); |
||||
|
||||
// http://doc.spip.org/@action_configurer_relayeur_dist |
||||
function action_configurer_relayeur_dist() { |
||||
|
||||
$securiser_action = charger_fonction('securiser_action', 'inc'); |
||||
$arg = $securiser_action(); |
||||
|
||||
$http_proxy = _request('http_proxy'); |
||||
$http_noproxy = _request('http_noproxy'); |
||||
$test_proxy = _request('test_proxy'); |
||||
$tester_proxy = _request('tester_proxy'); |
||||
|
||||
$test = configuration_relayeur_post($http_proxy, $http_noproxy, $test_proxy, $tester_proxy); |
||||
|
||||
// message a afficher dans l'exec de retour |
||||
|
||||
$r = rawurldecode(_request('redirect')); |
||||
$r = parametre_url($r, 'retour_proxy', $test, "&"); |
||||
redirige_par_entete($r); |
||||
} |
||||
?> |
@ -1,147 +0,0 @@
|
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
* SPIP, Systeme de publication pour l'internet * |
||||
* * |
||||
* Copyright (c) 2001-2010 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
include_spip('inc/presentation'); |
||||
|
||||
/// A PASSER DANS LES FICHIERS DE LANGUE |
||||
|
||||
function configuration_relayeur_dist($retour_proxy='') |
||||
{ |
||||
global $spip_lang_left; |
||||
|
||||
$res = $submit = ''; |
||||
|
||||
$http_proxy = $GLOBALS['meta']["http_proxy"]; |
||||
$http_noproxy = $GLOBALS['meta']["http_noproxy"]; |
||||
|
||||
if ($http_proxy) { |
||||
include_spip('inc/distant'); |
||||
// Masquer un eventuel password authentifiant |
||||
$http_proxy=entites_html(no_password_proxy_url($http_proxy)); |
||||
if ($http_proxy) { |
||||
$res = "\n<p style='text-align: $spip_lang_left;' class='verdana1 spip_small'>" |
||||
. "<label for='test_proxy'>" |
||||
. _T('texte_test_proxy') |
||||
. "</label>" |
||||
. "</p>" |
||||
. "\n<p>" |
||||
. "<input type='text' name='test_proxy' id='test_proxy' value='http://www.spip.net/' size='40' class='forml' />" |
||||
. "</p>"; |
||||
|
||||
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 = "<label for='http_proxy'>" . ($http_proxy ? $http_proxy : "http://proxy:8080") . '</label>' ; |
||||
$exemple = "<label for='http_noproxy'>" . ($http_noproxy ? $http_noproxy : "127.0.0.1 .mondomaine.net") . "</label>"; |
||||
$res = "\n<div class='verdana2'>" |
||||
. propre(_T('texte_proxy', array('proxy_en_cours' => "<b><tt><html>$encours</html></tt></b>"))) |
||||
. "</div>" |
||||
. "\n<div class='verdana2'>" |
||||
. "<input type='text' name='http_proxy' id='http_proxy' size='40' class='forml' value='$http_proxy' />" |
||||
. "<br />" |
||||
. propre(_T('pas_de_proxy_pour', array('exemple' => "<b><tt><html>$exemple</html></tt></b>"))) |
||||
. "<input type='text' name='http_noproxy' id='http_noproxy' size='40' class='forml' value='$http_noproxy' />" |
||||
. $res |
||||
. "</div>"; |
||||
|
||||
$res = debut_cadre_trait_couleur("reseau-24.png", 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 = ''; |
||||
|
||||
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'); |
||||
} else { |
||||
include_spip('inc/texte'); // pour aide, couper, lang |
||||
if (!need_proxy($t['host'])) |
||||
$page = "<p>"._T('page_pas_proxy')."</p>\n"; |
||||
$page = recuperer_page($test_proxy, true); |
||||
if ($page) |
||||
$retour = "<p>"._T('info_proxy_ok')."</p>\n<tt>".couper(entites_html($page),300)."</tt>"; |
||||
else |
||||
$retour = _T('info_impossible_lire_page', array('test_proxy' => $test_proxy)) |
||||
. " <tt>".no_password_proxy_url($http_proxy)."</tt>." |
||||
. aide('confhttpproxy'); |
||||
} |
||||
} |
||||
if ($http_proxy !== NULL) { |
||||
ecrire_meta('http_proxy', $http_proxy); |
||||
} |
||||
if ($http_noproxy !== NULL) { |
||||
ecrire_meta('http_noproxy', $http_noproxy); |
||||
} |
||||
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; |
||||
} |
||||
?> |
@ -0,0 +1,45 @@
|
||||
<div class="formulaire_spip formulaire_configurer formulaire_#FORM formulaire_#FORM-#ENV{id,nouveau}"> |
||||
<h3 class='titrem'><img src="#CHEMIN_IMAGE{reseau-24.png}" class="cadre-icone" /><:info_sites_proxy:>#AIDER{confhttpproxy}</h3> |
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
[(#ENV{editable}) |
||||
#SET{proxy,#VAL{<b><tt>}|concat{'http://proxy:8080','</tt></b>'}} |
||||
<p><:texte_proxy{proxy_en_cours=#GET{proxy}}:></p> |
||||
<form method='post' action='#ENV{action}' enctype='multipart/form-data'><div> |
||||
[(#REM) declarer les hidden qui declencheront le service du formulaire |
||||
parametre : url d'action ] |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
<input type='submit' class='submit' value='<:bouton_enregistrer:>' style="display:none;"/> |
||||
<ul> |
||||
#SET{name,http_proxy}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} |
||||
<li class="editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]"> |
||||
<label for="#GET{name}">Adresse du proxy</label>[ |
||||
<span class='erreur_message'>(#GET{erreurs})</span> |
||||
] |
||||
<input type="text" class="text" name="#GET{name}" id="#GET{name}" value="#ENV*{#GET{name}}" |
||||
onchange="if (jQuery(this).val()) jQuery('.editer_test_proxy:hidden').show('fast'); else jQuery('.editer_test_proxy:visible').hide('fast');" |
||||
/> |
||||
</li> |
||||
#SET{exemple,#VAL{<b><tt>}|concat{'127.0.0.1 .mondomaine.net','</tt></b>'}} |
||||
#SET{name,http_noproxy}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} |
||||
<li class="editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]"> |
||||
<label for="#GET{name}">Exceptions pour le proxy</label>[ |
||||
<span class='erreur_message'>(#GET{erreurs})</span> |
||||
]<p class="explication"><:pas_de_proxy_pour{exemple=#GET{exemple}}:></p> |
||||
<input type="text" class="text" name="#GET{name}" id="#GET{name}" value="#ENV*{#GET{name}}" /> |
||||
</li> |
||||
#SET{name,test_proxy}#SET{erreurs,#ENV**{erreurs}|table_valeur{#GET{name}}} |
||||
<li class="editer_[(#GET{name})][ (#GET{obli})][ (#GET{erreurs}|oui)erreur]"[(#ENV{http_proxy}|strlen|non)style='display:none;']> |
||||
<label for="#GET{name}">Adresse de test</label>[ |
||||
<span class='erreur_message'>(#GET{erreurs})</span> |
||||
]<p class="explication"><:texte_test_proxy:></p> |
||||
<input type="text" class="text" name="#GET{name}" id="#GET{name}" value="#ENV*{#GET{name}}" /> |
||||
<input type='submit' class='submit' name="tester_proxy" value='<:bouton_test_proxy:>' /> |
||||
</li> |
||||
</ul> |
||||
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] |
||||
<!--extra--> |
||||
<p class='boutons'><span class='image_loading'> </span><input type='submit' class='submit' value='<:bouton_enregistrer:>' /></p> |
||||
</div></form> |
||||
] |
||||
</div> |
@ -0,0 +1,135 @@
|
||||
<?php |
||||
|
||||
/***************************************************************************\ |
||||
* SPIP, Systeme de publication pour l'internet * |
||||
* * |
||||
* Copyright (c) 2001-2010 * |
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
||||
* * |
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
||||
\***************************************************************************/ |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
include_spip('inc/presentation'); |
||||
|
||||
function formulaires_configurer_relayeur_charger_dist(){ |
||||
$valeurs = array( |
||||
'http_proxy' => no_password_proxy_url($GLOBALS['meta']['http_proxy']), |
||||
'http_noproxy' => $GLOBALS['meta']['http_noproxy'], |
||||
'test_proxy' => 'http://www.spip.net/', |
||||
); |
||||
|
||||
return $valeurs; |
||||
} |
||||
|
||||
function formulaires_configurer_relayeur_verifier_dist(){ |
||||
$erreurs = array(); |
||||
$http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), $GLOBALS['meta']['http_proxy']); |
||||
$http_noproxy = _request('http_noproxy'); |
||||
|
||||
if ($http_proxy AND !preg_match(",https?://,", $http_proxy)){ |
||||
$erreurs['http_proxy'] = _L('format_proxy_incorrect'); |
||||
} |
||||
|
||||
if (!isset($erreurs['http_proxy']) AND _request('tester_proxy')) { |
||||
if (!$http_proxy) |
||||
$erreurs['http_proxy'] = _T('info_obligatoire'); |
||||
else { |
||||
include_spip('inc/distant'); |
||||
$test_proxy = _request('test_proxy'); |
||||
$t = parse_url($test_proxy); |
||||
if (!@$t['host']) { |
||||
$erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
||||
} |
||||
else { |
||||
include_spip('inc/texte'); // pour aide, couper, lang |
||||
$info = ""; |
||||
if (!need_proxy($t['host'],$http_proxy,$http_noproxy)) |
||||
$info = "<strong>"._T('page_pas_proxy')."</strong><br />"; |
||||
|
||||
// il faut fausser le proxy actuel pour faire le test ! |
||||
$cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
||||
$cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
||||
$GLOBALS['meta']['http_proxy'] = $http_proxy; |
||||
$GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
||||
$page = recuperer_page($test_proxy, true); |
||||
$GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
||||
$GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
||||
if ($page) { |
||||
$erreurs['message_ok'] = _T('info_proxy_ok')."<br />$info\n<tt>".couper(entites_html($page),300)."</tt>"; |
||||
} |
||||
else { |
||||
$erreurs['message_erreur'] = $info._T('info_impossible_lire_page', array('test_proxy' => "<tt>$test_proxy</tt>")) |
||||
. " <b><tt>".no_password_proxy_url($http_proxy)."</tt></b>." |
||||
. aide('confhttpproxy'); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
return $erreurs; |
||||
} |
||||
|
||||
function formulaires_configurer_relayeur_traiter_dist(){ |
||||
$res = array('editable'=>true); |
||||
|
||||
$http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), $GLOBALS['meta']['http_proxy']); |
||||
$http_noproxy = _request('http_noproxy'); |
||||
if ($http_proxy !== NULL) |
||||
ecrire_meta('http_proxy', $http_proxy); |
||||
|
||||
if ($http_noproxy !== NULL) |
||||
ecrire_meta('http_noproxy', $http_noproxy); |
||||
|
||||
$res['message_ok'] = _T('config_info_enregistree'); |
||||
return $res; |
||||
} |
||||
|
||||
function relayeur_saisie_ou_config($http_proxy, $default){ |
||||
// http_proxy : ne pas prendre en compte la modif si le password est '****' |
||||
if (preg_match(',:\*\*\*\*@,', $http_proxy)) |
||||
$http_proxy = $default; |
||||
return $http_proxy; |
||||
} |
||||
|
||||
// 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; |
||||
} |
||||
?> |
Loading…
Reference in new issue