self::HEADER_USER_AGENT,
'Referer' => self::$URL_TC,
);
$respuesta = RespuestaCurl::request('https://' . self::HOST_ . '/'.$urlCompleta, null, $headers);
// https://easyvent.solerpalau.com/fan-info/view/00019/192/594/p/5FUTURE-100/1
$html = $respuesta->getBody();
//echo $html;
//die();
$form = $this->getFormData($respuesta->getBody());
// echo $form['__VIEWSTATE'];
// echo $form['ctl00$ContentPlaceHolder1$AeroChart$aeroSettingsJSON'];
// var_dump($form);
$post = array( '__ASYNCPOST' =>'false',
'__EVENTARGUMENT' => '',
'__EVENTTARGET' => '',
'__VIEWSTATE' => $form['__VIEWSTATE'],
'__LASTFOCUS' => '',
'ctl00$ContentPlaceHolder1$ScriptManager1'=>'form1'
);
$respuesta = RespuestaCurl::request(self::$URL_TC, $post, $headers);
$html = $respuesta->getBody();
//echo($respuesta);
$array = json_decode($html, true);
// die();
//print($array['dutyPointTechnicalInformations'][0]['technicalData'][1]['Value']);
// $data = $array['chartMiniSourceLarge'];
// list($type, $data) = explode(';', $data);
// list(, $data) = explode(',', $data);
// $data = base64_decode($data);
// file_put_contents('imagen3.png', $data);
// $imagen = " ";
//***********************************************************
$respuesta = RespuestaCurl::request('https://www.tracepartsonline.net/global/viewer.aspx?Mode=3DWebGL&xmp=-1-49-'.$modelo.'.xmp&previewCad='.$modelo.'&h=340&w=360&version=3&Lang=en&fwsid=SOLER_PALAU_MX&CF=0&PMLOG=0&show2DToolbar=1', null, array('User-Agent' => self::HEADER_USER_AGENT, 'Referer' => 'www.tracepartsonline.net'));
$html = $respuesta->getRequestHeader();
$src = string_get_before((string)$html, '/global/viewer.aspx');
$src = string_get_after($src, 'GET ' );
$respuesta = RespuestaCurl::request('https://www.tracepartsonline.net' . $src . '/ws/SOLER_PALAU_MX/reference.aspx?reference='.$modelo.'', null, array('User-Agent' => self::HEADER_USER_AGENT, 'Referer' => 'www.tracepartsonline.net'));
$html = $respuesta->getBody();
//$respuesta = RespuestaCurl::request('https://www.tracepartsonline.net' . $src . '/global/viewer.aspx?Mode=3DWebGL&xmp=-1-59-'.$modelo.'.xmp&previewCad='.$modelo.'&h=340&w=360&version=3&Lang=en&fwsid=SOLER_PALAU_MX&CF=0&PMLOG=0&show2DToolbar=1', null, array('User-Agent' => self::HEADER_USER_AGENT, 'Referer' => 'www.tracepartsonline.net'));
//$html = $respuesta->getBody();
// echo $src . ' ';
/*
echo '
';
*/
/*
Imprime en pantalla el modelo 3D según el producto
*/
echo '
';
//echo ' ';
//echo ' ';
/*echo $imagen;
echo '' .
'' .
'ACC REGULADOR VEL. DESLIZABLE - Utilizable en aplicaciones de gama hábitat, debido a su agradable presentación y fácil manejo. Monofasico 127V AC 60 Hz. Fabricados en plástico y certificados con normativa UL de seguridad. Color blanco. ' .
' ' .
'ACC INTERRUPTOR ELECTRONICO - Utilizable en aplicaciones de gama hábitat, debido a su agradable presentación y fácil manejo. Monofasico 127V AC 60 Hz. Fabricados en plástico y certificados con normativa UL de seguridad. Cuenta con 4 diferentes rangos de tiempo delimitables por el usuario. Rango de carga para el temporizador de 20A/1HP. Color blanco. ' .
' ' .
'ACC CONTROL SIMULTANEO VENT - Permite regular la operación del ventilador de acuerdo con el porcentaje de humedad indicado, garantizando las condiciones internas deseadas.Características: Ideal para su colocación en baños, cocinas o lavanderías. Precaución: La humedad del aire fuera del recinto, debe ser menor que la humedad dentro del recinto, para que el sensor funcione correctamente. Aumenta el control del flujo dependiendo de las necesidades del usuario ' .
' ' .
'FL0425 DUCTO FLEX.DE ALUM.4X2 5 2 DEFLE - Aplicable a los extractores de cocina, baños y la serie TD, y en general en cualquier sistema de ventilación. ' .
' ' .
'HS4W PERSIANA 3 ALETAS 4 (DEF LE) - Persianas de sobrepresión construidas en material termoplástico estabilizado contra los rayos UV. ' .
' ' ,
'
';*/
}
public function getArrayDatos()
{
$headers = array(
'User-Agent' => self::HEADER_USER_AGENT,
'Referer' => self::$URL_TC,
);
$respuesta = RespuestaCurl::request('https://' . self::HOST_ . '/fan-info/view/00019/192/595/p/5SILENT100/1/', null, $headers);
$form = $this->getFormData($respuesta->getBody());
//echo $form['__VIEWSTATE'];
//print_r($form);
$post = array( '__ASYNCPOST' =>'false',
'__EVENTARGUMENT' => '',
'__EVENTTARGET' => '',
'__VIEWSTATE' => $form['__VIEWSTATE'],
'__LASTFOCUS' => '',
'ctl00$ContentPlaceHolder1$ScriptManager1'=>'form1'
);
$respuesta = RespuestaCurl::request(self::$URL_TC, $post, $headers);
$html = $respuesta->getBody();
$array = json_decode($html, true);
//print_r($array);
print($array['dutyPointTechnicalInformations'][0]['technicalData'][1]['Value']);
die();
$data = $array['chartSource'];
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
file_put_contents('imagen.png', $data);
echo $html;
die();
}
public function compara($modelo,$numero,$serie,$categoria)
{
$headers = array(
'User-Agent' => self::HEADER_USER_AGENT,
'Referer' => self::$URL_TC,
);
$respuesta = RespuestaCurl::request('https://' . self::HOST_ . '/series-info/'.$serie.'/'.$categoria, null, $headers);
$html = $respuesta->getBody();
$form = $this->getFormData($respuesta->getBody());
$respuesta = RespuestaCurl::request('https://easyvent.solerpalau.com/callbacks.aspx?m=CloneFan&datarow='.$numero.'&model='.$modelo.'&series='.$serie.'&cat='.$categoria.'&sku=p&_='.time(), null, array('User-Agent' => self::HEADER_USER_AGENT, 'Referer' => 'easyvent.solerpalau.com'));
// ultima llamada para generar la imagen(no mover)
$respuesta = RespuestaCurl::request('https://easyvent.solerpalau.com/chartimage.aspx?m=1&s='.$serie.'&w=400&h=400&d=1552326936376', null, array('User-Agent' => self::HEADER_USER_AGENT, 'Referer' => 'easyvent.solerpalau.com'));
$data = $respuesta->getBody();
$imagen = " ";
return $imagen;
}
public function getTablaSoler($url)
{
$headers = array(
'User-Agent' => self::HEADER_USER_AGENT,
'Referer' => self::$URL_TC,
);
// $respuesta = RespuestaCurl::request('https://' . self::HOST_ . '/series-info/595/192', null, $headers);
$respuesta = RespuestaCurl::request($url, null, $headers);
$body = $respuesta->getBody();
$body = str_replace("../../", "https://easyvent.solerpalau.com/", $body);
$tablaHTML = "";
$seccionGris = strstr($body, "section section-grey");
$removeFooter = strstr($seccionGris, "section cookie-warning",true);
$tablaHTML .= ("
");
$tablaHTML .= "
";
echo $tablaHTML;
}
/**
* Devuelve el XML del CFDI como string
*/
public function obtenerXml($url)
{}
public function headerPortalCfdi($referer, $ajax){}
/**
* Guarda el XML del CFDI en la ruta especificada
*/
public function guardarXml($url, $nombre)
{}
public function guardarAcuse($url, $dir, $nombre)
{}
public function obtenerSesion()
{
return base64_encode(
json_encode(RespuestaCurl::getCookie())
);
}
public function restaurarSesion($sesion)
{}
private function getPostResponse($url, $post = null, $encabezados = null)
{
$response = RespuestaCurl::request($url, $post, $encabezados, true);
return $response;
}
private function getGetResponse($url, $encabezados = null)
{
$response = RespuestaCurl::request($url, null, $encabezados);
return $response;
}
private function getTableObjects($html)
{}
private function getFormData($html_source)
{
$document = new DOMDocument();
$document->loadHTML($html_source);
if ($document) {
$post = array();
// Configuración anterior.
// $form = $document->getElementsByTagName('form')->item(2);
$form = $document->getElementsByTagName('form')->item(0);
foreach (array('input', 'span') as $element) {
foreach ($form->getElementsByTagName($element) as $val) {
$name = $val->getAttribute('name');
$id = false;
if(empty($name))
{
$name = $val->getAttribute('id');
$id = true;
}
if (!empty($name)) {
$checked = $val->getAttribute('checked');
$value = NULL;
if ($val->nodeName == 'select') {
$opcion_seleccionada = $val->getElementsByTagName('option')->item(0)->getAttribute('selected');
if (!empty($opcion_seleccionada)) {
$value = $val->getElementsByTagName('option')->item(0)->nodeValue;
}
}
if (!empty($checked)) {
$post[$name] = utf8_decode($val->getAttribute('checked'));
} else if (!empty($value)) {
$post[$name] = $value;
} else if ($id) {
$post[$name] = $val->nodeValue;
} else {
$post[$name] = utf8_decode($val->getAttribute('value'));
}
}
}
}
return $post;
}
return null;
}
private function getFormResult($html_source)
{
$document = new DOMDocument();
$document->loadHTML($html_source);
if ($document) {
$classname = "result_msg";
$finder = new DomXPath($document);
$form = $finder->query("//*[contains(@class, '$classname')]");
$post = array();
foreach ($form as $node) {
foreach ($node->childNodes as $child) {
$post[] = array($child->nodeName => utf8_decode($child->nodeValue));
}
}
return $post;
}
return null;
}
private function obtenerArchivoString($url)
{}
}
function string_get_before($string, $before)
{
return substr($string, 0, strpos($string, $before));
}
function string_get_after($string, $after)
{
$pos = strpos($string, $after) + strlen($after);
return substr($string, $pos, strlen($string) - $pos);
}
class filaInfo
{
public $rfc;
public $nombre;
public $correo;
public $servicio;
public $ultimoMovimiento;
public $siguientePaso;
public $linkEmisor;
public $linkSaldo;
}
class RespuestaCurl
{
private $respuesta;
private static $cookie = array();
public function __construct($respuesta)
{
$this->respuesta = $respuesta;
}
public static function setCookie($cookie)
{
self::$cookie = $cookie;
return true;
}
public static function request($url, $post = null, $headers = null, $useCookies = true)
{
$options = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "UTF-8",
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120,
CURLOPT_TIMEOUT => 120,
CURLOPT_MAXREDIRS => 10,
CURLINFO_HEADER_OUT => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1
);
if ($useCookies) {
if ($cookie = self::getCookieString()) {
$options[CURLOPT_COOKIE] = $cookie;
}
}
if ($post) {
if (empty($headers)) {
$headers = array();
}
$options[CURLOPT_POST] = 1;
$options[CURLOPT_POSTFIELDS] = http_build_query($post);
} else {
$options[CURLOPT_CUSTOMREQUEST] = 'GET';
}
if ($headers) {
$postStr = array();
foreach ($headers as $key => $value) {
$postStr[] = $key . ': ' . $value;
}
$options[CURLOPT_HTTPHEADER] = $postStr;
}
$ch = curl_init();
curl_setopt_array($ch, $options);
$rough_content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch);
$header = curl_getinfo($ch);
$multi = curl_multi_getcontent($ch);
curl_close($ch);
$header_content = substr($rough_content, 0, $header['header_size']);
$body_content = trim(str_replace($header_content, '', $rough_content));
preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $header_content, $matches);
$cookies = array();
foreach ($matches[1] as $item) {
$pos = strpos($item, '=');
$cookies[substr($item, 0, $pos)] = substr($item, $pos + 1);
}
self::$cookie = array_merge(self::$cookie, $cookies);
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['headers'] = $header_content;
$header['content'] = $body_content;
$header['cookies'] = $cookies;
$res = new self($header);
return $res;
}
public static function getCookie()
{
return self::$cookie;
}
public function getStatusCode()
{
return $this->respuesta['http_code'];
}
public function getBody()
{
return $this->respuesta['content'];
}
public function getRequestHeader()
{
return $this->respuesta['request_header'];
}
private static function getCookieString()
{
if (!empty(self::$cookie)) {
$str = '';
foreach (self::$cookie as $key => $value) {
$str .= $key . '=' . $value . '; ';
}
$str = rtrim($str, '; ');
return $str;
}
return '';
}
}
// $url ="https://easyvent.solerpalau.com/series-info/594/192";
// $accesoPortal = new AccesoPortal();
// echo $accesoPortal-> buscarInfo();