> /dev/null 2>&1 //i posava els resultats a la taula kini.temps (elimino) //per tornar resultats: select lloc,web,dayname(data_web),hour(hora_web),avg(delay) from kini.temps where (lloc<>'Sweetgrass' and web='CAN (CAN)') or (lloc='Sweetgrass' and web='USA') group by lloc,web,dayname(data_web),hour(hora_web) order by lloc,hour(hora_web); //assumeixo que USA posen fraccions minuts en decimals (p.e. 1.25 hores passo a 75 minuts), potser no és així però no vindrà d'aquí if($ok==1){ $web="USA"; $a=file_get_contents('http://apps.cbp.gov/bwt/'); $lloc="Pacific Highway"; $b=explode($lloc,$a); $c=explode("",$b[1]); list($mes, $dia, $any) = split('[/.-]', substr($c[1],strpos($c[1],"
")+5)); $d=explode("
",$c[6]); $hora=trim(substr(substr($d[0],-8),0,2)); $uni=substr(substr($d[0],-6),0,2); if($hora=="No") {$hora=12;$uni="zz";} if($hora=="Mi") {$hora=0;$uni="am";} if($uni=="pm") {$hora=$hora+12;} $min="00"; $delay0=trim(substr($d[1],0,strpos($d[1],"delay")-1)); $delay1=substr($delay0,0,strpos($delay0," ")); if(strpos($delay1,".")==true) {$delay1=(substr($delay1,0,strpos($delay1,"."))*60) + (substr($delay1,strpos($delay1,".")+1)/100*60);} if($delay0=="no") {$delay1=0;} $lines=substr($d[2],0,1); include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $lloc="Peace Arch"; $b=explode($lloc,$a); $c=explode("",$b[1]); list($mes, $dia, $any) = split('[/.-]', substr($c[1],strpos($c[1],"
")+5)); $d=explode("
",$c[6]); $hora=trim(substr(substr($d[0],-8),0,2)); $uni=substr(substr($d[0],-6),0,2); if($hora=="No") {$hora=12;$uni="zz";} if($hora=="Mi") {$hora=0;$uni="am";} if($uni=="pm") {$hora=$hora+12;} $min="00"; $delay0=trim(substr($d[1],0,strpos($d[1],"delay")-1)); $delay1=substr($delay0,0,strpos($delay0," ")); if(strpos($delay1,".")==true) {$delay1=(substr($delay1,0,strpos($delay1,"."))*60) + (substr($delay1,strpos($delay1,".")+1)/100*60);} if($delay0=="no") {$delay1=0;} $lines=substr($d[2],0,1); include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $lloc="Sweetgrass"; $b=explode($lloc,$a); $c=explode("",$b[1]); list($mes, $dia, $any) = split('[/.-]', substr($c[1],strpos($c[1],"
")+5)); $d=explode("
",$c[6]); $hora=trim(substr(substr($d[0],-8),0,2)); $uni=substr(substr($d[0],-6),0,2); if($hora=="No") {$hora=12;$uni="zz";} if($hora=="Mi") {$hora=0;$uni="am";} if($uni=="pm") {$hora=$hora+12;} $min="00"; $delay0=trim(substr($d[1],0,strpos($d[1],"delay")-1)); $delay1=substr($delay0,0,strpos($delay0," ")); if(strpos($delay1,".")==true) {$delay1=(substr($delay1,0,strpos($delay1,"."))*60) + (substr($delay1,strpos($delay1,".")+1)/100*60);} if($delay0=="no") {$delay1=0;} $lines=substr($d[2],0,1); include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (CAN)"; $a=file_get_contents('http://www.cbsa-asfc.gc.ca/general/times/menu-e.html'); $lloc="Pacific Highway"; $b=explode($lloc,$a); $c=explode("",$b[1]); $e=explode("
",$c[0]); list($any, $mes, $dia, $any) = split('[/.-]', substr(strip_tags($e[3]),0,10)); list($hora,$min) = split('[:]', substr(substr(strip_tags($e[3]),-9),0,5)); $delay0=trim(strip_tags($c[3])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0;} $lines=99; include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (US)"; $delay0=trim(strip_tags($c[4])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0;} include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (CAN)"; $lloc="Peace Arch"; $b=explode($lloc,$a); $c=explode("",$b[1]); $e=explode("
",$c[0]); list($any, $mes, $dia, $any) = split('[/.-]', substr(strip_tags($e[3]),0,10)); list($hora,$min) = split('[:]', substr(substr(strip_tags($e[3]),-9),0,5)); $delay0=trim(strip_tags($c[3])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0;} $lines=99; include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (US)"; $delay0=trim(strip_tags($c[4])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0; } include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (CAN)"; $lloc="Sweet Grass"; $b=explode($lloc,$a); $lloc="Sweetgrass"; $c=explode("",$b[1]); $e=explode("
",$c[0]); list($any, $mes, $dia, $any) = split('[/.-]', substr(strip_tags($e[2]),0,10)); list($hora,$min) = split('[:]', substr(substr(strip_tags($e[2]),-9),0,5)); $delay0=trim(strip_tags($c[3])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0;} $lines=99; include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; $web="CAN (US)"; $delay0=trim(strip_tags($c[4])); if(strpos($delay0,"hou")==true && strpos($delay0,"min")==true) {$delay1=substr($delay0,0,strpos($delay0," "))*60+substr($delay0,strpos($delay0," ",strpos($delay0,"hour"))+1,2);} else {$delay1=substr($delay0,0,strpos($delay0," "));} if($delay0=="No delay") {$delay1=0;} include "/var/www/xxxxx.php"; $insert = mysql_query("INSERT INTO temps (web,lloc,data_ara,hora_ara,data_web,hora_web,delay,linies) VALUES ('$web','$lloc',CURRENT_DATE,CURRENT_TIME,'$any-$mes-$dia','$hora:$min','$delay1','$lines')",$conexion) or die(mysql_Error()); include "/var/www/xxxxx.php"; } ?>