mira te dejo el code para que lo mires.
Código PHP:
function CIC_V($api_key, $rol, $tip_cuaderno, $cod_tribunal, $crr_IdCuaderno, $crr_IdCausa)
{
$this->init($api_key);
if($this->fSocket)
{
$rol_c = explode("-", $rol);
$data = array();
$data['TIP_Consulta'] = "1";
$data['TIP_Cuaderno'] = $tip_cuaderno;
$data['CRR_IdCuaderno'] = $crr_IdCuaderno;
$data['ROL_Causa'] = $rol_c[1];
$data['TIP_Causa'] = $rol_c[0];
$data['ERA_Causa'] = $rol_c[2];
$data['CRR_IdCausa'] = $crr_IdCausa;
$data['COD_Tribunal'] = $cod_tribunal;
$data['TIP_Informe'] = "1";
$url = "laweb.com";
$get_data = $this->compile_post_data($data);
$url_get = $url. "" .$get_data;
$this->load_defaults();
$this->setopt(CURLOPT_POST, 0);
$this->setopt(CURLOPT_CUSTOMREQUEST,'GET');
$this->setopt(CURLOPT_URL, $url_get);
$result = curl_exec($this->fSocket);
$this->destroy();
$html = str_get_html($result);
$bytes = strlen($result);
$conn = mysql_connect("localhost", "root", "root");
mysql_select_db("judiscap");
foreach($html->find('script') as $e)
{
$qtip = explode("TIP_Cuaderno.value", $e);
if (is_array($qtip) == "Array"):
array_shift($qtip);
$nro_arr = count($qtip);
else:
$nro_arr = "1";
endif;
}
foreach($html->find('select') as $e)
{
$q = explode("<option value=", $e);
if (is_array($q) == "Array"):
array_shift($q);
$nro_arr = count($q);
else:
$nro_arr = "1";
endif;
}
$sql = "SELECT * FROM bd_api WHERE rit = '" .$rol. "'";
$consulta = mysql_query($sql) or die(mysql_error());
$data = mysql_fetch_array($consulta);
$nros_cuadernos_bd = $data['nros_cuadernos'];
$cant_cuadernos_bd = $data['cant_cuadernos'];
$todos_cuadernos = array($nros_cuadernos);
$todos_TIP_Cuaderno = array($tip_cuaderno_live);
for($i=0; $i<=$nro_arr-1; $i++):
$nros_cuadernos = ereg_replace("[^0-9]", "", $q[$i]);
$todos_cuadernos[$i] = $nros_cuadernos;
$tip_cuaderno = ereg_replace(".=", "", $qtip[$i]);
$tip_cuaderno_exp = explode(";", $tip_cuaderno);
$tip_cuaderno_live = str_replace("'", "", $tip_cuaderno_exp[0]);
$todos_TIP_Cuaderno[$i] = trim($tip_cuaderno_live) ;
if($i === $nro_arr-1): // Ultima iteracion del bucle.
$arr_to_string = implode("_", $todos_cuadernos);
$arr_to_string_TIP_C = implode("_", $todos_TIP_Cuaderno);
if ($cant_cuadernos_bd < $nro_arr OR $cant_cuadernos_bd == 0):
$sql = "UPDATE bd_api SET cant_cuadernos = " .$nro_arr. " WHERE rit = '" .$rol. "'";
$consulta = mysql_query($sql, $conn);
$sql = "UPDATE bd_api SET nros_cuadernos = '" .$arr_to_string. "' WHERE rit = '" .$rol. "'";
$consulta = mysql_query($sql, $conn);
endif;
$crr_cuadernos = explode("_", $arr_to_string);
$api_key = "615wcBop0912MlKppA543AA";
$books_bd = explode("_", $nros_cuadernos_bd);
$t_arr = count($todos_TIP_Cuaderno);
for($i=0; $i<=$t_arr-1; $i++):
$call = $this->Revisa_Cuadernos($api_key, $todos_cuadernos[$i], $todos_TIP_Cuaderno[$i], $rol, $cod_tribunal);
$BYTES_CUADERNO = strlen($call['llamada']);
$tot = $tot + $BYTES_CUADERNO;
if(!in_array($todos_cuadernos[$i], $books_bd)):
echo "CUADERNO NUEVO: " .$rol. " " .$todos_cuadernos[$i]. "\n\r";
endif;
endfor;
endif;
endfor;
return array('bytes_pjud' => $tot, //$bytes,
'llamada_pud' => $result,
'url' => $url_get,
'escapado_html' => htmlspecialchars($result),
'http_code' => $http_code,
'cookie' => $Cookie_Civil,
'crr_cuadernos_live' => $todos_cuadernos,
'TIP_Cuadernos_Live' => $todos_TIP_Cuaderno);
}
return 0;
}
}
gracias.