[insert_php] function get_data($url) {
//$url = “http://www.google.com/search?q=”.$strSearch.”&hl=en&start=0&sa=N”;
$ch = curl_init();
$timeout = 5;
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2’);
$data = curl_exec($ch);
curl_close($ch);

return $data;

}

$returned_content = get_data(‘http://lecheriasantos.com/aurbinag/ultimoordeno’);

//echo $returned_content;
$document = new DOMDocument();
libxml_use_internal_errors(true);
$document->loadHTML($returned_content);
$selector = new DOMXPath($document);
$anchors = $selector->query(‘/html/body’);

$time = date(“Y-m-d”);
$t=time();
$yesterday = date(‘Y-m-d’, strtotime($time . ” – 1 day”));
//echo $yesterday ;
$timestamp_5 = strtotime(“$yesterday 5:30:00”);
$timestamp_10 = strtotime(“$yesterday 13:00:00”);
$timestamp_13 = strtotime(“$yesterday 13:30:00”);
$timestamp_18 = strtotime(“$yesterday 21:00:00”);
$timestamp_21 = strtotime(“$yesterday 21:30:00”);
$timestamp_2 = strtotime(“$time 5:00:00”);

foreach($anchors as $head) {

$text1 = $head->nodeValue;
//print_r($text1);
$array1 = explode(PHP_EOL,$text1);
$c=0;
$b=1;

echo ‘

‘;
$q=0;
foreach($array1 as $tr1){
$T = substr($tr1,0,1);
$grp = substr($tr1,6,2);
$total_cow = substr($tr1,1,5);
if($q == 1){

$current_time = substr($tr1,11,7);

}
$q++;
if($T == ‘T’ && $grp == ‘ ‘ )
{
$timestamp_current = strtotime(“$time $current_time”);

echo ‘‘;

if($timestamp_5 <= $timestamp_current && $timestamp_current <= $timestamp_10 ){ echo 'Ordeño Mañana:'.$total_cow; } else if($timestamp_13 <= $timestamp_current && $timestamp_current <= $timestamp_18){ echo 'Ordeño Trade:'.$total_cow; } else if($timestamp_21 <= $timestamp_current && $timestamp_current <= $timestamp_2 ){ echo 'Ordeño Noche:'.$total_cow; } else{ echo 'Ordeño XXX:'.$total_cow.','; } } } echo '‘;
echo ‘
‘;
foreach($array1 as $tr){
if($c < 2) { $f = substr($tr,0,9); if($f =="Fecha "){ echo '‘;
echo ” “;
echo ‘
‘;
}
else{
echo ‘‘;
$d = substr($tr,0,9);
$userTimezone = new DateTimeZone(‘America/New_York’);
$today = date(“M j, Y”);
echo $today ;
date_default_timezone_set(“America/New_York”);
$userTimezone = new DateTimeZone(‘America/New_York’);
$gmtTimezone = new DateTimeZone(‘GMT’);
$myDateTime = new DateTime($d , $gmtTimezone);
$offset = $userTimezone->getOffset($myDateTime);
//echo $offset;

}
echo ‘‘;
if($c==1){
echo ‘‘;
echo substr($tr,11,7).”|”;
echo ‘
‘;
//echo ‘‘;
// echo “,”;
//echo ‘
‘;
}
else{
echo ‘‘;
//echo substr($tr,9,7);
echo ‘
‘;
}
}
$c++;
}
echo ‘

‘;
echo ‘

‘;
}
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;

echo ‘

‘;
echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
foreach($anchors as $a) {

$text = $a->nodeValue;
//print_r($text);
$array = explode(PHP_EOL,$text);
$c=0;
$b=1;
foreach($array as $tr){
if($c >= 7)
{
$T = substr($tr,0,1);

if($T == “T”)
{

echo ‘

‘;
echo ‘

‘;
$group = substr($tr,6,2);
if($group == ‘ 2’)
{
$group2_cow= substr($tr,1,6);
$group2_ordeno= substr($tr,20,8);
$group2_ayer= substr($tr,28,7);
$group2_var= substr($tr,35,7);
$group2_0= substr($tr,42,8);
$group2_3= substr($tr,-8);
//echo $group2_cow;
}
if($group == ‘ ‘)
{
$group_null_cow= substr($tr,1,6);
$group_null_ordeno= substr($tr,20,8);
$group_null_ayer= substr($tr,28,7);
$group_null_var= substr($tr,35,7);
$group_null_0= substr($tr,42,8);
$group_null_3= substr($tr,-8);
//echo $group2_cow;
}
echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
$b++;
}
else{
$cow = substr($tr,1,6);
$sta = substr($tr,8,4);
if($T != ‘T’ && $T !=’ ‘)
{

}
else if(($cow ==” “&& $sta=” “)||($cow==” 100% “))
{

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

}
else
{
echo ‘

‘;
$firsttd = substr($tr,1,6);
echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;
}
}

}
$c++;
//echo $c;
}
}
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ”;
echo ‘
‘;
echo ‘
‘;
echo ‘Cow’;
echo ‘
‘;
echo ‘Grp’;
echo ‘
‘;
echo ‘DSLB’;
echo ‘
‘;
echo ‘DIM’;
echo ‘
‘;
if($timestamp_5 <= $timestamp_current && $timestamp_current <= $timestamp_10 ){ echo 'Ordeño Mañana'; } else if($timestamp_13 <= $timestamp_current && $timestamp_current <= $timestamp_18){ echo 'Ordeño Trade'; } else if($timestamp_21 <= $timestamp_current && $timestamp_current <= $timestamp_2 ){ echo 'Ordeño Noche'; } else{ echo 'Ordeño XXX '; } echo '
‘;
if($timestamp_5 <= $timestamp_current && $timestamp_current <= $timestamp_10 ){ echo 'Ayer Mañana'; } else if($timestamp_13 <= $timestamp_current && $timestamp_current <= $timestamp_18){ echo 'Ayer Trade'; } else if($timestamp_21 <= $timestamp_current && $timestamp_current <= $timestamp_2 ){ echo 'Ayer Noche'; } else{ echo 'Ayer XXX '; } echo '
‘;
echo ‘Var’;
echo ‘
‘;
echo ‘0+1+2’;
echo ‘
‘;
echo ‘3+4+5’;
echo ‘
‘;
echo ‘total’;
echo ‘
‘;
echo number_format(substr($tr,1,6));
echo ‘
‘;
echo substr($tr,6,2);
echo ‘
‘;
//echo substr($tr,12,4);
echo ” “;
echo ‘
‘;
echo substr($tr,16,4);
echo ‘
‘;
echo number_format(substr($tr,20,8) , 1);
echo ‘
‘;
echo number_format(substr($tr,28,7) , 1);
echo ‘
‘;
echo number_format(substr($tr,35,7) , 1);
echo ‘
‘;
echo number_format(substr($tr,42,8) , 1);
echo ‘
‘;
echo number_format(substr($tr,-8), 1);
echo ‘
‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘Cow’;
echo ‘
‘;
echo ‘Grp’;
echo ‘
‘;
echo ‘Sta’;
echo ‘
‘;
echo ‘DSLB’;
echo ‘
‘;
echo ‘DIM’;
echo ‘
‘;
echo ‘Ultimo’;
echo ‘
‘;
echo ‘Ayer’;
echo ‘
‘;
echo ‘Var’;
echo ‘
‘;
echo ‘0+1+2’;
echo ‘
‘;
echo ‘3+4+5’;
echo ‘

‘;
echo ‘

‘;
echo ‘
‘;
echo ‘Avg’;
echo ‘
‘;
echo substr($tr,1,6);
echo ‘
‘;
echo substr($tr,6,2);
echo ‘
‘;
echo substr($tr,12,4);
echo ‘
‘;
echo substr($tr,16,4);
echo ‘
‘;
echo substr($tr,20,8);
echo ‘
‘;
echo substr($tr,28,7);
echo ‘
‘;
echo substr($tr,35,7);
echo ‘
‘;
echo substr($tr,42,8);
echo ‘
‘;
echo substr($tr,-8);
echo ‘
‘;
if($firsttd != “======”)
echo substr($tr,1,6);
echo ‘
‘;
echo substr($tr,6,2);
echo ‘
‘;
echo substr($tr,8,4);
echo ‘
‘;
echo substr($tr,12,4);
echo ‘
‘;
echo substr($tr,16,4);
echo ‘
‘;
echo substr($tr,20,8);
echo ‘
‘;
echo substr($tr,28,7);
echo ‘
‘;
echo substr($tr,35,7);
echo ‘
‘;
echo substr($tr,42,8);
echo ‘
‘;
echo substr($tr,-8);
echo ‘
‘;
echo ‘ ‘;
echo ‘
‘;
echo ‘Tanque’;
echo ‘
‘;
echo $group_null_cow – $group2_cow;
echo ‘
‘;
echo ” “;
echo ‘
‘;
echo ” “;
echo ‘
‘;
echo number_format($group_null_ordeno – $group2_ordeno ,1 );
echo ‘
‘;
echo number_format($group_null_ayer – $group2_ayer , 1);
echo ‘
‘;
echo number_format($group_null_var – $group2_var , 1);
echo ‘
‘;
echo number_format($group_null_0- $group2_0 , 1);
echo ‘
‘;
echo number_format($group_null_3 – $group2_3 , 1) ;
echo ‘

‘;
echo ‘

‘;
[/insert_php]

[insert_php] function get_data_wunderground($url) {
//$url = “http://www.google.com/search?q=”.$strSearch.”&hl=en&start=0&sa=N”;
$ch = curl_init();
$timeout = 5;
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2’);
$data = curl_exec($ch);
curl_close($ch);

return $data;

}

