64 lines
2.3 KiB
PHP
64 lines
2.3 KiB
PHP
<?php
|
|
require "vendor/autoload.php";
|
|
use PHPHtmlParser\Dom;
|
|
|
|
$dom = new Dom;
|
|
$period = strtotime("1 week ago");
|
|
$formatter = new IntlDateFormatter( 'ru', IntlDateFormatter::LONG, IntlDateFormatter::NONE );
|
|
|
|
function printGame($url, $title, $author, $description = '') {
|
|
echo "<li><a href='$url'>«".$title."»</a> — $author";
|
|
if ($description) {
|
|
echo "<br>$description";
|
|
}
|
|
echo "</li>\n";
|
|
}
|
|
|
|
echo "<h4> Apero </h4>\n";
|
|
$dom->loadFromUrl('http://apero.ru/');
|
|
$games = $dom->find('.tabled-game-block');
|
|
foreach ($games as $game) {
|
|
$date = trim($game->find('.game-updated-block')->innerHtml, "() \t\n\r\0\x0B");
|
|
$date = $formatter->parse($date);
|
|
if ($date < $period) continue;
|
|
$author = trim($game->find('.game-author-block')[0]->find('a')->innerHtml);
|
|
$title = trim($game->find('h2')[0]->find('a')[0]->innerHtml);
|
|
$url = trim($game->find('h2')[0]->find('a')[0]->getAttribute('href'));
|
|
$description = trim($game->find('.game-desc-block')[0]->innerHtml);
|
|
printGame($url, $title, $author, $description);
|
|
}
|
|
|
|
function insteadfeed($url) {
|
|
global $dom, $period, $formatter;
|
|
$dom->loadFromUrl($url);
|
|
$games = $dom->find('.game');
|
|
foreach ($games as $game) {
|
|
$date = trim($game->find('.b .date b')->innerHtml);
|
|
$date = DateTime::createFromFormat('Y.m.d', $date);
|
|
$date = $date->format('U');
|
|
if ($date < $period) continue;
|
|
$author = str_replace(trim($game->find('span.author')->innerHtml), 'Автор: ', '');
|
|
$title = trim($game->find('h2')[0]->find('a')[0]->innerHtml);
|
|
$url = trim($game->find('h2')[0]->find('a')[0]->getAttribute('href'));
|
|
$description = "";
|
|
printGame($url, $title, $author, $description);
|
|
}
|
|
}
|
|
echo "<h4> Неофициальный INSTEAD репозиторий </h4>\n";
|
|
insteadfeed("http://instead-games.ru/");
|
|
echo "<h5> Песочница </h5>\n";
|
|
insteadfeed("http://instead-games.ru/index.php?approved=0");
|
|
|
|
echo "<h4> Storymaze </h4>\n";
|
|
$api = file_get_contents('http://storymaze.ru/api/stories/search?count=10&offset=0&asc=');
|
|
$api = json_decode($api, TRUE);
|
|
foreach ($api as $game) {
|
|
$date = strtotime($game['publishStart']);
|
|
if ($date < $period) continue;
|
|
$title = $game['name'];
|
|
$url = "http://storymaze.ru/story/view/".$game['id'].".html";
|
|
$description = $game['description'];
|
|
$author = $game['authorName'];
|
|
printGame($url, $title, $author, $description);
|
|
}
|