Aide pour passerelle ubiflow

Fermé
jetrouvetous - Modifié le 3 mai 2022 à 21:20
jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 - 5 mai 2022 à 08:00
Bonjour,

je me permet de vous faire la demande d'aide pour m'aider a configurer ma passerelle ubiflow pour pouvoir afficher correctement les annonces .

Voici mon site pour un premier aperçue mon site [url supprimée par la modération] .

Merci d'avance de m'avoir lue .

Cordialement

Configuration: Windows / Chrome 100.0.4896.127

8 réponses

jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 4 689
3 mai 2022 à 21:18
Bonjour
Qu'as tu essayé ?
Sur quoi bloques tu ?

A savoir qu'ubiflow dispose de documentation assez détaillée ... et d'un suport technique qui peut te venir en aide.

PS: Le lien vers ton site ne nous est pas utile à l'heure actuelle. Je le supprime de la discussion.
0
jetrouvetous
3 mai 2022 à 22:00
Bonsoir, merci de votre réponse.
J'ai déjà la passerelle d'origine a mon cms mais je n'arrive pas a mettre les tous les tags du xml.
J'en est que quelque uns qui s'affiche.
Cordialement
0
jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 4 689
4 mai 2022 à 00:00
Qu'as tu fais exactement ?
Sur quoi bloques tu précisément ?
Quel code as tu écrit ?
A quoi ressemble le xml ?
Quel cms as tu utilisé pour créer ton site ?
As tu regardé la doc d'ubiflow ?
As tu contacté leur support ?
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022 > jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024
4 mai 2022 à 18:23
Bonsoir je n'arrive pas a poster a chaque fois sa me noter "Corps du message vide " je ne comprend pas
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022 > jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
4 mai 2022 à 18:40
Comment je peut partager ma page en php le code doit etre trop gros il ne veut pas s'afficher
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
Modifié le 4 mai 2022 à 19:21
et de mon deuxieme xml :
<coordonnees>
<nom>AGENCE IMMOBILIERE SOVIMO</nom>
<raison_sociale>SARL</raison_sociale>
<adresse>
<voirie>3 place de la liberté</voirie>
<code_postal>16500</code_postal>
<ville>Confolens</ville>
<pays>France</pays>
</adresse>
<telephone>05 45 85 45 65</telephone>
<fax/>
<email>ag160120@contact-manager.net</email>
<web>http://www.sovimo-immobilier-confolens.fr</web>
<siret>41167822000038</siret>
<logo>https://common.ubiflow.net/images/logos/160120.jpg?ts=1636975489</logo>
<lien_tarifs>https://www.canva.com/design/DAEvWOWvPho/share/preview?token=NNt668JsfkSiaQaxf_vbiA&role=EDITOR&utm_content=DAEvWOWvPho&utm_campaign=designshare&utm_medium=link&utm_source=sharebutton</lien_tarifs>
</coordonnees>
<annonce id="340641789">
<reference>33571</reference>
<titre>A LOUER : Confolens, centre ville, Rez de chaussée Studio</titre>
<titre_anglais>Confolens, TO RENT : Ground floor Studio ...</titre_anglais>
<titre_fr>A LOUER : Confolens, centre ville, Rez de chaussée Studio</titre_fr>
<texte>REF. 33571 : Confolens, centre ville, Rez de chaussée Studio, 31,29 m2 habitable, LIBRE le 1er juillet : Cuisine/séjour/chambre, Salle de bain/wc, Chauffage électrique. APPT NON MEUBLE : Loyer hors charge : 190 euros par mois + Charges : 40 euros par mois (régularisation annuelle), LOYER CHARGES COMPRISES : 230 EUR - Dépôt de garantie : 190 euros (1 mois de loyer) Honoraires agences charge locataire : 148.20 euros ttc. Nota : état des lieux rédigé par le propriétaire (gratuit), en l'absence de la propriétaire, prévoir : 47 EUR TTC charge locataire</texte>
<texte_anglais>REF. 33571: Confolens, to rent : Ground floor Studio free, 31,29 sqm : kitchen / living / bedroom, bathroom / wc. Electric heating. Unfurnished flat Rental amount : 190 euros per month + standing charges 40 euros per month (annual adjustment) - RENTAL AMOUNT CHARGES INCLUDED : 230 euros - Deposit : 190 euros - Agency fees to the tenant's charge : 148.20 euros Inventory of fixtures to the tenant's charge : 47 euros</texte_anglais>
<texte_fr>REF. 33571 : Confolens, centre ville, Rez de chaussée Studio, 31,29 m2 habitable, LIBRE le 1er juillet : Cuisine/séjour/chambre, Salle de bain/wc, Chauffage électrique. APPT NON MEUBLE : Loyer hors charge : 190 euros par mois + Charges : 40 euros par mois (régularisation annuelle), LOYER CHARGES COMPRISES : 230 EUR - Dépôt de garantie : 190 euros (1 mois de loyer) Honoraires agences charge locataire : 148.20 euros ttc. Nota : état des lieux rédigé par le propriétaire (gratuit), en l'absence de la propriétaire, prévoir : 47 EUR TTC charge locataire</texte_fr>
<date_saisie>20/04/2022</date_saisie>
<date_integration>03/05/2022 23:47:48</date_integration>
<url_annonce_sur_site_annonceur>https://www.sovimo-immobilier-confolens.fr</url_annonce_sur_site_annonceur>
<contact_a_afficher>Sovimo Immobilier</contact_a_afficher>
<email_a_afficher>ag160120@contact-manager.net</email_a_afficher>
<telephone_a_afficher>05 45 85 45 65</telephone_a_afficher>
<url_tarifs_publics>https://www.sovimo-immobilier-confolens.fr</url_tarifs_publics>
<bien>
<code_type>1132</code_type>
<libelle_type>Studio</libelle_type>
<code_postal>16500</code_postal>
<communiquer_adresse_exacte>false</communiquer_adresse_exacte>
<adresse>9, place DE LA LIBERTE</adresse>
<latitude>46.014507294</latitude>
<longitude>0.666666985</longitude>
<ville>Confolens</ville>
<code_insee>16106</code_insee>
<departement>16</departement>
<pays code="FRA">France</pays>
<surface>31</surface>
<nb_pieces>1</nb_pieces>
<prestige>false</prestige>
<nb_chambres>1</nb_chambres>
<cuisine>sans cuisine</cuisine>
<nb_salles_de_bain>1</nb_salles_de_bain>
<meuble>false</meuble>
<balcon>false</balcon>
<jardin_privatif>false</jardin_privatif>
<surface_habitable>31.29</surface_habitable>
<avec_jardin>false</avec_jardin>
<type_cuisine>sans cuisine</type_cuisine>
<proche_commerces>true</proche_commerces>
<diagnostiques>
<soumis_dpe>false</soumis_dpe>
<dpe_vierge>false</dpe_vierge>
<dpe_date_realisation>15/10/2015</dpe_date_realisation>
<dpe_version>2011</dpe_version>
</diagnostiques>
<copropriete>false</copropriete>
</bien>
<prestation>
<type>L</type>
<mandat_numero>5060</mandat_numero>
<mandat_type>simple</mandat_type>
<mandat_est_semi_exclusif>false</mandat_est_semi_exclusif>
<mandat_date>01/04/2022</mandat_date>
<afficher_prix>true</afficher_prix>
<loyer>190</loyer>
<charges>40</charges>
<depot_garantie>190</depot_garantie>
<depot_garantie_nb_mois_loyer>1</depot_garantie_nb_mois_loyer>
<droit_bail>0</droit_bail>
<loyer_mensuel_cc>230</loyer_mensuel_cc>
<frais_agence>136.8</frais_agence>
<zone_encadrement_loyer>false</zone_encadrement_loyer>
<date_disponibilite>01/07/2022</date_disponibilite>
<environnement>centre ville</environnement>
<disponible_immediatement>false</disponible_immediatement>
<devise>EUR</devise>
</prestation>
<photos>
<photo>https://photos.ubiflow.net/160120/340641789/photos/1.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220420101139</photo>
<photo>https://photos.ubiflow.net/160120/340641789/photos/2.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220420101139</photo>
<photo>https://photos.ubiflow.net/160120/340641789/photos/3.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220420101139</photo>
</photos>
</annonce>
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
Modifié le 4 mai 2022 à 19:20
Voici une annonce de mon premier xml
<coordonnees>
          <nom>JT IMMO</nom>
  <raison_sociale>JT IMMO</raison_sociale>
  <adresse>
   <voirie>51 AVENUE DE LA MADELEINE</voirie>
   <code_postal>66330</code_postal>
   <ville>CABESTANY</ville>
   <pays>France</pays>
  </adresse>
  <telephone>04 68 67 93 77</telephone>
  <fax></fax>
  <email>jtimmo@power-immo.com</email>
  <web></web>
  <siret>82968853000015</siret>
  <logo></logo>
        <lien_tarifs></lien_tarifs>
 </coordonnees>
  <annonce id="339752949">
              <reference>715</reference>
            <titre>MAISON DE VILLAGE  EN R+2 AVEC TERRASSE</titre>
            <titre_allemand>MAISON DE VILLAGE  EN R+2 AVEC TERRASSE</titre_allemand>
            <titre_espagnol>MAISON DE VILLAGE  EN R+2 AVEC TERRASSE</titre_espagnol>
            <titre_fr>MAISON DE VILLAGE  EN R+2 AVEC TERRASSE</titre_fr>
            <texte>MAUREILLAS LAS ILLAS - Réf: S714 - Maison de village en R+2 avec terrasse vue dégagée - Hall d'entrée distribuant cuisine non équipée, WC et salle d'eau - Au 1er pièce de vie salon / séjour d'environ 30 m² coin évier. Au 2 ème : une chambre avec terrasse d'environ 10 m² avec vue dégagée -  Possibilité de combles en partie de la maison. Menuiserie double vitrage chauffage électrique et poêle fuel. Contacter Joël au 06.11.83.15.58 Agence JTIMMO by Joël "L'Agence proche de vous" 51 Av de la Madeleine 66330 Cabestany. DPE EN COURS.</texte>
            <texte_anglais>MAUREILLAS LAS ILLAS - Réf: S714 - Maison de village en R+ 2 avec terrasse vue dégagée. Hall d'entrée distribuant cuisine non équipée, wc et dalle d'eau - Au pièce de vie salon / séjour d'environ 30 m² coin évier. Au 2 éme une chambre avec terrasse  avec vue dégagée d'environ 10 m².  Possibilité de combles en partie de la maison. Menuiserie double vitrage chauffage électrique et poêle fuel. Contacter Joël au 06.11.83.15.58 Agence JTIMMO by Joël "L'Agence proche de vous" 51 Av de la Madeleine 66330 Cabestany. DPE EN COURS.</texte_anglais>
            <texte_allemand>MAUREILLAS LAS ILLAS - Réf: S714 - Maison de village en R+ 2 avec terrasse vue dégagée. Hall d'entrée distribuant cuisine non équipée, wc et dalle d'eau - Au pièce de vie salon / séjour d'environ 30 m² coin évier. Au 2 éme une chambre avec terrasse  avec vue dégagée d'environ 10 m².  Possibilité de combles en partie de la maison. Menuiserie double vitrage chauffage électrique et poêle fuel. Contacter Joël au 06.11.83.15.58 Agence JTIMMO by Joël "L'Agence proche de vous" 51 Av de la Madeleine 66330 Cabestany. DPE EN COURS.</texte_allemand>
            <texte_espagnol>MAUREILLAS LAS ILLAS - Réf: S714 - Maison de village en R+ 2 avec terrasse vue dégagée. Hall d'entrée distribuant cuisine non équipée, wc et dalle d'eau - Au pièce de vie salon / séjour d'environ 30 m² coin évier. Au 2 éme une chambre avec terrasse  avec vue dégagée d'environ 10 m².  Possibilité de combles en partie de la maison. Menuiserie double vitrage chauffage électrique et poêle fuel. Contacter Joël au 06.11.83.15.58 Agence JTIMMO by Joël "L'Agence proche de vous" 51 Av de la Madeleine 66330 Cabestany. DPE EN COURS.</texte_espagnol>
            <texte_fr>MAUREILLAS LAS ILLAS - Réf: S714 - Maison de village en R+2 avec terrasse vue dégagée - Hall d'entrée distribuant cuisine non équipée, WC et salle d'eau - Au 1er pièce de vie salon / séjour d'environ 30 m² coin évier. Au 2 ème : une chambre avec terrasse d'environ 10 m² avec vue dégagée -  Possibilité de combles en partie de la maison. Menuiserie double vitrage chauffage électrique et poêle fuel. Contacter Joël au 06.11.83.15.58 Agence JTIMMO by Joël "L'Agence proche de vous" 51 Av de la Madeleine 66330 Cabestany. DPE EN COURS.</texte_fr>
            <date_saisie>27/12/2021</date_saisie>
            <date_integration>12/04/2022 07:55:51</date_integration>
            <url_annonce_sur_site_annonceur>https://v2.immo-facile.com/catalog/admin-v2/product_info.php?action=popup_agence&products_autorised=true&msites_id=&site=&msites_code=&cle=d3a287d8792ee94ac4be7c15fb4e625e&products_id=48457616&show_price=1</url_annonce_sur_site_annonceur>
            <contact_a_afficher>JT IMMO</contact_a_afficher>
            <email_a_afficher>jtimmo@power-immo.com</email_a_afficher>
            <telephone_a_afficher>04 68 67 93 77</telephone_a_afficher>
            <url_tarifs_publics>https://media.immo-facile.com/segments/immo/catalog/images/manufacturers_bareme/307976.pdf</url_tarifs_publics>
            <affichage_privilegie>false</affichage_privilegie>
   <bien>
                <code_type>1214</code_type>
                <libelle_type>Maison de village</libelle_type>
                <code_postal>66480</code_postal>
                <communiquer_adresse_exacte>false</communiquer_adresse_exacte>
                <latitude>42.490082</latitude>
                <longitude>2.807331</longitude>
                <ville>Maureillas Las Illas</ville>
                <code_insee >66106</code_insee>
                <departement>66</departement>
                <pays code="FRA">France</pays>
                <surface>70</surface>
                <nb_pieces>3</nb_pieces>
                <taxe_fonciere>537</taxe_fonciere>
                <piscine>false</piscine>
                <nb_chambres>2</nb_chambres>
                <grenier>non</grenier>
                <meuble>false</meuble>
                <veranda>false</veranda>
                <jardin_privatif>false</jardin_privatif>
                <surface_habitable>70</surface_habitable>
                <nb_etages>2</nb_etages>
                <lotissement>false</lotissement>
                <ascenseur>false</ascenseur>
                <nb_niveaux>1</nb_niveaux>
                <sous_sol>false</sous_sol>
                <gardien>false</gardien>
                <avec_jardin>false</avec_jardin>
                <vue_sur_mer>false</vue_sur_mer>
                <acces_handicapes>false</acces_handicapes>
                <proche_aeroport>false</proche_aeroport>
                <proche_bus>false</proche_bus>
                <proche_commerces>false</proche_commerces>
                <proche_gare>false</proche_gare>
                <proche_sortie_autoroute>false</proche_sortie_autoroute>
                <proche_tram>false</proche_tram>
                <diagnostiques>
                    <dpe_vierge>false</dpe_vierge>
    </diagnostiques>
    <copropriete>false</copropriete>
   </bien>
   <prestation>
    <type>V</type>
        <mandat_numero>715</mandat_numero>
    <mandat_type>simple</mandat_type>
    <mandat_libelle>Simple</mandat_libelle>
    <mandat_est_semi_exclusif>false</mandat_est_semi_exclusif>
    <mandat_date>11/04/2022</mandat_date>
    <mandat_echeance>11/04/2023</mandat_echeance>
    <afficher_prix>true</afficher_prix>
    <prix>80000</prix>
        <honoraires_payeurs>vendeur</honoraires_payeurs>
        <prix_hors_honoraires>80000</prix_hors_honoraires>
        <honoraires_charge_vendeur>true</honoraires_charge_vendeur>
        <honoraires_charge_acquereur>false</honoraires_charge_acquereur>
                <devise>EUR</devise>
   </prestation>
   <photos>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/1.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/2.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/3.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/4.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/5.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/6.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/7.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/8.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/9.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/10.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
    <photo>https://photos.ubiflow.net/661433/339752949/photos/11.jpg?DIFFUSION_PRIVEE_AGENCE_3831160849_20220412075551</photo>
   </photos>
 </annonce></
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
Modifié le 4 mai 2022 à 19:20
Et mon fichier html qui affiche les tags:
{{photo}} {{photos}} {{photo_a_afficher}} {{photos_a_afficher}}
{{prix}}
==== Référence ====
Référence annonce:{{reference}} 
==== Coordonnées ====
{{coordonnees}}
{{username}} 
{{adresse}}  {{voirie}} {{code_postal}}  {{ville}} {{pays}}
{{adresse}} {{voirie}} 
{{code_postal}} {{ville}} {{pays}}
==== Contact ====
Email:{{email_a_afficher}} 
Téléphone:{{telephone_a_afficher}} 
==== Prix ====
Prix: {{prix_a_afficher}} {{price}} {{prix_marchand}} {{prix}}
==== Descriptions ====
{{observations}} 
{{equipements}}
{{titre}} 
{{texte}}
{{logo}}
 {{lien}}
 {{date_saisie}} 
 {{date_integration}} 
{{url_annonce_sur_site_annonceur}} 
{{contact_a_afficher}} 
{{url_tarifs_publics}} 
{{bien}} 
{{logo}} 
{{code_type}}
 {{libelle_type}}  
{{communiquer_adresse_exacte}} 
{{code_insee}} 
{{departement}} 
{{surface}} 
{{prestige}} 
{{raccorde}} 
{{viabilise}} 
{{type_cuisine}} 
{{proche_commerces}}
{{copropriete}} 
{{alur_pourcentage_honoraires_ttc}} 
{{prestation}} 
{{type}} 
{{mandat_numero}} 
{{mandat_type}} 
{{mandat_est_semi_exclusif}} 
{{mandat_date}} 
{{afficher_prix}} 
{{honoraires_payeurs}} 
{{prix_hors_honoraire}}
 {{honoraires_charge_vendeur}} 
{{honoraires_charge_acquereur}} 
{{pourcentage_honoraires_acquereur}} 
{{disponible_immediatement}} 
{{devise}} 
{{price}} 
{{type}} 
{{id}} 
{{priority}} 
{{currency}} 
{{creation_date}} 
{{username}}
{{user_type}}
 {{user_company}} 
 {{user_siret}}
 {{user_id}} 
 {{latlng}}
 {{medias}} 
{{video}}
 {{videos}}
 {{audio}} 
 {{audios}}
