Project

General

Profile

Feature #31818 ยป class.t3lib_div.php.diff

Michel Nederlof, 2011-11-15 14:21

View differences:

class.t3lib_div.php (working copy)
*************************/
/**
* Checks the proxy blacklist, if found, returns true
*
* @param string $url The URL to be checked (host will be extracted from here)
* @return boolean
*/
protected static function inProxyBlackList($url) {
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyBlackList'])) return false;
$urlParts = parse_url($url);
if (!isset($urlParts['host']) || empty($urlParts['host'])) return false;
$hostParts = array_reverse(self::trimExplode('.', $urlParts['host'], 1));
foreach(explode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyBlackList']) as $hostName) {
$parts = array_reverse(self::trimExplode(".", $hostName, 1));
$partsMatch = 0;
foreach($parts as $index => $hostNamePart) {
if ($hostParts[$index] == $hostNamePart) $partsMatch++;
else if ($hostNamePart == '*') {
$partsMatch += 99;
}
}
if ($partsMatch >= count($hostParts)) return true;
}
return true;
}
/**
* Reads the file or url $url and returns the content
* If you are having trouble with proxys when reading URLs you can configure your way out of that with settings like $TYPO3_CONF_VARS['SYS']['curlUse'] etc.
* Usage: 83
......
}
// (Proxy support implemented by Arco <arco@appeltaart.mine.nu>)
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) {
if (!self::inProxyBlacklist($url) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) {
curl_setopt($ch, CURLOPT_PROXY, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']);
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel']) {
    (1-1/1)