


/**************
 * Entreprise
 ************/
//
//function init_entreprise()
//{
//    //Labels = noms utilisées
//    $labels = array(
//        'name' => 'Entreprise',
//        'singular_name' => 'Entreprise',
//        'menu_name' => 'Entreprise',
//        'name_admin_bar' => 'Entreprise',
//        'add_new' => 'Ajouter',
//        'add_new_item' => 'Ajouter un element',
//        'new_item' => 'Nouveau element',
//        'edit_item' => 'Editer l\'element',
//        'view_item' => 'Voir l\'element',
//        'all_items' => 'Tous les elements',
//        'search_items' => 'Chercher un element',
//        'parent_item_colon' => 'Parent element',
//        'not_found' => 'Aucun element.',
//        'not_found_in_trash' => 'Aucun element trouvée dans la corbeille.'
//    );
//
//    $args = array(
//        'labels' => $labels,
//        'public' => true,
//        'publicly_queryable' => true,
//        'show_ui' => true,
//        'show_in_rest' => true, // Important !
//        'show_in_menu' => true,
//        'query_var' => true,
//        'exclude_from_search' => false,
//        'rewrite' => array('slug' => 'entreprise', 'with_front' => false),
//        //'rewrite'            => true,
//        'capability_type' => 'page', //permet de gerer les droits
//        'has_archive' => false,
//        'hierarchical' => true,
//        // L'icone afficher dans le backoffice, voir https://developer.wordpress.org/resource/dashicons/
//        'menu_icon' => 'dashicons-businessperson',
////        'taxonomies'         => array('Service'),
//        'menu_position' => 4,//position dans le menu admin
////        'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
//        'supports' => array('title', 'custom-fields', 'thumbnail', 'page-attributes')
//    );
//
//    register_post_type('entreprise', $args);//id unique sera affiché dans l'URL
//}
//
//add_action('init', 'init_entreprise');











//function msk_create_message_after_wpcf7_submission() {
//    $submission = WPCF7_Submission::get_instance();
//
//    if ($submission) {
//
//        // On récupère les données du formulaire
//        $posted_data = $submission->get_posted_data();
//
//        // On stocke ce qu'on veut dans des variables, tout en assanissant les données
//        $entreprisename = sanitize_text_field($posted_data['your-entreprise']);
//        if ($entreprisename):
//            $email = sanitize_email($posted_data['your-email']);
//            $tel = sanitize_text_field($posted_data['tel-292']);
//            $lien = sanitize_text_field($posted_data['your-site']);
//
//
//            $args = array(
//                'post_status' => 'publish',
//                'post_type' => 'entreprise',
//                'post_title' => $entreprisename,
//                //                'post_content' => $post_body
//                'meta_input'  => [
//                    'email' => $email,
//                    'telephone' => $tel,
//                    'lien_du_site' => $lien,
////                    'logo' => $uploaded_files['file-1'],
//                    'logo_test' => $posted_data['file-1'],
//                ]
//            );
//            $post_id = wp_insert_post($args);
//
//
//        endif;
//
//    }
//}
//add_action('wpcf7_mail_sent', 'msk_create_message_after_wpcf7_submission');

