doti3/bar/src/rss.php

40 lines
657 B
PHP
Raw Normal View History

2019-01-21 16:20:04 +01:00
#!/usr/bin/php7.1
2017-12-04 18:17:42 +01:00
<?php
require __DIR__.'/base/block.php';
$rss = $argv[1] ?? null;
2019-01-28 11:13:11 +01:00
$client = $argv[2] ?? null;
2017-12-04 18:17:42 +01:00
2019-01-28 11:13:11 +01:00
if (empty($rss)) {
2017-12-04 18:17:42 +01:00
die;
}
$content = @file_get_contents($rss);
if (empty($content)) {
die;
}
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
2019-01-28 11:13:11 +01:00
$title = pemoji(0xf09e);
2019-01-21 16:20:04 +01:00
$count = count($matches);
if ($count > 0) {
$title .= ' +'.$count;
}
2019-01-28 11:13:11 +01:00
$fullText = span($title, $count ? color('normal') : color('info'), '#333');
2017-12-04 18:17:42 +01:00
2019-01-28 11:13:11 +01:00
if ($client && (int) getenv('BLOCK_BUTTON') === 1) {
shell_exec(sprintf('xdg-open %s', escapeshellarg($client)));
2017-12-04 18:17:42 +01:00
}
2017-12-15 17:43:15 +01:00
echo block(
'rss',
[
'full_text' => $fullText,
]
);