Esempio n. 1
0
                $copied = copyWUfile();
            }
        }
        if (is_file($WUcacheFile) and $WUrequest != $thisMonth and $WUrequest < $thisMonth) {
            // for rebuild incomplete old this month cache; extra if for better performance
            if (filemtime($WUcacheFile) < $endOfMonth) {
                // determine if is cache file complete
                $copied = copyWUfile();
            }
        }
        if ($tMonthCache and $WUrequest == $thisMonth and @filemtime($WUcacheFile) + $tMonthCacheT * 3600 < time()) {
            // then create this month cache file
            $copied = copyWUfile();
        }
    } else {
        $copied = copyWUfile();
    }
} else {
    // without caching
    $WUcacheFile = $WUsourceFile;
}
$dayscm = $WUrequest < $thisMonth ? $daysInMonth : date('j');
// Average month Baro
if ($calcMbaroAvg && $dataSource != 'mysql') {
    // create baro output
    $ambFile = $WUcacheDir . $WUID . '-month-ab-' . $year . $month . '.txt';
    // same must be in WUG-parser-d.php
    if (is_file($ambFile)) {
        $avgBaro = substr(file_get_contents($ambFile), 0, -1);
    } else {
        $avgBaro = "";
Esempio n. 2
0
 // test ./WUG-settings.php in root
 $pgRoot = substr(realpath(dirname(__FILE__)), 0, -10);
 // eg: /home/dir/www/WUG-settings.php (removed 'wxwugraphs/')
 $bsErr = is_file($pgRoot . 'WUG-settings.php') ? 'Error: Probably you have file WUG-settings.php in root dir. of your website - this may causing errors in wu graphs.<br>' : '';
 // test for "allow_url_fopen"
 if (!ini_get('allow_url_fopen') && $dataSource != 'mysql') {
     $baseErr = 'You have disabled allow_url_fopen on your server/webhosting so WU Graphs cannot download graph data. This is critical error. You can try to enable "<i>Alternative URL fopen<i/>" in <a href="configurator.php" target="_blank">WU Graphs configurator</a>';
 }
 // test whole get WU data process
 if ($writableFlag and $_GET['complex'] == "1") {
     $unitsLnk = $metric ? 'metric' : 'english';
     $opts = array('http' => array('method' => 'GET', 'header' => 'Cookie: Units=' . $unitsLnk));
     $context = stream_context_create($opts);
     $WUcacheFile = $WUcacheDir . '/test-url-fopen.txt';
     $WUsourceFile = 'http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=' . $WUID . '&graphspan=month&year=' . date('j') . '&year=' . date('Y') . '&month=' . date('n') . '&format=1&units=' . $unitsLnk;
     copyWUfile();
     // is cache file empty???
     if ('' == @file_get_contents($WUcacheFile)) {
         // file is empty
         $aufErr = 'Error: Unspecified error in the data acquisition. You can try set $sendAgent value in WUG-settings.php to <b>true</b>.<br>';
     } else {
         $aufErr = '<span style="color: green;">No error was detected during a comprehensive test.</span><br />';
     }
 } elseif (!$writableFlag and $_GET['complex'] == "1") {
     $aufErr = 'For this test must be cache directory (configured in WUG-settings.php) writable for PHP. (chmod 777)';
 } else {
     $aufErr = '';
 }
 // PHP version test
 if (strnatcmp(phpversion(), '5.0.0') >= 0) {
     $phpVerNfo = '<span style="color: green;"> - O.K.</span>';