//
//function wp_ftp_upload_connect() {
//    $ftp_server = 'hdm.pom-preview.ch'; // Replace with your FTP server hostname
//    $ftp_port = 21; // Replace with the appropriate port
//    $ftp_username = 'ei3or_hdmfile'; // Replace with your FTP username
//    $ftp_password = 'IkUJd_gZvI1'; // Replace with your FTP password
//
//    $ftp = ftp_connect($ftp_server, $ftp_port);
//    if ($ftp) {
//        $login_result = ftp_login($ftp, $ftp_username, $ftp_password);
//        if ($login_result) {
//            return $ftp;
//        } else {
//            // Handle login error
//            return false;
//        }
//    } else {
//        // Handle connection error
//        return false;
//    }
//}
//
//function wp_ftp_upload($ftp, $local_file, $remote_path) {
//    $upload_result = ftp_put($ftp, $remote_path, $local_file, FTP_BINARY);
//    return $upload_result;
//}
//
//function wp_ftp_upload_disconnect($ftp) {
//    ftp_close($ftp);
//}
//
//
//function upload_to_ftp_and_save_link($uploaded_file_path, $custom_field_key) {
//    $ftp = wp_ftp_upload_connect();
//
//    if ($ftp) {
//        $filename = basename($uploaded_file_path);
//        $remote_path = '/' . $filename; // Chemin sur le serveur FTP
//
//        $upload_result = wp_ftp_upload($ftp, $uploaded_file_path, $remote_path);
//
//        if ($upload_result) {
//            wp_ftp_upload_disconnect($ftp);
//
//            // Enregistre le lien FTP dans le champ personnalisé
//            $attachment_id = wp_insert_attachment(array(), $uploaded_file_path);
//            update_post_meta($attachment_id, $custom_field_key, $remote_path);
//        }
//    }
//}
//
//function handle_form_submission($contact_form) {
//    $submission = WPCF7_Submission::get_instance();
//
//    if ($submission) {
//        $posted_data = $submission->get_posted_data();
//        $uploaded_file_path = $posted_data['file']; // Changez en fonction du nom réel du champ
//
//        // Appelle la fonction pour télécharger le fichier sur le serveur FTP et enregistrer le lien
//        $attachment_id = upload_to_ftp_and_save_link($uploaded_file_path, 'logo_test');
//
//        // Enregistre l'entreprise dans WordPress
//        $entreprisename = sanitize_text_field($posted_data['your-entreprise']);
//        if ($entreprisename) {
//            $email = sanitize_email($posted_data['your-email']);
//            $tel = sanitize_text_field($posted_data['tel-292']);
//            $lien = sanitize_text_field($posted_data['your-site']);
//
//            $args = array(
//                'post_status' => 'publish',
//                'post_type' => 'entreprise',
//                'post_title' => $entreprisename,
//                'meta_input'  => [
//                    'email' => $email,
//                    'telephone' => $tel,
//                    'lien_du_site' => $lien,
//                    'logo_test' => get_post_meta($attachment_id, 'logo_test', true),
//                ]
//            );
//            $post_id = wp_insert_post($args);
//        }
//    }
//}
//add_action('wpcf7_before_send_mail', 'handle_form_submission');


//function handle_form_submission($contact_form) {
//    $submission = WPCF7_Submission::get_instance();
//
//    if ($submission) {
//        $posted_data = $submission->get_posted_data();
//        $uploaded_file_path = $posted_data['file']; // Remplacez par le nom réel du champ de fichier
//
//        // Upload du fichier sur le serveur FTP
//
//            $ftp_server = 'hdm.pom-preview.ch'; // Replace with your FTP server hostname
//            $ftp_username = 'ei3or_hdmfile'; // Replace with your FTP username
//            $ftp_password = 'IkUJd_gZvI1'; // Replace with your FTP password
//            $ftp_path = '/'; // Remplacez avec le chemin FTP
//
//        $ftp = ftp_connect($ftp_server);
//        $ftp_login = ftp_login($ftp, $ftp_username, $ftp_password);
//
//        if ($ftp && $ftp_login) {
//            $remote_file_path = $ftp_path . basename($uploaded_file_path);
//            $upload_result = ftp_put($ftp, $remote_file_path, $uploaded_file_path, FTP_BINARY);
//
//            if ($upload_result) {
//                ftp_close($ftp);
//
//                // Envoi de l'email via Contact Form 7
//                $mail_sent = $contact_form->mail();
//
//                if ($mail_sent) {
//                    // Enregistrement du post (entreprise) avec le lien FTP dans le champ personnalisé
//                    $entreprisename = sanitize_text_field($posted_data['your-entreprise']);
//                    if ($entreprisename) {
//                        $email = sanitize_email($posted_data['your-email']);
//                        $tel = sanitize_text_field($posted_data['tel-292']);
//                        $lien = sanitize_text_field($posted_data['your-site']);
//
//                        $post_args = array(
//                            'post_status' => 'publish',
//                            'post_type' => 'entreprise',
//                            'post_title' => $entreprisename,
//                            'meta_input' => array(
//                                'email' => $email,
//                                'telephone' => $tel,
//                                'lien_du_site' => $lien,
//                                'logo_test' => $remote_file_path, // Stocke le lien FTP
//                            ),
//                        );
//
//                        $post_id = wp_insert_post($post_args);
//                    }
//                }
//            }
//        }
//    }
//}
//add_action('wpcf7_before_send_mail', 'handle_form_submission');

