Skip to content
Extraits de code Groupes Projets
Valider d6d7731b rédigé par cerdic's avatar cerdic
Parcourir les fichiers

#FORMULAIRE_CONFIGURER_RELAYEUR remplace configuration/relayeur

parent 89e5158c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,7 +9,6 @@ ecrire/action/changer_mode_document.php -text
ecrire/action/charger_plugin.php -text
ecrire/action/configuration.php -text
ecrire/action/configurer_moderniseur_html.php -text
ecrire/action/configurer_relayeur.php -text
ecrire/action/confirmer_email.php -text
ecrire/action/converser.php -text
ecrire/action/copier_local.php -text
......@@ -73,7 +72,6 @@ ecrire/charsets/translit.php -text
ecrire/charsets/translitcomplexe.php -text
ecrire/configuration/index.php -text
ecrire/configuration/moderniseur_html.php -text
ecrire/configuration/relayeur.php -text
ecrire/core.xml -text
ecrire/exec/403.php -text
ecrire/exec/404.php -text
......@@ -375,6 +373,8 @@ prive/formulaires/configurer_redacteurs.html -text
prive/formulaires/configurer_redacteurs.php -text
prive/formulaires/configurer_reducteur.html -text
prive/formulaires/configurer_reducteur.php -text
prive/formulaires/configurer_relayeur.html -text
prive/formulaires/configurer_relayeur.php -text
prive/formulaires/configurer_rubriques.html -text
prive/formulaires/configurer_rubriques.php -text
prive/formulaires/configurer_transcodeur.html -text
......
<?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);
}
?>
......@@ -530,11 +530,21 @@ function recuperer_infos_distantes($source, $max=0, $charger_si_petite_image = t
}
// http://doc.spip.org/@need_proxy
function need_proxy($host)
{
$http_proxy = @$GLOBALS['meta']["http_proxy"];
$http_noproxy = @$GLOBALS['meta']["http_noproxy"];
/**
* Tester si un host peut etre recuperer directement ou doit passer par un proxy
* on peut passer en parametre le proxy et la liste des host exclus,
* pour les besoins des tests, lors de la configuration
*
* @param string $host
* @param string $http_proxy
* @param string $http_noproxy
* @return string
*/
function need_proxy($host, $http_proxy=null,$http_noproxy=null){
if (is_null($http_proxy))
$http_proxy = @$GLOBALS['meta']["http_proxy"];
if (is_null($http_noproxy))
$http_noproxy = @$GLOBALS['meta']["http_noproxy"];
$domain = substr($host,strpos($host,'.'));
......
<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'>&nbsp;</span><input type='submit' class='submit' value='<:bouton_enregistrer:>' /></p>
</div></form>
]
</div>
\ No newline at end of file
......@@ -11,101 +11,89 @@
\***************************************************************************/
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);
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');
}
}
$submit = array('valider_proxy' => _T('bouton_valider'),
'tester_proxy' => _T('bouton_test_proxy'));
}
}
return $erreurs;
}
function formulaires_configurer_relayeur_traiter_dist(){
$res = array('editable'=>true);
$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);
$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 configuration_relayeur_post ($http_proxy, $http_noproxy, $test_proxy, $tester_proxy)
{
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 = $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;
$http_proxy = $default;
return $http_proxy;
}
// Function glue_url : le pendant de parse_url
// Function glue_url : le pendant de parse_url
// http://doc.spip.org/@glue_url
function glue_url ($url){
if (!is_array($url)){
......@@ -144,4 +132,4 @@ function no_password_proxy_url($http_proxy) {
}
return $http_proxy;
}
?>
?>
\ No newline at end of file
......@@ -13,15 +13,17 @@
#FORMULAIRE_CONFIGURER_PREVISUALISEUR
</div>
<div class="ajax">
#FORMULAIRE_CONFIGURER_RELAYEUR
</div>
<?php
include_spip('inc/presentation');
$relayeur = charger_fonction('relayeur', 'configuration');
$moderniseur_html = charger_fonction('moderniseur_html', 'configuration');
echo
$relayeur(_request('retour_proxy')), // Proxy pour syndication & doc
$moderniseur_html(), // Selection de la version max de HTML (4 ou 5)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter