Skip to content

Commit

Permalink
Added proxy configuration dashboard widgets (RSS)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matic Šulc committed Mar 28, 2024
1 parent d8767ef commit ea8dd3f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions core/src/Revolution/Processors/System/Dashboard/Widget/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public function loadFeed($url)
$this->modx->cacheManager->writeTree($cachePath);
}

$proxy_config = $this->buildProxyOptions();
if (!empty($proxy_config)) {
$feed->set_curl_options($proxy_config);
}

$feed->set_cache_location($cachePath);
$feed->set_useragent($this->modx->getVersionData()['full_version']);
$feed->set_feed_url($url);
Expand Down Expand Up @@ -115,4 +120,28 @@ public function getFileChunk($tpl, array $placeholders = [])

return $output;
}

/**
* Build configuration for the SimplePie client based on configuration settings.
*
* @return array The proxy configuration.
*/
private function buildProxyOptions()
{
$config = [];
$proxyHost = $this->modx->getOption('proxy_host', null, '');
if (!empty($proxyHost)) {
$config['CURLOPT_PROXY'] = $proxyHost;
$proxyPort = $this->modx->getOption('proxy_port', null, '');
if (!empty($proxyPort)) {
$config['CURLOPT_PROXY'] .= ':' . $proxyPort;
}
$proxyUsername = $this->modx->getOption('proxy_username', null, '');
if (!empty($proxyUsername)) {
$proxyPassword = $this->modx->getOption('proxy_password', null, '');
$config['CURLOPT_PROXYUSERPWD'] = $proxyUsername . ':' . $proxyPassword;
}
}
return $config;
}
}

0 comments on commit ea8dd3f

Please sign in to comment.