doti3/bar/src/rss.php

43 lines
828 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;
$title = $argv[2] ?? null;
if (empty($rss) || empty($title)) {
die;
}
$content = @file_get_contents($rss);
if (empty($content)) {
die;
}
preg_match_all('/<entry/isU', $content, $matches, PREG_SET_ORDER);
2019-01-21 16:20:04 +01:00
$title = IntlChar::chr(0xf09e);
$count = count($matches);
if ($count > 0) {
$title .= ' +'.$count;
}
$fullText = span(' '.$title.' ', $count ? color('normal') : color('info'), '#333'); // sprintf('[%s] %s', $title, $count = count($matches));
2017-12-04 18:17:42 +01:00
$blockButton = (int) getenv('BLOCK_BUTTON');
if ($blockButton === 1) {
2018-01-03 13:53:49 +01:00
shell_exec('xdg-open "https://tiny.deblan.org/index.php"');
2017-12-04 18:17:42 +01:00
}
2017-12-15 17:43:15 +01:00
echo block(
'rss',
[
'full_text' => $fullText,
2019-01-21 16:20:04 +01:00
// 'color' => $count ? color('normal') : color('info'),
2017-12-15 17:43:15 +01:00
]
);