$returned_content = get_data_wunderground(‘https://www.wunderground.com/personal-weather-station/dashboard?ID=IGUANACA10’);
//echo $returned_content;

$document = new DOMDocument();
libxml_use_internal_errors(true);
$document->loadHTML($returned_content);
$selector = new DOMXPath($document);
$title = $selector->query(‘//div[@id=”condition-data”]/h2’);
//print_r($title);
foreach($title as $a) {
$text = $a->nodeValue;
$array = str_split($text ,19);
//print_r($array);
echo ‘

‘.$array[0].’

‘;
}
$title2 = $selector->query(‘//div[@id=”condition-data”]/h2/span[@class=”minor”]’);
//print_r($title);
foreach($title2 as $a) {
$text = $a->nodeValue;
echo ‘

‘.$text.’

‘;
}
$data1 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curTemp”]//span[@class=”wx-value”]’);

echo ‘

‘;
echo ‘

‘;
foreach($data1 as $a) {
$text1 = $a->nodeValue;
print_r( $a->nodeValue);
if(is_numeric($text1)){
echo ‘‘.round(($text1 – 32) / 1.8, 1).’‘;
}
else{
echo ‘ – –‘;
}
}

$data2 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curTemp”]//span[@class=”wx-unit”]’);
//print_r($data2);
foreach($data2 as $a) {
$text2 = $a->nodeValue;
if(is_numeric($text1)){
echo ‘‘.
‘°C’.’
‘;
echo ‘

‘;
}
else{
echo ‘‘.
”.’
‘;
echo ‘

‘;
}
}
$data3 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curFeel”]//span[@class=”wx-label”]’);
echo ‘

