Форум

Навигация Форума
Вы должны войти, чтобы создавать сообщения и темы.

Неполадки со скриптом php

Здравствуйте, имеется скрипт парсер погоды от яндекса:

С недавнего времени он работать перестал, вероятно яндекс погода заблочило мой айпи хостинга ... не могу понять почему

Возможно версия php на хостинге например изменилась..

Скрипт тут http://ideone.com/oaizUe


<?php
$city_id = 28666; //id &#208;&#179;&#208;&#190;&#209;
&#128;&#208;&#190;&#208;&#180;
&#208;°, &#208;&#178;&#208;&#191;&#208;
&#184;&#209;&#129;&#208;°&#209
;&#130;&#209;&#140; &#209;&#129;&#208;&#178;&#208;
&#190;&#208;&#185;, &#208;&#188;&#208;&#190;&#208;
¶&#208;&#189;&#208;&#190; &#209;&#131;&#208;·&#208;&#189
;&#208;°&#209;&#130;&#209;&#14
0; &#209;&#130;&#209;&#131;&#209;
&#130; https://p...content-available-to-author-only..
.x.ru/static/cities.xml - &#208;&#191;&#208;°&#209;&#128
;&#208;°&#208;&#188;&#208;µ&#2
09;&#130;&#209;&#128; city id=
$cache_lifetime = 7200; //&#208;&#178;&#209;&#128;&#20
8;µ&#208;&#188;&#209;&#143; &#208;&#186;&#209;&#141;&#209;
&#136;&#208;° &#209;&#132;&#208;°&#208;&#185
;&#208;»&#208;° &#208;&#178; &#209;&#129;&#208;µ&#208;&#186
;&#209;&#131;&#208;&#189;&#208
;&#180;&#208;°&#209;&#133;, 3600=1 &#209;&#135;&#208;°&#209;&#129
;
$cache_file = 'weather_'.$city_id.'.xml'; // &#208;&#178;&#209;&#128;&#208;
µ&#208;&#188;&#208;µ&#208;&#18
9;&#208;&#189;&#209;&#139;&#20
8;&#185; &#209;&#132;&#208;°&#208;&#185
;&#208;»-&#208;&#186;&#209;&#1
41;&#209;&#136;

function loadxmlyansex($city_id)
{
$url = 'http://e...content-available-to-author-on
ly...x.ru/weather-ng/forecasts/'.$city_id.&#39
;.xml';
$userAgent = 'Googlebot/2.1 (+http://www.google.com/bot.html)'
;
$xml = 'weather_'.$city_id.'.xml';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
$output = curl_exec($ch);
$fh = fopen($xml, 'w');
fwrite($fh, $output);
fclose($fh);
}

