comparador_BKP.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. require 'shared/extraeInfo.php';
  3. $accesoPortal = new AccesoPortal();
  4. error_reporting(0);
  5. if (isset($_POST['compare'])) {
  6. $arrComparador = json_decode($_POST['compare'],true);
  7. $arrJson = $_POST['compare'];
  8. if (!empty($arrComparador)) {
  9. foreach ($arrComparador as $key => $datos) {
  10. foreach ($datos as $key => $detalles) {
  11. $idx = $detalles['Id'];
  12. $model = $detalles['Model'];
  13. $serie = $detalles['codSerie'];
  14. $categoria = $detalles['catId'];
  15. $imagen = $accesoPortal->compara($model,$idx,$serie,$categoria);
  16. }
  17. }
  18. ?>
  19. <div class="row">
  20. <div id="compare" class="section">
  21. <div class="container title-only">
  22. <div class="row">
  23. <div class="col-md-12 section-title">
  24. <h2 id="compare-fans-header">Comparar ventiladores</h2>
  25. <hr>
  26. </div>
  27. </div>
  28. <div class="saved-container">
  29. <div class="row">
  30. <div class="col-md-5">
  31. <div class="saved-chart-container" style="margin-bottom:30px">
  32. <?php if(!empty($imagen)) echo $imagen; ?>
  33. </div>
  34. </div>
  35. <div class="col-md-7">
  36. <div class="saved-grid-container">
  37. <table id="saved-grid" style="width:100%;" class="table table-hover table-striped dt-responsive no-wrap">
  38. </table>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <script>
  47. if (compareEnabled) {
  48. $j("#saved-grid").DataTable({
  49. language: {
  50. url: 'js/0.js'
  51. },
  52. searching: false,
  53. lengthChange: false,
  54. data: [],
  55. responsive: {
  56. details: {
  57. type: 'column'
  58. },
  59. },
  60. rowId: 'RowId',
  61. columns: [
  62. {
  63. title: "", data: "Id", orderable: false, render: function (data, type, full, meta) {
  64. return "<a class=\"delete-saved\" style=\"cursor: pointer;\" onclick=\"removeFan(" + data + ")\" data-val=\"" + data + "\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i></a>";
  65. }
  66. },
  67. { data: "Model", title: ColumnCode, visible: true },
  68. { data: "Description", title: ColumnDescription, visible: true }
  69. /*{
  70. title: "", data: "Id", orderable: false, render: function (data, type, full, meta) {
  71. return "<a style=\"cursor: pointer;\" class='tree quickview btn btn-primary btn-xs' data-val=\"" + data + "\"><i class=\"fa fa-search\" aria-hidden=\"true\"></i> " + ViewStr + "</a>";
  72. // return ;
  73. }
  74. }*/
  75. ]
  76. });
  77. var $grid = $j('#saved-grid').DataTable();
  78. $grid.clear();
  79. //pasamos el array de php a Js
  80. var datos = '<?php echo $arrJson ?>';
  81. //le damos formato tipo json
  82. var res = datos.split('"').join("'");
  83. var json = JSON.stringify(eval("(" + res + ")"));
  84. arrToJson = JSON.parse(json);
  85. //los agregamos a la tabla
  86. for (var i = 0; i < arrToJson.datos.length; i++) {
  87. $grid.row.add(arrToJson.datos[i]).draw();
  88. }
  89. //desaparecer comparador si no tenemos datos
  90. if (Object.keys(arrToJson.datos).length === 0) {
  91. $j("#comparador").hide();
  92. }
  93. }
  94. </script>
  95. <?php
  96. }
  97. }
  98. //Imprimimos el modelo en 3D
  99. if (isset($_POST['url'])) {
  100. $url = trim($_POST['url']);
  101. //Mandamos a llamar el método getTablas
  102. $accesoPortal->buscarInfo($url);
  103. }
  104. // Extraer la tabla de modelos
  105. if (isset($_POST['table'])) {
  106. $url = $_POST['table'];
  107. extraerTabla($url);
  108. }
  109. function extraerTabla($url)
  110. {
  111. //echo $url;
  112. for ($i = 0; $i <= 5; $i++) {
  113. $arrProxies[0] = '187.188.168.57:9991';
  114. $arrProxies[1] = '148.217.94.54:3128';
  115. $arrProxies[2] = '187.189.96.94:9991';
  116. $arrProxies[3] = '187.162.11.94:3128';
  117. $arrProxies[4] = '177.234.0.218:43173';
  118. $arrProxies[5] = '187.178.238.177:3629';
  119. $proxy = $arrProxies[$i];
  120. $proxy = explode(":", $proxy);
  121. $ch = curl_init($proxy[0]);
  122. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  123. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  124. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  125. $data = curl_exec($ch);
  126. $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  127. if ($httpcode >= 200 && $httpcode < 300) {
  128. $proxyN = 'tcp://' . $arrProxies[$i];
  129. $context = array(
  130. 'http' => array(
  131. 'proxy' => $proxyN,
  132. 'request_fulluri' => True,
  133. ),
  134. );
  135. $context = stream_context_create($context);
  136. $contenido = file_get_contents($url, False, $context);
  137. if ($contenido) {
  138. $tablaHTML = "<div class='section section-grey'>";
  139. $seccionGris = strstr($contenido, "section section-grey");
  140. $removeFooter = strstr($seccionGris, "section cookie-warning", true);
  141. $tablaHTML .= ("<div class=\" " . $removeFooter . "\" >");
  142. $tablaHTML .= "</div>";
  143. echo $tablaHTML;
  144. } else {
  145. echo "<p style='text-align: center;'>El contenido no fue cargado correctamente, recargue la página.</p>";
  146. // $archivoActual = $_SERVER['PHP_SELF'];
  147. // header("refresh:1;url=".$archivoActual." ");
  148. }
  149. break;
  150. } else {
  151. $i = 0;
  152. }
  153. }
  154. curl_close($ch);
  155. }
  156. ?>