//function upload_to_ftp($local_file_path) {
//    $ftp_server = 'hdm.pom-preview.ch'; // Replace with your FTP server hostname
//    $ftp_username = 'ei3or_hdmfile'; // Replace with your FTP username
//    $ftp_password = 'IkUJd_gZvI1'; // Replace with your FTP password
//    $ftp_path = '/'; // Remplacez avec le chemin FTP
//
//    $ftp = ftp_connect($ftp_server);
//    $ftp_login = ftp_login($ftp, $ftp_username, $ftp_password);
//
//    if ($ftp && $ftp_login) {
//        $filename = basename($local_file_path);
//        $remote_file_path = $ftp_path . $filename;
//
//        $upload_result = ftp_put($ftp, $remote_file_path, $local_file_path, FTP_BINARY);
//
//        if ($upload_result) {
//            ftp_close($ftp);
//            return $remote_file_path; // Retourne le chemin du fichier distant
//        }
//    }
//
//    return false; // Retourne false en cas d'échec
//}
//
//function handle_form_submission() {
//    if (isset($_FILES['file']['tmp_name'])) {
//        $uploaded_file_path = $_FILES['file']['tmp_name']; // Récupère le chemin du fichier temporaire
//
//        // Téléchargement FTP et obtention du chemin du fichier distant
//        $remote_path = upload_to_ftp($uploaded_file_path);
//
//        // Création du post (entreprise)
//        $entreprisename = sanitize_text_field($_POST['your-entreprise']);
//        if ($entreprisename) {
//            $email = sanitize_email($_POST['your-email']);
//            $tel = sanitize_text_field($_POST['tel-292']);
//            $lien = sanitize_text_field($_POST['your-site']);
//
//            $post_args = array(
//                'post_status' => 'publish',
//                'post_type' => 'entreprise',
//                'post_title' => $entreprisename,
//                'meta_input' => array(
//                    'email' => $email,
//                    'telephone' => $tel,
//                    'lien_du_site' => $lien,
//                    'logo_test' => $remote_path,
//                ),
//            );
//
//            $post_id = wp_insert_post($post_args);
//
//            if ($post_id && $remote_path) {
//                // Attache l'image mise en avant
//                $attachment_id = attachment_url_to_postid($remote_path);
//                if ($attachment_id) {
//                    set_post_thumbnail($post_id, $attachment_id);
//                }
//            }
//        }
//    }
//}
//add_action('wpcf7_mail_sent', 'handle_form_submission');