if ( file_exists($cache_file) ) {
$cache_modified = time() - @filemtime($cache_file);
if ( $cache_modified > $cache_lifetime )

{
//&#208;&#190;&#208;±&#208;&#1
89;&#208;&#190;&#208;&#178;&#2
08;»&#209;&#143;&#208;µ&#208;&
#188; &#209;&#132;&#208;°&#208;&#185
;&#208;» &#208;&#191;&#208;&#190;&#208;
&#179;&#208;&#190;&#208;&#180;
&#209;&#139;, &#208;µ&#209;&#129;&#208;»&#20
8;&#184; &#208;&#178;&#209;&#128;&#208;
µ&#208;&#188;&#209;&#143; &#209;&#132;&#208;°&#208;&#185
;&#208;»&#208;° &#208;&#186;&#209;&#141;&#209;
&#136;&#208;° &#209;&#131;&#209;&#129;&#209;
&#130;&#208;°&#209;&#128;&#208
;µ&#208;»&#208;&#190;
loadxmlyansex($city_id);
}
}
else {
//&#208;µ&#209;&#129;&#208;»&#
208;&#184; &#208;&#189;&#208;µ&#209;&#130
; &#209;&#132;&#208;°&#208;&#185
;&#208;»&#208;° &#208;&#191;&#208;&#190;&#208;
&#179;&#208;&#190;&#208;&#180;
&#209;&#139; &#208;&#178;&#208;&#190;&#208;
&#190;&#208;±&#209;&#137;&#208
;µ, &#208;·&#208;°&#208;&#186;&#20
8;°&#209;&#135;&#208;&#184;&#2
08;&#178;&#208;°&#208;µ&#208;&
#188; &#208;µ&#208;&#179;&#208;&#190
;
loadxmlyansex($city_id);
}
?>
<?php
if(file_exists($cache_file)):
$data = simplexml_load_file($cache_file); ?>
<style type="text/css">
.weather .date{font-size:13px;font-weight:700;paddi
ng-bottom:5px;text-transform:uppercase;bor
der-bottom:1px solid #d5d5d5;margin-top:10px;}
.weather .item{background-color:#DAD9D5;padding:15p
x;font-family:Georgia;margin-bottom:20px;}

.weather .item table{border:0;width:100%;}
.weather .item table td{padding-bottom:15px;width:20%;vertical-
align:baseline;padding-right:5px;}
.weather .item .day-part td{font-size:18px;}
.weather .item .day-temp td{font-size:30px;}
.weather .item .day-temp td img{margin-left:5px;}
.weather .item .day-param td{font-size:12px;}
.weather .item .day-param td p{padding-bottom:3px;}
.weather .days{margin-top:35px;border:0;width:1
00%;}
.weather .days td{width:50%;padding-bottom:35px;}
.weather .days a{font-family:Georgia;font-size:18px;text-
decoration:underline;font-weight:700;}

.tabs input[type=radio] {
position: absolute;
top: -9999px;
left: -9999px;
}
.tabs {
width: 700px;
float: right;
list-style: none;
position: relative;
padding: 0;
font-family: "Georgia";
}
.tabs li{
float: left;
}
.tabs label {
display: block;
padding: 10px 8px;
border-radius: 2px 2px 0 0;
color: #000;
font-size: 18px;
font-weight: normal;
font-family: 'Lily Script One', helveti;
background: rgba(255,255,255,0.2);
cursor: pointer;
position: relative;
top: 3px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.tabs label:hover {
background: rgba(255,255,255,0.5);
top: 0;
}
[id^=tab]:checked + label {
background: rgba(0,153,204,1);
color: white;
}
[id^=tab]:checked ~ [id^=tab-content] {
display: block;
}
.tab-content{
z-index: 2;
display: none;
text-align: left;
width: 100%;
font-size: 20px;
line-height: 140%;
padding-top: 10px;
background: rgba(0,153,204,1);
padding: 15px;
color: white;
position: absolute;
top: 53px;
left: 0;
box-sizing: border-box;
-webkit-animation-duration: 0.5s;
-o-animation-duration: 0.5s;
-moz-animation-duration: 0.5s;
animation-duration: 0.5s;
}</style><div class="weather"><ul class="tabs"><?php
foreach($data->day as $day):?>
<li><?php $s6=$s6+1;?><input type="radio"
<?php if($s6==1) echo "checked";
else
echo "";?> name="tabs" id="tab<?php echo $s1=$s1+1;?>">
<label for="tab<?php echo $s2=$s2+1;?>"><div class="date"><?php echo getDayDate($day['date']);?
></div></label>
<div id="tab-content<?php echo $s3=$s3+1;?>" class="tab-content animated fadeIn">
<div class="item"><table><tr class="day-part"><td>&#208
;&#163;&#209;&#130;&#209;&#128
;&#208;&#190;&#208;&#188;</td&
#62;<td>&#208;&#148;&#208;&amp
;#189;&#208;µ&#208;&#188;</td>
<td>&#208;&#146;&#208;µ&#2
09;&#135;&#208;µ&#209;&#128;&#
208;&#190;&#208;&#188;</td>&#6
0;td>&#208;&#157;&#208;&#190;&
amp;#209;&#135;&#209;&#140;&#209;&
amp;#142;</td>
</tr><tr class="day-temp"><?php for($i = 0;$i < 4;$i++): // &#209;&#130;.&#208;&#186;. &#208;&#189;&#208;°&#208;&#188
; &#208;&#189;&#208;µ &#208;&#189;&#209;&#131;&#208;
¶&#208;&#189;&#209;&#139; &#208;&#180;&#208;°&#208;&#189
;&#208;&#189;&#209;&#139;&#208
;µ day_short &#208;&#184; night_short, &#208;&#188;&#209;&#139; &#208;&#190;&#209;&#129;&#209;
&#130;&#208;°&#208;&#189;&#208
;°&#208;&#178;&#208;»&#208;&#1
84;&#208;&#178;&#208;°&#208;µ&
#208;&#188; &#208;&#191;&#209;&#128;&#208;
&#190;&#209;&#133;&#208;&#190;
&#208;&#180; &#208;&#189;&#208;° 4
$img = $day->day_part[$i]->{'image-v3
'};?><td><?php echo getTempSign($day->day_part[$i]-&#6
2;{'temperature-data'}->avg);?&#62
; &#194;°C <img src="pogoda/<?php echo $img;?>.png" width="48" height="48" /></td><?php endfor;?>
</tr><tr class="day-param"><?php for($i = 0;$i < 4;$i++): // &#209;&#130;.&#208;&#186;. &#208;&#189;&#208;°&#208;&#188
; &#208;&#189;&#208;µ &#208;&#189;&#209;&#131;&#208;
¶&#208;&#189;&#209;&#139; &#208;&#180;&#208;°&#208;&#189
;&#208;&#189;&#209;&#139;&#208
;µ day_short &#208;&#184; night_short, &#208;&#188;&#209;&#139; &#208;&#190;&#209;&#129;&#209;
&#130;&#208;°&#208;&#189;&#208
;°&#208;&#178;&#208;»&#208;&#1
84;&#208;&#178;&#208;°&#208;µ&
#208;&#188; &#208;&#191;&#209;&#128;&#208;
&#190;&#209;&#133;&#208;&#190;
&#208;&#180; &#208;&#189;&#208;° 4?>
<td><p><strong><?php echo $day->day_part[$i]->weather_type;?
></strong></p><p>&
#208;&#178;&#208;µ&#209;&#130;&amp
;#208;µ&#209;&#128;: <?php echo getWindDirection($day->day_part[$i&#93
;->wind_direction).' '.$day->day_part[$i]->wind_spe
ed;?> &#208;&#188;/&#209;&#129;</p&#
62;
<p>&#208;&#178;&#208;»&#20
8;°&#208;¶&#208;&#189;&#208;&#
190;&#209;&#129;&#209;&#130;&#
209;&#140;: <?php echo $day->day_part[$i]->humidity;?&#62
;%</p><p>&#208;&#180;&
#208;°&#208;&#178;&#208;»&#208;µ&a
mp;#208;&#189;&#208;&#184;&#208;µ&
#58; <?php echo $day->day_part[$i]->pressure;?&#62
; &#208;&#188;&#208;&#188; &#209;&#128;&#209;&#130;. &#209;&#129;&#209;&#130;.</p&#
62;
</td><?php endfor;?></tr></table></di
v></div></li><?php
endforeach;?>
</ul></div>
<?php
endif;
// &#208;&#191;&#208;&#190;&#208;
»&#209;&#131;&#209;&#135;&#208
;°&#208;µ&#208;&#188; &#208;»&#208;&#190;&#208;&#186
;&#208;°&#208;»&#208;&#184;&#2
08;·&#208;&#190;&#208;&#178;&#
208;°&#208;&#189;&#208;&#189;&
#209;&#131;&#209;&#142; &#208;&#180;&#208;°&#209;&#130
;&#209;&#131;
function getDayDate($date)
{
$date = strtotime($date);
$months = array('','/01','/02',&
#39;/03','/04','/05','/06&
#39;,'/07','/08','/09',&#3
9;/10','/11','/12');
$days = array('&#208;&#146;&#208;&
#161;','&#208;&#159;&#208;&amp
;#157;', '&#208;&#146;&#208;&#162;'
, '&#208;&#161;&#208; ', '&#208;§&#208;&#162;', '&#208;&#159;&#208;&#162;'
, '&#208;&#161;&#208;&#145;'
);
return $days[date('w', $date)].', '.(int)date('d',$date)
.' '.$months[date('n', $date)];
}
// &#208;&#191;&#208;&#190;&#208;
»&#209;&#131;&#209;&#135;&#208
;°&#208;µ&#208;&#188; &#208;·&#208;&#189;&#208;°&#20
8;&#186; &#209;&#130;&#208;µ&#208;&#188
;&#208;&#191;&#208;µ&#209;&#12
8;&#208;°&#209;&#130;&#209;&#1
31;&#209;&#128;&#209;&#139;
function getTempSign($temp)
{
$temp = (int)$temp;
return $temp > 0 ? '+'.$temp : $temp;
}
// &#208;&#191;&#208;&#190;&#208;
»&#209;&#131;&#209;&#135;&#208
;°&#208;µ&#208;&#188; &#208;&#189;&#208;°&#208;&#191
;&#209;&#128;&#208;°&#208;&#17
8;&#208;»&#208;µ&#208;&#189;&#
208;&#184;&#209;&#143; &#208;&#178;&#208;µ&#209;&#130
;&#209;&#128;&#208;°
function getWindDirection($wind)
{
$wind = (string)$wind;
$wind_direction = array('s'=>'&#8593; &#209;&#142;','n'=>'&a
mp;#8595; &#209;&#129;','w'=>'&a
mp;#8594; &#208;·','e'=>'&#8592;
&#208;&#178;','sw'=>'&
amp;#8599; &#209;&#142;&#208;·','se'=
>'&#8598; &#209;&#142;&#208;&#178;',&#39
;nw'=>'&#8600; &#209;&#129;&#208;·','ne'=
>'&#8601; &#209;&#129;&#208;&#178;')
;
return $wind_direction[$wind];
}
?>

что за адрес такой $url в функции loadxmlyansex ?
есть права чтобы создать фаил $cache_file ?

Цитата: BeerMan
что за адрес такой $url в функции loadxmlyansex ?
есть права чтобы создать фаил $cache_file ?

Хз хз

вот отсюда скрипт брал
Ссылка

Авторизация
*
*
Регистрация
*
*
*
Генерация пароля
Буксы, программирование, криптовалюта
Обзор конфиденциальности

На этом сайте используются файлы cookie, что позволяет нам обеспечить наилучшее качество обслуживания пользователей. Информация о файлах cookie хранится в вашем браузере и выполняет такие функции, как распознавание вас при возвращении на наш сайт и помощь нашей команде в понимании того, какие разделы сайта вы считаете наиболее интересными и полезными.