==== Diagnostiques ====
Diagnostiques: {{dpe_etiquette_conso}}  {{dpe_etiquette_ges}}  {{dpe_version}}
               {{energie}} {{emission_co2}} {{Classe énergie}}
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
Modifié le 4 mai 2022 à 19:19
Bonjour, merci de votre réponse.
Oui j'ai déjà contacter le support et le créateur de mon cms qui a fait la passerelle pour l'automobile et non pour l'immo .
Voici ma passerelle
<?php
// PHP7 READY
/******************************************************************************
  • ZADS GATEWAY FOR CARGEST
  • Note : need bootstrap0.php

*
  • @category CorePackage
  • @package ZADS
  • @author Patrice COHAUT <patrice.cohaut@gmail.com>
  • @copyright 2018 PATMISC
  • @version 8.0.9
                                                                                                                                                            • /


define('DB_MODE', 'pdo'); // both = create two db accesses (one with old mode and one with new mode)
require_once("bootstrap0_with_functions.php");
include_once('inc/API_client_lib.php');

define('INTRA_TOKEN' , '1234PPLUSSTT');

// call to this functionns from internal scripts
$thisIsValidInternalApiCall =false;
if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR'] ) {
$INTERNAL_CRON=true;
if ($_POST['token']==INTRA_TOKEN || $_POST['token']==INTRA_CALL_TOKEN) $thisIsValidInternalApiCall=true;
} else {
if ($_POST['token']==INTRA_CALL_TOKEN) $thisIsValidInternalApiCall=true;
}


if (isset($_POST['ubiflow'])) define('WHATS', 'ubiflow');
else if (isset($_POST['cargest'])) define('WHATS', 'cargest');
else if (isset($_POST['aycp'])) define('WHATS', 'aycp');
else define('WHATS', 'xml');

$is_cargest = (WHATS=="cargest") ? true : false ;
$is_ubiflow = (WHATS=="ubiflow") ? true : false ;
$is_import_xml = (WHATS=="xml") ? true : false ;

$is_aycp = (WHATS=="aycp") ? true : false ;
$is_aycp_v2 = (AYCP_VERSION=="2") ? true : false;


$t0=microtime(true);

if (isset($_POST[WHATS]) ) {


// general variables
$now= date( 'Y-m-d H:i:s', time());
$dest_path_from_root_user ='./uploads/user/';

$action = $_POST[WHATS] ;
$dbThisTable = '';

// authorized methods
$AUTHORIZED_METHODS=['parseXml', 'parseXmlAndAdd', 'deleteAllAds', 'deleteAllAdsAdmin', 'deleteAllUsersAdmin',"getKeys", "getStatus", "getLogs",
"setAdsStatusDeleted", "getUsers", "deleteAllLogs", "deleteLogs", "deleteSyndicLogs", 'getImage', 'sanitizeCatsMapList'];
if (!in_array($action,$AUTHORIZED_METHODS)) exit_with_error("method does not exist!");

$type = secure_var($_POST["type"]) ; if (!isset($_POST["type"])) $type="review";
$status = secure_var($_POST["forceflag"]) ;

/* check if user has the right to do so if ok => continue => else=> page is exited with a special message*/
// $curuser_is_admin=false;
// $user_details = check_userRights(WHAT, $action);


