$xdays*24*3600 ){ $myfile = fopen("loadlog.txt", "a") or die("could not open 'loadlog.txt'"); $mline = sprintf("\n%s\n", date("F d Y H:i:s: ", time())); $mline = sprintf("%s %s", $mline, $f[1]); $monfile = fopen($mmfil, "a") or die("could not open fil"); for ($i=1; $i<=2; $i++){ $mf[$i] = sprintf("%s.temp", $f[$i]); if(!copy($ef[$i], $mf[$i])) printf("Copy feilet
\n"); $mfile = fopen($mf[$i], "r") or die("could not open fil"); $lc=0; while(! feof($mfile) ) //******************FIL************* { $linje= fgets($mfile); $mkol = explode(",", $linje); $year = $mkol[0]; $mon = $mkol[1]; $days=0; $sumice=0; while (strcmp($mkol[1], $mon)==0 && !feof($myfile)){ $sumice += $mkol[3]; $days++; $linje= fgets($mfile); $mkol = explode(",", $linje); } // $monyear = $year + round(($mon-0.5)/12, 3); if($days>0){ $ice = $sumice/$days; }else{ $ice = "null"; } if($i==1){ $ar1[$lc][0]=$year; $ar1[$lc][1]=$mon; $ar1[$lc][2]=$ice; $ar1[$lc][3]=$days; }else { if($year == $ar1[$lc][0] && $mon == $ar1[$lc][1]){ $monline= sprintf("%s %s %s %s %s %s %s\n", $year, $mon, $ar1[$lc][2], $ar1[$lc][3], $ice, $days, $ar1[$lc][2]+$ice); }else{ $monline = sprintf("year=%s lc= %d ar1=%s mon=%s arm=%s\n", $year, $lc, $ar1[$lc][0], $mon, $ar1[$lc][1]); } } $lc++; // $monline= sprintf("%s %s %s %s\n", $year, $mon, $ice, $days); if($monline > "1900" && $monline < "3000") fwrite($monfile, $monline); }// while fclose($mfile); } // for fclose($monfile); $wl = fwrite($myfile, $mline); copy($mmfil, $f[3]); printf("Line=%s
\n", $mline); if($wl ==0) printf("Feil i Write to log
Line=%s", $mline); else printf("Antall byte skrevet = %d
\n", $wl); fclose ($myfile); } //if ?>