<?php
$file_data = file_get_contents('./data/date.test');
if ($file_data != ceil(time()/100)) {
$news = file_get_contents('https://api.vk.com/method/wall.get?owner_id=-206341834&count=16&v=5.131&access_token=f419d8f6f419d8f6f419d8f62df46105f6ff419f419d8f695141acece2a70a4b6f260c0');
file_put_contents('./data/date.test', ceil(time()/100));
file_put_contents('./data/cache.test', $news);
$news = json_decode(file_get_contents('./data/cache.test'), true)['response'];
} else {
$news = json_decode(file_get_contents('./data/cache.test'), true)['response'];
}
$id = 0;
foreach($news['items'] as $n) {
$id++;
foreach($n['attachments'] as $item) {
$img = $item['photo']['sizes']['width = 604'];
}
if ($n['views']['count'] < 1)
$n['views']['count'] = 0;
$content = mb_strimwidth($n['text'], 0, 350, "...");
$contents = strstr($content, '!');
$contentnews = substr($n['text'], 0, strpos($content, '.' ));
echo '<div class="block-container"> ';
echo '<div class="block-container__name mb-2"><div class="text-b"><span></span>'.$contentnews.' </div></div> ';
echo '<div class="poster"> <a target="_blank" href="https://vk.com/testworld_games?w=wall-191598884_'.$n['id'].'"><div class="scale"><img class="xfieldimage foto" src="'.$img.'" alt=""></a></div></div> ';
echo '<p class="description"> '.$contents.' </p> <br> ';
echo '<div class="button-game waves-effect">';
echo '<a onclick="load_page(start);" class="button-game__header"><img src=".$img." alt=""><span></span>Подробнее</a> ';
echo '</div>';
echo '<span class="time-data">'.date('d.m.Y в H:i',$n['date']).'</span> ';
echo '<span class="time-data">Просмотров: '. $n['views']['count'] .'</span> ';
echo '<span class="time-data">Коментариев: '. $n['comments']['count'] .'</span> ';
echo '</div>';
}