//common
$curuser_is_owner=false; $curuser_is_admin=false;
$curuserid = $_POST["curuserid"]+0 ; // SECURED
$userid = $_POST["userid"]+0 ; // SECURED

// check session details
$session_details = get_session_details($userid);

$curuser_id = $session_details['user_id'];
$curuser_is_admin = $session_details['is_admin'];

if ($thisIsValidInternalApiCall) $curuser_is_admin=true;

if( isset($_POST['userid']) ){
if ($userid==$curuser_id) $curuser_is_owner=true; // note : curuser_id is set by CHECK USER RIGHT function
}
// EBUG MODE


// identify selector
$what = secure_var($_POST["what"]) ; // SECURITY
$laction = secure_var($_POST["laction"]) ; // SECURITY
$id = $_POST["id"]+0 ;

// content
// TYPE : can be "REVIEW || COMMENT || CONVERSATION || QUESTION "

$title = secure_var($_POST["title"]) ;
$description = secure_var($_POST["description"]) ;
$adid = $_POST["adid"]+0 ;
$fromid = $_POST["fromid"]+0 ;

// to id can be an integer of a
$toid = (isset($_POST["toid"])) ? $_POST["toid"] : '0' ;


$metas = secure_var($_POST["metas"]) ;

// IP address are stored as INTEGERS for a better performance and check
// var_dump(ip2long('209.85.227.147'));
// var_dump(long2ip(3512066963));
$fromip =ip2long($_SERVER['REMOTE_ADDR']);
$toip=0; // we don't know it !

$nav=$_POST["nav"];
$sort=$_POST["sort"];
$sortoriginal = $sort;
$sort=explode("_",$sort);
$sort_dir = $sort[1];
$sort_by = $sort[0];


// filter
$faction = $_POST["faction"] ;
$fseverity = $_POST["fseverity"] ;
$fwhat = trim(secure_var($_POST["fwhat"]));
$search=trim(secure_var($_POST["search"])); // SECURITY
$ftime=trim(secure_var($_POST["ftime"])); // SECURED
$fuserid = $_POST["fuserid"]+0 ; // SECURED
$fadid = $_POST["fadid"]+0 ; // SECURED
$fstatus = secure_var($_POST["fstatus"]) ;
$ftype = secure_var($_POST["ftype"]) ;

$fdir=secure_var($_POST["fdir"]) ; // direction

$fcomid = secure_var($_POST["fcomid"]) ;
$focusid = secure_var($_POST["focusid"]) ;

// indicate this is an inline display area for a given ID
$inlinefor = $_POST["inlinefor"]+0 ; // SECURED
if ($action=="load" && $fadid) $inlinefor=$fadid;

$msg="";
$filter="";
$sql_sort="";
$sql_group="";
$success=true;
$view_mode ='';

$maxresults=0;


$noQuery= false;
$trace='';

$datas_for_email=array(); // will save all datas for email sending


// ---- get all KEYS
// -----------------------------------------------------------------------------
if ($action=="getKeys")
{
// if (!($curuser_is_admin)) exit_with_error('not authorized');

//take the fisrt XMl file and first item from the list
define('EXCLUDETN', true);
define('FILETYPEWHITELIST', '');
$files = ft_get_filelist('../cargest_repo/', 'type');

// ft_get_ext($files);
// $loglist = $files;

// take the first XML file :
if ($is_cargest){
$first=true;
foreach($files as $key => $file)
{
if ($file["type"]=="file" && $file['ext']=="xml" && $first){
$first=false;
$_filename_xml = $file['name'];
$_local_file_xml = CARGEST_FILES_DIR.$_filename_xml;
$xml=simplexml_load_file($_local_file_xml) or exit_with_error("Error: Cannot create object from ".$_local_file_xml);

$i=0;
$keysCollection=[];
foreach ($xml->annonce as $xml_vehicule){
$xml_vehicule = (array)$xml_vehicule;
foreach($xml_vehicule as $key => $value)
{
if ($i==0) $keysCollection[]=$key;
}
$i++;
}
}
}
}

if ($is_ubiflow){
$keysCollection = [
'reference'
,'titre'
,'texte'
,'data_saisie'
,'username'
,'email_a_afficher'
,'telephone_a_afficher'
,'equipements'
,'nom'
,'raison_sociale'
,'adresse', 'voirie', 'code_postal', 'ville', 'pays'
,'web'
,'fax'
,'siret'
,'logo'
,'titre'
,'lien_tarifs'
,'annonce id'
,'reference'
,'date_saisie'
,'url_annonce_sur_site_annonceur'
,'contact_a_afficher'
,'bien'
,'code_type'
,'libelle_type'
,'code_postal'
,'communiquer_adresse_exacte'
,'adresse'
,'latitude'
,'longitude'
,'departement'
, 'voirie'
, 'pays code'
, 'surface'
, 'prestige'
,'raccorde'
,'viabilise'
,'type_cuisine'
,'proche_commerces'
,'diagnostiques', 'dpe_vierge', 'dpe_version', 'soumis_dpe'
,'copropriete'
,'alur_pourcentage_honoraires_ttc'
,'prestation', 'type', 'mandat_numero', 'mandat_type', 'mandat_est_semi_exclusif', 'mandat_date'
,'afficher_prix'
,'dpe_etiquette_ges'
,'dpe_etiquette_conso'
,'prix_a_afficher'
,'prix'
,'price'
,'prix_marchand'
,'honoraires_payeurs'
,'prix_hors_honoraires'
,'honoraires_charge_vendeur'
, 'honoraires_charge_acquereur'
,'pourcentage_honoraires_acquereur'
, 'disponible_immediatement'
,'devise'
, 'marque', 'modele', 'version', 'energie', 'millesime', 'mise_en_circulation', 'kilometrage', 'kilometrage_garanti'
, 'couleur', 'puissance_reelle' , 'puissance_fiscale', 'boite_de_vitesse', 'nb_places', 'emission_co2'
];
}


if ($is_aycp){

$_local_file_xml = AYCP_IMPORT_URL;

// get the file directly (API call)
$res= simple_rest_client($_local_file_xml, 'GET');
if ($res['success']){
$xml = simplexml_load_string($res['response']);
} else exit_with_error("Error: Cannot create object from ".$_local_file_xml);

$total = count($xml->ad);
if ($is_aycp_v2) $total = count($xml->publisher);

if ($total==0) exit_with_error("Error: file is empty (no ads) : ".$_local_file_xml);

$i=0; $j=0;
$keysCollection=[];

if ($is_aycp_v2){
// --- version 2 ------
$keysCollection[]="_version2";

foreach ($xml->publisher as $xml_publisher){
$this_publisher = (array)$xml_publisher;
foreach ($xml_publisher->ad as $xml_vehicule){
$xml_vehicule = (array)$xml_vehicule;
foreach($xml_vehicule as $key => $value)
{
if ($i==0) $keysCollection[]=$key;
else break;
}
$i++;
}
$j++;
if ($j>0) break;
}

// echo json_encode( $xml->publisher);
// die();

} else {
// --- version 1 -------
$keysCollection[]="_version1";

foreach ($xml->ad as $xml_vehicule){
$xml_vehicule = (array)$xml_vehicule;
foreach($xml_vehicule as $key => $value)
{
if ($i==0) $keysCollection[]=$key;
}
$i++;
}
}

}

$loglist = $keysCollection;
}


// ---- get all USERS
// -----------------------------------------------------------------------------
// list all users with cargest enabled and file defined
if ($action=="getUsers")
{
if (!($curuser_is_admin)) exit_with_error('not authorized');

// force with current userid
if ($is_import_xml || $is_aycp){
$res[0] = array( "id"=> $curuserid, "status" => array("success" => true, "isuptodate" => false ));
}
else {
// loop though alml users and get their IDs and staus
$res = getUsers();
foreach ($res as $key => $user) {
$status = getStatus($user['id']);
$res[$key]['status'] = $status;
}
}

$loglist= $res;
$maxresults = count($res);
}


// --- get an image
// -----------------------------------------------------------------------------
if ($action=="getImage")
{

if (!($curuser_is_admin || $curuser_is_owner)) exit_with_error('not authorized');
$url= $_POST["url"];
$res = getImageFromUrl($url);
$loglist= $res;
$maxresults = count($res);
}


// check the synchroniztoin status for a given userid
// -----------------------------------------------------------------------------
if ($action=="getStatus")
{
if (!($curuser_is_admin || $curuser_is_owner)) exit_with_error('not authorized');
$res = getStatus($userid);
$loglist= $res;
$maxresults = count($res);
}


// check the synchroniztoin status for a given userid
// -----------------------------------------------------------------------------
if ($action=="getLogs")
{
if (!($curuser_is_admin || $curuser_is_owner)) exit_with_error('not authorized');
if (!$userid) exit_with_error('missing userid');
$USERID = (int)$userid;
$res = getLogs(" where `action` like 'parseXmlAndAdd' AND `what` like 'syn%' AND `whatid` = '$USERID' ");
$loglist= $res;
$maxresults = count($res);
}

