?

áEÓê¤ÎïLwebshll2019

Current Path : /home/webyoo/www/leumi/site/
Upload File :
Current File : /home/webyoo/www/leumi/site/price_estimate.php

<?php
include "start.php";
header('Content-Type: application/json; charset=utf-8');

// Estimation du loyer moyen de biens comparables (gratuit, basé sur nos données).
// Repli automatique : quartier -> région -> ville.
$city         = isset($_REQUEST['city'])         ? trim($_REQUEST['city'])         : '';
$region       = isset($_REQUEST['region'])       ? trim($_REQUEST['region'])       : '';
$neighborhood = isset($_REQUEST['neighborhood']) ? trim($_REQUEST['neighborhood']) : '';
$rooms        = isset($_REQUEST['rooms'])        ? (int)$_REQUEST['rooms']         : 0;
$excludeId    = isset($_REQUEST['exclude'])      ? (int)$_REQUEST['exclude']       : 0;

$scopes = array();
if ($neighborhood !== '') { $scopes[] = array('col' => 'neighborhood', 'val' => $neighborhood, 'min' => 2); }
if ($region !== '')       { $scopes[] = array('col' => 'region',       'val' => $region,       'min' => 2); }
if ($city !== '')         { $scopes[] = array('col' => 'city',         'val' => $city,         'min' => 1); }

$out = array('ok' => false);
foreach ($scopes as $sc) {
    $vEsc     = mysqli_real_escape_string($link, $sc['val']);
    $roomCond = ($rooms > 0) ? " AND nb_rooms BETWEEN ".($rooms-1)." AND ".($rooms+1)." " : "";
    $exclCond = ($excludeId > 0) ? " AND id_property <> ".$excludeId." " : "";
    $q = mysqli_query($link, "SELECT AVG(price_monthly) a, COUNT(*) c, MIN(price_monthly) mn, MAX(price_monthly) mx
        FROM rent_properties
        WHERE status=3 AND price_monthly>0 AND ".$sc['col']."='".$vEsc."' ".$roomCond.$exclCond);
    $r = $q ? mysqli_fetch_assoc($q) : null;
    if ($r && (int)$r['c'] >= $sc['min'] && $r['a'] > 0) {
        $out = array(
            'ok'    => true,
            'avg'   => (int)round($r['a']),
            'min'   => (int)$r['mn'],
            'max'   => (int)$r['mx'],
            'count' => (int)$r['c'],
            'scope' => $sc['val']
        );
        break;
    }
}

echo json_encode($out, JSON_UNESCAPED_UNICODE);



web shell, Coded By 2019