1
0
Fork 0
forked from blallo/rss-bridge

enable proxy usage for individual bridge

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-07-03 23:11:28 +02:00
parent b43e8ef689
commit 3dd63ab6fd
3 changed files with 24 additions and 7 deletions

View file

@ -100,7 +100,7 @@ try{
// whitelist control // whitelist control
if(!Bridge::isWhitelisted($whitelist_selection, $bridge)) { if(!Bridge::isWhitelisted($whitelist_selection, $bridge)) {
throw new \HttpException('This bridge is not whitelisted', 401); throw new \HttpException('This bridge is not whitelisted', 401);
die; die;
} }
$cache = Cache::create('FileCache'); $cache = Cache::create('FileCache');
@ -111,6 +111,10 @@ try{
} else { } else {
$bridge->setCache($cache); // just add disable cache to your query to disable caching $bridge->setCache($cache); // just add disable cache to your query to disable caching
} }
if(isset($_REQUEST['_p'])){
$bridge->useProxy=true;
}
$bridge->setDatas($_REQUEST);
$bridge->loadMetadatas(); $bridge->loadMetadatas();
$bridge->setDatas($_REQUEST); $bridge->setDatas($_REQUEST);
// Data transformation // Data transformation

View file

@ -21,6 +21,7 @@ abstract class BridgeAbstract implements BridgeInterface{
public $uri = ""; public $uri = "";
public $description = 'No description provided'; public $description = 'No description provided';
public $maintainer = 'No maintainer'; public $maintainer = 'No maintainer';
public $useProxy = false;
public $parameters = array(); public $parameters = array();
/** /**
@ -111,7 +112,7 @@ abstract class BridgeAbstract implements BridgeInterface{
), ),
); );
if(defined('PROXY_URL')) { if(defined('PROXY_URL') && $this->useProxy) {
$contextOptions['http']['proxy'] = PROXY_URL; $contextOptions['http']['proxy'] = PROXY_URL;
$contextOptions['http']['request_fulluri'] = true; $contextOptions['http']['request_fulluri'] = true;

View file

@ -28,6 +28,12 @@ CARD;
$card .= HTMLUtils::getFormHeader($bridgeName); $card .= HTMLUtils::getFormHeader($bridgeName);
if ($isActive){ if ($isActive){
if(defined('PROXY_URL')){
$idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode('proxy') . '-' . urlencode('_p');
$card .= '<input id="' . $idArg . '" type="checkbox" name="_p" />' . PHP_EOL;
$card .= '<label for="' .$idArg. '">Enable proxy ('.PROXY_URL.')</label><br />' . PHP_EOL;
}
$card .= HTMLUtils::getHelperButtonsFormat($formats); $card .= HTMLUtils::getHelperButtonsFormat($formats);
} else { } else {
$card .= '<span style="font-weight: bold;">Inactive</span>'; $card .= '<span style="font-weight: bold;">Inactive</span>';
@ -40,13 +46,13 @@ CARD;
if($hasGlobalParameter) if($hasGlobalParameter)
$globalParameters = json_decode($bridgeElement->parameters['global'], true); $globalParameters = json_decode($bridgeElement->parameters['global'], true);
foreach($bridgeElement->parameters as $parameterName => $parameter){ foreach($bridgeElement->parameters as $parameterName => $parameter){
$parameter = json_decode($parameter, true); $parameter = json_decode($parameter, true);
if(!is_numeric($parameterName) && $parameterName == 'global') if(!is_numeric($parameterName) && $parameterName == 'global')
continue; continue;
if($hasGlobalParameter) if($hasGlobalParameter)
$parameter = array_merge($parameter, $globalParameters); $parameter = array_merge($parameter, $globalParameters);
@ -82,7 +88,7 @@ CARD;
$card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL; $card .= '<input ' . $additionalInfoString . ' id="' . $idArg . '" type="number" value="' . $inputEntry['defaultValue'] . '" placeholder="' . $inputEntry['exampleValue'] . '" name="' . $inputEntry['identifier'] . '" /><br />' . PHP_EOL;
} else if($inputEntry['type'] == 'list') { } else if($inputEntry['type'] == 'list') {
$card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . $inputEntry['identifier'] . '" >'; $card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . $inputEntry['identifier'] . '" >';
foreach($inputEntry['values'] as $listValues) { foreach($inputEntry['values'] as $listValues) {
if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value']) if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value'])
$card .= '<option value="' . $listValues['value'] . '" selected>' . $listValues['name'] . '</option>'; $card .= '<option value="' . $listValues['value'] . '" selected>' . $listValues['name'] . '</option>';
@ -100,11 +106,17 @@ CARD;
} }
if ($isActive){ if ($isActive){
if(defined('PROXY_URL')){
$idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode('proxy') . '-' . urlencode('_p');
$card .= '<input id="' . $idArg . '" type="checkbox" name="_p" />' . PHP_EOL;
$card .= '<label for="' .$idArg. '">Enable proxy ('.PROXY_URL.')</label><br />' . PHP_EOL;
}
$card .= HTMLUtils::getHelperButtonsFormat($formats); $card .= HTMLUtils::getHelperButtonsFormat($formats);
} else { } else {
$card .= '<span style="font-weight: bold;">Inactive</span>'; $card .= '<span style="font-weight: bold;">Inactive</span>';
} }
$card .= '</form>' . PHP_EOL; $card .= '</form>' . PHP_EOL;
} }
@ -161,7 +173,7 @@ class HTMLSanitizer {
$element->outertext = ''; $element->outertext = '';
} else { } else {
foreach($element->getAllAttributes() as $attributeName => $attribute) { foreach($element->getAllAttributes() as $attributeName => $attribute) {
if(!in_array($attributeName, $this->keptAttributes)) if(!in_array($attributeName, $this->keptAttributes))
$element->removeAttribute($attributeName); $element->removeAttribute($attributeName);
} }
} }