// parse the XML file
// -----------------------------------------------------------------------------
if ($action=="parseXml" || $action=="parseXmlAndAdd")
{

if (!($curuser_is_admin || $curuser_is_owner)) exit_with_error('not authorized');
if (!$userid) exit_with_error('missing userid');

// link with the user
$USERID = (int)$userid;
if ($is_aycp && !CARGEST_USER_DETAILS_FROM_SOURCE ) $USERID = AYCP_DEFAULT_USERID;

// get elemnts from user and check is exist
$result000 = $dbb->get(DB_TABLE_USERS, '*' , " `id` = $USERID " );
if (!$result000) exit_with_error('this user does not exits');


$_filename_xml = $result000['syndicuserid'];
if (WHATS=="cargest") $_local_file_xml = CARGEST_FILES_DIR.$_filename_xml;
if (WHATS=="ubiflow") $_local_file_xml = preg_replace('/{{id}}/i', $_filename_xml,UBIFLOW_URL_FORMAT);
if ($is_import_xml) $_local_file_xml = XML_IMPORT_URL;
if ($is_aycp) $_local_file_xml = AYCP_IMPORT_URL;


// read CATALOGUE mapping
if (SYNDIC_CATS_MAP_URL !="") {
$general_cats_map = json_decode(file_get_contents(SYNDIC_CATS_MAP_URL),true);
}

// -- read the file
// -- case of cargest
if ($is_cargest){
// get the file from local repository (sent by FTP too it)
$xml=simplexml_load_file($_local_file_xml) or exit_with_error("Error: Cannot create object from ".$_local_file_xml);
$total = count($xml->annonce);
}

// -- case of others
if ($is_ubiflow || $is_import_xml || $is_aycp){
// get the file directly (API call)
$res= simple_rest_client($_local_file_xml, 'GET');

if ($res['success']){
$xml = simplexml_load_string($res['response']);
$total = count($xml->annonce);

if ($is_aycp) {
$total = count($xml->ad);
if ($is_aycp_v2) $total = count($xml->publisher);
}

} else exit_with_error("Error: Cannot create object from ".$_local_file_xml);

}


// -- parse the file
$parsedXml=array(); // will save all datas for email sending
$mainTagsToMap =array();
$secondaryTagsToMap=array();

if ($is_cargest){
$mainTagsToMap = [
'reference', 'marque', 'modele', 'version'
,'carrosserie', 'genre', 'energie', 'kilometrage','garantie','type_garantie'
,'prix'
,'prix_marchand'
,'equipements'
,'observations'
,'email'
,'tel'
,'raison_sociale'
,'couleur_ext','puissance_fiscale', 'puissance_din'
,'cylindree', 'mise_en_circulation', 'annee_mec'
,'energie', 'boite'
,'nbr_vitesse', 'nbr_portes', 'nbr_places'

];
$secondaryTagsToMap = array(
array( "key"=> 'carrosserie', "vfieldId" => 50 ) // type
,array( "key"=> 'marque', "vfieldId" => 29 ) // marque
,array( "key"=> 'annee_mec', "vfieldId" => 28 ) // année modéle
,array( "key"=> 'kilometrage', "vfieldId" => 14 ) // kilometrages
,array( "key"=> 'boite', "vfieldId" => 27 ) // boite vitesse
,array( "key"=> 'energie', "vfieldId" => 32 ) // energie
);
}


if ($is_ubiflow){
$mainTagsToMap = [
'reference'
,'titre'
,'texte'
,'data_saisie'
,'username'
,'email_a_afficher'
,'telephone_a_afficher'
,'equipements'
,'nom'
,'raison_sociale'
,'adresse', 'voirie', 'code_postal', 'ville', 'pays'
,'web'
,'fax_a_afficher'
,'siret'
,'logo'
,'titre'
,'lien_tarifs'
,'annonce id'
,'reference'
,'date_saisie'
,'url_annonce_sur_site_annonceur'
,'contact_a_afficher'
,'bien'
,'code_type'
,'libelle_type'
,'code_postal'
,'communiquer_adresse_exacte'
,'adresse'
,'latitude'
,'longitude'
,'departement'
, 'voirie'
, 'pays code'
, 'surface'
, 'prestige'
,'raccorde'
,'viabilise'
,'type_cuisine'
,'proche_commerces'
,'diagnostiques', 'dpe_vierge', 'dpe_version', 'soumis_dpe'
,'copropriete'
,'alur_pourcentage_honoraires_ttc'
,'prestation', 'type', 'mandat_numero', 'mandat_type', 'mandat_est_semi_exclusif', 'mandat_date'
,'afficher_prix'
,'dpe_etiquette_ges'
,'dpe_etiquette_conso'
,'prix_a_afficher'
,'prix_marchand'
,'prix'
,'honoraires_payeurs'
,'prix_hors_honoraires'
,'honoraires_charge_vendeur'
, 'honoraires_charge_acquereur'
,'pourcentage_honoraires_acquereur'
, 'disponible_immediatement'
,'devise'
, 'marque', 'modele', 'version', 'energie', 'millesime', 'mise_en_circulation', 'kilometrage', 'kilometrage_garanti'
, 'couleur', 'puissance_reelle' , 'puissance_fiscale', 'boite_de_vitesse', 'nb_places', 'emission_co2'
];
$secondaryTagsToMap = array(
array( "key"=> 'couleur', "vfieldId" => 50 ) // type
,array( "key"=> 'marque', "vfieldId" => 29 ) // marque
,array( "key"=> 'millesime', "vfieldId" => 28 ) // année modéle
,array( "key"=> 'kilometrage', "vfieldId" => 14 ) // kilometrages
,array( "key"=> 'boite_de_vitesse', "vfieldId" => 27 ) // boite vitesse
,array( "key"=> 'energie', "vfieldId" => 32 ) // energie
,array( "key"=> 'dpe_etiquette_conso', "vfieldId" => 20 ) // Classe énergie
,array( "key"=> 'Surface', "vfieldId" => 126 ) // Surface
,array( "key"=> 'dpe_etiquette_ges', "vfieldId" => 125 ) // GES
,array( "key"=> 'Piscine', "vfieldId" => 124 ) // Piscine
,array( "key"=> 'Piéces', "vfieldId" => 123 ) // Piéces
,array( "key"=> 'Surface', "vfieldId" => 13 ) // Surface
,array( "key"=> 'Piéces', "vfieldId" => 16 ) // Piéces
,array( "key"=> 'Type de bien', "vfieldId" => 17 ) // Type de bien
,array( "key"=> 'dpe_etiquette_ges', "vfieldId" => 21 ) // GES
,array( "key"=> 'Meublé', "vfieldId" => 22 ) // Meublé
,array( "key"=> 'Piscine', "vfieldId" => 23 ) // Piscine

);
}

if ($is_import_xml){
$mainTagsToMap = [
'id'
,'titre'
,'description'
,'cat_id', 'cat_desc'
,'type','type2', 'priority'
,'price', 'currency', 'price2'
,'creation_date', 'modification_date'
];
$secondaryTagsToMap = array();
}

if ($is_aycp) {

$mainTagsToMap = array(
'id'
,'titre'
,'content'
,'category', 'type'
,'url_pro'
,'price'
,'address', 'city', 'postcode', 'country_code'
,'phone', 'email'
,'publisher_type','publisher_name'
,'_publisher_details'
);


// champ id zads 9
// Essence|Diesel|GPL ou GNL|Electrique|Hybride|Autres
$translationTable['fuel'] = array(
1 => 'Diesel',
2 => 'Essence',
3 => 'Electrique',
4 => 'Hybride',
5 => 'GPL ou GNL',
6=> 'Autres'
);

//Manuelle|Automatique
$translationTable['transmission'] = array(
1 => 'Automatique',
2 => 'Manuelle'
);

// Meublé|Non Meublé
$translationTable['property_furnished'] = array(
0 => 'Non Meuble',
1 => 'Meuble'
);

//Maison|Appartement|Terrain|Location de vacances|Parking|Autre
$translationTable['property_type'] = array(
1 => 'Maison',
2 => 'Appartement',
3 => 'Parking',
4 => 'Bureaux',
5 => 'Commerce',
6 => 'Terrain',
7 => 'Autre'
);

//champ 132
//values: "Alarme - Antivol|Audio (Radio - CD)|Barres de toit|Peinture métallisée|Direction Assistée|Fermeture centralisée|Vitres électriques|Rétroviseurs électriques|Siège chauffant|Climatisation|Distribution Chaîne|Jantes ALU|Roue de secours|GPS|Toit ouvrant|Toit panoramique|Autres"




$secondaryTagsToMap = array(
// cars
array( "key"=> 'make', "vfieldId" => 29 ) // marque
,array( "key"=> 'model', "vfieldId" => 130 ) // modéle for car
,array( "key"=> 'year', "vfieldId" => 28 ) // année modéle
,array( "key"=> 'mileage', "vfieldId" => 14 ) // kilometrages
,array( "key"=> 'transmission', "vfieldId" => 27 , "translation" => true) // boite vitesse
,array( "key"=> 'fuel', "vfieldId" => 9, "translation" => true ) // energie

//boat
,array( "key"=> 'length', "vfieldId" => 65 ) // Longueur bateau




,array( "key"=> 'engine_size', "vfieldId" => 30 ) // engine=> inf cubic centimetres

// ,array( "key"=> 'accessory_type', "vfieldId" => 00 ) // only for spare parts

// Housing ads
,array( "key"=> 'property_energy_dpe', "vfieldId" => 20 ) // engine inf cubic centimetres
,array( "key"=> 'property_energy_ges', "vfieldId" => 21 ) // engine inf cubic centimetres
,array( "key"=> 'property_room', "vfieldId" => 16 ) // engine inf cubic centimetres
,array( "key"=> 'property_bedroom', "vfieldId" => 143 ) // engine inf cubic centimetres
,array( "key"=> 'property_sleepings', "vfieldId" => 145 ) // couchage
,array( "key"=> 'property_area', "vfieldId" => 13 ) // surface en M2

,array( "key"=> 'property_type', "vfieldId" => 17 ,"translation" => true ) // property type

,array( "key"=> 'property_furnished', "vfieldId" => 22, "translation" => true ) // engine inf cubic centimetres

// for land
,array( "key"=> 'property_constructible', "vfieldId" => 141, "type" => "bool" ) // constructible

// for parkings
,array( "key"=> 'property_covered', "vfieldId" => 142, "type" => "bool" ) // couvert ou non

// for rental
,array( "key"=> 'property_place', "vfieldId" => 144, "type" => "bool" ) // mer / montagne / ...


// shoes
,array( "key"=> 'size_feet', "vfieldId" => 26 ) // engine inf cubic centimetres

// // for Cat21,21,22
// ,array( "key"=> 'make', "vfieldId" => 135 ) // marque bateaux

);
}


// extract the keys :
$secondaryTagsToMapKeys=false;
foreach ($secondaryTagsToMap as $x => $tag) {
$secondaryTagsToMapKeys[] =$tag['key'];
}

// model for Title
$titleTagstoAssemble=CARGEST_TITLE_TEMPLATE;

$i=0;
$keysCollection=[];

// --- get the ad tag
if ($is_aycp){
if ($is_aycp_v2){
// --- preprocessing for V2 as ads are grouped by publishers
$ad_idx =0;
$all_aycp_publishers=[]; // in case of, saving all publishers

foreach ($xml->publisher as $xml_publisher){
$this_publisher = extract_aycp_publisher_details($xml_publisher);

$all_aycp_publishers[] = $this_publisher;
// $this_publisher = array("name"=>'test', "lastname"=>"test");

foreach ($xml_publisher->ad as $xml_vehicule){
$aycl_ads_preproc[$ad_idx] = (array)$xml_vehicule;
$aycl_ads_preproc[$ad_idx]['_publisher_details'] = $this_publisher;
$aycl_ads_preproc[$ad_idx]['_version'] = 2;
$ad_idx++;
}
}
$xml_ad = $aycl_ads_preproc;


} else {
$xml_ad = $xml->ad;
}
}
else $xml_ad = $xml->annonce;


// echo json_encode( $all_aycp_publishers);
// die();


// -- loop though each ads
foreach ($xml_ad as $xml_vehicule){
$xml_vehicule = (array)$xml_vehicule;

$parsedXml[$i]['id']= $i+1;

foreach($xml_vehicule as $key => $value)
{
if ($i==0) $keysCollection[]=$key;

// get the main tags
if (in_array($key,$mainTagsToMap) ){
if ($key=="_publisher_details") $parsedXml[$i]['primeKeys'][$key] = $value ; // this is an array
else $parsedXml[$i]['primeKeys'][$key] = (string)$value; // this to convert it to string
}

// get the secondary tags
if ($is_cargest || $is_aycp) if (in_array($key, $secondaryTagsToMapKeys)) $parsedXml[$i]['secondaryKeys'][$key] = (string) $value;

// special process for photos
if (!$is_import_xml && !$is_aycp) if (in_array($key, ["photos"])) $parsedXml[$i]['photos'] = implode('|photo|0;', (array)$value->photo);

} // end each key


if ($is_cargest){
// prix
$parsedXml[$i]['mainKeys']['price'] = (float)$parsedXml[$i]['primeKeys']['prix'];

// user details in case of overwrite
$parsedXml[$i]['mainKeys']['username'] = $parsedXml[$i]['primeKeys']['raison_sociale'];
$parsedXml[$i]['mainKeys']['phone'] = $parsedXml[$i]['primeKeys']['tel'];
$parsedXml[$i]['mainKeys']['phone'] = str_replace(' ', '', $parsedXml[$i]['mainKeys']['phone']); // remove tel white space
$parsedXml[$i]['mainKeys']['email'] = $parsedXml[$i]['primeKeys']['email'];

$parsedXml[$i]['mainKeys']['type2']="";
$parsedXml[$i]['mainKeys']['priority'] = "";

}



// special cases for Ubiflow
if ($is_ubiflow){
// prix
$parsedXml[$i]['mainKeys']['price'] = (string)$xml_vehicule['offre']->prix;

// secondary keys
foreach($xml_vehicule['vehicule'] as $key => $value){
if (in_array($key, $secondaryTagsToMapKeys)) $parsedXml[$i]['secondaryKeys'][$key] = (string) $value;
if (in_array($key, $mainTagsToMap)) $parsedXml[$i]['primeKeys'][$key] = (string) $value;
}

// user details in case of overwrite
$parsedXml[$i]['mainKeys']['phone'] = $parsedXml[$i]['primeKeys']['telephone_a_afficher'];
$parsedXml[$i]['mainKeys']['phone'] = str_replace(' ', '', $parsedXml[$i]['mainKeys']['phone']); // remove tel white space
$parsedXml[$i]['mainKeys']['email'] = $parsedXml[$i]['primeKeys']['email_a_afficher'];

$parsedXml[$i]['mainKeys']['type']="sell";


$parsedXml[$i]['mainKeys']['type2']="";
$parsedXml[$i]['mainKeys']['priority'] = "";
}


// --- case of XML import
if ($is_import_xml){

$parsedXml[$i]['primeKeys']['reference'] = $parsedXml[$i]['primeKeys']['id'];
$parsedXml[$i]['mainKeys']['phone'] = (string)$xml_vehicule['contact']->phone;
$parsedXml[$i]['mainKeys']['email'] = (string)$xml_vehicule['contact']->email;
$parsedXml[$i]['mainKeys']['username'] = (string)$xml_vehicule['contact']->username;

// photos which are in media section
$parsedXml[$i]['photos'] = implode('|photo|0;', (array)$xml_vehicule['medias']->photos->photo);

// check for location
$parsedXml[$i]['mainKeys']['loccity'] = (string)$xml_vehicule['location']->city;
$parsedXml[$i]['mainKeys']['loczipcode'] = (string)$xml_vehicule['location']->zipcode;
$parsedXml[$i]['mainKeys']['loclatlng'] = (string)$xml_vehicule['location']->latlng;

// user
$parsedXml[$i]['mainKeys']['user_type'] = (string)$xml_vehicule['user']->user_type;
$parsedXml[$i]['mainKeys']['user_company'] = (string)$xml_vehicule['user']->user_company;
$parsedXml[$i]['mainKeys']['user_siret'] = (string)$xml_vehicule['user']->user_siret;
$parsedXml[$i]['mainKeys']['user_id'] = (string)$xml_vehicule['user']->user_id;

// price
$parsedXml[$i]['mainKeys']['price'] = (string)$xml_vehicule['price'];
$parsedXml[$i]['mainKeys']['price2'] = (string)$xml_vehicule['price2'];

$parsedXml[$i]['mainKeys']['type2'] = (string)$xml_vehicule['type2'];
$parsedXml[$i]['mainKeys']['priority'] = (string)$xml_vehicule['priority'];

$parsedXml[$i]['mainKeys']['type']=(string)$xml_vehicule['type'];
$parsedXml[$i]['mainKeys']['quantity']=isset($xml_vehicule['quantity']) ? (int)$xml_vehicule['quantity'] : 1 ;

}


// --- case of XML import
if ($is_aycp){

$parsedXml[$i]['primeKeys']['reference'] = $parsedXml[$i]['primeKeys']['id'];
$parsedXml[$i]['mainKeys']['originurl'] = $parsedXml[$i]['primeKeys']['url_pro'];


// -- is present in V2 and V1
$parsedXml[$i]['mainKeys']['phone'] = $parsedXml[$i]['primeKeys']['phone'];
$parsedXml[$i]['mainKeys']['email'] = $parsedXml[$i]['primeKeys']['email'];


// publisher_type yes string Publisher_type :
// 1 = profesional
// 2 = individual
if ($is_aycp_v2){
$parsedXml[$i]['mainKeys']['username'] = (string)$parsedXml[$i]['primeKeys']['_publisher_details']['_contact']['nickname'];
$parsedXml[$i]['mainKeys']['usertype'] = (string)$parsedXml[$i]['primeKeys']['_publisher_details']['protype'];
$parsedXml[$i]['mainKeys']['_version'] = 2;
}
else {
$parsedXml[$i]['mainKeys']['username'] = $parsedXml[$i]['primeKeys']['publisher_name'];
$parsedXml[$i]['mainKeys']['usertype'] = (int)$parsedXml[$i]['primeKeys']['publisher_type']==1 ? "pro" : "par";
$parsedXml[$i]['mainKeys']['_version'] = 1;
}


// categorie
$parsedXml[$i]['mainKeys']['catid'] = $parsedXml[$i]['primeKeys']['category'];

// price details
$parsedXml[$i]['mainKeys']['pricecurrency'] = $parsedXml[$i]['primeKeys']['price']['unit'];

// Type of ad :
// 1 = offered
// 2 = wanted ad
// Default value = 1
$parsedXml[$i]['mainKeys']['type'] = $parsedXml[$i]['primeKeys']['type'] == 1 ? "sell" : "buy";
$parsedXml[$i]['mainKeys']['type2']="";
$parsedXml[$i]['mainKeys']['priority'] = "";


// location
$parsedXml[$i]['mainKeys']['loccity'] = $parsedXml[$i]['primeKeys']['city'];
$parsedXml[$i]['mainKeys']['loczipcode'] = $parsedXml[$i]['primeKeys']['postcode'];
$parsedXml[$i]['mainKeys']['location'] = $parsedXml[$i]['primeKeys']['address'];
$parsedXml[$i]['primeKeys']['location'] = $parsedXml[$i]['primeKeys']['address'];
$parsedXml[$i]['mainKeys']['loccountrycode'] = $parsedXml[$i]['primeKeys']['country_code'];

// price
$parsedXml[$i]['mainKeys']['price'] = $parsedXml[$i]['primeKeys']['price'];



// nex category
if ($general_cats_map) {
$res_cat = json_find_elem_by_field($general_cats_map, 'from_id', (int)$parsedXml[$i]['mainKeys']['catid']);
if ($res_cat) {
$parsedXml[$i]['mainKeys']['old_catid'] = (int)$parsedXml[$i]['mainKeys']['catid'];
$parsedXml[$i]['mainKeys']['catid'] = $res_cat['to_id'];
}
}



// photos which are in media section
// official in the doc
// <pictures>
// <picture>
// <picture_url><![CDATA[...]]></picture_url>
// <picture_title><![CDATA[...]]></picture_title>
// </picture>
// real in the flow
//<pictures>
//<picture_url><!https://www.allyoucanpost.com/uploads/ad/t2-46-m-avec-terrasse-et-parking-rue-barbacane-1590402855-1502166423.jpg' rel='noopener noreferrer ugc nofollow' target='_blank'>CDATAhttps://www.allyoucanpost.com/uploads/ad/t2-46-m-avec-terrasse-et-parking-rue-barbacane-1590402855-1502166423.jpg></picture_url>
$has_picture_format = $xml_vehicule['pictures']->picture ? true : false;

$bufferPicture=array(); $photodebug='';
if ( $has_picture_format ){
foreach ($xml_vehicule['pictures']->picture as $key => $elem) {
$bufferPicture[] = $elem->picture_url;
}
} else {
foreach ($xml_vehicule['pictures'] as $key => $elem) {
$bufferPicture[] = $elem;
}
}
$parsedXml[$i]['photos'] = implode('|photo|0;', $bufferPicture);
}

// --- create the tittle
$_title ="";

if ($is_cargest){
$_title = $titleTagstoAssemble;
if (preg_match_all("/{{(.*?)}}/", $titleTagstoAssemble,$m)) {
foreach ($m[1] as $j => $key) {
if ($parsedXml[$i]['primeKeys'][$key]) $_title = str_replace($m[0][$j],$parsedXml[$i]['primeKeys'][$key], $_title);
else $_title = str_replace($m[0][$j],'',$_title); // if key does not exists
}
}
}

if ($is_ubiflow){
$_title = (string)$xml_vehicule['titre'];
}


if ($is_import_xml || $is_aycp){
$_title = (string)html_entity_decode($xml_vehicule['title']);
}

$parsedXml[$i]['mainKeys']['title'] = $_title;


// --- create the description
// load the template file
$_description = '';
if ($is_cargest) $tpl_name = 'cargest_description_template.html';
if ($is_ubiflow) $tpl_name = 'ubiflow_description_template.html';
if ($is_import_xml || $is_aycp) $tpl_name = 'none.html';

$tpl_full_fqdn = CARGEST_TMPL_DIR.$tpl_name;
if (file_exists($tpl_full_fqdn)) {

$tpl_content = file_get_contents($tpl_full_fqdn);

$_description = $tpl_content;
if (preg_match_all("/{{(.*?)}}/", $tpl_content,$m)) {
foreach ($m[1] as $j => $key) {
if ($parsedXml[$i]['primeKeys'][$key]) $_description = str_replace($m[0][$j], $parsedXml[$i]['primeKeys'][$key], $_description);
else $_description = str_replace($m[0][$j], '',$_description); // if key does not exists
}
}
} else {

if ($is_cargest) $_description = (string)$xml_vehicule['equipements'];
if ($is_ubiflow) $_description = (string)$xml_vehicule['texte'];
if ($is_import_xml) $_description = (string)$xml_vehicule['description'];
if ($is_aycp) {
$_description = (string)html_entity_decode($xml_vehicule['content']);

// description > add contact infos
if (AYCP_ADD_CONTACT_DETAILS_IN_DESC) {
$contact_in_desc="";
if ($parsedXml[$i]['mainKeys']['email']!='') $contact_in_desc .= 'Contact : '.$parsedXml[$i]['mainKeys']['email'].'';
if ($parsedXml[$i]['mainKeys']['phone']!='') $contact_in_desc .= ' - <a href="tel:'.$parsedXml[$i]['mainKeys']['phone'].'">'.$parsedXml[$i]['mainKeys']['phone'].'</a>';
if ($contact_in_desc!="") $_description.= '<br><br><p class="contact-in-desc">' . $contact_in_desc."</p><br>";
}

}
}

$parsedXml[$i]['mainKeys']['description'] = $_description;


// --- create the vfields
//"50=break|29=citroen|28=2016|14=41690|27=manuelle|32=diesel"
$_vfieldsAr=array();
$copyOf_secondaryTagsToMap = $secondaryTagsToMap;


// special patch for boat
$x_debug='nothing special';
if ($is_aycp && (int)$parsedXml[$i]['mainKeys']['old_catid']>=20 && (int)$parsedXml[$i]['mainKeys']['old_catid']<=24){

$this_idx = json_find_idx_by_field($copyOf_secondaryTagsToMap, 'key', 'make');
if ($this_idx !== false) $copyOf_secondaryTagsToMap[$this_idx]['vfieldId']=135;

$x_debug .= '|'.$this_idx;
$x_debug .= '|'.$copyOf_secondaryTagsToMap[$this_idx]['vfieldId'];

$this_idx = json_find_idx_by_field($copyOf_secondaryTagsToMap, 'key', 'year');
if ($this_idx !== false) $copyOf_secondaryTagsToMap[$this_idx]['vfieldId']=56;

$x_debug .= '|'.$this_idx;
$x_debug .= '|'.$copyOf_secondaryTagsToMap[$this_idx]['vfieldId'];
}

$parsedXml[$i]['mainKeys']['debug']=$x_debug;


foreach ($copyOf_secondaryTagsToMap as $x => $tag) {
$vId =$tag['vfieldId'];
$vKey =$tag['key'];
$vVal = $parsedXml[$i]['secondaryKeys'][$vKey];


// get the translated value
if (isset($tag['translation'])) {
$vVal = $translationTable[$vKey][$vVal] ;
// lowercase + cut to 10 chars max
$vVal = substr(strtolower($vVal), 0, 10);
}

if ($vVal) $_vfieldsAr[$vId] = $vVal;
}
$parsedXml[$i]['mainKeys']['vfields'] = serializeArToStr($_vfieldsAr, '|') ;


// test with goecoding
// get loc lat/lng nominatim
$elem_data = $parsedXml[$i]['primeKeys'];
$elem_dest = $parsedXml[$i]['mainKeys'];
if ($is_aycp && AYCP_IMPORT_LOC_GEOCODE_EN && $elem_data['city']!="" ){

$defaultQuery = $elem_data['location'].','. $elem_data['city'];

if (GEOCODING_API_LIB == 'nominatim' || GEOCODING_API_LIB==""){
$geocodingUrl = "https://nominatim.openstreetmap.org/search";

// IMPORTANT : format must be geocodejson
$api_params = array(
'q' => $defaultQuery,
'city' =>$elem_data['city'] ,
'postalcode'=> $elem_data['postcode'],
'country' => $elem_data['country_code'],
'format'=>'geocodejson',
'limit'=>1,
'addressdetails'=>1 // get details
);

// MANDATORY !!! to provide user agent here
$api_header = array(
'User-Agent' => COOKIENAME.'_'.time()
);
}

if (GEOCODING_API_LIB == 'gouvfr'){
$geocodingUrl = "https://api-adresse.data.gouv.fr/search/";
$api_params = array(
'q' => $defaultQuery,
'postcode'=> $elem_data['postcode'],
'limit'=>1
);
// mandatory to provide user agent here
$api_header = array(
'User-Agent' => COOKIENAME.'_'.time()
);
}


if (GEOCODING_API_LIB == 'opencage'){
$geocodingUrl = "https://api.opencagedata.com/geocode/v1/geojson";
$api_params = array(
'q' => $defaultQuery,
'postcode'=> $elem_data['postcode'],
'countrycode' => $elem_data['country_code'],
'limit'=>1,
'key'=>GEOCODING_API_TOKEN,
'no_record'=>1,
'no_annotations'=>1
);
// mandatory to provide user agent here
$api_header = array(
'User-Agent' => COOKIENAME.'_'.time()
);
}

// $parsedXml[$i]['debug_keys'] = $api_params;
// $parsedXml[$i]['geocodingUrl'] = $geocodingUrl;
$res_loc= simple_rest_client($geocodingUrl, 'GET', $api_params, [],'', $api_header);


$parsedXml[$i]['debug_geocoder'] = $res_loc;
$parsedXml[$i]['debug_geocoder']['a_geocoder_platform'] = GEOCODING_API_LIB;

if ($res_loc['success']){
$res_details = $res_loc['response']['features'][0]['geometry']['coordinates']; // get the fisrt response
$elem_dest['loclat'] = $res_details[1];
$elem_dest['loclng'] = $res_details[0];
$elem_dest['loclatlng'] = str_replace(',', '.',implode('|', [ $res_details[1],$res_details[0]]));
$elem_dest['location'] = get_goecoder_formatted_location($res_loc);

// get mor details
// "context":"80, Somme, Hauts-de-France",
if (GEOCODING_API_LIB == 'gouvfr') {
$res_properties =$res_loc['response']['features'][0]['properties']['context'];
$res_propertiesAr= explode(',', $res_properties);
$elem_dest['locregion'] = trim($res_propertiesAr[2]);
$elem_dest['loccountry'] = 'France';
$elem_dest['locdept'] = trim($res_propertiesAr[1]);
}

if (GEOCODING_API_LIB == 'nominatim' || GEOCODING_API_LIB==""){
$res_properties =$res_loc['response']['features'][0]['properties']['geocoding'];
$elem_dest['locregion'] = ($res_properties['state']);
$elem_dest['loccountry'] = ($res_properties['country']);
$elem_dest['locdept'] = ($res_properties['county']);
}



}


}
$parsedXml[$i]['primeKeys'] = $elem_data;
$parsedXml[$i]['mainKeys']= $elem_dest;


// --- max upload limit
$i+=1;
if ($is_import_xml ){
if ($i> XML_IMPORT_MAX_UPLOAD_ITEMS) break ;
}
else if ($i>CARGEST_MAX_UPLOAD_ITEMS) break ;

}// end each elements


if ( $action=="parseXml") {
$loglist= array('nbr'=>$total, 'vehicules'=>$parsedXml);
$maxresults = $total;
$stream_url=$_local_file_xml;
}


// logs
if (SYNDIC_LOGS_EN && $action=="parseXml"){
$deltatime= (microtime(true)-$t0); $deltatime= sprintf("%01.3f", $deltatime). "s";
gen_log_event($action,'syndic', $USERID, 0 , WHATS.'-'.$action .'|nb='.$total.'&time='. $deltatime . '&userid='.$USERID, 0);
}


}