//function msk_create_message_after_wpcf7_submission($contact_form) {
//    $submission = WPCF7_Submission::get_instance();
//
//    if ($submission) {
//        $posted_data = $submission->get_posted_data();
//        $entreprisename = sanitize_text_field($posted_data['your-entreprise']);
//
//        if ($entreprisename) {
//            $email = sanitize_email($posted_data['your-email']);
//            $tel = sanitize_text_field($posted_data['tel-292']);
//            $lien = sanitize_text_field($posted_data['your-site']);
//
//            $args = array(
//                'post_status' => 'publish',
//                'post_type' => 'entreprise',
//                'post_title' => $entreprisename,
//                'meta_input' => [
//                    'email' => $email,
//                    'telephone' => $tel,
//                    'lien_du_site' => $lien,
//                ]
//            );
//
//            $post_id = wp_insert_post($args);
//
//            if ($post_id) {
//                // Image handling logic similar to the first code snippet
////                if (isset($posted_data['file-1']) && !empty($posted_data['file-1'])) {
////                    $file_path = $posted_data['file-1']; // Assuming this contains the file path
////
////                    $upload_file = wp_upload_bits(basename($file_path), null, @file_get_contents($file_path));
////                    if (!$upload_file['error']) {
////                        $wp_filetype = wp_check_filetype(basename($upload_file['file']), null);
////                        $attachment = array(
////                            'post_mime_type' => $wp_filetype['type'],
////                            'post_parent' => $post_id,
////                            'post_title' => preg_replace('/\.[^.]+$/', '', basename($upload_file['file'])),
////                            'post_content' => '',
////                            'post_status' => 'inherit'
////                        );
////
////                        $attachment_id = wp_insert_attachment($attachment, $upload_file['file'], $post_id);
////
////                        if (!is_wp_error($attachment_id)) {
////                            require_once(ABSPATH . 'wp-admin/includes/image.php');
////                            $attachment_data = wp_generate_attachment_metadata($attachment_id, $upload_file['file']);
////                            wp_update_attachment_metadata($attachment_id, $attachment_data);
////                            set_post_thumbnail($post_id, $attachment_id);
////                        }
////                    }
////                }
//            }
//            if (isset($posted_data['file-1']) && !empty($posted_data['file-1'])) {
//                $file_path = $posted_data['file-1']; // Assuming this contains the file path
//
//                // Check if the file exists
//                if (file_exists($file_path)) {
//                    // Prepare the image for attachment
//                    $file_name = basename($file_path);
//                    $upload_dir = wp_upload_dir(); // Get the upload directory details
//                    $upload_file = $upload_dir['path'] . '/' . $file_name;
//
//                    // Copy the file to the upload directory
//                    if (copy($file_path, $upload_file)) {
//                        // Set up the attachment data
//                        $attachment = array(
//                            'post_mime_type' => mime_content_type($upload_file),
//                            'post_title' => preg_replace('/\.[^.]+$/', '', $file_name),
//                            'post_content' => '',
//                            'post_status' => 'inherit'
//                        );
//
//                        // Insert the attachment
//                        $attachment_id = wp_insert_attachment($attachment, $upload_file, $post_id);
//
//                        if (!is_wp_error($attachment_id)) {
//                            require_once(ABSPATH . 'wp-admin/includes/image.php');
//                            $attachment_data = wp_generate_attachment_metadata($attachment_id, $upload_file);
//                            wp_update_attachment_metadata($attachment_id, $attachment_data);
//                            set_post_thumbnail($post_id, $attachment_id);
//                        }
//                    }
//                }
//            }
//
//        }
//    }
//}
//add_action('wpcf7_mail_sent', 'msk_create_message_after_wpcf7_submission');



<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="https://halledesmacons.ch/sitemaps_xsl.xsl"?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://halledesmacons.ch/post-sitemap1.xml</loc>
<lastmod>2026-09-22T16:01:06+02:00</lastmod>
</sitemap>
<sitemap>
<loc>https://halledesmacons.ch/page-sitemap1.xml</loc>
<lastmod>2026-08-25T10:40:39+02:00</lastmod>
</sitemap>
<sitemap>
<loc>https://halledesmacons.ch/category-sitemap1.xml</loc>
</sitemap>
<sitemap>
<loc>https://halledesmacons.ch/post_tag-sitemap1.xml</loc>
</sitemap>
</sitemapindex>