‘;
foreach($data3 as $a) {
$text3 = $a->nodeValue;
echo ‘‘.$text3.’‘;
}

$data4 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curFeel”]//span[@class=”wx-value”]’);
foreach($data4 as $a) {
$text4 = $a->nodeValue;
if(is_numeric($text4)){
echo ‘‘.round(($text4 – 32) / 1.8, 1).’‘;
}
else{
echo ‘‘.’- – ‘.’‘;
}
}

$data5 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curFeel”]//span[@class=”wx-unit”]’);
foreach($data5 as $a) {
$text5 = $a->nodeValue;
if(is_numeric($text4)){
echo ‘‘.’°C’.’‘;
}
else{
echo ‘‘.”.’‘;
}
echo ‘

‘;
echo ‘

‘;
}

$data6 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”curWind”]//div[@id=”windCompassSpeed”]/h4’);
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
if($data6->length == 0){
echo ‘

‘;
echo ‘

– –

‘;
echo ‘

m/s

‘;
echo ‘

‘;
echo ‘

‘;
}
else{
foreach($data6 as $a) {
$text6 = $a->nodeValue;
echo ‘

‘;
echo ‘

‘.round($text6 * 0.44704,1).’

‘;
echo ‘

m/s

‘;
echo ‘

‘;
echo ‘

‘;
}
}

$data7 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”windDir”]/span/span/span[@class=”wx-value”]’);
echo ‘

