doti3/bar/src/rss.php
2017-12-15 17:43:15 +01:00

36 lines
637 B
PHP
Executable file

#!/usr/bin/php
<?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);
$fullText = sprintf('[%s] %s', $title, $count = count($matches));
$blockButton = (int) getenv('BLOCK_BUTTON');
if ($blockButton === 1) {
shell_exec('xdg-open https://tiny.deblan.org/index.php');
}
echo block(
'rss',
[
'full_text' => $fullText,
'color' => $count ? color('normal') : color('info'),
]
);