//----- ADD adds into the database -----------------------------
if ( $action=="parseXmlAndAdd")
{




// init variables
$maxresults=0; $nbModified = 0;$nbUploaded=0;
$nbUserCreated=0; $nbUserModified=0;
$DEFAULT_STATUS = ($is_import_xml) ? XML_IMPORT_DEFAULT_AD_STATUS : CARGEST_DEFAULT_AD_STATUS;

// exits conditions
if (!($curuser_is_admin || $curuser_is_owner)) exit_with_error('not authorized');
if ($total==0) exit_with_error('no ads to add');

// get user details (initializing the call) to be used for adding adds
$result0 = $dbb->get(DB_TABLE_USERS, '*' , " `id` = $USERID " );
if (!$result0) exit_with_error('no user found with id ='.$USERID);
else $u = $result0;

// set to "deleted exists ads" for Ubiflow which then will be deleted
setAdsStatusDeleted($USERID, '80', true);

foreach ($parsedXml as $k => $e) {
$stamp= date( 'Y-m-d H:i:s', time());

// max limit
if ($is_import_xml ){
if ($k>= XML_IMPORT_MAX_UPLOAD_ITEMS) break ;
} else if ($k>=CARGEST_MAX_UPLOAD_ITEMS) break ;

// check if adds already exists
$result00 = $dbb->get(DB_TABLE_ITEMS, ['id', 'status'] , " `origin` = '".WHATS."' AND `originref` = '".$e['primeKeys']['reference']."' " );
if ($result00) $is_modify=true; else $is_modify=false;


//--- process the images
unset($rp_cumul); // reset the array
$rp_cumul=array();
$newPictures=array();
if (CARGEST_UPLOAD_FILES_ON_DISK){
$savedPhotos = $e['photos'];

$nbPhotos=0;
foreach (explode(";", $e['photos']) as $key => $picture) {
$pictureUrl = explode('|', $picture)[0];
$rp = getImageFromUrl($pictureUrl);

$rp_cumul[] =$rp;
if ($rp['success']){
$newPicture=$rp['basename'].'|photo|'.$rp['filesize'];
$newPictures[] =$newPicture;
$nbUploaded++;
}

// quit of max nbr of pictures excedded
$nbPhotos+=1;
if (isset($CARGEST_PHOTOS_MAX_NBR) && $CARGEST_PHOTOS_MAX_NBR==$nbPhotos) break;

$m = "getImageFromUrl results for $pictureUrl = ". json_encode($rp);
logfile('DEBUG',$m );

}
// each foreach
$e['photos']=implode(';',$newPictures);
}

// DEBUG --- early exit for debug reasons
//$out= array('photos'=>$e['photos'], 'rp_cumul'=>$rp_cumul, 'newPictures'=>$newPictures);
// echo json_encode($out);
// die();

//$m = "FINAL results for ".$e['mainKeys']['title']." = ". json_encode($out);
//logfile('DEBUG',$m );


// ---- process modifications
if ($is_modify){

$fields_list=array(
// 'moddate'=>$stamp
'title'=>$e['mainKeys']['title']
,'description'=>$e['mainKeys']['description']
,'vfields'=>$e['mainKeys']['vfields']
,'price'=>$e['mainKeys']['price']
,'imgname'=>$e['photos']
,'status'=> $DEFAULT_STATUS

);

// case of modedate
if (!isset($SYNDIC_EXISTING_ADS_RULE) || SYNDIC_EXISTING_ADS_RULE == 'updatemoddate'){
$fields_list['moddate'] = $stamp;
}


if (is_array($fields_list)){
$this_id = $result00['id'];
$this_status = $result00['status'];
$result = $dbb->update(DB_TABLE_ITEMS, $fields_list, " `id` = $this_id " );
$maxresults+=1; $nbModified+=1;
// save in log
if ($result && ENABLE_ELEM_LOGS){
gen_log_event(WHATS.'-edit','ad', $this_id, 0, $DEFAULT_STATUS, 0);
}
} else exit_with_error( "bad / incorrect fields ");

} else {
// adapt user details
if (
( ($is_cargest || $is_ubiflow || $is_aycp) && CARGEST_USER_DETAILS_FROM_SOURCE )
|| ($is_import_xml && XML_IMPORT_USER_DETAILS_FROM_SOURCE )

){

// user name
if (isset($e['mainKeys']['username']))
$u['username'] = $e['mainKeys']['username'];

if (isset($e['mainKeys']['usertype']))
$u['usertype'] = $e['mainKeys']['usertype'];

$u['userid'] = $u['id']; // save it back to ID

if ($is_import_xml && XML_IMPORT_USER_ID_FROM_SOURCE) {
$u['userid'] = $e['mainKeys']['userid'];
}

// automatically create users
if ($is_aycp && AYCP_AUTO_CREATE_USER){
$resCr= create_user_if_not_exist(WHATS, $e);
$u['userid'] = ($resCr) ? $resCr : AYCP_DEFAULT_USERID;

// get back elements from this userid
$result0 = $dbb->get(DB_TABLE_USERS, '*' , " `id` = ".$u['userid']." " );
$u = $result0;

$u['userid'] = $u['id']; // save it back to ID
}

$u['phone'] = not_null($e['mainKeys']['phone']);
$u['email'] = not_null($e['mainKeys']['email']);

} else {

// force to take the default user created in DB
if ($is_aycp) $u['userid'] = AYCP_DEFAULT_USERID;

}


// case of locations for XML imports
if (($is_import_xml || $is_aycp) && XML_IMPORT_LOC_FROM_SOURCE){
$u['loccity'] = not_null($e['mainKeys']['loccity']);
$u['loczipcode'] = not_null($e['mainKeys']['loczipcode']);
$u['loclatlng'] = not_null($e['mainKeys']['loclatlng']);
$u['loccountrycode'] =not_null($e['mainKeys']['loccountrycode']);
$u['loccountry'] =not_null($e['mainKeys']['loccountry']);
$u['locreg'] =not_null($e['mainKeys']['locreg']);
$u['locdept'] =not_null($e['mainKeys']['locdept']);

$u['location'] =not_null($e['mainKeys']['location']);

if ($u['loclatlng']) {
$u['loclat'] = not_null($e['mainKeys']['loclat']);
$u['loclng'] = not_null($e['mainKeys']['loclng']);
}

}

// finalize userid
$thisUserId = isset($u['userid']) ? $u['userid'] : $USERID;

// finalze categoryid
$thisCatId = $is_import_xml ? $e['primeKeys']['cat_id'] : CARGEST_DEFAULT_CATID;
if ($is_aycp) $thisCatId = $e['mainKeys']['catid'];

$fields_list=array(

'moddate'=>$stamp
,'createdate'=>$stamp
,'firstpublisheddate'=>$stamp
,'title'=>$e['mainKeys']['title']
,'description'=>$e['mainKeys']['description']
,'catid'=>$thisCatId
,'vfields'=>$e['mainKeys']['vfields']
,'type'=>$e['mainKeys']['type']
,'type2'=>$e['mainKeys']['type2']
,'priority'=>$e['mainKeys']['priority']
,'price'=>$e['mainKeys']['price']
,'price2'=>$e['mainKeys']['price2']
,'imgname'=>$e['photos']
,'status'=> $DEFAULT_STATUS // set to DRAFT

//quantity of products
,'quantity'=>isset($e['mainKeys']['quantity']) ? $e['mainKeys']['quantity'] : 1

// special tags for
,'origin'=> WHATS
,'originref'=>$e['primeKeys']['reference']

// user inherited informations or direct informations
,'userid'=> $thisUserId
,'username'=>$u['username']
,'phone'=>$u['phone']
,'email'=>$u['email']

// locations from real user
,'location'=>$u['location']
,'loclat'=>$u['loclat']
,'loclng'=>$u['loclng']
,'loclatlng'=>$u['loclatlng']
,'loczipcode'=>$u['loczipcode']
,'loccity'=>$u['loccity']
,'locdept'=>$u['locdept']
,'locregion'=>$u['locregion']

,'loccountrycode'=>$u['loccountrycode']
,'lochash'=>$u['lochash']
,'lochashregion'=>$u['lochashregion']

);

// genuine Url
if ($e['mainKeys']['originurl']){
$fields_list['originurl'] = $e['mainKeys']['originurl'];
}

if (is_array($fields_list)){
$result = $dbb->insert(DB_TABLE_ITEMS, $fields_list);
$maxresults+=1;

// save in log
if ($result && ENABLE_ELEM_LOGS){
gen_log_event(WHATS.'-create','ad', $result, 0, $DEFAULT_STATUS, 0);
}
} else exit_with_error( "bad / incorrect fields ");



} // end ELSE if MODIFY

} // end for each

$loglist= array('total'=>$maxresults, 'modified'=>$nbModified, 'userid'=>$USERID, 'user_created'=>$nbUserCreated, 'user_modified'=>$nbUserModified);


if (SYNDIC_LOGS_EN && $action=="parseXmlAndAdd"){
$deltatime= (microtime(true)-$t0); $deltatime= sprintf("%01.3f", $deltatime). "s";
gen_log_event($action,'syndic', $USERID, 0 , WHATS.'-'.$action .'|nb='.$maxresults.'&nbmod='. $nbModified.'&nbup='.$nbUploaded.'&time='. $deltatime.'&userid='.$USERID, 0);
}



} // end iF


