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:
parent
b43e8ef689
commit
3dd63ab6fd
3 changed files with 24 additions and 7 deletions
|
@ -100,7 +100,7 @@ try{
|
|||
// whitelist control
|
||||
if(!Bridge::isWhitelisted($whitelist_selection, $bridge)) {
|
||||
throw new \HttpException('This bridge is not whitelisted', 401);
|
||||
die;
|
||||
die;
|
||||
}
|
||||
|
||||
$cache = Cache::create('FileCache');
|
||||
|
@ -111,6 +111,10 @@ try{
|
|||
} else {
|
||||
$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->setDatas($_REQUEST);
|
||||
// Data transformation
|
||||
|
|
|
@ -21,6 +21,7 @@ abstract class BridgeAbstract implements BridgeInterface{
|
|||
public $uri = "";
|
||||
public $description = 'No description provided';
|
||||
public $maintainer = 'No maintainer';
|
||||
public $useProxy = false;
|
||||
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']['request_fulluri'] = true;
|
||||
|
||||
|
|
|
@ -28,6 +28,12 @@ CARD;
|
|||
$card .= HTMLUtils::getFormHeader($bridgeName);
|
||||
|
||||
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);
|
||||
} else {
|
||||
$card .= '<span style="font-weight: bold;">Inactive</span>';
|
||||
|
@ -40,13 +46,13 @@ CARD;
|
|||
|
||||
if($hasGlobalParameter)
|
||||
$globalParameters = json_decode($bridgeElement->parameters['global'], true);
|
||||
|
||||
|
||||
foreach($bridgeElement->parameters as $parameterName => $parameter){
|
||||
$parameter = json_decode($parameter, true);
|
||||
|
||||
if(!is_numeric($parameterName) && $parameterName == 'global')
|
||||
continue;
|
||||
|
||||
|
||||
if($hasGlobalParameter)
|
||||
$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;
|
||||
} else if($inputEntry['type'] == 'list') {
|
||||
$card .= '<select ' . $additionalInfoString . ' id="' . $idArg . '" name="' . $inputEntry['identifier'] . '" >';
|
||||
|
||||
|
||||
foreach($inputEntry['values'] as $listValues) {
|
||||
if($inputEntry['defaultValue'] === $listValues['name'] || $inputEntry['defaultValue'] === $listValues['value'])
|
||||
$card .= '<option value="' . $listValues['value'] . '" selected>' . $listValues['name'] . '</option>';
|
||||
|
@ -100,11 +106,17 @@ CARD;
|
|||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
$card .= '<span style="font-weight: bold;">Inactive</span>';
|
||||
}
|
||||
|
||||
|
||||
$card .= '</form>' . PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -161,7 +173,7 @@ class HTMLSanitizer {
|
|||
$element->outertext = '';
|
||||
} else {
|
||||
foreach($element->getAllAttributes() as $attributeName => $attribute) {
|
||||
if(!in_array($attributeName, $this->keptAttributes))
|
||||
if(!in_array($attributeName, $this->keptAttributes))
|
||||
$element->removeAttribute($attributeName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue