this is my first posting and I'd like to say thanks in advance to anyone who can help me out here
I have two sets of code which need to update once a day (updates cols.php) at around 08:00am GMT.
I'm not sure how to implement this.....If anyone could help me with a change to the code I'd be most grateful
Code: Select all
<?php
include("cols.php");
if(date("m",$last_updated)!=date("m")||date("d",$last_updated)!=date("d")||date("Y",$last_updated)!=date("Y")){
$content=file_get_contents("http://horses.sportinglife.com/Naps_Table");
$needle="<th class=\"napHdr\" style=\"padding-left:0px;\">Selection";
$start=strpos($content,$needle);
if($start>0){
$needle="<tr>";
$start=strpos($content,$needle,$start)+strlen($needle);
$needle="</table>";
$end=strpos($content,$needle,$start);
$content=substr($content,$start,$end-$start);
$rows=explode("<tr>",$content);
$needle=array('<span style="font-weight:bold">','</span>','<a','>','</a>','<div style="font-weight:bold">','</div>','</td>');
unset($col1,$col2,$col3,$col4);
for($i=0,$n=count($rows);$i<$n;$i++){
$offset=0;
$content=$rows[$i];
$offset=$start=strpos($content,$needle[0],$offset)+strlen($needle[0]);
$offset=$end=strpos($content,$needle[1],$offset);
$lenght=$end-$start;
$col2[$i]=substr($content,$start,$lenght);
$offset=$start=strpos($content,$needle[2],$offset)+strlen($needle[2]);
$offset=$start=strpos($content,$needle[3],$offset)+strlen($needle[3]);
$offset=$end=strpos($content,$needle[4],$offset);
$lenght=$end-$start;
$col1[$i]=substr($content,$start,$lenght);
$offset=$start=strpos($content,$needle[5],$offset)+strlen($needle[5]);
$offset=$end=strpos($content,$needle[6],$offset);
$lenght=$end-$start;
$col3[$i]=substr($content,$start,$lenght);
$start=$end+strlen($needle[6]);
$offset=$end=strpos($content,$needle[7],$offset);
$lenght=$end-$start;
$col4[$i]=substr($content,$start,$lenght);
}
$last_updated=time(); $file="<?php
\$last_updated=".time().";\n";
for($i=0;$i<$n;$i++){
$file.="\$col1[".$i."]=\"".$col1[$i]."\";\n";
$file.="\$col2[".$i."]=\"".$col2[$i]."\";\n";
$file.="\$col3[".$i."]=\"".$col3[$i]."\";\n";
$file.="\$col4[".$i."]=\"".$col4[$i]."\";\n";
}
$file.="?>";
$fp=fopen("cols.php","w+");
fwrite($fp,$file,strlen($file));
fclose($fp);
}else{
$n=count($col1);
}
}else{
$n=count($col1);
}
?>thanks