// -- DELETE all ads with origin=WHAT -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteAllAds"){
$fromUserId = $_POST["fromuserid"]+0 ; // SECURED

// securing
if (!($fromUserId!=0 && ($curuser_is_admin || $curuser_is_owner))) { exit_with_error('not authorized - missing admin or owner rights or fromuserid parameter'); }

//make the delete action
$result = $dbb->delete(DB_TABLE_ITEMS, " `userid` = $fromUserId AND `origin` = '".WHATS."' ");
$maxresults =$result;


// delete the logs if exits
// TOTO
if (SYNDIC_LOGS_EN){
$deltatime= (microtime(true)-$t0); $deltatime= sprintf("%01.3f", $deltatime). "s ";
gen_log_event($action,'syndic', 0, $fromUserId , WHATS.'-'.$action .'|nb='.$maxresults.'&time='. $deltatime.'&userid='.$fromUserId, 0);
}


} // end IF deleteAllAds


// -- SET STATUS to deletes for all ads with origin=WHAT -------------
// -----------------------------------------------------------------------------
if ( $action=="setAdsStatusDeleted") {

$fromUserId = $_POST["fromuserid"]+0 ; // SECURED
// securing
if (!($fromUserId!=0 && ($curuser_is_admin || $curuser_is_owner))) exit_with_error('not authorized - missing right or fromuserid parameter');

$res = setAdsStatusDeleted($fromUserId, '80', false);
$loglist= $res;

} // end IF deleteAllAds




