getBasename(), array('.', '..'))) continue; elseif ($cacheFile->isFile()) { if( filemtime($cacheFile->getPathname()) < $cacheTimeLimit ) unlink( $cacheFile->getPathname() ); } } } // default whitelist $whitelist_file = './whitelist.txt'; $whitelist_default = array( "BandcampBridge", "CryptomeBridge", "DansTonChatBridge", "DuckDuckGoBridge", "FacebookBridge", "FlickrExploreBridge", "GooglePlusPostBridge", "GoogleSearchBridge", "IdenticaBridge", "InstagramBridge", "OpenClassroomsBridge", "PinterestBridge", "ScmbBridge", "TwitterBridge", "WikipediaENBridge", "WikipediaEOBridge", "WikipediaFRBridge", "YoutubeBridge"); if (!file_exists($whitelist_file)) { $whitelist_selection = $whitelist_default; $whitelist_write = implode("\n", $whitelist_default); file_put_contents($whitelist_file, $whitelist_write); } else { $whitelist_selection = explode("\n", file_get_contents($whitelist_file)); array_pop($whitelist_selection); } // whitelist control function function BridgeWhitelist( $whitelist, $name ) { if(in_array("$name", $whitelist) or in_array("$name.php", $whitelist)) return TRUE; else return FALSE; } try{ require_once __DIR__ . '/lib/RssBridge.php'; Bridge::setDir(__DIR__ . '/bridges/'); Format::setDir(__DIR__ . '/formats/'); Cache::setDir(__DIR__ . '/caches/'); if( isset($_REQUEST) && isset($_REQUEST['action']) ){ switch($_REQUEST['action']){ case 'display': if( isset($_REQUEST['bridge']) ){ unset($_REQUEST['action']); $bridge = $_REQUEST['bridge']; unset($_REQUEST['bridge']); $format = $_REQUEST['format']; unset($_REQUEST['format']); // whitelist control if(!BridgeWhitelist($whitelist_selection, $bridge)) { throw new \HttpException('This bridge is not whitelisted', 401); die; } $cache = Cache::create('FileCache'); // Data retrieval $bridge = Bridge::create($bridge); if(isset($_REQUEST["disable_cache"])) { } else { $bridge->setCache($cache); // just add disable cache to your query to disable caching } $bridge->setDatas($_REQUEST); $bridge->loadMetadatas(); // Data transformation try { $format = Format::create($format); $format ->setDatas($bridge->getDatas()) ->setExtraInfos(array( 'name' => $bridge->getName(), 'uri' => $bridge->getURI(), )) ->display(); } catch(Exception $e) { echo "The brige has crashed. You should report this to the bridges maintainer"; } die; } break; } } } catch(HttpException $e){ header('HTTP/1.1 ' . $e->getCode() . ' ' . Http::getMessageForCode($e->getCode())); header('Content-Type: text/plain'); die($e->getMessage()); } catch(\Exception $e){ die($e->getMessage()); } function getHelperButtonFormat($value, $name){ return ''; } function getHelperButtonsFormat($formats){ $buttons = ''; foreach( $formats as $name => $infos ) { if ( isset($infos['name']) ) { $buttons .= getHelperButtonFormat($name, $infos['name']) . PHP_EOL; } } return $buttons; } function displayBridgeCard($bridgeName, $formats, $isActive = true) { $bridgeElement = Bridge::create($bridgeName); if($bridgeElement == false) { return ""; } $bridgeElement->loadMetadatas(); $name = ''.$bridgeElement->name.''; $description = $bridgeElement->description; $card = <<

{$name}

{$description}

CARD; // If we don't have any parameter for the bridge, we print a generic form to load it. if(count($bridgeElement->parameters) == 0) { $card .= '
' . PHP_EOL; if ($isActive) { $card .= getHelperButtonsFormat($formats); } else { $card .= 'Inactive'; } $card .= '
' . PHP_EOL; } foreach($bridgeElement->parameters as $parameterName => $parameter) { $card .= '
    ' . PHP_EOL; if(!is_numeric($parameterName)) { $card .= '
    '.$parameterName.'
    ' . PHP_EOL; } $card .= '
    ' . PHP_EOL; $parameter = json_decode($parameter, true); foreach($parameter as $inputEntry) { if(!isset($inputEntry['exampleValue'])) $inputEntry['exampleValue'] = ""; $idArg = 'arg-' . $bridgeName . '-' . $parameterName . '-' . $inputEntry['identifier']; $card .= '' . PHP_EOL; if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text') { $card .= '
    ' . PHP_EOL; } else if($inputEntry['type'] == 'number') { $card .= '
    ' . PHP_EOL; } else if($inputEntry['type'] == 'list') { $card .= '
    '; } else if($inputEntry['type'] == 'checkbox') { $card .= '
    ' . PHP_EOL; } } if ($isActive) { $card .= getHelperButtonsFormat($formats); } else { $card .= 'Inactive'; } $card .= '
    ' . PHP_EOL; } $card .= ''.$bridgeElement->maintainer.''; $card .= ''; return $card; } $formats = Format::searchInformation(); ?> RSS-Bridge

    RSS-Bridge

    ·Reconnecting the Web·

    ' . $inactiveBridges; ?>