?

webshll2019

Current Path : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/
Upload File :
Current File : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/insert_new_property.php

<?php
include "start.php";
include "verif_session.php";
include "send_email.php";
extract($_POST);

function buildAdminPropertyEmail($d, $property_id) {
    $msg = "<html><head><meta charset='UTF-8'></head><body dir='rtl' style='font-family:Arial,sans-serif;color:#222;'>";
    $msg .= "<h2>砖诇讜诐 诪谞讛诇,</h2>";
    $msg .= "<p>谞讻住 讞讚砖 诪诪转讬谉 诇讗讬砖讜专.</p>";
    $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";

    $msg .= "<h3 style='color:#0070ba;'>驻专讟讬 讛谞讻住</h3>";
    $msg .= "<p><strong>讻讜转专转:</strong> ".$d['title']."</p>";
    $msg .= "<p><strong>转讗讜专:</strong> ".nl2br(htmlspecialchars($d['description']))."</p>";
    $msg .= "<p><strong>住讜讙 讛谞讻住:</strong> ".$d['type_property']."</p>";
    $msg .= "<p><strong>住讜讙 讛讛砖讻专讛:</strong> ".$d['type_location']."</p>";
    $msg .= "<p><strong>诪讞讬专 砖讻讬专讜转 讞讜讚砖讬:</strong> &#8362;".$d['price_monthly']."</p>";
    $msg .= "<p><strong>讜注讚 讘讬转 (诇讞讜讚砖):</strong> &#8362;".$d['price_vaad']."</p>";
    $msg .= "<p><strong>讗专谞讜谞讛 (诇讞讜讚砖讬讬诐):</strong> &#8362;".$d['price_arnona']."</p>";
    $msg .= "<p><strong>转讗专讬讱 讻谞讬住讛 诇谞讻住:</strong> ".$d['date_entry']."</p>";
    $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";

    $msg .= "<h3 style='color:#0070ba;'>诪讬拽讜诐</h3>";
    $msg .= "<p><strong>讻转讜讘转:</strong> ".$d['address']."</p>";
    $msg .= "<p><strong>注讬专:</strong> ".$d['city']."</p>";
    $msg .= "<p><strong>讗讝讜专:</strong> ".$d['region']."</p>";
    if (!empty($d['neighborhood'])) {
        $msg .= "<p><strong>砖讻讜谞讛/住讘讬讘讛:</strong> ".htmlspecialchars($d['neighborhood'])."</p>";
    }
    $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";

    $msg .= "<h3 style='color:#0070ba;'>驻专讟讬诐</h3>";
    $msg .= "<p><strong>讙讜讚诇 讘诪&quot;专:</strong> ".$d['surface']."</p>";
    $msg .= "<p><strong>诪住驻专 讞讚专讬诐:</strong> ".$d['nb_rooms']."</p>";
    $msg .= "<p><strong>诪住驻专 讞讚专讬 讗诪讘讟讬讛:</strong> ".$d['nb_bathrooms']."</p>";
    $msg .= "<p><strong>拽讜诪讛:</strong> ".$d['floor']."</p>";
    $msg .= "<p><strong>诪住驻专 拽讜诪讜转 讘讘谞讬讬谉:</strong> ".$d['nb_floor']."</p>";
    $msg .= "<p><strong>诪住驻专 讞谞讬讜转:</strong> ".$d['parking']."</p>";
    $msg .= "<p><strong>诪注诇讬转:</strong> ".$d['elevator']."</p>";
    $msg .= "<p><strong>诪讬讝讜讙:</strong> ".$d['air_cond']."</p>";
    $msg .= "<p><strong>诪诪&quot;讚:</strong> ".$d['mamad']."</p>";
    $msg .= "<p><strong>讚诇转讜转 专讘 讘专讬讞:</strong> ".$d['multib_doors']."</p>";
    $msg .= "<p><strong>住讜专讙讬诐:</strong> ".$d['bars']."</p>";
    $msg .= "<p><strong>讚讜讚 砖诪砖:</strong> ".$d['heater']."</p>";
    $msg .= "<p><strong>诪讞住谉:</strong> ".$d['storeroom']."</p>";
    $msg .= "<p><strong>讙讬砖讛 诇谞讻讬诐:</strong> ".$d['accessibility']."</p>";
    $msg .= "<p><strong>讞讬讜转 诪讞诪讚:</strong> ".$d['pets']."</p>";
    $msg .= "<p><strong>诪专驻住转:</strong> ".$d['balcony']."</p>";
    $msg .= "<p><strong>讞爪专:</strong> ".$d['courtyard']."</p>";
    $msg .= "<p><strong>住讜讙 讞讬诪讜诐:</strong> ".$d['heating']."</p>";
    $msg .= "<p><strong>诪讝讙谉 讟讜专谞讚讜:</strong> ".$d['tornado']."</p>";
    $msg .= "<p><strong>诪砖讜驻爪转:</strong> ".$d['renovated']."</p>";
    $msg .= "<p><strong>诪专讜讛讟转:</strong> ".$d['furnished']."</p>";
    $msg .= "<p><strong>讘讘诇注讚讬讜转:</strong> ".$d['exclusive']."</p>";
    $msg .= "<p><strong>诇砖讜转驻讬诐:</strong> ".$d['roommates']."</p>";
    $msg .= "<p><strong>诪诪&quot;拽:</strong> ".$d['mamak']."</p>";
    $msg .= "<p><strong>诪拽诇讟 讘讘谞讬讬谉:</strong> ".$d['shelter']."</p>";
    if (!empty($d['more_infos'])) {
        $msg .= "<p><strong>诪讬讚注 谞讜住祝 注诇 讛谞讻住:</strong> ".htmlspecialchars($d['more_infos'])."</p>";
    }
    $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";

    $msg .= "<h3 style='color:#0070ba;'>转讻讜诇讛 讘谞讻住</h3>";
    $amenities = [];
    if ($d['refrigerator'] == '1') $amenities[] = '诪拽专专';
    if ($d['tanur']        == '1') $amenities[] = '转谞讜专';
    if ($d['kira']         == '1') $amenities[] = '讻讬专讛';
    if ($d['micro']        == '1') $amenities[] = '诪讬拽专讜';
    if ($d['kelim']        == '1') $amenities[] = '诪讚讬讞 讻诇讬诐';
    if ($d['kvisa']        == '1') $amenities[] = '诪讻讜谞转 讻讘讬住讛';
    if ($d['meyavesh']     == '1') $amenities[] = '诪讬讬讘砖 讻讘讬住讛';
    if ($d['shida']        == '1') $amenities[] = '砖讬讚转 住诇讜谉';
    if ($d['tv']           == '1') $amenities[] = '讟诇讜讬讝讬讛';
    if ($d['mita']         == '1') $amenities[] = '诪讬讟转 砖讬谞讛';
    if ($d['salon']        == '1') $amenities[] = '住诇讜谉';
    if ($d['shulhan']      == '1') $amenities[] = '砖讜诇讞谉 讗讜讻诇';
    if ($d['aron']         == '1') $amenities[] = '讗专讜谉 讘讙讚讬诐';
    $msg .= !empty($amenities) ? "<p>".implode(' &nbsp;|&nbsp; ', $amenities)."</p>" : "<p>讗讬谉 转讻讜诇讛 诪爪讜讬谞转</p>";
    if (!empty($d['more_infos2'])) {
        $msg .= "<p><strong>诪讬讚注 谞讜住祝 注诇 转讻讜诇讛:</strong> ".htmlspecialchars($d['more_infos2'])."</p>";
    }

    if (!empty($d['list_images'])) {
        $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";
        $msg .= "<h3 style='color:#0070ba;'>转诪讜谞讜转</h3>";
        foreach (explode(',', $d['list_images']) as $img_file) {
            $img_file = trim($img_file);
            if (!empty($img_file)) {
                $img_url = 'https://web4yoo.com/leumi/site/uploads/' . rawurlencode($img_file);
                $msg .= "<img src='".$img_url."' alt='转诪讜谞转 谞讻住' style='max-width:200px;max-height:150px;margin:5px;border:1px solid #ddd;border-radius:4px;'>";
            }
        }
    }

    $msg .= "<hr style='border:1px solid #ddd;margin:20px 0;'>";
    $msg .= "<p style='margin-top:20px;'>";
    $msg .= "<a href='https://web4yoo.com/leumi/site/single-property.php?id=".$property_id."' style='display:inline-block;padding:12px 24px;background-color:#6c757d;color:white;text-decoration:none;border-radius:5px;font-size:15px;margin-left:10px;'>&#128269; 爪驻讛 讘谞讻住</a> ";
    $msg .= "<a href='https://web4yoo.com/leumi/site/valid_property.php?id=".$property_id."' style='display:inline-block;padding:12px 24px;background-color:#28a745;color:white;text-decoration:none;border-radius:5px;font-size:15px;'>&#10003; 讗砖专 谞讻住</a>";
    $msg .= "</p>";
    $msg .= "</body></html>";
    return $msg;
}
$id=$_POST['property_id'];
function dmYtoYmd($dt)
{
    if (strpos($dt, ' ') !== false)
        $dt = explode(' ', $dt ? $dt : '')[0];
    $dts = explode('/', $dt ? $dt : '');
    if (count($dts) <> 3)
        return '';
    else 
        return $dts[2].'-'.$dts[1].'-'.$dts[0];
}

