178 lines
6.5 KiB
PHP
Executable File
178 lines
6.5 KiB
PHP
Executable File
<?php
|
|
include "psk.mondialRelay.php";
|
|
|
|
$localWsdl = __DIR__ . '/Web_Services.wsdl';
|
|
|
|
// Vérification ultime que le WSDL est bien formé
|
|
if (!file_exists($localWsdl)) {
|
|
die("Fichier Web_Services.wsdl introuvable ! Crée-le manuellement avec le WSDL complet.");
|
|
}
|
|
if (trim(file_get_contents($localWsdl)) === '' || strpos(file_get_contents($localWsdl), '<') !== 0) {
|
|
die("Le fichier Web_Services.wsdl est vide ou corrompu ! Recrée-le avec le vrai WSDL.");
|
|
}
|
|
|
|
$context = stream_context_create([
|
|
'ssl' => [
|
|
'verify_peer' => false,
|
|
'verify_peer_name' => false,
|
|
'allow_self_signed' => true
|
|
],
|
|
'http' => [
|
|
'method' => 'POST',
|
|
'header' => "Content-Type: text/xml; charset=utf-8\r\n",
|
|
'timeout' => 30
|
|
]
|
|
]);
|
|
|
|
$options = [
|
|
'location' => 'https://api.mondialrelay.com/Web_Services.asmx',
|
|
'uri' => 'http://www.mondialrelay.fr/webservice/',
|
|
'trace' => true,
|
|
'exceptions' => true,
|
|
'cache_wsdl' => WSDL_CACHE_NONE,
|
|
'stream_context' => $context,
|
|
'user_agent' => 'PHP-SOAP/' . phpversion()
|
|
];
|
|
|
|
try {
|
|
$client = new SoapClient($localWsdl, $options);
|
|
|
|
$client->__setSoapHeaders(new SoapHeader(
|
|
'http://www.mondialrelay.fr/webservice/',
|
|
'SOAPAction',
|
|
'http://www.mondialrelay.fr/webservice/WSI4_PointRelais_Recherche'
|
|
));
|
|
|
|
$params = [
|
|
'Enseigne' => $MR_WebSiteId,
|
|
'Pays' => 'FR',
|
|
'NumPointRelais' => '',
|
|
'Ville' => $_SESSION['villeLiv'] ?? '',
|
|
'CP' => $_SESSION['codePostLiv'] ?? '',
|
|
'Latitude' => '',
|
|
'Longitude' => '',
|
|
'Taille' => '',
|
|
'Poids' => '',
|
|
'Action' => '',
|
|
'DelaiEnvoi' => '0',
|
|
'RayonRecherche' => '20',
|
|
'TypeActivite' => '',
|
|
'NACE' => '',
|
|
'NombreResultats' => '20',
|
|
];
|
|
|
|
$params['Security'] = strtoupper(md5(implode('', $params) . $MR_WebSiteKey));
|
|
|
|
$result = $client->__soapCall('WSI4_PointRelais_Recherche', [$params]);
|
|
|
|
// echo "<pre style='background:#90EE90; padding:20px; font-size:16px;'>";
|
|
// echo "SUCCÈS ! Voici les points relais :\n\n";
|
|
// print_r($result);
|
|
// echo "</pre>";
|
|
|
|
} catch (SoapFault $e) {
|
|
echo "<pre style='background:#FFB6C1; padding:20px;'>";
|
|
echo "Erreur SOAP : " . $e->getMessage() . "\n\n";
|
|
echo "Request:\n" . htmlspecialchars($client->__getLastRequest()) . "\n\n";
|
|
echo "Response:\n" . htmlspecialchars($client->__getLastResponse());
|
|
echo "</pre>";
|
|
}
|
|
|
|
|
|
|
|
|
|
// === AFFICHAGE DES POINTS RELAIS (compatible WSI4) ===
|
|
$myVar = '<div class="msgPanier" style="background:lightblue; text-align:center; text-decoration:underline; grid-column:1 / span 2; display:block; max-width:100%; margin:auto; border-radius:12px; padding:15px;">Liste des points relais à 20km</div>';
|
|
|
|
if (!isset($result->WSI4_PointRelais_RechercheResult->PointsRelais->PointRelais_Details)) {
|
|
echo "<p>Aucun point relais trouvé.</p>";
|
|
return;
|
|
}
|
|
|
|
$liste = $result->WSI4_PointRelais_RechercheResult->PointsRelais->PointRelais_Details;
|
|
|
|
// Si un seul point relais → on le met dans un tableau
|
|
if (isset($liste->Num)) {
|
|
$liste = [$liste];
|
|
}
|
|
|
|
$a = 0;
|
|
foreach ($liste as $pr) {
|
|
$a++;
|
|
if ($a == 3) $a = 1;
|
|
|
|
$Num = $pr->Num ?? '';
|
|
$LgAdr1 = $pr->LgAdr1 ?? '';
|
|
$LgAdr2 = $pr->LgAdr2 ?? '';
|
|
$LgAdr3 = $pr->LgAdr3 ?? '';
|
|
$LgAdr4 = $pr->LgAdr4 ?? '';
|
|
$CP = $pr->CP ?? '';
|
|
$Ville = $pr->Ville ?? '';
|
|
$Pays = $pr->Pays ?? '';
|
|
$Localisation1 = $pr->Localisation1 ?? '';
|
|
$Distance = $pr->Distance ?? '';
|
|
$URL_Photo = $pr->URL_Photo ?? '';
|
|
|
|
$myVar .= '<div id="zoneMR" style="grid-column:' . $a . '; padding:8px; display:flex; flex-direction:column; text-align:left; width:98%; border:1px solid grey; border-radius:3px; margin:5px;">';
|
|
|
|
// Photo + Nom + Adresse principale
|
|
if ($URL_Photo) {
|
|
// $myVar .= '<img src="' . htmlspecialchars($URL_Photo) . '" style="max-width:100%; height:auto; border-radius:4px; margin-bottom:8px;">';
|
|
|
|
// On force le passage par notre proxy maison
|
|
$proxyUrl = str_replace(
|
|
'https://ww2.mondialrelay.com',
|
|
'/mr-photo', // ← ton chemin proxy
|
|
$URL_Photo
|
|
);
|
|
$myVar .= '<img src="' . htmlspecialchars($proxyUrl) . '" style="max-width:200px; height:auto; border-radius:12px; margin-bottom:8px;" loading="lazy">';
|
|
|
|
}
|
|
$myVar .= '<span class="libPanier" style="padding-left:0;">• ' . htmlspecialchars($LgAdr1) . '</span><br>';
|
|
|
|
// Adresses secondaires
|
|
foreach ([$LgAdr2, $LgAdr3, $LgAdr4] as $adr) {
|
|
if ($adr) {
|
|
$myVar .= '<span class="champsPanier" style="font-size:0.9em;">' . htmlspecialchars($adr) . '</span><br>';
|
|
}
|
|
}
|
|
|
|
// CP + Ville
|
|
$myVar .= '<span class="champsPanier" style="font-size:0.9em;">' . htmlspecialchars($CP) . ' ' . htmlspecialchars($Ville) . '</span><br>';
|
|
|
|
// Localisation + Distance
|
|
if ($Localisation1) {
|
|
$myVar .= '<span class="champsPanier" style="font-size:0.9em;">' . htmlspecialchars($Localisation1) . '</span><br>';
|
|
}
|
|
if ($Distance) {
|
|
$myVar .= '<span style="font-size:0.9em; color:#0066cc;"><b>≈ ' . round($Distance/1000, 1) . ' km</b></span><br>';
|
|
}
|
|
|
|
// Horaires (uniquement les jours avec ouverture)
|
|
$jours = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];
|
|
$horairesAffiches = false;
|
|
foreach ($jours as $jour) {
|
|
$champ = 'Horaires_' . $jour;
|
|
if (isset($pr->$champ->string) && is_array($pr->$champ->string)) {
|
|
$h = $pr->$champ->string;
|
|
if (count($h) >= 2 && $h[0] && $h[1]) {
|
|
$ouvert = substr($h[0], 0, 2) . 'h' . substr($h[0], 2) . ' - ' . substr($h[1], 0, 2) . 'h' . substr($h[1], 2);
|
|
$myVar .= '<span style="font-size:0.85em;">' . $jour . ' : ' . $ouvert . '</span><br>';
|
|
$horairesAffiches = true;
|
|
}
|
|
}
|
|
}
|
|
if (!$horairesAffiches) {
|
|
$myVar .= '<span style="font-size:0.85em; color:#888;">Horaires non disponibles</span><br>';
|
|
}
|
|
|
|
// Bouton radio
|
|
$checked = (!empty($idPointRelais) && $idPointRelais == $Num) ? 'checked' : '';
|
|
$myVar .= '<br><input type="radio" onChange="majPointRelais(this.value);" name="mondialRelay" value="' . $Num . '" id="Num' . $Num . '" ' . $checked . '>';
|
|
$myVar .= '<label for="Num' . $Num . '"><b> Choisir ce point relais</b></label>';
|
|
|
|
$myVar .= '</div>';
|
|
}
|
|
|
|
echo $myVar;
|
|
?>
|