| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <?php
- class AccesoPortal
- {
- const HOST_ = 'easyvent.solerpalau.com'; //'www.oanda.com/lang/es/currency/classic-converter';
- const HEADER_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36';
- const HEADER_ACCEPT = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
- public static $URL_TC;
- public static $p;
- private $cookie;
- private $sesion;
- public function __construct()
- {
- //https://www.tracepartsonline.net/global/viewer.aspx?Mode=3DWebGL&xmp=-1-59-5SILENT100.xmp&previewCad=5SILENT100&h=30&w=30&version=3&Lang=en&fwsid=SOLER_PALAU_MX&CF=0&PMLOG=0&show2DToolbar=1
- self::$URL_TC = 'https://' . self::HOST_ . '/callbacks.aspx?m=UpdateTechnicalData&fanIndex=0&_=1545121360677';
- // Ocultar Warnings por errores de HTML
- libxml_use_internal_errors(true);
- }
- /*
- * Realiza en inicio de sesión en el Portal de Oanda
- */
- public function buscarInfo($url)
- {
- $urlSeccionada = explode('|',$url);
- $urlCompleta = $urlSeccionada[0];
- $modelo = $urlSeccionada[1];
- $headers = array(
- 'User-Agent' => 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 = "<img src='data:image/png;base64,".base64_encode($data)."' />";
- //***********************************************************
- $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 . '<br>';
-
- /*
- echo '<div class="product3d">
- <iframe src="https://www.tracepartsonline.net' . $src . '/global/viewer.aspx?Mode=3DWebGL&xmp=-1-59-'.$modelo.'.xmp&previewCad='.$modelo.'&h=440&w=460&version=3&Lang=en&fwsid=SOLER_PALAU_MX&CF=0&PMLOG=0&show2DToolbar=1" id="view3d" style="border:0;height:440px;width:100%;">
- </iframe>
- </div>';
- */
-
- /*
- Imprime en pantalla el modelo 3D según el producto
- */
- echo '<div class="product3d">
- <iframe src="https://www.traceparts.com/els/soler-palau-mx/en/api/viewer/3d?SupplierID=SOLER_PALAU_MX&PartNumber='.$modelo.'" id="view3d" style="border:0;height:440px;width:100%;">
- </iframe>
- </div>';
-
- //echo '<object type="text/html" data="https://www.tracepartsonline.net' . $src . '/global/viewer.aspx?Mode=3DWebGL&xmp=-1-59-5SILENT100.xmp&previewCad=5SILENT100&h=340&w=360&version=3&Lang=en&fwsid=SOLER_PALAU_MX&CF=0&PMLOG=0&show2DToolbar=1" width="360" height="340"></object><br>';
- //echo '<object type="text/html" data="https://easyvent.solerpalau.com/images/products/19-RD04.jpg?w=125" width="125" height="125"></object>';
- /*echo $imagen;
- echo '<table id="tblAccessories" class="table table-striped">' .
- '<tr>' .
- '<td class="accessoryImage"><img src="https://easyvent.solerpalau.com/images/products/19-RD04.jpg?w=125" /></td><td class="accessoryLabel">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.</td>' .
- '</tr><tr>' .
- '<td class="accessoryImage"><img src="https://easyvent.solerpalau.com/images/products/19-IE0noimagen.jpg?w=125" /></td><td class="accessoryLabel">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.</td>' .
- '</tr><tr>' .
- '<td class="accessoryImage"><img src="https://easyvent.solerpalau.com/images/products/19-CS03.jpg?w=125" /></td><td class="accessoryLabel">ACC CONTROL SIMULTANEO VENT - Permite regular la operación del ventilador de acuerdo con el porcentaje de humedad indicado, garantizando las condiciones internas deseadas.<br><strong>Características:</strong><br><li>Ideal para su colocación en baños, cocinas o lavanderías.</li><li>Precaución: La humedad del aire fuera del recinto, debe ser menor que la humedad dentro del recinto, para que el sensor funcione correctamente.</li><li>Aumenta el control del flujo dependiendo de las necesidades del usuario</li></td>' .
- '</tr><tr>' .
- '<td class="accessoryImage"><img src="https://easyvent.solerpalau.com/images/products/19-DFA.jpg?w=125" /></td><td class="accessoryLabel">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.</td>' .
- '</tr><tr>' .
- '<td class="accessoryImage"><img src="https://easyvent.solerpalau.com/images/products/19-HSnW.jpg?w=125" /></td><td class="accessoryLabel">HS4W PERSIANA 3 ALETAS 4 (DEF LE) - Persianas de sobrepresión construidas en material termoplástico estabilizado contra los rayos UV.</td>' .
- '</tr>' ,
- '</table>';*/
- }
- 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 = "<img src='data:image/png;base64,".base64_encode($data)."' />";
- 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 = "<div class='section section-grey'>";
- $seccionGris = strstr($body, "section section-grey");
- $removeFooter = strstr($seccionGris, "section cookie-warning",true);
- $tablaHTML .= ("<div class=\" ".$removeFooter."\" >");
- $tablaHTML .= "</div>";
- 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();
|