// Traitement des cases 脿 cocher (checkboxes) - conversion en entiers pour la BDD
$refrigerator = isset($_POST['refrigerator']) ? 1 : 0;
$tanur = isset($_POST['tanur']) ? 1 : 0;
$kira = isset($_POST['kira']) ? 1 : 0;
$micro = isset($_POST['micro']) ? 1 : 0;
$kelim = isset($_POST['kelim']) ? 1 : 0;
$kvisa = isset($_POST['kvisa']) ? 1 : 0;
$meyavesh = isset($_POST['meyavesh']) ? 1 : 0;
$shida = isset($_POST['shida']) ? 1 : 0;
$tv = isset($_POST['tv']) ? 1 : 0;
$mita = isset($_POST['mita']) ? 1 : 0;
$salon = isset($_POST['salon']) ? 1 : 0;
$shulhan = isset($_POST['shulhan']) ? 1 : 0;
$aron = isset($_POST['aron']) ? 1 : 0;

// Traitement des images - conversion d'array en cha卯ne s茅par茅e par des virgules
$list_images = '';

if (isset($_POST['list_images'])) {
    if (is_array($_POST['list_images'])) {
        // Si c'est un array, on le convertit en cha卯ne
        $clean_images = array_filter($_POST['list_images'], function($img) {
            return !empty(trim($img)) && is_string($img);
        });
        $list_images = implode(',', $clean_images);
    } else {
        // Si c'est une cha卯ne, v茅rifier si elle contient une repr茅sentation d'array
        $raw_string = trim($_POST['list_images']);
        
        // Cas 1: Cha卯ne normale s茅par茅e par des virgules
        if (strpos($raw_string, 'Array') === false && strpos($raw_string, '[0]') === false) {
            $list_images = $raw_string;
        } else {
            // Cas 2: Cha卯ne contenant une repr茅sentation d'array
            // Extraire les noms de fichiers avec une regex
            if (preg_match_all('/\[(\d+)\]\s*=>\s*([^\s\n\r]+)/', $raw_string, $matches)) {
                $extracted_files = $matches[2]; // Les noms de fichiers captur茅s
                $list_images = implode(',', $extracted_files);
            } else {
                // Fallback: essayer d'extraire simplement les extensions de fichiers
                if (preg_match_all('/([a-zA-Z0-9_-]+\.(jpg|jpeg|png|gif|webp))/i', $raw_string, $matches)) {
                    $extracted_files = $matches[1];
                    $list_images = implode(',', array_unique($extracted_files));
                } else {
                    $list_images = '';
                }
            }
        }
    }
}

