$out .= "Content-Length: " . strlen($parts['query']) . "\r\n"; $out .= "Connection: Close\r\n\r\n"; if (isset($parts['query'])) { $out .= $parts['query']; } fwrite($fp, $out); fclose($fp); return true; } } // PARSE GRAPH DATA if ($dataSource == 'mysql' || $dataSource == 'wutowdmysql' && $timeStampImput > $WDsinceTS) { require 'wdmysql-d.php'; } else { require 'WUG-parser-d.php'; parse_wu_day($WUcacheFile, $year, $month, $day); // Output is global var. $JSdata // $cRow is global in parse_wu_day if ($cRow <= 1) { // we need at least two values for drawing a line in graph if ($WUrequest == $Today) { $emptyGraph = true; } else { $emptyGraphTP = true; } } } // php copy with context parameter started up to version 5.3.0 (and it may be problematic for many people...) so must be enough fopen ... function copyWUfile() { global $WUsourceFile, $context, $WUcacheFile, $fopenOff;
$WUcacheFile2 = $dirCont . '/' . $WUID . '-day-' . $cYear . $cMnth . zero_bd($cDay) . '.txt'; ## cache file creation $opts = array('http' => array('method' => 'GET', 'header' => 'Cookie: Units=' . $unitsLnk)); $context = stream_context_create($opts); // context HEADER with cookie for changing units if ($fopenOff) { include './fopener.php'; $read = new HTTPRequest($WUsourceFile2); $wsource2 = $read->DownloadToString(); } else { $wsource2 = file_get_contents($WUsourceFile2, 0, $context); } $ctarget2 = fopen($WUcacheFile2, "w"); fwrite($ctarget2, $wsource2); fclose($ctarget2); parse_wu_day($WUcacheFile2, $cYear, $cMnth, zero_bd($cDay), true); // for calculation a creation Average baro, solar and wind cache files $cpEnd = $cron ? true : false; // at once in WU pages and more steps in cron mode given by $cronFiles in WU-precache.php $sbl++; //echo '<br>copied<br>'; continue; } else { $fileExists++; } // create flag file for completed month if ($fileExists == $chckMdays + 1 and !$uncompMonth) { $comfil = fopen($dirCont . "/" . $WUID . "-completed.txt", "w"); fwrite($comfil, "This month is completely cached."); fclose($comfil); }