- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
<!-- saved from url=(0014)about:internet -->
<?php
define('WEATHER_FILE_3_DAYS', '/meteoparse/weather.xml');
define('WEATHER_URL_3_DAYS', 'http://pogoda.by/xml2/xml-kstati.by.php');
define('BASE_PATH', $_SERVER['DOCUMENT_ROOT']);
define('DAYS_COUNT', 3);
require_once('include/weather_tools.php');
if (date('d.m.Y.h', filectime(BASE_PATH . WEATHER_FILE_3_DAYS)) != date('d.m.Y.h')) {
copy(WEATHER_URL_3_DAYS, BASE_PATH . WEATHER_FILE_3_DAYS);
}
$file = file_get_contents ('weather.xml');
$xmlWeather = simplexml_load_string($file);
$aXmlForecasts = $xmlWeather->xpath('/pogoda/CITY/FORECAST');
$aWeather = array();
$curDay = 0;
foreach($aXmlForecasts as $xmlForecast) {
$attrs = $xmlForecast->attributes();
$date = $attrs->day . '-' .
$attrs->month . '-' .
$attrs->year;
$hour = strval($attrs->hour);
if (!array_key_exists($date, $aWeather)) {
$curDay++;
if ($curDay > DAYS_COUNT) break;
$aWeather[$date] = array();
}
if (!array_key_exists($hour, $aWeather[$date])) {
$aWeather[$date][$hour] = array();
}
foreach($xmlForecast as $property => $values) {
$aWeather[$date][$hour][$property] = '';
$valuesAttr = $values->attributes();
foreach($valuesAttr as $value) {
$aWeather[$date][$hour][$property] .= strval($value);
}
}
}
foreach($aWeather as $dateKey => $date) {
foreach ($date as $hourKey => $hour) {
$aWeather[$dateKey][$hourKey]['DAYTIME'] = getDayTime($hourKey);
$aWeather[$dateKey][$hourKey]['PHENOMENA'] = getPhenomeaUrl($hour['PHENOMENA']);
$aWeather[$dateKey][$hourKey]['WIND'] = getWind($hour['WIND']);
}
}
?>
<td colspan="<?php echo count($aWeather); ?>">
<?php foreach ($aWeather as $date => $hours) : ?>
<table id="<?php echo 'table' . $date; ?>" class="hide">
<tr class="attrs">
<th></th>
<th></th>
<th>Давление</th>
<th>t, °С</th>
<th>Ветер</th>
</tr>
<?php foreach($hours as $hour => $properties) : ?>
<tr>
<td><?php echo $properties['DAYTIME']; ?></td>
<td><img src="<?php echo $properties['PHENOMENA']; ?>" /></td>
<td class="param"><?php echo $properties['PRESSURE']; ?> гПа </td>
<td class="param1"><?php echo $properties['TEMPERATURE']; ?> °C</td>
<td class="param"><?php echo $properties['WIND']; ?>  (м/с)</td>
</tr>
<?php endforeach; ?>
</table>
<?php endforeach; ?>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
var weatherBox = document.getElementById('weatherBox');
weatherBox.getElementsByTagName('table')[0].getElementsByTagName('table')[0].className = "show";
</script>
Lure Of Chaos 07.12.2010 23:20 # 0
долго ржал
pogoda.by засветился сорцами
brainstorm 08.12.2010 09:55 # 0
Владельцам сайтов, желающих размещать погоду в формате XML, рекомендуется связаться с администрацией сайта.
можно не связываться. ок.
Lure Of Chaos 08.12.2010 15:26 # 0
skif 12.12.2010 20:38 # 0
skif, pogoda.by
bugmenot 12.12.2010 20:45 # 0
skif 12.12.2010 21:23 # 0