// Debug : afficher la valeur finale de list_images
// error_log("list_images final nettoy茅: " . $list_images);

$formatted_date = dmYtoYmd($_POST['date_entry']);
if($id > 0){
    echo $up = "UPDATE rent_properties SET name_property = '".$title."', surface = '".$surface."', nb_rooms = '".$nb_rooms."', nb_bathrooms = '".$nb_bathrooms."', price_monthly = '".$price_monthly."', price_vaad = '".$price_vaad."', price_arnona = '".$price_arnona."', title = '".$title."', description = '".$description."', date_entry = '".$formatted_date."', type_property = '".$type_property."', type_location = '".$type_location."', latitude = '".$latitude."', longitude = '".$longitude."', address = '".$address."', region = '".$region."', city = '".$city."', neighborhood = '".$neighborhood."', floor = '".$floor."', nb_floor = '".$nb_floor."', parking = '".$parking."', elevator = '".$elevator."', air_cond = '".$air_cond."', mamad = '".$mamad."', multib_doors = '".$multib_doors."', bars = '".$bars."', heater = '".$heater."', storeroom = '".$storeroom."', accessibility = '".$accessibility."', pets = '".$pets."', balcony = '".$balcony."', courtyard = '".$courtyard."', heating = '".$heating."', renovated = '".$renovated."', furnished = '".$furnished."', exclusive = '".$exclusive."', roommates = '".$roommates."', mamak = '".$mamak."', shelter = '".$shelter."', more_infos = '".$more_infos."', refrigerator = ".$refrigerator.", tanur = ".$tanur.", kira = ".$kira.", micro = ".$micro.", kelim = ".$kelim.", kvisa = ".$kvisa.", meyavesh = ".$meyavesh.", shida = ".$shida.", tv = ".$tv.", mita = ".$mita.", salon = ".$salon.", shulhan = ".$shulhan.", aron = ".$aron.", tornado = '".$tornado."', more_infos2 = '".$more_infos2."', list_images = '".$list_images."', status = 2 WHERE id_property = ".$id;
    $query = mysqli_query($link, $up);

    // Envoi d'email de confirmation
    if($query) {
        $user_query = mysqli_query($link, "SELECT email, name FROM rent_users WHERE id = ".$_SESSION['user']['id']);
        $user_data = mysqli_fetch_array($user_query, MYSQLI_ASSOC);
        
        $subject = "转讜讚讛 注诇 注讚讻讜谉 讛谞讻住";
        $email_message = "<html><head><meta charset='UTF-8'></head><body dir='rtl'>";
        $email_message .= "<h2>砖诇讜诐 ".$user_data['name'].",</h2>";
        $email_message .= "<p>转讜讚讛 注诇 注讚讻讜谉 讛谞讻住 砖诇讱 诇讗转专 - 讗砖讻专讛.</p>";
        $email_message .= "<p>砖诐 讛谞讻住: ".$title."</p>";
        $email_message .= "<p>讻转讜讘转: ".$address."</p>";
        $email_message .= "<p>诪讞讬专 讞讜讚砖讬: 鈧".$price_monthly."</p>";
        $email_message .= "<p>讛谞讻住 砖诇讱 注讜讚讻谉 讘讛爪诇讞讛 讜转讻祝 讬讬讘讚拽 诇讗讬砖讜专.</p>";
        $email_message .= "</body></html>";
        
        sendEmail($user_data['email'], $subject, $email_message, '讗砖讻专讛 - 转讜讚讛 注诇 注讚讻讜谉 谞讻住');

        // Envoi d'email 脿 l'admin pour approbation
        $admin_subject = "谞讻住 诪诪转讬谉 诇讗讬砖讜专";
        $admin_data = array_merge($_POST, ['refrigerator'=>$refrigerator,'tanur'=>$tanur,'kira'=>$kira,'micro'=>$micro,'kelim'=>$kelim,'kvisa'=>$kvisa,'meyavesh'=>$meyavesh,'shida'=>$shida,'tv'=>$tv,'mita'=>$mita,'salon'=>$salon,'shulhan'=>$shulhan,'aron'=>$aron,'list_images'=>$list_images]);
        $admin_message = buildAdminPropertyEmail($admin_data, $id);
        sendEmail("hmichael26@gmail.com", $admin_subject, $admin_message, '讗砖讻专讛 - 讗讬砖讜专 谞讻住 讞讚砖');
        sendEmail("leumi67@gmail.com", $admin_subject, $admin_message, '讗砖讻专讛 - 讗讬砖讜专 谞讻住 讞讚砖');
    }

}else{
    $sql = "INSERT INTO rent_properties SET name_property = '".$title."', surface = '".$surface."', nb_rooms = '".$nb_rooms."', nb_bathrooms = '".$nb_bathrooms."', price_monthly = '".$price_monthly."', price_vaad = '".$price_vaad."', price_arnona = '".$price_arnona."', title = '".$title."', description = '".$description."', date_entry = '".$formatted_date."', type_property = '".$type_property."', type_location = '".$type_location."', latitude = '".$latitude."', longitude = '".$longitude."', address = '".$address."', region = '".$region."', city = '".$city."', neighborhood = '".$neighborhood."', floor = '".$floor."', nb_floor = '".$nb_floor."', parking = '".$parking."', elevator = '".$elevator."', air_cond = '".$air_cond."', mamad = '".$mamad."', multib_doors = '".$multib_doors."', bars = '".$bars."', heater = '".$heater."', storeroom = '".$storeroom."', accessibility = '".$accessibility."', pets = '".$pets."', balcony = '".$balcony."', courtyard = '".$courtyard."', heating = '".$heating."', renovated = '".$renovated."', furnished = '".$furnished."', exclusive = '".$exclusive."', roommates = '".$roommates."', mamak = '".$mamak."', shelter = '".$shelter."', more_infos = '".$more_infos."', refrigerator = ".$refrigerator.", tanur = ".$tanur.", kira = ".$kira.", micro = ".$micro.", kelim = ".$kelim.", kvisa = ".$kvisa.", meyavesh = ".$meyavesh.", shida = ".$shida.", tv = ".$tv.", mita = ".$mita.", salon = ".$salon.", shulhan = ".$shulhan.", aron = ".$aron.", tornado = '".$tornado."', more_infos2 = '".$more_infos2."', id_user = '".$_SESSION['user']['id']."', list_images = '".$list_images."', date_creation = NOW(), status = 1";
    // echo $sql;
    $query = mysqli_query($link, $sql);
    
    // Envoi d'email de confirmation
    if($query) {
        $user_query = mysqli_query($link, "SELECT email, name FROM rent_users WHERE id = ".$_SESSION['user']['id']);
        $user_data = mysqli_fetch_array($user_query, MYSQLI_ASSOC);
        
        $subject = "转讜讚讛 注诇 讛讜住驻转 讛谞讻住";
        $email_message = "<html><head><meta charset='UTF-8'></head><body dir='rtl'>";
        $email_message .= "<h2>砖诇讜诐 ".$user_data['name'].",</h2>";
        $email_message .= "<p>转讜讚讛 注诇 讛讜住驻转 讛谞讻住 砖诇讱 诇讗转专 - 讗砖讻专讛.</p>";
        $email_message .= "<p>砖诐 讛谞讻住: ".$title."</p>";
        $email_message .= "<p>讻转讜讘转: ".$address."</p>";
        $email_message .= "<p>诪讞讬专 讞讜讚砖讬: 鈧".$price_monthly."</p>";
        $email_message .= "<p>讛谞讻住 砖诇讱 注讜讚讻谉 讘讛爪诇讞讛. 转讜讻诇 诇专讗讜转 讗讜转讜 讘<a href='https://web4yoo.com/leumi/site/dashboard-my-properties.php'>讛诇讜讞 砖诇讱 讘住讟讟讜住 注专讬讻讛</a>.</p>";
        $email_message .= "</body></html>";
        
        sendEmail($user_data['email'], $subject, $email_message, '讗砖讻专讛 - 转讜讚讛 注诇 讛讜住驻转 谞讻住');

        // Envoi d'email 脿 l'admin pour approbation
        $new_id = mysqli_insert_id($link);
        $admin_subject = "谞讻住 诪诪转讬谉 诇讗讬砖讜专";
        $admin_data = array_merge($_POST, ['refrigerator'=>$refrigerator,'tanur'=>$tanur,'kira'=>$kira,'micro'=>$micro,'kelim'=>$kelim,'kvisa'=>$kvisa,'meyavesh'=>$meyavesh,'shida'=>$shida,'tv'=>$tv,'mita'=>$mita,'salon'=>$salon,'shulhan'=>$shulhan,'aron'=>$aron,'list_images'=>$list_images]);
        $admin_message = buildAdminPropertyEmail($admin_data, $new_id);
        sendEmail("hmichael26@gmail.com", $admin_subject, $admin_message, '讗砖讻专讛 - 讗讬砖讜专 谞讻住 讞讚砖');
        sendEmail("leumi67@gmail.com", $admin_subject, $admin_message, '讗砖讻专讛 - 讗讬砖讜专 谞讻住 讞讚砖');
    }

}
?>



web shell, Coded By 2019