From 5d3d175654a0d8b234617ef56b31e436f345d778 Mon Sep 17 00:00:00 2001 From: pacomte-Paris1 Date: Thu, 6 Feb 2025 10:52:26 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20du=20WS=20AgentWS.php=20dans?= =?UTF-8?q?=20un=20dossier=20ws=5Fpublic=20D=C3=A9claration=20de=20la=20co?= =?UTF-8?q?nstante=20G2T=5FWS=5FPUBLIC=5FURL=20dans=20le=20fichier=20de=20?= =?UTF-8?q?configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config_exemple.php | 2 + html/class/fonctions.php | 64 +++++++++++++++++++++++++++++ html/gestion_periodeobligatoire.php | 10 ++--- html/index.php | 2 +- {ws => ws_public}/agentWS.php | 0 5 files changed, 72 insertions(+), 6 deletions(-) rename {ws => ws_public}/agentWS.php (100%) diff --git a/config/config_exemple.php b/config/config_exemple.php index 820a045..e211b0b 100644 --- a/config/config_exemple.php +++ b/config/config_exemple.php @@ -2,6 +2,8 @@ // URL d'accès aux WS G2T define('G2T_WS_URL', "http://host_name:port/webservice_folder"); +// URL d'accès aux WS public G2T +define('G2T_WS_PUBLIC_URL', 'http://host_name:port/webservice_public_folder'); // URL d'accès à G2T define('G2T_URL', 'http://host_name:port/appli_folder'); // Défini le type d'environnement : diff --git a/html/class/fonctions.php b/html/class/fonctions.php index 8f9bd4d..2fdc441 100644 --- a/html/class/fonctions.php +++ b/html/class/fonctions.php @@ -2001,6 +2001,70 @@ public function get_g2t_ws_url() return $g2t_ws_url; } + public function get_g2t_ws_public_url() + { + if (defined('G2T_WS_PUBLIC_URL')) /* A partir de la version 7.1.9 de G2T, la constante est forcément déclarée ==> Donc on devrait passer systématiquement ici */ + { + $g2t_ws_url = G2T_WS_PUBLIC_URL; + // error_log(basename(__FILE__) . $this->stripAccents(" L'URL de base des WS G2T est récupérée de la constante => $g2t_ws_url" )); + } + else if (!isset($_SERVER['SERVER_NAME'])) /* Si on passe là, on a un problème car la constante n'est pas défini et on n'a aucun moyen de calculer l'URL du WS!! */ + { + $g2t_ws_url = "URL invalide !"; + error_log(basename(__FILE__) . $this->stripAccents(" L'URL de base des WS G2T n'est pas dans la constante et impossible de calculer l'URL => $g2t_ws_url" )); + } + else + { + error_log(basename(__FILE__) . $this->stripAccents(" L'URL de base des WS G2T va être calculée" )); + // On récuère le nom du serveur G2T + $servername = $_SERVER['SERVER_NAME']; + + + // Si on passe par un proxy ==> HTTP_X_FORWARDED_PROTO est défini dans le header (protocole utilisé entre le client et le proxy) + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) + { + $serverprotocol = $_SERVER['HTTP_X_FORWARDED_PROTO']; + } + // Si la requète vient directement sur le serveur, on regarde si $_SERVER['HTTPS'] est défini + else if (isset($_SERVER['HTTPS'])) + { + $serverprotocol = "https"; + } + // Sinon c'est de l'HTTP + else + { + $serverprotocol = "http"; + } + + //Si on passe par un proxy => HTTP_X_FORWARDED_PORT est défini dans le header (port utilisé entre le client et le proxy) + if (isset($_SERVER['HTTP_X_FORWARDED_PORT'])) + { + $serverport = $_SERVER['HTTP_X_FORWARDED_PORT']; + } + // Si la requête vient directement sur le serveur, on regarde si $_SERVER['SERVER_PORT'] est défini + else if (isset($_SERVER['SERVER_PORT'])) + { + // Le port pour parler au serveur est contenu dans la variable + $serverport = $_SERVER['SERVER_PORT']; + } + // Si le protocole est en https => Le port par défaut est 443 + else if ($serverprotocol == "https") + { + $serverport = "443"; + } + // Si c'est de l'HTTP ou si on n'a aucune information => Le port par défaut est 80 + else + { + $serverport = "80"; + } + + //echo "serverprotocol = $serverprotocol servername = $servername serverport = $serverport
"; + $g2t_ws_url = $serverprotocol . "://" . $servername . ":" . $serverport.'/ws_public'; + error_log(basename(__FILE__) . $this->stripAccents(" L'URL de base des WS G2T est => $g2t_ws_url" )); + } + return $g2t_ws_url; + } + public function get_alimCET_liste($typeconges, $listStatuts = array(), $forcesynchro = true) // $typeconges de la forme annYY { $full_g2t_ws_url = $this->get_g2t_ws_url() . "/alimentationWS.php"; diff --git a/html/gestion_periodeobligatoire.php b/html/gestion_periodeobligatoire.php index 79eca5b..1172e7e 100644 --- a/html/gestion_periodeobligatoire.php +++ b/html/gestion_periodeobligatoire.php @@ -449,7 +449,7 @@ function sendmail_global() function sendmail_struct(structid) { //console.log('sendmail_struct => ' + structid); - //var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + //var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; var currenttab = document.getElementById(structid); if (currenttab) @@ -489,7 +489,7 @@ function sendmail_struct(structid) function sendmail_agent(button) { //console.log('sendmail_struct => ' + structid); - var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; var currentbutton = button; var currenttr = currentbutton.closest("tr"); @@ -563,7 +563,7 @@ function poserconges_global() function poserconges_struct(structid) { //console.log('sendmail_struct => ' + structid); - //var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + //var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; var currenttab = document.getElementById(structid); if (currenttab) @@ -603,7 +603,7 @@ function poserconges_struct(structid) function poserconges_agent(button) { //console.log('poserconges_agent => ' + button.id); - var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; var currentbutton = button; var currenttr = currentbutton.closest("tr"); @@ -700,7 +700,7 @@ function poserconges_agent(button) function modifieperiode(selectobject, agentid, periodeid) { - var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; var currentindx = selectobject.selectedIndex; var optionvalue = selectobject.options[currentindx].value; diff --git a/html/index.php b/html/index.php index dac73fb..880afb7 100644 --- a/html/index.php +++ b/html/index.php @@ -434,7 +434,7 @@ function AppelWSAgent(display_flag) { - var fullWSURL = "get_g2t_ws_url() ?>/agentWS.php"; + var fullWSURL = "get_g2t_ws_public_url() ?>/agentWS.php"; $.post(fullWSURL , { methode : "", agentid: agentid(); ?>, display: display_flag }) .done(function( data ) { if (data.status.toUpperCase()=='OK') diff --git a/ws/agentWS.php b/ws_public/agentWS.php similarity index 100% rename from ws/agentWS.php rename to ws_public/agentWS.php