2019-02-06 18:34:51 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
|
|
|
|
* Atom feeds for websites that don't have one.
|
|
|
|
*
|
|
|
|
* For the full license information, please view the UNLICENSE file distributed
|
|
|
|
* with this source code.
|
|
|
|
*
|
|
|
|
* @package Core
|
|
|
|
* @license http://unlicense.org/ UNLICENSE
|
|
|
|
* @link https://github.com/rss-bridge/rss-bridge
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ListAction extends ActionAbstract {
|
|
|
|
public function execute() {
|
|
|
|
$list = new StdClass();
|
|
|
|
$list->bridges = array();
|
|
|
|
$list->total = 0;
|
|
|
|
|
2019-06-18 18:55:29 +02:00
|
|
|
$bridgeFac = new \BridgeFactory();
|
|
|
|
$bridgeFac->setWorkingDir(PATH_LIB_BRIDGES);
|
2019-02-06 18:34:51 +01:00
|
|
|
|
2019-06-18 18:55:29 +02:00
|
|
|
foreach($bridgeFac->getBridgeNames() as $bridgeName) {
|
|
|
|
|
|
|
|
$bridge = $bridgeFac->create($bridgeName);
|
2019-02-06 18:34:51 +01:00
|
|
|
|
|
|
|
if($bridge === false) { // Broken bridge, show as inactive
|
|
|
|
|
|
|
|
$list->bridges[$bridgeName] = array(
|
|
|
|
'status' => 'inactive'
|
|
|
|
);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-06-18 18:55:29 +02:00
|
|
|
$status = $bridgeFac->isWhitelisted($bridgeName) ? 'active' : 'inactive';
|
2019-02-06 18:34:51 +01:00
|
|
|
|
|
|
|
$list->bridges[$bridgeName] = array(
|
|
|
|
'status' => $status,
|
|
|
|
'uri' => $bridge->getURI(),
|
|
|
|
'name' => $bridge->getName(),
|
|
|
|
'icon' => $bridge->getIcon(),
|
|
|
|
'parameters' => $bridge->getParameters(),
|
|
|
|
'maintainer' => $bridge->getMaintainer(),
|
|
|
|
'description' => $bridge->getDescription()
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$list->total = count($list->bridges);
|
|
|
|
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
echo json_encode($list, JSON_PRETTY_PRINT);
|
|
|
|
}
|
|
|
|
}
|