// -- DELETE all the logs (ads and syndic) -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteAllLogs") {

if (!$curuser_is_admin) exit_with_error('not authorized');

$res = deleteLogs('all');
$loglist= $res;

} // delete all the logs


// -- DELETE THE SYNDICATION LOGS -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteSyndicLogs") {

if (!$curuser_is_admin) exit_with_error('not authorized');

$res = deleteLogs('syndic');
$loglist= $res;
$msg = "syndic logs deleted successfully";

} // delete all the logs


// -- DELETE the syndic logs for a given user -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteLogs") {

if (!$curuser_is_admin) exit_with_error('not authorized');
if (!$userid) exit_with_error('missing userid');

$res = deleteLogs($userid);
$loglist= $res;

} // delete all the logs


// -- DELETE all ads with origin=WHAT for Admin users only -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteAllAdsAdmin"){

// securing
if (!$curuser_is_admin) exit_with_error('not authorized - must be admin');

//make the delete action
$result = $dbb->delete(DB_TABLE_ITEMS, " `origin` = '".WHATS."' ");
$maxresults =$result;

// delete the logs if exits
// TOTO
if (SYNDIC_LOGS_EN){
$deltatime= (microtime(true)-$t0); $deltatime= sprintf("%01.3f", $deltatime). "s ";
gen_log_event($action,'syndic', 0, $curuserid , WHATS.'-'.$action .'|nb='.$maxresults.'&time='. $deltatime.'&userid='.$curuserid, 0);
}


// !!!! warning !!!
// delete all images with "notn" prefix
$dest_path_img = '../uploads/img/';