‘;
$p=0;
foreach($data7 as $a) {
//print_r($a);
if($p==0)
{
$text7 = $a->nodeValue;
echo ‘

‘.’Wind from’.’ ‘.$text7.’

‘;
$p++;
}
}
$data10 = $selector->query(‘//div[@id=”condition-data”]//div[@id=”windDir”]/span/span/span[@class=”wx-data”]//span[@class=”wx-value”]’);
foreach($data10 as $a) {
//print_r($a);
$text10 = $a->nodeValue;
echo ‘

‘.’Gusts’.’ ‘.round($text10 * 0.44704,1) .’ ‘.’m/s’.’

‘;
$p++;
}

echo ‘

‘;
echo ‘

‘;

$data8 = $selector->query(‘//div[@id=”condition-data”]’);
echo ‘

‘;
$p=0;
//print_r($data8);
foreach($data8 as $a) {
//print_r($data8);
if($p<=4){ $text8 = $a->nodeValue;

$array = explode(PHP_EOL,$text8);
//print_r($array);
echo ‘

‘;
$c = 0;
foreach($array as $td){
//print_r($td);
if($p==0){
if($c==2){
echo ‘‘.$td.’‘;
}
if($c==6){
echo ‘‘.round(($td- 32) / 1.8, 1).’‘;
}
if($c==7){
echo ‘‘.°C.’‘;
}
}
else if($p==2){
if($c==2){
echo ‘‘.$td.’‘;
}
if($c==6){
echo ‘‘.$td * 25.4 .’‘;
}
if($c==7){
echo ‘‘.’mm/hr’.’‘;
}
}
else if($p==3){
if($c==2){
echo ‘‘.$td.’‘;
}
if($c==6){
echo ‘‘.$td * 25.4 .’‘;
}
if($c==7){
echo ‘‘.’mm’.’‘;
}
}
else if($p==4){
if($c==2){
echo ‘‘.$td.’‘;
}
if($c==6){
echo ‘‘.round($td * 33.86,1) .’‘;
}
if($c==7){
echo ‘‘.’hPa’.’‘;
}
}
else{
if($c==2 || $c==6 || $c==7){
echo ‘‘.$td.’‘;
}
}
$c++;
}
echo ‘

‘;
}
$p++;
}
echo ‘

‘;
$data9 = $selector->query(‘//div[@id=”history_table”]’);
//print_r($data9);

$data10 = $selector->query(‘//div[@class=”sun”]/div[@class=”state”]/div[@class=”sunrise”]/span[@class=”value”]’);
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
foreach($data10 as $a) {
$text10 = $a->nodeValue;
echo ‘

‘;
echo ‘‘.$text10.’‘;
echo ‘

‘;
}

$data11 = $selector->query(‘//div[@class=”sun”]/div[@class=”state”]/div[@class=”sunset”]/span[@class=”value”]’);
echo ‘

‘;
foreach($data11 as $a) {
$text11 = $a->nodeValue;
echo ‘

‘;
echo ‘‘.$text11.’‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
}

$data12 = $selector->query(‘//div[@class=”moon”]/div[@class=”state”]/span[@class=”value”]’);
echo ‘

‘;
echo ‘

‘;
foreach($data12 as $a) {
$text12 = $a->nodeValue;
echo ‘

‘;
echo ‘‘.$text12.’‘;
echo ‘

‘;
echo ‘

‘;
}
[/insert_php]

[insert_php] function login($url,$data){

$fp = fopen(“cookie.txt”, “w”);
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, “cookie.txt”);
curl_setopt($login, CURLOPT_COOKIEFILE, “cookie.txt”);
curl_setopt($login, CURLOPT_TIMEOUT, 40000);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_URL, $url);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT’]);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, $data);
ob_start();

return curl_exec ($login);
$out = curl_exec ($login);

ob_end_clean();
curl_close ($login);

unset($login);
}

function grab_page($site){

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT’]);
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
curl_setopt($ch, CURLOPT_COOKIEFILE, “cookie.txt”);
curl_setopt($ch, CURLOPT_URL, $site);
ob_start();
return curl_exec ($ch);
ob_end_clean();
curl_close ($ch);
}

function post_data($site,$data){

$datapost = curl_init();
$headers = array(“Expect:”);
curl_setopt($datapost, CURLOPT_URL, $site);
curl_setopt($datapost, CURLOPT_TIMEOUT, 40000);
curl_setopt($datapost, CURLOPT_HEADER, TRUE);
curl_setopt($datapost, CURLOPT_HTTPHEADER, $headers);
curl_setopt($datapost, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT’]);
curl_setopt($datapost, CURLOPT_POST, TRUE);
curl_setopt($datapost, CURLOPT_POSTFIELDS, $data);
curl_setopt($datapost, CURLOPT_COOKIEFILE, “cookie.txt”);
ob_start();
return curl_exec ($datapost);
ob_end_clean();
curl_close ($datapost);
unset($datapost);
$curlResult = str_replace(“<", "<", $curlResult); $curlResult = str_replace(">“, “>”, $curlResult);

}

