Example #1
0
        $new_name = md5($ruta);
        $new_file_name = $template_dir . "/images/apartamentos/" . $new_name . "." . $img_ext;
        if (!file_exists($new_file_name)) {
            file_put_contents($new_file_name, file_get_contents($ruta));
        }
        $new_ruta = $template_url . "/images/apartamentos/" . $new_name . "." . $img_ext;
        $imagenes[$e_k]['ruta'] = $new_ruta;
    }
    $imagenes[$e_k]['tipo'] = 'imagen';
    $imagenes[$e_k]['extension'] = 'jpg';
}
$hoteles = getHotelByUrl($hotel_url);
if ($hoteles && count($hoteles) > 0) {
    foreach ($hoteles as $h) {
        deleteHotelServicios($h->id);
        deleteHotelImages($h->id);
        deleteHotel($h->id);
    }
}
$descripcion = $html('#summary');
$descripcion_larga = trim($descripcion[0]->getInnerText());
$nombre = $html('#hp_hotel_name');
$nombre = trim($nombre[0]->getInnerText());
$rating = $html('#wrap-hotelpage-top h1 span.use_sprites');
if (isset($rating[0]) && strlen($rating[0]->getAttribute('title')) > 0) {
    $rating = filter_var($rating[0]->getAttribute('title'), FILTER_SANITIZE_NUMBER_INT);
} else {
    $rating = 0;
}
$hotel = array('descripcionLarga' => $descripcion_larga, 'url' => $hotel_url, 'estado' => 'activo', 'visitas' => 0, 'nombre' => $nombre, 'calidad' => (int) $rating);
$hotel_id = insertHotel($hotel);
Example #2
0
             if (isset($longitude) && isset($latitude)) {
                 updateDireccionByHotelId($hotel->id, array('lat' => $latitude, 'lon' => $longitude));
             }
         }
     }
     $data_hotel = array('descripcionLarga' => json_encode($descripciones_largas_array), 'nombre' => $nombreHotel, 'calidad' => (int) $rating);
     updateHotelData($hotel->id, $data_hotel);
     foreach ($servicios_array as $servicio) {
         inserHotelServicio(array('categoria' => json_encode($servicio['categoria']), 'servicio' => json_encode($servicio['servicio'])), $hotel->id);
     }
     foreach ($condiciones_array as $servicio) {
         inserHotelCondicion(array('categoria' => json_encode($servicio['categoria']), 'servicio' => json_encode($servicio['servicio'])), $hotel->id);
     }
     inserHotelTenerEnCuenta(json_encode($tener_en_cuenta_array), $hotel->id);
 } else {
     deleteHotelImages($hotel->id);
     $url = $hotel_url;
     $contexto = stream_context_create($opciones);
     $content = file_get_contents($url, false, $contexto);
     $html = str_get_dom($content);
     $photos = $html('#photos_distinct a');
     foreach ($photos as $e_k => $element) {
         $imagen = array();
         $ruta = false;
         if (strlen($element->getAttribute('data-resized')) > 0) {
             $ruta = trim($element->getAttribute('data-resized'));
         } else {
             if (strlen($element->getAttribute('href')) > 0) {
                 $ruta = trim($element->getAttribute('href'));
             }
         }
Example #3
0
function deleteHotel($idHotel, $transactional = true)
{
    try {
        if ($transactional) {
            $transaction = new Transaction();
        }
        $hotel = DAOFactory::getHotelDAO()->load($idHotel);
        deleteHotelServicios($idHotel, false);
        deleteHotelImages($idHotel, false);
        deleteHotelCondiciones($idHotel, false);
        deleteHotelDirecciones($idHotel, false);
        deleteReservasByHotelId($idHotel);
        DAOFactory::getHotelIdiomaDAO()->deleteByHotelId($hotel->id);
        DAOFactory::getHotelMonedaDAO()->deleteByHotelId($hotel->id);
        DAOFactory::getHotelDominiosDAO()->deleteByHotelId($hotel->id);
        DAOFactory::getHotelFechasDAO()->deleteByHotelId($idHotel);
        DAOFactory::getPromocionDAO()->deleteByHotelId($idHotel);
        DAOFactory::getBlackListDAO()->deleteByHotelId($idHotel);
        DAOFactory::getHotelPrecioDAO()->deleteByHotelId($idHotel);
        DAOFactory::getBusquedaDisponibilidadDAO()->deleteByHotelId($idHotel);
        DAOFactory::getHotelDAO()->delete($hotel->id);
        if ($transactional) {
            $transaction->commit();
        }
        return true;
    } catch (Exception $e) {
        print_r($e);
        if ($transaction) {
            $transaction->rollback();
        }
        return false;
    }
}