ft_settings_load('img'); // initialize the "file objects"
$img_files = ft_get_filelist($dest_path_img,'name');

$delCounter=0;
foreach ($img_files as $key => $img_file) {
if (strpos($img_file['name'], 'notn_')===0){
// delete this file
unlink($dest_path_img."".$img_file['name']);
$delCounter++;
}
}
$loglist['imgs'] = $delCounter; // save the counter
$loglist['items'] = $maxresults; // save the counter

$msg= ($maxresults>0) ? "$maxresults ads deleted" : "No ads deleted or detected";
$msg.= " with ".WHATS." origin.";

} // end IF deleteAllAds


// -- DELETE all users with origin=WHAT for Admin users only -------------
// -----------------------------------------------------------------------------
if ( $action=="deleteAllUsersAdmin"){

// securing
if (!$curuser_is_admin) exit_with_error('not authorized - must be admin');

//make the delete action
$result = $dbb->delete(DB_TABLE_USERS, " `createdby` = '".WHATS."' ");
$maxresults =$result;

// delete the logs if exits
// TOTO
if (SYNDIC_LOGS_EN){
$deltatime= (microtime(true)-$t0); $deltatime= sprintf("%01.3f", $deltatime). "s ";
gen_log_event($action,'syndic', 0, $curuserid , WHATS.'-'.$action .'|nb='.$maxresults.'&time='. $deltatime.'&userid='.$curuserid, 0);
}
$loglist['users'] = $maxresults; // save the counter

$msg= ($maxresults>0) ? "$maxresults users deleted" : "No users deleted or detected";
$msg.= " with ".WHATS." auth.";


} // end IF deleteAllAds



// -- SANITIZE catlist map file -------------
// -----------------------------------------------------------------------------
if ( $action=="sanitizeCatsMapList"){
$msg="";

// securing
if (!$curuser_is_admin) exit_with_error('not authorized - must be admin');

// read the file
if (SYNDIC_CATS_MAP_URL !="") {
$general_cats_map = json_decode(file_get_contents(SYNDIC_CATS_MAP_URL),true);

if ($general_cats_map){

// make a backup
$tCopyPath = SYNDIC_CATS_MAP_URL.'.'.time().'.bak';
$bakupContent = file_get_contents(SYNDIC_CATS_MAP_URL);
$write_status = file_put_contents($tCopyPath, $bakupContent);
if (!$write_status) $msg .="error while writing file $tCopyPath | " ;

// check with cattable records
$result_db_cats = $dbb->select(DB_TABLE_CATS, ["id", "title", "pid"]);

// for debug
$result = $result_db_cats;
$result0 = $general_cats_map;


// report errors with link
$cat_error=0;
foreach ($general_cats_map as $key => $cat) {
$found_cat_db = json_find_elem_by_id($result_db_cats, $cat['to_id']);
if ($found_cat_db){
$general_cats_map[$key]['to_name'] = $found_cat_db ['title'];
$general_cats_map[$key]['to_error'] = '';
} else {
$general_cats_map[$key]['to_error'] = 'ERROR - does not exist';
$general_cats_map[$key]['to_name'] = '?';
$cat_error+=1;
}
}
$msg .= ($cat_error>0) ? "$cat_error erros detected" : "No errors detected";
$absoluteUrl = str_replace("../", DOMAIN_FQDN, SYNDIC_CATS_MAP_URL);
$msg .= '<br>'.'<a href="'.$absoluteUrl.'" target="_blank" >check the file</a>';
$result00=$general_cats_map;

// save the file
$write_status = file_put_contents(SYNDIC_CATS_MAP_URL, json_encode($general_cats_map, JSON_PRETTY_PRINT));
if (!$write_status) $msg .=" | error while writing file ".SYNDIC_CATS_MAP_URL." " ;


} else $msg .= "error while reading file ".SYNDIC_CATS_MAP_URL." ";
} else $msg .= "missing file name";

} // end SANITIZE catlist map file


// -- output result -------------
$json = array(
'success' => $success,
'totnb' =>$maxresults,
'message'=> $msg,
'action' => WHATS,
'subaction' => $action,
'what' => $what,
'a_streamurl'=>$stream_url,
'nav'=>$nav,
'sort'=>$sortoriginal,
'paged' => $paged,
'eppage'=>$eppage,
'search'=>$search,
'faction'=>$faction,
'ftype'=>$ftype,
'focusid'=>$focusid,
'id' => $id,
'comid' => $comid,
'toid'=>$toid,
'inlinefor'=>$inlinefor,
'fadid' => $fadid,
'counters'=>$counters,
'sendmode'=>$_POST["sendmode"],
'data' => $loglist,

'thisIsValidInternalApiCall'=>$thisIsValidInternalApiCall
);

if ($debug_tmp==1){ // add debug info into the stream when working local

$query = $dbb->get_log();
$trace .= $dbb->get_logtime();

$json["xdebug"]= array(
'db_queries'=> $query,
'filterparams'=>$filterparams,
'filter'=>$filter,
'filterfull'=>$filterfull,
'curuserid'=>$curuserid,
'curuser_id'=>$curuser_id,
'curuser_type'=>$curuser_type,
'curuser_is_admin'=>$curuser_is_admin,
'curuser_is_owner'=>$curuser_is_owner,
'id'=>$id,
'cookietxt'=>$cookietxt,
'cokVal'=>$cokVal,
'userdetails'=>$user_details,
'trace'=>$trace,
'datas_for_email'=>$datas_for_email,
'$_SESSION'=>$_SESSION,
'$result'=>$result,
'$result0'=>$result0,
'$result00'=>$result00,
'resultItem'=>$resultItem,
'keysCollection'=>$keysCollection
,'fields_list'=>$fields_list
,'secondaryTagsToMapKeys'=>$secondaryTagsToMapKeys
);
}

encode_json_and_send_with_compression($json);

}
else {
echo json_encode(
array(
'$_POST'=>$_POST,
"message"=>'hi from '.basename($_SERVER["SCRIPT_FILENAME"])
)
);
die();
}


function extract_aycp_publisher_details($full_publisher_data){
$publisher = [];
foreach($full_publisher_data as $key => $value)
{
if ($key!="ad") $publisher[$key] = $value ;
}

// --post processing
$this_protype = (in_array($publisher['type'], ["1", "profesional"])) ? "pro" : "par";
$publisher['protype'] = $this_protype;

// normalize values
foreach ($publisher['contact'] as $key => $elem) {
$publisher['_contact'][$key] = (string)$elem;
}

// normalize values
foreach ($publisher['location'] as $key => $elem) {
$publisher['_location'][$key] = (string)$elem;
}

// normalize values
foreach ($publisher as $key => $elem) {
if (in_array($key, ['location', 'contact', '_contact', '_location'])) continue;
else $publisher[$key] = (string)$elem;
}

return $publisher;
}


function create_user_if_not_exist($what, $e){
global $dbb;
global $nbUserCreated, $nbUserModified;


$has_publisher_details= array_key_exists('_publisher_details', $e['primeKeys']);

$stamp= date( 'Y-m-d H:i:s', time());

if ($has_publisher_details){
$ref_email = $e['primeKeys']['_publisher_details']['_contact']['email'] ;
} else {
$ref_email = $e['primeKeys']['email'] ;
}


// check if email is defined // quit if no emails
if ($ref_email=="") return false;

// check is this user exist or not
$result_user = $dbb->get(DB_TABLE_USERS, ['id', 'status', 'auth'] , " `email` = '".$ref_email."' " );
if ($result_user) {$nbUserModified+=1; return $result_user['id'];}
else {

// must create the user
if ($has_publisher_details){


$pubD = $e['primeKeys']['_publisher_details'];

// check if robot
$is_anonymous = (is_null($pubD['_contact']['nickname']) |
0
jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 4 689
4 mai 2022 à 20:23
Et donc.. quel est le souci exactement ?
Où le constates tu ?
Qu'est-ce qui ne fonctionne pas ?
Si c'est un souci pour lire le contenu du XML et de l'afficher sur ta page ... quel(s) champ(s) te manquent ?
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
4 mai 2022 à 21:11
Bonjour, dans les tags de mon php je doit avoir les balise de xml, mais j'ai que un quart et après dans mon html sa n'appelle pas.
Voilà se que sa donne.
https://www.jetrouvetous.fr/annonces/6484/en-centre-ville--maison-tout-confort--pas-de-jardin
0
jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 4 689
4 mai 2022 à 22:59
le lien que tu donnes n'existe pas....

En plus .. ne pourrais tu pas nous indiquer par toi même quelques exemples de champs qui manquent ???


Et puis... je suppose que ton script PHP est lancé via une CRON ....
As tu regardé si tu avais des logs ??
As tu essayé de le lancer à la main pour voir ce qu'il fait ?
As tu essayé d'y mettre des var_dump des variables ou des echo dans le script pour essayer de voir par où il passe et ce que contiennent les différentes variables ?

très clairement .. si tu n'es pas plus précis sur le souci rencontré et sans tests de ta part pour essayer de déterminer où se trouve le probmème .. on n'avancera pas.
Le script est bien trop gros et nous ne possédons pas la base de données pour pouvoir le tester...
En plus on ne sait toujours pas quel CMS tu utilises ...

Et puis tu nous dis
Oui j'ai déjà contacter le support et le créateur de mon cms qui a fait la passerelle pour l'automobile et non pour l'immo .

Tu veux dire que personne n'as créé ce script ...mais que tu as essayé de dupliquer son script (pour l'import des voirutres) pour l'adapter à l'immobilier ?

Et enfin.. as tu vérifié en BDD si les données s'y mettent ?
Histoire de savoir si c'est un problème d'import .. ou juste un problème de réaffichage sur ton site ...
0
jetrouvetous Messages postés 45 Date d'inscription mercredi 4 mai 2022 Statut Membre Dernière intervention 18 septembre 2022
5 mai 2022 à 07:53
Bonjour, merci de votre réponse.
Non je n'ai pas dupliquer le script mais acheté, le cms que j'utilise est zads je l'ai dit au départ.
Le créateur du cms a fait une passerelle pour Ubiflow mais configurer pour l'automobile et pas pour l'immobilier.
Il demande presque 800€ pour la modification alors que le script m'a coûter 160€.
J'essaie de faire moi même si je peux économiser un peu.
L'url est dead normal j'ai désactiver les annonces en lien avec Ubiflow.
Cordialement
0
jordane45 Messages postés 38241 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 septembre 2024 4 689
5 mai 2022 à 08:00
Tu ne réponds toujours pas à toutes mes questions.... Dans ces conditions, impossible pour moi de t'aider...
0