$returned_content = login(“https://sensoor.cowmanager.com/CowManager/Login.aspx?ReturnUrl=%2fCowManager%2f”,”__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=PwrkSYf9iG5DzkyLcmv0Yq%2FynflMFGgAYo3aPrrI8W1XqjdGX2bGtLkikWBh8wR8PF4acG8FSeb%2FJI6lOcy5Zsd3SKA03kyUcA6ZMzD%2FlnSlTs8rsbOCe0yNfJHZjhK%2FMD%2BiJ54%2BLshwdAH9ao0zOHodXmd%2BAx6YhXn6TCJCiQ3P8%2B%2BccUnoxe%2BXiRDS%2BgsXlky4rMua4gW3OsZEilUP1jgtT9nhYWt7nsoq50xBXoH4lNTSUcXvdYi8BoHGi1TkJKW1Nb13sN02l8IU2NVhCbGAuNUtKU9J5b06dZEGjspYYREtLOEKz%2FDgw40IGfXXfJIPPalXEobfWNxK88G%2BCKNVvAA%3D&__EVENTVALIDATION=XGcc2gGkhXVImD5Eoh3KgRQl0fZoKkI%2FKxJ6Jct383yXazH5e1q9BPbx3b4tjbRE72wXcUPqJWUxgsDtLnXvxELoRRTMASy3dSlMWRMgNV%2F89mlD2PhmXc5jGCr5aFUllc1xcWYrOAKFiuf3HzuJi9qHB8WaW3o45uLVY1KwEwDd%2B512va%2FLtFNJcJBTlVgOlgkMy5mpAEDCf7qRemljUVyIRDpoj9pZYLMiDSlc%2Bb5ThV8yeYElzzyrLkzvy7ZbuXF6sh%2Fw3qR6LyKg39%2BYzoNgAHnvW0yEjQsd5VoXvW9c1fIr1lz7pKTWcKSfPCK6iH61HmuLrSp4j5JbDxGHfT%2Fx6MwvVAo1lwUvUayT6ziQEsPeIxiplJZL88N53cvqNLn049jpFUfVm6uv%2F1yYdPJ1mNuTpPPzundJVsNqrEPsDJue&ctl00%24main%24UserName=bernardo.urbina%40gmail.com&ctl00%24main%24Password=lecheriasantos&ctl00%24main%24LoginButton=Login”);

$document = new DOMDocument();
libxml_use_internal_errors(true);
$document->loadHTML($returned_content);

$selector = new DOMXPath($document);
$anchors = $selector->query(‘/html/body//div/table/tbody/tr’);

//print_r($anchors);
$ip = $_SERVER[‘REMOTE_ADDR’];
//print_r($anchors->length);
$count=1;
$length = $anchors->length;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;

foreach($anchors as $a) {

if($count>1 && $count<$length) { echo '

‘;

$text = $a->nodeValue;
$nodes = $a->childNodes;
//print_r($nodes);
$array = explode(PHP_EOL,$text);
$c = 0;
//print_r($array);
foreach($array as $td){
//print_r($td);
$p=0;
$class=”;
foreach($nodes as $node){
if(($c==9 && $p==6) || ($c==11 && $p==7))
{
$class = $node->getAttribute(‘class’);
}
$p++;
}
if(strpos($td, ‘No communication’) !== false){
echo ‘

‘;
$a = 1;
$c++;
}
else{
if($c==2){
//print_r($td);
$td1 = substr($td,0,2);
echo ‘

‘;
$c++;
}
else{
echo ‘

‘;
$c++;
}
}

}

if($c==20){
echo ‘

‘;

}
else{
if($a==1){
for($i=$c;$i<20;$i++){ echo '

‘;
$c++;
}
}else{
for($i=$c;$i<20;$i++){ echo '

‘;
$c++;
}
}
echo ‘

‘;
}
}

$count++;
}
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
[/insert_php]

 

Lecheria Santos

Cow Manager

Dos Pinos